HierarchicalListView.st
author penk
Wed, 11 Sep 2002 14:54:23 +0200
changeset 2179 e105597b0375
parent 2134 0d7056b5ae06
child 2181 afce4bbf8fdc
permissions -rw-r--r--
on press key left to parent if not expanded
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1431
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
     1
"
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
     2
 COPYRIGHT (c) 1999 by eXept Software AG
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
     3
              All Rights Reserved
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
     4
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
     5
 This software is furnished under a license and may be used
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
     6
 only in accordance with the terms of that license and with the
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
     8
 be provided or otherwise made available to, or used by, any
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
     9
 other person.  No title to or ownership of the software is
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    10
 hereby transferred.
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    11
"
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    12
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    13
1752
1c11b6e4ab37 use isHierarchicalItem instead of hack variable
ca
parents: 1746
diff changeset
    14
"{ Package: 'stx:libwidg2' }"
1c11b6e4ab37 use isHierarchicalItem instead of hack variable
ca
parents: 1746
diff changeset
    15
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
SelectionInListModelView subclass:#HierarchicalListView
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
	instanceVariableNames:'imageInset imageWidth lineMask lineColor showRoot showLines
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
		showLeftIndicators indicatorAction useDefaultIcons icons
1568
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
    19
		openIndicator closeIndicator alignTextRight alignTextRightX
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
    20
		maxWidthOfText'
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
	classVariableNames:''
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
	poolDictionaries:''
1430
ae9e48cc7b9d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1400
diff changeset
    23
	category:'Views-Trees'
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
!HierarchicalListView class methodsFor:'documentation'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
1431
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    28
copyright
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    29
"
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    30
 COPYRIGHT (c) 1999 by eXept Software AG
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    31
              All Rights Reserved
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    32
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    33
 This software is furnished under a license and may be used
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    34
 only in accordance with the terms of that license and with the
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    35
 inclusion of the above copyright notice.   This software may not
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    36
 be provided or otherwise made available to, or used by, any
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    37
 other person.  No title to or ownership of the software is
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    38
 hereby transferred.
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    39
"
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    40
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    41
!
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    42
1757
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
    43
documentation
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
"
1757
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
    45
    This class implements a hierarchical list view based on a
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
    46
    hierachical list.
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
    47
    It provides functionality similar to SelectionInTreeView, but optimizes
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
    48
    redraws, and operates directly upon the model (in contrast to
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
    49
    SelectionInTreeView, which generates a list internally).
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
1757
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
    51
    [Instance variables:]
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
    52
        textStartLeft       <Integer>              inset between icon and text 
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
    53
        imageInset          <Integer>              inset between left side and icon
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
    54
        imageWidth          <Integer>              width of widest icon
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
    55
        lineMask            <Form>                 line mask
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
    56
        lineColor           <Color>                line color
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
    57
        showRoot            <Boolean>              root element is shown or hidden
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
    58
                                                   derives from the hierachical list.
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
    59
        showLines           <Boolean>              show or hide lines
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
    60
        useDefaultIcons     <Boolean>              use the default icons if no icon
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
    61
                                                   for an item is specified
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
    62
        icons               <IdentityDictionary>   list of registered icons;
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
    63
                                                   identifier := <key> value := <icon>
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
    64
        showLeftIndicators  <Boolean>              show or hide indicator for most left items
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
    65
        indicatorAction     <Block>                action evaluated if indicator is pressed
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
    66
        openIndicator       <Icon, Image or Form>  expanded indicator      
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
    67
        closeIndicator      <Icon, Image or Form>  collapsed indicator
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
1757
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
    69
        alignTextRight      <Boolean>              enable disable of align the text right
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
    70
                                                   icon            text
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
    71
                                                        icon       text of child
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
    72
                                                   should be set after creation of the widget!!
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
    73
        alignTextRightX     <Integer>              left x position of aligned right text
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
    74
        maxWidthOfText      <Integer>              keeps the maximum width of a text label
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
    75
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
    76
    [author:]
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
    77
        Claus Atzkern
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
    78
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
    79
    [see also:]
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
    80
        ListModelView
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
    81
        SelectionInListModelView
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
        HierarchicalList
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
        HierarchicalItem
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
1757
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
    87
!
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
    88
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
    89
examples
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
    90
"
1916
3021f70d9211 add example for opening an editor on selected line
ca
parents: 1904
diff changeset
    91
    show a hierarchical list
1757
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
    92
                                                                        [exBegin]
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
    93
    |top sel list item|
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
    94
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
    95
    list := HierarchicalList new.
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
    96
    item := HierarchicalItem::Example labeled:'Root Item'.
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
    97
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
    98
    item expand.
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
    99
    list showRoot:false.
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   100
    list root:item.
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   101
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   102
    top := StandardSystemView new; extent:300@300.
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   103
    sel := ScrollableView for:HierarchicalListView miniScroller:true
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   104
                       origin:0.0@0.0 corner:1.0@1.0 in:top.
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   105
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   106
    sel list:list.
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   107
    sel multipleSelectOk:true.
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   108
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   109
    sel doubleClickAction:[:i| (list at:i) toggleExpand ].
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   110
    sel   indicatorAction:[:i| (list at:i) toggleExpand ].
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   111
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   112
    top open.
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   113
                                                                        [exEnd]
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   114
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   115
1916
3021f70d9211 add example for opening an editor on selected line
ca
parents: 1904
diff changeset
   116
    show a hierarchical list; open an editor on reselect a
3021f70d9211 add example for opening an editor on selected line
ca
parents: 1904
diff changeset
   117
    line with label is a string.
3021f70d9211 add example for opening an editor on selected line
ca
parents: 1904
diff changeset
   118
3021f70d9211 add example for opening an editor on selected line
ca
parents: 1904
diff changeset
   119
                                                                        [exBegin]
3021f70d9211 add example for opening an editor on selected line
ca
parents: 1904
diff changeset
   120
    |top sel list item|
3021f70d9211 add example for opening an editor on selected line
ca
parents: 1904
diff changeset
   121
3021f70d9211 add example for opening an editor on selected line
ca
parents: 1904
diff changeset
   122
    list := HierarchicalList new.
3021f70d9211 add example for opening an editor on selected line
ca
parents: 1904
diff changeset
   123
    item := HierarchicalItem::Example labeled:'Root Item'.
3021f70d9211 add example for opening an editor on selected line
ca
parents: 1904
diff changeset
   124
3021f70d9211 add example for opening an editor on selected line
ca
parents: 1904
diff changeset
   125
    item expand.
3021f70d9211 add example for opening an editor on selected line
ca
parents: 1904
diff changeset
   126
    list showRoot:false.
3021f70d9211 add example for opening an editor on selected line
ca
parents: 1904
diff changeset
   127
    list root:item.
3021f70d9211 add example for opening an editor on selected line
ca
parents: 1904
diff changeset
   128
3021f70d9211 add example for opening an editor on selected line
ca
parents: 1904
diff changeset
   129
    top := StandardSystemView new; extent:300@300.
3021f70d9211 add example for opening an editor on selected line
ca
parents: 1904
diff changeset
   130
    sel := ScrollableView for:HierarchicalListView miniScroller:true
3021f70d9211 add example for opening an editor on selected line
ca
parents: 1904
diff changeset
   131
                       origin:0.0@0.0 corner:1.0@1.0 in:top.
3021f70d9211 add example for opening an editor on selected line
ca
parents: 1904
diff changeset
   132
3021f70d9211 add example for opening an editor on selected line
ca
parents: 1904
diff changeset
   133
    sel list:list.
3021f70d9211 add example for opening an editor on selected line
ca
parents: 1904
diff changeset
   134
3021f70d9211 add example for opening an editor on selected line
ca
parents: 1904
diff changeset
   135
    sel openEditorAction:[:ln :aGC| |field item|
3021f70d9211 add example for opening an editor on selected line
ca
parents: 1904
diff changeset
   136
        item  := list at:ln.
3021f70d9211 add example for opening an editor on selected line
ca
parents: 1904
diff changeset
   137
3021f70d9211 add example for opening an editor on selected line
ca
parents: 1904
diff changeset
   138
        item label isString ifFalse:[
3021f70d9211 add example for opening an editor on selected line
ca
parents: 1904
diff changeset
   139
            field := nil
3021f70d9211 add example for opening an editor on selected line
ca
parents: 1904
diff changeset
   140
        ] ifTrue:[
3021f70d9211 add example for opening an editor on selected line
ca
parents: 1904
diff changeset
   141
            field := EditField new.
3021f70d9211 add example for opening an editor on selected line
ca
parents: 1904
diff changeset
   142
            field level:0.
3021f70d9211 add example for opening an editor on selected line
ca
parents: 1904
diff changeset
   143
            field acceptOnLostFocus:true.
3021f70d9211 add example for opening an editor on selected line
ca
parents: 1904
diff changeset
   144
            field acceptAction:[:x| item label:(field contents) ].
3021f70d9211 add example for opening an editor on selected line
ca
parents: 1904
diff changeset
   145
            field font:(aGC font).
3021f70d9211 add example for opening an editor on selected line
ca
parents: 1904
diff changeset
   146
            field contents:(item label).
3021f70d9211 add example for opening an editor on selected line
ca
parents: 1904
diff changeset
   147
        ].
3021f70d9211 add example for opening an editor on selected line
ca
parents: 1904
diff changeset
   148
        field
3021f70d9211 add example for opening an editor on selected line
ca
parents: 1904
diff changeset
   149
    ].
3021f70d9211 add example for opening an editor on selected line
ca
parents: 1904
diff changeset
   150
3021f70d9211 add example for opening an editor on selected line
ca
parents: 1904
diff changeset
   151
    sel multipleSelectOk:true.
3021f70d9211 add example for opening an editor on selected line
ca
parents: 1904
diff changeset
   152
3021f70d9211 add example for opening an editor on selected line
ca
parents: 1904
diff changeset
   153
    sel doubleClickAction:[:i| (list at:i) toggleExpand ].
3021f70d9211 add example for opening an editor on selected line
ca
parents: 1904
diff changeset
   154
    sel   indicatorAction:[:i| (list at:i) toggleExpand ].
3021f70d9211 add example for opening an editor on selected line
ca
parents: 1904
diff changeset
   155
3021f70d9211 add example for opening an editor on selected line
ca
parents: 1904
diff changeset
   156
    top open.
3021f70d9211 add example for opening an editor on selected line
ca
parents: 1904
diff changeset
   157
                                                                        [exEnd]
3021f70d9211 add example for opening an editor on selected line
ca
parents: 1904
diff changeset
   158
1757
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   159
"
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   160
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   161
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   162
!HierarchicalListView class methodsFor:'resources'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   163
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   164
closeIndicator
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   165
    "returns a little [+] bitmap"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   166
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   167
    <resource: #fileImage>
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   168
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   169
    ^ Icon constantNamed:#plus
1632
d1479a31986e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1624
diff changeset
   170
             ifAbsentPut:[Smalltalk imageFromFileNamed:'plus.xpm' forClass:self]
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   171
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   172
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   173
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   174
1757
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   175
collapsedIcon
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   176
    "returns icon to indicate a collapsed entry
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   177
    "
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   178
    <resource: #fileImage>
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   179
1757
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   180
    ^ Icon constantNamed:#directory
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   181
             ifAbsentPut:[Smalltalk imageFromFileNamed:'dir.xpm' forClass:self]
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   182
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   183
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   184
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   185
emptyIcon
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   186
    "returns icon to indicate an not extendable entry
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   187
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   188
    <resource: #fileImage>
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   189
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   190
    ^ Icon constantNamed:#plainFile
1632
d1479a31986e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1624
diff changeset
   191
             ifAbsentPut:[Smalltalk imageFromFileNamed:'file_plain.xpm' forClass:self]
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   192
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   193
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   194
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   195
expandedIcon
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   196
    "returns icon to indicate an extended entry
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   197
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   198
    <resource: #fileImage>
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   199
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   200
    ^ Icon constantNamed:#directoryOpened
1632
d1479a31986e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1624
diff changeset
   201
             ifAbsentPut:[Smalltalk imageFromFileNamed:'dir_open.xpm' forClass:self]
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   202
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   203
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   204
1757
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   205
openIndicator
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   206
    "returns a little [-] bitmap"
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   207
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   208
    <resource: #fileImage>
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   209
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   210
    ^ Icon constantNamed:#minus
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   211
             ifAbsentPut:[Smalltalk imageFromFileNamed:'minus.xpm' forClass:self]
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   212
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   213
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   214
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   215
!HierarchicalListView methodsFor:'accessing'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   216
1843
61595a6b2e37 handle font changed notification
martin
parents: 1818
diff changeset
   217
font:aFont
61595a6b2e37 handle font changed notification
martin
parents: 1818
diff changeset
   218
    "set a new font
61595a6b2e37 handle font changed notification
martin
parents: 1818
diff changeset
   219
    "
61595a6b2e37 handle font changed notification
martin
parents: 1818
diff changeset
   220
    |root|
61595a6b2e37 handle font changed notification
martin
parents: 1818
diff changeset
   221
61595a6b2e37 handle font changed notification
martin
parents: 1818
diff changeset
   222
    (aFont isNil or:[aFont = font]) ifFalse:[
61595a6b2e37 handle font changed notification
martin
parents: 1818
diff changeset
   223
        (list notNil and:[(root := list root) notNil]) ifTrue:[
61595a6b2e37 handle font changed notification
martin
parents: 1818
diff changeset
   224
            root fontChanged
61595a6b2e37 handle font changed notification
martin
parents: 1818
diff changeset
   225
        ].
61595a6b2e37 handle font changed notification
martin
parents: 1818
diff changeset
   226
        super font:aFont
61595a6b2e37 handle font changed notification
martin
parents: 1818
diff changeset
   227
    ].
61595a6b2e37 handle font changed notification
martin
parents: 1818
diff changeset
   228
!
61595a6b2e37 handle font changed notification
martin
parents: 1818
diff changeset
   229
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   230
list:aList
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   231
    "get the status of <showRoot> from the list
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   232
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   233
    aList notNil ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   234
        showRoot := aList showRoot
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   235
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   236
    super list:aList
1897
5609f92e6d4a do not draw the first vertical line if the rootItem is not visible
ca
parents: 1843
diff changeset
   237
!
5609f92e6d4a do not draw the first vertical line if the rootItem is not visible
ca
parents: 1843
diff changeset
   238
5609f92e6d4a do not draw the first vertical line if the rootItem is not visible
ca
parents: 1843
diff changeset
   239
parentToChildInset
5609f92e6d4a do not draw the first vertical line if the rootItem is not visible
ca
parents: 1843
diff changeset
   240
    "returns the computed inset between parent / child
5609f92e6d4a do not draw the first vertical line if the rootItem is not visible
ca
parents: 1843
diff changeset
   241
    "
5609f92e6d4a do not draw the first vertical line if the rootItem is not visible
ca
parents: 1843
diff changeset
   242
    ^ imageInset + imageWidth
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   243
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   244
1818
fe99c5c721e9 category changes
Claus Gittinger <cg@exept.de>
parents: 1792
diff changeset
   245
!HierarchicalListView methodsFor:'accessing-colors'!
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   246
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   247
lineColor
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   248
    "get the line color
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   249
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   250
    ^ lineColor
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   251
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   252
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   253
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   254
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   255
lineColor:aColor
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   256
    "set the line color
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   257
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   258
    (aColor notNil and:[aColor ~= lineColor]) ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   259
        lineColor := aColor.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   260
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   261
        shown ifTrue:[
2099
64402b3555eb Do not use obsolete methods.
Stefan Vogel <sv@exept.de>
parents: 2094
diff changeset
   262
            lineColor := lineColor onDevice:device.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   263
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   264
            showLines ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   265
                self invalidate
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   266
            ]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   267
        ]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   268
    ]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   269
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   270
1818
fe99c5c721e9 category changes
Claus Gittinger <cg@exept.de>
parents: 1792
diff changeset
   271
!HierarchicalListView methodsFor:'accessing-look'!
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   272
1568
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
   273
alignTextRight
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
   274
    "align the text right
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
   275
    "
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
   276
    ^ alignTextRight
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
   277
!
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
   278
1757
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   279
alignTextRight:aBool
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   280
    "align the text right
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   281
    "
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   282
    alignTextRight := aBool ? false.
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   283
!
1568
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
   284
1904
84155d7a6011 access method for #alignTextRightX
ca
parents: 1898
diff changeset
   285
alignTextRightX
84155d7a6011 access method for #alignTextRightX
ca
parents: 1898
diff changeset
   286
    "returns the minimum used text inset, if text is aligned right.
84155d7a6011 access method for #alignTextRightX
ca
parents: 1898
diff changeset
   287
    "
84155d7a6011 access method for #alignTextRightX
ca
parents: 1898
diff changeset
   288
    ^ alignTextRightX
84155d7a6011 access method for #alignTextRightX
ca
parents: 1898
diff changeset
   289
!
84155d7a6011 access method for #alignTextRightX
ca
parents: 1898
diff changeset
   290
84155d7a6011 access method for #alignTextRightX
ca
parents: 1898
diff changeset
   291
alignTextRightX:aNumber
84155d7a6011 access method for #alignTextRightX
ca
parents: 1898
diff changeset
   292
    "set the minimum used text inset, if text is aligned right.
84155d7a6011 access method for #alignTextRightX
ca
parents: 1898
diff changeset
   293
    "
84155d7a6011 access method for #alignTextRightX
ca
parents: 1898
diff changeset
   294
    aNumber > self parentToChildInset ifTrue:[
84155d7a6011 access method for #alignTextRightX
ca
parents: 1898
diff changeset
   295
        alignTextRightX := aNumber.
84155d7a6011 access method for #alignTextRightX
ca
parents: 1898
diff changeset
   296
84155d7a6011 access method for #alignTextRightX
ca
parents: 1898
diff changeset
   297
        (alignTextRight and:[widthOfContents notNil]) ifTrue:[
84155d7a6011 access method for #alignTextRightX
ca
parents: 1898
diff changeset
   298
            widthOfContents := alignTextRightX + maxWidthOfText.
84155d7a6011 access method for #alignTextRightX
ca
parents: 1898
diff changeset
   299
84155d7a6011 access method for #alignTextRightX
ca
parents: 1898
diff changeset
   300
            shown ifTrue:[
84155d7a6011 access method for #alignTextRightX
ca
parents: 1898
diff changeset
   301
                self invalidate.
84155d7a6011 access method for #alignTextRightX
ca
parents: 1898
diff changeset
   302
                self contentsChanged.
84155d7a6011 access method for #alignTextRightX
ca
parents: 1898
diff changeset
   303
            ]
84155d7a6011 access method for #alignTextRightX
ca
parents: 1898
diff changeset
   304
        ]
84155d7a6011 access method for #alignTextRightX
ca
parents: 1898
diff changeset
   305
    ].
84155d7a6011 access method for #alignTextRightX
ca
parents: 1898
diff changeset
   306
!
84155d7a6011 access method for #alignTextRightX
ca
parents: 1898
diff changeset
   307
2094
71c676b5f061 add icons which are stored under a specific key
ca
parents: 2069
diff changeset
   308
iconAt:aKey ifAbsentPut:aBlock
71c676b5f061 add icons which are stored under a specific key
ca
parents: 2069
diff changeset
   309
    "return the icon stored under a key; if not present,the
71c676b5f061 add icons which are stored under a specific key
ca
parents: 2069
diff changeset
   310
     result of the block if not nil is stored under the key
71c676b5f061 add icons which are stored under a specific key
ca
parents: 2069
diff changeset
   311
     and returned.
71c676b5f061 add icons which are stored under a specific key
ca
parents: 2069
diff changeset
   312
    "
71c676b5f061 add icons which are stored under a specific key
ca
parents: 2069
diff changeset
   313
    |icon|
71c676b5f061 add icons which are stored under a specific key
ca
parents: 2069
diff changeset
   314
71c676b5f061 add icons which are stored under a specific key
ca
parents: 2069
diff changeset
   315
    icon := icons at:aKey ifAbsent:nil.
71c676b5f061 add icons which are stored under a specific key
ca
parents: 2069
diff changeset
   316
    icon ifNotNil:[^ icon].
71c676b5f061 add icons which are stored under a specific key
ca
parents: 2069
diff changeset
   317
71c676b5f061 add icons which are stored under a specific key
ca
parents: 2069
diff changeset
   318
    icon := aBlock value.
71c676b5f061 add icons which are stored under a specific key
ca
parents: 2069
diff changeset
   319
    icon ifNil:[^ nil].
71c676b5f061 add icons which are stored under a specific key
ca
parents: 2069
diff changeset
   320
71c676b5f061 add icons which are stored under a specific key
ca
parents: 2069
diff changeset
   321
    realized ifTrue:[
71c676b5f061 add icons which are stored under a specific key
ca
parents: 2069
diff changeset
   322
        icon := self imageOnDevice:icon
71c676b5f061 add icons which are stored under a specific key
ca
parents: 2069
diff changeset
   323
    ].
71c676b5f061 add icons which are stored under a specific key
ca
parents: 2069
diff changeset
   324
    icons at:aKey put:icon.
71c676b5f061 add icons which are stored under a specific key
ca
parents: 2069
diff changeset
   325
  ^ icon
71c676b5f061 add icons which are stored under a specific key
ca
parents: 2069
diff changeset
   326
!
71c676b5f061 add icons which are stored under a specific key
ca
parents: 2069
diff changeset
   327
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   328
registerKeysAndIcons:aDictionary
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   329
    "register icons by key and value derived from a directory
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   330
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   331
    |image|
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   332
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   333
    (aDictionary isNil or:[aDictionary isEmpty]) ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   334
        ^ self
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   335
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   336
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   337
    aDictionary keysAndValuesDo:[:aKey :anImage|
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   338
        (image := self imageOnDevice:anImage) notNil ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   339
            icons at:aKey put:image
1746
0a4f786f8c9a icon handling; default icons can be undefined
ca
parents: 1738
diff changeset
   340
        ] ifFalse:[
0a4f786f8c9a icon handling; default icons can be undefined
ca
parents: 1738
diff changeset
   341
            icons removeKey:aKey ifAbsent:nil
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   342
        ]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   343
    ]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   344
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   345
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   346
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   347
showLeftIndicators
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   348
    "show or hide the indicators for the most left items
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   349
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   350
    ^ showLeftIndicators
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   351
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   352
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   353
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   354
showLeftIndicators:aState
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   355
    "show or hide the indicators for the most left items
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   356
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   357
    aState ~~ showLeftIndicators ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   358
        showLeftIndicators := aState.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   359
        self invalidate
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   360
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   361
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   362
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   363
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   364
showLines
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   365
    "returns true if lines are shown
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   366
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   367
  ^ showLines
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   368
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   369
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   370
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   371
showLines:aState
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   372
    "show or hide lines
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   373
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   374
    aState ~~ showLines ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   375
        showLines := aState.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   376
        self invalidate
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   377
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   378
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   379
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   380
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   381
useDefaultIcons
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   382
    "use the default icons if no icon for an item is specified;
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   383
     ** default: true
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   384
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   385
    ^ useDefaultIcons
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   386
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   387
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   388
useDefaultIcons:aBool
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   389
    "use the default icons if no icon for an item is specified;
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   390
     ** default: true
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   391
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   392
    useDefaultIcons ~~ aBool ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   393
        useDefaultIcons := aBool.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   394
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   395
        shown ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   396
            self invalidate
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   397
        ]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   398
    ]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   399
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   400
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   401
!HierarchicalListView methodsFor:'actions'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   402
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   403
indicatorAction
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   404
    "if the action is not nil, indicators are shown and a click on the indicator
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   405
     will evaluate the action with none or one argument, the index into the list
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   406
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   407
    ^ indicatorAction
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   408
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   409
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   410
indicatorAction:anAction
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   411
    "if the action is not nil, indicators are shown and a click on the indicator
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   412
     will evaluate the action with none or one argument, the index into the list
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   413
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   414
    |wasNilBefore|
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   415
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   416
    wasNilBefore    := indicatorAction isNil.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   417
    indicatorAction := anAction.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   418
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   419
    wasNilBefore == (anAction isNil) ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   420
        self invalidate
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   421
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   422
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   423
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   424
!HierarchicalListView methodsFor:'change & update'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   425
1782
4fa475b5037e allow space for indicatationPressed action
ca
parents: 1779
diff changeset
   426
indicatorPressedAt:aLnNr
1783
ffe767ea66ea check whether children exists before calling indicatorPressed action
ca
parents: 1782
diff changeset
   427
    |item|
ffe767ea66ea check whether children exists before calling indicatorPressed action
ca
parents: 1782
diff changeset
   428
ffe767ea66ea check whether children exists before calling indicatorPressed action
ca
parents: 1782
diff changeset
   429
    indicatorAction notNil ifTrue:[
ffe767ea66ea check whether children exists before calling indicatorPressed action
ca
parents: 1782
diff changeset
   430
        item := list at:aLnNr ifAbsent:nil.
ffe767ea66ea check whether children exists before calling indicatorPressed action
ca
parents: 1782
diff changeset
   431
ffe767ea66ea check whether children exists before calling indicatorPressed action
ca
parents: 1782
diff changeset
   432
        (item notNil and:[item hasChildren]) ifTrue:[
2069
7891c7d3af69 use new #perform:withOptionalArgument:
Claus Gittinger <cg@exept.de>
parents: 2049
diff changeset
   433
            indicatorAction valueWithOptionalArgument:aLnNr
1782
4fa475b5037e allow space for indicatationPressed action
ca
parents: 1779
diff changeset
   434
        ]
4fa475b5037e allow space for indicatationPressed action
ca
parents: 1779
diff changeset
   435
    ]
4fa475b5037e allow space for indicatationPressed action
ca
parents: 1779
diff changeset
   436
!
4fa475b5037e allow space for indicatationPressed action
ca
parents: 1779
diff changeset
   437
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   438
lineChangedAt:aLnNr with:arg
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   439
    "line changed at position; check whether line height changed
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   440
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   441
    |item
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   442
     lv "{ Class:SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   443
     x0 "{ Class:SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   444
     x1 "{ Class:SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   445
     h  "{ Class:SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   446
     y0 "{ Class:SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   447
     y1 "{ Class:SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   448
    |
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   449
1399
da1eed642569 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1391
diff changeset
   450
    (arg == #icon or:[arg == #hierarchy]) ifFalse:[
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   451
        ^ super lineChangedAt:aLnNr with:arg
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   452
    ].
1568
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
   453
    shown ifFalse:[^ self].
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
   454
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   455
    y0 := (self yVisibleOfLine:aLnNr)       max:margin.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   456
    y1 := (self yVisibleOfLine:(aLnNr + 1)) min:(height - margin).
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   457
1399
da1eed642569 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1391
diff changeset
   458
    (h := y1 - y0) > 0 ifTrue:[
da1eed642569 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1391
diff changeset
   459
        x0 := margin.
da1eed642569 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1391
diff changeset
   460
        x1 := width - margin.
da1eed642569 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1391
diff changeset
   461
da1eed642569 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1391
diff changeset
   462
        (item := list at:aLnNr ifAbsent:nil) isNil ifFalse:[
da1eed642569 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1391
diff changeset
   463
            lv := item level.
1570
c8baa4a17043 support configuration of length of vertical line
ca
parents: 1568
diff changeset
   464
            x1 := (self xOfStringLevel:lv) - (textStartLeft // 2).
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   465
1399
da1eed642569 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1391
diff changeset
   466
            arg == #hierarchy ifTrue:[
da1eed642569 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1391
diff changeset
   467
                x0 := self xOfFigureLevel:(lv -1).
1570
c8baa4a17043 support configuration of length of vertical line
ca
parents: 1568
diff changeset
   468
            ] ifFalse:[
c8baa4a17043 support configuration of length of vertical line
ca
parents: 1568
diff changeset
   469
                x0 := self xOfFigureLevel:lv
1399
da1eed642569 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1391
diff changeset
   470
            ].
da1eed642569 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1391
diff changeset
   471
            x0 := x0 max:margin.
da1eed642569 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1391
diff changeset
   472
            x1 := x1 min:(width - margin).
1568
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
   473
            x1 > x0 ifFalse:[^ self]
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
   474
        ].
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
   475
        self repairDamage.
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
   476
        self invalidate:(Rectangle left:x0 top:y0 width:(x1 - x0) height:h) 
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
   477
              repairNow:true.
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
   478
    ]
1976
1788b0045176 bug fix when adding new elements; must draw vertical lines above
ca
parents: 1916
diff changeset
   479
!
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   480
1976
1788b0045176 bug fix when adding new elements; must draw vertical lines above
ca
parents: 1916
diff changeset
   481
listChangedInsert:firstAddedIndex nItems:nLines
1788b0045176 bug fix when adding new elements; must draw vertical lines above
ca
parents: 1916
diff changeset
   482
    "must draw vertical lines above the added items
1788b0045176 bug fix when adding new elements; must draw vertical lines above
ca
parents: 1916
diff changeset
   483
    "
1788b0045176 bug fix when adding new elements; must draw vertical lines above
ca
parents: 1916
diff changeset
   484
    |item prnt idx level yTop yBot xLft rec start maxY|
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   485
1976
1788b0045176 bug fix when adding new elements; must draw vertical lines above
ca
parents: 1916
diff changeset
   486
    super listChangedInsert:firstAddedIndex nItems:nLines.
1788b0045176 bug fix when adding new elements; must draw vertical lines above
ca
parents: 1916
diff changeset
   487
1788b0045176 bug fix when adding new elements; must draw vertical lines above
ca
parents: 1916
diff changeset
   488
    (     shown
1788b0045176 bug fix when adding new elements; must draw vertical lines above
ca
parents: 1916
diff changeset
   489
     and:[showLines
1788b0045176 bug fix when adding new elements; must draw vertical lines above
ca
parents: 1916
diff changeset
   490
     and:[firstAddedIndex > 1
1788b0045176 bug fix when adding new elements; must draw vertical lines above
ca
parents: 1916
diff changeset
   491
     and:[nLines ~~ 0
1788b0045176 bug fix when adding new elements; must draw vertical lines above
ca
parents: 1916
diff changeset
   492
     and:[(item := list at:firstAddedIndex ifAbsent:nil) notNil
1788b0045176 bug fix when adding new elements; must draw vertical lines above
ca
parents: 1916
diff changeset
   493
     and:[(level := item level) > 1]]]]]
1788b0045176 bug fix when adding new elements; must draw vertical lines above
ca
parents: 1916
diff changeset
   494
    ) ifFalse:[
1788b0045176 bug fix when adding new elements; must draw vertical lines above
ca
parents: 1916
diff changeset
   495
         ^ self.
1788b0045176 bug fix when adding new elements; must draw vertical lines above
ca
parents: 1916
diff changeset
   496
    ].
1788b0045176 bug fix when adding new elements; must draw vertical lines above
ca
parents: 1916
diff changeset
   497
    xLft := (self xOfFigureLevel:(level - 1)) + (imageWidth // 2) - 1.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   498
1976
1788b0045176 bug fix when adding new elements; must draw vertical lines above
ca
parents: 1916
diff changeset
   499
    (xLft > margin and:[xLft < (width - margin)]) ifFalse:[
1788b0045176 bug fix when adding new elements; must draw vertical lines above
ca
parents: 1916
diff changeset
   500
        ^ self
1788b0045176 bug fix when adding new elements; must draw vertical lines above
ca
parents: 1916
diff changeset
   501
    ].
1788b0045176 bug fix when adding new elements; must draw vertical lines above
ca
parents: 1916
diff changeset
   502
    start := firstAddedIndex - 1.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   503
1976
1788b0045176 bug fix when adding new elements; must draw vertical lines above
ca
parents: 1916
diff changeset
   504
    start to:1 by:-1 do:[:i| |el|
1788b0045176 bug fix when adding new elements; must draw vertical lines above
ca
parents: 1916
diff changeset
   505
        el := list at:i.
1399
da1eed642569 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1391
diff changeset
   506
1976
1788b0045176 bug fix when adding new elements; must draw vertical lines above
ca
parents: 1916
diff changeset
   507
        el level <= level ifTrue:[
1788b0045176 bug fix when adding new elements; must draw vertical lines above
ca
parents: 1916
diff changeset
   508
            i == start ifTrue:[^ self].
1788b0045176 bug fix when adding new elements; must draw vertical lines above
ca
parents: 1916
diff changeset
   509
1788b0045176 bug fix when adding new elements; must draw vertical lines above
ca
parents: 1916
diff changeset
   510
            yTop := (self yVisibleOfLine:i + 1) max:margin.
1788b0045176 bug fix when adding new elements; must draw vertical lines above
ca
parents: 1916
diff changeset
   511
            maxY := height - margin.
1788b0045176 bug fix when adding new elements; must draw vertical lines above
ca
parents: 1916
diff changeset
   512
1788b0045176 bug fix when adding new elements; must draw vertical lines above
ca
parents: 1916
diff changeset
   513
            yTop < maxY ifTrue:[
1788b0045176 bug fix when adding new elements; must draw vertical lines above
ca
parents: 1916
diff changeset
   514
                yBot := (self yVisibleOfLine:firstAddedIndex) - 1 min:maxY.
1788b0045176 bug fix when adding new elements; must draw vertical lines above
ca
parents: 1916
diff changeset
   515
                self invalidate:(Rectangle left:xLft top:yTop width:3 height:(yBot - yTop))
1788b0045176 bug fix when adding new elements; must draw vertical lines above
ca
parents: 1916
diff changeset
   516
            ].
1788b0045176 bug fix when adding new elements; must draw vertical lines above
ca
parents: 1916
diff changeset
   517
            ^ self
1788b0045176 bug fix when adding new elements; must draw vertical lines above
ca
parents: 1916
diff changeset
   518
        ]
1788b0045176 bug fix when adding new elements; must draw vertical lines above
ca
parents: 1916
diff changeset
   519
    ].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   520
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   521
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   522
update:what with:aPara from:chgObj
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   523
    "get the status of <showRoot> from the list
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   524
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   525
    chgObj == list ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   526
        showRoot ~~ list showRoot ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   527
            showRoot := list showRoot.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   528
            self invalidate.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   529
        ]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   530
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   531
    super update:what with:aPara from:chgObj
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   532
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   533
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   534
!HierarchicalListView methodsFor:'drawing basics'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   535
1757
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   536
displayElement:anItem x:x y:y h:h
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   537
    "draw a label at x/y; fg/bg colors are already set
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   538
    "
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   539
    anItem displayOn:self x:x y:y h:h
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   540
1399
da1eed642569 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1391
diff changeset
   541
!
da1eed642569 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1391
diff changeset
   542
1568
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
   543
drawElementsFrom:start to:stop x:xLeft y:yT w:w
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   544
    "draw the items between start to stop without clearing the background
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   545
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   546
    |item prevItem parent icon showIndc showIcon showText nxtPrnt
2049
ad5f350ae2c2 checkin from browser
ca
parents: 1976
diff changeset
   547
     iconExtent
1568
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
   548
     yTop      "{ Class:SmallInteger }"
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
   549
     yCtr      "{ Class:SmallInteger }"
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
   550
     yBot      "{ Class:SmallInteger }"
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   551
1568
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
   552
     xIndc     "{ Class:SmallInteger }"
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
   553
     xIcon     "{ Class:SmallInteger }"
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
   554
     xText     "{ Class:SmallInteger }"
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
   555
     xDeltaIT  "{ Class:SmallInteger }"
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
   556
     xL        "{ Class:SmallInteger }"
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
   557
     xR        "{ Class:SmallInteger }"
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
   558
     height    "{ Class:SmallInteger }"
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   559
1568
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
   560
     widthLvl  "{ Class:SmallInteger }"
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
   561
     insetTxt  "{ Class:SmallInteger }"
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   562
1568
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
   563
     offIndcX  "{ Class:SmallInteger }"
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
   564
     offIndcY  "{ Class:SmallInteger }"
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
   565
     offIconX  "{ Class:SmallInteger }"
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
   566
     iconWidth "{ Class:SmallInteger }"
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
   567
     iconRgtX  "{ Class:SmallInteger }"
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   568
    |
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   569
    widthLvl := imageInset    + imageWidth.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   570
    insetTxt := textStartLeft + imageWidth.
1568
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
   571
    xL       := xLeft.
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
   572
    xR       := xL + w.
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
   573
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
   574
    alignTextRight ifTrue:[
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
   575
        xText    := alignTextRightX - (viewOrigin x).
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
   576
        showText := xText < xR.
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
   577
    ].
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
   578
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   579
    offIconX := self xOfFigureLevel:0.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   580
    showIndc := false.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   581
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   582
    indicatorAction notNil ifTrue:[
2049
ad5f350ae2c2 checkin from browser
ca
parents: 1976
diff changeset
   583
        offIndcX := offIndcY := 0.
ad5f350ae2c2 checkin from browser
ca
parents: 1976
diff changeset
   584
        openIndicator notNil ifTrue:[
ad5f350ae2c2 checkin from browser
ca
parents: 1976
diff changeset
   585
            iconExtent     := openIndicator extent // 2.
ad5f350ae2c2 checkin from browser
ca
parents: 1976
diff changeset
   586
            offIndcX := imageWidth // 2 - widthLvl.
ad5f350ae2c2 checkin from browser
ca
parents: 1976
diff changeset
   587
            offIndcX := offIndcX - iconExtent x.
ad5f350ae2c2 checkin from browser
ca
parents: 1976
diff changeset
   588
            offIndcY := iconExtent y.
ad5f350ae2c2 checkin from browser
ca
parents: 1976
diff changeset
   589
        ]
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   590
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   591
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   592
    showLines ifTrue:[
1399
da1eed642569 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1391
diff changeset
   593
        self drawLinesFrom:start to:stop x:xL y:yT toX:xR
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   594
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   595
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   596
    parent   := 4711.   "/ to force a recompute
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   597
    prevItem := 4711.   "/ to force a recomputation of the level
1399
da1eed642569 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1391
diff changeset
   598
    yBot     := yT.
1756
f0f9ae674364 supress warnings
ca
parents: 1752
diff changeset
   599
    xIcon    := offIconX.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   600
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   601
    start to:stop do:[:anIndex|
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   602
        (item := list at:anIndex ifAbsent:nil) isNil ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   603
            ^ self      "/ list changed
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   604
        ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   605
        yTop := yBot.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   606
        yBot := self yVisibleOfLine:(anIndex + 1).
1532
56e0fafc4349 change display protocol for item
Claus Gittinger <cg@exept.de>
parents: 1509
diff changeset
   607
        height := yBot - yTop.
56e0fafc4349 change display protocol for item
Claus Gittinger <cg@exept.de>
parents: 1509
diff changeset
   608
56e0fafc4349 change display protocol for item
Claus Gittinger <cg@exept.de>
parents: 1509
diff changeset
   609
        yCtr := yTop + (height // 2).
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   610
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   611
        (nxtPrnt := item parent) ~~ parent ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   612
            parent := nxtPrnt.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   613
            xIcon  := prevItem == parent ifTrue:[xIcon + widthLvl]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   614
                                        ifFalse:[item level * widthLvl + offIconX].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   615
1568
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
   616
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
   617
            alignTextRight ifFalse:[
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
   618
                xText    := xIcon + insetTxt.
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
   619
                showText := xText < xR.
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
   620
            ].
1399
da1eed642569 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1391
diff changeset
   621
            showIcon := xIcon < xR and:[xText > xL].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   622
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   623
            indicatorAction notNil ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   624
                xIndc := xIcon + offIndcX.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   625
1756
f0f9ae674364 supress warnings
ca
parents: 1752
diff changeset
   626
                (xIcon > xL and:[xIndc < xR]) ifTrue:[
f0f9ae674364 supress warnings
ca
parents: 1752
diff changeset
   627
                    showIndc := parent notNil or:[showLeftIndicators]
f0f9ae674364 supress warnings
ca
parents: 1752
diff changeset
   628
                ] ifFalse:[
f0f9ae674364 supress warnings
ca
parents: 1752
diff changeset
   629
                    showIndc := false
f0f9ae674364 supress warnings
ca
parents: 1752
diff changeset
   630
                ]
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   631
            ]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   632
        ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   633
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   634
        (showIcon and:[(icon := self figureFor:item) notNil]) ifTrue:[
1568
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
   635
            iconWidth := icon width.
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
   636
            iconRgtX  := xIcon + iconWidth.
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
   637
            xDeltaIT  := xText - textStartLeft - iconRgtX.
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
   638
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
   639
            xDeltaIT < 0 ifTrue:[
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
   640
                alignTextRightX := alignTextRightX - xDeltaIT.
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
   641
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
   642
                alignTextRight ifFalse:[
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
   643
                    imageWidth := iconWidth.
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
   644
                    widthOfContents := widthOfContents - xDeltaIT.
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
   645
                ] ifTrue:[
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
   646
                    widthOfContents := alignTextRightX + maxWidthOfText
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
   647
                ].
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
   648
                self contentsChanged.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   649
                StopRedrawSignal raise
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   650
            ].
1568
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
   651
            iconRgtX > xL ifTrue:[
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
   652
                self displayForm:icon x:xIcon y:(yCtr - (icon height // 2))
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
   653
            ]
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   654
        ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   655
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   656
        showText ifTrue:[
1532
56e0fafc4349 change display protocol for item
Claus Gittinger <cg@exept.de>
parents: 1509
diff changeset
   657
            self drawLabelAt:anIndex x:xText y:yTop h:height
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   658
        ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   659
        (showIndc and:[item hasChildren]) ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   660
            icon := item isExpanded ifTrue:[openIndicator] ifFalse:[closeIndicator].
2049
ad5f350ae2c2 checkin from browser
ca
parents: 1976
diff changeset
   661
            icon notNil ifTrue:[
ad5f350ae2c2 checkin from browser
ca
parents: 1976
diff changeset
   662
                self displayForm:icon x:xIndc y:(yCtr - offIndcY)
ad5f350ae2c2 checkin from browser
ca
parents: 1976
diff changeset
   663
            ]
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   664
        ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   665
        prevItem := item.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   666
    ]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   667
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   668
1399
da1eed642569 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1391
diff changeset
   669
drawLinesFrom:start to:stop x:xL y:yT toX:xR
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   670
    "draw the lines between start to stop without clearing the background
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   671
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   672
    |item prevItem parent p1 p2 showVLines showHLine lv nxtPrnt
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   673
     showRootNot isFirst buildInArray
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   674
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   675
     x        "{ Class:SmallInteger }"
1570
c8baa4a17043 support configuration of length of vertical line
ca
parents: 1568
diff changeset
   676
     xText    "{ Class:SmallInteger }"
c8baa4a17043 support configuration of length of vertical line
ca
parents: 1568
diff changeset
   677
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   678
     y        "{ Class:SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   679
     yTop     "{ Class:SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   680
     yBot     "{ Class:SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   681
     yCtr     "{ Class:SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   682
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   683
     begHLnY  "{ Class:SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   684
     runHLnY  "{ Class:SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   685
     begHLnX  "{ Class:SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   686
     endHLnX  "{ Class:SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   687
1897
5609f92e6d4a do not draw the first vertical line if the rootItem is not visible
ca
parents: 1843
diff changeset
   688
     widthLvl  "{ Class:SmallInteger }"
5609f92e6d4a do not draw the first vertical line if the rootItem is not visible
ca
parents: 1843
diff changeset
   689
     offsHLnX  "{ Class:SmallInteger }"
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   690
1897
5609f92e6d4a do not draw the first vertical line if the rootItem is not visible
ca
parents: 1843
diff changeset
   691
     level     "{ Class:SmallInteger }"
5609f92e6d4a do not draw the first vertical line if the rootItem is not visible
ca
parents: 1843
diff changeset
   692
     startLvI  "{ Class:SmallInteger }"
5609f92e6d4a do not draw the first vertical line if the rootItem is not visible
ca
parents: 1843
diff changeset
   693
     startLvX  "{ Class:SmallInteger }"
5609f92e6d4a do not draw the first vertical line if the rootItem is not visible
ca
parents: 1843
diff changeset
   694
     limitLvI  "{ Class:SmallInteger }"
5609f92e6d4a do not draw the first vertical line if the rootItem is not visible
ca
parents: 1843
diff changeset
   695
     limitLvX  "{ Class:SmallInteger }"
5609f92e6d4a do not draw the first vertical line if the rootItem is not visible
ca
parents: 1843
diff changeset
   696
     imgHWdt   "{ Class:SmallInteger }"
5609f92e6d4a do not draw the first vertical line if the rootItem is not visible
ca
parents: 1843
diff changeset
   697
     minXVLine "{ Class:SmallInteger }"
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   698
    |
1792
26aa6dc38278 draw vertical line not into icon if no children defined
ca
parents: 1784
diff changeset
   699
    imgHWdt  := imageWidth // 2.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   700
    widthLvl := imageInset + imageWidth.
1792
26aa6dc38278 draw vertical line not into icon if no children defined
ca
parents: 1784
diff changeset
   701
    offsHLnX := imgHWdt + (self xOfFigureLevel:-1).
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   702
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   703
    parent   := 4711.                           "/ to force a recompute
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   704
    prevItem := 4711.                           "/ to force a recomputation of the level
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   705
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   706
    self setMaskOrigin:(self viewOrigin + (0 @ 1) \\ (lineMask extent)).
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   707
    self paint:lineColor on:bgColor.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   708
    self mask:lineMask.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   709
    startLvI := self smallestLevelBetween:start and:stop.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   710
    startLvX := self xOfFigureLevel:startLvI.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   711
    limitLvI := 2.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   712
    limitLvX := limitLvI * widthLvl + offsHLnX.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   713
1897
5609f92e6d4a do not draw the first vertical line if the rootItem is not visible
ca
parents: 1843
diff changeset
   714
    showRoot ifFalse:[
5609f92e6d4a do not draw the first vertical line if the rootItem is not visible
ca
parents: 1843
diff changeset
   715
        minXVLine := (self xOfFigureLevel:2) - 2.       "/ tolerance
5609f92e6d4a do not draw the first vertical line if the rootItem is not visible
ca
parents: 1843
diff changeset
   716
    ] ifTrue:[
5609f92e6d4a do not draw the first vertical line if the rootItem is not visible
ca
parents: 1843
diff changeset
   717
        minXVLine := 0
5609f92e6d4a do not draw the first vertical line if the rootItem is not visible
ca
parents: 1843
diff changeset
   718
    ].
5609f92e6d4a do not draw the first vertical line if the rootItem is not visible
ca
parents: 1843
diff changeset
   719
1567
f57fafbb7049 bug fix when drawing vertical lines
ca
parents: 1566
diff changeset
   720
    showRootNot  := showRoot not.
f57fafbb7049 bug fix when drawing vertical lines
ca
parents: 1566
diff changeset
   721
    yBot         := yT.
f57fafbb7049 bug fix when drawing vertical lines
ca
parents: 1566
diff changeset
   722
    begHLnY      := runHLnY := yT.
1756
f0f9ae674364 supress warnings
ca
parents: 1752
diff changeset
   723
    endHLnX      := limitLvX.
f0f9ae674364 supress warnings
ca
parents: 1752
diff changeset
   724
    level        := 1.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   725
1570
c8baa4a17043 support configuration of length of vertical line
ca
parents: 1568
diff changeset
   726
    alignTextRight ifTrue:[
c8baa4a17043 support configuration of length of vertical line
ca
parents: 1568
diff changeset
   727
        xText := alignTextRightX - (viewOrigin x) - textStartLeft.
c8baa4a17043 support configuration of length of vertical line
ca
parents: 1568
diff changeset
   728
    ].
c8baa4a17043 support configuration of length of vertical line
ca
parents: 1568
diff changeset
   729
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   730
    start to:stop do:[:anIndex|
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   731
        (item := list at:anIndex ifAbsent:nil) isNil ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   732
            ^ self mask:nil     "/ list changed
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   733
        ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   734
        yTop := yBot.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   735
        yBot := self yVisibleOfLine:(anIndex + 1).
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   736
        yCtr := yTop + (yBot - yTop // 2).
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   737
        anIndex == 1 ifTrue:[ begHLnY := runHLnY := yCtr ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   738
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   739
        (nxtPrnt := item parent) ~~ parent ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   740
            parent := nxtPrnt.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   741
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   742
            prevItem == parent ifTrue:[
1567
f57fafbb7049 bug fix when drawing vertical lines
ca
parents: 1566
diff changeset
   743
                level   := level + 1.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   744
                begHLnX := endHLnX.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   745
            ] ifFalse:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   746
                level   := item level.
1567
f57fafbb7049 bug fix when drawing vertical lines
ca
parents: 1566
diff changeset
   747
                begHLnX := level * widthLvl + offsHLnX.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   748
            ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   749
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   750
            isFirst    := parent isNil or:[(showRootNot and:[level == 2])].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   751
            endHLnX    := begHLnX + widthLvl.
1399
da1eed642569 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1391
diff changeset
   752
            showVLines := begHLnX >= xL and:[level > 1].
1570
c8baa4a17043 support configuration of length of vertical line
ca
parents: 1568
diff changeset
   753
c8baa4a17043 support configuration of length of vertical line
ca
parents: 1568
diff changeset
   754
            alignTextRight ifFalse:[
c8baa4a17043 support configuration of length of vertical line
ca
parents: 1568
diff changeset
   755
                xText := endHLnX + (widthLvl // 2).
c8baa4a17043 support configuration of length of vertical line
ca
parents: 1568
diff changeset
   756
            ].
c8baa4a17043 support configuration of length of vertical line
ca
parents: 1568
diff changeset
   757
            showHLine := (xL < xText and:[xR > begHLnX]).
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   758
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   759
            (showHLine and:[isFirst]) ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   760
                showHLine := showLeftIndicators and:[indicatorAction notNil]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   761
            ]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   762
        ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   763
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   764
        showHLine ifTrue:[
1570
c8baa4a17043 support configuration of length of vertical line
ca
parents: 1568
diff changeset
   765
            item drawHorizontalLineUpToText ifTrue:[
c8baa4a17043 support configuration of length of vertical line
ca
parents: 1568
diff changeset
   766
                p1 := xText
c8baa4a17043 support configuration of length of vertical line
ca
parents: 1568
diff changeset
   767
            ] ifFalse:[
1792
26aa6dc38278 draw vertical line not into icon if no children defined
ca
parents: 1784
diff changeset
   768
                item hasChildren ifTrue:[
26aa6dc38278 draw vertical line not into icon if no children defined
ca
parents: 1784
diff changeset
   769
                    p1 := endHLnX.
26aa6dc38278 draw vertical line not into icon if no children defined
ca
parents: 1784
diff changeset
   770
                ] ifFalse:[
1897
5609f92e6d4a do not draw the first vertical line if the rootItem is not visible
ca
parents: 1843
diff changeset
   771
                    (showRoot not and:[item parent isRootItem]) ifTrue:[
5609f92e6d4a do not draw the first vertical line if the rootItem is not visible
ca
parents: 1843
diff changeset
   772
                        p1 := xL - 1    "/ do not draw the horizontal line
5609f92e6d4a do not draw the first vertical line if the rootItem is not visible
ca
parents: 1843
diff changeset
   773
                    ] ifFalse:[
5609f92e6d4a do not draw the first vertical line if the rootItem is not visible
ca
parents: 1843
diff changeset
   774
                        p1 := begHLnX + imgHWdt
5609f92e6d4a do not draw the first vertical line if the rootItem is not visible
ca
parents: 1843
diff changeset
   775
                    ]
1792
26aa6dc38278 draw vertical line not into icon if no children defined
ca
parents: 1784
diff changeset
   776
                ]
1570
c8baa4a17043 support configuration of length of vertical line
ca
parents: 1568
diff changeset
   777
            ].
1792
26aa6dc38278 draw vertical line not into icon if no children defined
ca
parents: 1784
diff changeset
   778
            xL < p1 ifTrue:[
1570
c8baa4a17043 support configuration of length of vertical line
ca
parents: 1568
diff changeset
   779
                self displayLineFromX:begHLnX y:yCtr toX:p1 y:yCtr
c8baa4a17043 support configuration of length of vertical line
ca
parents: 1568
diff changeset
   780
            ]
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   781
        ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   782
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   783
        showVLines ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   784
            y  := (parent last == item) ifTrue:[yCtr] ifFalse:[yBot].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   785
            x  := begHLnX.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   786
            p2 := parent.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   787
            lv := level - 1.
1897
5609f92e6d4a do not draw the first vertical line if the rootItem is not visible
ca
parents: 1843
diff changeset
   788
5609f92e6d4a do not draw the first vertical line if the rootItem is not visible
ca
parents: 1843
diff changeset
   789
            x >= minXVLine ifTrue:[
5609f92e6d4a do not draw the first vertical line if the rootItem is not visible
ca
parents: 1843
diff changeset
   790
                self displayLineFromX:x y:runHLnY toX:x y:y.
5609f92e6d4a do not draw the first vertical line if the rootItem is not visible
ca
parents: 1843
diff changeset
   791
            ].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   792
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   793
            [((p1 := p2 parent) notNil and:[(x := x - widthLvl) >= limitLvX])] whileTrue:[
1399
da1eed642569 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1391
diff changeset
   794
                (p1 last ~~ p2 and:[x <= xR]) ifTrue:[
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   795
                    x >= startLvX ifTrue:[
1897
5609f92e6d4a do not draw the first vertical line if the rootItem is not visible
ca
parents: 1843
diff changeset
   796
                        x >= minXVLine ifTrue:[
5609f92e6d4a do not draw the first vertical line if the rootItem is not visible
ca
parents: 1843
diff changeset
   797
                            self displayLineFromX:x y:(yTop - 1) toX:x y:yBot
5609f92e6d4a do not draw the first vertical line if the rootItem is not visible
ca
parents: 1843
diff changeset
   798
                        ]
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   799
                    ] ifFalse:[
1567
f57fafbb7049 bug fix when drawing vertical lines
ca
parents: 1566
diff changeset
   800
                        buildInArray isNil ifTrue:[buildInArray := Array new:startLvI].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   801
                        buildInArray at:lv put:yBot
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   802
                    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   803
                ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   804
                lv := lv - 1.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   805
                p2 := p1
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   806
            ]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   807
        ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   808
        prevItem := item.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   809
        runHLnY  := yCtr.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   810
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   811
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   812
    "/
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   813
    "/ draw outstanding verical lines to left
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   814
    "/
1897
5609f92e6d4a do not draw the first vertical line if the rootItem is not visible
ca
parents: 1843
diff changeset
   815
    x := minXVLine max:xL.
5609f92e6d4a do not draw the first vertical line if the rootItem is not visible
ca
parents: 1843
diff changeset
   816
1567
f57fafbb7049 bug fix when drawing vertical lines
ca
parents: 1566
diff changeset
   817
    (item isExpanded and:[item hasChildren]) ifTrue:[
1897
5609f92e6d4a do not draw the first vertical line if the rootItem is not visible
ca
parents: 1843
diff changeset
   818
        (endHLnX >= x and:[endHLnX <= xR]) ifTrue:[
1567
f57fafbb7049 bug fix when drawing vertical lines
ca
parents: 1566
diff changeset
   819
            self displayLineFromX:endHLnX y:yCtr toX:endHLnX y:yBot.
f57fafbb7049 bug fix when drawing vertical lines
ca
parents: 1566
diff changeset
   820
        ]
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   821
    ].
1567
f57fafbb7049 bug fix when drawing vertical lines
ca
parents: 1566
diff changeset
   822
f57fafbb7049 bug fix when drawing vertical lines
ca
parents: 1566
diff changeset
   823
    buildInArray notNil ifTrue:[
f57fafbb7049 bug fix when drawing vertical lines
ca
parents: 1566
diff changeset
   824
        x := limitLvX.
f57fafbb7049 bug fix when drawing vertical lines
ca
parents: 1566
diff changeset
   825
        y := begHLnY.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   826
1567
f57fafbb7049 bug fix when drawing vertical lines
ca
parents: 1566
diff changeset
   827
        limitLvI to:startLvI do:[:i|
1597
9a9abffb7911 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1596
diff changeset
   828
            |yB|
1596
0792a5f915ab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1579
diff changeset
   829
1597
9a9abffb7911 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1596
diff changeset
   830
            (yB := buildInArray at:i) notNil ifTrue:[
1897
5609f92e6d4a do not draw the first vertical line if the rootItem is not visible
ca
parents: 1843
diff changeset
   831
                x >= minXVLine ifTrue:[
5609f92e6d4a do not draw the first vertical line if the rootItem is not visible
ca
parents: 1843
diff changeset
   832
                    self displayLineFromX:x y:y toX:x y:yB
5609f92e6d4a do not draw the first vertical line if the rootItem is not visible
ca
parents: 1843
diff changeset
   833
                ]
1567
f57fafbb7049 bug fix when drawing vertical lines
ca
parents: 1566
diff changeset
   834
            ].
f57fafbb7049 bug fix when drawing vertical lines
ca
parents: 1566
diff changeset
   835
            x := x + widthLvl.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   836
        ]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   837
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   838
    self mask:nil.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   839
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   840
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   841
!HierarchicalListView methodsFor:'event handling'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   842
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   843
buttonMultiPress:button x:x y:y
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   844
    "handle a button multiPress event
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   845
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   846
    |lnNr|
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   847
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   848
    enabled ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   849
        (     (button == 1 or:[button == #select])
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   850
         and:[(lnNr := self indicatorLineAtX:x y:y) notNil]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   851
        ) ifFalse:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   852
            super buttonMultiPress:button x:x y:y
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   853
        ]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   854
    ]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   855
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   856
1757
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   857
buttonPress:button x:x y:y
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   858
    "handle a button press event
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   859
    "
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   860
    |lnNr|
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   861
1757
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   862
    enabled ifTrue:[
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   863
        (button == 1 or:[button == #select]) ifTrue:[
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   864
            (lnNr := self indicatorLineAtX:x y:y) notNil ifTrue:[
1782
4fa475b5037e allow space for indicatationPressed action
ca
parents: 1779
diff changeset
   865
                ^ self indicatorPressedAt:lnNr
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   866
            ]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   867
        ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   868
        super buttonPress:button x:x y:y
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   869
    ]
1757
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   870
!
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   871
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   872
keyPress:aKey x:x y:y
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   873
    "a key was pressed - handle page-keys here
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   874
    "
1784
4b8a7a2811f5 *** empty log message ***
ca
parents: 1783
diff changeset
   875
    <resource: #keyboard( #CursorLeft #CursorRight )>
1757
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   876
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   877
    |item parent index size stop step|
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   878
1782
4fa475b5037e allow space for indicatationPressed action
ca
parents: 1779
diff changeset
   879
    enabled ifFalse:[^ self].
2179
e105597b0375 on press key left to parent if not expanded
penk
parents: 2134
diff changeset
   880
    index := self selectedIndex.
1782
4fa475b5037e allow space for indicatationPressed action
ca
parents: 1779
diff changeset
   881
4fa475b5037e allow space for indicatationPressed action
ca
parents: 1779
diff changeset
   882
    aKey == Character space ifTrue:[
2179
e105597b0375 on press key left to parent if not expanded
penk
parents: 2134
diff changeset
   883
        index ~~ 0 ifTrue:[
1782
4fa475b5037e allow space for indicatationPressed action
ca
parents: 1779
diff changeset
   884
            ^ self indicatorPressedAt:index
4fa475b5037e allow space for indicatationPressed action
ca
parents: 1779
diff changeset
   885
        ]
4fa475b5037e allow space for indicatationPressed action
ca
parents: 1779
diff changeset
   886
    ].
2179
e105597b0375 on press key left to parent if not expanded
penk
parents: 2134
diff changeset
   887
    ((aKey == #CursorRight) or:[(aKey == #CursorLeft)]) ifTrue:[
e105597b0375 on press key left to parent if not expanded
penk
parents: 2134
diff changeset
   888
        index ~~ 0 ifTrue:[
e105597b0375 on press key left to parent if not expanded
penk
parents: 2134
diff changeset
   889
            item := list at:index ifAbsent:nil.
e105597b0375 on press key left to parent if not expanded
penk
parents: 2134
diff changeset
   890
            item notNil ifTrue:[
e105597b0375 on press key left to parent if not expanded
penk
parents: 2134
diff changeset
   891
"/                (((aKey == #CursorRight) and:[item isExpanded not]) 
e105597b0375 on press key left to parent if not expanded
penk
parents: 2134
diff changeset
   892
"/                or:[((aKey == #CursorLeft) and:[item isExpanded])]) ifTrue:[
e105597b0375 on press key left to parent if not expanded
penk
parents: 2134
diff changeset
   893
                (aKey == #CursorLeft) == (item isExpanded) ifTrue:[
e105597b0375 on press key left to parent if not expanded
penk
parents: 2134
diff changeset
   894
                    ^ self indicatorPressedAt:index
e105597b0375 on press key left to parent if not expanded
penk
parents: 2134
diff changeset
   895
                ] ifFalse:[
e105597b0375 on press key left to parent if not expanded
penk
parents: 2134
diff changeset
   896
                    aKey == #CursorLeft ifTrue:[
e105597b0375 on press key left to parent if not expanded
penk
parents: 2134
diff changeset
   897
                        self selectElement:item parent ifAbsent:[].
e105597b0375 on press key left to parent if not expanded
penk
parents: 2134
diff changeset
   898
                        ^ self.
e105597b0375 on press key left to parent if not expanded
penk
parents: 2134
diff changeset
   899
                    ].
e105597b0375 on press key left to parent if not expanded
penk
parents: 2134
diff changeset
   900
                ].
e105597b0375 on press key left to parent if not expanded
penk
parents: 2134
diff changeset
   901
            ]
e105597b0375 on press key left to parent if not expanded
penk
parents: 2134
diff changeset
   902
        ]
e105597b0375 on press key left to parent if not expanded
penk
parents: 2134
diff changeset
   903
    ].
1782
4fa475b5037e allow space for indicatationPressed action
ca
parents: 1779
diff changeset
   904
2179
e105597b0375 on press key left to parent if not expanded
penk
parents: 2134
diff changeset
   905
"/    (aKey == #CursorLeft or:[aKey == #CursorRight]) ifTrue:[
e105597b0375 on press key left to parent if not expanded
penk
parents: 2134
diff changeset
   906
"/        
e105597b0375 on press key left to parent if not expanded
penk
parents: 2134
diff changeset
   907
"/    
e105597b0375 on press key left to parent if not expanded
penk
parents: 2134
diff changeset
   908
"/
e105597b0375 on press key left to parent if not expanded
penk
parents: 2134
diff changeset
   909
"/        (     enabled
e105597b0375 on press key left to parent if not expanded
penk
parents: 2134
diff changeset
   910
"/         and:[(size  := list size) > 1
e105597b0375 on press key left to parent if not expanded
penk
parents: 2134
diff changeset
   911
"/         and:[(index := self selectedIndex) ~~ 0
e105597b0375 on press key left to parent if not expanded
penk
parents: 2134
diff changeset
   912
"/         and:[(item  := list at:index ifAbsent:nil) notNil]]]
e105597b0375 on press key left to parent if not expanded
penk
parents: 2134
diff changeset
   913
"/        ) ifTrue:[
e105597b0375 on press key left to parent if not expanded
penk
parents: 2134
diff changeset
   914
"/            parent := item parent.
e105597b0375 on press key left to parent if not expanded
penk
parents: 2134
diff changeset
   915
"/
e105597b0375 on press key left to parent if not expanded
penk
parents: 2134
diff changeset
   916
"/            aKey == #CursorLeft ifTrue:[step := -1. stop :=    1]
e105597b0375 on press key left to parent if not expanded
penk
parents: 2134
diff changeset
   917
"/                               ifFalse:[step :=  1. stop := size].    
e105597b0375 on press key left to parent if not expanded
penk
parents: 2134
diff changeset
   918
"/
e105597b0375 on press key left to parent if not expanded
penk
parents: 2134
diff changeset
   919
"/            (index + step) to:stop by:step do:[:i|
e105597b0375 on press key left to parent if not expanded
penk
parents: 2134
diff changeset
   920
"/                item := list at:i ifAbsent:nil.
e105597b0375 on press key left to parent if not expanded
penk
parents: 2134
diff changeset
   921
"/                item isNil ifTrue:[^ nil].
e105597b0375 on press key left to parent if not expanded
penk
parents: 2134
diff changeset
   922
"/                item parent ~~ parent ifTrue:[^ self selection:i]
e105597b0375 on press key left to parent if not expanded
penk
parents: 2134
diff changeset
   923
"/            ].
e105597b0375 on press key left to parent if not expanded
penk
parents: 2134
diff changeset
   924
"/
e105597b0375 on press key left to parent if not expanded
penk
parents: 2134
diff changeset
   925
"/            index := aKey == #CursorLeft ifTrue:[size] ifFalse:[1].
e105597b0375 on press key left to parent if not expanded
penk
parents: 2134
diff changeset
   926
"/            self selection:index
e105597b0375 on press key left to parent if not expanded
penk
parents: 2134
diff changeset
   927
"/        ].
e105597b0375 on press key left to parent if not expanded
penk
parents: 2134
diff changeset
   928
"/        ^ self
e105597b0375 on press key left to parent if not expanded
penk
parents: 2134
diff changeset
   929
"/    ].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   930
2179
e105597b0375 on press key left to parent if not expanded
penk
parents: 2134
diff changeset
   931
    ^ super keyPress:aKey x:x y:y
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   932
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   933
1757
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   934
!HierarchicalListView methodsFor:'fetch resources'!
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   935
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   936
fetchResources
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   937
    "fetch device colors and ..., to avoid reallocation at redraw time;
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   938
     *** called after a create or snapin to fetch all device resources
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   939
    "
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   940
    |image|
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   941
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   942
    super fetchResources.
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   943
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   944
    lineMask       := lineMask  onDevice:device.
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   945
    lineColor      := lineColor onDevice:device.
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   946
    openIndicator  := self imageOnDevice:openIndicator.
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   947
    closeIndicator := self imageOnDevice:closeIndicator.
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   948
    imageWidth     := 2.
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   949
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   950
    icons keysAndValuesDo:[:aKey :anImage|
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   951
        anImage isNil ifTrue:[
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   952
            ('HierachicalListView [warning]: missing image: ' , aKey) errorPrintCR.
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   953
        ] ifFalse:[
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   954
            image := self imageOnDevice:anImage.
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   955
            icons at:aKey put:image.
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   956
            imageWidth := image width max:imageWidth.
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   957
        ]
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   958
    ].
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   959
    imageWidth      := imageWidth + 1 // 2 * 2.
1904
84155d7a6011 access method for #alignTextRightX
ca
parents: 1898
diff changeset
   960
    alignTextRightX := imageWidth + 20 max:alignTextRightX.
1757
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   961
! !
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   962
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   963
!HierarchicalListView methodsFor:'initialize / release'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   964
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   965
initStyle
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   966
    "setup viewStyle specifics
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   967
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   968
    |cls|
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   969
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   970
    super initStyle.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   971
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   972
    cls := self class.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   973
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   974
    lineMask := Form width:2 height:2 fromArray:#[16rAA 16r55].
1779
5848ce6ff439 change registeredIcons from IdentityDictionary to Dictionary
ca
parents: 1757
diff changeset
   975
    icons    := Dictionary new.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   976
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   977
    openIndicator      := self class openIndicator.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   978
    closeIndicator     := self class closeIndicator.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   979
    lineColor          := fgColor.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   980
    highlightMode      := #label.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   981
    showRoot           := true.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   982
    showLeftIndicators := true.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   983
    useDefaultIcons    := true.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   984
    showLines          := true.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   985
    imageInset         := 4.
1746
0a4f786f8c9a icon handling; default icons can be undefined
ca
parents: 1738
diff changeset
   986
    imageWidth         := 4.    "/ default
1568
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
   987
    alignTextRight     := false.
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
   988
    alignTextRightX    := 8.
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
   989
    maxWidthOfText     := 0.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   990
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   991
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   992
!HierarchicalListView methodsFor:'private'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   993
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   994
figureFor:anItem
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   995
    "return a (bitmap) figure for an item
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   996
    "
1756
f0f9ae674364 supress warnings
ca
parents: 1752
diff changeset
   997
    |key image|
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   998
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   999
    "/ the item may provide an icon
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1000
    "/ (it knows for itself if its open or closed)
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1001
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1002
    (key := anItem icon) notNil ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1003
        (key isImageOrForm and:[key device == device]) ifTrue:[
2134
0d7056b5ae06 add some comments
penk
parents: 2099
diff changeset
  1004
            "/ get a icon from the item
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1005
            ^ key
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1006
        ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1007
2134
0d7056b5ae06 add some comments
penk
parents: 2099
diff changeset
  1008
        "/ get a key from the item
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1009
        (image := icons at:key ifAbsent:nil) notNil ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1010
            ^ image
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1011
        ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1012
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1013
        key isImageOrForm ifTrue:[
2134
0d7056b5ae06 add some comments
penk
parents: 2099
diff changeset
  1014
            "/ associate image to device
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1015
            image := self imageOnDevice:key.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1016
            icons at:key put:image.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1017
          ^ image
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1018
        ]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1019
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1020
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1021
    useDefaultIcons ifFalse:[^ nil].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1022
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1023
    "/ ok, item did not return an icon - use default.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1024
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1025
    anItem hasChildren ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1026
        key := anItem isExpanded ifTrue:[#expanded] ifFalse:[#collapsed]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1027
    ] ifFalse:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1028
        key := #empty
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1029
    ].
1898
4239a343dbe6 remove defaule icons from list of icons; create lazy
ca
parents: 1897
diff changeset
  1030
    image := icons at:key ifAbsent:nil.
4239a343dbe6 remove defaule icons from list of icons; create lazy
ca
parents: 1897
diff changeset
  1031
4239a343dbe6 remove defaule icons from list of icons; create lazy
ca
parents: 1897
diff changeset
  1032
    image isNil ifTrue:[
4239a343dbe6 remove defaule icons from list of icons; create lazy
ca
parents: 1897
diff changeset
  1033
        key == #expanded  ifTrue:[image := self class expandedIcon].
4239a343dbe6 remove defaule icons from list of icons; create lazy
ca
parents: 1897
diff changeset
  1034
        key == #collapsed ifTrue:[image := self class collapsedIcon].
4239a343dbe6 remove defaule icons from list of icons; create lazy
ca
parents: 1897
diff changeset
  1035
        key == #empty     ifTrue:[image := self class emptyIcon].
4239a343dbe6 remove defaule icons from list of icons; create lazy
ca
parents: 1897
diff changeset
  1036
4239a343dbe6 remove defaule icons from list of icons; create lazy
ca
parents: 1897
diff changeset
  1037
        image isNil ifTrue:[^ nil].
4239a343dbe6 remove defaule icons from list of icons; create lazy
ca
parents: 1897
diff changeset
  1038
        image := self imageOnDevice:image.
4239a343dbe6 remove defaule icons from list of icons; create lazy
ca
parents: 1897
diff changeset
  1039
        icons at:key put:image.
4239a343dbe6 remove defaule icons from list of icons; create lazy
ca
parents: 1897
diff changeset
  1040
    ].
4239a343dbe6 remove defaule icons from list of icons; create lazy
ca
parents: 1897
diff changeset
  1041
  ^ image
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1042
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1043
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1044
heightOfLineAt:aLineNr
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1045
    "returns the total height for a line at an index, including
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1046
     lineSpacing, the figure and the label
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1047
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1048
    |item icon height|
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1049
1508
9c54f2e53da1 check whether #at:ifAbsent returns nil.
Claus Gittinger <cg@exept.de>
parents: 1431
diff changeset
  1050
    item := list at:aLineNr ifAbsent:nil.
9c54f2e53da1 check whether #at:ifAbsent returns nil.
Claus Gittinger <cg@exept.de>
parents: 1431
diff changeset
  1051
    item isNil ifTrue:[^ 4].
9c54f2e53da1 check whether #at:ifAbsent returns nil.
Claus Gittinger <cg@exept.de>
parents: 1431
diff changeset
  1052
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1053
    height := item heightOn:self.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1054
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1055
    (icon := self figureFor:item) notNil ifTrue:[
1391
83ed7574be4c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1056
        height := (icon heightOn:self) max:height.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1057
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1058
  ^ lineSpacing + height
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1059
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1060
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1061
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1062
1757
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
  1063
indicatorLineAtX:x y:y
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
  1064
    "returns the lineNumber assigned to an indicator at x/y or nil
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
  1065
    "
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
  1066
    |lnNr item x0|
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1067
1757
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
  1068
    (    indicatorAction isNil
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
  1069
     or:[(lnNr := self yVisibleToLineNr:y)   isNil
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
  1070
     or:[(item := list at:lnNr ifAbsent:nil) isNil
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
  1071
     or:[item hasChildren not]]]
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
  1072
    ) ifFalse:[
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
  1073
        x0 := self xOfFigureLevel:(item level - 1).
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
  1074
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
  1075
        (x > x0 and:[(x0 + imageWidth) > x]) ifTrue:[
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
  1076
            ^ lnNr
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
  1077
        ]
1756
f0f9ae674364 supress warnings
ca
parents: 1752
diff changeset
  1078
    ].
1757
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
  1079
    ^ nil
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1080
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1081
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1082
smallestLevelBetween:start and:stop
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1083
    "returns the smallest level between a range
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1084
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1085
    |prevItem currParent nextParent item
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1086
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1087
     lvl "{ Class:SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1088
     min "{ Class:SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1089
     beg "{ Class:SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1090
    |
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1091
1508
9c54f2e53da1 check whether #at:ifAbsent returns nil.
Claus Gittinger <cg@exept.de>
parents: 1431
diff changeset
  1092
    prevItem := list at:start ifAbsent:nil.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1093
1508
9c54f2e53da1 check whether #at:ifAbsent returns nil.
Claus Gittinger <cg@exept.de>
parents: 1431
diff changeset
  1094
    (prevItem isNil or:[(currParent := prevItem parent) isNil]) ifTrue:[
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1095
        ^ 1
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1096
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1097
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1098
    (min := prevItem level) == 2 ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1099
        ^ min
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1100
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1101
    beg := start + 1.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1102
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1103
    beg to:stop do:[:i|
1508
9c54f2e53da1 check whether #at:ifAbsent returns nil.
Claus Gittinger <cg@exept.de>
parents: 1431
diff changeset
  1104
        item := list at:i ifAbsent:nil.
9c54f2e53da1 check whether #at:ifAbsent returns nil.
Claus Gittinger <cg@exept.de>
parents: 1431
diff changeset
  1105
        item isNil ifTrue:[^ min].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1106
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1107
        (nextParent := item parent) == currParent ifFalse:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1108
            (currParent := nextParent) == prevItem ifFalse:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1109
                (lvl := item level) == 2 ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1110
                    ^ 2
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1111
                ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1112
                min := min min:lvl
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1113
            ]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1114
        ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1115
        prevItem := item
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1116
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1117
    ^ min
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1118
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1119
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1120
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1121
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1122
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1123
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1124
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1125
widthOfWidestLineBetween:firstLine and:lastLine
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1126
    "return the width of the longest line in pixels
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1127
    "
1756
f0f9ae674364 supress warnings
ca
parents: 1752
diff changeset
  1128
    |nprnt pprnt pitem item
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1129
     textX     "{ Class: SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1130
     level     "{ Class: SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1131
     width     "{ Class: SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1132
     deltaX    "{ Class: SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1133
     startX    "{ Class: SmallInteger }"
1568
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
  1134
     itemW     "{ Class: SmallInteger }"
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1135
    |
1568
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
  1136
    width  := 20.
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
  1137
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
  1138
    alignTextRight ifTrue:[
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
  1139
        firstLine to:lastLine do:[:idx|
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
  1140
            item  := list at:idx ifAbsent:nil.
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
  1141
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
  1142
            item isNil ifTrue:[
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
  1143
                  maxWidthOfText := maxWidthOfText max:width.
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
  1144
                ^ alignTextRightX + width
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
  1145
            ].
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
  1146
            width := (item widthOn:self) max:width.
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
  1147
        ].
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
  1148
        maxWidthOfText := maxWidthOfText max:width.
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
  1149
      ^ alignTextRightX + width
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
  1150
    ].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1151
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1152
    pprnt  := 4711.  "/ force a computation
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1153
    pitem  := 4712.  "/ force a computation
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1154
    deltaX := imageInset + imageWidth.
1568
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
  1155
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1156
    startX := self xOfStringLevel:1.
1568
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
  1157
    startX := startX + (viewOrigin x).
1756
f0f9ae674364 supress warnings
ca
parents: 1752
diff changeset
  1158
    textX  := 0.
f0f9ae674364 supress warnings
ca
parents: 1752
diff changeset
  1159
    level  := 1.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1160
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1161
    firstLine to:lastLine do:[:idx|
1508
9c54f2e53da1 check whether #at:ifAbsent returns nil.
Claus Gittinger <cg@exept.de>
parents: 1431
diff changeset
  1162
        item := list at:idx ifAbsent:nil.
9c54f2e53da1 check whether #at:ifAbsent returns nil.
Claus Gittinger <cg@exept.de>
parents: 1431
diff changeset
  1163
        item isNil ifTrue:[^ width + startX].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1164
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1165
        (nprnt := item parent) ~~ pprnt ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1166
            (pprnt := nprnt) == pitem ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1167
                level := level + 1.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1168
                textX := textX + deltaX.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1169
            ] ifFalse:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1170
                level := item level.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1171
                textX := level - 1 * deltaX.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1172
            ]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1173
        ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1174
        pitem := item.
1568
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
  1175
        itemW := item widthOn:self.
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
  1176
        maxWidthOfText := maxWidthOfText max:itemW.
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
  1177
        width := (itemW + textX) max:width
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1178
    ].
1568
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
  1179
    ^ width + startX.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1180
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1181
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1182
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1183
xOfFigureLevel:aLevel
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1184
    "origin x where to draw the icon
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1185
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1186
    |l "{ Class:SmallInteger }"|
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1187
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1188
    l := showRoot ifTrue:[aLevel] ifFalse:[aLevel - 1].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1189
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1190
    indicatorAction isNil ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1191
        l := l - 1
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1192
    ] ifFalse:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1193
        showLeftIndicators ifFalse:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1194
            l := l - 1
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1195
        ]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1196
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1197
  ^ (l * (imageInset + imageWidth)) + imageInset - (viewOrigin x)
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1198
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1199
1757
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
  1200
xOfStringLevel:aLevel
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
  1201
    "origin x where to draw the text( label )
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
  1202
    "
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
  1203
    alignTextRight ifTrue:[
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
  1204
        ^ alignTextRightX - (viewOrigin x)
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
  1205
    ].
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
  1206
    ^ (self xOfFigureLevel:aLevel) + imageWidth + textStartLeft
1756
f0f9ae674364 supress warnings
ca
parents: 1752
diff changeset
  1207
1554
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1541
diff changeset
  1208
!
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1541
diff changeset
  1209
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1541
diff changeset
  1210
xVisibleOfItem:anItem
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1541
diff changeset
  1211
    "returns the visible x of the labeled text
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1541
diff changeset
  1212
    "
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1541
diff changeset
  1213
    ^ self xOfStringLevel:(anItem level)
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1541
diff changeset
  1214
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1215
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1216
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1217
!HierarchicalListView class methodsFor:'documentation'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1218
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1219
version
2179
e105597b0375 on press key left to parent if not expanded
penk
parents: 2134
diff changeset
  1220
    ^ '$Header: /cvs/stx/stx/libwidg2/HierarchicalListView.st,v 1.43 2002-09-11 12:54:23 penk Exp $'
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1221
! !