UIPainterView.st
changeset 223 203460df426e
parent 219 7b38043ae232
child 231 75de472d579f
equal deleted inserted replaced
222:dd2688307d90 223:203460df426e
     9  other person.  No title to or ownership of the software is
     9  other person.  No title to or ownership of the software is
    10  hereby transferred.
    10  hereby transferred.
    11 "
    11 "
    12 
    12 
    13 UIObjectView subclass:#UIPainterView
    13 UIObjectView subclass:#UIPainterView
    14 	instanceVariableNames:'listHolder superclassName className methodName categoryName'
    14 	instanceVariableNames:'claus listHolder superclassName className methodName categoryName'
    15 	classVariableNames:'HandCursor'
    15 	classVariableNames:'HandCursor'
    16 	poolDictionaries:''
    16 	poolDictionaries:''
    17 	category:'Interface-UIPainter'
    17 	category:'Interface-UIPainter'
    18 !
       
    19 
       
    20 MultiSelectionInList subclass:#ListHolder
       
    21 	instanceVariableNames:'painter propertyList masterElement disabledChanged'
       
    22 	classVariableNames:''
       
    23 	poolDictionaries:''
       
    24 	privateIn:UIPainterView
       
    25 !
    18 !
    26 
    19 
    27 Object subclass:#ViewProperty
    20 Object subclass:#ViewProperty
    28 	instanceVariableNames:'view spec identifier'
    21 	instanceVariableNames:'view spec identifier'
    29 	classVariableNames:'Identifier'
    22 	classVariableNames:'Identifier'
    70     ^ #showMiddleButtonMenu
    63     ^ #showMiddleButtonMenu
    71 
    64 
    72 
    65 
    73 ! !
    66 ! !
    74 
    67 
    75 !UIPainterView class methodsFor:'menu specs'!
       
    76 
       
    77 menu
       
    78     "this window spec was automatically generated by the ST/X MenuEditor"
       
    79 
       
    80     "do not manually edit this - the builder may not be able to
       
    81      handle the specification if its corrupted."
       
    82 
       
    83     "
       
    84      MenuEditor new openOnClass:UIPainterView andSelector:#menu
       
    85      (Menu new fromLiteralArrayEncoding:(UIPainterView menu)) startUp
       
    86     "
       
    87 
       
    88     <resource: #menu>
       
    89 
       
    90     ^
       
    91      
       
    92        #(#Menu
       
    93           
       
    94            #(
       
    95              #(#MenuItem
       
    96                 #'label:' 'copy'
       
    97                 #'value:' #copySelection
       
    98                 #'shortcutKeyCharacter:' #Copy
       
    99             )
       
   100              #(#MenuItem
       
   101                 #'label:' 'cut'
       
   102                 #'value:' #deleteSelection
       
   103                 #'shortcutKeyCharacter:' #Cut
       
   104             )
       
   105              #(#MenuItem
       
   106                 #'label:' 'paste'
       
   107                 #'nameKey:' #paste
       
   108                 #'value:' #paste
       
   109                 #'submenu:' 
       
   110                  #(#Menu
       
   111                     
       
   112                      #(
       
   113                        #(#MenuItem
       
   114                           #'label:' 'paste'
       
   115                           #'value:' #pasteBuffer
       
   116                           #'activeHelpKey:' #pasteBuffer
       
   117                           #'shortcutKeyCharacter:' #Paste
       
   118                       )
       
   119                        #(#MenuItem
       
   120                           #'label:' 'keep layout'
       
   121                           #'value:' #pasteWithLayout
       
   122                           #'activeHelpKey:' #pasteWithLayout
       
   123                       )
       
   124                     ) nil
       
   125                     nil
       
   126                 )
       
   127             )
       
   128              #(#MenuItem
       
   129                 #'label:' '-'
       
   130             )
       
   131              #(#MenuItem
       
   132                 #'label:' 'undo'
       
   133                 #'nameKey:' #undo
       
   134                 #'value:' #undoLast
       
   135             )
       
   136              #(#MenuItem
       
   137                 #'label:' '-'
       
   138             )
       
   139              #(#MenuItem
       
   140                 #'label:' 'arrange'
       
   141                 #'value:' #arrange
       
   142                 #'submenu:' 
       
   143                  #(#Menu
       
   144                     
       
   145                      #(
       
   146                        #(#MenuItem
       
   147                           #'label:' 'to front'
       
   148                           #'value:' #raiseSelection
       
   149                       )
       
   150                        #(#MenuItem
       
   151                           #'label:' 'to back'
       
   152                           #'value:' #lowerSelection
       
   153                       )
       
   154                     ) nil
       
   155                     nil
       
   156                 )
       
   157             )
       
   158              #(#MenuItem
       
   159                 #'label:' 'dimension'
       
   160                 #'value:' #dimension
       
   161                 #'submenu:' 
       
   162                  #(#Menu
       
   163                     
       
   164                      #(
       
   165                        #(#MenuItem
       
   166                           #'label:' 'default extent'
       
   167                           #'value:' #setToDefaultExtent
       
   168                           #'activeHelpKey:' #setToDefaultExtent
       
   169                       )
       
   170                        #(#MenuItem
       
   171                           #'label:' 'default width'
       
   172                           #'value:' #setToDefaultWidth
       
   173                           #'activeHelpKey:' #setToDefaultWidth
       
   174                       )
       
   175                        #(#MenuItem
       
   176                           #'label:' 'default height'
       
   177                           #'value:' #setToDefaultHeight
       
   178                           #'activeHelpKey:' #setToDefaultHeight
       
   179                       )
       
   180                        #(#MenuItem
       
   181                           #'label:' 'copy extent'
       
   182                           #'value:' #copyExtent
       
   183                           #'activeHelpKey:' #copyExtent
       
   184                       )
       
   185                        #(#MenuItem
       
   186                           #'label:' 'paste extent'
       
   187                           #'value:' #pasteExtent
       
   188                           #'activeHelpKey:' #pasteExtent
       
   189                       )
       
   190                        #(#MenuItem
       
   191                           #'label:' 'paste width'
       
   192                           #'value:' #pasteWidth
       
   193                           #'activeHelpKey:' #pasteWidth
       
   194                       )
       
   195                        #(#MenuItem
       
   196                           #'label:' 'paste height'
       
   197                           #'value:' #pasteHeight
       
   198                           #'activeHelpKey:' #pasteHeight
       
   199                       )
       
   200                        #(#MenuItem
       
   201                           #'label:' 'copy  layout'
       
   202                           #'value:' #copyLayout
       
   203                           #'activeHelpKey:' #copyLayout
       
   204                       )
       
   205                        #(#MenuItem
       
   206                           #'label:' 'paste layout'
       
   207                           #'value:' #pasteLayout
       
   208                           #'activeHelpKey:' #pasteLayout
       
   209                       )
       
   210                     )
       
   211                     #(3 1 3)
       
   212                     nil
       
   213                 )
       
   214             )
       
   215              #(#MenuItem
       
   216                 #'label:' 'align'
       
   217                 #'value:' #align
       
   218                 #'submenu:' 
       
   219                  #(#Menu
       
   220                     
       
   221                      #(
       
   222                        #(#MenuItem
       
   223                           #'label:' 'align left'
       
   224                           #'value:' #alignSelectionLeft
       
   225                           #'activeHelpKey:' #alignSelectionLeft
       
   226                           #'labelImage:' 
       
   227                            #(#ResourceRetriever
       
   228                               #UIPainter #iconAlignL
       
   229                               'align left'
       
   230                           )
       
   231                       )
       
   232                        #(#MenuItem
       
   233                           #'label:' 'align right'
       
   234                           #'value:' #alignSelectionRight
       
   235                           #'activeHelpKey:' #alignSelectionRight
       
   236                           #'labelImage:' 
       
   237                            #(#ResourceRetriever
       
   238                               #UIPainter #iconAlignR
       
   239                               'align right'
       
   240                           )
       
   241                       )
       
   242                        #(#MenuItem
       
   243                           #'label:' 'align left & right'
       
   244                           #'value:' #alignSelectionLeftAndRight
       
   245                           #'activeHelpKey:' #alignSelectionLeftAndRight
       
   246                           #'labelImage:' 
       
   247                            #(#ResourceRetriever
       
   248                               #UIPainter #iconAlignLR
       
   249                               'align left & right'
       
   250                           )
       
   251                       )
       
   252                        #(#MenuItem
       
   253                           #'label:' 'align top'
       
   254                           #'value:' #alignSelectionTop
       
   255                           #'activeHelpKey:' #alignSelectionTop
       
   256                           #'labelImage:' 
       
   257                            #(#ResourceRetriever
       
   258                               #UIPainter #iconAlignT
       
   259                               'align top'
       
   260                           )
       
   261                       )
       
   262                        #(#MenuItem
       
   263                           #'label:' 'align bottom'
       
   264                           #'value:' #alignSelectionBottom
       
   265                           #'activeHelpKey:' #alignSelectionBottom
       
   266                           #'labelImage:' 
       
   267                            #(#ResourceRetriever
       
   268                               #UIPainter #iconAlignB
       
   269                               'align bottom'
       
   270                           )
       
   271                       )
       
   272                        #(#MenuItem
       
   273                           #'label:' 'align top & bottom'
       
   274                           #'value:' #alignSelectionTopAndBottom
       
   275                           #'activeHelpKey:' #alignSelectionTopAndBottom
       
   276                           #'labelImage:' 
       
   277                            #(#ResourceRetriever
       
   278                               #UIPainter #iconAlignTB
       
   279                               'align top & bottom'
       
   280                           )
       
   281                       )
       
   282                        #(#MenuItem
       
   283                           #'label:' 'align centered horizontal'
       
   284                           #'value:' #alignSelectionCenterHor
       
   285                           #'activeHelpKey:' #alignSelectionCenterHor
       
   286                           #'labelImage:' 
       
   287                            #(#ResourceRetriever
       
   288                               #UIPainter #iconAlignCenterH
       
   289                               'align centered horizontal'
       
   290                           )
       
   291                       )
       
   292                        #(#MenuItem
       
   293                           #'label:' 'align centered vertical'
       
   294                           #'value:' #alignSelectionCenterVer
       
   295                           #'activeHelpKey:' #alignSelectionCenterVer
       
   296                           #'labelImage:' 
       
   297                            #(#ResourceRetriever
       
   298                               #UIPainter #iconAlignCenterV
       
   299                               'align centered vertical'
       
   300                           )
       
   301                       )
       
   302                        #(#MenuItem
       
   303                           #'label:' 'spread horizontal'
       
   304                           #'value:' #spreadSelectionHor
       
   305                           #'activeHelpKey:' #spreadSelectionHor
       
   306                       )
       
   307                        #(#MenuItem
       
   308                           #'label:' 'spread vertical'
       
   309                           #'value:' #spreadSelectionVer
       
   310                           #'activeHelpKey:' #spreadSelectionVer
       
   311                       )
       
   312                        #(#MenuItem
       
   313                           #'label:' 'center horizontal in frame'
       
   314                           #'value:' #centerSelectionHor
       
   315                           #'activeHelpKey:' #centerSelectionHor
       
   316                       )
       
   317                        #(#MenuItem
       
   318                           #'label:' 'center vertical in frame'
       
   319                           #'value:' #centerSelectionVer
       
   320                           #'activeHelpKey:' #centerSelectionVer
       
   321                       )
       
   322                     )
       
   323                     #(8 2)
       
   324                     nil
       
   325                 )
       
   326             )
       
   327           ) nil
       
   328           nil
       
   329       )
       
   330 ! !
       
   331 
       
   332 !UIPainterView methodsFor:'accessing'!
    68 !UIPainterView methodsFor:'accessing'!
   333 
    69 
   334 application
    70 application
   335     ^ nil
    71     ^ nil
   336 
    72 
   358     superclassName := aSuperclassName.
    94     superclassName := aSuperclassName.
   359     methodName     := aSelector.
    95     methodName     := aSelector.
   360 
    96 
   361 !
    97 !
   362 
    98 
   363 listHolder
    99 findInputViewIn:aSuperView
   364     ^ listHolder
   100     "returns index of input view into superview or nil
       
   101     "
       
   102     |subviews|
       
   103 
       
   104     aSuperView == self ifTrue:[
       
   105         ^ self subViews findFirst:[:v| v == inputView ]
       
   106     ].
       
   107   ^ 0
       
   108 !
       
   109 
       
   110 inputView
       
   111     ^ inputView
   365 !
   112 !
   366 
   113 
   367 methodName
   114 methodName
   368     ^ methodName
   115     ^ methodName
   369 !
   116 !
   403 
   150 
   404 ! !
   151 ! !
   405 
   152 
   406 !UIPainterView methodsFor:'change & update'!
   153 !UIPainterView methodsFor:'change & update'!
   407 
   154 
   408 changed:aParameter
   155 layoutChanged
   409     aParameter == #layout ifTrue:[
   156     claus layoutChanged
   410         listHolder removeDependent:self.
       
   411         listHolder changed:aParameter.
       
   412         listHolder addDependent:self.
       
   413     ] ifFalse:[
       
   414         super changed:aParameter
       
   415     ]
       
   416 !
       
   417 
       
   418 selectionChanged
       
   419     "selection has changed
       
   420     "
       
   421     |newSel|
       
   422 
       
   423     self selectionDo:[:aView||p|
       
   424         (p := self propertyOfView:aView) notNil ifTrue:[
       
   425             newSel isNil ifTrue:[
       
   426                 newSel := OrderedCollection new
       
   427             ].
       
   428             newSel add:(listHolder indexOfName:(p name))
       
   429         ]
       
   430     ].
       
   431     listHolder removeDependent:self.
       
   432     listHolder selectionIndex:newSel.
       
   433     listHolder addDependent:self.
       
   434 !
       
   435 
       
   436 update:what with:aParm from:aSender
       
   437     |loIdx newSel|
       
   438 
       
   439     (what == #selectionIndex and:[aSender == listHolder]) ifFalse:[
       
   440         ^ self
       
   441     ].
       
   442     loIdx := listHolder selectionIndex.
       
   443 
       
   444     loIdx size ~~ 0 ifTrue:[
       
   445         newSel := loIdx collect:[:i|(listHolder propertyAt:i) view]
       
   446     ].
       
   447     self updateSelectionFrom:newSel.
       
   448 !
       
   449 
       
   450 updateSelectionFrom:aSel
       
   451     "update selection from a new selection
       
   452     "
       
   453     |csel|
       
   454 
       
   455     selectionHiddenLevel == 0 ifTrue:[
       
   456         aSel isCollection ifTrue:[
       
   457             self selectionDo:[:el|
       
   458                 (aSel includes:el) ifFalse:[self showUnselected:el]
       
   459             ]
       
   460         ] ifFalse:[
       
   461             self selectionDo:[:el|
       
   462                 aSel == el ifFalse:[self showUnselected:el]
       
   463             ]
       
   464         ]
       
   465     ].
       
   466     self setSelection:aSel withRedraw:false.
       
   467     self showSelection
       
   468 ! !
   157 ! !
   469 
   158 
   470 !UIPainterView methodsFor:'copy & cut & paste'!
   159 !UIPainterView methodsFor:'copy & cut & paste'!
   471 
   160 
   472 copySelection
   161 copySelection
   492     |specs coll|
   181     |specs coll|
   493 
   182 
   494     coll := self minSetOfSuperViews:(self selection).
   183     coll := self minSetOfSuperViews:(self selection).
   495 
   184 
   496     coll notNil ifTrue:[
   185     coll notNil ifTrue:[
   497         listHolder disableNotificationsWhileEvaluating:[
   186         claus cvsEventsDisabledDo:[
   498             self select:nil.
   187             self select:nil.
   499             specs := coll collect:[:aView| self fullSpecFor:aView ].
   188             specs := coll collect:[:aView| self fullSpecFor:aView ].
   500 
   189 
   501             self withinTransaction:#cut objects:coll do:[
   190             self withinTransaction:#cut objects:coll do:[
   502                 coll reverseDo:[:aView|
   191                 coll reverseDo:[:aView|
   510 !
   199 !
   511 
   200 
   512 pasteBuffer
   201 pasteBuffer
   513     "add the objects in the paste-buffer to the object view
   202     "add the objects in the paste-buffer to the object view
   514     "
   203     "
   515     self pasteSpecifications:(self getSelection) keepLayout:false
   204     |sel|
       
   205 
       
   206     sel := self pasteSpecifications:(self getSelection) keepLayout:false.
       
   207 
       
   208     sel notNil ifTrue:[
       
   209         self select:sel.
       
   210     ].
   516 
   211 
   517 !
   212 !
   518 
   213 
   519 pasteSpecifications:aSpecificationOrList keepLayout:keepLayout
   214 pasteSpecifications:aSpecificationOrList keepLayout:keepLayout
   520     "add the specs to the object view
   215     "add the specs to the object view; returns list of pasted components
   521     "
   216     "
   522     |paste frame pasteOrigin pasteOffset builder newSel|
   217     |paste frame pasteOrigin pasteOffset builder newSel|
   523 
   218 
   524     (self canPaste:aSpecificationOrList) ifFalse:[
   219     (self canPaste:aSpecificationOrList) ifFalse:[
   525         ^ self
   220         ^ nil
   526     ].
   221     ].
   527     listHolder disableNotificationsWhileEvaluating:[
   222 
       
   223     claus cvsSetupListDo:[
   528         aSpecificationOrList isCollection ifTrue:[
   224         aSpecificationOrList isCollection ifTrue:[
   529             paste := aSpecificationOrList
   225             paste := aSpecificationOrList
   530         ] ifFalse:[
   226         ] ifFalse:[
   531             paste := Array with:aSpecificationOrList
   227             paste := Array with:aSpecificationOrList
   532         ].
   228         ].
   533         frame := self singleSelection.
   229         (frame := self singleSelection) isNil ifTrue:[
   534 
       
   535         (self canPasteInto:frame) ifFalse:[
       
   536             frame := self
   230             frame := self
   537         ].
   231         ].
   538         self setSelection:nil withRedraw:true.
   232         self setSelection:nil withRedraw:true.
   539 
   233 
   540         newSel  := OrderedCollection new.
   234         newSel  := OrderedCollection new.
   547             pasteOffset := 0@0.
   241             pasteOffset := 0@0.
   548             pasteOrigin := self sensor mousePoint.
   242             pasteOrigin := self sensor mousePoint.
   549             pasteOrigin := device translatePoint:pasteOrigin from:device rootView id to:frame id.
   243             pasteOrigin := device translatePoint:pasteOrigin from:device rootView id to:frame id.
   550         ].
   244         ].
   551 
   245 
   552         listHolder disableNotificationsWhileEvaluating:[
   246         paste do:[:aSpec|
   553             paste do:[:aSpec|
   247             |view|
   554                 |view|
   248 
   555 
   249             view := self addSpec:aSpec builder:builder in:frame.
   556                 view := self addSpec:aSpec builder:builder in:frame.
   250 
   557 
   251             keepLayout ifFalse:[
   558                 keepLayout ifFalse:[
   252                 (frame bounds containsPoint:pasteOrigin) ifFalse:[
   559                     (frame bounds containsPoint:pasteOrigin) ifFalse:[
   253                     self moveObject:view to:pasteOffset.
   560                         self moveObject:view to:pasteOffset.
   254                 ] ifTrue:[
   561                     ] ifTrue:[
   255                     self moveObject:view to:pasteOrigin + pasteOffset.
   562                         self moveObject:view to:pasteOrigin + pasteOffset.
       
   563                     ].
       
   564                     pasteOffset := pasteOffset + 4
       
   565                 ].
   256                 ].
   566                 view realize.
   257                 pasteOffset := pasteOffset + 4
   567                 newSel add:view.
       
   568             ].
   258             ].
       
   259             view realize.
       
   260             newSel add:view.
   569         ].
   261         ].
   570 
   262 
   571         self withinTransaction:#paste objects:newSel do:[
   263         self withinTransaction:#paste objects:newSel do:[
   572             undoHistory addUndoSelector:#undoCreate:
   264             undoHistory addUndoSelector:#undoCreate:
   573                                withArgs:(newSel collect:[:v|(self propertyOfView:v) identifier])
   265                                withArgs:(newSel collect:[:v|(self propertyOfView:v) identifier])
   576         newSel size == 1 ifTrue:[
   268         newSel size == 1 ifTrue:[
   577             newSel := newSel at:1
   269             newSel := newSel at:1
   578         ].
   270         ].
   579         self realizeAllSubViews.
   271         self realizeAllSubViews.
   580         inputView raise.
   272         inputView raise.
   581         self select:newSel.
       
   582         self elementChangedSize:frame.
   273         self elementChangedSize:frame.
   583     ]
   274     ].
   584 
   275     ^ newSel
   585     "Modified: 4.7.1997 / 23:49:14 / cg"
       
   586 !
   276 !
   587 
   277 
   588 pasteWithLayout
   278 pasteWithLayout
   589     "add the objects in the paste-buffer to the object view; don't change the
   279     "add the objects in the paste-buffer to the object view; don't change the
   590      layout
   280      layout
   591     "
   281     "
   592     self pasteSpecifications:(self getSelection) keepLayout:true
   282     |sel|
   593 
   283 
       
   284     sel := self pasteSpecifications:(self getSelection) keepLayout:true.
       
   285 
       
   286     sel notNil ifTrue:[
       
   287         self select:sel.
       
   288     ].
   594 ! !
   289 ! !
   595 
   290 
   596 !UIPainterView methodsFor:'drag & drop'!
   291 !UIPainterView methodsFor:'drag & drop'!
   597 
   292 
   598 canDrop:anObjectOrCollection
   293 canDrop:anObjectOrCollection
       
   294     anObjectOrCollection size == 1 ifTrue:[
       
   295         ^ self canPaste:(anObjectOrCollection first theObject)
       
   296     ].
       
   297     ^ false
       
   298 !
       
   299 
       
   300 canPaste:something
       
   301     "returns true if something could be paste
       
   302     "
       
   303     |el size|
       
   304 
       
   305     ((size := self numberOfSelections) <= 1 and:[self enabled]) ifFalse:[
       
   306         ^ false
       
   307     ].
       
   308     something isCollection ifTrue:[something notEmpty ifTrue:[el := something first]]
       
   309                           ifFalse:[el := something].
       
   310 
       
   311     (el isKindOf:UISpecification) ifFalse:[
       
   312         ^ false
       
   313     ].
       
   314 
       
   315     size == 1 ifTrue:[
       
   316         ^ self canPasteInto:(self singleSelection)
       
   317     ].
       
   318   ^ true
       
   319 
       
   320 !
       
   321 
       
   322 canPasteInto:aView
       
   323     "can paste into a view
       
   324     "
   599     |spec|
   325     |spec|
   600 
   326 
   601     self enabled ifTrue:[
   327     aView notNil ifTrue:[
   602         anObjectOrCollection size == 1 ifTrue:[
   328         spec := self specFor:aView.
   603             spec := (anObjectOrCollection at:1) theObject.
   329 
   604             ^ (spec isKindOf:UISpecification)
   330         spec isNil ifTrue:[^ aView specClass supportsSubComponents]
   605         ]
   331                   ifFalse:[^ spec  class     supportsSubComponents]
   606     ].
   332     ].
   607     ^ false
   333     ^ false
   608 
   334 
   609     "Modified: 8.4.1997 / 01:01:50 / cg"
       
   610 !
   335 !
   611 
   336 
   612 drop:anObjectOrCollection at:aPoint
   337 drop:anObjectOrCollection at:aPoint
   613     |spec|
   338     |spec newSel oldSel|
   614 
   339 
       
   340     oldSel := selection copy.
   615     spec := (anObjectOrCollection at:1) theObject.
   341     spec := (anObjectOrCollection at:1) theObject.
   616     self pasteSpecifications:spec keepLayout:false.
   342     newSel := self pasteSpecifications:spec keepLayout:false.
   617 
   343 
   618 
   344     oldSel isNil ifTrue:[self select:newSel]
       
   345                 ifFalse:[self select:oldSel]
   619 ! !
   346 ! !
   620 
   347 
   621 !UIPainterView methodsFor:'generating output'!
   348 !UIPainterView methodsFor:'generating output'!
   622 
   349 
   623 generateActionMethodFor:aspect spec:protoSpec inClass:targetClass
   350 generateActionMethodFor:aspect spec:protoSpec inClass:targetClass
   667         self warn:'set the class first'.
   394         self warn:'set the class first'.
   668         ^ code
   395         ^ code
   669     ].
   396     ].
   670     cls := Smalltalk classNamed:className.
   397     cls := Smalltalk classNamed:className.
   671 
   398 
   672     listHolder propertiesDo:[:aProp |
   399     claus propertiesDo:[:aProp |
   673         |modelSelector menuSelector protoSpec thisCode|
   400         |modelSelector menuSelector protoSpec thisCode|
   674 
   401 
   675         protoSpec := aProp spec.
   402         protoSpec := aProp spec.
   676 
   403 
   677         (modelSelector := aProp model) notNil ifTrue:[
   404         (modelSelector := aProp model) notNil ifTrue:[
   797     "Modified: 24.6.1997 / 19:12:44 / cg"
   524     "Modified: 24.6.1997 / 19:12:44 / cg"
   798 ! !
   525 ! !
   799 
   526 
   800 !UIPainterView methodsFor:'initialization'!
   527 !UIPainterView methodsFor:'initialization'!
   801 
   528 
   802 destroy
       
   803     "remove dependencies
       
   804     "
       
   805     listHolder notNil ifTrue:[
       
   806         listHolder removeDependent:self.
       
   807     ].
       
   808     super destroy.
       
   809 !
       
   810 
       
   811 initialize
   529 initialize
   812     "setup attributes
   530     "setup attributes
   813     "
   531     "
   814     super initialize.
   532     super initialize.
   815 
   533 
   816     superclassName := 'ApplicationModel'.
   534     superclassName := 'ApplicationModel'.
   817     className      := 'NewApplication'.
   535     className      := 'NewApplication'.
   818     methodName     := 'windowSpec'.
   536     methodName     := 'windowSpec'.
   819     categoryName   := 'Applications'.
   537     categoryName   := 'Applications'.
   820     listHolder     := ListHolder for:self.
       
   821     HandCursor     := Cursor leftHand.
   538     HandCursor     := Cursor leftHand.
   822 
   539 
   823 !
   540 !
   824 
   541 
   825 setupFromSpec:specOrSpecArray
   542 setupFromSpec:specOrSpecArray
   826     |spec builder|
   543     |spec builder|
   827 
   544 
   828     listHolder disableNotificationsWhileEvaluating:[
   545     claus cvsSetupListDo:[
   829         self removeAll.
   546         self removeAll.
   830         spec    := UISpecification from:specOrSpecArray.
   547         spec    := UISpecification from:specOrSpecArray.
   831         builder := UIBuilder new.
   548         builder := UIBuilder new.
   832         spec window setupView:self topView for:builder.
   549         spec window setupView:self topView for:builder.
   833         self addSpec:(spec component) builder:builder in:self.
   550         self addSpec:(spec component) builder:builder in:self.
   834         self realizeAllSubViews.
   551         self realizeAllSubViews.
   835         inputView raise.
   552         inputView raise.
   836     ]
   553     ]
       
   554 !
       
   555 
       
   556 treeView:aTreeView
       
   557     claus := aTreeView
   837 ! !
   558 ! !
   838 
   559 
   839 !UIPainterView methodsFor:'menus'!
   560 !UIPainterView methodsFor:'menus'!
   840 
   561 
   841 showMiddleButtonMenu
   562 showMiddleButtonMenu
   842     "show the middle button menu; this returns nil
   563     "show the middle button menu; this returns nil
   843     "
   564     "
   844     |menu canPaste|
   565     |menu|
   845 
   566 
   846     self enabled ifFalse:[
   567     self enabled ifTrue:[
   847         ^ nil
   568         menu := MenuPanel fromSpec:(UIPainter menuCanvas) receiver:self.
   848     ].
   569 
   849     menu := MenuPanel fromSpec:(self class menu) receiver:self.
   570         self hasSelection ifFalse:[
   850 
   571             menu disableAll
   851     canPaste := self canPaste:(self getSelection).
   572         ].
   852 
   573         menu enabledAt:#paste put:(self canPaste:(self getSelection)).
   853     self hasSelection ifTrue:[
   574         menu enabledAt:#undo  put:(undoHistory isEmpty not).
   854         canPaste := (canPaste and:[self canPasteInto:(self selection)])
   575         menu startUp.
   855     ] ifFalse:[
   576     ].
   856         menu disableAll
       
   857     ].
       
   858     menu enabledAt:#paste put:canPaste.
       
   859     menu enabledAt:#undo  put:(undoHistory isEmpty not).
       
   860     menu startUp.
       
   861   ^ nil
   577   ^ nil
   862 
   578 
   863 
   579 
   864 
   580 
   865 ! !
   581 ! !
   868 
   584 
   869 remove:anObject
   585 remove:anObject
   870     "remove anObject from the contents do redraw
   586     "remove anObject from the contents do redraw
   871     "
   587     "
   872     anObject notNil ifTrue:[
   588     anObject notNil ifTrue:[
   873         listHolder remove:anObject
   589         claus removeView:anObject.
   874     ]
   590     ]
   875 !
   591 !
   876 
   592 
   877 removeAll
   593 removeAll
   878     "remove all objects and properties
   594     "remove all objects and properties
   879     "
   595     "
   880     listHolder disableNotificationsWhileEvaluating:[
   596     claus cvsEventsDisabledDo:[
   881         self select:nil.
   597         self  select:nil.
   882         listHolder removeAll.
   598         claus removeAll.
   883         self removeUndoHistory.
   599         self  removeUndoHistory.
   884     ]
   600     ]
   885 ! !
   601 ! !
   886 
   602 
   887 !UIPainterView methodsFor:'searching'!
   603 !UIPainterView methodsFor:'searching'!
   888 
   604 
   934 
   650 
   935 propertyOfIdentifier:anId
   651 propertyOfIdentifier:anId
   936     "returns property assigned to unique identifier
   652     "returns property assigned to unique identifier
   937     "
   653     "
   938     anId notNil ifTrue:[
   654     anId notNil ifTrue:[
   939         ^ listHolder detectProperty:[:p| p identifier == anId ]
   655         ^ claus propertyDetect:[:p| p identifier == anId ]
   940     ].
   656     ].
   941     ^ nil
   657     ^ nil
   942 !
   658 !
   943 
   659 
   944 propertyOfName:aString
   660 propertyOfName:aString
   946     "
   662     "
   947     |name|
   663     |name|
   948 
   664 
   949     aString isNil ifFalse:[
   665     aString isNil ifFalse:[
   950         name := aString string withoutSeparators.
   666         name := aString string withoutSeparators.
   951 
   667       ^ claus propertyDetect:[:p| p name = name ].
   952         name = 'self' ifFalse:[
       
   953             ^ listHolder detectProperty:[:p| p name = name ].
       
   954         ]
       
   955     ].
   668     ].
   956     ^ nil
   669     ^ nil
   957 !
   670 !
   958 
   671 
   959 propertyOfView:aView
   672 propertyOfView:aView
   960     "returns property assigned to view
   673     "returns property assigned to view
   961     "
   674     "
   962     (aView isNil or:[aView == self]) ifFalse:[
   675     (aView isNil or:[aView == self]) ifFalse:[
   963         ^ listHolder detectProperty:[:p| p view == aView ]
   676         ^ claus propertyDetect:[:p| p view == aView ]
   964     ].
   677     ].
   965     ^ nil
   678     ^ nil
   966 !
   679 !
   967 
   680 
   968 uniqueNameFor:aSpecOrString
   681 uniqueNameFor:aSpecOrString
   980     ].
   693     ].
   981     name at:1 put:(name at:1) asLowercase.
   694     name at:1 put:(name at:1) asLowercase.
   982     size  := name size + 1.
   695     size  := name size + 1.
   983     next  := 0.
   696     next  := 0.
   984 
   697 
   985     listHolder propertiesDo:[:p|
   698     claus propertiesDo:[:p|
   986         |n|
   699         |n|
   987         n := p name.
   700         n := p name.
   988 
   701 
   989         (n size >= size and:[n startsWith:name]) ifTrue:[
   702         (n size >= size and:[n startsWith:name]) ifTrue:[
   990             next := next max:(p extractNumberStartingAt:size)
   703             next := next max:(p extractNumberStartingAt:size)
  1006             prop name:(self uniqueNameFor:(prop spec)).
   719             prop name:(self uniqueNameFor:(prop spec)).
  1007         ].
   720         ].
  1008         ^ prop name
   721         ^ prop name
  1009     ].
   722     ].
  1010     ^ 'self'
   723     ^ 'self'
       
   724 
       
   725 ! !
       
   726 
       
   727 !UIPainterView methodsFor:'selection basics'!
       
   728 
       
   729 addToSelection:anObject
       
   730     "add an object to the selection
       
   731     "
       
   732     (self enabled and:[(self isSelected:anObject) not]) ifTrue:[
       
   733         selection isCollection ifFalse:[
       
   734             selection isNil ifTrue:[
       
   735                 selection := anObject
       
   736             ] ifFalse:[
       
   737                 selection := OrderedCollection with:selection with:anObject
       
   738             ]
       
   739         ] ifTrue:[
       
   740             selection add:anObject
       
   741         ].
       
   742         self showSelected:anObject.
       
   743         claus cvsSelectionAdd:anObject.
       
   744     ]
       
   745 
       
   746 
       
   747 !
       
   748 
       
   749 removeFromSelection:anObject
       
   750     "remove an object from the selection
       
   751     "
       
   752     (self isSelected:anObject) ifTrue:[
       
   753         self showUnselected:anObject.
       
   754 
       
   755         selection size > 1 ifTrue:[
       
   756             selection remove:anObject ifAbsent:nil.
       
   757             self showSelection.
       
   758         ] ifFalse:[
       
   759             selection := nil
       
   760         ].
       
   761         claus cvsSelectionRemove:anObject.
       
   762     ]
       
   763 
       
   764 !
       
   765 
       
   766 select:something
       
   767     "change selection to something
       
   768     "
       
   769     (self enabled and:[something ~= self selection]) ifTrue:[
       
   770         self setSelection:something withRedraw:true.
       
   771         claus cvsSelection:something
       
   772     ]
       
   773 
       
   774 !
       
   775 
       
   776 updateSelectionFromModel:aSel
       
   777     "update selection from a new selection
       
   778     "
       
   779     |sel|
       
   780 
       
   781     selectionHiddenLevel == 0 ifTrue:[
       
   782         self selectionDo:[:el| (aSel includes:el) ifFalse:[self showUnselected:el] ]
       
   783     ].
       
   784 
       
   785     (aSel indexOf:self) ~~ 0 ifTrue:[
       
   786         aSel size > 1 ifTrue:[sel := aSel copyWithout:self]
       
   787     ] ifFalse:[
       
   788         aSel size ~~ 0 ifTrue:[sel := aSel]
       
   789     ].
       
   790 
       
   791     self setSelection:sel withRedraw:false.
       
   792     self showSelection
       
   793 
  1011 
   794 
  1012 ! !
   795 ! !
  1013 
   796 
  1014 !UIPainterView methodsFor:'specification'!
   797 !UIPainterView methodsFor:'specification'!
  1015 
   798 
  1035         n := s name.
   818         n := s name.
  1036 
   819 
  1037         (n isNil or:[(self propertyOfName:n) notNil]) ifTrue:[
   820         (n isNil or:[(self propertyOfName:n) notNil]) ifTrue:[
  1038             s name:(self uniqueNameFor:s)
   821             s name:(self uniqueNameFor:s)
  1039         ].
   822         ].
  1040         listHolder add:p
   823         claus addProperty:p.
  1041     ].
   824     ].
  1042 
   825 
  1043     ^ aSpecification buildViewWithLayoutFor:aBuilder in:aFrame.
   826     ^ aSpecification buildViewWithLayoutFor:aBuilder in:aFrame.
  1044 
   827 
  1045     "Modified: 4.7.1997 / 23:48:55 / cg"
   828     "Modified: 4.7.1997 / 23:48:55 / cg"
  1133                 ] ifFalse:[
   916                 ] ifFalse:[
  1134                     aSpec setAttributesIn:aView with:builder.
   917                     aSpec setAttributesIn:aView with:builder.
  1135                     self elementChangedSize:aView.
   918                     self elementChangedSize:aView.
  1136                 ].
   919                 ].
  1137                 props spec:(aSpec copy).
   920                 props spec:(aSpec copy).
  1138                 listHolder propertyChanged:props.
   921                 claus propertyChanged:props.
  1139             ]
   922             ]
  1140         ]
   923         ]
  1141     ]
   924     ]
  1142 
   925 
  1143     "Modified: 4.7.1997 / 23:49:44 / cg"
   926     "Modified: 4.7.1997 / 23:49:44 / cg"
  1246     "
  1029     "
  1247     |view|
  1030     |view|
  1248 
  1031 
  1249     (view := self findViewWithId:(args at:1)) notNil ifTrue:[
  1032     (view := self findViewWithId:(args at:1)) notNil ifTrue:[
  1250         view perform:(args at:2) with:(args at:3).
  1033         view perform:(args at:2) with:(args at:3).
  1251         self changed:#layout.
  1034         self layoutChanged.
  1252     ]
  1035     ]
  1253 !
  1036 !
  1254 
  1037 
  1255 undoRemove:args
  1038 undoRemove:args
  1256     "undo method when removing an object; see 'createUndoRemove:'
  1039     "undo method when removing an object; see 'createUndoRemove:'
  1295             view become:v
  1078             view become:v
  1296         ] ifFalse:[
  1079         ] ifFalse:[
  1297             spec setAttributesIn:view with:builder.
  1080             spec setAttributesIn:view with:builder.
  1298             self elementChangedSize:view.
  1081             self elementChangedSize:view.
  1299         ].
  1082         ].
  1300         listHolder propertyChanged:props.
  1083         claus propertyChanged:props.
  1301     ]
  1084     ]
  1302 
       
  1303     "Modified: 4.7.1997 / 23:49:39 / cg"
       
  1304 ! !
       
  1305 
       
  1306 !UIPainterView methodsFor:'user actions - arrange'!
       
  1307 
       
  1308 lowerSelection
       
  1309     "lower all objects in the selection
       
  1310     "
       
  1311     self hasSelection ifTrue:[
       
  1312         self selectionDo:[:aView|
       
  1313             aView lower.
       
  1314             aView superView changeSequenceOrderFor:aView to:1.
       
  1315         ].
       
  1316         listHolder recompute.
       
  1317     ]
       
  1318 
       
  1319 
       
  1320 !
       
  1321 
       
  1322 raiseSelection
       
  1323     "raise all objects in the selection
       
  1324     "
       
  1325     self hasSelection ifTrue:[
       
  1326         self selectionDo:[:aView||sv|
       
  1327             aView raise.
       
  1328             sv := aView superView.
       
  1329             sv changeSequenceOrderFor:aView to:(sv subViews size)
       
  1330         ].
       
  1331         inputView raise.
       
  1332         listHolder recompute.
       
  1333     ].
       
  1334 
       
  1335 
       
  1336 ! !
       
  1337 
       
  1338 !UIPainterView::ListHolder class methodsFor:'instance creation'!
       
  1339 
       
  1340 for:aPainter
       
  1341     ^ self new for:aPainter
       
  1342 ! !
       
  1343 
       
  1344 !UIPainterView::ListHolder methodsFor:'accessing'!
       
  1345 
       
  1346 painter
       
  1347     "returns painter
       
  1348     "
       
  1349     ^ painter
       
  1350 !
       
  1351 
       
  1352 propertyAt:anIndex
       
  1353     "returns property at an index
       
  1354     "
       
  1355     ^ propertyList at:anIndex
       
  1356 ! !
       
  1357 
       
  1358 !UIPainterView::ListHolder methodsFor:'adding & removing'!
       
  1359 
       
  1360 add:aProperty
       
  1361     "add property and update list
       
  1362     "
       
  1363     |idx list name last|
       
  1364 
       
  1365     list := self list.
       
  1366     idx  := self findParentProperty:aProperty.
       
  1367     name := aProperty name.
       
  1368 
       
  1369     idx == 0 ifTrue:[
       
  1370         last := list size
       
  1371     ] ifFalse:[
       
  1372         last := self lastInGroupStartingAt:idx.
       
  1373         name := (String new:(4+((list at:idx) leftIndent))), name.
       
  1374     ].
       
  1375     propertyList add:aProperty afterIndex:last.
       
  1376     list         add:name      afterIndex:last.
       
  1377     self changed:#size
       
  1378 
       
  1379 
       
  1380 !
       
  1381 
       
  1382 remove:aView
       
  1383     "remove all view relevant resources
       
  1384     "
       
  1385     |start|
       
  1386 
       
  1387     aView notNil ifTrue:[
       
  1388         start := self findProperty:[:p| p view == aView ].
       
  1389 
       
  1390         start ~~ 0 ifTrue:[
       
  1391             self basicRemove:start.
       
  1392             self changed:#size.
       
  1393         ]
       
  1394     ]
       
  1395 !
       
  1396 
       
  1397 removeAll
       
  1398     masterElement := nil.
       
  1399     self selection:#().
       
  1400 
       
  1401     [propertyList notEmpty] whileTrue:[
       
  1402         self basicRemove:1
       
  1403     ].
       
  1404     self changed:#size.
       
  1405 
       
  1406 ! !
       
  1407 
       
  1408 !UIPainterView::ListHolder methodsFor:'change & update'!
       
  1409 
       
  1410 changed:aParameter
       
  1411     "notify all dependents that the receiver has changed somehow.
       
  1412      Each dependent gets a '#update:'-message with aParameter
       
  1413      as argument. In case of disabled no notifications are raised
       
  1414     "
       
  1415     disabledChanged ifFalse:[
       
  1416         super changed:aParameter
       
  1417     ]
       
  1418 !
       
  1419 
       
  1420 disableNotificationsWhileEvaluating:aBlock
       
  1421     "perform block without notification; after evaluation of block,
       
  1422      a #size changed notification is raised
       
  1423     "
       
  1424     |oldState|
       
  1425 
       
  1426     oldState := disabledChanged.
       
  1427     disabledChanged := true.
       
  1428     aBlock value.
       
  1429     disabledChanged := oldState.
       
  1430     self changed:#size.
       
  1431 !
       
  1432 
       
  1433 propertyChanged:aProperty
       
  1434     "property list changed; update list names
       
  1435     "
       
  1436     |list idx oldName newName wspName view indent mid|
       
  1437 
       
  1438     view := aProperty view.
       
  1439     idx  := self findProperty:[:p| p view == view ].
       
  1440 
       
  1441     idx == 0 ifTrue:[
       
  1442         ^ self error
       
  1443     ].
       
  1444 
       
  1445     list    := self list.
       
  1446     oldName := list at:idx.
       
  1447     wspName := oldName string withoutSeparators.
       
  1448     newName := aProperty name.
       
  1449 
       
  1450     wspName = newName ifFalse:[
       
  1451         mid := self masterElement.
       
  1452         list at:idx put:((String new:(oldName leftIndent)), newName).
       
  1453 
       
  1454         idx == mid ifTrue:[
       
  1455             masterElement := nil.
       
  1456             self masterElement:idx
       
  1457         ].
       
  1458     ].
       
  1459     self changed:#property
       
  1460 
       
  1461 ! !
       
  1462 
       
  1463 !UIPainterView::ListHolder methodsFor:'enumerating'!
       
  1464 
       
  1465 propertiesDo:aBlock
       
  1466     "evaluate a block for each property
       
  1467     "
       
  1468     propertyList do:aBlock
       
  1469 ! !
       
  1470 
       
  1471 !UIPainterView::ListHolder methodsFor:'initialization'!
       
  1472 
       
  1473 for:aPainter
       
  1474     "initialize for a painter
       
  1475     "
       
  1476     painter := aPainter.
       
  1477     disabledChanged := false.
       
  1478     self list:(OrderedCollection new).
       
  1479     propertyList := OrderedCollection new.
       
  1480     self selection:#().
       
  1481     self addDependent:painter.
       
  1482 
       
  1483 ! !
       
  1484 
       
  1485 !UIPainterView::ListHolder methodsFor:'private'!
       
  1486 
       
  1487 basicRemove:start
       
  1488     "remove all resources assigned to a group starting at start;
       
  1489      no notifications are raised
       
  1490     "
       
  1491     |end view superView|
       
  1492 
       
  1493     end  := self lastInGroupStartingAt:start.
       
  1494     view := (propertyList at:start) view.
       
  1495 
       
  1496     view notNil ifTrue:[
       
  1497         superView := view superView.
       
  1498         view destroy.
       
  1499         superView sizeChanged:nil.
       
  1500     ].
       
  1501 
       
  1502     propertyList removeFromIndex:start toIndex:end.
       
  1503     self list    removeFromIndex:start toIndex:end.
       
  1504 !
       
  1505 
       
  1506 masterElement
       
  1507     "returns index of master
       
  1508     "
       
  1509     ^ self indexOfName:masterElement.
       
  1510 !
       
  1511 
       
  1512 masterElement:newIndex
       
  1513     "change master of selection
       
  1514     "
       
  1515     |name list oldIdx|
       
  1516 
       
  1517     (oldIdx := self masterElement) ~~ newIndex ifTrue:[
       
  1518         list := self list.
       
  1519         
       
  1520         oldIdx ~~ 0 ifTrue:[
       
  1521             list at:oldIdx put:masterElement
       
  1522         ].
       
  1523         newIndex ~~ 0 ifTrue:[
       
  1524             masterElement := list at:newIndex.
       
  1525             name := Text string:masterElement.
       
  1526             name emphasizeFrom:(1+(name leftIndent)) with:#(#bold #underline).
       
  1527             list at:newIndex put:name.
       
  1528         ] ifFalse:[
       
  1529             masterElement := nil
       
  1530         ].
       
  1531         self changed:#list.
       
  1532     ]
       
  1533 ! !
       
  1534 
       
  1535 !UIPainterView::ListHolder methodsFor:'recomputing'!
       
  1536 
       
  1537 recompute
       
  1538     |list prop size osel|
       
  1539 
       
  1540     osel := self selection copy.
       
  1541     size := self list size.
       
  1542     list := OrderedCollection new:size.
       
  1543     prop := OrderedCollection new:size.
       
  1544 
       
  1545     painter allSubViewsDo:[:v|
       
  1546         size := self indexOfView:v.
       
  1547 
       
  1548         size ~~ 0 ifTrue:[
       
  1549             list add:(self list at:size).
       
  1550             prop add:(propertyList at:size)
       
  1551         ]
       
  1552     ].
       
  1553     propertyList := prop.
       
  1554     self list:list.
       
  1555     self selection:osel.
       
  1556 ! !
       
  1557 
       
  1558 !UIPainterView::ListHolder methodsFor:'searching'!
       
  1559 
       
  1560 detectProperty:aBlock
       
  1561     "find the property, for which evaluation of the argument, aBlock
       
  1562      returns true; return the property or nil if none detected
       
  1563     "
       
  1564     |idx|
       
  1565 
       
  1566     idx := self findProperty:aBlock.
       
  1567     idx ~~ 0 ifTrue:[ ^ propertyList at:idx ].
       
  1568   ^ nil
       
  1569 !
       
  1570 
       
  1571 findParentProperty:aChildProp
       
  1572     "returns index of parent or 0
       
  1573     "
       
  1574     |view index|
       
  1575 
       
  1576     view := aChildProp view.
       
  1577 
       
  1578     view notNil ifTrue:[
       
  1579         [ (view := view superView) notNil ] whileTrue:[
       
  1580             index := self findProperty:[:aProp| aProp view == view ].
       
  1581             index ~~ 0 ifTrue:[
       
  1582                 ^ index
       
  1583             ]
       
  1584         ]
       
  1585     ].
       
  1586     ^ 0
       
  1587 
       
  1588 
       
  1589 !
       
  1590 
       
  1591 findProperty:aBlock
       
  1592     "find the first property, for which evaluation of the argument, aBlock
       
  1593      returns true; return its index or 0 if none detected
       
  1594     "
       
  1595     ^ propertyList findFirst:aBlock
       
  1596 !
       
  1597 
       
  1598 indexOfName:aString
       
  1599     "returns index assigned to a string or 0
       
  1600     "
       
  1601     |name list size|
       
  1602 
       
  1603     aString notNil ifTrue:[
       
  1604         name := aString string withoutSeparators.
       
  1605         size := name size.
       
  1606         list := self list.
       
  1607 
       
  1608         list keysAndValuesDo:[:anIndex :aName|
       
  1609             |el|
       
  1610 
       
  1611             el := aName string.
       
  1612             (el endsWith:name) ifTrue:[
       
  1613                 (el size - el leftIndent) == name size ifTrue:[
       
  1614                     ^ anIndex
       
  1615                 ]
       
  1616             ]
       
  1617         ]
       
  1618     ].
       
  1619     ^ 0
       
  1620 
       
  1621 !
       
  1622 
       
  1623 indexOfView:aView
       
  1624     "returns index assigned to a view or 0
       
  1625     "
       
  1626     aView notNil ifTrue:[
       
  1627         ^ propertyList findFirst:[:p| p view == aView ]
       
  1628     ].
       
  1629     ^ 0
       
  1630 
       
  1631 !
       
  1632 
       
  1633 lastInGroupStartingAt:start
       
  1634     "returns last index of a group
       
  1635     "
       
  1636     |end list idt|
       
  1637 
       
  1638     list := self list.
       
  1639 
       
  1640     start < list size ifTrue:[
       
  1641         idt := (list at:start) leftIndent.
       
  1642         end := list findFirst:[:el|(el leftIndent) <= idt] startingAt:(start+1).
       
  1643         end ~~ 0 ifTrue:[
       
  1644             ^ end - 1
       
  1645         ]
       
  1646     ].
       
  1647     ^ list size
       
  1648 ! !
       
  1649 
       
  1650 !UIPainterView::ListHolder methodsFor:'selection'!
       
  1651 
       
  1652 selectGroup
       
  1653     "select all elements assigned to master
       
  1654     "
       
  1655     |start end sel size|
       
  1656 
       
  1657     painter enabled ifTrue:[
       
  1658         (start := self masterElement) ~~ 0 ifTrue:[
       
  1659             end  := self lastInGroupStartingAt:start.
       
  1660             size := end - start + 1.
       
  1661             sel  := Array new:size.
       
  1662 
       
  1663             1 to:size do:[:i|
       
  1664                 sel at:i put:start.
       
  1665                 start := start + 1
       
  1666             ].
       
  1667             self selectionIndex:sel.
       
  1668         ] ifFalse:[
       
  1669             (self selectionIndex) size == 0 ifFalse:[
       
  1670                 self selectionIndex:#()
       
  1671             ].
       
  1672         ]
       
  1673     ]
       
  1674 !
       
  1675 
       
  1676 selectedProperty
       
  1677     "returns current selected instance; in case of multiple selection
       
  1678      or no selection nil is returned
       
  1679     "
       
  1680     |selection|
       
  1681     selection := self selectionIndex.
       
  1682 
       
  1683     selection size == 1 ifTrue:[
       
  1684         propertyList size ~~ 0 ifTrue:[
       
  1685             ^ propertyList at:(selection first)
       
  1686         ]
       
  1687     ].
       
  1688     ^ nil
       
  1689 !
       
  1690 
       
  1691 selectionIndex:aList
       
  1692     |masterIndex aSel|
       
  1693 
       
  1694     painter enabled ifTrue:[aSel := aList]
       
  1695                    ifFalse:[aSel := nil].
       
  1696 
       
  1697     aSel size ~~ 0 ifTrue:[masterIndex := aSel at:1]
       
  1698                   ifFalse:[masterIndex := 0].
       
  1699 
       
  1700     self masterElement:masterIndex.
       
  1701     super selectionIndex:aSel
       
  1702 ! !
  1085 ! !
  1703 
  1086 
  1704 !UIPainterView::ViewProperty class methodsFor:'instance creation'!
  1087 !UIPainterView::ViewProperty class methodsFor:'instance creation'!
  1705 
  1088 
  1706 new
  1089 new