Update Form Designer - Better code generation based on the index (start from 0 or 1).
@@ -18,6 +18,8 @@ class FormDesignerCodeGenerator
cClassName = PrepareClassName(cClassName)
cClassName2 = cFormName + "Controller"
cClassName2 = PrepareClassName(cClassName2)
+ # Index start from 1
+ lIndexStartFrom1 = Not oDesigner.oModel.FormObject().IndexTypeValue()
# Add the File Header
cOutput = "# Form/Window View - Generated Source Code File " + nl +
"# Generated by the Ring "+version()+" Form Designer" + nl +
@@ -25,19 +27,29 @@ class FormDesignerCodeGenerator
"# Time : " + time() + nl + nl
# Write general code to show the window
cOutput += 'Load "stdlib.ring"' + nl +
- 'Load "guilib.ring"' + nl + nl +
- 'import System.GUI' + nl + nl +
- "if IsMainSourceFile() { " + nl +
- char(9) + "new App {" + nl +
- char(9) + char(9) + "StyleFusion()" + nl +
+ 'Load "guilib.ring"' + nl + nl
+ if lIndexStartFrom1 {
+ cOutput += 'import System.GUI' + nl + nl
+ cOutput += "if IsMainSourceFile() { " + nl
+ cOutput += char(9) + "new App {" + nl
+ else
+ cOutput += "if IsMainSourceFile() { " + nl
+ cOutput += char(9) + "new qApp {" + nl
+ }
+
+ cOutput += char(9) + char(9) + "StyleFusion()" + nl +
char(9) + char(9) + "new " + cClassName + " { win.show() } " + nl +
char(9) + char(9) + "exec()" + nl +
char(9) + "}" + nl +
"}" + nl + nl
# Write the Class
- cOutput += "class " + cClassName + " from WindowsViewParent" + nl +
- char(9) + "win = new MainWindow() { " + nl +
- GenerateWindowCode(oDesigner) +
+ cOutput += "class " + cClassName + " from WindowsViewParent" + nl
+ if lIndexStartFrom1 {
+ cOutput += char(9) + "win = new MainWindow() { " + nl
+ else
+ cOutput += char(9) + "win = new qMainWindow() { " + nl
+ }
+ cOutput += GenerateWindowCode(oDesigner) +
GenerateObjectsCode(oDesigner) +
GenerateWindowCodeAfterObjects(oDesigner) +
char(9) + "}" + nl + nl
@@ -52,10 +64,10 @@ class FormDesignerCodeGenerator
load "#{f1}View.ring"
-import System.GUI
+#{f4}
if IsMainSourceFile() {
- new App {
+ new #{f5} {
StyleFusion()
open_window(:#{f2})
exec()
@@ -69,6 +81,13 @@ class #{f2} from windowsControllerParent
cOutput = substr(cOutput,"#{f1}",cFormName)
cOutput = substr(cOutput,"#{f2}",cClassName2)
cOutput = substr(cOutput,"#{f3}",cClassName)
+ if lIndexStartFrom1 {
+ cOutput = substr(cOutput,"#{f4}","import System.GUI")
+ cOutput = substr(cOutput,"#{f5}","App")
+ else
+ cOutput = substr(cOutput,"#{f4}","")
+ cOutput = substr(cOutput,"#{f5}","qApp")
+ }
write(cSourceFileName,cOutput)
func PrepareClassName cClassName
