--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/UIPainterTreeView.st Fri Feb 14 16:32:50 1997 +0100
@@ -0,0 +1,286 @@
+"
+ COPYRIGHT (c) 1995 by Claus Gittinger
+ All Rights Reserved
+
+ This software is furnished under a license and may be used
+ only in accordance with the terms of that license and with the
+ inclusion of the above copyright notice. This software may not
+ be provided or otherwise made available to, or used by, any
+ other person. No title to or ownership of the software is
+ hereby transferred.
+"
+
+ObjectView subclass:#UIPainterTreeView
+ instanceVariableNames:'builderView indent yPos maxX'
+ classVariableNames:''
+ poolDictionaries:''
+ category:'Interface-UIPainter'
+!
+
+!UIPainterTreeView class methodsFor:'documentation'!
+
+copyright
+"
+ COPYRIGHT (c) 1995 by Claus Gittinger
+ All Rights Reserved
+
+ This software is furnished under a license and may be used
+ only in accordance with the terms of that license and with the
+ inclusion of the above copyright notice. This software may not
+ be provided or otherwise made available to, or used by, any
+ other person. No title to or ownership of the software is
+ hereby transferred.
+"
+!
+
+documentation
+"
+ not yet finished, not yet published, not yet released.
+"
+! !
+
+!UIPainterTreeView class methodsFor:'startup'!
+
+start
+ |topView v|
+
+ topView := StandardSystemView
+ label:'View hierarchy'
+ icon:(Form fromFile:'BuildTreeV.icon' resolution:100).
+ v := HVScrollableView for:self in:topView.
+ v origin:(0 @ 0) extent:(1.0 @ 1.0).
+
+ topView realize.
+ ^ v scrolledView
+
+ "BuilderTreeView start"
+
+
+! !
+
+!UIPainterTreeView methodsFor:'BuilderView interface'!
+
+builderView:aBuilderView
+ builderView := aBuilderView.
+
+
+!
+
+selectName:aString
+ contents do:[:obj |
+ (obj text asString withoutSeparators = aString) ifTrue:[
+ ^ self select:obj.
+ ]
+ ]
+
+!
+
+selectNameAdd:aString
+ contents do:[:obj |
+ (obj text asString withoutSeparators = aString) ifTrue:[
+ ^ self addToSelection:obj.
+ ]
+ ]
+
+
+!
+
+update:something
+ |sel|
+
+ something == #tree ifTrue:[
+ ^ self updateTree.
+ ].
+
+ something == #widgetName ifTrue:[
+ self updateTree
+ ] ifFalse:[
+ something == #selection ifFalse:[
+ ^ self
+ ]
+ ].
+
+ sel := builderView selection.
+
+ (sel isKindOf:Collection) ifTrue:[
+ sel do:[:v | self selectNameAdd:(builderView variableNameOf:v)]
+ ] ifFalse:[
+ self selectName:(builderView variableNameOf:sel)
+ ]
+
+! !
+
+!UIPainterTreeView methodsFor:'drawing'!
+
+showSelected:anObject
+ "show an object as selected"
+
+ |oldFg oldBg|
+
+ oldFg := anObject foreground.
+ oldBg := anObject background.
+ anObject foreground:oldBg.
+ anObject background:oldFg.
+ anObject drawIn:self.
+ anObject foreground:oldFg.
+ anObject background:oldBg
+
+ "Modified: 31.8.1995 / 13:52:02 / claus"
+! !
+
+!UIPainterTreeView methodsFor:'generating the class-tree picture'!
+
+addToTree:name indent:indent
+ |newObject|
+
+ newObject := DrawText new.
+ "newObject font:font. "
+ newObject text:name.
+ newObject origin:((indent asInteger + margin) @ yPos).
+ newObject foreground:Color black. "/ foreground.
+ newObject background:Color white. "/background.
+ newObject linePattern:1; fillPattern:1. "/ opaque
+ yPos := yPos + newObject frame height.
+ self add:newObject.
+ maxX := maxX max:(newObject frame corner x).
+
+ "Modified: 5.9.1995 / 23:54:26 / claus"
+!
+
+addViewsToTreeFrom:aView indent:currentIndent
+ |name|
+
+ name := builderView variableNameOf:aView.
+ self addToTree:name indent:currentIndent.
+
+ builderView subviewsOf:aView do:[:subview |
+ self addViewsToTreeFrom:subview
+ indent:(currentIndent + indent)
+ ]
+!
+
+updateTree
+ self removeAll.
+ maxX := 0.
+ yPos := (self verticalPixelPerMillimeter:1) rounded asInteger.
+ self addViewsToTreeFrom:builderView indent:(self horizontalPixelPerMillimeter:1).
+ self contentsChanged
+
+ "Modified: 5.9.1995 / 23:54:35 / claus"
+! !
+
+!UIPainterTreeView methodsFor:'initialization'!
+
+initialize
+ super initialize.
+
+ maxX := 0.
+ yPos := (self verticalPixelPerMillimeter:1) rounded asInteger.
+ indent := (self horizontalPixelPerMillimeter:5) rounded asInteger.
+ sorted := true.
+ pressAction := [:aPoint | self click:aPoint].
+ shiftPressAction := [:aPoint | self shiftClick:aPoint]
+
+ "Modified: 6.9.1995 / 00:11:48 / claus"
+!
+
+initializeMiddleButtonMenu
+ |labels|
+
+ labels := resources array:#(
+ 'inspect view'
+ 'inspect properties'
+ ).
+
+ self middleButtonMenu:(PopUpMenu
+ labels:labels
+ selectors:#(
+ inspectView
+ inspectProps
+ )
+ receiver:self
+ for:self)
+! !
+
+!UIPainterTreeView methodsFor:'private'!
+
+selectedName
+ selection isNil ifTrue:[^ nil].
+ ^ selection text asString withoutSeparators
+!
+
+withSelectedNameDo:aBlock
+ |name|
+
+ name := self selectedName.
+ name notNil ifTrue:[aBlock value:name]
+! !
+
+!UIPainterTreeView methodsFor:'queries'!
+
+heightOfContents
+ ^ yPos + (self verticalPixelPerMillimeter:1) rounded
+
+ "Modified: 6.9.1995 / 12:56:24 / claus"
+!
+
+widthOfContents
+ ^ maxX + (self horizontalPixelPerMillimeter:1) rounded
+
+ "Modified: 6.9.1995 / 12:56:28 / claus"
+! !
+
+!UIPainterTreeView methodsFor:'user interaction'!
+
+click:aPoint
+ |anObject|
+
+ anObject := self findObjectAtVisible:aPoint.
+ (anObject ~~ selection) ifTrue:[
+ self unselect.
+ anObject notNil ifTrue:[
+ self select:anObject.
+ builderView selectName:(self selectedName)
+ ] ifFalse:[
+ builderView selectName:'self'
+ ]
+ ]
+
+
+
+
+!
+
+inspectProps
+ builderView inspectAttributes
+!
+
+inspectView
+ builderView inspectSelection
+!
+
+shiftClick:aPoint
+ |anObject|
+
+ anObject := self findObjectAtVisible:aPoint.
+
+ anObject notNil ifTrue:[
+ (self isSelected:anObject) ifTrue:[
+ builderView removeNameFromSelection:anObject text asString withoutSeparators
+ ] ifFalse:[
+ builderView addNameToSelection:anObject text asString withoutSeparators
+ ]
+ ]
+
+
+
+
+
+
+! !
+
+!UIPainterTreeView class methodsFor:'documentation'!
+
+version
+ ^ '$Header$'
+! !