eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'HierarchicalListView':

Home

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

Class: HierarchicalListView


Inheritance:

   Object
   |
   +--GraphicsMedium
      |
      +--DisplaySurface
         |
         +--SimpleView
            |
            +--View
               |
               +--ListModelView
                  |
                  +--SelectionInListModelView
                     |
                     +--HierarchicalListView

Package:
stx:libwidg2
Category:
Views-Trees
Version:
rev: 1.168 date: 2023/10/26 16:47:10
user: stefan
file: HierarchicalListView.st directory: libwidg2
module: stx stc-classLibrary: libwidg2

Description:


This class implements a hierarchical list view based on a
hierachical list.
It provides functionality similar to SelectionInTreeView, but optimizes
redraws, and operates directly on the model 
(in contrast to SelectionInTreeView, which generates a list internally).

[Instance variables:]
    textStartLeft       <Integer>              inset between icon and text
    imageInset          <Integer>              inset between left side and icon
    imageWidth          <Integer>              width of widest icon
    minLineHeight       <Integer>              minimum required line height
                                               including open/close indication ...
    indicatorWidth      <Integer>              max. width  of indicator
    indicatorHeight     <Integer>              max. height of indicator

    lineMask            <Form>                 line mask
    lineColor           <Color>                line color
    showRoot            <Boolean>              root element is shown or hidden
                                               derives from the hierachical list.
    showLines           <Boolean>              show or hide lines
    showIndicators      <Boolean>              show or hide indicators
    useDefaultIcons     <Boolean>              use the default icons if no icon
                                               for an item is specified
    icons               <IdentityDictionary>   list of registered icons;
                                               identifier := <key> value := <icon>
    showLeftIndicators  <Boolean>              show or hide indicator for most left items
    indicatorAction     <Block>                action evaluated if indicator is pressed (0/1/2 arguments)
    openIndicator       <Icon, Image or Form>  expanded indicator
    closeIndicator      <Icon, Image or Form>  collapsed indicator

    alignTextRight      <Boolean>              enable disable of align the text right
                                               icon            text
                                                    icon       text of child
                                               should be set after creation of the widget!
    alignTextRightX     <Integer>              left x position of aligned right text
    maxWidthOfText      <Integer>              keeps the maximum width of a text label

    levelOfLastItem     <Integer>              keeps the level of the last item;
                                               in case of a delete last items from list
                                               we know were to redraw lines from

    autoScrollHorizontal <Boolean>             true, than automatically scroll horizontal upto
                                               the text label of the current selected line.

    expandOnSelect      <Boolean>              true, than the item selected by a buttonPress
                                               event will be immediately expanded.

copyright

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

example2

|top sel list item| list := HierarchicalList new. item := HierarchicalItem::Example label:'Root Item'. item expand. list showRoot:false. list root:item. top := StandardSystemView extent:300@300. sel := ScrollableView for:HierarchicalListView miniScrollerH:true origin:0.0@0.0 corner:1.0@1.0 in:top. sel useDefaultIcons:false. sel list:list. sel multipleSelectOk:true. sel showLines:false. sel doubleClickAction:[:i| (list at:i) toggleExpand ]. sel indicatorAction:[:i| (list at:i) toggleExpand ]. top open.

Class protocol:

resources
o  closeIndicator

o  collapsedIcon

o  emptyIcon

o  expandedIcon

o  openIndicator


Instance protocol:

accessing
o  font: aFont
set a new font; if the font changed, all my items
have to clear their cached width and height.

o  list: aList

o  newDefaultList
creates and returns a new default list; by default, an instance of HierarchicalList

o  root
return the anchor of the list or nil

accessing-behavior
o  autoScrollHorizontal
returns true if automatic horizontal scrolling
(upto the text label of the selected line)
is allowed (the default is as specified in the styleSheet).

o  autoScrollHorizontal: aBoolean
true, than automatically scroll horizontal upto the text label
of the current selected line.

o  expandOnSelect
true, than the item selected by a buttonPress event will
be immediately expanded.

o  expandOnSelect: aBoolean
true, than the item selected by a buttonPress event will
be immediately expanded.

accessing-color & font
o  lineColor
get the color of the horizontal and vertical lines

o  lineColor: aColor
set the color of the horizontal and vertical lines

accessing-look
o  alignTextRight
align the text right

o  alignTextRight: aBool
align the text right

o  alignTextRightX
returns the minimum used text inset, if text is aligned right.

o  alignTextRightX: aNumber
set the minimum used text inset, if text is aligned right.

o  closeIndicator: anIconOrNil

o  iconAlignment: aSymbol
alignment of the icons
#left align icons left
#right align icons right
#center align icons center between left and right

o  iconAt: aKey ifAbsentPut: aBlock
return the icon stored under a key; if not present,the
result of the block if not nil is stored under the key
and returned.

o  openIndicator

o  openIndicator: anIconOrNil

o  registerKeysAndIcons: aDictionary
register icons by key and value derived from a directory

o  selectedVisualBlock
To be polymorph with SelectionInListView

o  selectedVisualBlock: aBlockOrNil
To be polymorph with SelectionInListView

o  showIndicators
returns true if indicators are shown

o  showIndicators: aBoolean
true if indicators are shown

o  showLeftIndicators
show or hide the indicators for the most left items

o  showLeftIndicators: aBoolean
show or hide the indicators for the most left items

o  showLines
returns true if lines are shown

o  showLines: aBoolean
show or hide lines

o  showRoot
return true if the root is shown

o  showRoot: aBoolean
controls if the root is to be shown

o  useDefaultIcons
use the default icons if no icon for an item is specified;
** default: true

o  useDefaultIcons: aBoolean
use the default icons if no icon for an item is specified;
** default: true

o  visualBlock
To be polymorph with SelectionInListView

o  visualBlock: aBlockOrNil
To be polymorph with SelectionInListView

actions
o  indicatorAction
the action evaluated if an indicator is pressed; otherwise
if indicators are shown a default action is performed (toggle expand item).

The arguments to the block are:
- no argument
- 1 argument index
- 2 argument index, self

o  indicatorAction: anAction
the action evaluated if an indicator is pressed; otherwise
if indicators are shown a default action is performed (toggle expand item).

The arguments to the block are:
- no argument
- 1 argument index
- 2 argument index, self

change & update
o  indicatorIconChanged
must recompute all

o  indicatorPressedAt: aLnNr
handle indicator pressed action;
if the item changed expanded, we try to show all
new visible children

o  lineChangedAt: aLnNr with: arg
line changed at position; check whether line height changed

o  listChangedInsert: firstAddedIndex nItems: nLines
may have to draw vertical lines above the added items

o  listChangedRemove: aStart toIndex: aStop
test whether last items are deleted;
than we have to redraw lines because of different levels

o  updateFromList: what with: aPara
get the status of <showRoot> from the list

drawing basics
o  drawElementsFrom: start to: stop x: xLeft y: yT w: w
draw the items between start to stop without clearing the background

o  drawLinesFrom: start to: stop x: xL y: yT toX: xR
draw the lines between start to stop without clearing the background

o  drawVericalLineForElement: item minX: xL maxX: xR
draw the vertical line my children are connected to

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  drawVerticalLineForElement: item minX: xL maxX: xR
draw the vertical line my children are connected to

o  validateDrawableIconFor: anItem
returns the icon to be drawn for an item or nil
test the extent of the icon; on error an exception is raised

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

o  buttonPressOrReleaseAtLine: aLnNr x: x y: y
handle a button press or release at a line

o  keyPress: aKey x: x y: y
a key was pressed - handle page-keys here

fetch resources
o  fetchResources
fetch device colors and ..., to avoid reallocation at redraw time;
*** called after a create or snapin to fetch all device resources

initialization & release
o  initStyle
setup viewStyle specifics

o  initialize
(comment from inherited method)
setup default attributes/behavior

private
o  iconFor: anItem
returns an icon or image for the item or nil if the item
provides no image and useDefaultIcons is switched off,
or if anItem returns #none from the icon query.

o  lineHeightFor: anItem
returns the computed line height for an item

o  smallestLevelBetween: start and: stop
returns the smallest level of all items in a range

o  widthOfWidestLineBetween: firstLine and: lastLine
returns the width of the longest line in pixels in a range
- used to optimize scrolling, by limiting the scrolled area;
not for scrollbar or other width related stuff which should be exact.

o  xVisibleOfIconAtLevel: aLevel
returns the visible origin x of the icon at a level.

o  xVisibleOfIndicatorAtLevel: aLevel
returns the visible origin x of the vertical line at a level.

o  xVisibleOfItem: anItem
returns the visible origin x of the item's label.

o  xVisibleOfTextAtLevel: aLevel
returns the visible origin x of the text label at a level.

o  xVisibleOfVerticalLineAt: aLevel
returns the visible origin x of the vertical line assigned to a level.

o  yVisibleOfIndicatorForItem: anItem
return the y of the vertical center of anItem

o  yVisibleOfIndicatorForItemBottom: anItem
return the y of the vertical bottom of anItem

o  yVisibleOfIndicatorForItemTop: anItem
return the y of the vertical top of anItem

queries
o  hasToSkipButtonMultiPress: button x: x y: y
do not process doubleClick actions on indicator

scrolling
o  computeViewOriginXat: aLnrNr
returns the viewOrigin x to make the item at a line visisble

o  makeItemVisible: anItem withMinimumLines: aNumber
handle indicator pressed action;
if the item changed expanded, we try to show all
new visible children

o  makeLineVisible: aLineNumber
make the line horizontally and vertically visible


Examples:


show a hierarchical list
|top sel list item|

list := HierarchicalList new.
item := HierarchicalItem::Example labeled:'Root Item'.

item expand.
list showRoot:false.
list root:item.

top := StandardSystemView new; extent:300@300.
sel := ScrollableView for:HierarchicalListView miniScrollerH:true
                   origin:0.0@0.0 corner:1.0@1.0 in:top.

sel list:list.
sel multipleSelectOk:true.

sel doubleClickAction:[:i| (list at:i) toggleExpand ].
sel   indicatorAction:[:i| (list at:i) toggleExpand ].

top open.
show a hierarchical list; open an editor on reselect a line with label is a string.
|top sel list item|

list := HierarchicalList new.
item := HierarchicalItem::Example labeled:'Root Item'.

item expand.
list showRoot:false.
list root:item.

top := StandardSystemView new; extent:300@300.
sel := ScrollableView for:HierarchicalListView miniScrollerH:true
                   origin:0.0@0.0 corner:1.0@1.0 in:top.

sel list:list.

sel openEditorAction:[:ln :aGC| |field item|
    item  := list at:ln.

    item label isString ifFalse:[
        field := nil
    ] ifTrue:[
        field := EditField new.
        field level:0.
        field acceptOnLostFocus:true.
        field acceptAction:[:x| item label:(field contents) ].
        field font:(aGC font).
        field contents:(item label).
    ].
    field
].

sel multipleSelectOk:true.

sel doubleClickAction:[:i| (list at:i) toggleExpand ].
sel   indicatorAction:[:i| (list at:i) toggleExpand ].

top open.
|top sel list item|

list := HierarchicalList new.
item := HierarchicalItem::Example labeled:'Root Item'.

item expand.
list showRoot:false.
list root:item.

top := StandardSystemView new; extent:300@300.
sel := ScrollableView for:HierarchicalListView miniScrollerH:true
                   origin:0.0@0.0 corner:1.0@1.0 in:top.

sel openIndicator:(ToolbarIconLibrary down22x22Icon).
sel closeIndicator:(ToolbarIconLibrary downRight22x22Icon).
sel showLines:false.

sel list:list.
sel multipleSelectOk:true.
sel alignTextRight:true.
sel doubleClickAction:[:i| (list at:i) toggleExpand ].
sel   indicatorAction:[:i| (list at:i) toggleExpand ].

top open.


ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Thu, 21 Nov 2024 13:11:10 GMT