eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'SelectionInTreeView':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: SelectionInTreeView


Inheritance:

   Object
   |
   +--GraphicsMedium
      |
      +--DisplaySurface
         |
         +--SimpleView
            |
            +--View
               |
               +--ListView
                  |
                  +--SelectionInListView
                     |
                     +--SelectionInTreeView
                        |
                        +--FileSelectionTree

Package:
stx:libwidg2
Category:
Views-Trees
Version:
rev: 1.146 date: 2023/12/19 20:48:58
user: cg
file: SelectionInTreeView.st directory: libwidg2
module: stx stc-classLibrary: libwidg2

Description:


OBSOLETE, please use HierarchicalListView.

somewhat like a SelectionInListView; but specialized for hierarchical (i.e. tree-like)
lists and adds the functions to show/hide subtrees. 
Requires SelectionInTree as model and TreeItem (or compatible) list entries.

Notice: 
    This class obsoletes SelectionInHierarchyView, which is no longer
    maintained but kept for backward compatibility.

Notice2: 
    Even for this class, an improved replacement now exists:
    HierarchicalListView.
    Please consider using that one.
    (however, this class is kept for backward compatibility).

copyright

COPYRIGHT (c) 1997 by eXept Software AG / 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.

Class protocol:

constants
o  minImageInset
returns minimum inset from directory indication to image

defaults
o  defaultModelClass
returns the default model

o  updateStyleCache
extract values from the styleSheet and cache them in class variables

Usage example(s):

     self updateStyleCache

resources
o  closeIndicator
returns a little [+] bitmap

o  imageClosed
returns a closed file-directory bitmap

o  imageItem
returns a regular file bitmap

o  imageOpened
returns an opened file-directory bitmap

o  openIndicator
returns a little [-] bitmap


Instance protocol:

accessing
o  highlightMode
get the mode how to draw a selected line:
#line draw whole line selected
#label draw label selected

o  highlightMode: aMode
set the mode how to draw a selected line:
#line draw whole line selected
#label draw label selected

o  itemClass
returns current itemClass used

o  itemClass: anItemClass
set itemClass to be used

o  lineColor
returns user configured line color or nil

o  lineColor: aColor
returns user configured line color or nil

o  nodeAtIndex: anIndex
returns node at an index or nil

o  root
gets the root of the model; the first item into list.

o  root: aRoot
sets the root of the model; the first item into list.

o  textInset
get the left inset of the text label

o  textInset: anInset
set the left inset of the text label

accessing-behavior
o  drawVLinesFromLevel
returns the level vertical lines are drawn from;
starting at 1 up to n

o  drawVLinesFromLevel: aLevel
set the level vertical lines are drawn from;
starting at 1 up to n

o  supportsExpandAll

o  supportsExpandAll: aBool

o  validateDoubleClickBlock
return the conditionBlock; this block is evaluated before a doubleClick action
on a node will be performed. In case of returning false, the doubleClick will
not be handled.

o  validateDoubleClickBlock: aOneArgBlock
set the conditionBlock; this block is evaluated before a doubleClick action
on a node will be performed. In case of returning false, the doubleClick will
not be handled.

o  validateExpandabilityBlock
return the expand conditionBlock; this block is evaluated before an expand due to
a doubleClick on a node will be performed. In case of returning false,
the node will not be expanded.

o  validateExpandabilityBlock: aOneArgBlock
set the expand conditionBlock; this block is evaluated before an expand due to
a doubleClick on a node will be performed. In case of returning false,
the node will not be expanded.

accessing-channels
o  rootHolder
get the holder which keeps the hierarchical list entry or nil

o  rootHolder: aValueHolder
set the holder which keeps the hierarchical list entry or nil

o  selectionHolder
get the holder which keeps a list of selected items or nil

o  selectionHolder: aHolder
set the holder which keeps a list of selected items or nil

accessing-images
o  closeIndicator
return the bitmap image shown for expandable tree items (a little right arrow)
(initialized to a right arrow)

o  closeIndicator: aBitmapIcon
set the bitmap image shown for expandable tree items
(defaults to a right arrow)

o  imageClosed
return the value of the instance variable 'imageClosed'.
That's the (default) bitmap image shown for closed folders
(initialized to a file-directory bitmap)

o  imageClosed: anIconImage
set the instance variable 'imageClosed'.
That's the (default) bitmap image shown for closed folders
(if nil, a class-specific open file-directory bitmap will be used).
Must be set early (before opening the view)

o  imageItem
return the value of the instance variable 'imageItem'.
That's the (default) bitmap image shown for regular items
(initialized to a plain-file bitmap)

o  imageItem: anIconImage
set the instance variable 'imageItem'.
That's the (default) bitmap image shown for non-folders
(if nil, a class-specific file bitmap will be used).
Must be set early (before opening the view)

o  imageOnMyDevice: anImage
associate image to device and returns the new image.

o  imageOpened
return the value of the instance variable 'imageOpened'.
That's the (default) bitmap image shown for opened folders
(initialized to an open file-directory bitmap)

o  imageOpened: anIconImage
set the instance variable 'imageOpened'.
That's the (default) bitmap image shown for opened folders
(if nil, a class-specific open file-directory bitmap will be used).
Must be set early (before opening the view)

o  openIndicator
return the bitmap image shown for expanded tree items (a little down arrow)
(initialized to a down arrow)

o  openIndicator: aBitmapIcon
set the bitmap image shown for expanded tree items
(defaults to a down arrow)

accessing-look
o  showDirectoryIndicator
returns true if items with children have an open/closed indicator

o  showDirectoryIndicator: aBoolean
show or hide open/closed indicators for items with children

o  showDirectoryIndicatorForRoot
returns true if the root item has an open/closed indicator
(showing requires that the general showDirectoryIndicator is also enabled)

o  showDirectoryIndicatorForRoot: aBoolean
show/hide the root item's open/closed indicator
(showing requires that the the common showDirectoryIndicator is also enabled)

o  showLines
returns true if lines are shown

o  showLines: aBoolean
show or hide lines

o  showLinesForRoot
returns true if root-lines are shown

o  showLinesForRoot: aBoolean
show or hide lines for root(s)

o  showRoot
return true if the root is shown

o  showRoot: aBoolean
show or hide the root item

change & update
o  modelChanged: what with: aPara
hierarchical list changed

o  update: anAspect with: aParameter from: changedObject
one of my models changed its value

drawing
o  drawLine: line atX: atX inVisible: visLineNr with: fg and: bg
(comment from inherited method)
draw a given string at visible lines position with
given x position in fg/bg. Clears the whole line before drawing the string.
This is a low level entry; not meant for public use.

o  drawLine: line fromX: x inVisible: visLineNr with: fg and: bg
(comment from inherited method)
draw a given string at visible lines position with
given x position in fg/bg. Clears partial line before drawing the string.
Low level entry; not meant for public use.

o  drawLine: line inVisible: visLineNr with: fg and: bg
(comment from inherited method)
draw a given string at visible lines position in fg/bg

o  drawVisibleLine: visLineNr col: col with: fg and: bg
(comment from inherited method)
draw single character at col index of visible line in fg/bg

o  drawVisibleLine: visLineNr from: startCol to: endCol with: fg and: bg
(comment from inherited method)
draw part of a visible line in fg/bg

o  drawVisibleLine: visLineNr from: startCol with: fg and: bg
(comment from inherited method)
draw right part of a visible line from startCol to end of line in fg/bg

o  redrawFromVisibleLine: startVisLineNr to: endVisLineNr
(comment from inherited method)
redraw a range of lines.
Must check, if any is in the selection and handle this case.
Otherwise draw it en-bloque using supers method.

o  redrawIconAndIndicatorAt: aLnNr

o  redrawIndicatorLine: aLineNr
redraw the directory indicator for a line

o  redrawVisibleLine: visLineNr
(comment from inherited method)
redraw a single line.
Must check, if any is in the selection and handle this case.
Otherwise draw using supers method.

o  redrawVisibleLine: visLineNr from: startCol to: endCol
(comment from inherited method)
redraw from a startCol to endCol.
Must check, if it's in the selection and handle this case.

drawing basics
o  drawFromVisibleLine: startVisLineNr to: endVisLineNr with: fg and: bg
redraw a visible line range with clearing the background

o  drawVHLinesX: x0 y: y0 toX: x1 start: start stop: stop
redraw from line to line without clearing the background

o  drawVisibleLineSelected: visLineNr with: fg and: bg
redraw a single line as selected.

o  paintOnIsSelected: isSelected

o  redrawElement: anIndex
(comment from inherited method)
redraw an individual element

o  redrawLabelAt: x y: yTop index: anIndex

o  redrawLinesX: x0 y: y0 toX: x1 start: start stop: stop
redraw from line to line without clearing the background

o  redrawSelFrameAtX: x0 y: y0 toX: x1
redraw selection frame for a line

o  redrawX: x y: y width: w height: h
a region must be redrawn

enumerating
o  detectNode: aOneArgBlock
evaluate the argument, aBlock for each node in the list until
the block returns true; in this case return the node which caused
the true evaluation. If none node is detected, nil is returned.

o  selectedNodesDo: aOneArgBlock
evaluate the block on each node selected

event handling
o  activateMenu
menu receiver:appl. -- now done in findGuiResources ...

o  buttonMotion: buttonMask x: x y: y
mouse-move while button was pressed - handle selection changes

o  buttonMultiPress: button x: x y: y
discard doubleClick on indicator

o  buttonPress: button x: x y: y
handle button press event

o  buttonRelease: button x: x y: y
stop any autoscroll

o  doubleClicked
handle a double click; collapse or expand selected entry
in case of having children

o  handleSelectButtonAtX: x y: y
handle a select button click

o  indicatiorLineForButton: aButton atX: x y: y
returns linenumber assigned to indicator at x/y or 0

o  isCtrlMetaAltOrShiftPressed
returns true if CTRL, META, ALT or SHIFT is pressed

o  key: key select: index x: x y: y
select an entry by a keyboard action. This is treated like a doubleClick
on that entry.
Add on: In case that the entry is not selectable, scroll to the entry

Usage example(s):

^ super key:key select:index x:x y:y

o  keyPress: key x: x y: y
handle keyboard input

initialization & release
o  create
(comment from inherited method)
I cache font parameters here - they are used so often ...

o  fetchDefaultImages
returns a directory with default keys and images;
could be redefined by subclass.

o  fetchDeviceResources
initialize heavily used device resources - to avoid rendering
images again and again later

o  fetchImageResources
initialize heavily used device resources - to avoid rendering
images again and again later;
returns the maximum extent of the images used.
Could be redefined by subclass

o  getFontParameters
save old computed height derived from images

o  initStyle
setup viewStyle specifics

o  initialize
setup instance attributes

o  realize

o  recomputeDirectoryIndicator
setup attributes used by directory indicator

o  refetchDeviceResources
reinitialize heavily used device resources - to avoid rendering
images again and again later

o  release
remove dependencies

model
o  getListFromModel
if I have a model, get my list from it using the listMessage.
If listMessage is nil, try aspectMessage for backward compatibilty.

o  listFromModel
get list from model and return the new list.
If listMessage is nil, try aspectMessage for backward compatibilty.

o  model: aModel
check whether given new model is nil;
then a default model is created

o  rootFromModel
update hierarchical list from root model; 'rootHolder'

o  selectionFromModel
set the selection derived from the selectionHolder

o  selectionToModel
write selection to selection holder

private
o  closeEditor
close the editor

o  list: aList keepSelection: keepSelection
setup new list; keep selection dependent on the boolean state
keepSelection

o  openEditor
open an editor on the selected item

private-drag and drop
o  collectionOfDragObjects
returns collection of dragable objects assigned to selection
Here, by default, a collection of text-dragObjects is generated;
however, if a dragObjectConverter is defined, that one gets a chance
to convert as appropriate.

o  dragObjectForNode: aNode
returns the dragable object for a node; could be redefined in subclass

o  startDragX: x y: y
start drag

private-queries
o  lengthOfLongestLineBetween: firstLine and: lastLine
return the length (in characters) of the longest line in a line-range

o  smallestLevelOfNodesBetween: start and: stop
returns the smallest level of the nodes in a line range

o  widthOfLongestLine
return the width of the longest line in pixels

private-redefinitions
o  expandTabs
nothing to do

o  list: aCollection expandTabs: expand scanForNonStrings: scan
(comment from inherited method)
set the contents (a collection of strings)
and scroll as specified in scrollWhenUpdating (default:top-left).
If expand is true, tabs are expanded (to spaces).
If scan is true, scan the passed list for nonStrings; otherwise,
assume that it does contain non-strings
(remembered to optimize later redraws).

o  withoutRedrawAt: anIndex put: aString
change a line without redisplay and WITHOUT any sizeChange notifications.
Somewhat dangerous, since scrollBars will not be informed about contents-changes.
Use only if multiple lines are to be changed, and a sizeChanged is invoked by some other
means at the end.

queries
o  figureFor: aNode
return a (bitmap) figure for a node

o  indexOfNode: aNode
returns index of a node

o  xOfFigureLevel: aLevel
origin x where to draw the icon

o  xOfFigureNode: aNode
origin x where to draw the icon

o  xOfStringLevel: aLevel
origin x where to draw the text( label )

o  xOfStringNode: aNode
origin x where to draw the text( label )

o  xOfValueNode: aNode
returns the left x position of the start of the value

queries-contents
o  widthOfContents
return the width of the contents in pixels
- used for scrollbar interface

scrolling
o  needScrollToMakeLine: aListLineNr
redefined to scroll whenever line is not in top half

o  originChanged: delta
sent after scrolling - have to update origin of editor

selection
o  selectNode: aNode
change selection to a node

o  selectNode: aNode withNotify: withNotify
change selection to a node

o  selectNodes: aCollectionOfNodes

o  selectNodes: aCollectionOfNodes withNotify: withNotify
first := true.

o  selectedIndex
get single selected index or 0

o  selectedNode
get the single selected node or nil

o  selectedNodes
get a collection of selected nodes

o  selectionChangedFrom: oldSelection
update selectionHolder if not nil

o  setSelection: aSelection
if no selection exists, close the editor

selection actions
o  selectedNodeAdd: something
add a node or collection of nodes after the selected node

o  selectedNodeBecomeChildOfNext
make the selected node a child of the next node

o  selectedNodeBecomeChildOfPrevious
make the selected node a child of the previous node

o  selectedNodeBecomeSisterOfParent
become node a sister of its current parent

o  selectedNodeChangeSequenceOrder: anOffset
move child 'anOffset' forward or backward in list of children

o  selectedNodeExpand: doExpand
collapse or expand selected node

o  selectedNodesBecomeChildrenOfNext
make the selected nodes children of the next node

o  selectedNodesBecomeSistersOfParent
move selected nodes up (out of their parent to their grandparent).
I.e. nodes become sisters of their current parent

o  selectedNodesRemove
remove selected nodes


Examples:


shows the tree of smalltalk classes:
  |top sel|

  top := StandardSystemView new; extent:300@300.
  sel := SelectionInTreeView new.
  sel root:(TreeItem newAsTreeFromSmalltalkClass:Object).
  sel action:[:nr | Transcript show:'selected:'; showCR:nr].
  top add:(ScrollableView forView:sel) in:((0.0 @ 0.0 ) corner:( 1.0 @ 1.0)).
  top open.
same, including nil-subclasses (i.e. really all classes):
  |top sel|

  top := StandardSystemView new; extent:300@300.
  sel := SelectionInTreeView new.
  sel root:(TreeItem newAsTreeFromSmalltalkClass:nil).
  sel action:[:nr | Transcript show:'selected:'; showCR:nr].
  sel lineColor:(Color red).
  top add:(ScrollableView forView:sel) in:((0.0 @ 0.0 ) corner:( 1.0 @ 1.0)).
  top open.
shows the tree of smalltalk classes; show directory indication and no lines.
  |top sel|

  top := StandardSystemView new; extent:300@300.
  sel := SelectionInTreeView new.
  sel showLines:false.
  sel showDirectoryIndicator:true.
  sel root:(TreeItem newAsTreeFromSmalltalkClass:Object).
  sel action:[:nr | Transcript show:'selected:'; showCR:nr].
  top add:(ScrollableView forView:sel) in:((0.0 @ 0.0 ) corner:( 1.0 @ 1.0)).
  top open.


ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Mon, 18 Nov 2024 04:18:56 GMT