UIPainter.st
changeset 297 14db1276218c
parent 295 114befd1c369
child 301 131f874fc2a2
equal deleted inserted replaced
296:e542c6fb0de7 297:14db1276218c
    11 "
    11 "
    12 
    12 
    13 
    13 
    14 ApplicationModel subclass:#UIPainter
    14 ApplicationModel subclass:#UIPainter
    15 	instanceVariableNames:'treeView selectionPanel tabSelection specClass specSelector
    15 	instanceVariableNames:'treeView selectionPanel tabSelection specClass specSelector
    16 		specSuperclass aspects layoutCanvas helpCanvas specCanvas'
    16 		specSuperclass aspects layoutCanvas helpCanvas specCanvas
       
    17 		transcript'
    17 	classVariableNames:'IconStepUp IconStepOut IconStepIn IconStepDown'
    18 	classVariableNames:'IconStepUp IconStepOut IconStepIn IconStepDown'
    18 	poolDictionaries:''
    19 	poolDictionaries:''
    19 	category:'Interface-UIPainter'
    20 	category:'Interface-UIPainter'
    20 !
    21 !
    21 
    22 
   208 
   209 
   209 #setToDefaultHeight
   210 #setToDefaultHeight
   210 'set selected widgets to their default height'
   211 'set selected widgets to their default height'
   211 
   212 
   212 )
   213 )
       
   214 ! !
       
   215 
       
   216 !UIPainter class methodsFor:'helpers'!
       
   217 
       
   218 convertString:aString maxLineSize:maxCharactersPerLine
       
   219     "converts a string to a string collection with maximum characters
       
   220      per line
       
   221     "
       
   222     |stream
       
   223         max     "{ Class:SmallInteger }"
       
   224         size    "{ Class:SmallInteger }"
       
   225         start   "{ Class:SmallInteger }"
       
   226         stop    "{ Class:SmallInteger }"
       
   227         cpySz   "{ Class:SmallInteger }"
       
   228         lnSz    "{ Class:SmallInteger }"|
       
   229 
       
   230     maxCharactersPerLine < 20 ifFalse:[max := maxCharactersPerLine - 1]
       
   231                                ifTrue:[max := 20].
       
   232 
       
   233     (size := aString size) <= max ifTrue:[
       
   234         ^ aString
       
   235     ].
       
   236     start  := 1.
       
   237     lnSz   := 0.
       
   238     stream := (String new:size) writeStream.
       
   239 
       
   240     [start <= size] whileTrue:[
       
   241         (start := aString indexOfNonSeparatorStartingAt:start) == 0 ifTrue:[
       
   242             ^ stream contents
       
   243         ].
       
   244         (stop := aString indexOfSeparatorStartingAt:start) == 0 ifTrue:[
       
   245                 stop := size + 1
       
   246         ].
       
   247         cpySz := stop - start.
       
   248 
       
   249         lnSz == 0 ifFalse:[
       
   250             (lnSz := lnSz + cpySz) >= max ifTrue:[stream cr.    lnSz := cpySz ]
       
   251                                          ifFalse:[stream space. lnSz := lnSz + 1]
       
   252         ] ifTrue:[
       
   253             lnSz := cpySz
       
   254         ].
       
   255         stream nextPutAll:aString startingAt:start to:(stop - 1).
       
   256         start := stop.
       
   257     ].
       
   258     ^ stream contents
   213 ! !
   259 ! !
   214 
   260 
   215 !UIPainter class methodsFor:'icons'!
   261 !UIPainter class methodsFor:'icons'!
   216 
   262 
   217 iconAlignB
   263 iconAlignB
   445      
   491      
   446        #(#FullSpec
   492        #(#FullSpec
   447           #'window:' 
   493           #'window:' 
   448            #(#WindowSpec
   494            #(#WindowSpec
   449               #'name:' 'Tree-View'
   495               #'name:' 'Tree-View'
   450               #'layout:' #(#LayoutFrame 199 0 167 0 759 0 616 0)
   496               #'layout:' #(#LayoutFrame 135 0 129 0 648 0 589 0)
   451               #'label:' 'Tree-View'
   497               #'label:' 'Tree-View'
   452               #'min:' #(#Point 10 10)
   498               #'min:' #(#Point 10 10)
   453               #'max:' #(#Point 1160 870)
   499               #'max:' #(#Point 1160 870)
   454               #'bounds:' #(#Rectangle 199 167 760 617)
   500               #'bounds:' #(#Rectangle 135 129 649 590)
   455           )
   501           )
   456           #'component:' 
   502           #'component:' 
   457            #(#SpecCollection
   503            #(#SpecCollection
   458               #'collection:' 
   504               #'collection:' 
   459                #(
   505                #(
   460                  #(#MenuPanelSpec
   506                  #(#MenuPanelSpec
   461                     #'name:' 'menuPullDown'
   507                     #'name:' 'menuPullDown'
   462                     #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 25 0)
   508                     #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 25 0)
   463                     #'tabable:' true
   509                     #'tabable:' true
   464                     #'menu:' #menuPullDown
   510                     #'menu:' #menuPullDown
   465                 )
       
   466                  #(#NoteBookViewSpec
       
   467                     #'name:' 'noteBook'
       
   468                     #'layout:' #(#LayoutFrame 0 0.4 59 0.0 0 1.0 -55 1.0)
       
   469                     #'enableChannel:' #enableChannel
       
   470                     #'tabable:' true
       
   471                     #'menu:' #tabList
       
   472                     #'model:' #tabModel
       
   473                     #'tabWidget:' #Window
       
   474                     #'canvas:' #noteBookView
       
   475                 )
       
   476                  #(#HorizontalPanelViewSpec
       
   477                     #'name:' 'modifyPanel'
       
   478                     #'layout:' #(#LayoutFrame 0 0.4 -55 1.0 0 1.0 -25 1.0)
       
   479                     #'component:' 
       
   480                      #(#SpecCollection
       
   481                         #'collection:' 
       
   482                          #(
       
   483                            #(#ActionButtonSpec
       
   484                               #'name:' 'cancelButton'
       
   485                               #'activeHelpKey:' #cancel
       
   486                               #'label:' 'cancel'
       
   487                               #'tabable:' true
       
   488                               #'model:' #cancel
       
   489                               #'enableChannel:' #modifiedChannel
       
   490                               #'extent:' #(#Point 164 24)
       
   491                           )
       
   492                            #(#ActionButtonSpec
       
   493                               #'name:' 'acceptButton'
       
   494                               #'activeHelpKey:' #accept
       
   495                               #'label:' 'ok'
       
   496                               #'tabable:' true
       
   497                               #'model:' #accept
       
   498                               #'enableChannel:' #modifiedChannel
       
   499                               #'extent:' #(#Point 164 24)
       
   500                           )
       
   501                         )
       
   502                     )
       
   503                     #'level:' 0
       
   504                     #'horizontalLayout:' #fitSpace
       
   505                     #'verticalLayout:' #fitSpace
       
   506                     #'horizontalSpace:' 3
       
   507                     #'verticalSpace:' 3
       
   508                 )
       
   509                  #(#LabelSpec
       
   510                     #'name:' 'helpInfo'
       
   511                     #'layout:' #(#LayoutFrame 2 0.0 -25 1.0 -2 1.0 -2 1.0)
       
   512                     #'level:' -1
       
   513                     #'adjust:' #left
       
   514                 )
   511                 )
   515                  #(#ToggleSpec
   512                  #(#ToggleSpec
   516                     #'name:' 'galleryLabel'
   513                     #'name:' 'galleryLabel'
   517                     #'layout:' #(#LayoutFrame -162 1.0 1 0 -82 1.0 23 0)
   514                     #'layout:' #(#LayoutFrame -162 1.0 1 0 -82 1.0 23 0)
   518                     #'activeHelpKey:' #galleryShown
   515                     #'activeHelpKey:' #galleryShown
   529                     #'label:' 'Painter'
   526                     #'label:' 'Painter'
   530                     #'model:' #painterShown
   527                     #'model:' #painterShown
   531                     #'isTriggerOnDown:' true
   528                     #'isTriggerOnDown:' true
   532                     #'showLamp:' true
   529                     #'showLamp:' true
   533                     #'lampColor:' #(#Color 100.0 100.0 0.0)
   530                     #'lampColor:' #(#Color 100.0 100.0 0.0)
   534                 )
       
   535                  #(#ArbitraryComponentSpec
       
   536                     #'name:' 'treeView'
       
   537                     #'layout:' #(#LayoutFrame 0 0.0 59 0 0 0.4 -25 1.0)
       
   538                     #'menu:' #menuCanvas
       
   539                     #'hasHorizontalScrollBar:' true
       
   540                     #'hasVerticalScrollBar:' true
       
   541                     #'miniScrollerHorizontal:' true
       
   542                     #'miniScrollerVertical:' true
       
   543                     #'component:' #treeView
       
   544                     #'hasBorder:' false
       
   545                 )
   531                 )
   546                  #(#HorizontalPanelViewSpec
   532                  #(#HorizontalPanelViewSpec
   547                     #'name:' 'menuContainer'
   533                     #'name:' 'menuContainer'
   548                     #'layout:' #(#LayoutFrame 0 0.0 26 0 0 1.0 58 0)
   534                     #'layout:' #(#LayoutFrame 0 0.0 26 0 0 1.0 58 0)
   549                     #'component:' 
   535                     #'component:' 
   624                     #'horizontalLayout:' #spread
   610                     #'horizontalLayout:' #spread
   625                     #'verticalLayout:' #fit
   611                     #'verticalLayout:' #fit
   626                     #'horizontalSpace:' 3
   612                     #'horizontalSpace:' 3
   627                     #'verticalSpace:' 3
   613                     #'verticalSpace:' 3
   628                 )
   614                 )
       
   615                  #(#VariableVerticalPanelSpec
       
   616                     #'name:' 'vpanel'
       
   617                     #'layout:' #(#LayoutFrame 0 0.0 59 0.0 0 1.0 0 1.0)
       
   618                     #'component:' 
       
   619                      #(#SpecCollection
       
   620                         #'collection:' 
       
   621                          #(
       
   622                            #(#VariableHorizontalPanelSpec
       
   623                               #'name:' 'hpanel'
       
   624                               #'component:' 
       
   625                                #(#SpecCollection
       
   626                                   #'collection:' 
       
   627                                    #(
       
   628                                      #(#ArbitraryComponentSpec
       
   629                                         #'name:' 'treeView'
       
   630                                         #'menu:' #menuCanvas
       
   631                                         #'hasHorizontalScrollBar:' true
       
   632                                         #'hasVerticalScrollBar:' true
       
   633                                         #'miniScrollerHorizontal:' true
       
   634                                         #'miniScrollerVertical:' true
       
   635                                         #'component:' #treeView
       
   636                                         #'hasBorder:' false
       
   637                                     )
       
   638                                      #(#ViewSpec
       
   639                                         #'name:' 'specHolderView'
       
   640                                         #'component:' 
       
   641                                          #(#SpecCollection
       
   642                                             #'collection:' 
       
   643                                              #(
       
   644                                                #(#NoteBookViewSpec
       
   645                                                   #'name:' 'noteBook'
       
   646                                                   #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 -30 1.0)
       
   647                                                   #'enableChannel:' #enableChannel
       
   648                                                   #'tabable:' true
       
   649                                                   #'menu:' #tabList
       
   650                                                   #'model:' #tabModel
       
   651                                                   #'tabWidget:' #Window
       
   652                                                   #'canvas:' #noteBookView
       
   653                                               )
       
   654                                                #(#HorizontalPanelViewSpec
       
   655                                                   #'name:' 'modifyPanel'
       
   656                                                   #'layout:' #(#LayoutFrame 0 0.0 -30 1.0 0 1.0 0 1.0)
       
   657                                                   #'component:' 
       
   658                                                    #(#SpecCollection
       
   659                                                       #'collection:' 
       
   660                                                        #(
       
   661                                                          #(#ActionButtonSpec
       
   662                                                             #'name:' 'cancelButton'
       
   663                                                             #'activeHelpKey:' #cancel
       
   664                                                             #'label:' 'cancel'
       
   665                                                             #'tabable:' true
       
   666                                                             #'model:' #cancel
       
   667                                                             #'enableChannel:' #modifiedChannel
       
   668                                                             #'extent:' #(#Point 165 24)
       
   669                                                         )
       
   670                                                          #(#ActionButtonSpec
       
   671                                                             #'name:' 'acceptButton'
       
   672                                                             #'activeHelpKey:' #accept
       
   673                                                             #'label:' 'ok'
       
   674                                                             #'tabable:' true
       
   675                                                             #'model:' #accept
       
   676                                                             #'enableChannel:' #modifiedChannel
       
   677                                                             #'extent:' #(#Point 165 24)
       
   678                                                         )
       
   679                                                       )
       
   680                                                   )
       
   681                                                   #'horizontalLayout:' #fitSpace
       
   682                                                   #'verticalLayout:' #fitSpace
       
   683                                                   #'horizontalSpace:' 3
       
   684                                                   #'verticalSpace:' 3
       
   685                                               )
       
   686                                             )
       
   687                                         )
       
   688                                         #'borderWidth:' 1
       
   689                                     )
       
   690                                   )
       
   691                               )
       
   692                               #'level:' 1
       
   693                               #'handles:' #(#Any 0.329435 1.0)
       
   694                           )
       
   695                            #(#TextEditorSpec
       
   696                               #'name:' 'Transcript'
       
   697                               #'hasHorizontalScrollBar:' true
       
   698                               #'hasVerticalScrollBar:' true
       
   699                               #'miniScrollerHorizontal:' true
       
   700                               #'miniScrollerVertical:' true
       
   701                           )
       
   702                         )
       
   703                     )
       
   704                     #'handles:' #(#Any 0.880597 1.0)
       
   705                 )
   629               )
   706               )
   630           )
   707           )
   631       )
   708       )
   632 ! !
   709 ! !
   633 
   710 
  1359     ]
  1436     ]
  1360 
  1437 
  1361     "Modified: 31.7.1997 / 14:26:13 / cg"
  1438     "Modified: 31.7.1997 / 14:26:13 / cg"
  1362 ! !
  1439 ! !
  1363 
  1440 
  1364 !UIPainter methodsFor:'active help'!
       
  1365 
       
  1366 showHelp:aHelpText for:view
       
  1367     "hook to allow an application to display active help
       
  1368      texts in its own info area.
       
  1369      This method may be redefined in a concrete application.
       
  1370      If it returns false, the ActiveHelp manager will popup a
       
  1371      bubble with the help text."
       
  1372 
       
  1373     |l|
       
  1374 
       
  1375     (l := self builder componentAt:#helpInfo) notNil ifTrue:[
       
  1376         aHelpText replaceAll:(Character cr) by:(Character space).
       
  1377         l label:aHelpText.
       
  1378       ^ true.
       
  1379     ].
       
  1380     ^ false
       
  1381 
       
  1382 
       
  1383 ! !
       
  1384 
       
  1385 !UIPainter methodsFor:'aspects'!
  1441 !UIPainter methodsFor:'aspects'!
  1386 
  1442 
  1387 canMoveOrAlignSelection
  1443 canMoveOrAlignSelection
  1388     "returns a boolean value holder which is true in case that any selection exists
  1444     "returns a boolean value holder which is true in case that any selection exists
  1389      and all widgets in the selection can change its layout through to a move or
  1445      and all widgets in the selection can change its layout through to a move or
  1631     ^ self class menuPullDown
  1687     ^ self class menuPullDown
  1632 
  1688 
  1633 
  1689 
  1634 ! !
  1690 ! !
  1635 
  1691 
       
  1692 !UIPainter methodsFor:'printing'!
       
  1693 
       
  1694 show:aText
       
  1695     transcript hideCursor.
       
  1696     transcript contents:aText.
       
  1697         
       
  1698 !
       
  1699 
       
  1700 showHelp:aHelpText for:view
       
  1701     "hook to allow an application to display active help
       
  1702      texts in its own info area.
       
  1703      This method may be redefined in a concrete application.
       
  1704      If it returns false, the ActiveHelp manager will popup a
       
  1705      bubble with the help text."
       
  1706 
       
  1707     |txt|
       
  1708 
       
  1709     txt := self class convertString:(aHelpText asString)
       
  1710                         maxLineSize:(transcript width // transcript font width).
       
  1711 
       
  1712     transcript hideCursor.
       
  1713     transcript contents:txt.
       
  1714   ^ true
       
  1715 ! !
       
  1716 
  1636 !UIPainter methodsFor:'private'!
  1717 !UIPainter methodsFor:'private'!
  1637 
  1718 
  1638 hideUIView:aView
  1719 hideUIView:aView
  1639     "hide the view which is an application or top view
  1720     "hide the view which is an application or top view
  1640     "
  1721     "
  1850         list   := Array new:(size + 2).
  1931         list   := Array new:(size + 2).
  1851         1 to:size do:[:i| list at:i put:((slices at:i) first asString)].
  1932         1 to:size do:[:i| list at:i put:((slices at:i) first asString)].
  1852         list at:(size + 1) put:(UIHelpTool   label).
  1933         list at:(size + 1) put:(UIHelpTool   label).
  1853         list at:(size + 2) put:(UILayoutTool label).
  1934         list at:(size + 2) put:(UILayoutTool label).
  1854         self tabList value:list.
  1935         self tabList value:list.
  1855         self showHelp:(spec class name) for:nil.
  1936         self show:(spec class name).
  1856         tabComponent enabled:true.
  1937         tabComponent enabled:true.
  1857 
  1938 
  1858         (tabSelection := tabComponent selection) isNil ifTrue:[
  1939         (tabSelection := tabComponent selection) isNil ifTrue:[
  1859             tabComponent setSelection:(tabSelection := list first)
  1940             tabComponent setSelection:(tabSelection := list first)
  1860         ].
  1941         ].
  1861         self raiseTabView
  1942         self raiseTabView
  1862     ] ifFalse:[
  1943     ] ifFalse:[
  1863         self helpTool helpKey:nil.
  1944         self helpTool helpKey:nil.
  1864         tabComponent enabled:false.
  1945         tabComponent enabled:false.
  1865         self showHelp:'' for:nil.
  1946         self show:nil.
  1866     ].
  1947     ].
  1867     self modifiedChannel value:false.
  1948     self modifiedChannel value:false.
  1868 ! !
  1949 ! !
  1869 
  1950 
  1870 !UIPainter methodsFor:'startup / release'!
  1951 !UIPainter methodsFor:'startup / release'!
  1951     treeView := treeView canvas:painter.
  2032     treeView := treeView canvas:painter.
  1952     painter treeView:treeView.
  2033     painter treeView:treeView.
  1953     treeView model addDependent:self.
  2034     treeView model addDependent:self.
  1954 
  2035 
  1955     super openInterface.
  2036     super openInterface.
  1956 
  2037     transcript := (self builder componentAt:#Transcript) scrolledView.
  1957     topView := self window.
  2038     topView := self window.
  1958     topView bePartner.
  2039     topView bePartner.
  1959     topView label:'GUI Builder'.
  2040     topView label:'GUI Builder'.
  1960 
  2041 
  1961     painterView openInGroup:(topView windowGroup).
  2042     painterView openInGroup:(topView windowGroup).