UIPainter.st
changeset 287 1ecabfd468dc
parent 282 bb88d92ae887
child 295 114befd1c369
--- a/UIPainter.st	Wed Aug 20 17:55:38 1997 +0200
+++ b/UIPainter.st	Wed Aug 20 17:57:49 1997 +0200
@@ -12,8 +12,8 @@
 
 
 ApplicationModel subclass:#UIPainter
-	instanceVariableNames:'activeHelpTool layoutTool specTool treeView selectionPanel
-		tabSelection specClass specSelector specSuperclass aspects'
+	instanceVariableNames:'treeView selectionPanel tabSelection specClass specSelector
+		specSuperclass aspects layoutCanvas helpCanvas specCanvas'
 	classVariableNames:'IconStepUp IconStepOut IconStepIn IconStepDown'
 	poolDictionaries:''
 	category:'Interface-UIPainter'
@@ -106,115 +106,106 @@
     "
   ^ super helpSpec addPairsFrom:#(
 
-#alignSelectionCenterVer
-'align selected widgets vertical'
-
-#alignSelectionLeft
-'align selected widgets to the left edge of the dominant widget ( underlined )'
-
-#alignSelectionRight
-'align selected widgets to the right edge of the dominant widget ( underlined )'
-
-#alignSelectionLeftAndRight
-'align selected widgets to the right and left edge of the dominant widget ( underlined )'
-
-#alignSelectionTop
-'align selected widgets to the top edge of the dominant widget ( underlined )'
-
-#alignSelectionBottom
-'align selected widgets to the bottom edge of the dominant widget ( underlined )'
-
-#alignSelectionTopAndBottom
-'align selected widgets to the top and bottom edge of the dominant widget ( underlined )'
-
-#alignSelectionCenterVer
-'align selected widgets horizontal to the center of the dominant widget ( underlined )'
-
-#alignSelectionCenterHor
-'align selected widgets vertical to the center of the dominant widget ( underlined )'
-
-#spreadSelectionVer
-'vertical spacing between selected widgets is made the same'
-
-#spreadSelectionHor
-'horizontal spacing between selected widgets is made the same'
-
-#centerSelectionHor
-'center widgets horizontal to their top widget'
-
-#centerSelectionVer
-'center vertical horizontal in contained view'
-
-#setToDefaultExtent
-'set selected widgets to their default extent'
+#moveSelectionLeft
+'move selected widgets left while pressing the button'
 
 #setToDefaultWidth
 'set selected widgets to their default width'
 
-#setToDefaultHeight
-'set selected widgets to their default height'
-
-#copyExtent
-'copy extent of the selected widget'
-
-#pasteExtent
-'change extent of all selected widgets to the last copied extent'
-
-#pasteWidth
-'change width of all selected widgets to the last copied extent width'
-
-#pasteHeight
-'change height of all selected widgets to the last copied extent height'
-
-#copyLayout
-'copy layout of the selected widget'
-
-#pasteLayout
-'change layout of all selected widgets to the last copied layout'
-
 #pasteBuffer
 'paste widgets at current mouse position'
 
-#pasteWithLayout
-'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'
 
+#spreadSelectionVer
+'vertical spacing between selected widgets is made the same'
+
 #menuChangeHierarchy
 'change hierarchy of the selected widget'
 
+#copyExtent
+'copy extent of the selected widget'
+
+#moveSelectionRight
+'move selected widgets right while pressing the button'
+
+#cancel
+'reread specification and layout'
+
+#pasteWithLayout
+'paste widgets without changing their layouts'
+
+#alignSelectionRight
+'align selected widgets to the right edge of the dominant widget'
+
+#alignSelectionLeftAndRight
+'align selected widgets to the right and left edge of the dominant widget'
+
+#pasteWidth
+'change width of all selected widgets to the last copied extent width'
+
+#alignSelectionTopAndBottom
+'align selected widgets to the top and bottom edge of the dominant widget'
+
+#copyLayout
+'copy layout of the selected widget'
+
+#painterShown
+'show or hide painter view'
+
+#pasteExtent
+'change extent of all selected widgets to the last copied extent'
+
+#pasteHeight
+'change height of all selected widgets to the last copied extent height'
+
+#accept
+'write back changes'
+
+#centerSelectionVer
+'center vertical horizontal in contained view'
+
+#centerSelectionHor
+'center widgets horizontal to their top widget'
+
 #menuAlignment
 'provides a set of alignment operation on the current selected widgets'
 
-
+#alignSelectionCenterVer
+'align selected widgets horizontal to the center of the dominant widget'
+
+#pasteLayout
+'change layout of all selected widgets to the last copied layout'
+
+#alignSelectionLeft
+'align selected widgets to the left edge of the dominant widget'
+
+#spreadSelectionHor
+'horizontal spacing between selected widgets is made the same'
+
+#alignSelectionBottom
+'align selected widgets to the bottom edge of the dominant widget'
+
+#setToDefaultExtent
+'set selected widgets to their default extent'
+
+#alignSelectionCenterHor
+'align selected widgets vertical to the center of the dominant widget'
+
+#alignSelectionTop
+'align selected widgets to the top edge of the dominant widget'
+
+#setToDefaultHeight
+'set selected widgets to their default height'
 
 )
-
-
-
-
 ! !
 
 !UIPainter class methodsFor:'icons'!
@@ -340,7 +331,7 @@
        #(#FullSpec
           #'window:' 
            #(#WindowSpec
-              #'name:' 'uIPainterView'
+              #'name:' 'NameAndSelectorSpec'
               #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
               #'label:' 'Painter'
               #'bounds:' #(#Rectangle 0 0 391 170)
@@ -474,11 +465,6 @@
                     #'enableChannel:' #enableChannel
                     #'tabable:' true
                     #'menu:' #tabList
-                    #'style:' 
-                     #(#FontDescription
-                        #helvetica #medium
-                        #roman #'10'
-                    )
                     #'model:' #tabModel
                     #'tabWidget:' #Window
                     #'canvas:' #noteBookView
@@ -664,6 +650,7 @@
              #(#MenuItem
                 #'label:' 'align left'
                 #'value:' #alignSelectionLeft
+                #'activeHelpKey:' #alignSelectionLeft
                 #'labelImage:' 
                  #(#ResourceRetriever
                     nil #iconAlignL
@@ -1242,9 +1229,11 @@
      specification will change immediately dependant on the attributes derived
      from the specification.
     "
-    |layout|
+    |layout spec prop key layoutTool|
 
     self isLayoutToolSelected ifTrue:[
+        layoutTool := self layoutTool.
+
         (layout := layoutTool layout) notNil ifTrue:[
             layoutTool layoutType == #Extent ifTrue:[
                 layoutTool layoutView == self painter topView ifTrue:[
@@ -1257,22 +1246,37 @@
             ]
         ]
     ] ifFalse:[
+        spec := self specTool specification.
+
         self isHelpToolSelected ifTrue:[
-            activeHelpTool accept
-        ].
-        self painter updateFromSpec:(specTool specification).
+            self helpTool accept.
+            key  := self helpTool helpKey.
+            prop := treeView propertySelected.
+
+            prop notNil ifTrue:[
+                prop spec activeHelpKey:key
+            ].
+            spec activeHelpKey:key.
+        ] ifFalse:[
+            self painter updateFromSpec:spec.
+        ]
     ].
     self modifiedChannel value:false.
-
 !
 
 cancel
     "cancel all changes done to the specification; reread attributes from the
      assigned component
     "
+    |spec key|
+
     self isModified ifTrue:[
-        specTool specification:(self painter specForSelection).
-        self setViewInLayoutTool:(layoutTool layoutView).
+        (spec := self painter specForSelection) notNil ifTrue:[
+            key := spec activeHelpKey.
+        ].
+        self helpTool helpKey:key.
+        self specTool specification:spec.
+        self setViewInLayoutTool:(self layoutTool layoutView).
         self modifiedChannel value:false.
     ]
 !
@@ -1305,6 +1309,8 @@
 !
 
 openEditMenu
+    "opens a menu editor on current widget
+    "
     |cls aspect editor|
 
     specClass isNil ifTrue:[
@@ -1318,7 +1324,7 @@
     ].
 
     cls notNil ifTrue:[
-        (aspect := specTool specification menu) notNil ifTrue:[
+        (aspect := self specTool specification menu) notNil ifTrue:[
             aspect := aspect asSymbol
         ] ifFalse:[
             "/ cg: q&d hack ...
@@ -1331,21 +1337,17 @@
                     aspect := aspect view asMenu.
                 ]
             ].
-
-"/            aspect isNil ifTrue:[
-"/                self warn:'first enter (and confirm) the menus selector.'.
-"/                ^ self.
-"/            ].
         ].
         
         editor := MenuEditor new.
         editor masterApplication:self.
-        editor activeHelpTool:(self activeHelpTool).
+        editor useHelpDictionary:(self helpTool dictionary).
         editor openModalOnClass:cls andSelector:aspect.
+        self helpTool updateList.
 
         editor selectorName ~= aspect ifTrue:[
             editor didInstall ifTrue:[
-                specTool specification menu:editor selectorName asSymbol.
+                self specTool specification menu:editor selectorName asSymbol.
                 self modifiedChannel value:true.
                 self accept
             ]
@@ -1357,17 +1359,6 @@
 
 !UIPainter methodsFor:'active help'!
 
-activeHelpTool
-    "setup help tool
-    "
-    activeHelpTool isNil ifTrue:[
-        activeHelpTool := UIHelpTool new.
-        activeHelpTool helpSpecFrom:specClass.
-        activeHelpTool masterApplication:self.
-    ].
-    ^ activeHelpTool
-!
-
 showHelp:aHelpText for:view
     "hook to allow an application to display active help
      texts in its own info area.
@@ -1448,27 +1439,36 @@
 noteBookView
     "returns the notebook view; initialize components within the notebook
     "
-    |noteBook channel n1 n2|
+    |noteBook channel helpTool layoutTool specTool|
 
     (noteBook := builder bindingAt:#noteBookView) isNil ifTrue:[
         noteBook   := View new.
         layoutTool := UILayoutTool new.
+        helpTool   := UIHelpTool   new.
+        helpTool helpSpecFrom:specClass.
         specTool   := UISpecificationTool new.
         channel    := self modifiedChannel.
 
         layoutTool masterApplication:self.
         specTool   masterApplication:self.
-
-        n1 := SubCanvas origin:0.0@0.0 corner:1.0@1.0 in:noteBook.
-        n2 := SubCanvas origin:0.0@0.0 corner:1.0@1.0 in:noteBook.
-
-        n1 client:layoutTool.
-        specTool builder:(n2 client:specTool).
+        helpTool   masterApplication:self.
+
+        layoutCanvas := SubCanvas origin:0.0@0.0 corner:1.0@1.0 in:noteBook.
+        helpCanvas   := SubCanvas origin:0.0@0.0 corner:1.0@1.0 in:noteBook.
+        specCanvas   := SubCanvas origin:0.0@0.0 corner:1.0@1.0 in:noteBook.
+
+        layoutCanvas client:layoutTool.
+        helpCanvas   client:helpTool.
+        specTool builder:(specCanvas client:specTool).
 
         layoutTool masterApplication:self.
         specTool   masterApplication:self.
+        helpTool   masterApplication:self.
+
         layoutTool modifiedHolder:channel.
+        helpTool   modifiedHolder:channel.
         specTool   modifiedHolder:channel.
+
         builder aspectAt:#noteBookView put:noteBook.
     ].
     ^ noteBook
@@ -1532,7 +1532,7 @@
      widget changed
     "
     self isModified ifFalse:[
-        layoutTool update.
+        self layoutTool update.
         self modifiedChannel value:false
     ]
 !
@@ -1544,11 +1544,11 @@
     |p|
 
     (p := treeView propertySelected) notNil ifTrue:[
-        specTool specification:(p spec copy).
+        self specTool specification:(p spec copy).
         self setViewInLayoutTool:(p view).
         self modifiedChannel value:false
     ] ifFalse:[
-        layoutTool layoutView notNil ifTrue:[
+        self layoutTool layoutView notNil ifTrue:[
             self modifiedChannel value:false.
             self treeSelection
         ]
@@ -1638,10 +1638,18 @@
     aView unmap.
 !
 
-painter
-    "returns the painter/canvas view
-    "
-    ^ treeView canvas
+raiseTabView
+
+    self isLayoutToolSelected ifTrue:[
+        layoutCanvas raise
+    ] ifFalse:[
+        self isHelpToolSelected ifTrue:[
+            helpCanvas raise
+        ] ifFalse:[
+            self specTool selection:tabSelection.
+            specCanvas raise
+        ]
+    ]
 !
 
 raiseUIView:aView
@@ -1669,7 +1677,7 @@
             superclassName:superClassName
             selector:(selector ? '').
 
-    specClass := clsName.
+    self specClass:clsName.
     specSelector := (selector ? '').
     specSuperclass := superClassName.
 
@@ -1679,13 +1687,53 @@
 setViewInLayoutTool:aView
     "set view for layout tool
     "
-    self painter topView ~~ aView ifTrue:[
-        layoutTool layoutView:aView type:nil
-    ] ifFalse:[
-        layoutTool layoutView:aView type:#Extent
+    |type|
+
+    self painter topView == aView ifTrue:[
+        type := #Extent
+    ].
+    self layoutTool layoutView:aView type:type
+
+!
+
+specClass:aClass
+    specClass := aClass.
+    self helpTool helpSpecFrom:specClass.
+! !
+
+!UIPainter methodsFor:'private tools'!
+
+helpTool
+    "returns the help tool
+    "
+    helpCanvas isNil ifTrue:[
+        self noteBookView
     ].
-
-
+    ^ helpCanvas application
+!
+
+layoutTool
+    "returns the layout tool
+    "
+    layoutCanvas isNil ifTrue:[
+        self noteBookView
+    ].
+    ^ layoutCanvas application
+!
+
+painter
+    "returns the painter/canvas view
+    "
+    ^ treeView canvas
+!
+
+specTool
+    "returns the spec tool
+    "
+    specCanvas isNil ifTrue:[
+        self noteBookView
+    ].
+    ^ specCanvas application
 ! !
 
 !UIPainter methodsFor:'queries'!
@@ -1713,14 +1761,15 @@
     "returns true if current selected tab in the noteBook is assigned
      to the 'Help' tool
     "
-    ^ tabSelection = 'Help'
+    ^ tabSelection = UIHelpTool label
+
 !
 
 isLayoutToolSelected
     "returns true if current selected tab in the noteBook is assigned
      to the 'Layout' tool
     "
-    ^ tabSelection = layoutTool class label
+    ^ tabSelection = UILayoutTool label
 !
 
 isModified
@@ -1746,8 +1795,6 @@
 tabSelection:something
     "the tab selection of the notebook changed
     "
-    |raiseViewIdx|
-
     (something isNil or:[tabSelection = something]) ifTrue:[
         ^ self
     ].
@@ -1759,14 +1806,8 @@
         self accept
     ].
 
-    raiseViewIdx := 1.
     tabSelection := something.
-
-    self isLayoutToolSelected ifFalse:[
-        specTool selection:tabSelection.
-        raiseViewIdx := 2
-    ].
-    (self noteBookView subViews at:raiseViewIdx) raise.
+    self raiseTabView.
     self cancel.
 !
 
@@ -1796,11 +1837,13 @@
     ].
     tabComponent := builder componentAt:#noteBook.
     self setViewInLayoutTool:view.
-    specTool specification:spec.
+    self specTool specification:spec.
 
     spec notNil ifTrue:[
+        self helpTool helpKey:(spec activeHelpKey).
         list := spec class slices collect:[:aSlice| aSlice first asString].
-        view notNil ifTrue:[list add:(layoutTool class label)].
+        list add:(UIHelpTool   label).
+        list add:(UILayoutTool label).
         self tabList value:list.
         self showHelp:(spec class name) for:nil.
         tabComponent enabled:true.
@@ -1808,18 +1851,13 @@
         (tabSelection := tabComponent selection) isNil ifTrue:[
             tabComponent setSelection:(tabSelection := list first)
         ].
-        self isLayoutToolSelected ifTrue:[
-            (self noteBookView subViews at:1) raise
-        ] ifFalse:[
-            specTool selection:tabSelection.
-            (self noteBookView subViews at:2) raise
-        ]
+        self raiseTabView
     ] ifFalse:[
+        self helpTool helpKey:nil.
         tabComponent enabled:false.
         self showHelp:'' for:nil.
     ].
     self modifiedChannel value:false.
-
 ! !
 
 !UIPainter methodsFor:'startup / release'!
@@ -1841,9 +1879,7 @@
         selectionPanel closeRequest
     ].
     selectionPanel := nil.
-    layoutTool     := nil.
     treeView       := nil.
-    activeHelpTool := nil.
 
     super closeRequest.
 
@@ -2078,7 +2114,7 @@
 
         (self openDialogInterface:#nameAndSelectorSpec) ifTrue:[
 
-            specClass := (self aspectFor:#classNameChannel) value.
+            specClass    := (self aspectFor:#classNameChannel) value.
             specSelector := (self aspectFor:#methodNameChannel) value.
             specSelector notNil ifTrue:[specSelector := specSelector asSymbol].
             specSuperclass := (self aspectFor:#superclassNameChannel) value.
@@ -2090,9 +2126,9 @@
             ]
         ]
 
-    ] doWhile:[again]
-
-    "Modified: 17.6.1997 / 14:42:02 / cg"
+    ] doWhile:[again].
+
+    self specClass:specClass.
 ! !
 
 !UIPainter methodsFor:'user interaction - move'!
@@ -2246,11 +2282,7 @@
 doInstallHelp
     "install help text
     "
-    activeHelpTool notNil ifTrue:[
-        activeHelpTool installHelpSpecInto:specClass
-    ] ifFalse:[
-        self information:'no help text defined'
-    ]    
+    self helpTool installHelpSpecInto:specClass
 !
 
 doInstallSpec