UILayoutTool.st
changeset 1072 84ae04e0af72
parent 1070 1735e40c6825
child 1074 49ef9991d1d5
equal deleted inserted replaced
1071:560a9eb1a5d8 1072:84ae04e0af72
    12 
    12 
    13 
    13 
    14 
    14 
    15 
    15 
    16 ApplicationModel subclass:#UILayoutTool
    16 ApplicationModel subclass:#UILayoutTool
    17 	instanceVariableNames:'modifiedHolder aspects selection layoutView tabList'
    17 	instanceVariableNames:'modifiedHolder aspects selection layoutView tabList layoutSpec'
    18 	classVariableNames:''
    18 	classVariableNames:''
    19 	poolDictionaries:''
    19 	poolDictionaries:''
    20 	category:'Interface-UIPainter'
    20 	category:'Interface-UIPainter'
    21 !
    21 !
    22 
    22 
   479     "returns current edited view
   479     "returns current edited view
   480     "
   480     "
   481     ^ layoutView
   481     ^ layoutView
   482 !
   482 !
   483 
   483 
   484 layoutView:aView
   484 layoutView:aView type:aTypeOrNil spec:aSpec
   485     "change current edited view
   485     "change current edited view
   486     "
   486     "
   487     self layoutView:aView type:nil
       
   488 !
       
   489 
       
   490 layoutView:aView type:aTypeOrNil
       
   491     "change current edited view
       
   492     "
       
   493     |type name list|
   487     |type name list|
   494 
   488 
   495     layoutView := aView.
   489     layoutView := aView.
       
   490     layoutSpec := aSpec.
   496 
   491 
   497     aTypeOrNil notNil ifTrue:[
   492     aTypeOrNil notNil ifTrue:[
   498         self class slices findFirst:[:e|
   493         self class slices findFirst:[:e|
   499             e last == aTypeOrNil ifTrue:[name := e first. true]
   494             e last == aTypeOrNil ifTrue:[name := e first. true]
   500         ].
   495         ].
   537     "update from view
   532     "update from view
   538     "
   533     "
   539     |view appl|
   534     |view appl|
   540 
   535 
   541     selection notNil ifTrue:[
   536     selection notNil ifTrue:[
   542         (view := self layoutView) notNil ifTrue:[
   537         (view := layoutView) notNil ifTrue:[
   543             (appl := self noteBookView application) notNil ifTrue:[
   538             (appl := self noteBookView application) notNil ifTrue:[
   544                 appl fetch:view
   539                 appl fetch:view spec:layoutSpec
   545             ]
   540             ]
   546         ]
   541         ]
   547     ].
   542     ].
   548         
   543         
   549 ! !
   544 ! !
   553 aspectFor:aKey
   548 aspectFor:aKey
   554     "returns aspect for a key or nil
   549     "returns aspect for a key or nil
   555     "
   550     "
   556   ^ aspects at:aKey ifAbsent:[ super aspectFor:aKey ]
   551   ^ aspects at:aKey ifAbsent:[ super aspectFor:aKey ]
   557 
   552 
       
   553 
       
   554 !
       
   555 
       
   556 notUsingDefaultExtent
       
   557     |holder|
       
   558 
       
   559     (holder := builder bindingAt:#notUsingDefaultExtent) isNil ifTrue:[
       
   560         holder := BlockValue forLogicalNot:(self aspectFor:#useDefaultExtent).
       
   561         builder aspectAt:#notUsingDefaultExtent put:holder.
       
   562     ].
       
   563     ^ holder
   558 
   564 
   559 !
   565 !
   560 
   566 
   561 noteBookList
   567 noteBookList
   562     "returns list of tab labels
   568     "returns list of tab labels
   705     #(  bottomFraction          bottomOffset
   711     #(  bottomFraction          bottomOffset
   706         leftFraction            leftOffset
   712         leftFraction            leftOffset
   707         topFraction             topOffset
   713         topFraction             topOffset
   708         rightFraction           rightOffset
   714         rightFraction           rightOffset
   709         leftAlignmentFraction   topAlignmentFraction
   715         leftAlignmentFraction   topAlignmentFraction
       
   716         useDefaultExtent
   710     )
   717     )
   711 
   718 
   712     do:[:aKey||holder|
   719     do:[:aKey||holder|
   713         holder := ValueHolder new.
   720         holder := ValueHolder new.
   714         holder addDependent:self.
   721         holder addDependent:self.
   890                               #activeHelpKey: #alignHorizontal
   897                               #activeHelpKey: #alignHorizontal
   891                               #tabable: true
   898                               #tabable: true
   892                               #model: #leftAlignmentFraction
   899                               #model: #leftAlignmentFraction
   893                               #group: #inputGroup
   900                               #group: #inputGroup
   894                               #type: #numberOrNil
   901                               #type: #numberOrNil
       
   902                               #acceptOnLostFocus: true
   895                     #acceptChannel: #acceptChannel
   903                     #acceptChannel: #acceptChannel
   896                     #modifiedChannel: #modifiedChannel
   904                     #modifiedChannel: #modifiedChannel
   897                           )
   905                           )
   898                            #(#InputFieldSpec
   906                            #(#InputFieldSpec
   899                               #name: 'topAlignmentFractionField'
   907                               #name: 'topAlignmentFractionField'
   901                               #activeHelpKey: #alignVertical
   909                               #activeHelpKey: #alignVertical
   902                               #tabable: true
   910                               #tabable: true
   903                               #model: #topAlignmentFraction
   911                               #model: #topAlignmentFraction
   904                               #group: #inputGroup
   912                               #group: #inputGroup
   905                               #type: #numberOrNil
   913                               #type: #numberOrNil
       
   914                               #acceptOnLostFocus: true
   906                     #acceptChannel: #acceptChannel
   915                     #acceptChannel: #acceptChannel
   907                     #modifiedChannel: #modifiedChannel
   916                     #modifiedChannel: #modifiedChannel
   908                           )
   917                           )
   909                            #(#DividerSpec
   918                            #(#DividerSpec
   910                               #name: 'separator1'
   919                               #name: 'separator1'
   990     "Modified: / 13.8.1998 / 19:57:47 / cg"
   999     "Modified: / 13.8.1998 / 19:57:47 / cg"
   991 ! !
  1000 ! !
   992 
  1001 
   993 !UILayoutTool::AlignmentOrigin methodsFor:'accessing'!
  1002 !UILayoutTool::AlignmentOrigin methodsFor:'accessing'!
   994 
  1003 
   995 fetch:aView
  1004 fetch:aView spec:aSpec
   996     "fetch alignmentOrigin
  1005     "fetch alignmentOrigin
   997     "
  1006     "
   998     |layout type|
  1007     |layout type|
   999 
  1008 
  1000     type   := UIPainterView layoutType:aView.
  1009     type   := UIPainterView layoutType:aView.
  1170     <resource: #canvas>
  1179     <resource: #canvas>
  1171 
  1180 
  1172     ^
  1181     ^
  1173      
  1182      
  1174        #(#FullSpec
  1183        #(#FullSpec
       
  1184           #name: #windowSpec
  1175           #window: 
  1185           #window: 
  1176            #(#WindowSpec
  1186            #(#WindowSpec
  1177               #name: 'UILayoutTool-Extent'
  1187               #name: 'UILayoutTool-Extent'
  1178               #layout: #(#LayoutFrame 291 0 130 0 616 0 278 0)
  1188               #layout: #(#LayoutFrame 20 0 61 0 345 0 209 0)
       
  1189               #level: 0
  1179               #label: 'UILayoutTool-Extent'
  1190               #label: 'UILayoutTool-Extent'
  1180               #min: #(#Point 10 10)
  1191               #min: #(#Point 10 10)
  1181               #max: #(#Point 1152 900)
  1192               #max: #(#Point 1152 900)
  1182               #bounds: #(#Rectangle 291 130 617 279)
  1193               #bounds: #(#Rectangle 20 61 346 210)
  1183               #usePreferredExtent: false
  1194               #usePreferredExtent: false
       
  1195               #returnIsOKInDialog: true
       
  1196               #escapeIsCancelInDialog: true
  1184           )
  1197           )
  1185           #component: 
  1198           #component: 
  1186            #(#SpecCollection
  1199            #(#SpecCollection
  1187               #collection: 
  1200               #collection: 
  1188                #(
  1201                #(
  1189                  #(#FramedBoxSpec
  1202                  #(#FramedBoxSpec
  1190                     #name: 'FramedBox'
  1203                     #name: 'FramedBox'
  1191                     #layout: #(#LayoutFrame 0 0.0 6 0.0 0 1.0 100 0)
  1204                     #layout: #(#LayoutFrame 0 0.0 6 0.0 0 1.0 137 0)
  1192                     #component: 
  1205                     #component: 
  1193                      #(#SpecCollection
  1206                      #(#SpecCollection
  1194                         #collection: 
  1207                         #collection: 
  1195                          #(
  1208                          #(
  1196                            #(#LabelSpec
  1209                            #(#LabelSpec
  1201                           )
  1214                           )
  1202                            #(#InputFieldSpec
  1215                            #(#InputFieldSpec
  1203                               #name: 'fieldLeftOffset'
  1216                               #name: 'fieldLeftOffset'
  1204                               #layout: #(#LayoutFrame 90 0 13 0 140 0 35 0)
  1217                               #layout: #(#LayoutFrame 90 0 13 0 140 0 35 0)
  1205                               #activeHelpKey: #hrzExtent
  1218                               #activeHelpKey: #hrzExtent
       
  1219                               #enableChannel: #notUsingDefaultExtent
  1206                               #tabable: true
  1220                               #tabable: true
  1207                               #model: #leftOffset
  1221                               #model: #leftOffset
  1208                               #group: #inputGroup
  1222                               #group: #inputGroup
  1209                               #type: #numberOrNil
  1223                               #type: #numberOrNil
  1210                     #acceptChannel: #acceptChannel
  1224                               #acceptOnLostFocus: true
  1211                     #modifiedChannel: #modifiedChannel
  1225                               #acceptChannel: #acceptChannel
       
  1226                               #modifiedChannel: #modifiedChannel
  1212                           )
  1227                           )
  1213                            #(#LabelSpec
  1228                            #(#LabelSpec
  1214                               #name: 'labelHeight'
  1229                               #name: 'labelHeight'
  1215                               #layout: #(#AlignmentOrigin 89 0 49 0 1 0.5)
  1230                               #layout: #(#AlignmentOrigin 89 0 49 0 1 0.5)
  1216                               #label: 'Height:'
  1231                               #label: 'Height:'
  1218                           )
  1233                           )
  1219                            #(#InputFieldSpec
  1234                            #(#InputFieldSpec
  1220                               #name: 'fieldRightOffset'
  1235                               #name: 'fieldRightOffset'
  1221                               #layout: #(#LayoutFrame 90 0 38 0 140 0 60 0)
  1236                               #layout: #(#LayoutFrame 90 0 38 0 140 0 60 0)
  1222                               #activeHelpKey: #vrtExtent
  1237                               #activeHelpKey: #vrtExtent
       
  1238                               #enableChannel: #notUsingDefaultExtent
  1223                               #tabable: true
  1239                               #tabable: true
  1224                               #model: #rightOffset
  1240                               #model: #rightOffset
  1225                               #group: #inputGroup
  1241                               #group: #inputGroup
  1226                               #type: #numberOrNil
  1242                               #type: #numberOrNil
  1227                     #acceptChannel: #acceptChannel
  1243                               #acceptOnLostFocus: true
  1228                     #modifiedChannel: #modifiedChannel
  1244                               #acceptChannel: #acceptChannel
       
  1245                               #modifiedChannel: #modifiedChannel
       
  1246                           )
       
  1247                            #(#CheckBoxSpec
       
  1248                               #name: 'useDefaultExtentCheckBox'
       
  1249                               #layout: #(#LayoutFrame -1 0 75 0 135 0 97 0)
       
  1250                               #model: #useDefaultExtent
       
  1251                               #label: 'Use Widgets Default Extent'
       
  1252                               #translateLabel: true
  1229                           )
  1253                           )
  1230                         )
  1254                         )
  1231                     )
  1255                     )
  1232                     #label: 'Extent'
  1256                     #label: 'Extent'
  1233                     #labelPosition: #topLeft
  1257                     #labelPosition: #topLeft
  1234                 )
  1258                 )
  1235               )
  1259               )
  1236           )
  1260           )
  1237       )
  1261       )
  1238 
       
  1239     "Modified: / 13.8.1998 / 19:58:04 / cg"
       
  1240 ! !
  1262 ! !
  1241 
  1263 
  1242 !UILayoutTool::Extent methodsFor:'accessing'!
  1264 !UILayoutTool::Extent methodsFor:'accessing'!
  1243 
  1265 
  1244 fetch:aView
  1266 fetch:aView spec:aSpec
  1245     "fetch extent
  1267     "fetch extent
  1246     "
  1268     "
  1247     |extent|
  1269     |extent|
  1248 
  1270 
  1249     extent  := aView computeExtent.
  1271     extent  := aView computeExtent.
  1250 
  1272 
  1251     (self aspectFor:#leftOffset)  value:(extent x).
  1273     (self aspectFor:#leftOffset)  value:(extent x).
  1252     (self aspectFor:#rightOffset) value:(extent y).
  1274     (self aspectFor:#rightOffset) value:(extent y).
  1253 
  1275 
  1254 
  1276     (self aspectFor:#useDefaultExtent) value:aSpec useDefaultExtent 
  1255 !
  1277 !
  1256 
  1278 
  1257 layout
  1279 layout
  1258     "returns current extent
  1280     "returns current extent
  1259     "
  1281     "
  1527                               #layout: #(#LayoutFrame 90 0 14 0 140 0 36 0)
  1549                               #layout: #(#LayoutFrame 90 0 14 0 140 0 36 0)
  1528                               #activeHelpKey: #rightRelative
  1550                               #activeHelpKey: #rightRelative
  1529                               #model: #rightFraction
  1551                               #model: #rightFraction
  1530                               #group: #inputGroup
  1552                               #group: #inputGroup
  1531                               #type: #numberOrNil
  1553                               #type: #numberOrNil
       
  1554                               #acceptOnLostFocus: true
  1532                               #acceptChannel: #acceptChannel
  1555                               #acceptChannel: #acceptChannel
  1533                               #modifiedChannel: #modifiedChannel
  1556                               #modifiedChannel: #modifiedChannel
  1534                           )
  1557                           )
  1535                            #(#ActionButtonSpec
  1558                            #(#ActionButtonSpec
  1536                               #name: 'actionRelativeRight'
  1559                               #name: 'actionRelativeRight'
  1543                               #layout: #(#LayoutFrame 190 0 14 0 240 0 36 0)
  1566                               #layout: #(#LayoutFrame 190 0 14 0 240 0 36 0)
  1544                               #activeHelpKey: #rightAbsolute
  1567                               #activeHelpKey: #rightAbsolute
  1545                               #model: #rightOffset
  1568                               #model: #rightOffset
  1546                               #group: #inputGroup
  1569                               #group: #inputGroup
  1547                               #type: #numberOrNil
  1570                               #type: #numberOrNil
       
  1571                               #acceptOnLostFocus: true
  1548                               #acceptChannel: #acceptChannel
  1572                               #acceptChannel: #acceptChannel
  1549                               #modifiedChannel: #modifiedChannel
  1573                               #modifiedChannel: #modifiedChannel
  1550                           )
  1574                           )
  1551                            #(#ActionButtonSpec
  1575                            #(#ActionButtonSpec
  1552                               #name: 'actionAbsoluteRight'
  1576                               #name: 'actionAbsoluteRight'
  1564                               #layout: #(#LayoutFrame 90 0 42 0 140 0 64 0)
  1588                               #layout: #(#LayoutFrame 90 0 42 0 140 0 64 0)
  1565                               #activeHelpKey: #bottomRelative
  1589                               #activeHelpKey: #bottomRelative
  1566                               #model: #bottomFraction
  1590                               #model: #bottomFraction
  1567                               #group: #inputGroup
  1591                               #group: #inputGroup
  1568                               #type: #numberOrNil
  1592                               #type: #numberOrNil
       
  1593                               #acceptOnLostFocus: true
  1569                               #acceptChannel: #acceptChannel
  1594                               #acceptChannel: #acceptChannel
  1570                               #modifiedChannel: #modifiedChannel
  1595                               #modifiedChannel: #modifiedChannel
  1571                           )
  1596                           )
  1572                            #(#ActionButtonSpec
  1597                            #(#ActionButtonSpec
  1573                               #name: 'actionRelativeBottom'
  1598                               #name: 'actionRelativeBottom'
  1580                               #layout: #(#LayoutFrame 190 0 42 0 240 0 64 0)
  1605                               #layout: #(#LayoutFrame 190 0 42 0 240 0 64 0)
  1581                               #activeHelpKey: #bottomAbsolute
  1606                               #activeHelpKey: #bottomAbsolute
  1582                               #model: #bottomOffset
  1607                               #model: #bottomOffset
  1583                               #group: #inputGroup
  1608                               #group: #inputGroup
  1584                               #type: #numberOrNil
  1609                               #type: #numberOrNil
       
  1610                               #acceptOnLostFocus: true
  1585                               #acceptChannel: #acceptChannel
  1611                               #acceptChannel: #acceptChannel
  1586                               #modifiedChannel: #modifiedChannel
  1612                               #modifiedChannel: #modifiedChannel
  1587                           )
  1613                           )
  1588                            #(#ActionButtonSpec
  1614                            #(#ActionButtonSpec
  1589                               #name: 'actionAbsoluteBottom'
  1615                               #name: 'actionAbsoluteBottom'
  1705       )
  1731       )
  1706 ! !
  1732 ! !
  1707 
  1733 
  1708 !UILayoutTool::LayoutFrame methodsFor:'accessing'!
  1734 !UILayoutTool::LayoutFrame methodsFor:'accessing'!
  1709 
  1735 
  1710 fetch:aView
  1736 fetch:aView spec:aSpec
  1711     |layout|
  1737     |layout|
  1712 
  1738 
  1713     layout  := UIPainterView asLayoutFrameFromView:aView.
  1739     layout  := UIPainterView asLayoutFrameFromView:aView.
  1714 
  1740 
  1715     (self aspectFor:#leftOffset)     value:(layout leftOffset).
  1741     (self aspectFor:#leftOffset)     value:(layout leftOffset).
  1866       )
  1892       )
  1867 ! !
  1893 ! !
  1868 
  1894 
  1869 !UILayoutTool::LayoutOrigin methodsFor:'accessing'!
  1895 !UILayoutTool::LayoutOrigin methodsFor:'accessing'!
  1870 
  1896 
  1871 fetch:aView
  1897 fetch:aView spec:aSpec
  1872     "fetch layoutOrigin
  1898     "fetch layoutOrigin
  1873     "
  1899     "
  1874     |layout|
  1900     |layout|
  1875 
  1901 
  1876     layout  := UIPainterView asLayoutFrameFromView:aView.
  1902     layout  := UIPainterView asLayoutFrameFromView:aView.
  1944       )
  1970       )
  1945 ! !
  1971 ! !
  1946 
  1972 
  1947 !UILayoutTool::Point methodsFor:'accessing'!
  1973 !UILayoutTool::Point methodsFor:'accessing'!
  1948 
  1974 
  1949 fetch:aView
  1975 fetch:aView spec:aSpec
  1950     "fetch point
  1976     "fetch point
  1951     "
  1977     "
  1952     |origin|
  1978     |origin|
  1953 
  1979 
  1954     origin  := aView computeOrigin.
  1980     origin  := aView computeOrigin.
  2026                               #activeHelpKey: #cornerX
  2052                               #activeHelpKey: #cornerX
  2027                               #tabable: true
  2053                               #tabable: true
  2028                               #model: #rightOffset
  2054                               #model: #rightOffset
  2029                               #group: #inputGroup
  2055                               #group: #inputGroup
  2030                               #type: #numberOrNil
  2056                               #type: #numberOrNil
       
  2057                               #acceptOnLostFocus: true
  2031                     #acceptChannel: #acceptChannel
  2058                     #acceptChannel: #acceptChannel
  2032                     #modifiedChannel: #modifiedChannel
  2059                     #modifiedChannel: #modifiedChannel
  2033                           )
  2060                           )
  2034                            #(#LabelSpec
  2061                            #(#LabelSpec
  2035                               #name: 'labelCornerX'
  2062                               #name: 'labelCornerX'
  2043                               #activeHelpKey: #cornerY
  2070                               #activeHelpKey: #cornerY
  2044                               #tabable: true
  2071                               #tabable: true
  2045                               #model: #bottomOffset
  2072                               #model: #bottomOffset
  2046                               #group: #inputGroup
  2073                               #group: #inputGroup
  2047                               #type: #numberOrNil
  2074                               #type: #numberOrNil
       
  2075                               #acceptOnLostFocus: true
  2048                     #acceptChannel: #acceptChannel
  2076                     #acceptChannel: #acceptChannel
  2049                     #modifiedChannel: #modifiedChannel
  2077                     #modifiedChannel: #modifiedChannel
  2050                           )
  2078                           )
  2051                         )
  2079                         )
  2052                     )
  2080                     )
  2060     "Modified: / 13.8.1998 / 19:59:16 / cg"
  2088     "Modified: / 13.8.1998 / 19:59:16 / cg"
  2061 ! !
  2089 ! !
  2062 
  2090 
  2063 !UILayoutTool::Rectangle methodsFor:'accessing'!
  2091 !UILayoutTool::Rectangle methodsFor:'accessing'!
  2064 
  2092 
  2065 fetch:aView
  2093 fetch:aView spec:aSpec
  2066     "fetch rectangle
  2094     "fetch rectangle
  2067     "
  2095     "
  2068     |origin corner|
  2096     |origin corner|
  2069 
  2097 
  2070     origin := aView computeOrigin.
  2098     origin := aView computeOrigin.