UIPainter.st
changeset 297 14db1276218c
parent 295 114befd1c369
child 301 131f874fc2a2
--- a/UIPainter.st	Wed Aug 27 17:03:18 1997 +0200
+++ b/UIPainter.st	Wed Aug 27 17:04:54 1997 +0200
@@ -13,7 +13,8 @@
 
 ApplicationModel subclass:#UIPainter
 	instanceVariableNames:'treeView selectionPanel tabSelection specClass specSelector
-		specSuperclass aspects layoutCanvas helpCanvas specCanvas'
+		specSuperclass aspects layoutCanvas helpCanvas specCanvas
+		transcript'
 	classVariableNames:'IconStepUp IconStepOut IconStepIn IconStepDown'
 	poolDictionaries:''
 	category:'Interface-UIPainter'
@@ -212,6 +213,51 @@
 )
 ! !
 
+!UIPainter class methodsFor:'helpers'!
+
+convertString:aString maxLineSize:maxCharactersPerLine
+    "converts a string to a string collection with maximum characters
+     per line
+    "
+    |stream
+        max     "{ Class:SmallInteger }"
+        size    "{ Class:SmallInteger }"
+        start   "{ Class:SmallInteger }"
+        stop    "{ Class:SmallInteger }"
+        cpySz   "{ Class:SmallInteger }"
+        lnSz    "{ Class:SmallInteger }"|
+
+    maxCharactersPerLine < 20 ifFalse:[max := maxCharactersPerLine - 1]
+                               ifTrue:[max := 20].
+
+    (size := aString size) <= max ifTrue:[
+        ^ aString
+    ].
+    start  := 1.
+    lnSz   := 0.
+    stream := (String new:size) writeStream.
+
+    [start <= size] whileTrue:[
+        (start := aString indexOfNonSeparatorStartingAt:start) == 0 ifTrue:[
+            ^ stream contents
+        ].
+        (stop := aString indexOfSeparatorStartingAt:start) == 0 ifTrue:[
+                stop := size + 1
+        ].
+        cpySz := stop - start.
+
+        lnSz == 0 ifFalse:[
+            (lnSz := lnSz + cpySz) >= max ifTrue:[stream cr.    lnSz := cpySz ]
+                                         ifFalse:[stream space. lnSz := lnSz + 1]
+        ] ifTrue:[
+            lnSz := cpySz
+        ].
+        stream nextPutAll:aString startingAt:start to:(stop - 1).
+        start := stop.
+    ].
+    ^ stream contents
+! !
+
 !UIPainter class methodsFor:'icons'!
 
 iconAlignB
@@ -447,11 +493,11 @@
           #'window:' 
            #(#WindowSpec
               #'name:' 'Tree-View'
-              #'layout:' #(#LayoutFrame 199 0 167 0 759 0 616 0)
+              #'layout:' #(#LayoutFrame 135 0 129 0 648 0 589 0)
               #'label:' 'Tree-View'
               #'min:' #(#Point 10 10)
               #'max:' #(#Point 1160 870)
-              #'bounds:' #(#Rectangle 199 167 760 617)
+              #'bounds:' #(#Rectangle 135 129 649 590)
           )
           #'component:' 
            #(#SpecCollection
@@ -463,55 +509,6 @@
                     #'tabable:' true
                     #'menu:' #menuPullDown
                 )
-                 #(#NoteBookViewSpec
-                    #'name:' 'noteBook'
-                    #'layout:' #(#LayoutFrame 0 0.4 59 0.0 0 1.0 -55 1.0)
-                    #'enableChannel:' #enableChannel
-                    #'tabable:' true
-                    #'menu:' #tabList
-                    #'model:' #tabModel
-                    #'tabWidget:' #Window
-                    #'canvas:' #noteBookView
-                )
-                 #(#HorizontalPanelViewSpec
-                    #'name:' 'modifyPanel'
-                    #'layout:' #(#LayoutFrame 0 0.4 -55 1.0 0 1.0 -25 1.0)
-                    #'component:' 
-                     #(#SpecCollection
-                        #'collection:' 
-                         #(
-                           #(#ActionButtonSpec
-                              #'name:' 'cancelButton'
-                              #'activeHelpKey:' #cancel
-                              #'label:' 'cancel'
-                              #'tabable:' true
-                              #'model:' #cancel
-                              #'enableChannel:' #modifiedChannel
-                              #'extent:' #(#Point 164 24)
-                          )
-                           #(#ActionButtonSpec
-                              #'name:' 'acceptButton'
-                              #'activeHelpKey:' #accept
-                              #'label:' 'ok'
-                              #'tabable:' true
-                              #'model:' #accept
-                              #'enableChannel:' #modifiedChannel
-                              #'extent:' #(#Point 164 24)
-                          )
-                        )
-                    )
-                    #'level:' 0
-                    #'horizontalLayout:' #fitSpace
-                    #'verticalLayout:' #fitSpace
-                    #'horizontalSpace:' 3
-                    #'verticalSpace:' 3
-                )
-                 #(#LabelSpec
-                    #'name:' 'helpInfo'
-                    #'layout:' #(#LayoutFrame 2 0.0 -25 1.0 -2 1.0 -2 1.0)
-                    #'level:' -1
-                    #'adjust:' #left
-                )
                  #(#ToggleSpec
                     #'name:' 'galleryLabel'
                     #'layout:' #(#LayoutFrame -162 1.0 1 0 -82 1.0 23 0)
@@ -532,17 +529,6 @@
                     #'showLamp:' true
                     #'lampColor:' #(#Color 100.0 100.0 0.0)
                 )
-                 #(#ArbitraryComponentSpec
-                    #'name:' 'treeView'
-                    #'layout:' #(#LayoutFrame 0 0.0 59 0 0 0.4 -25 1.0)
-                    #'menu:' #menuCanvas
-                    #'hasHorizontalScrollBar:' true
-                    #'hasVerticalScrollBar:' true
-                    #'miniScrollerHorizontal:' true
-                    #'miniScrollerVertical:' true
-                    #'component:' #treeView
-                    #'hasBorder:' false
-                )
                  #(#HorizontalPanelViewSpec
                     #'name:' 'menuContainer'
                     #'layout:' #(#LayoutFrame 0 0.0 26 0 0 1.0 58 0)
@@ -626,6 +612,97 @@
                     #'horizontalSpace:' 3
                     #'verticalSpace:' 3
                 )
+                 #(#VariableVerticalPanelSpec
+                    #'name:' 'vpanel'
+                    #'layout:' #(#LayoutFrame 0 0.0 59 0.0 0 1.0 0 1.0)
+                    #'component:' 
+                     #(#SpecCollection
+                        #'collection:' 
+                         #(
+                           #(#VariableHorizontalPanelSpec
+                              #'name:' 'hpanel'
+                              #'component:' 
+                               #(#SpecCollection
+                                  #'collection:' 
+                                   #(
+                                     #(#ArbitraryComponentSpec
+                                        #'name:' 'treeView'
+                                        #'menu:' #menuCanvas
+                                        #'hasHorizontalScrollBar:' true
+                                        #'hasVerticalScrollBar:' true
+                                        #'miniScrollerHorizontal:' true
+                                        #'miniScrollerVertical:' true
+                                        #'component:' #treeView
+                                        #'hasBorder:' false
+                                    )
+                                     #(#ViewSpec
+                                        #'name:' 'specHolderView'
+                                        #'component:' 
+                                         #(#SpecCollection
+                                            #'collection:' 
+                                             #(
+                                               #(#NoteBookViewSpec
+                                                  #'name:' 'noteBook'
+                                                  #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 -30 1.0)
+                                                  #'enableChannel:' #enableChannel
+                                                  #'tabable:' true
+                                                  #'menu:' #tabList
+                                                  #'model:' #tabModel
+                                                  #'tabWidget:' #Window
+                                                  #'canvas:' #noteBookView
+                                              )
+                                               #(#HorizontalPanelViewSpec
+                                                  #'name:' 'modifyPanel'
+                                                  #'layout:' #(#LayoutFrame 0 0.0 -30 1.0 0 1.0 0 1.0)
+                                                  #'component:' 
+                                                   #(#SpecCollection
+                                                      #'collection:' 
+                                                       #(
+                                                         #(#ActionButtonSpec
+                                                            #'name:' 'cancelButton'
+                                                            #'activeHelpKey:' #cancel
+                                                            #'label:' 'cancel'
+                                                            #'tabable:' true
+                                                            #'model:' #cancel
+                                                            #'enableChannel:' #modifiedChannel
+                                                            #'extent:' #(#Point 165 24)
+                                                        )
+                                                         #(#ActionButtonSpec
+                                                            #'name:' 'acceptButton'
+                                                            #'activeHelpKey:' #accept
+                                                            #'label:' 'ok'
+                                                            #'tabable:' true
+                                                            #'model:' #accept
+                                                            #'enableChannel:' #modifiedChannel
+                                                            #'extent:' #(#Point 165 24)
+                                                        )
+                                                      )
+                                                  )
+                                                  #'horizontalLayout:' #fitSpace
+                                                  #'verticalLayout:' #fitSpace
+                                                  #'horizontalSpace:' 3
+                                                  #'verticalSpace:' 3
+                                              )
+                                            )
+                                        )
+                                        #'borderWidth:' 1
+                                    )
+                                  )
+                              )
+                              #'level:' 1
+                              #'handles:' #(#Any 0.329435 1.0)
+                          )
+                           #(#TextEditorSpec
+                              #'name:' 'Transcript'
+                              #'hasHorizontalScrollBar:' true
+                              #'hasVerticalScrollBar:' true
+                              #'miniScrollerHorizontal:' true
+                              #'miniScrollerVertical:' true
+                          )
+                        )
+                    )
+                    #'handles:' #(#Any 0.880597 1.0)
+                )
               )
           )
       )
@@ -1361,27 +1438,6 @@
     "Modified: 31.7.1997 / 14:26:13 / cg"
 ! !
 
-!UIPainter methodsFor:'active help'!
-
-showHelp:aHelpText for:view
-    "hook to allow an application to display active help
-     texts in its own info area.
-     This method may be redefined in a concrete application.
-     If it returns false, the ActiveHelp manager will popup a
-     bubble with the help text."
-
-    |l|
-
-    (l := self builder componentAt:#helpInfo) notNil ifTrue:[
-        aHelpText replaceAll:(Character cr) by:(Character space).
-        l label:aHelpText.
-      ^ true.
-    ].
-    ^ false
-
-
-! !
-
 !UIPainter methodsFor:'aspects'!
 
 canMoveOrAlignSelection
@@ -1633,6 +1689,31 @@
 
 ! !
 
+!UIPainter methodsFor:'printing'!
+
+show:aText
+    transcript hideCursor.
+    transcript contents:aText.
+        
+!
+
+showHelp:aHelpText for:view
+    "hook to allow an application to display active help
+     texts in its own info area.
+     This method may be redefined in a concrete application.
+     If it returns false, the ActiveHelp manager will popup a
+     bubble with the help text."
+
+    |txt|
+
+    txt := self class convertString:(aHelpText asString)
+                        maxLineSize:(transcript width // transcript font width).
+
+    transcript hideCursor.
+    transcript contents:txt.
+  ^ true
+! !
+
 !UIPainter methodsFor:'private'!
 
 hideUIView:aView
@@ -1852,7 +1933,7 @@
         list at:(size + 1) put:(UIHelpTool   label).
         list at:(size + 2) put:(UILayoutTool label).
         self tabList value:list.
-        self showHelp:(spec class name) for:nil.
+        self show:(spec class name).
         tabComponent enabled:true.
 
         (tabSelection := tabComponent selection) isNil ifTrue:[
@@ -1862,7 +1943,7 @@
     ] ifFalse:[
         self helpTool helpKey:nil.
         tabComponent enabled:false.
-        self showHelp:'' for:nil.
+        self show:nil.
     ].
     self modifiedChannel value:false.
 ! !
@@ -1953,7 +2034,7 @@
     treeView model addDependent:self.
 
     super openInterface.
-
+    transcript := (self builder componentAt:#Transcript) scrolledView.
     topView := self window.
     topView bePartner.
     topView label:'GUI Builder'.