--- a/UIPainterTreeView.st Wed May 21 12:39:28 1997 +0200
+++ b/UIPainterTreeView.st Wed May 21 12:40:05 1997 +0200
@@ -1,6 +1,6 @@
"
COPYRIGHT (c) 1995 by Claus Gittinger
- All Rights Reserved
+ 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
@@ -10,8 +10,10 @@
hereby transferred.
"
-SelectionInListView subclass:#UIPainterTreeView
- instanceVariableNames:'builderView'
+
+
+ApplicationModel subclass:#UIPainterTreeView
+ instanceVariableNames:'listHolder'
classVariableNames:''
poolDictionaries:''
category:'Interface-UIPainter'
@@ -22,7 +24,7 @@
copyright
"
COPYRIGHT (c) 1995 by Claus Gittinger
- All Rights Reserved
+ 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
@@ -31,303 +33,102 @@
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:'constants'!
-
-indent
- "indent for contained element
- "
- ^ 2
-
! !
-!UIPainterTreeView class methodsFor:'defaults'!
+!UIPainterTreeView class methodsFor:'instance creation'!
-defaultMenuMessage
- "This message is the default yo be sent to the menuHolder to get a menu
- "
- ^ #menu
-
-
-! !
-
-!UIPainterTreeView methodsFor:'accessing'!
+listHolder:aListHolder
+ |appl|
-builderView:aBuilderView
- builderView := aBuilderView.
- self updateTree.
-
-!
-
-indexOf:aString
- "returns the index of the string entry into my list
- "
- ^ list findFirst:[:aName| aName string withoutSeparators = aString ]
-
+ appl := UIPainterTreeView new.
+ appl listHolder:aListHolder.
+ appl openInterface:#windowSpec.
+ ^ appl
! !
-!UIPainterTreeView methodsFor:'event handling'!
+!UIPainterTreeView class methodsFor:'interface specs'!
-builderViewChanged:what
- "something changed in the builder view
+windowSpec
+ "this window spec was automatically generated by the ST/X UIPainter"
+
+ "do not manually edit this - the painter/builder may not be able to
+ handle the specification if its corrupted."
+
"
- (what == #tree or:[what == #widgetName]) ifTrue:[
- self updateTree
- ] ifFalse:[
- what ~~ #selection ifTrue:[
- ^ self
- ].
- self disableMaster:selection.
- self setSelection:nil.
- ].
-
- "update selection
+ UIPainter new openOnClass:UIPainterTreeView andSelector:#windowSpec
+ UIPainterTreeView new openInterface:#windowSpec
"
- builderView selectionDo:[:aView||idx|
- idx := self indexOf:(builderView uniqueNameOf:aView).
- idx ~~ 0 ifTrue:[
- selection isNil ifTrue:[
- |m i|
+ <resource: #canvas>
- 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
- ]
- ].
- selection isNil ifTrue:[
- self setSelection:1
- ]
+ ^
+
+ #(#FullSpec
+ #'window:'
+ #(#WindowSpec
+ #'name:' 'treeView'
+ #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
+ #'label:' 'Tree-View'
+ #'bounds:' #(#Rectangle 0 0 192 479)
+ )
+ #'component:'
+ #(#SpecCollection
+ #'collection:'
+ #(
+ #(#SequenceViewSpec
+ #'name:' 'selectionInList'
+ #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
+ #'menu:' #listMenu
+ #'model:' #listHolder
+ #'callbacksSpec:'
+ #(#UIEventCallbackSubSpec
+ #'doubleClickSelector:' #doubleClick
+ )
+ #'hasHorizontalScrollBar:' true
+ #'hasVerticalScrollBar:' true
+ #'miniScrollerHorizontal:' false
+ #'miniScrollerVertical:' false
+ #'isMultiSelect:' true
+ )
+ )
+ )
+ )
+! !
+
+!UIPainterTreeView methodsFor:'aspects'!
+
+doubleClick
+ listHolder selectGroup
!
-selectionChanged
- "selection has changed
- "
- |sel|
-
- selection notNil ifTrue:[
- selection size == 1 ifTrue:[
- sel := (list at:(selection first)) string withoutSeparators
- ] ifFalse:[
- sel := OrderedCollection new.
- selection do:[:aNumber|
- aNumber ~~ 1 ifTrue:[
- sel add:((list at:aNumber) string withoutSeparators)
- ]
- ]
- ]
- ].
- builderView selectNames:sel
+listHolder
+ ^ listHolder
!
-selectionChangedFrom:oldSelection
- "redraw master
- "
- oldSelection ~= selection ifTrue:[
- self disableMaster:oldSelection.
- super selectionChangedFrom:oldSelection
- ]
-! !
-
-!UIPainterTreeView methodsFor:'initialization'!
-
-initialize
- super initialize.
-
- list := OrderedCollection new.
-
- self multipleSelectOk:true.
- self action:[:aSelection| self selectionChanged ].
- self doubleClickAction:[:aSelection| builderView selectSubComponents].
-! !
-
-!UIPainterTreeView methodsFor:'menu & actions'!
-
-inspectProps
- |view|
-
- (view := builderView singleSelection) notNil ifTrue:[
- (builderView propertyOfView:view) inspect
- ]
-!
-
-inspectSpec
- |view|
-
- (view := builderView singleSelection) notNil ifTrue:[
- (builderView fullSpecFor:view) inspect
- ]
-!
-
-inspectView
- |view|
-
- (view := builderView singleSelection) notNil ifTrue:[
- view inspect
- ]
-!
-
-menu
- |menu|
-
- (menu := builderView menu) notNil ifTrue:[
- menu addLabels:(
- resources array:#(
- '-'
- 'misc'
- )
- )
- selectors:#(
- nil
- #treeMisc
- ).
-
- (builderView numberOfSelections) == 1 ifTrue:[
- menu subMenuAt:#treeMisc put:(self menuMisc)
- ] ifFalse:[
- menu disable:#treeMisc
- ]
- ].
- ^ menu
-!
-
-menuMisc
-
- |menu ispMenu|
-
- menu := PopUpMenu labels:( resources array:#('inspect' 'ordering' ) )
- selectors:#( #inspect #ordering )
- receiver:self.
-
- ispMenu := PopUpMenu labels:( resources array:#('view' 'spec' 'property') )
- selectors:#( #inspectView #inspectSpec #inspectProps )
- receiver:self.
-
- menu subMenuAt:#inspect put:ispMenu.
- ^ menu
-
-
+listHolder:aListHolder
+ listHolder := aListHolder
!
-ordering
- "change selected view to an index in its subview subviews collection
+listMenu
+ "returns a block which returns the menu
"
- |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 subViews do:[: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 builderViewChanged:#tree
- ]
-! !
-
-!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'!
-
-updateSubTree:aView indent:anIndent
- |name indent|
-
- name := builderView uniqueNameOf:aView.
-
- anIndent ~~ 0 ifTrue:[
- name := (String new:anIndent), name
- ].
- list add:name.
-
- indent := anIndent + self class indent.
-
- builderView subviewsOf:aView do:[:subview|
- self updateSubTree:subview indent:indent
- ]
-
-
-!
-
-updateTree
-
- selection := nil.
- list := OrderedCollection new.
- self updateSubTree:builderView indent:0.
- super list:list.
-
+ ^ [listHolder painter menu]
! !
!UIPainterTreeView class methodsFor:'documentation'!
version
^ '$Header$'
+
! !