--- a/UIPainter.st Fri Aug 15 17:36:02 1997 +0200
+++ b/UIPainter.st Mon Aug 18 13:05:09 1997 +0200
@@ -21,8 +21,8 @@
SelectionInTreeView subclass:#TreeView
instanceVariableNames:'lastDrawnMaster cvsEventsDisabled imageMasterParent
- imageMasterChild'
- classVariableNames:'ImageMasterParent ImageMasterChild'
+ imageEmptyParent imageMasterChild'
+ classVariableNames:'ImageMasterParent ImageMasterChild ImageEmptyParent'
poolDictionaries:''
privateIn:UIPainter
!
@@ -71,21 +71,16 @@
!UIPainter class methodsFor:'instance creation'!
-listHolder:aListHolder
- |application|
-
- application := self new.
- application objectList:aListHolder.
- ^ application open
-!
-
openOnClass:aClass andSelector:aSelector
+ "open up an interface builder, fetching a spec from aClass
+ via some selector
+ "
^ self new openOnClass:aClass andSelector:aSelector
-
- "Created: 1.7.1997 / 19:16:59 / cg"
!
painter:aBuilderView
+ "set the painter
+ "
|application|
application := self new.
@@ -96,6 +91,8 @@
!UIPainter class methodsFor:'ST-80 queries'!
preferenceFor:aSymbol
+ "ST-80 compatible; always returns false
+ "
^ false
@@ -110,88 +107,108 @@
^ super helpSpec addPairsFrom:#(
#alignSelectionCenterVer
-'align selection vertical'
+'align selected widgets vertical'
#alignSelectionLeft
-'align selected components to the left edge of the
-dominant component ( underlined )'
+'align selected widgets to the left edge of the dominant widget ( underlined )'
#alignSelectionRight
-'align selected components to the right edge of the
-dominant component ( underlined )'
+'align selected widgets to the right edge of the dominant widget ( underlined )'
#alignSelectionLeftAndRight
-'align selected components to the right and left edge
-of the dominant component ( underlined )'
+'align selected widgets to the right and left edge of the dominant widget ( underlined )'
#alignSelectionTop
-'align selected components to the top edge of the
-dominant component ( underlined )'
+'align selected widgets to the top edge of the dominant widget ( underlined )'
#alignSelectionBottom
-'align selected components to the bottom edge of the
-dominant component ( underlined )'
+'align selected widgets to the bottom edge of the dominant widget ( underlined )'
#alignSelectionTopAndBottom
-'align selected components to the top and bottom edge
-of the dominant component ( underlined )'
+'align selected widgets to the top and bottom edge of the dominant widget ( underlined )'
#alignSelectionCenterVer
-'align selected components horizontal to the center of
-the dominant component ( underlined )'
+'align selected widgets horizontal to the center of the dominant widget ( underlined )'
#alignSelectionCenterHor
-'align selected components vertical to the center of
-the dominant component ( underlined )'
+'align selected widgets vertical to the center of the dominant widget ( underlined )'
#spreadSelectionVer
-'vertical spacing between selected components is made the same'
+'vertical spacing between selected widgets is made the same'
#spreadSelectionHor
-'horizontal spacing between selected components is made the same'
+'horizontal spacing between selected widgets is made the same'
#centerSelectionHor
-'center components horizontal in contained view'
+'center widgets horizontal to their top widget'
#centerSelectionVer
'center vertical horizontal in contained view'
#setToDefaultExtent
-'set selected components to their default extent'
+'set selected widgets to their default extent'
#setToDefaultWidth
-'set selected components to their default width'
+'set selected widgets to their default width'
#setToDefaultHeight
-'set selected components to their default height'
+'set selected widgets to their default height'
#copyExtent
-'copy extent of the selected component'
+'copy extent of the selected widget'
#pasteExtent
-'change extent of all selected components to the
-last copied extent'
+'change extent of all selected widgets to the last copied extent'
#pasteWidth
-'change width of all selected components to the
-last copied extent width'
+'change width of all selected widgets to the last copied extent width'
#pasteHeight
-'change height of all selected components to the
-last copied extent height'
+'change height of all selected widgets to the last copied extent height'
#copyLayout
-'copy layout of the selected component'
+'copy layout of the selected widget'
#pasteLayout
-'change layout of all selected components to the
-last copied layout'
+'change layout of all selected widgets to the last copied layout'
#pasteBuffer
-'paste components at current mouse position'
+'paste widgets at current mouse position'
#pasteWithLayout
-'paste components without changing their layouts'
+'paste widgets without changing their layouts'
+
+#accept
+'write back changes'
+
+#cancel
+'reread specification and layout'
+
+#galleryShown
+'show or hide gallery view'
+
+#painterShown
+'show or hide painter view'
+
+#moveSelectionLeft
+'move selected widgets left while pressing the button'
+
+#moveSelectionRight
+'move selected widgets right while pressing the button'
+
+#moveSelectionDown
+'move selected widgets down while pressing the button'
+
+#moveSelectionUp
+'move selected widgets up while pressing the button'
+
+#menuChangeHierarchy
+'change hierarchy of the selected widget'
+
+#menuAlignment
+'provides a set of alignment operation on the current selected widgets'
+
+
)
@@ -203,45 +220,63 @@
!UIPainter class methodsFor:'icons'!
iconAlignB
+ "returns image assigned to align bottom
+ "
^ Image fromFile:'b_alignB.xbm'
!
iconAlignCenterH
+ "returns image assigned to center horizontal
+ "
^ Image fromFile:'b_alignCH.xbm'
!
iconAlignCenterV
+ "returns image assigned to center vertical
+ "
^ Image fromFile:'b_alignCV.xbm'
!
iconAlignL
+ "returns image assigned to align left
+ "
^ Image fromFile:'b_alignL.xbm'
!
iconAlignLR
+ "returns image assigned to align left and right
+ "
^ Image fromFile:'b_alignLR.xbm'
!
iconAlignR
+ "returns image assigned to align right
+ "
^ Image fromFile:'b_alignR.xbm'
!
iconAlignT
+ "returns image assigned to align top
+ "
^ Image fromFile:'b_alignT.xbm'
!
iconAlignTB
+ "returns image assigned to align top and bottom
+ "
^ Image fromFile:'b_alignTB.xbm'
!
iconStepDown
+ "returns image assigned to step down (change hierarchy).
+ "
IconStepDown isNil ifTrue:[
IconStepDown := ((Image fromFile:'stepOver.xpm') rotated:90) flipHorizontal
].
@@ -254,6 +289,8 @@
!
iconStepIn
+ "returns image assigned to step in (change hierarchy).
+ "
IconStepIn isNil ifTrue:[
IconStepIn := ((Image fromFile:'stepIn.xpm') rotated:90) flipHorizontal
].
@@ -262,6 +299,8 @@
!
iconStepOut
+ "returns image assigned to step out (change hierarchy).
+ "
IconStepOut isNil ifTrue:[
IconStepOut := ((Image fromFile:'stepOut.xpm') rotated:90) flipHorizontal
].
@@ -269,6 +308,8 @@
!
iconStepUp
+ "returns image assigned to step up (change hierarchy).
+ "
IconStepUp isNil ifTrue:[
IconStepUp := ((Image fromFile:'stepOver.xpm') rotated:90) flipHorizontal flipVertical
].
@@ -410,10 +451,12 @@
#(#FullSpec
#'window:'
#(#WindowSpec
- #'name:' 'uIPainterView'
- #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
+ #'name:' 'Tree-View'
+ #'layout:' #(#LayoutFrame 199 0 167 0 759 0 616 0)
#'label:' 'Tree-View'
- #'bounds:' #(#Rectangle 0 0 561 450)
+ #'min:' #(#Point 10 10)
+ #'max:' #(#Point 1160 870)
+ #'bounds:' #(#Rectangle 199 167 760 617)
)
#'component:'
#(#SpecCollection
@@ -449,6 +492,7 @@
#(
#(#ActionButtonSpec
#'name:' 'cancelButton'
+ #'activeHelpKey:' #cancel
#'label:' 'cancel'
#'tabable:' true
#'model:' #cancel
@@ -457,6 +501,7 @@
)
#(#ActionButtonSpec
#'name:' 'acceptButton'
+ #'activeHelpKey:' #accept
#'label:' 'ok'
#'tabable:' true
#'model:' #accept
@@ -480,6 +525,7 @@
#(#ToggleSpec
#'name:' 'galleryLabel'
#'layout:' #(#LayoutFrame -162 1.0 1 0 -82 1.0 23 0)
+ #'activeHelpKey:' #galleryShown
#'label:' 'Gallery'
#'model:' #galleryShown
#'isTriggerOnDown:' true
@@ -489,6 +535,7 @@
#(#ToggleSpec
#'name:' 'painterLabel'
#'layout:' #(#LayoutFrame -81 1.0 1 0 -1 1.0 23 0)
+ #'activeHelpKey:' #painterShown
#'label:' 'Painter'
#'model:' #painterShown
#'isTriggerOnDown:' true
@@ -514,13 +561,17 @@
#'collection:'
#(
#(#MenuPanelSpec
- #'name:' 'menuMove'
- #'menu:' #menuMove
+ #'name:' 'menuChangeHierarchy'
+ #'activeHelpKey:' #menuChangeHierarchy
+ #'enableChannel:' #hasOneSelectionOtherThanCanvas
+ #'menu:' #menuChangeHierarchy
#'showSeparatingLines:' true
#'extent:' #(#Point 123 32)
)
#(#MenuPanelSpec
#'name:' 'menuAlignment'
+ #'activeHelpKey:' #menuAlignment
+ #'enableChannel:' #canMoveOrAlignSelection
#'tabable:' true
#'menu:' #menuAlignment
#'showSeparatingLines:' true
@@ -534,34 +585,38 @@
#(
#(#ArrowButtonSpec
#'name:' 'moveLeft'
+ #'activeHelpKey:' #moveSelectionLeft
#'tabable:' true
#'model:' #moveSelectionLeft
#'isTriggerOnDown:' true
- #'enableChannel:' #hasValidSelection
+ #'enableChannel:' #canMoveOrAlignSelection
#'direction:' #left
- #'extent:' #(#Point 25 24)
+ #'extent:' #(#Point 22 24)
)
#(#ArrowButtonSpec
#'name:' 'moveRight'
+ #'activeHelpKey:' #moveSelectionRight
#'model:' #moveSelectionRight
#'isTriggerOnDown:' true
- #'enableChannel:' #hasValidSelection
+ #'enableChannel:' #canMoveOrAlignSelection
#'direction:' #right
- #'extent:' #(#Point 26 24)
+ #'extent:' #(#Point 22 24)
)
#(#ArrowButtonSpec
#'name:' 'moveDown'
+ #'activeHelpKey:' #moveSelectionDown
#'model:' #moveSelectionDown
#'isTriggerOnDown:' true
- #'enableChannel:' #hasValidSelection
+ #'enableChannel:' #canMoveOrAlignSelection
#'direction:' #down
- #'extent:' #(#Point 26 24)
+ #'extent:' #(#Point 22 24)
)
#(#ArrowButtonSpec
#'name:' 'moveUp'
+ #'activeHelpKey:' #moveSelectionUp
#'model:' #moveSelectionUp
#'isTriggerOnDown:' true
- #'enableChannel:' #hasValidSelection
+ #'enableChannel:' #canMoveOrAlignSelection
#'direction:' #up
#'extent:' #(#Point 22 24)
)
@@ -609,8 +664,6 @@
#(#MenuItem
#'label:' 'align left'
#'value:' #alignSelectionLeft
- #'enabled:' #hasValidSelection
- #'activeHelpKey:' #alignSelectionLeft
#'labelImage:'
#(#ResourceRetriever
nil #iconAlignL
@@ -619,7 +672,6 @@
#(#MenuItem
#'label:' 'align right'
#'value:' #alignSelectionRight
- #'enabled:' #hasValidSelection
#'activeHelpKey:' #alignSelectionRight
#'labelImage:'
#(#ResourceRetriever
@@ -629,7 +681,6 @@
#(#MenuItem
#'label:' 'align left & right'
#'value:' #alignSelectionLeftAndRight
- #'enabled:' #hasValidSelection
#'activeHelpKey:' #alignSelectionLeftAndRight
#'labelImage:'
#(#ResourceRetriever
@@ -639,7 +690,6 @@
#(#MenuItem
#'label:' 'align top'
#'value:' #alignSelectionTop
- #'enabled:' #hasValidSelection
#'activeHelpKey:' #alignSelectionTop
#'labelImage:'
#(#ResourceRetriever
@@ -649,7 +699,6 @@
#(#MenuItem
#'label:' 'align bottom'
#'value:' #alignSelectionBottom
- #'enabled:' #hasValidSelection
#'activeHelpKey:' #alignSelectionBottom
#'labelImage:'
#(#ResourceRetriever
@@ -659,7 +708,6 @@
#(#MenuItem
#'label:' 'align top & bottom'
#'value:' #alignSelectionTopAndBottom
- #'enabled:' #hasValidSelection
#'activeHelpKey:' #alignSelectionTopAndBottom
#'labelImage:'
#(#ResourceRetriever
@@ -669,7 +717,6 @@
#(#MenuItem
#'label:' 'align centered horizontal'
#'value:' #alignSelectionCenterHor
- #'enabled:' #hasValidSelection
#'activeHelpKey:' #alignSelectionCenterHor
#'labelImage:'
#(#ResourceRetriever
@@ -679,7 +726,6 @@
#(#MenuItem
#'label:' 'align centered vertical'
#'value:' #alignSelectionCenterVer
- #'enabled:' #hasValidSelection
#'activeHelpKey:' #alignSelectionCenterVer
#'labelImage:'
#(#ResourceRetriever
@@ -708,21 +754,23 @@
^
#(#Menu
-
#(
#(#MenuItem
#'label:' 'copy'
#'value:' #copySelection
+ #'enabled:' #hasSelection
#'shortcutKeyCharacter:' #Copy
)
#(#MenuItem
#'label:' 'cut'
#'value:' #deleteSelection
+ #'enabled:' #hasSelection
#'shortcutKeyCharacter:' #Cut
)
#(#MenuItem
#'label:' 'paste'
#'nameKey:' #paste
+ #'enabled:' #canPaste
#'value:' #paste
#'submenu:'
#(#Menu
@@ -737,6 +785,7 @@
#(#MenuItem
#'label:' 'keep layout'
#'value:' #pasteWithLayout
+ #'enabled:' #canKeepLayoutInSelection
#'activeHelpKey:' #pasteWithLayout
)
) nil
@@ -749,6 +798,7 @@
#(#MenuItem
#'label:' 'undo'
#'nameKey:' #undo
+ #'enabled:' #hasUndoHistory
#'value:' #undoLast
)
#(#MenuItem
@@ -757,6 +807,7 @@
#(#MenuItem
#'label:' 'dimension'
#'value:' #dimension
+ #'enabled:' #hasSelection
#'submenu:'
#(#Menu
@@ -764,46 +815,55 @@
#(#MenuItem
#'label:' 'default extent'
#'value:' #setToDefaultExtent
+ #'enabled:' #canMoveOrAlignSelection
#'activeHelpKey:' #setToDefaultExtent
)
#(#MenuItem
#'label:' 'default width'
#'value:' #setToDefaultWidth
+ #'enabled:' #canMoveOrAlignSelection
#'activeHelpKey:' #setToDefaultWidth
)
#(#MenuItem
#'label:' 'default height'
#'value:' #setToDefaultHeight
+ #'enabled:' #canMoveOrAlignSelection
#'activeHelpKey:' #setToDefaultHeight
)
#(#MenuItem
#'label:' 'copy extent'
#'value:' #copyExtent
+ #'enabled:' #hasSingleSelection
#'activeHelpKey:' #copyExtent
)
#(#MenuItem
#'label:' 'paste extent'
#'value:' #pasteExtent
+ #'enabled:' #canMoveOrAlignSelection
#'activeHelpKey:' #pasteExtent
)
#(#MenuItem
#'label:' 'paste width'
#'value:' #pasteWidth
+ #'enabled:' #canMoveOrAlignSelection
#'activeHelpKey:' #pasteWidth
)
#(#MenuItem
#'label:' 'paste height'
#'value:' #pasteHeight
+ #'enabled:' #canMoveOrAlignSelection
#'activeHelpKey:' #pasteHeight
)
#(#MenuItem
#'label:' 'copy layout'
#'value:' #copyLayout
+ #'enabled:' #hasSingleSelection
#'activeHelpKey:' #copyLayout
)
#(#MenuItem
#'label:' 'paste layout'
#'value:' #pasteLayout
+ #'enabled:' #canMoveOrAlignSelection
#'activeHelpKey:' #pasteLayout
)
)
@@ -814,6 +874,7 @@
#(#MenuItem
#'label:' 'align'
#'value:' #align
+ #'enabled:' #canMoveOrAlignSelection
#'submenu:'
#(#Menu
@@ -930,15 +991,15 @@
!
-menuMove
+menuChangeHierarchy
"this window spec was automatically generated by the ST/X MenuEditor"
"do not manually edit this - the builder may not be able to
handle the specification if its corrupted."
"
- MenuEditor new openOnClass:UIPainter andSelector:#menuMove
- (Menu new fromLiteralArrayEncoding:(UIPainter menuMove)) startUp
+ MenuEditor new openOnClass:UIPainter andSelector:#menuChangeHierarchy
+ (Menu new fromLiteralArrayEncoding:(UIPainter menuChangeHierarchy)) startUp
"
<resource: #menu>
@@ -951,7 +1012,6 @@
#(#MenuItem
#'label:' 'stepUp'
#'value:' #doStepUp
- #'enabled:' #hasSingleSelection
#'labelImage:'
#(#ResourceRetriever
#UIPainter #iconStepUp
@@ -960,16 +1020,18 @@
#(#MenuItem
#'label:' 'stepDown'
#'value:' #doStepDown
- #'enabled:' #hasSingleSelection
#'labelImage:'
#(#ResourceRetriever
#UIPainter #iconStepDown
)
)
#(#MenuItem
+ #'label:' '-'
+ )
+ #(#MenuItem
#'label:' 'stepIn'
#'value:' #doStepIn
- #'enabled:' #canStepIn
+ #'enabled:' #canMoveSelectionIntoContainer
#'labelImage:'
#(#ResourceRetriever
#UIPainter #iconStepIn
@@ -978,14 +1040,13 @@
#(#MenuItem
#'label:' 'stepOut'
#'value:' #doStepOut
- #'enabled:' #canStepOut
+ #'enabled:' #canMoveSelectionOutOfContainer
#'labelImage:'
#(#ResourceRetriever
#UIPainter #iconStepOut
)
)
- )
- #( 2 )
+ ) nil
nil
)
!
@@ -1174,37 +1235,23 @@
)
! !
-!UIPainter methodsFor:'accessing menu'!
-
-menuCanvas
- ^ [ treeView canvas showMiddleButtonMenu ]
-!
-
-menuMove
- "this window spec was automatically generated by the ST/X MenuEditor"
-
- ^ self class menuMove
-
-
-!
-
-menuPullDown
- "this window spec was automatically generated by the ST/X MenuEditor"
-
- ^ self class menuPullDown
-
-
-! !
-
!UIPainter methodsFor:'actions'!
accept
+ "accept changes done to the specification. The component assigned to the
+ specification will change immediately dependant on the attributes derived
+ from the specification.
+ "
|layout|
self isLayoutToolSelected ifTrue:[
(layout := layoutTool layout) notNil ifTrue:[
layoutTool layoutType == #Extent ifTrue:[
- self painter setExtent:layout
+ layoutTool layoutView == self painter topView ifTrue:[
+ layoutTool layoutView extent:layout
+ ] ifFalse:[
+ self painter setExtent:layout
+ ]
] ifFalse:[
self painter setLayout:layout
]
@@ -1220,15 +1267,43 @@
!
cancel
- "cancel all changes and read back attributes from current view
+ "cancel all changes done to the specification; reread attributes from the
+ assigned component
"
self isModified ifTrue:[
specTool specification:(self painter specForSelection).
- layoutTool layoutView:(layoutTool layoutView).
+ self setViewInLayoutTool:(layoutTool layoutView).
self modifiedChannel value:false.
]
!
+moveSelectionDown
+ "move selected components down
+ "
+ self painter moveSelectionDown
+!
+
+moveSelectionLeft
+ "move selected components left
+ "
+ self painter moveSelectionLeft
+
+!
+
+moveSelectionRight
+ "move selected components right
+ "
+ self painter moveSelectionRight
+
+!
+
+moveSelectionUp
+ "move selected components up
+ "
+ self painter moveSelectionUp
+
+!
+
openEditMenu
|cls aspect editor|
@@ -1314,16 +1389,27 @@
!UIPainter methodsFor:'aspects'!
-canStepIn
- ^ builder booleanValueAspectFor:#canStepIn
-
- "Modified: 28.7.1997 / 12:52:16 / cg"
+canMoveOrAlignSelection
+ "returns a boolean value holder which is true in case that any selection exists
+ and all widgets in the selection can change its layout through to a move or
+ align operation
+ "
+ ^ builder booleanValueAspectFor:#canMoveOrAlignSelection
!
-canStepOut
- ^ builder booleanValueAspectFor:#canStepOut
-
- "Modified: 28.7.1997 / 12:52:18 / cg"
+canMoveSelectionIntoContainer
+ "returns a boolean value holder which is true in case that one component is selected
+ and can change its container widget to the next element in the list which will have
+ the same container.
+ "
+ ^ builder booleanValueAspectFor:#canMoveSelectionIntoContainer
+!
+
+canMoveSelectionOutOfContainer
+ "returns a boolean value holder which is true in case that one component is selected
+ which is contained within another component
+ "
+ ^ builder booleanValueAspectFor:#canMoveSelectionOutOfContainer
!
enableChannel
@@ -1333,6 +1419,8 @@
!
galleryShown
+ "returns a boolean value holder which is set to true if the gallery is shown
+ "
|holder|
(holder := builder bindingAt:#galleryShown) isNil ifTrue:[
@@ -1343,27 +1431,23 @@
!
-hasSingleSelection
- ^ builder booleanValueAspectFor:#hasSingleSelection
-
- "Modified: 28.7.1997 / 12:52:20 / cg"
-!
-
-hasValidSelection
- ^ builder booleanValueAspectFor:#hasValidSelection
-
- "Modified: 28.7.1997 / 12:52:22 / cg"
+hasOneSelectionOtherThanCanvas
+ "returns a value holder which is true in case that one component is selected
+ other than the canvas.
+ "
+ ^ builder booleanValueAspectFor:#hasOneSelectionOtherThanCanvas
!
modifiedChannel
+ "returns a boolean value holder which is set to true if something is modified
+ and not accepted
+ "
^ builder booleanValueAspectFor:#modifiedChannel
-
- "Modified: 28.7.1997 / 12:52:24 / cg"
!
noteBookView
- "automatically generated by UIPainter ..."
-
+ "returns the notebook view; initialize components within the notebook
+ "
|noteBook channel n1 n2|
(noteBook := builder bindingAt:#noteBookView) isNil ifTrue:[
@@ -1390,30 +1474,9 @@
^ noteBook
!
-objectList
- ^ nil
-"
- |holder|
-
- (holder := builder bindingAt:#objectList) isNil ifTrue:[
- builder aspectAt:#objectList put:(holder := SelectionInList).
- ].
- ^ holder
-
-"
-!
-
-objectListMenu
- "returns a block which returns the menu
- !!hack!!
+painterShown
+ "returns a boolean value holder which is set to true if the painter is shown
"
- ^ [ self painter showMiddleButtonMenu ].
-
-
-
-!
-
-painterShown
|holder|
(holder := builder bindingAt:#painterShown) isNil ifTrue:[
@@ -1425,8 +1488,8 @@
!
tabList
- "automatically generated by UIPainter ..."
-
+ "returns a value holder which keeps a list of labels assigned to the tabs
+ "
|holder|
(holder := builder bindingAt:#tabList) isNil ifTrue:[
@@ -1437,8 +1500,8 @@
!
tabModel
- "automatically generated by UIPainter ..."
-
+ "returns a value holder which keeps the current name of the tab selected
+ "
|holder|
(holder := builder bindingAt:#tabModel) isNil ifTrue:[
@@ -1449,6 +1512,8 @@
!
treeView
+ "returns the selection tree view which holds all widget identifiers
+ "
^ treeView
! !
@@ -1463,6 +1528,9 @@
!UIPainter methodsFor:'change & update'!
layoutChanged
+ "called by the painter/canvas whenever the layout of the current selected
+ widget changed
+ "
self isModified ifFalse:[
layoutTool update.
self modifiedChannel value:false
@@ -1470,13 +1538,14 @@
!
propertyChanged
- "property changed
+ "called by the painter/canvas whenever the property of the current selected
+ widget changed
"
|p|
(p := treeView propertySelected) notNil ifTrue:[
specTool specification:(p spec copy).
- layoutTool layoutView:(p view).
+ self setViewInLayoutTool:(p view).
self modifiedChannel value:false
] ifFalse:[
layoutTool layoutView notNil ifTrue:[
@@ -1487,7 +1556,8 @@
!
update:something with:aParameter from:someObject
-
+ "catch change notifications
+ "
someObject == treeView model ifTrue:[
something == #selection ifTrue:[self treeSelection].
^ self
@@ -1516,34 +1586,75 @@
!UIPainter methodsFor:'event handling'!
doesNotUnderstand:aMessage
- |painter|
-
- painter := self painter.
-
- (painter respondsTo:(aMessage selector)) ifTrue:[
+
+ |painter|
+
+ painter := self painter.
+
+ (painter respondsTo:(aMessage selector)) ifTrue:[
^ aMessage sendTo:painter
- ].
- super doesNotUnderstand:aMessage
+ ].
+ super doesNotUnderstand:aMessage
+
+! !
+
+!UIPainter methodsFor:'menu accessing'!
+
+menuAlignment
+ "returns the pull down menu which keeps the alignment operations
+ "
+ ^ self class menuAlignment
+
+!
+
+menuCanvas
+ "returns the middle button menu used by the painter and the tree view
+ "
+ ^ [ treeView canvas showMiddleButtonMenu ]
+!
+
+menuChangeHierarchy
+ "returns the hierarchy pull down menu
+ "
+ ^ self class menuChangeHierarchy
+
+
+!
+
+menuPullDown
+ "returns the main pull down menu
+ "
+ ^ self class menuPullDown
+
! !
!UIPainter methodsFor:'private'!
hideUIView:aView
+ "hide the view which is an application or top view
+ "
aView beIndependent.
aView unmap.
!
painter
+ "returns the painter/canvas view
+ "
^ treeView canvas
!
raiseUIView:aView
+ "raise the view which is an application or top view
+ "
aView map.
aView bePartner.
!
setClass:cls selector:selector
+ "set the application class and the selector under which the
+ window specification should be stored
+ "
|clsName superClassName|
clsName := cls name.
@@ -1563,12 +1674,25 @@
specSuperclass := superClassName.
"Modified: 24.6.1997 / 19:07:01 / cg"
+!
+
+setViewInLayoutTool:aView
+ "set view for layout tool
+ "
+ self painter topView ~~ aView ifTrue:[
+ layoutTool layoutView:aView type:nil
+ ] ifFalse:[
+ layoutTool layoutView:aView type:#Extent
+ ].
+
+
! !
!UIPainter methodsFor:'queries'!
hasSpecClass
-
+ "checks whether an application class is defined
+ "
specClass notNil ifTrue:[
^ (specClass isBehavior or:[(Smalltalk at:specClass asSymbol) notNil])
].
@@ -1576,7 +1700,9 @@
!
hasSpecClassAndSelector
-
+ "checks whether an application class and a selector under which
+ the window specification is stored is defined.
+ "
specSelector size > 1 ifTrue:[
^ self hasSpecClass
].
@@ -1584,70 +1710,41 @@
!
isHelpToolSelected
+ "returns true if current selected tab in the noteBook is assigned
+ to the 'Help' tool
+ "
^ tabSelection = 'Help'
!
isLayoutToolSelected
+ "returns true if current selected tab in the noteBook is assigned
+ to the 'Layout' tool
+ "
^ tabSelection = layoutTool class label
!
isModified
- "returns true if current spec. is modified
+ "returns true if current specification or layout is modified
"
^ self modifiedChannel value
!
isPainterEnabled
+ "returns true if not running in test mode
+ "
^ self painter enabled
! !
!UIPainter methodsFor:'selection'!
-canvasSelected
- |spec|
-
- self hasValidSelection value:false.
- self canStepIn value:false.
- self canStepOut value:false.
- self hasSingleSelection value:false.
-
- spec := treeView canvasSpec.
- (builder componentAt:#noteBook) setSelection:nil.
- self setupSlicesFrom:spec hasLayout:false.
- tabSelection := nil.
-
- layoutTool layoutView:nil.
- specTool specification:spec.
- self modifiedChannel value:false.
- self tabSelection:(self tabList value first).
- specTool selection:tabSelection.
- (self noteBookView subViews at:2) raise.
- (builder componentAt:#noteBook) setSelection:1.
- self modifiedChannel value:false.
-
-!
-
-setupSlicesFrom:aSpec hasLayout:hasLayout
-
- |slices list|
-
- slices := aSpec class slices.
- list := slices collect:[:aSlice| aSlice first asString].
-
- hasLayout ifTrue:[
- list add:(layoutTool class label)
- ].
- self tabList value:list.
-!
-
tabSelection
- "returns current name of section
+ "returns name of current selected tab in the notebook.
"
^ tabSelection
!
tabSelection:something
- "section changed
+ "the tab selection of the notebook changed
"
|raiseViewIdx|
@@ -1674,63 +1771,53 @@
!
treeSelection
- "called whenever tree-selection changed
+ "called whenever the selection of the treeview changed
"
- |oldSelection view slices list spec props size nameOfSpec|
+ |view list spec property tabComponent|
self isModified ifTrue:[
(self confirm:'accept change made in ' , tabSelection printString , ' section ?') ifTrue:[
self accept
]
].
+ self canMoveOrAlignSelection value:(treeView canMoveOrAlignSelection).
+ self canMoveSelectionIntoContainer value:(treeView canMoveSelectionIntoContainer).
+ self canMoveSelectionOutOfContainer value:(treeView canMoveSelectionOutOfContainer).
+ self hasOneSelectionOtherThanCanvas value:(treeView hasOneSelectionOtherThanCanvas).
+
treeView isCanvasSelected ifTrue:[
- ^ self canvasSelected
+ spec := treeView canvasSpec.
+ view := self painter topView.
+ ] ifFalse:[
+ (property := treeView propertySelected) notNil ifTrue:[
+ view := property view.
+ spec := property spec copy.
+ ]
].
-
- props := treeView propertySelected.
- oldSelection := tabSelection.
- tabSelection := nil.
-
- self hasValidSelection value:(treeView hasValidSelection).
- self canStepIn value:(treeView canStepIn).
- self canStepOut value:(treeView canStepOut).
-
- props isNil ifFalse:[
- self hasSingleSelection value:true.
- view := props view.
- spec := props spec copy.
-
- layoutTool layoutView == view ifFalse:[
- self setupSlicesFrom:spec hasLayout:true.
+ tabComponent := builder componentAt:#noteBook.
+ self setViewInLayoutTool:view.
+ specTool specification:spec.
+
+ spec notNil ifTrue:[
+ list := spec class slices collect:[:aSlice| aSlice first asString].
+ view notNil ifTrue:[list add:(layoutTool class label)].
+ self tabList value:list.
+ self showHelp:(spec class name) for:nil.
+ tabComponent enabled:true.
+
+ (tabSelection := tabComponent selection) isNil ifTrue:[
+ tabComponent setSelection:(tabSelection := list first)
].
- list := self tabList value.
-
- (list findFirst:[:n| n = oldSelection ]) ~~ 0 ifTrue:[
- tabSelection := oldSelection
- ] ifFalse:[
- tabSelection := list first
- ].
- nameOfSpec := spec class name.
- ] ifTrue:[
- self hasSingleSelection value:false.
- nameOfSpec := ''
- ].
-
- self showHelp:nameOfSpec for:nil.
-
- layoutTool layoutView:view.
- specTool specification:spec.
-
- tabSelection notNil ifTrue:[
self isLayoutToolSelected ifTrue:[
(self noteBookView subViews at:1) raise
] ifFalse:[
specTool selection:tabSelection.
(self noteBookView subViews at:2) raise
]
+ ] ifFalse:[
+ tabComponent enabled:false.
+ self showHelp:'' for:nil.
].
-
- (builder componentAt:#noteBook) setSelection:tabSelection.
self modifiedChannel value:false.
! !
@@ -1827,7 +1914,6 @@
topView := self window.
topView bePartner.
topView label:'GUI Builder'.
- topView icon:(Image fromFile:'bitmaps/UIPainter.xbm' resolution:100).
painterView openInGroup:(topView windowGroup).
painterView bePartner.
@@ -1842,6 +1928,15 @@
selectionPanel openWindow.
selectionPanel masterApplication:self.
+ topView iconLabel:'Builder'.
+ topView icon:(Image fromFile:'bitmaps/UIPainter.xbm' resolution:100).
+
+ painterView iconLabel:'Builder'.
+ painterView icon:(Image fromFile:'bitmaps/UIPainter.xbm' resolution:100).
+
+ selectionPanel window iconLabel:'Builder'.
+ selectionPanel window icon:(Image fromFile:'bitmaps/UIPainter.xbm' resolution:100).
+
"Modified: 1.8.1997 / 14:22:10 / cg"
!
@@ -2003,18 +2098,28 @@
!UIPainter methodsFor:'user interaction - move'!
doStepDown
+ "move selected component after the next component in the hierarchy of
+ its container widget
+ "
treeView doStepOver:1
!
doStepIn
+ "change the container of the selected widget
+ "
treeView doStepIn
!
doStepOut
+ "change the container of the selected widget
+ "
treeView doStepOut
!
doStepUp
+ "move selected component before the previous component in the hierarchy of
+ its container widget
+ "
treeView doStepOver:-1
! !
@@ -2049,6 +2154,9 @@
!
doFromClass
+ "setup new specification from a class and selector accessed through
+ to a dialog
+ "
|className methodName cls sel accepted failed spec s painter|
self painter isModified ifTrue:[
@@ -2114,6 +2222,8 @@
!
doInstallAspects
+ "install aspects and actions
+ "
|code|
self hasSpecClassAndSelector ifFalse:[
@@ -2144,6 +2254,8 @@
!
doInstallSpec
+ "install window specification
+ "
|code painter|
self hasSpecClassAndSelector ifFalse:[
@@ -2166,18 +2278,19 @@
!
doNew
+ "remove all components and associated resources
+ "
self painter isModified ifTrue:[
(self confirm:'edit a new interface without saving your modifications ?') ifFalse:[
^ self
]
].
-
- self removeAll
-
- "Modified: 28.7.1997 / 18:28:02 / cg"
+ self painter removeAll
!
doPickAView
+ "pick a view and setup specifications
+ "
|painter view cls spec|
self painter isModified ifTrue:[
@@ -2208,6 +2321,8 @@
!
doStartApplication
+ "start current edited application
+ "
|cls|
self painter isModified ifTrue:[
@@ -2241,6 +2356,9 @@
!
doWindowSpec
+ "create the window specification but do not write to application; instead
+ open a view
+ "
|code v|
code := self painter generateWindowSpecMethodSource.
@@ -2253,6 +2371,24 @@
!UIPainter::TreeView class methodsFor:'constants'!
+defaultNameOfCanvas
+ "returns the default name (id) of the application
+ "
+ ^ 'Canvas'
+!
+
+imageEmptyParent
+
+ ImageEmptyParent isNil ifTrue:[
+ ImageEmptyParent := Image fromFile:('xpmBitmaps/document_images/tiny_dir.xpm').
+ ].
+ ^ ImageEmptyParent
+
+ "
+ ImageEmptyParent := nil
+ "
+!
+
imageMasterChild
ImageMasterChild isNil ifTrue:[
@@ -2270,7 +2406,6 @@
imageMasterParent
ImageMasterParent isNil ifTrue:[
-"/ ImageMasterParent := Image fromFile:('xpmBitmaps/document_images/tiny_yellow_dir_locked.xpm').
ImageMasterParent := Image fromFile:('xpmBitmaps/document_images/tiny_yellow_dir_gray.xpm').
].
^ ImageMasterParent
@@ -2318,27 +2453,12 @@
props := UIPainterView::ViewProperty new.
props view:aCanvas.
- model root:(TreeItem name:'Canvas' contents:props).
+ model root:(TreeItem name:(self class defaultNameOfCanvas) contents:props).
model root expand.
self enableChannel:(aCanvas enableChannel).
!
-canvasName:aName
- "change id of canvas
- "
- |name|
-
- ( aName size ~~ 0
- and:[(name := aName string withoutSeparators) size ~~ 0
- and:[(self propertyDetect:[:p| p name = name]) isNil
- and:[(listOfNodes at:1) name ~= name]]]
- ) ifTrue:[
- (listOfNodes at:1) name:name.
- self redrawLine:1.
- ]
-!
-
canvasSpec
"returns spec assigned to canvas
"
@@ -2348,6 +2468,19 @@
spec fromView:(self canvas topView) callBack:nil.
spec name:(listOfNodes at:1) name.
^ spec
+!
+
+itemOfView:aView
+ "returns item assigned to view or nil
+ "
+ aView notNil ifTrue:[
+ self allItemsDo:[:anItem|
+ (anItem contents view == aView) ifTrue:[^ anItem]
+ ]
+ ].
+ ^ nil
+
+
! !
!UIPainter::TreeView methodsFor:'accessing property'!
@@ -2390,19 +2523,8 @@
addProperty:aProperty
"add a new item
"
- |prnt child canvas view|
-
- child := TreeItem name:(aProperty name) contents:aProperty.
- view := aProperty view.
- canvas := self canvas.
-
- [ ((view := view superView) notNil and:[(prnt := self itemOfView:view) isNil])
- ] whileTrue.
-
- prnt isNil ifTrue:[
- prnt := model root
- ].
- model add:child below:prnt.
+ model add:(TreeItem name:(aProperty name) contents:aProperty)
+ below:(self detectItemRespondsToView:(aProperty view superView))
!
@@ -2415,6 +2537,7 @@
self canvas subViews copy do:[:aView|
(aView isKindOf:InputView) ifFalse:[aView destroy]
].
+ model root name:(self class defaultNameOfCanvas).
model root children:(OrderedCollection new).
model recomputeList.
self selection:nil.
@@ -2425,14 +2548,11 @@
removeView:aView
"remove a view
"
- |item spv|
-
- item := self itemOfView:aView.
-
- item notNil ifTrue:[
- spv := aView superView.
+ |item prnt|
+
+ ((item := self itemOfView:aView) notNil and:[(prnt := item parent) notNil]) ifTrue:[
aView destroy.
- spv sizeChanged:nil.
+ prnt contents view sizeChanged:nil.
model remove:item
]
@@ -2617,6 +2737,16 @@
self canvas drop:anObjectOrCollection at:aPoint
! !
+!UIPainter::TreeView methodsFor:'enumerating'!
+
+allItemsDo:aOneArgBlock
+ "evaluate the argument a block on each item other than the canvas
+ "
+ model root allChildrenDo:aOneArgBlock
+
+
+! !
+
!UIPainter::TreeView methodsFor:'event processing'!
cvsEventsDisabledDo:aBlock
@@ -2667,58 +2797,39 @@
self multipleSelectOk:true.
self model:(SelectionInTree new).
cvsEventsDisabled := false.
-
+ imageMasterChild := (self class imageMasterChild) onDevice:device.
+ imageMasterParent := (self class imageMasterParent) onDevice:device.
+ imageEmptyParent := (self class imageEmptyParent) onDevice:device.
! !
!UIPainter::TreeView methodsFor:'private'!
-allItemsDo:aOneArgBlock
- "evaluate the argument a block on each item other than the canvas
- "
- model root allChildrenDo:aOneArgBlock
-
-
-!
-
figureFor:aNode
"returns image for an item; testing whether item is the first
entry into the selection
"
- |master|
+ |master subComp|
+
+ subComp := (aNode parent isNil or:[aNode contents spec class supportsSubComponents]).
selection size == 0 ifFalse:[
master := listOfNodes at:(selection first).
aNode == master ifTrue:[
lastDrawnMaster := master.
- aNode children size == 0 ifTrue:[
- imageMasterChild isNil ifTrue:[
- imageMasterChild := (self class imageMasterChild) onDevice:device.
- ].
- ^ imageMasterChild
- ].
- imageMasterParent isNil ifTrue:[
- imageMasterParent := (self class imageMasterParent) onDevice:device.
- ].
- ^ imageMasterParent
+ subComp ifFalse:[^ imageMasterChild]
+ ifTrue:[^ imageMasterParent].
]
].
- ^ super figureFor:aNode
-
-
-!
-
-itemOfView:aView
- "returns item assigned to view or nil
- "
- aView notNil ifTrue:[
- self allItemsDo:[:anItem|
- (anItem contents view == aView) ifTrue:[^ anItem]
- ]
+ subComp ifFalse:[
+ ^ imageItem
].
- ^ nil
-
+ aNode hasChildren ifTrue:[
+ aNode isExpandable ifTrue:[ ^ imageClosed ]
+ ifFalse:[ ^ imageOpened ]
+ ].
+ ^ imageEmptyParent
!
@@ -2726,34 +2837,57 @@
"selection has changed. update master selection and raise notification
to canvas in case of enabled cvs events
"
- |sel|
+ |sel size|
super selectionChangedFrom:oldSelection.
+ size := selection size.
cvsEventsDisabled ifFalse:[
- selection notNil ifTrue:[
- sel := selection collect:[:i| (listOfNodes at:i) contents view].
- ] ifFalse:[
- sel := #()
+ (size ~~ 0 and:[size ~~ 1 or:[selection first ~~ 1]]) ifTrue:[
+ sel := OrderedCollection new.
+
+ selection do:[:i|
+ i ~~ 1 ifTrue:[sel add:(listOfNodes at:i) contents view]
+ ]
].
- self canvas updateSelectionFromModel:sel.
+ self canvas updateSelectionFromModel:sel
].
- selection size ~~ 0 ifTrue:[
+ size ~~ 0 ifTrue:[
sel := selection first.
(listOfNodes at:sel) == lastDrawnMaster ifFalse:[
self redrawLine:sel
]
]
-
-
! !
!UIPainter::TreeView methodsFor:'queries'!
-canStepIn
- "returns true if can step in
+canMoveOrAlignSelection
+ "returns true if any selection exists and all widgets in the selection
+ can change their layout through to a move or align operation.
+ "
+ |canvas|
+
+ selection size == 0 ifTrue:[
+ ^ false
+ ].
+ canvas := self canvas.
+
+ selection do:[:i|
+ i == 1 ifTrue:[^ false].
+
+ (canvas canChangeLayoutOfView:((listOfNodes at:i) contents view)) ifFalse:[
+ ^ false
+ ]
+ ].
+ ^ true
+!
+
+canMoveSelectionIntoContainer
+ "returns true in case that one component is selected and can change its container
+ widget to the next element in the list which will have the same container.
"
|item prnt|
@@ -2767,7 +2901,10 @@
^ true
!
-canStepOut
+canMoveSelectionOutOfContainer
+ "returns true in case that one component is selected which is contained within
+ another component.
+ "
|item prnt|
( (item := self selectedNode) isNil
@@ -2779,17 +2916,10 @@
^ true
!
-hasValidSelection
- "returns true if any selection exists other than root
+hasOneSelectionOtherThanCanvas
+ "returns true in case that one selection exists other than the canvas
"
- |size|
-
- (size := selection size) > 1 ifFalse:[
- (size == 0 or:[self isInSelection:1]) ifTrue:[
- ^ false
- ]
- ].
- ^ true
+ ^ (selection size == 1 and:[selection first ~~ 1])
!
isCanvasSelected
@@ -2799,6 +2929,24 @@
^ (selection size == 1 and:[self isInSelection:1])
! !
+!UIPainter::TreeView methodsFor:'seraching'!
+
+detectItemRespondsToView:aView
+ "detect the item responding to the view. The item of the view or the first
+ subview providing the item is returned. If no property is detected nil is
+ returned
+ "
+ |view item|
+
+ (view := aView) notNil ifTrue:[
+ [(item := self itemOfView:view) isNil] whileTrue:[
+ (view := view superView) isNil ifTrue:[^ listOfNodes at:1]
+ ].
+ ].
+ ^ item
+
+! !
+
!UIPainter::TreeView methodsFor:'user interactions'!
doStepIn
@@ -2837,40 +2985,44 @@
doStepOver:anIndex
"move child 'anOffset' forward or backward in list of children
"
- |item idx size prnt spVw view|
+ |item idx size prnt spVw view canvas|
( (item := self selectedNode) isNil
or:[(prnt := item parent) isNil
- or:[(size := prnt children size) < 2]]
- ) ifFalse:[
- idx := prnt indexOfChild:item.
-
- model removeDependent:self.
- model removeSelection.
- selection := nil.
- model addDependent:self.
- idx := idx + anIndex.
-
- idx < 1 ifTrue:[idx := size]
- ifFalse:[idx > size ifTrue:[idx := 1]].
-
- model add:item beforeIndex:idx below:prnt.
- idx := prnt indexOfChild:item.
- view := item contents view.
- spVw := view superView.
-
- "/ input view might by contained in sequence
- ((size := self canvas findInputViewIn:spVw) ~~ 0 and:[idx >= size]) ifTrue:[
- idx := idx + 1
- ].
- spVw changeSequenceOrderFor:view to:idx.
-
- spVw specClass isLayoutContainer ifFalse:[
- spVw subViews do:[:v| v raise ].
- self canvas inputView raise
- ].
- self selectNode:item.
- ]
+ or:[(size := prnt children size) < 2
+ or:[(idx := prnt indexOfChild:item) == 0]]]
+ ) ifTrue:[
+ ^ self
+ ].
+ model removeDependent:self.
+ model removeSelection.
+ selection := nil.
+ model addDependent:self.
+ idx := idx + anIndex.
+
+ idx < 1 ifTrue:[idx := size]
+ ifFalse:[idx > size ifTrue:[idx := 1]].
+
+ model add:item beforeIndex:idx below:prnt.
+ idx := prnt indexOfChild:item.
+ view := item contents view.
+ spVw := prnt contents view.
+ canvas := self canvas.
+
+ canvas hideSelection.
+
+ "/ input view might by contained in sequence
+ ((size := canvas findInputViewIn:spVw) ~~ 0 and:[idx >= size]) ifTrue:[
+ idx := idx + 1
+ ].
+ spVw changeSequenceOrderFor:view to:idx.
+
+ spVw specClass isLayoutContainer ifFalse:[
+ spVw subViews do:[:v| v raise ].
+ canvas inputView raise
+ ].
+ canvas showSelection.
+ self selectNode:item.
! !
!UIPainter class methodsFor:'documentation'!