2 ** Project : Form Designer
3 ** File Purpose : QLayout Control
5 ** Author : Mahmoud Fayed <msfclipper@yahoo.com>
10 class FormDesigner_QLayout from QLabel
12 CreateCommonAttributes()
13 CreateMoveResizeCornersAttributes()
21 func SetLayoutTypeValue Value
24 func LayoutObjectsValue
27 func SetLayoutObjectsValue cValue
28 cLayoutObjects = cValue
30 func AddObjectProperties oDesigner
31 AddObjectCommonProperties(oDesigner)
32 oDesigner.oView.AddPropertyCombobox(T_FORMDESIGNER_ATTRIBUTE_TYPE,
33 [T_FORMDESIGNER_ATTRIBUTE_VERTICAL,T_FORMDESIGNER_ATTRIBUTE_HORIZONTAL]) # "Type" "Vertical" "Horizontal"
34 oDesigner.oView.AddProperty(T_FORMDESIGNER_ATTRIBUTE_OBJECTSSCOMMA,True) # "Objects (S: Comma)"
36 func DisplayProperties oDesigner
37 DisplayCommonProperties(oDesigner)
38 oPropertiesTable = oDesigner.oView.oPropertiesTable
39 oPropertiesTable.Blocksignals(True)
41 oWidget = oPropertiesTable.cellwidget(C_AFTERCOMMON,1)
42 oCombo = new qCombobox
43 oCombo.pObject = oWidget.pObject
44 oCombo.BlockSignals(True)
45 oCombo.setCurrentIndex(LayoutTypeValue())
46 oCombo.BlockSignals(False)
47 # Set the Layout Objects
48 oPropertiesTable.item(C_AFTERCOMMON+1,1).settext(LayoutObjectsValue())
49 oPropertiesTable.Blocksignals(False)
51 setText(oDesigner.oModel.GetObjectName(self))
53 func UpdateProperties oDesigner,nRow,nCol,cValue
54 UpdateCommonProperties(oDesigner,nRow,nCol,cValue)
57 setLayoutTypeValue(cValue)
58 case C_AFTERCOMMON + 1
59 setLayoutObjectsValue(cValue)
62 setText(oDesigner.oModel.GetObjectName(self))
64 func ComboItemAction oDesigner,nRow
65 nLayoutTypePos = C_AFTERCOMMON
66 if nRow = nLayoutTypePos { # Layout Type
67 oWidget = oDesigner.oView.oPropertiesTable.cellwidget(nLayoutTypePos,1)
68 oCombo = new qCombobox
69 oCombo.pObject = oWidget.pObject
70 nIndex = oCombo.CurrentIndex()
71 setLayoutTypeValue(nIndex)
74 func DialogButtonAction oDesigner,nRow
75 CommonDialogButtonAction(oDesigner,nRow)
77 case C_AFTERCOMMON + 1 # Layout Objects
78 open_window(:WindowObjectsController)
79 Last_Window().setParentObject(oDesigner)
80 Last_Window().setPropertyIndex(C_AFTERCOMMON+1)
81 Last_Window().setMethodName("setLayoutObjectsValue")
82 aList = oDesigner.oModel.GetObjectsNames()
83 # Remove the window Object name
85 # Remove the current layout object name
86 del(aList,std_find(aList,oDesigner.oModel.GetObjectName(self)))
87 Last_Window().LoadObjectsData(aList)
88 Last_Window().LoadSelectedItems()
91 func ObjectDataAsString oDesigner,nTabsCount
92 cOutput = ObjectDataAsString2(oDesigner,nTabsCount)
93 cTabs = std_copy(char(9),nTabsCount)
94 cOutput += "," + nl + cTabs + ' :LayoutType = ' + LayoutTypeValue()
95 cOutput += "," + nl + cTabs + ' :LayoutObjects = "' + oDesigner.PrepareStringForFormFile(LayoutObjectsValue()) + '"'
98 func GenerateCode oDesigner
99 cOutput = char(9) + char(9) +
100 oDesigner.oModel.GetObjectName(self) + " = " +
104 switch LayoutTypeValue() {
106 cClass = "QVBoxLayout"
108 cClass = "QHBoxLayout"
110 cOutput = substr(cOutput,"#{f1}",cClass)
111 cOutput = substr(cOutput,"#{f2}",AddTabs(GenerateCustomCode(oDesigner),3))
114 func GenerateCustomCode oDesigner
116 if LayoutObjectsValue() != NULL {
117 aItems = split(LayoutObjectsValue(),",")
119 if not oDesigner.oModel.GetObjectClassByName(item) = "formdesigner_qlayout" {
120 cOutput += 'AddWidget(#{f1})' + nl
122 cOutput += 'AddLayout(#{f1})' + nl
124 cOutput = substr(cOutput,"#{f1}",Item)
129 func RestoreProperties oDesigner,Item
130 RestoreCommonProperties(oDesigner,item)
131 itemdata = item[:data]
132 setLayoutTypeValue(itemdata[:LayoutType])
133 setLayoutObjectsValue(itemdata[:LayoutObjects])
134 setText(oDesigner.oModel.GetObjectName(self))