--- a/UIPainterTreeView.st Fri Feb 21 20:33:18 1997 +0100
+++ b/UIPainterTreeView.st Fri Feb 21 20:33:57 1997 +0100
@@ -54,7 +54,7 @@
defaultMenuMessage
"This message is the default yo be sent to the menuHolder to get a menu
"
- ^ #editMenu
+ ^ #menu
! !
@@ -70,7 +70,7 @@
indexOf:aString
"returns the index of the string entry into my list
"
- ^ list findFirst:[:aName| aName withoutSeparators = aString ]
+ ^ list findFirst:[:aName| aName string withoutSeparators = aString ]
! !
@@ -84,12 +84,12 @@
selection notNil ifTrue:[
selection size == 1 ifTrue:[
- sel := (list at:(selection first)) withoutSeparators
+ sel := (list at:(selection first)) string withoutSeparators
] ifFalse:[
sel := OrderedCollection new.
selection do:[:aNumber|
aNumber ~~ 1 ifTrue:[
- sel add:((list at:aNumber) withoutSeparators)
+ sel add:((list at:aNumber) string withoutSeparators)
]
]
]
@@ -98,14 +98,23 @@
!
+selectionChangedFrom:oldSelection
+ "redraw master
+ "
+ self disableMaster:oldSelection.
+ super selectionChangedFrom:oldSelection
+
+!
+
update:something
(something == #tree or:[something == #widgetName]) ifTrue:[
self updateTree
] ifFalse:[
- something == #selection ifFalse:[
+ something ~~ #selection ifTrue:[
^ self
].
+ self disableMaster:selection.
self setSelection:nil.
].
@@ -115,6 +124,16 @@
idx := self indexOf:(builderView variableNameOf:aView).
idx ~~ 0 ifTrue:[
+ selection isNil ifTrue:[
+ |m i|
+
+ m := list at:idx.
+ i := m indexOfNonSeparatorStartingAt:1.
+ i == 0 ifTrue:[ i := 1 ].
+ m := Text string:m.
+ m emphasizeFrom:i with:#(#bold #underline).
+ list at:idx put:m
+ ].
self addToSelection:idx
]
].
@@ -138,15 +157,65 @@
!UIPainterTreeView methodsFor:'menu & actions'!
-editMenu
+inspectProps
+ builderView inspectAttributes
+!
+
+inspectSpec
+ builderView inspectSpec
+!
+
+inspectView
+ builderView inspectSelection
+!
+
+menu
+ |menu noSel|
+
+ noSel := builderView numberOfSelections.
+
+ menu := PopUpMenu labels:(
+ resources array:#(
+ 'cut'
+ 'undo'
+ '-'
+ 'misc'
+ )
+ )
+ selectors:#(
+ #cut
+ #undo
+ nil
+ #misc
+ )
+ receiver:self.
+
+ noSel == 1 ifTrue:[ menu subMenuAt:#misc put:(self menuMisc)]
+ ifFalse:[ menu disable:#misc].
+
+ noSel == 0 ifTrue:[ menu disable:#cut]
+ ifFalse:[ menu actionAt:#cut put:[builderView deleteSelection]].
+
+ builderView hasUndos ifFalse:[ menu disable:#undo]
+ ifTrue:[ menu actionAt:#undo put:[builderView undoLast]].
+
+
+
+ ^ menu
+
+
+!
+
+menuMisc
+
|menu ispMenu|
- menu := PopUpMenu labels:( resources array:#('inspect') )
- selectors:#( #inspect )
+ menu := PopUpMenu labels:( resources array:#('inspect' 'ordering' 'remove layout' ) )
+ selectors:#( #inspect #ordering #removeLayout )
receiver:self.
- ispMenu := PopUpMenu labels:( resources array:#('view' 'property') )
- selectors:#( #inspectView #inspectProps )
+ ispMenu := PopUpMenu labels:( resources array:#('view' 'spec' 'property') )
+ selectors:#( #inspectView #inspectSpec #inspectProps )
receiver:self.
menu subMenuAt:#inspect put:ispMenu.
@@ -155,12 +224,85 @@
!
-inspectProps
- builderView inspectAttributes
+ordering
+ "change selected view to an index in its subview subviews collection
+ "
+ |myIdx view spView index names values|
+
+ view := builderView singleSelection.
+ view isNil ifTrue:[^ self].
+
+ spView := view superView.
+ names := OrderedCollection new.
+ values := OrderedCollection new.
+ index := 1.
+
+ spView allSubViewsDo:[:aView||props|
+ aView ~~ view ifTrue:[
+ props := builderView propertyOfView:aView.
+
+ props notNil ifTrue:[
+ names add:(props name).
+ values add:index
+ ]
+ ] ifFalse:[
+ myIdx := index
+ ].
+ index := index + 1
+ ].
+
+ names isEmpty ifTrue:[
+ ^ self
+ ].
+
+ index := Dialog choose:'before name:'
+ fromList:names
+ values:values
+ lines:20
+ cancel:[nil].
+
+ index isNil ifTrue:[
+ ^ self
+ ].
+ myIdx < index ifTrue:[
+ index := index - 1
+ ].
+ (spView changeSequenceOrderFor:view to:index) ifTrue:[
+ self update:#tree
+ ]
!
-inspectView
- builderView inspectSelection
+removeLayout
+ builderView selectionHiddenDo:[
+ builderView selectionDo:[:aView|
+ aView geometryLayout:nil.
+ aView superView sizeChanged:nil
+ ]
+ ].
+! !
+
+!UIPainterTreeView methodsFor:'redrawing'!
+
+disableMaster:aLineNrOrCollection
+ "find and redraw line from master as no master
+ "
+ |line|
+
+ aLineNrOrCollection notNil ifTrue:[
+ aLineNrOrCollection isCollection ifFalse:[
+ (line := list at:aLineNrOrCollection) isText ifTrue:[
+ list at:aLineNrOrCollection put:(line string).
+ self redrawLine:aLineNrOrCollection.
+ ]
+ ] ifTrue:[
+ aLineNrOrCollection do:[:aNumber|
+ (line := list at:aNumber) isText ifTrue:[
+ list at:aNumber put:(line string).
+ ^ self redrawLine:aNumber.
+ ]
+ ]
+ ]
+ ]
! !
!UIPainterTreeView methodsFor:'update'!