UIPainter.st
changeset 282 bb88d92ae887
parent 281 aabb4037f6a3
child 287 1ecabfd468dc
equal deleted inserted replaced
281:aabb4037f6a3 282:bb88d92ae887
    19 	category:'Interface-UIPainter'
    19 	category:'Interface-UIPainter'
    20 !
    20 !
    21 
    21 
    22 SelectionInTreeView subclass:#TreeView
    22 SelectionInTreeView subclass:#TreeView
    23 	instanceVariableNames:'lastDrawnMaster cvsEventsDisabled imageMasterParent
    23 	instanceVariableNames:'lastDrawnMaster cvsEventsDisabled imageMasterParent
    24 		imageMasterChild'
    24 		imageEmptyParent imageMasterChild'
    25 	classVariableNames:'ImageMasterParent ImageMasterChild'
    25 	classVariableNames:'ImageMasterParent ImageMasterChild ImageEmptyParent'
    26 	poolDictionaries:''
    26 	poolDictionaries:''
    27 	privateIn:UIPainter
    27 	privateIn:UIPainter
    28 !
    28 !
    29 
    29 
    30 !UIPainter class methodsFor:'documentation'!
    30 !UIPainter class methodsFor:'documentation'!
    69 
    69 
    70 ! !
    70 ! !
    71 
    71 
    72 !UIPainter class methodsFor:'instance creation'!
    72 !UIPainter class methodsFor:'instance creation'!
    73 
    73 
    74 listHolder:aListHolder
       
    75     |application|
       
    76 
       
    77     application := self new.
       
    78     application objectList:aListHolder.
       
    79   ^ application open
       
    80 !
       
    81 
       
    82 openOnClass:aClass andSelector:aSelector
    74 openOnClass:aClass andSelector:aSelector
       
    75     "open up an interface builder, fetching a spec from aClass
       
    76      via some selector
       
    77     "
    83     ^ self new openOnClass:aClass andSelector:aSelector
    78     ^ self new openOnClass:aClass andSelector:aSelector
    84 
       
    85     "Created: 1.7.1997 / 19:16:59 / cg"
       
    86 !
    79 !
    87 
    80 
    88 painter:aBuilderView
    81 painter:aBuilderView
       
    82     "set the painter
       
    83     "
    89     |application|
    84     |application|
    90 
    85 
    91     application := self new.
    86     application := self new.
    92     application painter:aBuilderView.
    87     application painter:aBuilderView.
    93   ^ application open
    88   ^ application open
    94 ! !
    89 ! !
    95 
    90 
    96 !UIPainter class methodsFor:'ST-80 queries'!
    91 !UIPainter class methodsFor:'ST-80 queries'!
    97 
    92 
    98 preferenceFor:aSymbol
    93 preferenceFor:aSymbol
       
    94     "ST-80 compatible; always returns false
       
    95     "
    99     ^ false
    96     ^ false
   100 
    97 
   101 
    98 
   102 ! !
    99 ! !
   103 
   100 
   108      These are used by the activeHelp tool.
   105      These are used by the activeHelp tool.
   109     "
   106     "
   110   ^ super helpSpec addPairsFrom:#(
   107   ^ super helpSpec addPairsFrom:#(
   111 
   108 
   112 #alignSelectionCenterVer
   109 #alignSelectionCenterVer
   113 'align selection vertical'
   110 'align selected widgets vertical'
   114 
   111 
   115 #alignSelectionLeft
   112 #alignSelectionLeft
   116 'align selected components to the left edge of the
   113 'align selected widgets to the left edge of the dominant widget ( underlined )'
   117 dominant component ( underlined )'
       
   118 
   114 
   119 #alignSelectionRight
   115 #alignSelectionRight
   120 'align selected components to the right edge of the
   116 'align selected widgets to the right edge of the dominant widget ( underlined )'
   121 dominant component ( underlined )'
       
   122 
   117 
   123 #alignSelectionLeftAndRight
   118 #alignSelectionLeftAndRight
   124 'align selected components to the right and left edge
   119 'align selected widgets to the right and left edge of the dominant widget ( underlined )'
   125 of the dominant component ( underlined )'
       
   126 
   120 
   127 #alignSelectionTop
   121 #alignSelectionTop
   128 'align selected components to the top edge of the
   122 'align selected widgets to the top edge of the dominant widget ( underlined )'
   129 dominant component ( underlined )'
       
   130 
   123 
   131 #alignSelectionBottom
   124 #alignSelectionBottom
   132 'align selected components to the bottom edge of the
   125 'align selected widgets to the bottom edge of the dominant widget ( underlined )'
   133 dominant component ( underlined )'
       
   134 
   126 
   135 #alignSelectionTopAndBottom
   127 #alignSelectionTopAndBottom
   136 'align selected components to the top and bottom edge
   128 'align selected widgets to the top and bottom edge of the dominant widget ( underlined )'
   137 of the dominant component ( underlined )'
       
   138 
   129 
   139 #alignSelectionCenterVer
   130 #alignSelectionCenterVer
   140 'align selected components horizontal to the center of
   131 'align selected widgets horizontal to the center of the dominant widget ( underlined )'
   141 the dominant component ( underlined )'
       
   142 
   132 
   143 #alignSelectionCenterHor
   133 #alignSelectionCenterHor
   144 'align selected components vertical to the center of
   134 'align selected widgets vertical to the center of the dominant widget ( underlined )'
   145 the dominant component ( underlined )'
       
   146 
   135 
   147 #spreadSelectionVer
   136 #spreadSelectionVer
   148 'vertical spacing between selected components is made the same'
   137 'vertical spacing between selected widgets is made the same'
   149 
   138 
   150 #spreadSelectionHor
   139 #spreadSelectionHor
   151 'horizontal spacing between selected components is made the same'
   140 'horizontal spacing between selected widgets is made the same'
   152 
   141 
   153 #centerSelectionHor
   142 #centerSelectionHor
   154 'center components horizontal in contained view'
   143 'center widgets horizontal to their top widget'
   155 
   144 
   156 #centerSelectionVer
   145 #centerSelectionVer
   157 'center vertical horizontal in contained view'
   146 'center vertical horizontal in contained view'
   158 
   147 
   159 #setToDefaultExtent
   148 #setToDefaultExtent
   160 'set selected components to their default extent'
   149 'set selected widgets to their default extent'
   161 
   150 
   162 #setToDefaultWidth
   151 #setToDefaultWidth
   163 'set selected components to their default width'
   152 'set selected widgets to their default width'
   164 
   153 
   165 #setToDefaultHeight
   154 #setToDefaultHeight
   166 'set selected components to their default height'
   155 'set selected widgets to their default height'
   167 
   156 
   168 #copyExtent
   157 #copyExtent
   169 'copy extent of the selected component'
   158 'copy extent of the selected widget'
   170 
   159 
   171 #pasteExtent
   160 #pasteExtent
   172 'change extent of all selected components to the
   161 'change extent of all selected widgets to the last copied extent'
   173 last copied extent'
       
   174 
   162 
   175 #pasteWidth
   163 #pasteWidth
   176 'change width of all selected components to the
   164 'change width of all selected widgets to the last copied extent width'
   177 last copied extent width'
       
   178 
   165 
   179 #pasteHeight
   166 #pasteHeight
   180 'change height of all selected components to the
   167 'change height of all selected widgets to the last copied extent height'
   181 last copied extent height'
       
   182 
   168 
   183 #copyLayout
   169 #copyLayout
   184 'copy layout of the selected component'
   170 'copy layout of the selected widget'
   185 
   171 
   186 #pasteLayout
   172 #pasteLayout
   187 'change layout of all selected components to the
   173 'change layout of all selected widgets to the last copied layout'
   188 last copied layout'
       
   189 
   174 
   190 #pasteBuffer
   175 #pasteBuffer
   191 'paste components at current mouse position'
   176 'paste widgets at current mouse position'
   192 
   177 
   193 #pasteWithLayout
   178 #pasteWithLayout
   194 'paste components without changing their layouts'
   179 'paste widgets without changing their layouts'
       
   180 
       
   181 #accept
       
   182 'write back changes'
       
   183 
       
   184 #cancel
       
   185 'reread specification and layout'
       
   186 
       
   187 #galleryShown
       
   188 'show or hide gallery view'
       
   189 
       
   190 #painterShown
       
   191 'show or hide painter view'
       
   192 
       
   193 #moveSelectionLeft
       
   194 'move selected widgets left while pressing the button'
       
   195 
       
   196 #moveSelectionRight
       
   197 'move selected widgets right while pressing the button'
       
   198 
       
   199 #moveSelectionDown
       
   200 'move selected widgets down while pressing the button'
       
   201 
       
   202 #moveSelectionUp
       
   203 'move selected widgets up while pressing the button'
       
   204 
       
   205 #menuChangeHierarchy
       
   206 'change hierarchy of the selected widget'
       
   207 
       
   208 #menuAlignment
       
   209 'provides a set of alignment operation on the current selected widgets'
       
   210 
       
   211 
   195 
   212 
   196 )
   213 )
   197 
   214 
   198 
   215 
   199 
   216 
   201 ! !
   218 ! !
   202 
   219 
   203 !UIPainter class methodsFor:'icons'!
   220 !UIPainter class methodsFor:'icons'!
   204 
   221 
   205 iconAlignB
   222 iconAlignB
       
   223     "returns image assigned to align bottom
       
   224     "
   206     ^ Image fromFile:'b_alignB.xbm'
   225     ^ Image fromFile:'b_alignB.xbm'
   207 
   226 
   208 !
   227 !
   209 
   228 
   210 iconAlignCenterH
   229 iconAlignCenterH
       
   230     "returns image assigned to center horizontal
       
   231     "
   211     ^ Image fromFile:'b_alignCH.xbm'
   232     ^ Image fromFile:'b_alignCH.xbm'
   212 
   233 
   213 !
   234 !
   214 
   235 
   215 iconAlignCenterV
   236 iconAlignCenterV
       
   237     "returns image assigned to center vertical
       
   238     "
   216     ^ Image fromFile:'b_alignCV.xbm'
   239     ^ Image fromFile:'b_alignCV.xbm'
   217 
   240 
   218 !
   241 !
   219 
   242 
   220 iconAlignL
   243 iconAlignL
       
   244     "returns image assigned to align left
       
   245     "
   221     ^ Image fromFile:'b_alignL.xbm'
   246     ^ Image fromFile:'b_alignL.xbm'
   222 !
   247 !
   223 
   248 
   224 iconAlignLR
   249 iconAlignLR
       
   250     "returns image assigned to align left and right
       
   251     "
   225     ^ Image fromFile:'b_alignLR.xbm'
   252     ^ Image fromFile:'b_alignLR.xbm'
   226 
   253 
   227 !
   254 !
   228 
   255 
   229 iconAlignR
   256 iconAlignR
       
   257     "returns image assigned to align right
       
   258     "
   230     ^ Image fromFile:'b_alignR.xbm'
   259     ^ Image fromFile:'b_alignR.xbm'
   231 
   260 
   232 !
   261 !
   233 
   262 
   234 iconAlignT
   263 iconAlignT
       
   264     "returns image assigned to align top
       
   265     "
   235     ^ Image fromFile:'b_alignT.xbm'
   266     ^ Image fromFile:'b_alignT.xbm'
   236 
   267 
   237 !
   268 !
   238 
   269 
   239 iconAlignTB
   270 iconAlignTB
       
   271     "returns image assigned to align top and bottom
       
   272     "
   240     ^ Image fromFile:'b_alignTB.xbm'
   273     ^ Image fromFile:'b_alignTB.xbm'
   241 
   274 
   242 !
   275 !
   243 
   276 
   244 iconStepDown
   277 iconStepDown
       
   278     "returns image assigned to step down (change hierarchy).
       
   279     "
   245     IconStepDown isNil ifTrue:[
   280     IconStepDown isNil ifTrue:[
   246         IconStepDown := ((Image fromFile:'stepOver.xpm') rotated:90) flipHorizontal
   281         IconStepDown := ((Image fromFile:'stepOver.xpm') rotated:90) flipHorizontal
   247     ].
   282     ].
   248   ^ IconStepDown
   283   ^ IconStepDown
   249 
   284 
   252 "
   287 "
   253 
   288 
   254 !
   289 !
   255 
   290 
   256 iconStepIn
   291 iconStepIn
       
   292     "returns image assigned to step in (change hierarchy).
       
   293     "
   257     IconStepIn isNil ifTrue:[
   294     IconStepIn isNil ifTrue:[
   258         IconStepIn := ((Image fromFile:'stepIn.xpm') rotated:90) flipHorizontal
   295         IconStepIn := ((Image fromFile:'stepIn.xpm') rotated:90) flipHorizontal
   259     ].
   296     ].
   260   ^ IconStepIn
   297   ^ IconStepIn
   261 
   298 
   262 !
   299 !
   263 
   300 
   264 iconStepOut
   301 iconStepOut
       
   302     "returns image assigned to step out (change hierarchy).
       
   303     "
   265     IconStepOut isNil ifTrue:[
   304     IconStepOut isNil ifTrue:[
   266         IconStepOut := ((Image fromFile:'stepOut.xpm') rotated:90) flipHorizontal
   305         IconStepOut := ((Image fromFile:'stepOut.xpm') rotated:90) flipHorizontal
   267     ].
   306     ].
   268   ^ IconStepOut
   307   ^ IconStepOut
   269 !
   308 !
   270 
   309 
   271 iconStepUp
   310 iconStepUp
       
   311     "returns image assigned to step up (change hierarchy).
       
   312     "
   272     IconStepUp isNil ifTrue:[
   313     IconStepUp isNil ifTrue:[
   273         IconStepUp := ((Image fromFile:'stepOver.xpm') rotated:90) flipHorizontal flipVertical
   314         IconStepUp := ((Image fromFile:'stepOver.xpm') rotated:90) flipHorizontal flipVertical
   274     ].
   315     ].
   275   ^ IconStepUp
   316   ^ IconStepUp
   276 
   317 
   408     ^
   449     ^
   409      
   450      
   410        #(#FullSpec
   451        #(#FullSpec
   411           #'window:' 
   452           #'window:' 
   412            #(#WindowSpec
   453            #(#WindowSpec
   413               #'name:' 'uIPainterView'
   454               #'name:' 'Tree-View'
   414               #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
   455               #'layout:' #(#LayoutFrame 199 0 167 0 759 0 616 0)
   415               #'label:' 'Tree-View'
   456               #'label:' 'Tree-View'
   416               #'bounds:' #(#Rectangle 0 0 561 450)
   457               #'min:' #(#Point 10 10)
       
   458               #'max:' #(#Point 1160 870)
       
   459               #'bounds:' #(#Rectangle 199 167 760 617)
   417           )
   460           )
   418           #'component:' 
   461           #'component:' 
   419            #(#SpecCollection
   462            #(#SpecCollection
   420               #'collection:' 
   463               #'collection:' 
   421                #(
   464                #(
   447                      #(#SpecCollection
   490                      #(#SpecCollection
   448                         #'collection:' 
   491                         #'collection:' 
   449                          #(
   492                          #(
   450                            #(#ActionButtonSpec
   493                            #(#ActionButtonSpec
   451                               #'name:' 'cancelButton'
   494                               #'name:' 'cancelButton'
       
   495                               #'activeHelpKey:' #cancel
   452                               #'label:' 'cancel'
   496                               #'label:' 'cancel'
   453                               #'tabable:' true
   497                               #'tabable:' true
   454                               #'model:' #cancel
   498                               #'model:' #cancel
   455                               #'enableChannel:' #modifiedChannel
   499                               #'enableChannel:' #modifiedChannel
   456                               #'extent:' #(#Point 164 24)
   500                               #'extent:' #(#Point 164 24)
   457                           )
   501                           )
   458                            #(#ActionButtonSpec
   502                            #(#ActionButtonSpec
   459                               #'name:' 'acceptButton'
   503                               #'name:' 'acceptButton'
       
   504                               #'activeHelpKey:' #accept
   460                               #'label:' 'ok'
   505                               #'label:' 'ok'
   461                               #'tabable:' true
   506                               #'tabable:' true
   462                               #'model:' #accept
   507                               #'model:' #accept
   463                               #'enableChannel:' #modifiedChannel
   508                               #'enableChannel:' #modifiedChannel
   464                               #'extent:' #(#Point 164 24)
   509                               #'extent:' #(#Point 164 24)
   478                     #'adjust:' #left
   523                     #'adjust:' #left
   479                 )
   524                 )
   480                  #(#ToggleSpec
   525                  #(#ToggleSpec
   481                     #'name:' 'galleryLabel'
   526                     #'name:' 'galleryLabel'
   482                     #'layout:' #(#LayoutFrame -162 1.0 1 0 -82 1.0 23 0)
   527                     #'layout:' #(#LayoutFrame -162 1.0 1 0 -82 1.0 23 0)
       
   528                     #'activeHelpKey:' #galleryShown
   483                     #'label:' 'Gallery'
   529                     #'label:' 'Gallery'
   484                     #'model:' #galleryShown
   530                     #'model:' #galleryShown
   485                     #'isTriggerOnDown:' true
   531                     #'isTriggerOnDown:' true
   486                     #'showLamp:' true
   532                     #'showLamp:' true
   487                     #'lampColor:' #(#Color 100.0 100.0 0.0)
   533                     #'lampColor:' #(#Color 100.0 100.0 0.0)
   488                 )
   534                 )
   489                  #(#ToggleSpec
   535                  #(#ToggleSpec
   490                     #'name:' 'painterLabel'
   536                     #'name:' 'painterLabel'
   491                     #'layout:' #(#LayoutFrame -81 1.0 1 0 -1 1.0 23 0)
   537                     #'layout:' #(#LayoutFrame -81 1.0 1 0 -1 1.0 23 0)
       
   538                     #'activeHelpKey:' #painterShown
   492                     #'label:' 'Painter'
   539                     #'label:' 'Painter'
   493                     #'model:' #painterShown
   540                     #'model:' #painterShown
   494                     #'isTriggerOnDown:' true
   541                     #'isTriggerOnDown:' true
   495                     #'showLamp:' true
   542                     #'showLamp:' true
   496                     #'lampColor:' #(#Color 100.0 100.0 0.0)
   543                     #'lampColor:' #(#Color 100.0 100.0 0.0)
   512                     #'component:' 
   559                     #'component:' 
   513                      #(#SpecCollection
   560                      #(#SpecCollection
   514                         #'collection:' 
   561                         #'collection:' 
   515                          #(
   562                          #(
   516                            #(#MenuPanelSpec
   563                            #(#MenuPanelSpec
   517                               #'name:' 'menuMove'
   564                               #'name:' 'menuChangeHierarchy'
   518                               #'menu:' #menuMove
   565                               #'activeHelpKey:' #menuChangeHierarchy
       
   566                               #'enableChannel:' #hasOneSelectionOtherThanCanvas
       
   567                               #'menu:' #menuChangeHierarchy
   519                               #'showSeparatingLines:' true
   568                               #'showSeparatingLines:' true
   520                               #'extent:' #(#Point 123 32)
   569                               #'extent:' #(#Point 123 32)
   521                           )
   570                           )
   522                            #(#MenuPanelSpec
   571                            #(#MenuPanelSpec
   523                               #'name:' 'menuAlignment'
   572                               #'name:' 'menuAlignment'
       
   573                               #'activeHelpKey:' #menuAlignment
       
   574                               #'enableChannel:' #canMoveOrAlignSelection
   524                               #'tabable:' true
   575                               #'tabable:' true
   525                               #'menu:' #menuAlignment
   576                               #'menu:' #menuAlignment
   526                               #'showSeparatingLines:' true
   577                               #'showSeparatingLines:' true
   527                               #'extent:' #(#Point 233 32)
   578                               #'extent:' #(#Point 233 32)
   528                           )
   579                           )
   532                                #(#SpecCollection
   583                                #(#SpecCollection
   533                                   #'collection:' 
   584                                   #'collection:' 
   534                                    #(
   585                                    #(
   535                                      #(#ArrowButtonSpec
   586                                      #(#ArrowButtonSpec
   536                                         #'name:' 'moveLeft'
   587                                         #'name:' 'moveLeft'
       
   588                                         #'activeHelpKey:' #moveSelectionLeft
   537                                         #'tabable:' true
   589                                         #'tabable:' true
   538                                         #'model:' #moveSelectionLeft
   590                                         #'model:' #moveSelectionLeft
   539                                         #'isTriggerOnDown:' true
   591                                         #'isTriggerOnDown:' true
   540                                         #'enableChannel:' #hasValidSelection
   592                                         #'enableChannel:' #canMoveOrAlignSelection
   541                                         #'direction:' #left
   593                                         #'direction:' #left
   542                                         #'extent:' #(#Point 25 24)
   594                                         #'extent:' #(#Point 22 24)
   543                                     )
   595                                     )
   544                                      #(#ArrowButtonSpec
   596                                      #(#ArrowButtonSpec
   545                                         #'name:' 'moveRight'
   597                                         #'name:' 'moveRight'
       
   598                                         #'activeHelpKey:' #moveSelectionRight
   546                                         #'model:' #moveSelectionRight
   599                                         #'model:' #moveSelectionRight
   547                                         #'isTriggerOnDown:' true
   600                                         #'isTriggerOnDown:' true
   548                                         #'enableChannel:' #hasValidSelection
   601                                         #'enableChannel:' #canMoveOrAlignSelection
   549                                         #'direction:' #right
   602                                         #'direction:' #right
   550                                         #'extent:' #(#Point 26 24)
   603                                         #'extent:' #(#Point 22 24)
   551                                     )
   604                                     )
   552                                      #(#ArrowButtonSpec
   605                                      #(#ArrowButtonSpec
   553                                         #'name:' 'moveDown'
   606                                         #'name:' 'moveDown'
       
   607                                         #'activeHelpKey:' #moveSelectionDown
   554                                         #'model:' #moveSelectionDown
   608                                         #'model:' #moveSelectionDown
   555                                         #'isTriggerOnDown:' true
   609                                         #'isTriggerOnDown:' true
   556                                         #'enableChannel:' #hasValidSelection
   610                                         #'enableChannel:' #canMoveOrAlignSelection
   557                                         #'direction:' #down
   611                                         #'direction:' #down
   558                                         #'extent:' #(#Point 26 24)
   612                                         #'extent:' #(#Point 22 24)
   559                                     )
   613                                     )
   560                                      #(#ArrowButtonSpec
   614                                      #(#ArrowButtonSpec
   561                                         #'name:' 'moveUp'
   615                                         #'name:' 'moveUp'
       
   616                                         #'activeHelpKey:' #moveSelectionUp
   562                                         #'model:' #moveSelectionUp
   617                                         #'model:' #moveSelectionUp
   563                                         #'isTriggerOnDown:' true
   618                                         #'isTriggerOnDown:' true
   564                                         #'enableChannel:' #hasValidSelection
   619                                         #'enableChannel:' #canMoveOrAlignSelection
   565                                         #'direction:' #up
   620                                         #'direction:' #up
   566                                         #'extent:' #(#Point 22 24)
   621                                         #'extent:' #(#Point 22 24)
   567                                     )
   622                                     )
   568                                   )
   623                                   )
   569                               )
   624                               )
   607           
   662           
   608            #(
   663            #(
   609              #(#MenuItem
   664              #(#MenuItem
   610                 #'label:' 'align left'
   665                 #'label:' 'align left'
   611                 #'value:' #alignSelectionLeft
   666                 #'value:' #alignSelectionLeft
   612                 #'enabled:' #hasValidSelection
       
   613                 #'activeHelpKey:' #alignSelectionLeft
       
   614                 #'labelImage:' 
   667                 #'labelImage:' 
   615                  #(#ResourceRetriever
   668                  #(#ResourceRetriever
   616                     nil #iconAlignL
   669                     nil #iconAlignL
   617                 )
   670                 )
   618             )
   671             )
   619              #(#MenuItem
   672              #(#MenuItem
   620                 #'label:' 'align right'
   673                 #'label:' 'align right'
   621                 #'value:' #alignSelectionRight
   674                 #'value:' #alignSelectionRight
   622                 #'enabled:' #hasValidSelection
       
   623                 #'activeHelpKey:' #alignSelectionRight
   675                 #'activeHelpKey:' #alignSelectionRight
   624                 #'labelImage:' 
   676                 #'labelImage:' 
   625                  #(#ResourceRetriever
   677                  #(#ResourceRetriever
   626                     nil #iconAlignR
   678                     nil #iconAlignR
   627                 )
   679                 )
   628             )
   680             )
   629              #(#MenuItem
   681              #(#MenuItem
   630                 #'label:' 'align left & right'
   682                 #'label:' 'align left & right'
   631                 #'value:' #alignSelectionLeftAndRight
   683                 #'value:' #alignSelectionLeftAndRight
   632                 #'enabled:' #hasValidSelection
       
   633                 #'activeHelpKey:' #alignSelectionLeftAndRight
   684                 #'activeHelpKey:' #alignSelectionLeftAndRight
   634                 #'labelImage:' 
   685                 #'labelImage:' 
   635                  #(#ResourceRetriever
   686                  #(#ResourceRetriever
   636                     nil #iconAlignLR
   687                     nil #iconAlignLR
   637                 )
   688                 )
   638             )
   689             )
   639              #(#MenuItem
   690              #(#MenuItem
   640                 #'label:' 'align top'
   691                 #'label:' 'align top'
   641                 #'value:' #alignSelectionTop
   692                 #'value:' #alignSelectionTop
   642                 #'enabled:' #hasValidSelection
       
   643                 #'activeHelpKey:' #alignSelectionTop
   693                 #'activeHelpKey:' #alignSelectionTop
   644                 #'labelImage:' 
   694                 #'labelImage:' 
   645                  #(#ResourceRetriever
   695                  #(#ResourceRetriever
   646                     nil #iconAlignT
   696                     nil #iconAlignT
   647                 )
   697                 )
   648             )
   698             )
   649              #(#MenuItem
   699              #(#MenuItem
   650                 #'label:' 'align bottom'
   700                 #'label:' 'align bottom'
   651                 #'value:' #alignSelectionBottom
   701                 #'value:' #alignSelectionBottom
   652                 #'enabled:' #hasValidSelection
       
   653                 #'activeHelpKey:' #alignSelectionBottom
   702                 #'activeHelpKey:' #alignSelectionBottom
   654                 #'labelImage:' 
   703                 #'labelImage:' 
   655                  #(#ResourceRetriever
   704                  #(#ResourceRetriever
   656                     nil #iconAlignB
   705                     nil #iconAlignB
   657                 )
   706                 )
   658             )
   707             )
   659              #(#MenuItem
   708              #(#MenuItem
   660                 #'label:' 'align top & bottom'
   709                 #'label:' 'align top & bottom'
   661                 #'value:' #alignSelectionTopAndBottom
   710                 #'value:' #alignSelectionTopAndBottom
   662                 #'enabled:' #hasValidSelection
       
   663                 #'activeHelpKey:' #alignSelectionTopAndBottom
   711                 #'activeHelpKey:' #alignSelectionTopAndBottom
   664                 #'labelImage:' 
   712                 #'labelImage:' 
   665                  #(#ResourceRetriever
   713                  #(#ResourceRetriever
   666                     nil #iconAlignTB
   714                     nil #iconAlignTB
   667                 )
   715                 )
   668             )
   716             )
   669              #(#MenuItem
   717              #(#MenuItem
   670                 #'label:' 'align centered horizontal'
   718                 #'label:' 'align centered horizontal'
   671                 #'value:' #alignSelectionCenterHor
   719                 #'value:' #alignSelectionCenterHor
   672                 #'enabled:' #hasValidSelection
       
   673                 #'activeHelpKey:' #alignSelectionCenterHor
   720                 #'activeHelpKey:' #alignSelectionCenterHor
   674                 #'labelImage:' 
   721                 #'labelImage:' 
   675                  #(#ResourceRetriever
   722                  #(#ResourceRetriever
   676                     nil #iconAlignCenterH
   723                     nil #iconAlignCenterH
   677                 )
   724                 )
   678             )
   725             )
   679              #(#MenuItem
   726              #(#MenuItem
   680                 #'label:' 'align centered vertical'
   727                 #'label:' 'align centered vertical'
   681                 #'value:' #alignSelectionCenterVer
   728                 #'value:' #alignSelectionCenterVer
   682                 #'enabled:' #hasValidSelection
       
   683                 #'activeHelpKey:' #alignSelectionCenterVer
   729                 #'activeHelpKey:' #alignSelectionCenterVer
   684                 #'labelImage:' 
   730                 #'labelImage:' 
   685                  #(#ResourceRetriever
   731                  #(#ResourceRetriever
   686                     nil #iconAlignCenterV
   732                     nil #iconAlignCenterV
   687                 )
   733                 )
   706     <resource: #menu>
   752     <resource: #menu>
   707 
   753 
   708     ^
   754     ^
   709 
   755 
   710        #(#Menu
   756        #(#Menu
   711 
       
   712            #(
   757            #(
   713              #(#MenuItem
   758              #(#MenuItem
   714                 #'label:' 'copy'
   759                 #'label:' 'copy'
   715                 #'value:' #copySelection
   760                 #'value:' #copySelection
       
   761                 #'enabled:' #hasSelection
   716                 #'shortcutKeyCharacter:' #Copy
   762                 #'shortcutKeyCharacter:' #Copy
   717             )
   763             )
   718              #(#MenuItem
   764              #(#MenuItem
   719                 #'label:' 'cut'
   765                 #'label:' 'cut'
   720                 #'value:' #deleteSelection
   766                 #'value:' #deleteSelection
       
   767                 #'enabled:' #hasSelection
   721                 #'shortcutKeyCharacter:' #Cut
   768                 #'shortcutKeyCharacter:' #Cut
   722             )
   769             )
   723              #(#MenuItem
   770              #(#MenuItem
   724                 #'label:' 'paste'
   771                 #'label:' 'paste'
   725                 #'nameKey:' #paste
   772                 #'nameKey:' #paste
       
   773                 #'enabled:' #canPaste
   726                 #'value:' #paste
   774                 #'value:' #paste
   727                 #'submenu:' 
   775                 #'submenu:' 
   728                  #(#Menu
   776                  #(#Menu
   729 
   777 
   730                      #(
   778                      #(
   735                           #'shortcutKeyCharacter:' #Paste
   783                           #'shortcutKeyCharacter:' #Paste
   736                       )
   784                       )
   737                        #(#MenuItem
   785                        #(#MenuItem
   738                           #'label:' 'keep layout'
   786                           #'label:' 'keep layout'
   739                           #'value:' #pasteWithLayout
   787                           #'value:' #pasteWithLayout
       
   788                           #'enabled:' #canKeepLayoutInSelection
   740                           #'activeHelpKey:' #pasteWithLayout
   789                           #'activeHelpKey:' #pasteWithLayout
   741                       )
   790                       )
   742                     ) nil
   791                     ) nil
   743                     nil
   792                     nil
   744                 )
   793                 )
   747                 #'label:' '-'
   796                 #'label:' '-'
   748             )
   797             )
   749              #(#MenuItem
   798              #(#MenuItem
   750                 #'label:' 'undo'
   799                 #'label:' 'undo'
   751                 #'nameKey:' #undo
   800                 #'nameKey:' #undo
       
   801                 #'enabled:' #hasUndoHistory
   752                 #'value:' #undoLast
   802                 #'value:' #undoLast
   753             )
   803             )
   754              #(#MenuItem
   804              #(#MenuItem
   755                 #'label:' '-'
   805                 #'label:' '-'
   756             )
   806             )
   757              #(#MenuItem
   807              #(#MenuItem
   758                 #'label:' 'dimension'
   808                 #'label:' 'dimension'
   759                 #'value:' #dimension
   809                 #'value:' #dimension
       
   810                 #'enabled:' #hasSelection
   760                 #'submenu:' 
   811                 #'submenu:' 
   761                  #(#Menu
   812                  #(#Menu
   762 
   813 
   763                      #(
   814                      #(
   764                        #(#MenuItem
   815                        #(#MenuItem
   765                           #'label:' 'default extent'
   816                           #'label:' 'default extent'
   766                           #'value:' #setToDefaultExtent
   817                           #'value:' #setToDefaultExtent
       
   818                           #'enabled:' #canMoveOrAlignSelection
   767                           #'activeHelpKey:' #setToDefaultExtent
   819                           #'activeHelpKey:' #setToDefaultExtent
   768                       )
   820                       )
   769                        #(#MenuItem
   821                        #(#MenuItem
   770                           #'label:' 'default width'
   822                           #'label:' 'default width'
   771                           #'value:' #setToDefaultWidth
   823                           #'value:' #setToDefaultWidth
       
   824                           #'enabled:' #canMoveOrAlignSelection
   772                           #'activeHelpKey:' #setToDefaultWidth
   825                           #'activeHelpKey:' #setToDefaultWidth
   773                       )
   826                       )
   774                        #(#MenuItem
   827                        #(#MenuItem
   775                           #'label:' 'default height'
   828                           #'label:' 'default height'
   776                           #'value:' #setToDefaultHeight
   829                           #'value:' #setToDefaultHeight
       
   830                           #'enabled:' #canMoveOrAlignSelection
   777                           #'activeHelpKey:' #setToDefaultHeight
   831                           #'activeHelpKey:' #setToDefaultHeight
   778                       )
   832                       )
   779                        #(#MenuItem
   833                        #(#MenuItem
   780                           #'label:' 'copy extent'
   834                           #'label:' 'copy extent'
   781                           #'value:' #copyExtent
   835                           #'value:' #copyExtent
       
   836                           #'enabled:' #hasSingleSelection
   782                           #'activeHelpKey:' #copyExtent
   837                           #'activeHelpKey:' #copyExtent
   783                       )
   838                       )
   784                        #(#MenuItem
   839                        #(#MenuItem
   785                           #'label:' 'paste extent'
   840                           #'label:' 'paste extent'
   786                           #'value:' #pasteExtent
   841                           #'value:' #pasteExtent
       
   842                           #'enabled:' #canMoveOrAlignSelection
   787                           #'activeHelpKey:' #pasteExtent
   843                           #'activeHelpKey:' #pasteExtent
   788                       )
   844                       )
   789                        #(#MenuItem
   845                        #(#MenuItem
   790                           #'label:' 'paste width'
   846                           #'label:' 'paste width'
   791                           #'value:' #pasteWidth
   847                           #'value:' #pasteWidth
       
   848                           #'enabled:' #canMoveOrAlignSelection
   792                           #'activeHelpKey:' #pasteWidth
   849                           #'activeHelpKey:' #pasteWidth
   793                       )
   850                       )
   794                        #(#MenuItem
   851                        #(#MenuItem
   795                           #'label:' 'paste height'
   852                           #'label:' 'paste height'
   796                           #'value:' #pasteHeight
   853                           #'value:' #pasteHeight
       
   854                           #'enabled:' #canMoveOrAlignSelection
   797                           #'activeHelpKey:' #pasteHeight
   855                           #'activeHelpKey:' #pasteHeight
   798                       )
   856                       )
   799                        #(#MenuItem
   857                        #(#MenuItem
   800                           #'label:' 'copy  layout'
   858                           #'label:' 'copy  layout'
   801                           #'value:' #copyLayout
   859                           #'value:' #copyLayout
       
   860                           #'enabled:' #hasSingleSelection
   802                           #'activeHelpKey:' #copyLayout
   861                           #'activeHelpKey:' #copyLayout
   803                       )
   862                       )
   804                        #(#MenuItem
   863                        #(#MenuItem
   805                           #'label:' 'paste layout'
   864                           #'label:' 'paste layout'
   806                           #'value:' #pasteLayout
   865                           #'value:' #pasteLayout
       
   866                           #'enabled:' #canMoveOrAlignSelection
   807                           #'activeHelpKey:' #pasteLayout
   867                           #'activeHelpKey:' #pasteLayout
   808                       )
   868                       )
   809                     )
   869                     )
   810                     #(3 1 3)
   870                     #(3 1 3)
   811                     nil
   871                     nil
   812                 )
   872                 )
   813             )
   873             )
   814              #(#MenuItem
   874              #(#MenuItem
   815                 #'label:' 'align'
   875                 #'label:' 'align'
   816                 #'value:' #align
   876                 #'value:' #align
       
   877                 #'enabled:' #canMoveOrAlignSelection
   817                 #'submenu:' 
   878                 #'submenu:' 
   818                  #(#Menu
   879                  #(#Menu
   819 
   880 
   820                      #(
   881                      #(
   821                        #(#MenuItem
   882                        #(#MenuItem
   928       )
   989       )
   929 
   990 
   930 
   991 
   931 !
   992 !
   932 
   993 
   933 menuMove
   994 menuChangeHierarchy
   934     "this window spec was automatically generated by the ST/X MenuEditor"
   995     "this window spec was automatically generated by the ST/X MenuEditor"
   935 
   996 
   936     "do not manually edit this - the builder may not be able to
   997     "do not manually edit this - the builder may not be able to
   937      handle the specification if its corrupted."
   998      handle the specification if its corrupted."
   938 
   999 
   939     "
  1000     "
   940      MenuEditor new openOnClass:UIPainter andSelector:#menuMove
  1001      MenuEditor new openOnClass:UIPainter andSelector:#menuChangeHierarchy
   941      (Menu new fromLiteralArrayEncoding:(UIPainter menuMove)) startUp
  1002      (Menu new fromLiteralArrayEncoding:(UIPainter menuChangeHierarchy)) startUp
   942     "
  1003     "
   943 
  1004 
   944     <resource: #menu>
  1005     <resource: #menu>
   945 
  1006 
   946     ^
  1007     ^
   949           
  1010           
   950            #(
  1011            #(
   951              #(#MenuItem
  1012              #(#MenuItem
   952                 #'label:' 'stepUp'
  1013                 #'label:' 'stepUp'
   953                 #'value:' #doStepUp
  1014                 #'value:' #doStepUp
   954                 #'enabled:' #hasSingleSelection
       
   955                 #'labelImage:' 
  1015                 #'labelImage:' 
   956                  #(#ResourceRetriever
  1016                  #(#ResourceRetriever
   957                     #UIPainter #iconStepUp
  1017                     #UIPainter #iconStepUp
   958                 )
  1018                 )
   959             )
  1019             )
   960              #(#MenuItem
  1020              #(#MenuItem
   961                 #'label:' 'stepDown'
  1021                 #'label:' 'stepDown'
   962                 #'value:' #doStepDown
  1022                 #'value:' #doStepDown
   963                 #'enabled:' #hasSingleSelection
       
   964                 #'labelImage:' 
  1023                 #'labelImage:' 
   965                  #(#ResourceRetriever
  1024                  #(#ResourceRetriever
   966                     #UIPainter #iconStepDown
  1025                     #UIPainter #iconStepDown
   967                 )
  1026                 )
       
  1027             )
       
  1028              #(#MenuItem
       
  1029                 #'label:' '-'
   968             )
  1030             )
   969              #(#MenuItem
  1031              #(#MenuItem
   970                 #'label:' 'stepIn'
  1032                 #'label:' 'stepIn'
   971                 #'value:' #doStepIn
  1033                 #'value:' #doStepIn
   972                 #'enabled:' #canStepIn
  1034                 #'enabled:' #canMoveSelectionIntoContainer
   973                 #'labelImage:' 
  1035                 #'labelImage:' 
   974                  #(#ResourceRetriever
  1036                  #(#ResourceRetriever
   975                     #UIPainter #iconStepIn
  1037                     #UIPainter #iconStepIn
   976                 )
  1038                 )
   977             )
  1039             )
   978              #(#MenuItem
  1040              #(#MenuItem
   979                 #'label:' 'stepOut'
  1041                 #'label:' 'stepOut'
   980                 #'value:' #doStepOut
  1042                 #'value:' #doStepOut
   981                 #'enabled:' #canStepOut
  1043                 #'enabled:' #canMoveSelectionOutOfContainer
   982                 #'labelImage:' 
  1044                 #'labelImage:' 
   983                  #(#ResourceRetriever
  1045                  #(#ResourceRetriever
   984                     #UIPainter #iconStepOut
  1046                     #UIPainter #iconStepOut
   985                 )
  1047                 )
   986             )
  1048             )
   987           )
  1049           ) nil
   988           #( 2 )
       
   989           nil
  1050           nil
   990       )
  1051       )
   991 !
  1052 !
   992 
  1053 
   993 menuPullDown
  1054 menuPullDown
  1172           ) nil
  1233           ) nil
  1173           nil
  1234           nil
  1174       )
  1235       )
  1175 ! !
  1236 ! !
  1176 
  1237 
  1177 !UIPainter methodsFor:'accessing menu'!
       
  1178 
       
  1179 menuCanvas
       
  1180     ^ [ treeView canvas showMiddleButtonMenu ]
       
  1181 !
       
  1182 
       
  1183 menuMove
       
  1184     "this window spec was automatically generated by the ST/X MenuEditor"
       
  1185 
       
  1186     ^ self class menuMove
       
  1187 
       
  1188 
       
  1189 !
       
  1190 
       
  1191 menuPullDown
       
  1192     "this window spec was automatically generated by the ST/X MenuEditor"
       
  1193 
       
  1194     ^ self class menuPullDown
       
  1195 
       
  1196 
       
  1197 ! !
       
  1198 
       
  1199 !UIPainter methodsFor:'actions'!
  1238 !UIPainter methodsFor:'actions'!
  1200 
  1239 
  1201 accept
  1240 accept
       
  1241     "accept changes done to the specification. The component assigned to the
       
  1242      specification will change immediately dependant on the attributes derived
       
  1243      from the specification.
       
  1244     "
  1202     |layout|
  1245     |layout|
  1203 
  1246 
  1204     self isLayoutToolSelected ifTrue:[
  1247     self isLayoutToolSelected ifTrue:[
  1205         (layout := layoutTool layout) notNil ifTrue:[
  1248         (layout := layoutTool layout) notNil ifTrue:[
  1206             layoutTool layoutType == #Extent ifTrue:[
  1249             layoutTool layoutType == #Extent ifTrue:[
  1207                 self painter setExtent:layout
  1250                 layoutTool layoutView == self painter topView ifTrue:[
       
  1251                     layoutTool layoutView extent:layout
       
  1252                 ] ifFalse:[
       
  1253                     self painter setExtent:layout
       
  1254                 ]
  1208             ] ifFalse:[
  1255             ] ifFalse:[
  1209                 self painter setLayout:layout
  1256                 self painter setLayout:layout
  1210             ]
  1257             ]
  1211         ]
  1258         ]
  1212     ] ifFalse:[
  1259     ] ifFalse:[
  1218     self modifiedChannel value:false.
  1265     self modifiedChannel value:false.
  1219 
  1266 
  1220 !
  1267 !
  1221 
  1268 
  1222 cancel
  1269 cancel
  1223     "cancel all changes and read back attributes from current view
  1270     "cancel all changes done to the specification; reread attributes from the
       
  1271      assigned component
  1224     "
  1272     "
  1225     self isModified ifTrue:[
  1273     self isModified ifTrue:[
  1226         specTool specification:(self painter specForSelection).
  1274         specTool specification:(self painter specForSelection).
  1227         layoutTool layoutView:(layoutTool layoutView).
  1275         self setViewInLayoutTool:(layoutTool layoutView).
  1228         self modifiedChannel value:false.
  1276         self modifiedChannel value:false.
  1229     ]
  1277     ]
       
  1278 !
       
  1279 
       
  1280 moveSelectionDown
       
  1281     "move selected components down
       
  1282     "
       
  1283     self painter moveSelectionDown
       
  1284 !
       
  1285 
       
  1286 moveSelectionLeft
       
  1287     "move selected components left
       
  1288     "
       
  1289     self painter moveSelectionLeft
       
  1290 
       
  1291 !
       
  1292 
       
  1293 moveSelectionRight
       
  1294     "move selected components right
       
  1295     "
       
  1296     self painter moveSelectionRight
       
  1297 
       
  1298 !
       
  1299 
       
  1300 moveSelectionUp
       
  1301     "move selected components up
       
  1302     "
       
  1303     self painter moveSelectionUp
       
  1304 
  1230 !
  1305 !
  1231 
  1306 
  1232 openEditMenu
  1307 openEditMenu
  1233     |cls aspect editor|
  1308     |cls aspect editor|
  1234 
  1309 
  1312 
  1387 
  1313 ! !
  1388 ! !
  1314 
  1389 
  1315 !UIPainter methodsFor:'aspects'!
  1390 !UIPainter methodsFor:'aspects'!
  1316 
  1391 
  1317 canStepIn
  1392 canMoveOrAlignSelection
  1318     ^ builder booleanValueAspectFor:#canStepIn
  1393     "returns a boolean value holder which is true in case that any selection exists
  1319 
  1394      and all widgets in the selection can change its layout through to a move or
  1320     "Modified: 28.7.1997 / 12:52:16 / cg"
  1395      align operation
  1321 !
  1396     "
  1322 
  1397     ^ builder booleanValueAspectFor:#canMoveOrAlignSelection
  1323 canStepOut
  1398 !
  1324     ^ builder booleanValueAspectFor:#canStepOut
  1399 
  1325 
  1400 canMoveSelectionIntoContainer
  1326     "Modified: 28.7.1997 / 12:52:18 / cg"
  1401     "returns a boolean value holder which is true in case that one component is selected
       
  1402      and can change its container widget to the next element in the list which will have
       
  1403      the same container.
       
  1404     "
       
  1405     ^ builder booleanValueAspectFor:#canMoveSelectionIntoContainer
       
  1406 !
       
  1407 
       
  1408 canMoveSelectionOutOfContainer
       
  1409     "returns a boolean value holder which is true in case that one component is selected
       
  1410      which is contained within another component
       
  1411     "
       
  1412     ^ builder booleanValueAspectFor:#canMoveSelectionOutOfContainer
  1327 !
  1413 !
  1328 
  1414 
  1329 enableChannel
  1415 enableChannel
  1330     "true if modifications are allowed otherwise running test
  1416     "true if modifications are allowed otherwise running test
  1331     "
  1417     "
  1332   ^ self painter enableChannel
  1418   ^ self painter enableChannel
  1333 !
  1419 !
  1334 
  1420 
  1335 galleryShown
  1421 galleryShown
       
  1422     "returns a boolean value holder which is set to true if the gallery is shown
       
  1423     "
  1336     |holder|
  1424     |holder|
  1337 
  1425 
  1338     (holder := builder bindingAt:#galleryShown) isNil ifTrue:[
  1426     (holder := builder bindingAt:#galleryShown) isNil ifTrue:[
  1339         builder aspectAt:#galleryShown put:(holder :=  true asValue).
  1427         builder aspectAt:#galleryShown put:(holder :=  true asValue).
  1340         holder addDependent:self
  1428         holder addDependent:self
  1341     ].
  1429     ].
  1342     ^ holder
  1430     ^ holder
  1343 
  1431 
  1344 !
  1432 !
  1345 
  1433 
  1346 hasSingleSelection
  1434 hasOneSelectionOtherThanCanvas
  1347     ^ builder booleanValueAspectFor:#hasSingleSelection
  1435     "returns a value holder which is true in case that one component is selected
  1348 
  1436      other than the canvas.
  1349     "Modified: 28.7.1997 / 12:52:20 / cg"
  1437     "
  1350 !
  1438     ^ builder booleanValueAspectFor:#hasOneSelectionOtherThanCanvas
  1351 
       
  1352 hasValidSelection
       
  1353     ^ builder booleanValueAspectFor:#hasValidSelection
       
  1354 
       
  1355     "Modified: 28.7.1997 / 12:52:22 / cg"
       
  1356 !
  1439 !
  1357 
  1440 
  1358 modifiedChannel
  1441 modifiedChannel
       
  1442     "returns a boolean value holder which is set to true if something is modified
       
  1443      and not accepted
       
  1444     "
  1359     ^ builder booleanValueAspectFor:#modifiedChannel
  1445     ^ builder booleanValueAspectFor:#modifiedChannel
  1360 
       
  1361     "Modified: 28.7.1997 / 12:52:24 / cg"
       
  1362 !
  1446 !
  1363 
  1447 
  1364 noteBookView
  1448 noteBookView
  1365     "automatically generated by UIPainter ..."
  1449     "returns the notebook view; initialize components within the notebook
  1366 
  1450     "
  1367     |noteBook channel n1 n2|
  1451     |noteBook channel n1 n2|
  1368 
  1452 
  1369     (noteBook := builder bindingAt:#noteBookView) isNil ifTrue:[
  1453     (noteBook := builder bindingAt:#noteBookView) isNil ifTrue:[
  1370         noteBook   := View new.
  1454         noteBook   := View new.
  1371         layoutTool := UILayoutTool new.
  1455         layoutTool := UILayoutTool new.
  1388         builder aspectAt:#noteBookView put:noteBook.
  1472         builder aspectAt:#noteBookView put:noteBook.
  1389     ].
  1473     ].
  1390     ^ noteBook
  1474     ^ noteBook
  1391 !
  1475 !
  1392 
  1476 
  1393 objectList
       
  1394     ^ nil
       
  1395 "
       
  1396     |holder|
       
  1397 
       
  1398     (holder := builder bindingAt:#objectList) isNil ifTrue:[
       
  1399         builder aspectAt:#objectList put:(holder := SelectionInList).
       
  1400     ].
       
  1401     ^ holder
       
  1402 
       
  1403 "
       
  1404 !
       
  1405 
       
  1406 objectListMenu
       
  1407     "returns a block which returns the menu
       
  1408      !!hack!!
       
  1409     "
       
  1410     ^ [ self painter showMiddleButtonMenu ].
       
  1411 
       
  1412 
       
  1413 
       
  1414 !
       
  1415 
       
  1416 painterShown
  1477 painterShown
       
  1478     "returns a boolean value holder which is set to true if the painter is shown
       
  1479     "
  1417     |holder|
  1480     |holder|
  1418 
  1481 
  1419     (holder := builder bindingAt:#painterShown) isNil ifTrue:[
  1482     (holder := builder bindingAt:#painterShown) isNil ifTrue:[
  1420         builder aspectAt:#painterShown put:(holder :=  true asValue).
  1483         builder aspectAt:#painterShown put:(holder :=  true asValue).
  1421         holder addDependent:self
  1484         holder addDependent:self
  1423     ^ holder
  1486     ^ holder
  1424 
  1487 
  1425 !
  1488 !
  1426 
  1489 
  1427 tabList
  1490 tabList
  1428     "automatically generated by UIPainter ..."
  1491     "returns a value holder which keeps a list of labels assigned to the tabs
  1429 
  1492     "
  1430     |holder|
  1493     |holder|
  1431 
  1494 
  1432     (holder := builder bindingAt:#tabList) isNil ifTrue:[
  1495     (holder := builder bindingAt:#tabList) isNil ifTrue:[
  1433         builder aspectAt:#tabList put:(holder :=  ValueHolder new).
  1496         builder aspectAt:#tabList put:(holder :=  ValueHolder new).
  1434         holder value:#( 'Properties' ).
  1497         holder value:#( 'Properties' ).
  1435     ].
  1498     ].
  1436     ^ holder
  1499     ^ holder
  1437 !
  1500 !
  1438 
  1501 
  1439 tabModel
  1502 tabModel
  1440     "automatically generated by UIPainter ..."
  1503     "returns a value holder which keeps the current name of the tab selected
  1441 
  1504     "
  1442     |holder|
  1505     |holder|
  1443 
  1506 
  1444     (holder := builder bindingAt:#tabModel) isNil ifTrue:[
  1507     (holder := builder bindingAt:#tabModel) isNil ifTrue:[
  1445         holder := AspectAdaptor new subject:self; forAspect:#tabSelection.
  1508         holder := AspectAdaptor new subject:self; forAspect:#tabSelection.
  1446         builder aspectAt:#tabModel put:holder.
  1509         builder aspectAt:#tabModel put:holder.
  1447     ].
  1510     ].
  1448     ^ holder
  1511     ^ holder
  1449 !
  1512 !
  1450 
  1513 
  1451 treeView
  1514 treeView
       
  1515     "returns the selection tree view which holds all widget identifiers
       
  1516     "
  1452     ^ treeView
  1517     ^ treeView
  1453 ! !
  1518 ! !
  1454 
  1519 
  1455 !UIPainter methodsFor:'binding access'!
  1520 !UIPainter methodsFor:'binding access'!
  1456 
  1521 
  1461 ! !
  1526 ! !
  1462 
  1527 
  1463 !UIPainter methodsFor:'change & update'!
  1528 !UIPainter methodsFor:'change & update'!
  1464 
  1529 
  1465 layoutChanged
  1530 layoutChanged
       
  1531     "called by the painter/canvas whenever the layout of the current selected
       
  1532      widget changed
       
  1533     "
  1466     self isModified ifFalse:[
  1534     self isModified ifFalse:[
  1467         layoutTool update.
  1535         layoutTool update.
  1468         self modifiedChannel value:false
  1536         self modifiedChannel value:false
  1469     ]
  1537     ]
  1470 !
  1538 !
  1471 
  1539 
  1472 propertyChanged
  1540 propertyChanged
  1473     "property changed
  1541     "called by the painter/canvas whenever the property of the current selected
       
  1542      widget changed
  1474     "
  1543     "
  1475     |p|
  1544     |p|
  1476 
  1545 
  1477     (p := treeView propertySelected) notNil ifTrue:[
  1546     (p := treeView propertySelected) notNil ifTrue:[
  1478         specTool specification:(p spec copy).
  1547         specTool specification:(p spec copy).
  1479         layoutTool  layoutView:(p view).
  1548         self setViewInLayoutTool:(p view).
  1480         self modifiedChannel value:false
  1549         self modifiedChannel value:false
  1481     ] ifFalse:[
  1550     ] ifFalse:[
  1482         layoutTool layoutView notNil ifTrue:[
  1551         layoutTool layoutView notNil ifTrue:[
  1483             self modifiedChannel value:false.
  1552             self modifiedChannel value:false.
  1484             self treeSelection
  1553             self treeSelection
  1485         ]
  1554         ]
  1486     ]
  1555     ]
  1487 !
  1556 !
  1488 
  1557 
  1489 update:something with:aParameter from:someObject
  1558 update:something with:aParameter from:someObject
  1490 
  1559     "catch change notifications
       
  1560     "
  1491     someObject == treeView model ifTrue:[
  1561     someObject == treeView model ifTrue:[
  1492         something == #selection ifTrue:[self treeSelection].
  1562         something == #selection ifTrue:[self treeSelection].
  1493       ^ self
  1563       ^ self
  1494     ].
  1564     ].
  1495 
  1565 
  1514 ! !
  1584 ! !
  1515 
  1585 
  1516 !UIPainter methodsFor:'event handling'!
  1586 !UIPainter methodsFor:'event handling'!
  1517 
  1587 
  1518 doesNotUnderstand:aMessage
  1588 doesNotUnderstand:aMessage
  1519    |painter|
  1589 
  1520 
  1590     |painter|
  1521    painter := self painter.
  1591 
  1522 
  1592     painter := self painter.
  1523    (painter respondsTo:(aMessage selector)) ifTrue:[
  1593 
       
  1594     (painter respondsTo:(aMessage selector)) ifTrue:[
  1524         ^ aMessage sendTo:painter
  1595         ^ aMessage sendTo:painter
  1525    ].
  1596     ].
  1526    super doesNotUnderstand:aMessage
  1597     super doesNotUnderstand:aMessage
       
  1598 
       
  1599 ! !
       
  1600 
       
  1601 !UIPainter methodsFor:'menu accessing'!
       
  1602 
       
  1603 menuAlignment
       
  1604     "returns the pull down menu which keeps the alignment operations
       
  1605     "
       
  1606     ^ self class menuAlignment
       
  1607 
       
  1608 !
       
  1609 
       
  1610 menuCanvas
       
  1611     "returns the middle button menu used by the painter and the tree view
       
  1612     "
       
  1613     ^ [ treeView canvas showMiddleButtonMenu ]
       
  1614 !
       
  1615 
       
  1616 menuChangeHierarchy
       
  1617     "returns the hierarchy pull down menu
       
  1618     "
       
  1619     ^ self class menuChangeHierarchy
       
  1620 
       
  1621 
       
  1622 !
       
  1623 
       
  1624 menuPullDown
       
  1625     "returns the main pull down menu
       
  1626     "
       
  1627     ^ self class menuPullDown
       
  1628 
  1527 
  1629 
  1528 ! !
  1630 ! !
  1529 
  1631 
  1530 !UIPainter methodsFor:'private'!
  1632 !UIPainter methodsFor:'private'!
  1531 
  1633 
  1532 hideUIView:aView
  1634 hideUIView:aView
       
  1635     "hide the view which is an application or top view
       
  1636     "
  1533     aView beIndependent.
  1637     aView beIndependent.
  1534     aView unmap.
  1638     aView unmap.
  1535 !
  1639 !
  1536 
  1640 
  1537 painter
  1641 painter
       
  1642     "returns the painter/canvas view
       
  1643     "
  1538     ^ treeView canvas
  1644     ^ treeView canvas
  1539 !
  1645 !
  1540 
  1646 
  1541 raiseUIView:aView
  1647 raiseUIView:aView
       
  1648     "raise the view which is an application or top view
       
  1649     "
  1542     aView map.
  1650     aView map.
  1543     aView bePartner.
  1651     aView bePartner.
  1544 !
  1652 !
  1545 
  1653 
  1546 setClass:cls selector:selector
  1654 setClass:cls selector:selector
       
  1655     "set the application class and the selector under which the
       
  1656      window specification should be stored
       
  1657     "
  1547     |clsName superClassName|
  1658     |clsName superClassName|
  1548 
  1659 
  1549     clsName := cls name.
  1660     clsName := cls name.
  1550     superClassName := cls superclass name.
  1661     superClassName := cls superclass name.
  1551 
  1662 
  1561     specClass := clsName.
  1672     specClass := clsName.
  1562     specSelector := (selector ? '').
  1673     specSelector := (selector ? '').
  1563     specSuperclass := superClassName.
  1674     specSuperclass := superClassName.
  1564 
  1675 
  1565     "Modified: 24.6.1997 / 19:07:01 / cg"
  1676     "Modified: 24.6.1997 / 19:07:01 / cg"
       
  1677 !
       
  1678 
       
  1679 setViewInLayoutTool:aView
       
  1680     "set view for layout tool
       
  1681     "
       
  1682     self painter topView ~~ aView ifTrue:[
       
  1683         layoutTool layoutView:aView type:nil
       
  1684     ] ifFalse:[
       
  1685         layoutTool layoutView:aView type:#Extent
       
  1686     ].
       
  1687 
       
  1688 
  1566 ! !
  1689 ! !
  1567 
  1690 
  1568 !UIPainter methodsFor:'queries'!
  1691 !UIPainter methodsFor:'queries'!
  1569 
  1692 
  1570 hasSpecClass
  1693 hasSpecClass
  1571 
  1694     "checks whether an application class is defined
       
  1695     "
  1572     specClass notNil ifTrue:[
  1696     specClass notNil ifTrue:[
  1573         ^ (specClass isBehavior or:[(Smalltalk at:specClass asSymbol) notNil])
  1697         ^ (specClass isBehavior or:[(Smalltalk at:specClass asSymbol) notNil])
  1574     ].
  1698     ].
  1575   ^ false
  1699   ^ false
  1576 !
  1700 !
  1577 
  1701 
  1578 hasSpecClassAndSelector
  1702 hasSpecClassAndSelector
  1579 
  1703     "checks whether an application class and a selector under which
       
  1704      the window specification is stored is defined.
       
  1705     "
  1580     specSelector size > 1 ifTrue:[
  1706     specSelector size > 1 ifTrue:[
  1581         ^ self hasSpecClass
  1707         ^ self hasSpecClass
  1582     ].
  1708     ].
  1583   ^ false
  1709   ^ false
  1584 !
  1710 !
  1585 
  1711 
  1586 isHelpToolSelected
  1712 isHelpToolSelected
       
  1713     "returns true if current selected tab in the noteBook is assigned
       
  1714      to the 'Help' tool
       
  1715     "
  1587     ^ tabSelection = 'Help'
  1716     ^ tabSelection = 'Help'
  1588 !
  1717 !
  1589 
  1718 
  1590 isLayoutToolSelected
  1719 isLayoutToolSelected
       
  1720     "returns true if current selected tab in the noteBook is assigned
       
  1721      to the 'Layout' tool
       
  1722     "
  1591     ^ tabSelection = layoutTool class label
  1723     ^ tabSelection = layoutTool class label
  1592 !
  1724 !
  1593 
  1725 
  1594 isModified
  1726 isModified
  1595     "returns true if current spec. is modified
  1727     "returns true if current specification or layout is modified
  1596     "
  1728     "
  1597     ^ self modifiedChannel value
  1729     ^ self modifiedChannel value
  1598 !
  1730 !
  1599 
  1731 
  1600 isPainterEnabled
  1732 isPainterEnabled
       
  1733     "returns true if not running in test mode
       
  1734     "
  1601     ^ self painter enabled
  1735     ^ self painter enabled
  1602 ! !
  1736 ! !
  1603 
  1737 
  1604 !UIPainter methodsFor:'selection'!
  1738 !UIPainter methodsFor:'selection'!
  1605 
  1739 
  1606 canvasSelected
       
  1607     |spec|
       
  1608 
       
  1609     self hasValidSelection value:false.
       
  1610     self canStepIn value:false.
       
  1611     self canStepOut value:false.
       
  1612     self hasSingleSelection value:false.
       
  1613 
       
  1614     spec := treeView canvasSpec.
       
  1615     (builder componentAt:#noteBook) setSelection:nil.
       
  1616     self setupSlicesFrom:spec hasLayout:false.
       
  1617     tabSelection := nil.
       
  1618 
       
  1619     layoutTool layoutView:nil.
       
  1620     specTool specification:spec.
       
  1621     self modifiedChannel value:false.
       
  1622     self tabSelection:(self tabList value first).
       
  1623     specTool selection:tabSelection.
       
  1624     (self noteBookView subViews at:2) raise.
       
  1625     (builder componentAt:#noteBook) setSelection:1.
       
  1626     self modifiedChannel value:false.
       
  1627 
       
  1628 !
       
  1629 
       
  1630 setupSlicesFrom:aSpec hasLayout:hasLayout
       
  1631 
       
  1632     |slices list|
       
  1633 
       
  1634     slices := aSpec class slices.
       
  1635     list   := slices collect:[:aSlice| aSlice first asString].
       
  1636 
       
  1637     hasLayout ifTrue:[
       
  1638         list add:(layoutTool class label)
       
  1639     ].
       
  1640     self tabList value:list.
       
  1641 !
       
  1642 
       
  1643 tabSelection
  1740 tabSelection
  1644     "returns current name of section
  1741     "returns name of current selected tab in the notebook.
  1645     "
  1742     "
  1646     ^ tabSelection
  1743     ^ tabSelection
  1647 !
  1744 !
  1648 
  1745 
  1649 tabSelection:something
  1746 tabSelection:something
  1650     "section changed
  1747     "the tab selection of the notebook changed
  1651     "
  1748     "
  1652     |raiseViewIdx|
  1749     |raiseViewIdx|
  1653 
  1750 
  1654     (something isNil or:[tabSelection = something]) ifTrue:[
  1751     (something isNil or:[tabSelection = something]) ifTrue:[
  1655         ^ self
  1752         ^ self
  1672     (self noteBookView subViews at:raiseViewIdx) raise.
  1769     (self noteBookView subViews at:raiseViewIdx) raise.
  1673     self cancel.
  1770     self cancel.
  1674 !
  1771 !
  1675 
  1772 
  1676 treeSelection
  1773 treeSelection
  1677     "called whenever tree-selection changed
  1774     "called whenever the selection of the treeview changed
  1678     "
  1775     "
  1679     |oldSelection view slices list spec props size nameOfSpec|
  1776     |view list spec property tabComponent|
  1680 
  1777 
  1681     self isModified ifTrue:[
  1778     self isModified ifTrue:[
  1682         (self confirm:'accept change made in ' , tabSelection printString , ' section ?') ifTrue:[
  1779         (self confirm:'accept change made in ' , tabSelection printString , ' section ?') ifTrue:[
  1683             self accept
  1780             self accept
  1684         ]
  1781         ]
  1685     ].
  1782     ].
       
  1783     self canMoveOrAlignSelection        value:(treeView canMoveOrAlignSelection).
       
  1784     self canMoveSelectionIntoContainer  value:(treeView canMoveSelectionIntoContainer).
       
  1785     self canMoveSelectionOutOfContainer value:(treeView canMoveSelectionOutOfContainer).
       
  1786     self hasOneSelectionOtherThanCanvas value:(treeView hasOneSelectionOtherThanCanvas).
       
  1787 
  1686     treeView isCanvasSelected ifTrue:[
  1788     treeView isCanvasSelected ifTrue:[
  1687         ^ self canvasSelected
  1789         spec := treeView canvasSpec.
  1688     ].
  1790         view := self painter topView.
  1689         
  1791     ] ifFalse:[
  1690     props := treeView propertySelected.
  1792         (property := treeView propertySelected) notNil ifTrue:[
  1691     oldSelection := tabSelection.
  1793             view := property view.
  1692     tabSelection := nil.
  1794             spec := property spec copy.
  1693 
  1795         ]
  1694     self hasValidSelection value:(treeView hasValidSelection).
  1796     ].
  1695     self canStepIn value:(treeView canStepIn).
  1797     tabComponent := builder componentAt:#noteBook.
  1696     self canStepOut value:(treeView canStepOut).
  1798     self setViewInLayoutTool:view.
  1697 
  1799     specTool specification:spec.
  1698     props isNil ifFalse:[
  1800 
  1699         self hasSingleSelection value:true.
  1801     spec notNil ifTrue:[
  1700         view := props view.
  1802         list := spec class slices collect:[:aSlice| aSlice first asString].
  1701         spec := props spec copy.
  1803         view notNil ifTrue:[list add:(layoutTool class label)].
  1702 
  1804         self tabList value:list.
  1703         layoutTool layoutView == view ifFalse:[
  1805         self showHelp:(spec class name) for:nil.
  1704             self setupSlicesFrom:spec hasLayout:true.
  1806         tabComponent enabled:true.
       
  1807 
       
  1808         (tabSelection := tabComponent selection) isNil ifTrue:[
       
  1809             tabComponent setSelection:(tabSelection := list first)
  1705         ].
  1810         ].
  1706         list := self tabList value.
       
  1707 
       
  1708         (list findFirst:[:n| n = oldSelection ]) ~~ 0 ifTrue:[
       
  1709             tabSelection := oldSelection
       
  1710         ] ifFalse:[
       
  1711             tabSelection := list first
       
  1712         ].
       
  1713         nameOfSpec := spec class name.
       
  1714     ] ifTrue:[
       
  1715         self hasSingleSelection value:false.
       
  1716         nameOfSpec := ''
       
  1717     ].
       
  1718 
       
  1719     self showHelp:nameOfSpec for:nil.
       
  1720 
       
  1721     layoutTool layoutView:view.
       
  1722     specTool specification:spec.
       
  1723 
       
  1724     tabSelection notNil ifTrue:[
       
  1725         self isLayoutToolSelected ifTrue:[
  1811         self isLayoutToolSelected ifTrue:[
  1726             (self noteBookView subViews at:1) raise
  1812             (self noteBookView subViews at:1) raise
  1727         ] ifFalse:[
  1813         ] ifFalse:[
  1728             specTool selection:tabSelection.
  1814             specTool selection:tabSelection.
  1729             (self noteBookView subViews at:2) raise
  1815             (self noteBookView subViews at:2) raise
  1730         ]
  1816         ]
  1731     ].
  1817     ] ifFalse:[
  1732 
  1818         tabComponent enabled:false.
  1733     (builder componentAt:#noteBook) setSelection:tabSelection.
  1819         self showHelp:'' for:nil.
       
  1820     ].
  1734     self modifiedChannel value:false.
  1821     self modifiedChannel value:false.
  1735 
  1822 
  1736 ! !
  1823 ! !
  1737 
  1824 
  1738 !UIPainter methodsFor:'startup / release'!
  1825 !UIPainter methodsFor:'startup / release'!
  1825     super openInterface.
  1912     super openInterface.
  1826 
  1913 
  1827     topView := self window.
  1914     topView := self window.
  1828     topView bePartner.
  1915     topView bePartner.
  1829     topView label:'GUI Builder'.
  1916     topView label:'GUI Builder'.
  1830     topView icon:(Image fromFile:'bitmaps/UIPainter.xbm' resolution:100).
       
  1831 
  1917 
  1832     painterView openInGroup:(topView windowGroup).
  1918     painterView openInGroup:(topView windowGroup).
  1833     painterView bePartner.
  1919     painterView bePartner.
  1834     painterView application:self.
  1920     painterView application:self.
  1835     painterView open.
  1921     painterView open.
  1839     selectionPanel allButOpenInterface:#windowSpec.
  1925     selectionPanel allButOpenInterface:#windowSpec.
  1840     selectionPanel window openInGroup:(topView windowGroup).
  1926     selectionPanel window openInGroup:(topView windowGroup).
  1841     selectionPanel window bePartner.
  1927     selectionPanel window bePartner.
  1842     selectionPanel openWindow.
  1928     selectionPanel openWindow.
  1843     selectionPanel masterApplication:self.
  1929     selectionPanel masterApplication:self.
       
  1930 
       
  1931     topView iconLabel:'Builder'.
       
  1932     topView icon:(Image fromFile:'bitmaps/UIPainter.xbm' resolution:100).
       
  1933 
       
  1934     painterView iconLabel:'Builder'.
       
  1935     painterView icon:(Image fromFile:'bitmaps/UIPainter.xbm' resolution:100).
       
  1936 
       
  1937     selectionPanel window iconLabel:'Builder'.
       
  1938     selectionPanel window icon:(Image fromFile:'bitmaps/UIPainter.xbm' resolution:100).
  1844 
  1939 
  1845     "Modified: 1.8.1997 / 14:22:10 / cg"
  1940     "Modified: 1.8.1997 / 14:22:10 / cg"
  1846 !
  1941 !
  1847 
  1942 
  1848 openNewWindowCanvas
  1943 openNewWindowCanvas
  2001 ! !
  2096 ! !
  2002 
  2097 
  2003 !UIPainter methodsFor:'user interaction - move'!
  2098 !UIPainter methodsFor:'user interaction - move'!
  2004 
  2099 
  2005 doStepDown
  2100 doStepDown
       
  2101     "move selected component after the next component in the hierarchy of
       
  2102      its container widget
       
  2103     "
  2006     treeView doStepOver:1
  2104     treeView doStepOver:1
  2007 !
  2105 !
  2008 
  2106 
  2009 doStepIn
  2107 doStepIn
       
  2108     "change the container of the selected widget
       
  2109     "
  2010     treeView doStepIn
  2110     treeView doStepIn
  2011 !
  2111 !
  2012 
  2112 
  2013 doStepOut
  2113 doStepOut
       
  2114     "change the container of the selected widget
       
  2115     "
  2014     treeView doStepOut
  2116     treeView doStepOut
  2015 !
  2117 !
  2016 
  2118 
  2017 doStepUp
  2119 doStepUp
       
  2120     "move selected component before the previous component in the hierarchy of
       
  2121      its container widget
       
  2122     "
  2018     treeView doStepOver:-1
  2123     treeView doStepOver:-1
  2019 ! !
  2124 ! !
  2020 
  2125 
  2021 !UIPainter methodsFor:'user interaction - pullDown'!
  2126 !UIPainter methodsFor:'user interaction - pullDown'!
  2022 
  2127 
  2047 
  2152 
  2048     "Modified: 28.7.1997 / 18:30:13 / cg"
  2153     "Modified: 28.7.1997 / 18:30:13 / cg"
  2049 !
  2154 !
  2050 
  2155 
  2051 doFromClass
  2156 doFromClass
       
  2157     "setup new specification from a class and selector accessed through
       
  2158      to a dialog
       
  2159     "
  2052     |className methodName cls sel accepted failed spec s painter|
  2160     |className methodName cls sel accepted failed spec s painter|
  2053 
  2161 
  2054     self painter isModified ifTrue:[
  2162     self painter isModified ifTrue:[
  2055         (self confirm:'edit another interface without saving your modifications ?') ifFalse:[
  2163         (self confirm:'edit another interface without saving your modifications ?') ifFalse:[
  2056             ^ self
  2164             ^ self
  2112 
  2220 
  2113     "Modified: 24.6.1997 / 18:59:29 / cg"
  2221     "Modified: 24.6.1997 / 18:59:29 / cg"
  2114 !
  2222 !
  2115 
  2223 
  2116 doInstallAspects
  2224 doInstallAspects
       
  2225     "install aspects and actions
       
  2226     "
  2117     |code|
  2227     |code|
  2118 
  2228 
  2119     self hasSpecClassAndSelector ifFalse:[
  2229     self hasSpecClassAndSelector ifFalse:[
  2120         self defineClassAndSelector
  2230         self defineClassAndSelector
  2121     ].
  2231     ].
  2142         self information:'no help text defined'
  2252         self information:'no help text defined'
  2143     ]    
  2253     ]    
  2144 !
  2254 !
  2145 
  2255 
  2146 doInstallSpec
  2256 doInstallSpec
       
  2257     "install window specification
       
  2258     "
  2147     |code painter|
  2259     |code painter|
  2148 
  2260 
  2149     self hasSpecClassAndSelector ifFalse:[
  2261     self hasSpecClassAndSelector ifFalse:[
  2150         self defineClassAndSelector
  2262         self defineClassAndSelector
  2151     ].
  2263     ].
  2164     (ReadStream on:code) fileIn.
  2276     (ReadStream on:code) fileIn.
  2165 
  2277 
  2166 !
  2278 !
  2167 
  2279 
  2168 doNew
  2280 doNew
       
  2281     "remove all components and associated resources
       
  2282     "
  2169     self painter isModified ifTrue:[
  2283     self painter isModified ifTrue:[
  2170         (self confirm:'edit a new interface without saving your modifications ?') ifFalse:[
  2284         (self confirm:'edit a new interface without saving your modifications ?') ifFalse:[
  2171             ^ self
  2285             ^ self
  2172         ]
  2286         ]
  2173     ].
  2287     ].
  2174 
  2288     self painter removeAll
  2175     self removeAll
       
  2176 
       
  2177     "Modified: 28.7.1997 / 18:28:02 / cg"
       
  2178 !
  2289 !
  2179 
  2290 
  2180 doPickAView
  2291 doPickAView
       
  2292     "pick a view and setup specifications
       
  2293     "
  2181     |painter view cls spec|
  2294     |painter view cls spec|
  2182 
  2295 
  2183     self painter isModified ifTrue:[
  2296     self painter isModified ifTrue:[
  2184         (self confirm:'pick another interface without saving your modifications ?') ifFalse:[
  2297         (self confirm:'pick another interface without saving your modifications ?') ifFalse:[
  2185             ^ self
  2298             ^ self
  2206 
  2319 
  2207     "Modified: 24.6.1997 / 19:02:57 / cg"
  2320     "Modified: 24.6.1997 / 19:02:57 / cg"
  2208 !
  2321 !
  2209 
  2322 
  2210 doStartApplication
  2323 doStartApplication
       
  2324     "start current edited application
       
  2325     "
  2211     |cls|
  2326     |cls|
  2212 
  2327 
  2213     self painter isModified ifTrue:[
  2328     self painter isModified ifTrue:[
  2214         (self confirm:'the changed spec has not yet been reinstalled.\\Start anyway (based upon the previous interface) ?' withCRs) ifFalse:[
  2329         (self confirm:'the changed spec has not yet been reinstalled.\\Start anyway (based upon the previous interface) ?' withCRs) ifFalse:[
  2215             ^ self
  2330             ^ self
  2239 
  2354 
  2240     "Modified: 28.7.1997 / 18:30:25 / cg"
  2355     "Modified: 28.7.1997 / 18:30:25 / cg"
  2241 !
  2356 !
  2242 
  2357 
  2243 doWindowSpec
  2358 doWindowSpec
       
  2359    "create the window specification but do not write to application; instead
       
  2360     open a view
       
  2361    "
  2244    |code v|
  2362    |code v|
  2245 
  2363 
  2246    code := self painter generateWindowSpecMethodSource.
  2364    code := self painter generateWindowSpecMethodSource.
  2247 
  2365 
  2248    v := CodeView open.
  2366    v := CodeView open.
  2251 
  2369 
  2252 ! !
  2370 ! !
  2253 
  2371 
  2254 !UIPainter::TreeView class methodsFor:'constants'!
  2372 !UIPainter::TreeView class methodsFor:'constants'!
  2255 
  2373 
       
  2374 defaultNameOfCanvas
       
  2375     "returns the default name (id) of the application
       
  2376     "
       
  2377     ^ 'Canvas'
       
  2378 !
       
  2379 
       
  2380 imageEmptyParent
       
  2381 
       
  2382     ImageEmptyParent isNil ifTrue:[
       
  2383         ImageEmptyParent := Image fromFile:('xpmBitmaps/document_images/tiny_dir.xpm').
       
  2384     ].
       
  2385     ^ ImageEmptyParent
       
  2386 
       
  2387     "
       
  2388     ImageEmptyParent := nil
       
  2389     "
       
  2390 !
       
  2391 
  2256 imageMasterChild
  2392 imageMasterChild
  2257 
  2393 
  2258     ImageMasterChild isNil ifTrue:[
  2394     ImageMasterChild isNil ifTrue:[
  2259         ImageMasterChild := Image fromFile:('xpmBitmaps/document_images/tiny_file_plain_gray.xpm').
  2395         ImageMasterChild := Image fromFile:('xpmBitmaps/document_images/tiny_file_plain_gray.xpm').
  2260     ].
  2396     ].
  2268 !
  2404 !
  2269 
  2405 
  2270 imageMasterParent
  2406 imageMasterParent
  2271 
  2407 
  2272     ImageMasterParent isNil ifTrue:[
  2408     ImageMasterParent isNil ifTrue:[
  2273 "/        ImageMasterParent := Image fromFile:('xpmBitmaps/document_images/tiny_yellow_dir_locked.xpm').
       
  2274         ImageMasterParent := Image fromFile:('xpmBitmaps/document_images/tiny_yellow_dir_gray.xpm').
  2409         ImageMasterParent := Image fromFile:('xpmBitmaps/document_images/tiny_yellow_dir_gray.xpm').
  2275     ].
  2410     ].
  2276     ^ ImageMasterParent
  2411     ^ ImageMasterParent
  2277 
  2412 
  2278     "
  2413     "
  2316     "
  2451     "
  2317     |props|
  2452     |props|
  2318 
  2453 
  2319     props := UIPainterView::ViewProperty new.
  2454     props := UIPainterView::ViewProperty new.
  2320     props view:aCanvas.
  2455     props view:aCanvas.
  2321     model root:(TreeItem name:'Canvas' contents:props).
  2456     model root:(TreeItem name:(self class defaultNameOfCanvas) contents:props).
  2322     model root expand.
  2457     model root expand.
  2323     self enableChannel:(aCanvas enableChannel).
  2458     self enableChannel:(aCanvas enableChannel).
  2324 
  2459 
  2325 !
       
  2326 
       
  2327 canvasName:aName
       
  2328     "change id of canvas
       
  2329     "
       
  2330     |name|
       
  2331 
       
  2332     (    aName size ~~ 0
       
  2333      and:[(name := aName string withoutSeparators) size ~~ 0
       
  2334      and:[(self propertyDetect:[:p| p name = name]) isNil
       
  2335      and:[(listOfNodes at:1) name ~= name]]]
       
  2336     ) ifTrue:[
       
  2337         (listOfNodes at:1) name:name.
       
  2338          self redrawLine:1.
       
  2339     ]
       
  2340 !
  2460 !
  2341 
  2461 
  2342 canvasSpec
  2462 canvasSpec
  2343     "returns spec assigned to canvas
  2463     "returns spec assigned to canvas
  2344     "
  2464     "
  2346 
  2466 
  2347     spec := WindowSpec new.
  2467     spec := WindowSpec new.
  2348     spec fromView:(self canvas topView) callBack:nil.
  2468     spec fromView:(self canvas topView) callBack:nil.
  2349     spec name:(listOfNodes at:1) name.
  2469     spec name:(listOfNodes at:1) name.
  2350   ^ spec
  2470   ^ spec
       
  2471 !
       
  2472 
       
  2473 itemOfView:aView
       
  2474     "returns item assigned to view or nil
       
  2475     "
       
  2476     aView notNil ifTrue:[
       
  2477         self allItemsDo:[:anItem|
       
  2478             (anItem contents view == aView) ifTrue:[^ anItem]
       
  2479         ]
       
  2480     ].
       
  2481   ^ nil
       
  2482 
       
  2483 
  2351 ! !
  2484 ! !
  2352 
  2485 
  2353 !UIPainter::TreeView methodsFor:'accessing property'!
  2486 !UIPainter::TreeView methodsFor:'accessing property'!
  2354 
  2487 
  2355 propertiesDo:aOneArgBlock
  2488 propertiesDo:aOneArgBlock
  2388 !UIPainter::TreeView methodsFor:'adding & removing'!
  2521 !UIPainter::TreeView methodsFor:'adding & removing'!
  2389 
  2522 
  2390 addProperty:aProperty
  2523 addProperty:aProperty
  2391     "add a new item
  2524     "add a new item
  2392     "
  2525     "
  2393     |prnt child canvas view|
  2526     model add:(TreeItem name:(aProperty name) contents:aProperty) 
  2394 
  2527         below:(self detectItemRespondsToView:(aProperty view superView))
  2395     child  := TreeItem name:(aProperty name) contents:aProperty.
       
  2396     view   := aProperty view.
       
  2397     canvas := self canvas.
       
  2398 
       
  2399     [ ((view := view superView) notNil and:[(prnt := self itemOfView:view) isNil])
       
  2400     ] whileTrue.
       
  2401 
       
  2402     prnt isNil ifTrue:[
       
  2403         prnt := model root
       
  2404     ].
       
  2405     model add:child below:prnt.
       
  2406 
  2528 
  2407 
  2529 
  2408 !
  2530 !
  2409 
  2531 
  2410 removeAll
  2532 removeAll
  2413     lastDrawnMaster := nil.
  2535     lastDrawnMaster := nil.
  2414 
  2536 
  2415     self canvas subViews copy do:[:aView|
  2537     self canvas subViews copy do:[:aView|
  2416         (aView isKindOf:InputView) ifFalse:[aView destroy]
  2538         (aView isKindOf:InputView) ifFalse:[aView destroy]
  2417     ].
  2539     ].
       
  2540     model root name:(self class defaultNameOfCanvas).
  2418     model root children:(OrderedCollection new).
  2541     model root children:(OrderedCollection new).
  2419     model recomputeList.
  2542     model recomputeList.
  2420     self selection:nil.
  2543     self selection:nil.
  2421 
  2544 
  2422 
  2545 
  2423 !
  2546 !
  2424 
  2547 
  2425 removeView:aView
  2548 removeView:aView
  2426     "remove a view
  2549     "remove a view
  2427     "
  2550     "
  2428     |item spv|
  2551     |item prnt|
  2429 
  2552 
  2430     item := self itemOfView:aView.
  2553     ((item := self itemOfView:aView) notNil and:[(prnt := item parent) notNil]) ifTrue:[
  2431 
       
  2432     item notNil ifTrue:[
       
  2433         spv := aView superView.
       
  2434         aView destroy.
  2554         aView destroy.
  2435         spv sizeChanged:nil.
  2555         prnt contents view sizeChanged:nil.
  2436         model remove:item
  2556         model remove:item
  2437     ]
  2557     ]
  2438 
  2558 
  2439 
  2559 
  2440 ! !
  2560 ! !
  2615     "drop objects ? delegate to canvas
  2735     "drop objects ? delegate to canvas
  2616     "
  2736     "
  2617     self canvas drop:anObjectOrCollection at:aPoint
  2737     self canvas drop:anObjectOrCollection at:aPoint
  2618 ! !
  2738 ! !
  2619 
  2739 
       
  2740 !UIPainter::TreeView methodsFor:'enumerating'!
       
  2741 
       
  2742 allItemsDo:aOneArgBlock
       
  2743     "evaluate the argument a block on each item other than the canvas
       
  2744     "
       
  2745     model root allChildrenDo:aOneArgBlock
       
  2746 
       
  2747 
       
  2748 ! !
       
  2749 
  2620 !UIPainter::TreeView methodsFor:'event processing'!
  2750 !UIPainter::TreeView methodsFor:'event processing'!
  2621 
  2751 
  2622 cvsEventsDisabledDo:aBlock
  2752 cvsEventsDisabledDo:aBlock
  2623     "evaluate the block without raising selection changed notifications
  2753     "evaluate the block without raising selection changed notifications
  2624      to canvas
  2754      to canvas
  2665     "
  2795     "
  2666     super initialize.
  2796     super initialize.
  2667     self multipleSelectOk:true.
  2797     self multipleSelectOk:true.
  2668     self model:(SelectionInTree new).
  2798     self model:(SelectionInTree new).
  2669     cvsEventsDisabled := false.
  2799     cvsEventsDisabled := false.
  2670 
  2800     imageMasterChild  := (self class imageMasterChild) onDevice:device.
       
  2801     imageMasterParent := (self class imageMasterParent) onDevice:device.
       
  2802     imageEmptyParent  := (self class imageEmptyParent)  onDevice:device.
  2671 
  2803 
  2672 ! !
  2804 ! !
  2673 
  2805 
  2674 !UIPainter::TreeView methodsFor:'private'!
  2806 !UIPainter::TreeView methodsFor:'private'!
  2675 
       
  2676 allItemsDo:aOneArgBlock
       
  2677     "evaluate the argument a block on each item other than the canvas
       
  2678     "
       
  2679     model root allChildrenDo:aOneArgBlock
       
  2680 
       
  2681 
       
  2682 !
       
  2683 
  2807 
  2684 figureFor:aNode
  2808 figureFor:aNode
  2685     "returns image for an item; testing whether item is the first
  2809     "returns image for an item; testing whether item is the first
  2686      entry into the selection
  2810      entry into the selection
  2687     "
  2811     "
  2688     |master|
  2812     |master subComp|
       
  2813 
       
  2814     subComp := (aNode parent isNil or:[aNode contents spec class supportsSubComponents]).
  2689 
  2815 
  2690     selection size == 0 ifFalse:[
  2816     selection size == 0 ifFalse:[
  2691         master := listOfNodes at:(selection first).
  2817         master := listOfNodes at:(selection first).
  2692 
  2818 
  2693         aNode == master ifTrue:[
  2819         aNode == master ifTrue:[
  2694             lastDrawnMaster := master.
  2820             lastDrawnMaster := master.
  2695             aNode children size == 0 ifTrue:[
  2821             subComp ifFalse:[^ imageMasterChild]
  2696                 imageMasterChild isNil ifTrue:[
  2822                      ifTrue:[^ imageMasterParent].
  2697                     imageMasterChild := (self class imageMasterChild) onDevice:device.
       
  2698                 ].
       
  2699               ^ imageMasterChild
       
  2700             ].
       
  2701             imageMasterParent isNil ifTrue:[
       
  2702                 imageMasterParent := (self class imageMasterParent) onDevice:device.
       
  2703             ].
       
  2704           ^ imageMasterParent
       
  2705         ]
  2823         ]
  2706     ].
  2824     ].
  2707     ^ super figureFor:aNode
  2825     subComp ifFalse:[
  2708 
  2826         ^ imageItem
  2709 
  2827     ].
  2710 !
  2828     aNode hasChildren ifTrue:[
  2711 
  2829         aNode isExpandable ifTrue:[ ^ imageClosed ]
  2712 itemOfView:aView
  2830                           ifFalse:[ ^ imageOpened ]
  2713     "returns item assigned to view or nil
  2831     ].
  2714     "
  2832     ^ imageEmptyParent
  2715     aView notNil ifTrue:[
       
  2716         self allItemsDo:[:anItem|
       
  2717             (anItem contents view == aView) ifTrue:[^ anItem]
       
  2718         ]
       
  2719     ].
       
  2720   ^ nil
       
  2721 
       
  2722 
  2833 
  2723 !
  2834 !
  2724 
  2835 
  2725 selectionChangedFrom:oldSelection
  2836 selectionChangedFrom:oldSelection
  2726     "selection has changed. update master selection and raise notification
  2837     "selection has changed. update master selection and raise notification
  2727      to canvas in case of enabled cvs events
  2838      to canvas in case of enabled cvs events
  2728     "
  2839     "
  2729     |sel|
  2840     |sel size|
  2730 
  2841 
  2731     super selectionChangedFrom:oldSelection.
  2842     super selectionChangedFrom:oldSelection.
       
  2843     size := selection size.
  2732 
  2844 
  2733     cvsEventsDisabled ifFalse:[
  2845     cvsEventsDisabled ifFalse:[
  2734         selection notNil ifTrue:[
  2846         (size ~~ 0 and:[size ~~ 1 or:[selection first ~~ 1]]) ifTrue:[
  2735             sel := selection collect:[:i| (listOfNodes at:i) contents view].
  2847             sel := OrderedCollection new.
  2736         ] ifFalse:[
  2848 
  2737             sel := #()
  2849             selection do:[:i|
       
  2850                 i ~~ 1 ifTrue:[sel add:(listOfNodes at:i) contents view]
       
  2851             ]
  2738         ].
  2852         ].
  2739         self canvas updateSelectionFromModel:sel.
  2853         self canvas updateSelectionFromModel:sel
  2740     ].
  2854     ].
  2741 
  2855 
  2742     selection size ~~ 0 ifTrue:[
  2856     size ~~ 0 ifTrue:[
  2743         sel := selection first.
  2857         sel := selection first.
  2744 
  2858 
  2745         (listOfNodes at:sel) == lastDrawnMaster ifFalse:[
  2859         (listOfNodes at:sel) == lastDrawnMaster ifFalse:[
  2746             self redrawLine:sel
  2860             self redrawLine:sel
  2747         ]
  2861         ]
  2748     ]
  2862     ]
  2749 
       
  2750 
       
  2751 ! !
  2863 ! !
  2752 
  2864 
  2753 !UIPainter::TreeView methodsFor:'queries'!
  2865 !UIPainter::TreeView methodsFor:'queries'!
  2754 
  2866 
  2755 canStepIn
  2867 canMoveOrAlignSelection
  2756     "returns true if can step in
  2868     "returns true if any selection exists and all widgets in the selection
       
  2869      can change their layout through to a move or align operation.
       
  2870     "
       
  2871     |canvas|
       
  2872 
       
  2873     selection size == 0 ifTrue:[
       
  2874         ^ false
       
  2875     ].
       
  2876     canvas := self canvas.
       
  2877 
       
  2878     selection do:[:i|
       
  2879         i == 1 ifTrue:[^ false].
       
  2880 
       
  2881         (canvas canChangeLayoutOfView:((listOfNodes at:i) contents view)) ifFalse:[
       
  2882             ^ false
       
  2883         ]
       
  2884     ].
       
  2885     ^ true
       
  2886 !
       
  2887 
       
  2888 canMoveSelectionIntoContainer
       
  2889     "returns true in case that one component is selected and can change its container
       
  2890      widget to the next element in the list which will have the same container.
  2757     "
  2891     "
  2758     |item prnt|
  2892     |item prnt|
  2759 
  2893 
  2760     (     (item := self selectedNode) isNil
  2894     (     (item := self selectedNode) isNil
  2761       or:[(prnt := item parent) isNil
  2895       or:[(prnt := item parent) isNil
  2765         ^ false
  2899         ^ false
  2766     ].
  2900     ].
  2767   ^ true
  2901   ^ true
  2768 !
  2902 !
  2769 
  2903 
  2770 canStepOut
  2904 canMoveSelectionOutOfContainer
       
  2905     "returns true in case that one component is selected which is contained within
       
  2906      another component.
       
  2907     "
  2771     |item prnt|
  2908     |item prnt|
  2772 
  2909 
  2773     (     (item := self selectedNode) isNil
  2910     (     (item := self selectedNode) isNil
  2774       or:[(prnt := item parent) isNil
  2911       or:[(prnt := item parent) isNil
  2775       or:[prnt parent isNil]]
  2912       or:[prnt parent isNil]]
  2777         ^ false
  2914         ^ false
  2778     ].
  2915     ].
  2779   ^ true
  2916   ^ true
  2780 !
  2917 !
  2781 
  2918 
  2782 hasValidSelection
  2919 hasOneSelectionOtherThanCanvas
  2783     "returns true if any selection exists other than root
  2920     "returns true in case that one selection exists other than the canvas
  2784     "
  2921     "
  2785     |size|
  2922     ^ (selection size == 1 and:[selection first ~~ 1])
  2786 
       
  2787     (size := selection size) > 1 ifFalse:[
       
  2788         (size == 0 or:[self isInSelection:1]) ifTrue:[
       
  2789             ^ false
       
  2790         ]
       
  2791     ].
       
  2792   ^ true
       
  2793 !
  2923 !
  2794 
  2924 
  2795 isCanvasSelected
  2925 isCanvasSelected
  2796     "returns true in case of a single selection and the
  2926     "returns true in case of a single selection and the
  2797      selection is the canvas (index 1)
  2927      selection is the canvas (index 1)
  2798     "
  2928     "
  2799     ^ (selection size == 1 and:[self isInSelection:1])
  2929     ^ (selection size == 1 and:[self isInSelection:1])
       
  2930 ! !
       
  2931 
       
  2932 !UIPainter::TreeView methodsFor:'seraching'!
       
  2933 
       
  2934 detectItemRespondsToView:aView
       
  2935     "detect the item responding to the view. The item of the view or the first
       
  2936      subview providing the item is returned. If no property is detected nil is
       
  2937      returned
       
  2938     "
       
  2939     |view item|
       
  2940 
       
  2941     (view := aView) notNil ifTrue:[
       
  2942         [(item := self itemOfView:view) isNil] whileTrue:[
       
  2943             (view := view superView) isNil ifTrue:[^ listOfNodes at:1]
       
  2944         ].
       
  2945     ].
       
  2946     ^ item
       
  2947 
  2800 ! !
  2948 ! !
  2801 
  2949 
  2802 !UIPainter::TreeView methodsFor:'user interactions'!
  2950 !UIPainter::TreeView methodsFor:'user interactions'!
  2803 
  2951 
  2804 doStepIn
  2952 doStepIn
  2835 !
  2983 !
  2836 
  2984 
  2837 doStepOver:anIndex
  2985 doStepOver:anIndex
  2838     "move child 'anOffset' forward or backward in list of children
  2986     "move child 'anOffset' forward or backward in list of children
  2839     "
  2987     "
  2840     |item idx size prnt spVw view|
  2988     |item idx size prnt spVw view canvas|
  2841 
  2989 
  2842     (    (item := self selectedNode) isNil
  2990     (    (item := self selectedNode) isNil
  2843      or:[(prnt := item parent) isNil
  2991      or:[(prnt := item parent) isNil
  2844      or:[(size := prnt children size) < 2]]
  2992      or:[(size := prnt children size) < 2
  2845     ) ifFalse:[
  2993      or:[(idx  := prnt indexOfChild:item) == 0]]]
  2846         idx := prnt indexOfChild:item.
  2994     ) ifTrue:[
  2847 
  2995         ^ self
  2848         model removeDependent:self.
  2996     ].
  2849         model removeSelection.
  2997     model removeDependent:self.
  2850         selection := nil.
  2998     model removeSelection.
  2851         model addDependent:self.
  2999     selection := nil.
  2852         idx := idx + anIndex.
  3000     model addDependent:self.
  2853 
  3001     idx := idx + anIndex.
  2854         idx < 1 ifTrue:[idx := size]
  3002 
  2855                ifFalse:[idx > size ifTrue:[idx := 1]].
  3003     idx < 1 ifTrue:[idx := size]
  2856 
  3004            ifFalse:[idx > size ifTrue:[idx := 1]].
  2857         model add:item beforeIndex:idx below:prnt.
  3005 
  2858         idx  := prnt indexOfChild:item.
  3006     model add:item beforeIndex:idx below:prnt.
  2859         view := item contents view.
  3007     idx    := prnt indexOfChild:item.
  2860         spVw := view superView.
  3008     view   := item contents view.
  2861 
  3009     spVw   := prnt contents view.
  2862      "/ input view might by contained in sequence
  3010     canvas := self canvas.
  2863         ((size := self canvas findInputViewIn:spVw) ~~ 0 and:[idx >= size]) ifTrue:[
  3011 
  2864             idx := idx + 1
  3012     canvas hideSelection.
  2865         ].
  3013 
  2866         spVw changeSequenceOrderFor:view to:idx.
  3014  "/ input view might by contained in sequence
  2867 
  3015     ((size := canvas findInputViewIn:spVw) ~~ 0 and:[idx >= size]) ifTrue:[
  2868         spVw specClass isLayoutContainer ifFalse:[
  3016         idx := idx + 1
  2869             spVw subViews do:[:v| v raise ].
  3017     ].
  2870             self canvas inputView raise
  3018     spVw changeSequenceOrderFor:view to:idx.
  2871         ].
  3019 
  2872         self selectNode:item.
  3020     spVw specClass isLayoutContainer ifFalse:[
  2873     ]
  3021         spVw subViews do:[:v| v raise ].
       
  3022         canvas inputView raise
       
  3023     ].
       
  3024     canvas showSelection.
       
  3025     self selectNode:item.
  2874 ! !
  3026 ! !
  2875 
  3027 
  2876 !UIPainter class methodsFor:'documentation'!
  3028 !UIPainter class methodsFor:'documentation'!
  2877 
  3029 
  2878 version
  3030 version