OSDN Git Service

Ring 1.10 以来となる開発環境の日本語ローカライズ版 (評価版) を追加 (ノートパッド、フォームデザイナー、対話型実行環境、ファイルの検索)。
[ring-lang-081/ring.git] / applications / build / ja-jp / formdesigner / controls / qlayout.ring
1 /*
2 **      Project : Form Designer 
3 **      File Purpose :  QLayout Control
4 **      Date : 2017.04.29
5 **      Author :  Mahmoud Fayed <msfclipper@yahoo.com>
6 */
7
8 package formdesigner
9
10 class FormDesigner_QLayout from QLabel
11
12         CreateCommonAttributes()
13         CreateMoveResizeCornersAttributes()
14
15         nLayoutType = 0
16         cLayoutObjects = ""
17
18         func LayoutTypeValue
19                 return nLayoutType
20
21         func SetLayoutTypeValue Value
22                 nLayoutType = Value
23
24         func LayoutObjectsValue
25                 return cLayoutObjects
26
27         func SetLayoutObjectsValue cValue
28                 cLayoutObjects = cValue
29
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)"
35
36         func DisplayProperties oDesigner
37                 DisplayCommonProperties(oDesigner)
38                 oPropertiesTable = oDesigner.oView.oPropertiesTable
39                 oPropertiesTable.Blocksignals(True)
40                 # Set the Layout Type
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)
50                 # Set the object name
51                         setText(oDesigner.oModel.GetObjectName(self))
52
53         func UpdateProperties oDesigner,nRow,nCol,cValue
54                 UpdateCommonProperties(oDesigner,nRow,nCol,cValue)
55                 switch nRow {
56                         case C_AFTERCOMMON
57                                 setLayoutTypeValue(cValue)
58                         case C_AFTERCOMMON + 1
59                                 setLayoutObjectsValue(cValue)
60                 }
61                 # Set the object name
62                         setText(oDesigner.oModel.GetObjectName(self))
63
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)
72                 }
73
74         func DialogButtonAction oDesigner,nRow
75                 CommonDialogButtonAction(oDesigner,nRow)
76                 switch 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
84                                         del(aList,1)
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()
89                 }
90
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()) + '"'
96                 return cOutput
97
98         func GenerateCode oDesigner
99                 cOutput = char(9) + char(9) +
100                 oDesigner.oModel.GetObjectName(self) + " = " +
101                 'new #{f1}() {
102 #{f2}
103                 }' + nl
104                 switch LayoutTypeValue()        {
105                         case 0
106                                 cClass = "QVBoxLayout"
107                         case 1
108                                 cClass = "QHBoxLayout"
109                 }
110                 cOutput = substr(cOutput,"#{f1}",cClass)
111                 cOutput = substr(cOutput,"#{f2}",AddTabs(GenerateCustomCode(oDesigner),3))
112                 return cOutput
113
114         func GenerateCustomCode oDesigner
115                 cOutput = ""
116                 if LayoutObjectsValue() != NULL {
117                         aItems = split(LayoutObjectsValue(),",")
118                         for item in aItems {
119                                 if not oDesigner.oModel.GetObjectClassByName(item) = "formdesigner_qlayout" {
120                                         cOutput += 'AddWidget(#{f1})' + nl
121                                 else
122                                         cOutput += 'AddLayout(#{f1})' + nl
123                                 }
124                                 cOutput = substr(cOutput,"#{f1}",Item)
125                         }
126                 }
127                 return cOutput
128
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))