5007 code readStream fileIn. |
5007 code readStream fileIn. |
5008 ]. |
5008 ]. |
5009 UserPreferences current systemBrowserClass openInClass:cls selector:aspect |
5009 UserPreferences current systemBrowserClass openInClass:cls selector:aspect |
5010 ! |
5010 ! |
5011 |
5011 |
5012 doBrowseAspectClass:aspectSelector |
|
5013 "browse the class as entered in the field (can be called by buttons in a subspec)" |
|
5014 |
|
5015 self doBrowseAspectClassAndSelector:{ aspectSelector . nil } |
|
5016 ! |
|
5017 |
|
5018 doBrowseAspectClassAndSelector:classAndSelectorPair |
|
5019 "browse the class as entered in the field (can be called by buttons in a subspec)" |
|
5020 |
|
5021 |spec classAspect selectorAspect className selector class | |
|
5022 |
|
5023 classAspect := classAndSelectorPair first. |
|
5024 selectorAspect := classAndSelectorPair second. |
|
5025 |
|
5026 "/ wrong: the code below uses the spec's aspect values; |
|
5027 "/ but the spec is only valid after accepting. |
|
5028 |
|
5029 "/ spec := painter specForSelection. |
|
5030 "/ spec isNil ifTrue:[^ self]. |
|
5031 "/ className := spec perform:classAspect. |
|
5032 "/ |
|
5033 "/ selectorAspect notNil ifTrue:[ |
|
5034 "/ selector := spec perform:selectorAspect. |
|
5035 "/ ]. |
|
5036 |
|
5037 "/ we have to take the current value from the widget's value, |
|
5038 "/ which is in the listOfAspects!! |
|
5039 className := (specTool aspectFor:classAspect) value. |
|
5040 selector := (specTool aspectFor:selectorAspect) value. |
|
5041 |
|
5042 (className isEmptyOrNil or:[(selectorAspect notNil and:[selector isEmptyOrNil])]) ifTrue:[ |
|
5043 Dialog information:(resources |
|
5044 string:'Class and/or selector missing (for "%1 / %2")' |
|
5045 with:classAspect with:selectorAspect). |
|
5046 ^ self |
|
5047 ]. |
|
5048 class := Smalltalk classNamed:className. |
|
5049 class isBehavior ifFalse:[ |
|
5050 Dialog information:(resources |
|
5051 string:'"%1" does not refer to a valid class (in "%2")' |
|
5052 with:className with:classAspect). |
|
5053 ^ self |
|
5054 ]. |
|
5055 UserPreferences current systemBrowserClass openInClass:class selector:selector |
|
5056 ! |
|
5057 |
|
5058 doBrowseAspectMethod:aspectSelector |
5012 doBrowseAspectMethod:aspectSelector |
5059 "browse or create the aspect method as entered in the field (button beside input fieled pressed)" |
5013 "browse or create the aspect method as entered in the field (button beside input fieled pressed)" |
5060 |
5014 |
5061 self isModified ifTrue:[ self accept ]. |
5015 self isModified ifTrue:[ self accept ]. |
5062 "/ self acceptOrIgnoreSectionModification. |
5016 "/ self acceptOrIgnoreSectionModification. |
5950 "Created: / 16-01-2008 / 17:49:20 / cg" |
5904 "Created: / 16-01-2008 / 17:49:20 / cg" |
5951 ! ! |
5905 ! ! |
5952 |
5906 |
5953 !UIPainter::TreeView class methodsFor:'documentation'! |
5907 !UIPainter::TreeView class methodsFor:'documentation'! |
5954 |
5908 |
5955 erarchy" |
5909 documentation |
5956 |
5910 " |
5957 treeView doStepOver:-1 |
5911 selection in tree view; only used by the UIPainter |
5958 ! ! |
5912 |
5959 |
5913 [see also:] |
5960 !UIPainter::TreeView methodsFor:'accessing'! |
5914 SelectionInTreeView |
5961 |
5915 SelectionInTree |
5962 ditToolbar |
5916 TreeItem |
5963 self editToolBarVisibleHolder value:false |
|
5964 ! |
|
5965 |
|
5966 BarVisibleHolder value:false |
|
5967 ! |
|
5968 |
|
5969 Spec newSpec| |
|
5970 |
|
5971 (aSpecOrWidgetClass isSubclassOf:UISpecification) ifTrue:[ |
|
5972 newSpecClass := aSpecOrWidgetClass. |
|
5973 ] ifFalse:[ |
|
5974 (aSpecOrWidgetClass isSubclassOf:View) ifTrue:[ |
|
5975 newSpecClass := aSpecOrWidgetClass basicNew specClass. |
|
5976 ] ifFalse:[ |
|
5977 newSpecClass := nil |
|
5978 ]. |
|
5979 ]. |
|
5980 newSpecClass isNil ifTrue:[ |
|
5981 Dialog warn:'Invalid Spec- or View-Class: ' , aSpecOrWidgetClass name. |
|
5982 ^ self. |
|
5983 ]. |
|
5984 |
|
5985 treeView isCanvasSelected ifTrue:[ |
|
5986 ^ self |
|
5987 ]. |
|
5988 oldSpec := self selectedSpec. |
|
5989 newSpec := newSpecClass cloneFrom:oldSpec. |
|
5990 |
|
5991 self painter replaceSelectionBy:newSpec. |
|
5992 |
|
5993 "Modified: / 05-09-2012 / 19:24:40 / cg" |
|
5994 ! |
|
5995 |
|
5996 og warn:'Invalid Spec- or View-Class: ' , aSpecOrWidgetClass name. |
|
5997 ^ self. |
|
5998 ]. |
|
5999 |
|
6000 treeView isCanvasSelected ifTrue:[ |
|
6001 ^ self |
|
6002 ]. |
|
6003 oldSpec := self selectedSpec. |
|
6004 newSpec := newSpecClass cloneFrom:oldSpec. |
|
6005 |
|
6006 self painter replaceSelectionBy:newSpec. |
|
6007 |
|
6008 "Modified: / 05-09-2012 / 19:24:40 / cg" |
|
6009 ! |
|
6010 |
|
6011 TreeItem |
|
6012 UIPainter |
5917 UIPainter |
6013 |
5918 |
6014 [author:] |
5919 [author:] |
6015 Claus Atzkern |
5920 Claus Atzkern |
6016 " |
5921 " |
6017 |
5922 |
6018 |
5923 |
6019 ! |
5924 ! ! |
6020 |
5925 |
6021 ew)" |
5926 !UIPainter::TreeView methodsFor:'accessing'! |
|
5927 |
|
5928 canvas |
|
5929 "returns the canvas (UIPainterView)" |
|
5930 |
|
5931 ^ model root contents view |
|
5932 |
|
5933 |
|
5934 ! |
|
5935 |
|
5936 canvas:aCanvas |
|
5937 "install canvas (UIPainterView)" |
6022 |
5938 |
6023 self canvas:aCanvas specName:nil |
5939 self canvas:aCanvas specName:nil |
6024 ! |
5940 ! |
6025 |
5941 |
6026 props := UIPainterView::ViewProperty new. |
5942 canvas:aCanvas specName:nameOfSpec |
|
5943 "install canvas (UIPainterView)" |
|
5944 |
|
5945 |props| |
|
5946 |
|
5947 props := UIPainterView::ViewProperty new. |
6027 props view:aCanvas. |
5948 props view:aCanvas. |
6028 |
5949 |
6029 model root:(TreeItem |
5950 model root:(TreeItem |
6030 name:(nameOfSpec ? painter defaultNameOfCanvas) asBoldText |
5951 name:(nameOfSpec ? painter defaultNameOfCanvas) asBoldText |
6031 contents:props). |
5952 contents:props). |
6032 |
5953 |
6033 model root expand. |
5954 model root expand. |
6034 self enableChannel:(aCanvas enableChannel). |
5955 self enableChannel:(aCanvas enableChannel). |
6035 ! |
5956 ! |
6036 |
5957 |
6037 model root expand. |
5958 canvasSpec |
6038 self enableChannel:(aCanvas enableChannel). |
|
6039 ! |
|
6040 |
|
6041 pec |
|
6042 "returns spec assigned to canvas" |
5959 "returns spec assigned to canvas" |
6043 |
5960 |
6044 |spec list cls canvas| |
5961 |spec list cls canvas| |
6045 |
5962 |
6046 spec := self windowSpecClass new. |
5963 spec := self windowSpecClass new. |
6077 thenDo:[:aKey|spec exportedAspectsAddKey:aKey type:#action]. |
5994 thenDo:[:aKey|spec exportedAspectsAddKey:aKey type:#action]. |
6078 ]. |
5995 ]. |
6079 ^ spec |
5996 ^ spec |
6080 ! |
5997 ! |
6081 |
5998 |
6082 igned to canvas" |
5999 canvasSpec:aSpec |
6083 |
6000 "update canvas from spec" |
6084 |spec list cls canvas| |
6001 |
6085 |
6002 |spec| |
6086 spec := self windowSpecClass new. |
6003 |
6087 canvas := self canvas. |
6004 self setAttributesFromWindowSpec:aSpec. |
6088 |
6005 spec := aSpec copy. |
6089 spec fromView:(canvas topView) callBack:nil. |
6006 spec menu:nil. |
6090 |
6007 spec flags:nil. |
6091 windowSpec notNil ifTrue:[ |
6008 |
6092 spec copyValuesFromSpec:windowSpec. |
6009 spec setAttributesIn:(self canvas "topView") with:(UIBuilder new isEditing:true). |
6093 ]. |
6010 ! |
6094 |
6011 |
6095 spec exportedAspects isNil ifTrue:[ |
6012 exportedAspects |
6096 ( (cls := canvas className) notNil |
6013 "returns spec assigned to canvas" |
6097 and:[(cls := canvas resolveName:cls) notNil] |
6014 |
6098 ) ifTrue:[ |
6015 windowSpec isNil ifTrue:[^ #()]. |
6099 list := cls perform:#aspectSelectors ifNotUnderstood:nil. |
6016 ^ windowSpec exportedAspects ? #() |
6100 ]. |
6017 |
6101 spec setExportedAspectsFrom:list. |
6018 ! |
6102 windowSpec notNil ifTrue:[ |
6019 |
6103 windowSpec exportedAspects:(spec exportedAspects). |
6020 itemOfView:aView |
6104 ] |
6021 "returns item assigned to view or nil" |
6105 ]. |
6022 |
6106 |
6023 aView notNil ifTrue:[ |
6107 self propertiesDo:[:aProp| |
|
6108 |propsSpec| |
|
6109 |
|
6110 spec exportedAspectsAddKey:(aProp model) type:nil. |
|
6111 propsSpec := aProp spec. |
|
6112 propsSpec aspectSelectors |
|
6113 select:[:a | a isString or:[a isSymbol]] |
|
6114 thenDo:[:aKey|spec exportedAspectsAddKey:aKey type:nil]. |
|
6115 propsSpec actionSelectors |
|
6116 select:[:a | a isString or:[a isSymbol]] |
|
6117 thenDo:[:aKey|spec exportedAspectsAddKey:aKey type:#action]. |
|
6118 ]. |
|
6119 ^ spec |
|
6120 ! |
|
6121 |
|
6122 spec := self windowSpecClass new. |
|
6123 canvas := self canvas. |
|
6124 |
|
6125 spec fromView:(canvas topView) callBack:nil. |
|
6126 |
|
6127 windowSpec notNil ifTrue:[ |
|
6128 spec copyValuesFromSpec:windowSpec. |
|
6129 ]. |
|
6130 |
|
6131 spec exportedAspects isNil ifTrue:[ |
|
6132 ( (cls := canvas className) notNil |
|
6133 and:[(cls := canvas resolveName:cls) notNil] |
|
6134 ) ifTrue:[ |
|
6135 list := cls perform:#aspectSelectors ifNotUnderstood:nil. |
|
6136 ]. |
|
6137 spec setExportedAspectsFrom:list. |
|
6138 windowSpec notNil ifTrue:[ |
|
6139 windowSpec exportedAspects:(spec exportedAspects). |
|
6140 ] |
|
6141 ]. |
|
6142 |
|
6143 self propertiesDo:[:aProp| |
|
6144 |propsSpec| |
|
6145 |
|
6146 spec exportedAspectsAddKey:(aProp model) type:nil. |
|
6147 propsSpec := aProp spec. |
|
6148 propsSpec aspectSelectors |
|
6149 select:[:a | a isString or:[a isSymbol]] |
|
6150 thenDo:[:aKey|spec exportedAspectsAddKey:aKey type:nil]. |
|
6151 propsSpec actionSelectors |
|
6152 select:[:a | a isString or:[a isSymbol]] |
|
6153 thenDo:[:aKey|spec exportedAspectsAddKey:aKey type:#action]. |
|
6154 ]. |
|
6155 ^ spec |
|
6156 ! |
|
6157 |
|
6158 l. |
|
6159 |
|
6160 windowSpec notNil ifTrue:[ |
|
6161 spec copyValuesFromSpec:windowSpec. |
|
6162 ]. |
|
6163 |
|
6164 spec exportedAspects isNil ifTrue:[ |
|
6165 ( (cls := canvas className) notNil |
|
6166 and:[(cls := canvas resolveName:cls) notNil] |
|
6167 ) ifTrue:[ |
|
6168 list := cls perform:#aspectSelectors ifNotUnderstood:nil. |
|
6169 ]. |
|
6170 spec setExportedAspectsFrom:list. |
|
6171 windowSpec notNil ifTrue:[ |
|
6172 windowSpec exportedAspects:(spec exportedAspects). |
|
6173 ] |
|
6174 ]. |
|
6175 |
|
6176 self propertiesDo:[:aProp| |
|
6177 |propsSpec| |
|
6178 |
|
6179 spec exportedAspectsAddKey:(aProp model) type:nil. |
|
6180 propsSpec := aProp spec. |
|
6181 propsSpec aspectSelectors |
|
6182 select:[:a | a isString or:[a isSymbol]] |
|
6183 thenDo:[:aKey|spec exportedAspectsAddKey:aKey type:nil]. |
|
6184 propsSpec actionSelectors |
|
6185 select:[:a | a isString or:[a isSymbol]] |
|
6186 thenDo:[:aKey|spec exportedAspectsAddKey:aKey type:#action]. |
|
6187 ]. |
|
6188 ^ spec |
|
6189 ! ! |
|
6190 |
|
6191 !UIPainter::TreeView methodsFor:'accessing-property'! |
|
6192 |
|
6193 as className) notNil |
|
6194 and:[(cls := canvas resolveName:cls) notNil] |
|
6195 ) ifTrue:[ |
|
6196 list := cls perform:#aspectSelectors ifNotUnderstood:nil. |
|
6197 ]. |
|
6198 spec setExportedAspectsFrom:list. |
|
6199 windowSpec notNil ifTrue:[ |
|
6200 windowSpec exportedAspects:(spec exportedAspects). |
|
6201 ] |
|
6202 ]. |
|
6203 |
|
6204 self propertiesDo:[:aProp| |
|
6205 |propsSpec| |
|
6206 |
|
6207 spec exportedAspectsAddKey:(aProp model) type:nil. |
|
6208 propsSpec := aProp spec. |
|
6209 propsSpec aspectSelectors |
|
6210 select:[:a | a isString or:[a isSymbol]] |
|
6211 thenDo:[:aKey|spec exportedAspectsAddKey:aKey type:nil]. |
|
6212 propsSpec actionSelectors |
|
6213 select:[:a | a isString or:[a isSymbol]] |
|
6214 thenDo:[:aKey|spec exportedAspectsAddKey:aKey type:#action]. |
|
6215 ]. |
|
6216 ^ spec |
|
6217 ! |
|
6218 |
|
6219 stood:nil. |
|
6220 ]. |
|
6221 spec setExportedAspectsFrom:list. |
|
6222 windowSpec notNil ifTrue:[ |
|
6223 windowSpec exportedAspects:(spec exportedAspects). |
|
6224 ] |
|
6225 ]. |
|
6226 |
|
6227 self propertiesDo:[:aProp| |
|
6228 |propsSpec| |
|
6229 |
|
6230 spec exportedAspectsAddKey:(aProp model) type:nil. |
|
6231 propsSpec := aProp spec. |
|
6232 propsSpec aspectSelectors |
|
6233 select:[:a | a isString or:[a isSymbol]] |
|
6234 thenDo:[:aKey|spec exportedAspectsAddKey:aKey type:nil]. |
|
6235 propsSpec actionSelectors |
|
6236 select:[:a | a isString or:[a isSymbol]] |
|
6237 thenDo:[:aKey|spec exportedAspectsAddKey:aKey type:#action]. |
|
6238 ]. |
|
6239 ^ spec |
|
6240 ! |
|
6241 |
|
6242 esDo:[:aProp| |
|
6243 |propsSpec| |
|
6244 |
|
6245 spec exportedAspectsAddKey:(aProp model) type:nil. |
|
6246 propsSpec := aProp spec. |
|
6247 propsSpec aspectSelectors |
|
6248 select:[:a | a isString or:[a isSymbol]] |
|
6249 thenDo:[:aKey|spec exportedAspectsAddKey:aKey type:nil]. |
|
6250 propsSpec actionSelectors |
|
6251 select:[:a | a isString or:[a isSymbol]] |
|
6252 thenDo:[:aKey|spec exportedAspectsAddKey:aKey type:#action]. |
|
6253 ]. |
|
6254 ^ spec |
|
6255 ! ! |
|
6256 |
|
6257 !UIPainter::TreeView methodsFor:'adding & removing'! |
|
6258 |
|
6259 sSymbol]] |
|
6260 thenDo:[:aKey|spec exportedAspectsAddKey:aKey type:#action]. |
|
6261 ]. |
|
6262 ^ spec |
|
6263 ! |
|
6264 |
|
6265 spec |
|
6266 ! |
|
6267 |
|
6268 aView notNil ifTrue:[ |
|
6269 self allItemsDo:[:anItem| |
6024 self allItemsDo:[:anItem| |
6270 (anItem contents view == aView) ifTrue:[^ anItem] |
6025 (anItem contents view == aView) ifTrue:[^ anItem] |
6271 ] |
6026 ] |
6272 ]. |
6027 ]. |
6273 ^ nil |
6028 ^ nil |
6274 |
6029 |
6275 |
6030 |
6276 ! |
6031 ! |
6277 |
6032 |
6278 ass |
6033 lastDrawnMaster |
|
6034 "returns the lastDrawnMaster" |
|
6035 |
|
6036 ^ lastDrawnMaster |
|
6037 |
|
6038 |
|
6039 ! |
|
6040 |
|
6041 painter |
|
6042 ^ painter |
|
6043 ! |
|
6044 |
|
6045 painter:something |
|
6046 painter := something. |
|
6047 ! |
|
6048 |
|
6049 windowSpecClass |
|
6050 "returns the default windowSpecClass (WindowSpec)" |
|
6051 |
|
6052 ^ windowSpecClass ? WindowSpec |
|
6053 ! |
|
6054 |
|
6055 windowSpecClass:aClass |
6279 "set the default windowSpecClass" |
6056 "set the default windowSpecClass" |
6280 |
6057 |
6281 ^ windowSpecClass := aClass |
6058 ^ windowSpecClass := aClass |
6282 ! ! |
6059 ! ! |
6283 |
6060 |
6284 !UIPainter::TreeView methodsFor:'building'! |
6061 !UIPainter::TreeView methodsFor:'accessing-property'! |
6285 |
6062 |
6286 yDetect:aOneArgBlock |
6063 propertiesDo:aOneArgBlock |
|
6064 "evaluates the argument a block on each property" |
|
6065 |
|
6066 self allItemsDo:[:anItem| aOneArgBlock value:(anItem contents)] |
|
6067 |
|
6068 |
|
6069 ! |
|
6070 |
|
6071 propertyDetect:aOneArgBlock |
6287 "evaluates the block on each property" |
6072 "evaluates the block on each property" |
6288 |
6073 |
6289 self allItemsDo:[:anItem| |
6074 self allItemsDo:[:anItem| |
6290 (aOneArgBlock value:(anItem contents)) ifTrue:[^ anItem contents] |
6075 (aOneArgBlock value:(anItem contents)) ifTrue:[^ anItem contents] |
6291 ]. |
6076 ]. |
6292 ^ nil |
6077 ^ nil |
6293 |
6078 |
6294 ! |
6079 ! |
6295 |
6080 |
6296 y beforeIndex:anIndex |
6081 propertySelected |
|
6082 "returns current selected property or nil in case of multi selection |
|
6083 or empty selection " |
|
6084 |
|
6085 |idx| |
|
6086 |
|
6087 selection size == 1 ifTrue:[ |
|
6088 (idx := selection first) ~~ 1 ifTrue:[ "canvas: not yet supported" |
|
6089 ^ (listOfNodes at:idx) contents |
|
6090 ] |
|
6091 ]. |
|
6092 ^ nil |
|
6093 |
|
6094 ! ! |
|
6095 |
|
6096 !UIPainter::TreeView methodsFor:'adding & removing'! |
|
6097 |
|
6098 addProperty:aProperty |
|
6099 "adds a new item" |
|
6100 |
|
6101 ^ self addProperty:aProperty beforeIndex:nil. |
|
6102 ! |
|
6103 |
|
6104 addProperty:aProperty beforeIndex:anIndex |
6297 "adds a new item" |
6105 "adds a new item" |
6298 |
6106 |
6299 |parent treeItem index| |
6107 |parent treeItem index| |
6300 |
6108 |
6301 parent := self detectItemCorespondingToView:(aProperty view superView). |
6109 parent := self detectItemCorespondingToView:(aProperty view superView). |
6395 sel := list collect:[:anItem| self indexOfNode:anItem ]. |
6219 sel := list collect:[:anItem| self indexOfNode:anItem ]. |
6396 ]. |
6220 ]. |
6397 self canvasEventsDisabledDo:[ self selection:sel ]. |
6221 self canvasEventsDisabledDo:[ self selection:sel ]. |
6398 ! |
6222 ! |
6399 |
6223 |
6400 ] |
6224 canvasSelectionAdd:aView |
6401 ]. |
6225 "canvas adds a view to current selection |
6402 sel := list collect:[:anItem| self indexOfNode:anItem ]. |
6226 " |
6403 ]. |
6227 |item index oldSel| |
6404 self canvasEventsDisabledDo:[ self selection:sel ]. |
6228 |
6405 ! ! |
6229 item := self itemOfView:aView. |
6406 |
6230 |
6407 !UIPainter::TreeView methodsFor:'drag & drop'! |
6231 item notNil ifTrue:[ |
6408 |
6232 model doMakeVisible:item. |
6409 election |
6233 |
|
6234 (index := self indexOfNode:item) ~~ 0 ifTrue:[ |
|
6235 oldSel := selection copy. |
|
6236 self addToSelection:index. |
|
6237 self selectionChangedFrom:oldSel |
|
6238 ] |
|
6239 ] |
|
6240 ! |
|
6241 |
|
6242 canvasSelectionRemove:aView |
|
6243 "canvas removes a view from current selection |
|
6244 " |
|
6245 |item index oldSel| |
|
6246 |
|
6247 ( (item := self itemOfView:aView) notNil |
|
6248 and:[(index := self indexOfNode:item) ~~ 0 |
|
6249 and:[self isInSelection:index]] |
|
6250 ) ifTrue:[ |
|
6251 oldSel := selection copy. |
|
6252 self removeFromSelection:index. |
|
6253 self selectionChangedFrom:oldSel. |
|
6254 ]. |
|
6255 ! |
|
6256 |
|
6257 selectedViews |
|
6258 ^ self selection |
6410 collect:[:index | |
6259 collect:[:index | |
6411 |node view| |
6260 |node view| |
6412 |
6261 |
6413 node := listOfNodes at:index. |
6262 node := listOfNodes at:index. |
6414 view := node contents view. |
6263 view := node contents view. |
6415 view |
6264 view |
6416 ] |
6265 ] |
6417 ! |
6266 ! ! |
6418 |
6267 |
6419 view |
6268 !UIPainter::TreeView methodsFor:'change & update'! |
6420 ] |
6269 |
6421 ! |
6270 canvasNameChanged:aName |
6422 |
6271 "called if identification name assigned to window (canvas) changed |
6423 fNodes at:1. |
6272 " |
|
6273 |name node| |
|
6274 |
|
6275 node := listOfNodes at:1. |
6424 |
6276 |
6425 ( aName size ~~ 0 |
6277 ( aName size ~~ 0 |
6426 and:[(name := aName string withoutSeparators) size ~~ 0 |
6278 and:[(name := aName string withoutSeparators) size ~~ 0 |
6427 and:[(self propertyDetect:[:p| p name = name]) isNil |
6279 and:[(self propertyDetect:[:p| p name = name]) isNil |
6428 and:[node name ~= name]]] |
6280 and:[node name ~= name]]] |
6479 self application propertyChanged |
6327 self application propertyChanged |
6480 ] |
6328 ] |
6481 ]. |
6329 ]. |
6482 |
6330 |
6483 |
6331 |
6484 ! |
|
6485 |
|
6486 ame = aProperty name ifFalse:[ |
|
6487 idx := self firstLineShown. |
|
6488 |
|
6489 (end := self lastLineShown) > listOfNodes size ifTrue:[ |
|
6490 end := listOfNodes size |
|
6491 ]. |
|
6492 item changed. |
|
6493 |
|
6494 [idx <= end] whileTrue:[ |
|
6495 (listOfNodes at:idx) == item ifTrue:[ |
|
6496 self redrawLine:idx. "/ is visible; redraw line |
|
6497 end := 0 |
|
6498 ] ifFalse:[ |
|
6499 idx := idx + 1 |
|
6500 ] |
|
6501 ] |
|
6502 ]. |
|
6503 |
|
6504 self selectedNode == item ifTrue:[ "/ inform application |
|
6505 self application propertyChanged |
|
6506 ] |
|
6507 ]. |
|
6508 |
|
6509 |
|
6510 ! |
|
6511 |
|
6512 ]. |
|
6513 item changed. |
|
6514 |
|
6515 [idx <= end] whileTrue:[ |
|
6516 (listOfNodes at:idx) == item ifTrue:[ |
|
6517 self redrawLine:idx. "/ is visible; redraw line |
|
6518 end := 0 |
|
6519 ] ifFalse:[ |
|
6520 idx := idx + 1 |
|
6521 ] |
|
6522 ] |
|
6523 ]. |
|
6524 |
|
6525 self selectedNode == item ifTrue:[ "/ inform application |
|
6526 self application propertyChanged |
|
6527 ] |
|
6528 ]. |
|
6529 |
|
6530 |
|
6531 ! ! |
6332 ! ! |
6532 |
6333 |
6533 !UIPainter::TreeView methodsFor:'enumerating'! |
6334 !UIPainter::TreeView methodsFor:'drag & drop'! |
6534 |
6335 |
6535 end := 0 |
6336 canDrop:aDropContext |
6536 ] ifFalse:[ |
6337 "can drop ? -> delegate to canvas" |
6537 idx := idx + 1 |
6338 |
6538 ] |
6339 ^ self canvas canDrop:aDropContext |
6539 ] |
6340 |
6540 ]. |
6341 "Modified: / 13-10-2006 / 16:08:43 / cg" |
6541 |
6342 ! |
6542 self selectedNode == item ifTrue:[ "/ inform application |
6343 |
6543 self application propertyChanged |
6344 canDrop:aDropContext at:aPoint |
6544 ] |
|
6545 ]. |
|
6546 |
|
6547 |
|
6548 ! ! |
|
6549 |
|
6550 !UIPainter::TreeView methodsFor:'event handling'! |
|
6551 |
|
6552 rm application |
|
6553 self application propertyChanged |
|
6554 ] |
|
6555 ]. |
|
6556 |
|
6557 |
|
6558 ! |
|
6559 |
|
6560 ntext at:aPoint |
|
6561 "can drop ? -> delegate to canvas" |
6345 "can drop ? -> delegate to canvas" |
6562 |
6346 |
6563 ^ self canvas canDrop:aDropContext at:aPoint |
6347 ^ self canvas canDrop:aDropContext at:aPoint |
6564 |
6348 |
6565 "Created: / 13-10-2006 / 12:35:53 / cg" |
6349 "Created: / 13-10-2006 / 12:35:53 / cg" |
6566 "Modified: / 13-10-2006 / 16:08:46 / cg" |
6350 "Modified: / 13-10-2006 / 16:08:46 / cg" |
6567 ! |
6351 ! |
6568 |
6352 |
6569 / cg" |
6353 canDropObjects:aCollectionOfDropObjects |
6570 "Modified: / 13-10-2006 / 16:08:46 / cg" |
6354 "can drop ? -> delegate to canvas" |
|
6355 |
|
6356 ^ self canvas canDropObjects:aCollectionOfDropObjects |
|
6357 |
|
6358 "Created: / 13-10-2006 / 16:08:31 / cg" |
|
6359 ! |
|
6360 |
|
6361 canDropObjects:aCollectionOfDropObjects at:aPoint |
|
6362 "can drop ? -> delegate to canvas" |
|
6363 |
|
6364 ^ self canvas canDropObjects:aCollectionOfDropObjects at:aPoint |
|
6365 |
|
6366 "Created: / 13-10-2006 / 16:08:35 / cg" |
|
6367 ! |
|
6368 |
|
6369 drop:aDropContext |
|
6370 "drop objects -> delegate to canvas" |
|
6371 |
|
6372 self canvas drop:aDropContext |
|
6373 |
|
6374 "Created: / 13-10-2006 / 12:35:59 / cg" |
|
6375 "Modified: / 13-10-2006 / 16:09:04 / cg" |
|
6376 ! |
|
6377 |
|
6378 drop:aDropContext at:aPoint |
|
6379 "drop objects -> delegate to canvas" |
|
6380 |
|
6381 self canvas drop:aDropContext at:nil |
|
6382 |
|
6383 "Modified: / 13-10-2006 / 16:09:07 / cg" |
|
6384 ! |
|
6385 |
|
6386 dropObjects:aCollectionOfDropObjects |
|
6387 "drop objects -> delegate to canvas" |
|
6388 |
|
6389 self canvas dropObjects:aCollectionOfDropObjects |
|
6390 |
|
6391 "Created: / 13-10-2006 / 16:08:51 / cg" |
|
6392 ! |
|
6393 |
|
6394 dropObjects:aCollectionOfDropObjects at:aPoint |
|
6395 "drop objects -> delegate to canvas" |
|
6396 |
|
6397 self canvas dropObjects:aCollectionOfDropObjects at:nil |
|
6398 |
|
6399 "Created: / 13-10-2006 / 16:08:56 / cg" |
6571 ! ! |
6400 ! ! |
6572 |
6401 |
|
6402 !UIPainter::TreeView methodsFor:'enumerating'! |
|
6403 |
|
6404 allItemsDo:aOneArgBlock |
|
6405 "evaluates the argument a block on each item other than the canvas" |
|
6406 |
|
6407 model root allChildrenDo:aOneArgBlock |
|
6408 |
|
6409 |
|
6410 ! ! |
|
6411 |
|
6412 !UIPainter::TreeView methodsFor:'event handling'! |
|
6413 |
|
6414 canvasEventsDisabledDo:aBlock |
|
6415 "evaluates the block without raising selection changed notifications to canvas" |
|
6416 |
|
6417 |restoreCanvasEvents| |
|
6418 |
|
6419 restoreCanvasEvents := canvasEventsDisabled. |
|
6420 canvasEventsDisabled := true. |
|
6421 aBlock value. |
|
6422 canvasEventsDisabled := restoreCanvasEvents. |
|
6423 ! |
|
6424 |
|
6425 doubleClicked |
|
6426 "disables collapsing of the root item" |
|
6427 |
|
6428 self selectedNode == model root ifFalse:[ |
|
6429 super doubleClicked |
|
6430 ] |
|
6431 |
|
6432 |
|
6433 ! |
|
6434 |
|
6435 redrawLabelAt:x y:yTop index:anIndex |
|
6436 "draws a tiny rectangle for indicating the master node (first selected node)" |
|
6437 |
|
6438 |dX| |
|
6439 |
|
6440 super redrawLabelAt:x y:yTop index:anIndex. |
|
6441 |
|
6442 ((selection size > 1) and: [selection first == anIndex]) ifTrue:[ |
|
6443 dX := textInset - 1. |
|
6444 self paint:(Color red). "/ self application painter handleMasterColor. |
|
6445 self fillRectangleX:(x - dX - 2) |
|
6446 y:yTop + ((fontHeight - dX) // 2) |
|
6447 width:dX |
|
6448 height:dX |
|
6449 ] |
|
6450 ! ! |
|
6451 |
6573 !UIPainter::TreeView methodsFor:'initialization'! |
6452 !UIPainter::TreeView methodsFor:'initialization'! |
6574 |
6453 |
6575 cg" |
6454 iconForNode:aNode |
6576 "Modified: / 13-10-2006 / 16:09:04 / cg" |
6455 |spec| |
6577 ! |
6456 |
6578 |
6457 spec := aNode contents spec. |
6579 "Modified: / 13-10-2006 / 16:09:07 / cg" |
6458 spec isNil ifTrue: [ |
6580 ! |
6459 ^ WindowSpec icon |
6581 |
6460 ] ifFalse:[ |
6582 : / 13-10-2006 / 16:08:56 / cg" |
6461 ^ spec icon |
6583 ! ! |
|
6584 |
|
6585 !UIPainter::TreeView methodsFor:'private'! |
|
6586 |
|
6587 ock |
|
6588 |
|
6589 |
|
6590 ! |
|
6591 |
|
6592 Clicked |
|
6593 ] |
6462 ] |
6594 |
6463 ! |
6595 |
6464 |
6596 ! ! |
6465 initialize |
6597 |
6466 "initialize the tree view; multiple select and tree item actions" |
6598 !UIPainter::TreeView methodsFor:'queries'! |
6467 |
6599 |
6468 super initialize. |
6600 [ |
6469 |
|
6470 self multipleSelectOk:true. |
|
6471 canvasEventsDisabled := false. |
|
6472 self showDirectoryIndicator: true. |
|
6473 self showDirectoryIndicatorForRoot: false. |
|
6474 |
|
6475 self model |
|
6476 iconAction:[:aNode| self iconForNode:aNode]; |
|
6477 labelAction: [:aNode | self labelForNode:aNode]. |
|
6478 ! |
|
6479 |
|
6480 labelForNode:aNode |
|
6481 |spec| |
|
6482 |
|
6483 spec := aNode contents spec. |
|
6484 spec notNil ifTrue: [ |
|
6485 ^ self nameForSpecInList:spec |
|
6486 ] ifFalse:[ |
6601 ^ aNode name |
6487 ^ aNode name |
6602 ] |
6488 ] |
6603 ! |
6489 ! ! |
6604 |
6490 |
6605 aspect := aSpec nameOfMainAspect. |
6491 !UIPainter::TreeView methodsFor:'private'! |
|
6492 |
|
6493 nameForSpecInList:aSpec |
|
6494 "returns the tree item label for aSpec" |
|
6495 |
|
6496 |aspect aspectPrefix nameString viewClassString| |
|
6497 |
|
6498 nameString := aSpec name ? ''. |
|
6499 viewClassString := '[',aSpec viewClass name,']' . |
|
6500 |
|
6501 aspect := aSpec nameOfMainAspect. |
6606 aspect notNil ifTrue:[ |
6502 aspect notNil ifTrue:[ |
6607 aspectPrefix := '(',aspect allBold ,') ' |
6503 aspectPrefix := '(',aspect allBold ,') ' |
6608 ] ifFalse:[ |
6504 ] ifFalse:[ |
6609 aspectPrefix := ''. |
6505 aspectPrefix := ''. |
6610 ]. |
6506 ]. |
6649 ] |
6545 ] |
6650 ] |
6546 ] |
6651 ifFalse: [ |
6547 ifFalse: [ |
6652 lastDrawnMaster := nil |
6548 lastDrawnMaster := nil |
6653 ] |
6549 ] |
6654 ! |
6550 ! ! |
6655 |
6551 |
6656 ]. |
6552 !UIPainter::TreeView methodsFor:'queries'! |
6657 size = 1 ifTrue:[ |
6553 |
6658 oldSelection size > 1 ifTrue: [ |
6554 canChangeOrderInContainer |
6659 (listOfNodes at:lastDrawnMaster) retrieveLabel. |
6555 "returns true if any selection exists and all widgets in the selection |
6660 self redrawLine: lastDrawnMaster. |
6556 can change their layout through to a move or align operation" |
6661 lastDrawnMaster := selection first |
|
6662 ] |
|
6663 ]. |
|
6664 size > 1 ifTrue:[ |
|
6665 selection first ~~ lastDrawnMaster ifTrue: [ |
|
6666 (listOfNodes at:selection first) retrieveLabel. |
|
6667 lastDrawnMaster notNil ifTrue: [(listOfNodes at:lastDrawnMaster) retrieveLabel]. |
|
6668 self redrawLine: lastDrawnMaster. |
|
6669 self redrawLine: (lastDrawnMaster := selection first) |
|
6670 ] |
|
6671 ] |
|
6672 ifFalse: [ |
|
6673 lastDrawnMaster := nil |
|
6674 ] |
|
6675 ! |
|
6676 |
|
6677 er := selection first) |
|
6678 ] |
|
6679 ] |
|
6680 ifFalse: [ |
|
6681 lastDrawnMaster := nil |
|
6682 ] |
|
6683 ! |
|
6684 |
|
6685 on" |
|
6686 |
6557 |
6687 ^(selection size == 1) and: |
6558 ^(selection size == 1) and: |
6688 [(selection at: 1) ~~ 1 and: |
6559 [(selection at: 1) ~~ 1 and: |
6689 [self selectedNode parent children size > 1]] |
6560 [self selectedNode parent children size > 1]] |
6690 |
6561 |
6691 |
6562 |
6692 ! |
6563 ! |
6693 |
6564 |
6694 AlignSelection |
6565 canExchangeSelectionLayouts |
|
6566 "returns true if the selections size is exactly 2 |
|
6567 and all widgets in the selection |
|
6568 can change their layout through to a move or align operation" |
|
6569 |
|
6570 selection size == 2 ifFalse:[ |
|
6571 ^ false |
|
6572 ]. |
|
6573 ^ self canMoveOrAlignSelection |
|
6574 ! |
|
6575 |
|
6576 canMoveOrAlignSelection |
6695 "returns true if any selection exists and all widgets in the selection |
6577 "returns true if any selection exists and all widgets in the selection |
6696 can change their layout through to a move or align operation" |
6578 can change their layout through to a move or align operation" |
6697 |
6579 |
6698 selection isEmptyOrNil ifTrue:[ |
6580 selection isEmptyOrNil ifTrue:[ |
6699 ^ false |
6581 ^ false |
6799 ] |
6642 ] |
6800 ]. |
6643 ]. |
6801 ^ false |
6644 ^ false |
6802 ! |
6645 ! |
6803 |
6646 |
6804 ctionChangeAllowed |
6647 canResizeSelection |
|
6648 "returns true if all selected widgets can be resized" |
|
6649 |
|
6650 selection isEmptyOrNil ifTrue:[ ^ false ]. |
|
6651 ^ self canvas canResize:(self selectedViews) |
|
6652 ! |
|
6653 |
|
6654 hasOneSelectionOtherThanCanvas |
|
6655 "returns true in case that one selection exists other than the canvas" |
|
6656 |
|
6657 ^ selection size == 1 and:[selection first ~~ 1] |
|
6658 ! |
|
6659 |
|
6660 isCanvasSelected |
|
6661 "returns true in case of a single selection and the |
|
6662 selection is the canvas (index 1)" |
|
6663 |
|
6664 ^ selection size == 1 and:[self isInSelection:1] |
|
6665 ! ! |
|
6666 |
|
6667 !UIPainter::TreeView methodsFor:'searching'! |
|
6668 |
|
6669 detectItemCorespondingToView:aView |
|
6670 "detects the item coresponding to the view. The item of the view or the first |
|
6671 subview providing the item is returned. If no property is detected nil is |
|
6672 returned" |
|
6673 |
|
6674 |view item| |
|
6675 |
|
6676 (view := aView) isNil ifTrue:[ ^ nil ]. |
|
6677 |
|
6678 [(item := self itemOfView:view) isNil] whileTrue:[ |
|
6679 (view := view superView) isNil ifTrue:[^ listOfNodes at:1] |
|
6680 ]. |
|
6681 ^ item |
|
6682 ! ! |
|
6683 |
|
6684 !UIPainter::TreeView methodsFor:'user interaction'! |
|
6685 |
|
6686 askForSelectionChangeAllowed |
6805 selectConditionBlock notNil ifTrue:[ |
6687 selectConditionBlock notNil ifTrue:[ |
6806 ^ selectConditionBlock value:nil |
6688 ^ selectConditionBlock value:nil |
6807 ]. |
6689 ]. |
6808 ^ true |
6690 ^ true |
6809 ! |
6691 ! |
6810 |
6692 |
6811 kForSelectionChangeAllowed ifFalse:[^ self]. |
6693 doChangeParentOfSelectedItemTo:newParentItem |
|
6694 |
|
6695 |canvas| |
|
6696 |
|
6697 newParentItem isNil ifTrue:[ |
|
6698 ^ self |
|
6699 ]. |
|
6700 self askForSelectionChangeAllowed ifFalse:[^ self]. |
|
6701 self setSelection:nil. |
|
6702 |
|
6703 canvas := self canvas. |
|
6704 canvas deleteSelection. |
|
6705 canvas setSelection:(newParentItem contents view) withRedraw:false. |
|
6706 canvas pasteWithLayout. |
|
6707 ! |
|
6708 |
|
6709 doSortItems |
|
6710 "sort items by their top-left position" |
|
6711 |
|
6712 |selectedItems parent sortedItems newChildren itemList parentView| |
|
6713 |
|
6714 self askForSelectionChangeAllowed ifFalse:[^ self]. |
6812 |
6715 |
6813 selectedItems := self selectedNodes. |
6716 selectedItems := self selectedNodes. |
6814 selectedItems size <= 1 ifTrue:[^ self]. |
6717 selectedItems size <= 1 ifTrue:[^ self]. |
6815 parent := selectedItems first parent. |
6718 parent := selectedItems first parent. |
6816 (parent isNil or:[(selectedItems conform:[:e| e parent == parent]) not]) ifTrue:[^ self]. |
6719 (parent isNil or:[(selectedItems conform:[:e| e parent == parent]) not]) ifTrue:[^ self]. |
6844 self canvas showSelection. |
6747 self canvas showSelection. |
6845 |
6748 |
6846 self selectNodes:itemList asOrderedCollection. |
6749 self selectNodes:itemList asOrderedCollection. |
6847 ! |
6750 ! |
6848 |
6751 |
6849 sNil or:[(selectedItems conform:[:e| e parent == parent]) not]) ifTrue:[^ self]. |
6752 doStepIn |
6850 |
6753 "move the currently selected widget into the next available container below" |
6851 sortedItems := selectedItems sort:[:a :b| |
6754 |
6852 a contents view origin isLeftOrAbove:(b contents view origin)]. |
6755 |item oldParentItem newParentItem idx| |
6853 itemList := selectedItems asIdentitySet. |
6756 |
6854 |
6757 item := self selectedNode. |
6855 newChildren := parent children collect:[:eachChild| |
6758 (item notNil and:[(oldParentItem := item parent) notNil]) ifTrue:[ |
6856 (itemList includes:eachChild) ifTrue:[ |
6759 idx := (oldParentItem indexOfChild:item) + 1. |
6857 sortedItems removeFirst. |
6760 newParentItem := oldParentItem children |
6858 ] ifFalse:[ |
6761 detect:[:eachChild | eachChild contents spec class supportsSubComponents] |
6859 eachChild. |
6762 startingAt:idx |
|
6763 ifNone:nil. |
|
6764 newParentItem notNil ifTrue:[ |
|
6765 self doChangeParentOfSelectedItemTo:newParentItem |
6860 ]. |
6766 ]. |
6861 ]. |
6767 ] |
|
6768 ! |
|
6769 |
|
6770 doStepOut |
|
6771 |item| |
|
6772 |
|
6773 item := self selectedNode. |
|
6774 (item notNil and:[(item := item parent) notNil]) ifTrue:[ |
|
6775 self doChangeParentOfSelectedItemTo:(item parent) |
|
6776 ]. |
|
6777 ! |
|
6778 |
|
6779 doStepOver:anIndex |
|
6780 "moves child 'anIndex' forward or backward in list of children" |
|
6781 |
|
6782 |item idx size parentItem parentItemsView itemsView canvas| |
|
6783 |
|
6784 self askForSelectionChangeAllowed ifFalse:[^ self]. |
|
6785 |
|
6786 ( (item := self selectedNode) isNil |
|
6787 or:[(parentItem := item parent) isNil |
|
6788 or:[(size := parentItem children size) < 2 |
|
6789 or:[(idx := parentItem indexOfChild:item) == 0]]] |
|
6790 ) ifTrue:[ |
|
6791 ^ self |
|
6792 ]. |
|
6793 |
|
6794 idx := idx + anIndex. |
|
6795 |
|
6796 idx < 1 ifTrue:[idx := size] |
|
6797 ifFalse:[idx > size ifTrue:[idx := 1]]. |
6862 |
6798 |
6863 self setSelection:nil. |
6799 self setSelection:nil. |
6864 model remove:parent children. |
6800 model remove:item. |
6865 model add:newChildren beforeIndex:1 below:parent. |
6801 model add:item beforeIndex:idx below:parentItem. |
6866 |
6802 |
6867 parentView := parent contents view. |
6803 idx := parentItem indexOfChild:item. |
6868 |
6804 itemsView := item contents view. |
6869 self canvas hideSelection. |
6805 parentItemsView := parentItem contents view. |
6870 newChildren keysAndValuesDo:[:idx :eachItem| |
6806 |
6871 parentView changeSequenceOrderFor:eachItem contents view to:idx. |
6807 canvas := self canvas. |
6872 ]. |
6808 canvas hideSelection. |
6873 parentView specClass isLayoutContainer ifFalse:[ |
6809 |
6874 parentView components notEmptyOrNil ifTrue:[ self halt ]. |
6810 itemsView isView ifFalse:[ |
6875 parentView subViews do:[:v| v raise ]. |
6811 "/ a component - has its own collection (and therefore indexing) - sigh |
6876 ]. |
6812 idx := idx - ((1 to:idx-1) count:[:i | (parentItem children at:i) contents view isView]). |
6877 self canvas showSelection. |
6813 parentItemsView changeSequenceOrderFor:itemsView to:idx. |
6878 |
6814 ] ifTrue:[ |
6879 self selectNodes:itemList asOrderedCollection. |
6815 "/ a view - has its own collection (and therefore indexing) - sigh |
|
6816 idx := idx - ((1 to:idx-1) count:[:i | (parentItem children at:i) contents view isView not]). |
|
6817 parentItemsView changeSequenceOrderFor:itemsView to:idx. |
|
6818 ]. |
|
6819 |
|
6820 parentItemsView specClass isLayoutContainer ifFalse:[ |
|
6821 "/ spVw components notEmptyOrNil ifTrue:[ self halt ]. |
|
6822 parentItemsView subViews do:[:v| v raise ]. |
|
6823 ]. |
|
6824 canvas showSelection. |
|
6825 self selectNode:item. |
6880 ! ! |
6826 ! ! |
6881 |
6827 |
6882 !UIPainter class methodsFor:'documentation'! |
6828 !UIPainter class methodsFor:'documentation'! |
6883 |
6829 |
6884 version |
6830 version |