*** empty log message ***
authorClaus Gittinger <cg@exept.de>
Mon, 06 Mar 2006 09:49:01 +0100
changeset 2022 746cc87a768e
parent 2021 5b7cc72d8226
child 2023 7a37b7c85092
*** empty log message ***
UILayoutTool.st
--- a/UILayoutTool.st	Mon Mar 06 09:47:37 2006 +0100
+++ b/UILayoutTool.st	Mon Mar 06 09:49:01 2006 +0100
@@ -875,17 +875,19 @@
 !UILayoutTool methodsFor:'selection'!
 
 selectedSlice
-    "returns slice assigned to selection or nil
-    "
-    selection notNil ifTrue:[
-        self class slices do:[:aSlice|
-            aSlice first = selection ifTrue:[
-                ^ aSlice
-            ]
-        ]
-    ].
-    ^ nil
-
+    "returns the slice assigned to the selection or nil"
+
+    selection isNil ifTrue:[^ nil].
+    ^ self class slices detect:[:aSlice | aSlice first = selection] ifNone:nil
+
+"/    selection notNil ifTrue:[
+"/        self class slices do:[:aSlice|
+"/            aSlice first = selection ifTrue:[
+"/                ^ aSlice
+"/            ]
+"/        ]
+"/    ].
+"/    ^ nil
 !
 
 selection
@@ -1489,7 +1491,7 @@
               name: 'FramedBox'
               layout: (LayoutFrame 0 0.0 6 0.0 0 1.0 145 0)
               labelPosition: topLeft
-                    translateLabel: true
+              translateLabel: true
               component: 
              (SpecCollection
                 collection: (
@@ -1497,8 +1499,8 @@
                     label: 'Width:'
                     name: 'labelWidth'
                     layout: (AlignmentOrigin 89 0 24 0 1 0.5)
+                    translateLabel: true
                     adjust: right
-                    translateLabel: true
                   )
                  (InputFieldSpec
                     name: 'fieldLeftOffset'
@@ -1518,8 +1520,8 @@
                     label: 'Height:'
                     name: 'labelHeight'
                     layout: (AlignmentOrigin 89 0 49 0 1 0.5)
+                    translateLabel: true
                     adjust: right
-                    translateLabel: true
                   )
                  (InputFieldSpec
                     name: 'fieldRightOffset'
@@ -1527,7 +1529,7 @@
                     activeHelpKey: vrtExtent
                     enableChannel: notUsingDefaultExtent
                     tabable: true
-                    model: rightOffset
+                    model: topOffset
                     group: inputGroup
                     type: numberOrNil
                     acceptOnLostFocus: true
@@ -1548,6 +1550,16 @@
                
               )
             )
+           (PopUpListSpec
+              label: 'Common Extents'
+              name: 'CommonExtentsPopUpList'
+              layout: (LayoutFrame 179 0 35 0 304 0 57 0)
+              tabable: true
+              menu: listOfCommonExtents
+              useIndex: true
+              ignoreReselect: false
+              stateChangeCallBackSelector: commonExtentSelected:
+            )
            )
          
         )
@@ -1557,24 +1569,53 @@
 !UILayoutTool::Extent methodsFor:'accessing'!
 
 fetch:aView spec:aSpec
-    "fetch extent
-    "
+    "fetch the extent from aView"
+
     |extent|
 
     extent  := aView computeExtent.
 
     (self aspectFor:#leftOffset)  value:(extent x).
-    (self aspectFor:#rightOffset) value:(extent y).
+    (self aspectFor:#topOffset)   value:(extent y).
 
     (self aspectFor:#useDefaultExtent) value:aSpec useDefaultExtent 
 !
 
 layout
-    "returns current extent
-    "
-  ^ Smalltalk::Point x:(((self aspectFor:#leftOffset)   value) ? 0)
-                     y:(((self aspectFor:#rightOffset)  value) ? 0)
-
+    "returns the current extent"
+
+    ^ (((self aspectFor:#leftOffset) value) ? 0) @ (((self aspectFor:#topOffset)  value) ? 0)
+! !
+
+!UILayoutTool::Extent methodsFor:'aspects'!
+
+commonExtentsSpec
+    ^ #( 
+        ('200 x 100'  (200 100) ) 
+        ('300 x 300'  (300 300) ) 
+        ('640 x 400'  (640 400) ) 
+        ('800 x 600'  (800 600) ) 
+      )
+!
+
+listOfCommonExtents
+    ^ self commonExtentsSpec collect:[:eachRow | eachRow first].
+! !
+
+!UILayoutTool::Extent methodsFor:'user actions'!
+
+commonExtentSelected:index
+    |xy x y|
+
+    xy := (self commonExtentsSpec at:index) second. 
+    x := xy at:1.
+    y := xy at:2.
+
+    (self aspectFor:#leftOffset)  value:x.
+    (self aspectFor:#topOffset)   value:y.
+
+    (builder componentAt:#CommonExtentsPopUpList) 
+        label:(resources string:'Common Extents').
 ! !
 
 !UILayoutTool::LayoutFrame class methodsFor:'defaults'!
@@ -1643,7 +1684,7 @@
 'Compute pure-fractional y.'
 
 #makeBottomRelativeFromBottom
-'Compute fraction+offset for y relative to container.'
+'Compute fraction+offset for y relative to containers bottom.'
 
 #makeRightAbsolute
 'Compute pure-absolute x.'
@@ -1709,9 +1750,9 @@
 
     ^Icon
         constantNamed:#'UILayoutTool::LayoutFrame class setBigBottomFixPartIcon'
-        ifAbsentPut:[(Depth4Image new) width: 16; height: 16; photometric:(#palette); bitsPerSample:(#(4 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'
-@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"H"H@H"H"@BDQDP@QDQH@HQDQ@ADQD @!!DQD@DQDR@BDQDP@QDQH@HQ
-DQ@ADQD @!!DQD@DQDR@BDQDP@QDQH@H"H"@BH"H @@@@@@@@@@@b') ; colorMapFromArray:#[0 0 0 255 0 0 255 255 255]; mask:((Depth1Image new) width: 16; height: 16; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'??>@@X@A @F@@_????????????????????????????<b') ; yourself); yourself]
+        ifAbsentPut:[(Depth4Image new) width: 16; height: 16; photometric:(#palette); bitsPerSample:(#(4)); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'
+@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"H"H"H"H"@BDQDQDQDQH@HQDQDQDQD @!!DQDQDQDR@BDQDQDQDQH@HQ
+DQDQDQD @!!DQDQDQDR@BDQDQDQDQH@H"H"H"H"H @@@@@@@@@@@b') ; colorMapFromArray:#[0 0 0 255 0 0 255 255 255]; mask:((Depth1Image new) width: 16; height: 16; photometric:(#blackIs0); bitsPerSample:(#(1)); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'??>A XFA XFA _????????????????????????????<b') ; yourself); yourself]
 !
 
 setBigHorizontalFixPartIcon
@@ -1731,9 +1772,9 @@
 
     ^Icon
         constantNamed:#'UILayoutTool::LayoutFrame class setBigHorizontalFixPartIcon'
-        ifAbsentPut:[(Depth4Image new) width: 16; height: 16; photometric:(#palette); bitsPerSample:(#(4 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'
-@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@BH"H @"H"H@HQDQ@ADQD @!!DQD@DQDR@BDQDP@QDQH@HQDQ@ADQD @!!DQD@DQDR@BDQDP@QDQH@H"
-H"@BH"H @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@b') ; colorMapFromArray:#[0 0 0 255 0 0 255 255 255]; mask:((Depth1Image new) width: 16; height: 16; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'??>@@X@A??????????????????????????>@@X@A??<b') ; yourself); yourself]
+        ifAbsentPut:[(Depth4Image new) width: 16; height: 16; photometric:(#palette); bitsPerSample:(#(4)); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'
+@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@BH"H"H"H"H@HQDQDQDQD @!!DQDQDQDR@BDQDQDQDQH@HQDQDQDQD @!!DQDQDQDR@BDQDQDQDQH@H"
+H"H"H"H @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@b') ; colorMapFromArray:#[0 0 0 255 0 0 255 255 255]; mask:((Depth1Image new) width: 16; height: 16; photometric:(#blackIs0); bitsPerSample:(#(1)); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'??>A XFA??????????????????????????>A XFA??<b') ; yourself); yourself]
 !
 
 setBigTopFixPartIcon
@@ -1753,9 +1794,9 @@
 
     ^Icon
         constantNamed:#'UILayoutTool::LayoutFrame class setBigTopFixPartIcon'
-        ifAbsentPut:[(Depth4Image new) width: 16; height: 16; photometric:(#palette); bitsPerSample:(#(4 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'
-@@@@@@@@@@@BH"H @"H"H@HQDQ@ADQD @!!DQD@DQDR@BDQDP@QDQH@HQDQ@ADQD @!!DQD@DQDR@BDQDP@QDQH@HQDQ@ADQD @"H"H@H"H"@@@@@@@@@@@@@@
-@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@b') ; colorMapFromArray:#[0 0 0 255 0 0 255 255 255]; mask:((Depth1Image new) width: 16; height: 16; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'?????????????????????????????8@A @F@@X@A??<b') ; yourself); yourself]
+        ifAbsentPut:[(Depth4Image new) width: 16; height: 16; photometric:(#palette); bitsPerSample:(#(4)); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'
+@@@@@@@@@@@BH"H"H"H"H@HQDQDQDQD @!!DQDQDQDR@BDQDQDQDQH@HQDQDQDQD @!!DQDQDQDR@BDQDQDQDQH@HQDQDQDQD @"H"H"H"H"@@@@@@@@@@@@@@
+@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@b') ; colorMapFromArray:#[0 0 0 255 0 0 255 255 255]; mask:((Depth1Image new) width: 16; height: 16; photometric:(#blackIs0); bitsPerSample:(#(1)); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'?????????????????????????????8FA XFA XFA??<b') ; yourself); yourself]
 !
 
 setBottomFixPartIcon
@@ -2971,14 +3012,13 @@
 !
 
 layout
-    "returns current layout as rectangle
-    "
-  ^ Smalltalk::Rectangle left:(((self aspectFor:#leftOffset)   value) ? 0)
-                          top:(((self aspectFor:#topOffset)    value) ? 0)
-                        right:(((self aspectFor:#rightOffset)  value) ? 0)
-                       bottom:(((self aspectFor:#bottomOffset) value) ? 0)
-
-
+    "returns current layout as rectangle"
+
+    ^ Smalltalk::Rectangle 
+        left:(((self aspectFor:#leftOffset)   value) ? 0)
+        top:(((self aspectFor:#topOffset)    value) ? 0)
+        right:(((self aspectFor:#rightOffset)  value) ? 0)
+        bottom:(((self aspectFor:#bottomOffset) value) ? 0)
 ! !
 
 !UILayoutTool class methodsFor:'documentation'!