2 ** Project : Form Designer
3 ** File Purpose : Common Attributes and Methods
5 ** Author : Mahmoud Fayed <msfclipper@yahoo.com>
10 class CommonAttributesMethods
13 func CreateCommonAttributes
14 AddAttribute(self,:cTextColor)
15 AddAttribute(self,:cBackColor)
16 AddAttribute(self,:cFontProperty)
17 AddAttribute(self,:cCurrentParentName)
20 cFontProperty = "Arial"
21 cCurrentParentName = "win"
26 func setTextColor cValue
33 func setBackColor cValue
40 func setFontProperty cValue
41 cFontProperty = cValue
42 oFont = new qfont("",0,0,0)
43 oFont.fromstring(cValue)
47 func CurrentParentName
48 return cCurrentParentName
50 func SetCurrentParentName cValue
51 cCurrentParentName = cValue
53 func updatestylesheets
54 setstylesheet("color:"+cTextColor+";background-color:"+cBackColor+";")
56 func AddObjectProperties oDesigner
57 AddObjectCommonProperties(oDesigner)
59 func AddObjectCommonProperties oDesigner
60 oDesigner.oView.AddProperty(T_FORMDESIGNER_ATTRIBUTE_NAME,False) # "Name"
61 oDesigner.oView.AddProperty(T_FORMDESIGNER_ATTRIBUTE_X,False) # "X"
62 oDesigner.oView.AddProperty(T_FORMDESIGNER_ATTRIBUTE_Y,False) # "Y"
63 oDesigner.oView.AddProperty(T_FORMDESIGNER_ATTRIBUTE_WIDTH,False) # "Width"
64 oDesigner.oView.AddProperty(T_FORMDESIGNER_ATTRIBUTE_HEIGHT,False) # "Height"
65 oDesigner.oView.AddProperty(T_FORMDESIGNER_ATTRIBUTE_TEXTCOLOR,True) # "Text Color"
66 oDesigner.oView.AddProperty(T_FORMDESIGNER_ATTRIBUTE_BACKCOLOR,True) # "Back Color"
67 oDesigner.oView.AddProperty(T_FORMDESIGNER_ATTRIBUTE_FONT,True) # "Font"
69 func UpdateProperties oDesigner,nRow,nCol,cValue
70 UpdateCommonProperties(oDesigner,nRow,nCol,cValue)
72 func UpdateCommonProperties oDesigner,nRow,nCol,cValue
76 oDesigner.oModel.SetObjectName(oDesigner,self,cValue)
77 oDesigner.AddObjectsToCombo()
78 # Because we may prevent name change (duplication)
79 DisplayCommonProperties(oDesigner)
85 resize(0+cValue,height())
87 resize(width(),0+cValue)
93 setFontProperty(cValue)
97 func DisplayProperties oDesigner
98 DisplayCommonProperties(oDesigner)
100 func DisplayCommonProperties oDesigner
101 oPropertiesTable = oDesigner.oView.oPropertiesTable
102 oPropertiesTable.Blocksignals(True)
104 oPropertiesTable.item(0,1).settext(
105 oDesigner.oModel.GetObjectName(self))
107 oPropertiesTable.item(1,1).settext(""+x())
109 oPropertiesTable.item(2,1).settext(""+y())
111 oPropertiesTable.item(3,1).settext(""+width())
113 oPropertiesTable.item(4,1).settext(""+height())
115 oPropertiesTable.item(5,1).settext(textcolor())
117 oPropertiesTable.item(6,1).settext(backcolor())
119 oPropertiesTable.item(7,1).settext(fontproperty())
121 oPropertiesTable.Blocksignals(False)
123 func DialogButtonAction oDesigner,nRow
124 CommonDialogButtonAction(oDesigner,nRow)
126 func CommonDialogButtonAction oDesigner,nRow
127 if nRow = 5 { # Text Color
128 cColor = oDesigner.oGeneral.SelectColor()
130 DisplayProperties(oDesigner)
131 elseif nRow = 6 # Back Color
132 cColor = oDesigner.oGeneral.SelectColor()
134 DisplayProperties(oDesigner)
135 elseif nRow = 7 # Font
136 cFont = oDesigner.oGeneral.SelectFont()
137 setFontProperty(cFont)
138 DisplayProperties(oDesigner)
141 func ObjectDataAsString oDesigner,nTabsCount
142 return ObjectDataAsString2(oDesigner,nTabsCount)
144 func ObjectDataAsString2 oDesigner,nTabsCount
145 cTabs = std_copy(char(9),nTabsCount)
146 cOutput = cTabs + " :x = #{f1} , : y = #{f2} , " + nl
147 cOutput += cTabs + " :width = #{f3} , :height = #{f4} , " + nl
148 cOutput += cTabs + ' :textcolor = "#{f5}" , ' + nl
149 cOutput += cTabs + ' :backcolor = "#{f6}" , ' + nl
150 cOutput += cTabs + ' :font = "#{f7}" , ' + nl
151 cOutput += cTabs + ' :parent = "#{f8}" '
152 cOutput = substr(cOutput,"#{f1}",oDesigner.PrepareStringForFormFile(""+x()))
153 cOutput = substr(cOutput,"#{f2}",oDesigner.PrepareStringForFormFile(""+y()))
154 cOutput = substr(cOutput,"#{f3}",oDesigner.PrepareStringForFormFile(""+width()))
155 cOutput = substr(cOutput,"#{f4}",oDesigner.PrepareStringForFormFile(""+height()))
156 cOutput = substr(cOutput,"#{f5}",oDesigner.PrepareStringForFormFile(textcolor()))
157 cOutput = substr(cOutput,"#{f6}",oDesigner.PrepareStringForFormFile(backcolor()))
158 cOutput = substr(cOutput,"#{f7}",oDesigner.PrepareStringForFormFile(fontproperty()))
159 cOutput = substr(cOutput,"#{f8}",oDesigner.PrepareStringForFormFile(CurrentParentName()))
162 func GenerateCode oDesigner
163 cOutput = char(9) + char(9) +
164 oDesigner.oModel.GetObjectName(self) + " = " +
168 setstylesheet("color:#{f6};background-color:#{f7};")
169 oFont = new qfont("",0,0,0)
170 oFont.fromstring("#{f8}")
175 cClass = substr(classname(self),"formdesigner_","")
176 if cClass = "qimage" or cClass = "qhyperlink" {
180 if oDesigner.oModel.FormObject().IndexTypeValue() = 0 {
181 # Remove the 'q' letter from the class name
182 cClass = substr(cClass,2)
184 cOutput = substr(cOutput,"#{f1}",cClass)
185 cOutput = substr(cOutput,"#{f2}",""+x())
186 cOutput = substr(cOutput,"#{f3}",""+y())
187 cOutput = substr(cOutput,"#{f4}",""+width())
188 cOutput = substr(cOutput,"#{f5}",""+height())
189 cOutput = substr(cOutput,"#{f6}",textcolor())
190 cOutput = substr(cOutput,"#{f7}",backcolor())
191 cOutput = substr(cOutput,"#{f8}",fontproperty())
192 cOutput = substr(cOutput,"#{f9}",AddTabs(GenerateCustomCode(oDesigner),3))
193 cOutput = substr(cOutput,"#{f10}",CurrentParentName())
196 func AddTabs cText,nCount
197 cTabs = std_copy(char(9),nCount)
198 cText = cTabs + cText
199 cText = substr(cText,nl,nl+cTabs)
202 func GenerateCustomCode oDesigner
205 func RestoreProperties oDesigner,Item
206 RestoreCommonProperties(oDesigner,item)
208 func RestoreCommonProperties oDesigner,item
209 itemdata = item[:data]
211 setMouseTracking(True)
213 oDesigner.oModel.SetObjectName(oDesigner,self,item[:name])
214 move(itemdata[:x],itemdata[:y])
215 resize(itemdata[:width],itemdata[:height])
216 setTextColor(itemdata[:textcolor])
217 setBackColor(itemdata[:backcolor])
218 if itemdata[:font] = NULL { itemdata[:font] = "Arial" }
219 setFontProperty(itemdata[:font])
220 setCurrentParentName(itemdata[:parent])
221 refreshCorners(oDesigner.oModel.ActiveObject())
224 func PrepareEvent cCode,cEvent,cReplace
225 # Remove " " around event if we uses Code
226 cEvent = std_lower(cEvent)
227 if substr(cEvent,"(") > 0 {
228 cCode = substr(cCode,char(34)+cReplace+char(34),cReplace)
231 cCode = substr(cCode,char(34)+cReplace+char(34),"Method(:"+cReplace+")")