HierarchicalListView.st
author Jan Vrany <jan.vrany@labware.com>
Fri, 02 Sep 2022 11:25:39 +0100
branchjv
changeset 6261 9b7eb7159d29
parent 6253 733a1d1bc8fc
permissions -rw-r--r--
Fix loong standing bug with some menus not being translated / resolved This has happened with browser "View" menu when sometimes it had the slice resolved and sometimes not. It turned out that it was because the code disabled resources (and therefore slices) resolution when processing shortcuts, so the menu was created and cached unresolved. This fixes the issue. eXept apparently run into the same problem.
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
6253
733a1d1bc8fc `HierarchicalListView`: draw icon *after* the label itself
Jan Vrany <jan.vrany@labware.com>
parents: 5389
diff changeset
     3
 COPYRIGHT (c) 2021 LabWare
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
     4
	      All Rights Reserved
1431
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
     5
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
     6
 This software is furnished under a license and may be used
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
     7
 only in accordance with the terms of that license and with the
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
     8
 inclusion of the above copyright notice.   This software may not
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
     9
 be provided or otherwise made available to, or used by, any
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    10
 other person.  No title to or ownership of the software is
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    11
 hereby transferred.
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    12
"
1752
1c11b6e4ab37 use isHierarchicalItem instead of hack variable
ca
parents: 1746
diff changeset
    13
"{ Package: 'stx:libwidg2' }"
1c11b6e4ab37 use isHierarchicalItem instead of hack variable
ca
parents: 1746
diff changeset
    14
4828
f0578de62d07 comment only
Claus Gittinger <cg@exept.de>
parents: 4625
diff changeset
    15
"{ NameSpace: Smalltalk }"
f0578de62d07 comment only
Claus Gittinger <cg@exept.de>
parents: 4625
diff changeset
    16
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
SelectionInListModelView subclass:#HierarchicalListView
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2366
diff changeset
    18
	instanceVariableNames:'imageInset imageWidth lineColor showRoot showLines
3279
b2bcf533add5 support different indicator icons
ca
parents: 3276
diff changeset
    19
		useDefaultIcons icons openIndicator closeIndicator indicatorWidth
b2bcf533add5 support different indicator icons
ca
parents: 3276
diff changeset
    20
		indicatorHeight alignTextRight iconAlignment alignTextRightX
b2bcf533add5 support different indicator icons
ca
parents: 3276
diff changeset
    21
		maxWidthOfText minLineHeight levelOfLastItem expandOnSelect
b2bcf533add5 support different indicator icons
ca
parents: 3276
diff changeset
    22
		autoScrollHorizontal showIndicators showLeftIndicators
b2bcf533add5 support different indicator icons
ca
parents: 3276
diff changeset
    23
		indicatorAction'
2361
c0e70e31ac28 close editor if button is pressed not in the editView
ca
parents: 2353
diff changeset
    24
	classVariableNames:''
c0e70e31ac28 close editor if button is pressed not in the editView
ca
parents: 2353
diff changeset
    25
	poolDictionaries:''
c0e70e31ac28 close editor if button is pressed not in the editView
ca
parents: 2353
diff changeset
    26
	category:'Views-Trees'
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
!HierarchicalListView class methodsFor:'documentation'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
1431
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    31
copyright
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
 COPYRIGHT (c) 1999 by eXept Software AG
6253
733a1d1bc8fc `HierarchicalListView`: draw icon *after* the label itself
Jan Vrany <jan.vrany@labware.com>
parents: 5389
diff changeset
    34
 COPYRIGHT (c) 2021 LabWare
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
    35
	      All Rights Reserved
1431
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    36
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    37
 This software is furnished under a license and may be used
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    38
 only in accordance with the terms of that license and with the
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    39
 inclusion of the above copyright notice.   This software may not
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    40
 be provided or otherwise made available to, or used by, any
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    41
 other person.  No title to or ownership of the software is
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    42
 hereby transferred.
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    43
"
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    44
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    45
!
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    46
1757
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
    47
documentation
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
"
1757
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
    49
    This class implements a hierarchical list view based on a
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
    50
    hierachical list.
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
    51
    It provides functionality similar to SelectionInTreeView, but optimizes
4828
f0578de62d07 comment only
Claus Gittinger <cg@exept.de>
parents: 4625
diff changeset
    52
    redraws, and operates directly on the model 
f0578de62d07 comment only
Claus Gittinger <cg@exept.de>
parents: 4625
diff changeset
    53
    (in contrast to SelectionInTreeView, which generates a list internally).
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
1757
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
    55
    [Instance variables:]
4828
f0578de62d07 comment only
Claus Gittinger <cg@exept.de>
parents: 4625
diff changeset
    56
        textStartLeft       <Integer>              inset between icon and text
f0578de62d07 comment only
Claus Gittinger <cg@exept.de>
parents: 4625
diff changeset
    57
        imageInset          <Integer>              inset between left side and icon
f0578de62d07 comment only
Claus Gittinger <cg@exept.de>
parents: 4625
diff changeset
    58
        imageWidth          <Integer>              width of widest icon
f0578de62d07 comment only
Claus Gittinger <cg@exept.de>
parents: 4625
diff changeset
    59
        minLineHeight       <Integer>              minimum required line height
f0578de62d07 comment only
Claus Gittinger <cg@exept.de>
parents: 4625
diff changeset
    60
                                                   including open/close indication ...
f0578de62d07 comment only
Claus Gittinger <cg@exept.de>
parents: 4625
diff changeset
    61
        indicatorWidth      <Integer>              max. width  of indicator
f0578de62d07 comment only
Claus Gittinger <cg@exept.de>
parents: 4625
diff changeset
    62
        indicatorHeight     <Integer>              max. height of indicator
3279
b2bcf533add5 support different indicator icons
ca
parents: 3276
diff changeset
    63
4828
f0578de62d07 comment only
Claus Gittinger <cg@exept.de>
parents: 4625
diff changeset
    64
        lineMask            <Form>                 line mask
f0578de62d07 comment only
Claus Gittinger <cg@exept.de>
parents: 4625
diff changeset
    65
        lineColor           <Color>                line color
f0578de62d07 comment only
Claus Gittinger <cg@exept.de>
parents: 4625
diff changeset
    66
        showRoot            <Boolean>              root element is shown or hidden
f0578de62d07 comment only
Claus Gittinger <cg@exept.de>
parents: 4625
diff changeset
    67
                                                   derives from the hierachical list.
f0578de62d07 comment only
Claus Gittinger <cg@exept.de>
parents: 4625
diff changeset
    68
        showLines           <Boolean>              show or hide lines
f0578de62d07 comment only
Claus Gittinger <cg@exept.de>
parents: 4625
diff changeset
    69
        showIndicators      <Boolean>              show or hide indicators
f0578de62d07 comment only
Claus Gittinger <cg@exept.de>
parents: 4625
diff changeset
    70
        useDefaultIcons     <Boolean>              use the default icons if no icon
f0578de62d07 comment only
Claus Gittinger <cg@exept.de>
parents: 4625
diff changeset
    71
                                                   for an item is specified
f0578de62d07 comment only
Claus Gittinger <cg@exept.de>
parents: 4625
diff changeset
    72
        icons               <IdentityDictionary>   list of registered icons;
f0578de62d07 comment only
Claus Gittinger <cg@exept.de>
parents: 4625
diff changeset
    73
                                                   identifier := <key> value := <icon>
f0578de62d07 comment only
Claus Gittinger <cg@exept.de>
parents: 4625
diff changeset
    74
        showLeftIndicators  <Boolean>              show or hide indicator for most left items
f0578de62d07 comment only
Claus Gittinger <cg@exept.de>
parents: 4625
diff changeset
    75
        indicatorAction     <Block>                action evaluated if indicator is pressed (0/1/2 arguments)
f0578de62d07 comment only
Claus Gittinger <cg@exept.de>
parents: 4625
diff changeset
    76
        openIndicator       <Icon, Image or Form>  expanded indicator
f0578de62d07 comment only
Claus Gittinger <cg@exept.de>
parents: 4625
diff changeset
    77
        closeIndicator      <Icon, Image or Form>  collapsed indicator
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
4828
f0578de62d07 comment only
Claus Gittinger <cg@exept.de>
parents: 4625
diff changeset
    79
        alignTextRight      <Boolean>              enable disable of align the text right
f0578de62d07 comment only
Claus Gittinger <cg@exept.de>
parents: 4625
diff changeset
    80
                                                   icon            text
f0578de62d07 comment only
Claus Gittinger <cg@exept.de>
parents: 4625
diff changeset
    81
                                                        icon       text of child
f0578de62d07 comment only
Claus Gittinger <cg@exept.de>
parents: 4625
diff changeset
    82
                                                   should be set after creation of the widget!!
f0578de62d07 comment only
Claus Gittinger <cg@exept.de>
parents: 4625
diff changeset
    83
        alignTextRightX     <Integer>              left x position of aligned right text
f0578de62d07 comment only
Claus Gittinger <cg@exept.de>
parents: 4625
diff changeset
    84
        maxWidthOfText      <Integer>              keeps the maximum width of a text label
1757
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
    85
4828
f0578de62d07 comment only
Claus Gittinger <cg@exept.de>
parents: 4625
diff changeset
    86
        levelOfLastItem     <Integer>              keeps the level of the last item;
f0578de62d07 comment only
Claus Gittinger <cg@exept.de>
parents: 4625
diff changeset
    87
                                                   in case of a delete last items from list
f0578de62d07 comment only
Claus Gittinger <cg@exept.de>
parents: 4625
diff changeset
    88
                                                   we know were to redraw lines from
2229
f1a236f5bd48 horizontal scrolling and documentation
ca
parents: 2227
diff changeset
    89
4828
f0578de62d07 comment only
Claus Gittinger <cg@exept.de>
parents: 4625
diff changeset
    90
        autoScrollHorizontal <Boolean>             true, than automatically scroll horizontal upto
f0578de62d07 comment only
Claus Gittinger <cg@exept.de>
parents: 4625
diff changeset
    91
                                                   the text label of the current selected line.
2229
f1a236f5bd48 horizontal scrolling and documentation
ca
parents: 2227
diff changeset
    92
4828
f0578de62d07 comment only
Claus Gittinger <cg@exept.de>
parents: 4625
diff changeset
    93
        expandOnSelect      <Boolean>              true, than the item selected by a buttonPress
f0578de62d07 comment only
Claus Gittinger <cg@exept.de>
parents: 4625
diff changeset
    94
                                                   event will be immediately expanded.
2229
f1a236f5bd48 horizontal scrolling and documentation
ca
parents: 2227
diff changeset
    95
1757
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
    96
    [author:]
4828
f0578de62d07 comment only
Claus Gittinger <cg@exept.de>
parents: 4625
diff changeset
    97
        Claus Atzkern
1757
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
    98
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
    99
    [see also:]
4828
f0578de62d07 comment only
Claus Gittinger <cg@exept.de>
parents: 4625
diff changeset
   100
        ListModelView
f0578de62d07 comment only
Claus Gittinger <cg@exept.de>
parents: 4625
diff changeset
   101
        SelectionInListModelView
f0578de62d07 comment only
Claus Gittinger <cg@exept.de>
parents: 4625
diff changeset
   102
        HierarchicalList
f0578de62d07 comment only
Claus Gittinger <cg@exept.de>
parents: 4625
diff changeset
   103
        HierarchicalItem
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
"
1757
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   105
!
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   106
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   107
examples
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   108
"
1916
3021f70d9211 add example for opening an editor on selected line
ca
parents: 1904
diff changeset
   109
    show a hierarchical list
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   110
									[exBegin]
1757
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   111
    |top sel list item|
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   112
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   113
    list := HierarchicalList new.
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   114
    item := HierarchicalItem::Example labeled:'Root Item'.
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   115
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   116
    item expand.
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   117
    list showRoot:false.
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   118
    list root:item.
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   119
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   120
    top := StandardSystemView new; extent:300@300.
2316
f91a9635462e bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents: 2313
diff changeset
   121
    sel := ScrollableView for:HierarchicalListView miniScrollerH:true
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   122
		       origin:0.0@0.0 corner:1.0@1.0 in:top.
1757
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   123
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   124
    sel list:list.
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   125
    sel multipleSelectOk:true.
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   126
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   127
    sel doubleClickAction:[:i| (list at:i) toggleExpand ].
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   128
    sel   indicatorAction:[:i| (list at:i) toggleExpand ].
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   129
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   130
    top open.
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   131
									[exEnd]
1757
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   132
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   133
1916
3021f70d9211 add example for opening an editor on selected line
ca
parents: 1904
diff changeset
   134
    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
   135
    line with label is a string.
3021f70d9211 add example for opening an editor on selected line
ca
parents: 1904
diff changeset
   136
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   137
									[exBegin]
1916
3021f70d9211 add example for opening an editor on selected line
ca
parents: 1904
diff changeset
   138
    |top sel list item|
3021f70d9211 add example for opening an editor on selected line
ca
parents: 1904
diff changeset
   139
3021f70d9211 add example for opening an editor on selected line
ca
parents: 1904
diff changeset
   140
    list := HierarchicalList new.
3021f70d9211 add example for opening an editor on selected line
ca
parents: 1904
diff changeset
   141
    item := HierarchicalItem::Example labeled:'Root Item'.
3021f70d9211 add example for opening an editor on selected line
ca
parents: 1904
diff changeset
   142
3021f70d9211 add example for opening an editor on selected line
ca
parents: 1904
diff changeset
   143
    item expand.
3021f70d9211 add example for opening an editor on selected line
ca
parents: 1904
diff changeset
   144
    list showRoot:false.
3021f70d9211 add example for opening an editor on selected line
ca
parents: 1904
diff changeset
   145
    list root:item.
3021f70d9211 add example for opening an editor on selected line
ca
parents: 1904
diff changeset
   146
3021f70d9211 add example for opening an editor on selected line
ca
parents: 1904
diff changeset
   147
    top := StandardSystemView new; extent:300@300.
2316
f91a9635462e bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents: 2313
diff changeset
   148
    sel := ScrollableView for:HierarchicalListView miniScrollerH:true
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   149
		       origin:0.0@0.0 corner:1.0@1.0 in:top.
1916
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 list:list.
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 openEditorAction:[:ln :aGC| |field item|
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   154
	item  := list at:ln.
1916
3021f70d9211 add example for opening an editor on selected line
ca
parents: 1904
diff changeset
   155
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   156
	item label isString ifFalse:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   157
	    field := nil
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   158
	] ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   159
	    field := EditField new.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   160
	    field level:0.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   161
	    field acceptOnLostFocus:true.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   162
	    field acceptAction:[:x| item label:(field contents) ].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   163
	    field font:(aGC font).
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   164
	    field contents:(item label).
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   165
	].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   166
	field
1916
3021f70d9211 add example for opening an editor on selected line
ca
parents: 1904
diff changeset
   167
    ].
3021f70d9211 add example for opening an editor on selected line
ca
parents: 1904
diff changeset
   168
3021f70d9211 add example for opening an editor on selected line
ca
parents: 1904
diff changeset
   169
    sel multipleSelectOk:true.
3021f70d9211 add example for opening an editor on selected line
ca
parents: 1904
diff changeset
   170
3021f70d9211 add example for opening an editor on selected line
ca
parents: 1904
diff changeset
   171
    sel doubleClickAction:[:i| (list at:i) toggleExpand ].
3021f70d9211 add example for opening an editor on selected line
ca
parents: 1904
diff changeset
   172
    sel   indicatorAction:[:i| (list at:i) toggleExpand ].
3021f70d9211 add example for opening an editor on selected line
ca
parents: 1904
diff changeset
   173
3021f70d9211 add example for opening an editor on selected line
ca
parents: 1904
diff changeset
   174
    top open.
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   175
									[exEnd]
1916
3021f70d9211 add example for opening an editor on selected line
ca
parents: 1904
diff changeset
   176
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   177
									[exBegin]
2316
f91a9635462e bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents: 2313
diff changeset
   178
    |top sel list item|
f91a9635462e bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents: 2313
diff changeset
   179
f91a9635462e bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents: 2313
diff changeset
   180
    list := HierarchicalList new.
f91a9635462e bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents: 2313
diff changeset
   181
    item := HierarchicalItem::Example labeled:'Root Item'.
f91a9635462e bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents: 2313
diff changeset
   182
f91a9635462e bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents: 2313
diff changeset
   183
    item expand.
f91a9635462e bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents: 2313
diff changeset
   184
    list showRoot:false.
f91a9635462e bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents: 2313
diff changeset
   185
    list root:item.
f91a9635462e bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents: 2313
diff changeset
   186
f91a9635462e bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents: 2313
diff changeset
   187
    top := StandardSystemView new; extent:300@300.
f91a9635462e bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents: 2313
diff changeset
   188
    sel := ScrollableView for:HierarchicalListView miniScrollerH:true
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   189
		       origin:0.0@0.0 corner:1.0@1.0 in:top.
2316
f91a9635462e bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents: 2313
diff changeset
   190
3279
b2bcf533add5 support different indicator icons
ca
parents: 3276
diff changeset
   191
    sel openIndicator:(ToolbarIconLibrary down22x22Icon).
b2bcf533add5 support different indicator icons
ca
parents: 3276
diff changeset
   192
    sel closeIndicator:(ToolbarIconLibrary downRight22x22Icon).
b2bcf533add5 support different indicator icons
ca
parents: 3276
diff changeset
   193
    sel showLines:false.
b2bcf533add5 support different indicator icons
ca
parents: 3276
diff changeset
   194
2316
f91a9635462e bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents: 2313
diff changeset
   195
    sel list:list.
f91a9635462e bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents: 2313
diff changeset
   196
    sel multipleSelectOk:true.
f91a9635462e bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents: 2313
diff changeset
   197
    sel alignTextRight:true.
f91a9635462e bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents: 2313
diff changeset
   198
    sel doubleClickAction:[:i| (list at:i) toggleExpand ].
f91a9635462e bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents: 2313
diff changeset
   199
    sel   indicatorAction:[:i| (list at:i) toggleExpand ].
f91a9635462e bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents: 2313
diff changeset
   200
f91a9635462e bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents: 2313
diff changeset
   201
    top open.
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   202
									[exBegin]
2316
f91a9635462e bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents: 2313
diff changeset
   203
f91a9635462e bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents: 2313
diff changeset
   204
1757
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   205
"
2383
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
   206
!
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
   207
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
   208
test
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
   209
    |top sel list item|
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
   210
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
   211
    list := HierarchicalList new.
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
   212
    item := HierarchicalItem::Example labeled:'Root Item'.
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
   213
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
   214
    item expand.
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
   215
    list showRoot:false.
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
   216
    list root:item.
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
   217
4949
5f8201378687 #BUGFIX
mawalch
parents: 4909
diff changeset
   218
    top := StandardSystemView extent:300@300.
2383
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
   219
    sel := ScrollableView for:HierarchicalListView miniScrollerH:true
4949
5f8201378687 #BUGFIX
mawalch
parents: 4909
diff changeset
   220
                       origin:0.0@0.0 corner:1.0@1.0 in:top.
2383
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
   221
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
   222
    sel useDefaultIcons:false.
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
   223
    sel list:list.
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
   224
    sel multipleSelectOk:true.
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
   225
    sel showLines:false.
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
   226
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
   227
    sel doubleClickAction:[:i| (list at:i) toggleExpand ].
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
   228
    sel   indicatorAction:[:i| (list at:i) toggleExpand ].
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
   229
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
   230
    top open.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   231
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   232
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   233
!HierarchicalListView class methodsFor:'resources'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   234
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   235
closeIndicator
3982
a38a6b83ab9f tree control icons
Claus Gittinger <cg@exept.de>
parents: 3979
diff changeset
   236
     ^ ToolbarIconLibrary closeIndicatorInTree
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   237
3982
a38a6b83ab9f tree control icons
Claus Gittinger <cg@exept.de>
parents: 3979
diff changeset
   238
    "Modified: / 19-12-2010 / 09:05:57 / cg"
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   239
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   240
1757
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   241
collapsedIcon
5389
d704f9a06ca8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5282
diff changeset
   242
    ^ ToolbarIconLibrary collapsedIconInTree
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
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   245
emptyIcon
5389
d704f9a06ca8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5282
diff changeset
   246
    ^ ToolbarIconLibrary emptyIconInTree.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   247
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   248
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   249
expandedIcon
5389
d704f9a06ca8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5282
diff changeset
   250
    ^ ToolbarIconLibrary expandedIconInTree.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   251
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   252
1757
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   253
openIndicator
3982
a38a6b83ab9f tree control icons
Claus Gittinger <cg@exept.de>
parents: 3979
diff changeset
   254
     ^ ToolbarIconLibrary openIndicatorInTree
1757
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   255
3982
a38a6b83ab9f tree control icons
Claus Gittinger <cg@exept.de>
parents: 3979
diff changeset
   256
    "Modified: / 19-12-2010 / 09:06:14 / cg"
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   257
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   258
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   259
!HierarchicalListView methodsFor:'accessing'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   260
1843
61595a6b2e37 handle font changed notification
martin
parents: 1818
diff changeset
   261
font:aFont
2307
4a9e9f71537a *** empty log message ***
ca
parents: 2303
diff changeset
   262
    "set a new font; if the font changed, all my items
3850
c9b77f759762 changed:
Stefan Vogel <sv@exept.de>
parents: 3741
diff changeset
   263
     have to clear their cached width and height."
c9b77f759762 changed:
Stefan Vogel <sv@exept.de>
parents: 3741
diff changeset
   264
1843
61595a6b2e37 handle font changed notification
martin
parents: 1818
diff changeset
   265
    |root|
61595a6b2e37 handle font changed notification
martin
parents: 1818
diff changeset
   266
4499
29cfc755b8c1 class: HierarchicalListView
Stefan Vogel <sv@exept.de>
parents: 4468
diff changeset
   267
    (aFont notNil and:[aFont ~= gc font]) ifTrue:[
3850
c9b77f759762 changed:
Stefan Vogel <sv@exept.de>
parents: 3741
diff changeset
   268
        root := self root.
c9b77f759762 changed:
Stefan Vogel <sv@exept.de>
parents: 3741
diff changeset
   269
        root notNil ifTrue:[root fontChanged].
c9b77f759762 changed:
Stefan Vogel <sv@exept.de>
parents: 3741
diff changeset
   270
        super font:aFont
1843
61595a6b2e37 handle font changed notification
martin
parents: 1818
diff changeset
   271
    ].
61595a6b2e37 handle font changed notification
martin
parents: 1818
diff changeset
   272
!
61595a6b2e37 handle font changed notification
martin
parents: 1818
diff changeset
   273
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   274
list:aList
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   275
    aList notNil ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   276
	aList isHierarchicalItem ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   277
	    self list root:aList.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   278
	    aList expand.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   279
	    ^ self
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   280
	].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   281
	showRoot := aList showRoot.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   282
    ].
2595
1ab5dc7d4796 create a default list; thus we have not to test for nil
ca
parents: 2554
diff changeset
   283
    super list:aList
1ab5dc7d4796 create a default list; thus we have not to test for nil
ca
parents: 2554
diff changeset
   284
!
1ab5dc7d4796 create a default list; thus we have not to test for nil
ca
parents: 2554
diff changeset
   285
1ab5dc7d4796 create a default list; thus we have not to test for nil
ca
parents: 2554
diff changeset
   286
newDefaultList
1ab5dc7d4796 create a default list; thus we have not to test for nil
ca
parents: 2554
diff changeset
   287
    "creates and returns a new default list class, on default a HierarchicalList
1ab5dc7d4796 create a default list; thus we have not to test for nil
ca
parents: 2554
diff changeset
   288
    "
1ab5dc7d4796 create a default list; thus we have not to test for nil
ca
parents: 2554
diff changeset
   289
    |list|
1ab5dc7d4796 create a default list; thus we have not to test for nil
ca
parents: 2554
diff changeset
   290
1ab5dc7d4796 create a default list; thus we have not to test for nil
ca
parents: 2554
diff changeset
   291
    list := HierarchicalList new.
1ab5dc7d4796 create a default list; thus we have not to test for nil
ca
parents: 2554
diff changeset
   292
    list showRoot:(showRoot ? true).
1ab5dc7d4796 create a default list; thus we have not to test for nil
ca
parents: 2554
diff changeset
   293
    ^ list
2408
8b0d11537dc0 accessing list indirect
ca
parents: 2392
diff changeset
   294
!
8b0d11537dc0 accessing list indirect
ca
parents: 2392
diff changeset
   295
8b0d11537dc0 accessing list indirect
ca
parents: 2392
diff changeset
   296
root
3850
c9b77f759762 changed:
Stefan Vogel <sv@exept.de>
parents: 3741
diff changeset
   297
    "return the anchor of the list or nil"
c9b77f759762 changed:
Stefan Vogel <sv@exept.de>
parents: 3741
diff changeset
   298
c9b77f759762 changed:
Stefan Vogel <sv@exept.de>
parents: 3741
diff changeset
   299
    |myList|
c9b77f759762 changed:
Stefan Vogel <sv@exept.de>
parents: 3741
diff changeset
   300
c9b77f759762 changed:
Stefan Vogel <sv@exept.de>
parents: 3741
diff changeset
   301
    myList := self list.
c9b77f759762 changed:
Stefan Vogel <sv@exept.de>
parents: 3741
diff changeset
   302
    ^ myList isNil ifTrue:[nil] ifFalse:[myList root]
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   303
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   304
2224
bfcabf142faa selection/indicator handling; scrolling horizontal
ca
parents: 2210
diff changeset
   305
!HierarchicalListView methodsFor:'accessing-behavior'!
bfcabf142faa selection/indicator handling; scrolling horizontal
ca
parents: 2210
diff changeset
   306
bfcabf142faa selection/indicator handling; scrolling horizontal
ca
parents: 2210
diff changeset
   307
autoScrollHorizontal
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   308
    "returns true if automatic horizontal scrolling
2780
692ba895ad57 hor. scroll on selection: changed algorithm
ca
parents: 2769
diff changeset
   309
     (upto the text label of the selected line)
2898
745eeceeb6b5 autoScrollHoriz
Claus Gittinger <cg@exept.de>
parents: 2880
diff changeset
   310
     is allowed (the default is as specified in the styleSheet)."
2780
692ba895ad57 hor. scroll on selection: changed algorithm
ca
parents: 2769
diff changeset
   311
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   312
    ^ autoScrollHorizontal == true
2224
bfcabf142faa selection/indicator handling; scrolling horizontal
ca
parents: 2210
diff changeset
   313
!
bfcabf142faa selection/indicator handling; scrolling horizontal
ca
parents: 2210
diff changeset
   314
bfcabf142faa selection/indicator handling; scrolling horizontal
ca
parents: 2210
diff changeset
   315
autoScrollHorizontal:aBoolean
bfcabf142faa selection/indicator handling; scrolling horizontal
ca
parents: 2210
diff changeset
   316
    "true, than automatically scroll horizontal upto the text label
2898
745eeceeb6b5 autoScrollHoriz
Claus Gittinger <cg@exept.de>
parents: 2880
diff changeset
   317
     of the current selected line."
745eeceeb6b5 autoScrollHoriz
Claus Gittinger <cg@exept.de>
parents: 2880
diff changeset
   318
2224
bfcabf142faa selection/indicator handling; scrolling horizontal
ca
parents: 2210
diff changeset
   319
    autoScrollHorizontal := aBoolean.
bfcabf142faa selection/indicator handling; scrolling horizontal
ca
parents: 2210
diff changeset
   320
!
bfcabf142faa selection/indicator handling; scrolling horizontal
ca
parents: 2210
diff changeset
   321
bfcabf142faa selection/indicator handling; scrolling horizontal
ca
parents: 2210
diff changeset
   322
expandOnSelect
bfcabf142faa selection/indicator handling; scrolling horizontal
ca
parents: 2210
diff changeset
   323
    "true, than the item selected by a buttonPress event will
bfcabf142faa selection/indicator handling; scrolling horizontal
ca
parents: 2210
diff changeset
   324
     be immediately expanded.
bfcabf142faa selection/indicator handling; scrolling horizontal
ca
parents: 2210
diff changeset
   325
    "
bfcabf142faa selection/indicator handling; scrolling horizontal
ca
parents: 2210
diff changeset
   326
    ^ expandOnSelect
bfcabf142faa selection/indicator handling; scrolling horizontal
ca
parents: 2210
diff changeset
   327
!
bfcabf142faa selection/indicator handling; scrolling horizontal
ca
parents: 2210
diff changeset
   328
bfcabf142faa selection/indicator handling; scrolling horizontal
ca
parents: 2210
diff changeset
   329
expandOnSelect:aBoolean
bfcabf142faa selection/indicator handling; scrolling horizontal
ca
parents: 2210
diff changeset
   330
    "true, than the item selected by a buttonPress event will
bfcabf142faa selection/indicator handling; scrolling horizontal
ca
parents: 2210
diff changeset
   331
     be immediately expanded.
bfcabf142faa selection/indicator handling; scrolling horizontal
ca
parents: 2210
diff changeset
   332
    "
bfcabf142faa selection/indicator handling; scrolling horizontal
ca
parents: 2210
diff changeset
   333
    expandOnSelect := aBoolean.
bfcabf142faa selection/indicator handling; scrolling horizontal
ca
parents: 2210
diff changeset
   334
! !
bfcabf142faa selection/indicator handling; scrolling horizontal
ca
parents: 2210
diff changeset
   335
1818
fe99c5c721e9 category changes
Claus Gittinger <cg@exept.de>
parents: 1792
diff changeset
   336
!HierarchicalListView methodsFor:'accessing-colors'!
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   337
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   338
lineColor
2307
4a9e9f71537a *** empty log message ***
ca
parents: 2303
diff changeset
   339
    "get the color of the horizontal and vertical lines
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   340
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   341
    ^ lineColor
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
lineColor:aColor
2307
4a9e9f71537a *** empty log message ***
ca
parents: 2303
diff changeset
   345
    "set the color of the horizontal and vertical lines
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   346
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   347
    (aColor notNil and:[aColor ~= lineColor]) ifTrue:[
4505
8b2a3ebaeb25 class: HierarchicalListView
Stefan Vogel <sv@exept.de>
parents: 4499
diff changeset
   348
        lineColor := aColor.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   349
4505
8b2a3ebaeb25 class: HierarchicalListView
Stefan Vogel <sv@exept.de>
parents: 4499
diff changeset
   350
        shown ifTrue:[
5003
3ad28e66c27e device access
Claus Gittinger <cg@exept.de>
parents: 4969
diff changeset
   351
            lineColor := lineColor onDevice:device.
4505
8b2a3ebaeb25 class: HierarchicalListView
Stefan Vogel <sv@exept.de>
parents: 4499
diff changeset
   352
            showLines ifTrue:[ self invalidate ]
8b2a3ebaeb25 class: HierarchicalListView
Stefan Vogel <sv@exept.de>
parents: 4499
diff changeset
   353
        ]
2307
4a9e9f71537a *** empty log message ***
ca
parents: 2303
diff changeset
   354
    ].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   355
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   356
1818
fe99c5c721e9 category changes
Claus Gittinger <cg@exept.de>
parents: 1792
diff changeset
   357
!HierarchicalListView methodsFor:'accessing-look'!
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   358
1568
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
   359
alignTextRight
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
   360
    "align the text right
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
   361
    "
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
   362
    ^ alignTextRight
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
   363
!
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
   364
1757
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   365
alignTextRight:aBool
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   366
    "align the text right
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   367
    "
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   368
    alignTextRight := aBool ? false.
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
   369
!
1568
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
   370
1904
84155d7a6011 access method for #alignTextRightX
ca
parents: 1898
diff changeset
   371
alignTextRightX
84155d7a6011 access method for #alignTextRightX
ca
parents: 1898
diff changeset
   372
    "returns the minimum used text inset, if text is aligned right.
84155d7a6011 access method for #alignTextRightX
ca
parents: 1898
diff changeset
   373
    "
84155d7a6011 access method for #alignTextRightX
ca
parents: 1898
diff changeset
   374
    ^ alignTextRightX
84155d7a6011 access method for #alignTextRightX
ca
parents: 1898
diff changeset
   375
!
84155d7a6011 access method for #alignTextRightX
ca
parents: 1898
diff changeset
   376
84155d7a6011 access method for #alignTextRightX
ca
parents: 1898
diff changeset
   377
alignTextRightX:aNumber
84155d7a6011 access method for #alignTextRightX
ca
parents: 1898
diff changeset
   378
    "set the minimum used text inset, if text is aligned right.
84155d7a6011 access method for #alignTextRightX
ca
parents: 1898
diff changeset
   379
    "
2383
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
   380
    aNumber > 0 ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   381
	alignTextRightX := aNumber.
1904
84155d7a6011 access method for #alignTextRightX
ca
parents: 1898
diff changeset
   382
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   383
	(alignTextRight and:[widthOfContents notNil]) ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   384
	    widthOfContents := alignTextRightX + maxWidthOfText.
1904
84155d7a6011 access method for #alignTextRightX
ca
parents: 1898
diff changeset
   385
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   386
	    shown ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   387
		self invalidate.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   388
		self contentsChanged.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   389
	    ]
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   390
	]
1904
84155d7a6011 access method for #alignTextRightX
ca
parents: 1898
diff changeset
   391
    ].
84155d7a6011 access method for #alignTextRightX
ca
parents: 1898
diff changeset
   392
!
84155d7a6011 access method for #alignTextRightX
ca
parents: 1898
diff changeset
   393
3279
b2bcf533add5 support different indicator icons
ca
parents: 3276
diff changeset
   394
closeIndicator:anIconOrNil
b2bcf533add5 support different indicator icons
ca
parents: 3276
diff changeset
   395
    closeIndicator ~= anIconOrNil ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   396
	closeIndicator := self imageOnMyDevice:anIconOrNil.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   397
	self indicatorIconChanged.
3279
b2bcf533add5 support different indicator icons
ca
parents: 3276
diff changeset
   398
    ].
b2bcf533add5 support different indicator icons
ca
parents: 3276
diff changeset
   399
!
b2bcf533add5 support different indicator icons
ca
parents: 3276
diff changeset
   400
3234
53f4c03b615a support icon alignment (default is left)
ca
parents: 3204
diff changeset
   401
iconAlignment:aSymbol
53f4c03b615a support icon alignment (default is left)
ca
parents: 3204
diff changeset
   402
    "alignment of the icons
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   403
	#left       align icons left
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   404
	#right      align icons right
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   405
	#center     align icons center between left and right
3234
53f4c03b615a support icon alignment (default is left)
ca
parents: 3204
diff changeset
   406
    "
53f4c03b615a support icon alignment (default is left)
ca
parents: 3204
diff changeset
   407
    aSymbol ~~ iconAlignment ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   408
	iconAlignment := aSymbol.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   409
	self invalidate.
3234
53f4c03b615a support icon alignment (default is left)
ca
parents: 3204
diff changeset
   410
    ].
53f4c03b615a support icon alignment (default is left)
ca
parents: 3204
diff changeset
   411
!
53f4c03b615a support icon alignment (default is left)
ca
parents: 3204
diff changeset
   412
2094
71c676b5f061 add icons which are stored under a specific key
ca
parents: 2069
diff changeset
   413
iconAt:aKey ifAbsentPut:aBlock
71c676b5f061 add icons which are stored under a specific key
ca
parents: 2069
diff changeset
   414
    "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
   415
     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
   416
     and returned.
71c676b5f061 add icons which are stored under a specific key
ca
parents: 2069
diff changeset
   417
    "
71c676b5f061 add icons which are stored under a specific key
ca
parents: 2069
diff changeset
   418
    |icon|
71c676b5f061 add icons which are stored under a specific key
ca
parents: 2069
diff changeset
   419
71c676b5f061 add icons which are stored under a specific key
ca
parents: 2069
diff changeset
   420
    icon := icons at:aKey ifAbsent:nil.
2307
4a9e9f71537a *** empty log message ***
ca
parents: 2303
diff changeset
   421
    icon notNil ifTrue:[^ icon].
2094
71c676b5f061 add icons which are stored under a specific key
ca
parents: 2069
diff changeset
   422
71c676b5f061 add icons which are stored under a specific key
ca
parents: 2069
diff changeset
   423
    icon := aBlock value.
2307
4a9e9f71537a *** empty log message ***
ca
parents: 2303
diff changeset
   424
    icon isNil ifTrue:[^ nil].
2094
71c676b5f061 add icons which are stored under a specific key
ca
parents: 2069
diff changeset
   425
71c676b5f061 add icons which are stored under a specific key
ca
parents: 2069
diff changeset
   426
    realized ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   427
	icon := self imageOnMyDevice:icon
2094
71c676b5f061 add icons which are stored under a specific key
ca
parents: 2069
diff changeset
   428
    ].
71c676b5f061 add icons which are stored under a specific key
ca
parents: 2069
diff changeset
   429
    icons at:aKey put:icon.
2814
612c60d1a9ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2791
diff changeset
   430
    ^ icon
2094
71c676b5f061 add icons which are stored under a specific key
ca
parents: 2069
diff changeset
   431
!
71c676b5f061 add icons which are stored under a specific key
ca
parents: 2069
diff changeset
   432
3279
b2bcf533add5 support different indicator icons
ca
parents: 3276
diff changeset
   433
openIndicator
b2bcf533add5 support different indicator icons
ca
parents: 3276
diff changeset
   434
    ^ openIndicator
b2bcf533add5 support different indicator icons
ca
parents: 3276
diff changeset
   435
!
b2bcf533add5 support different indicator icons
ca
parents: 3276
diff changeset
   436
b2bcf533add5 support different indicator icons
ca
parents: 3276
diff changeset
   437
openIndicator:anIconOrNil
b2bcf533add5 support different indicator icons
ca
parents: 3276
diff changeset
   438
    openIndicator ~= anIconOrNil ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   439
	openIndicator := self imageOnMyDevice:anIconOrNil.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   440
	self indicatorIconChanged.
3279
b2bcf533add5 support different indicator icons
ca
parents: 3276
diff changeset
   441
    ].
b2bcf533add5 support different indicator icons
ca
parents: 3276
diff changeset
   442
!
b2bcf533add5 support different indicator icons
ca
parents: 3276
diff changeset
   443
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   444
registerKeysAndIcons:aDictionary
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   445
    "register icons by key and value derived from a directory
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   446
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   447
    |image|
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   448
2880
74b81246abf1 isEmptyOrNil / notEmptyOrNil refactoring
Claus Gittinger <cg@exept.de>
parents: 2866
diff changeset
   449
    (aDictionary isEmptyOrNil) ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   450
	^ self
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   451
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   452
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   453
    aDictionary keysAndValuesDo:[:aKey :anImage|
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   454
	(image := self imageOnMyDevice:anImage) notNil ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   455
	    icons at:aKey put:image
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   456
	] ifFalse:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   457
	    icons removeKey:aKey ifAbsent:nil
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   458
	]
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   459
    ]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   460
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   461
4565
bafd0c21df02 Added empty methods to be polymorph with SelectionInListView
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4505
diff changeset
   462
selectedVisualBlock
bafd0c21df02 Added empty methods to be polymorph with SelectionInListView
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4505
diff changeset
   463
    "/ To be polymorph with SelectionInListView
bafd0c21df02 Added empty methods to be polymorph with SelectionInListView
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4505
diff changeset
   464
bafd0c21df02 Added empty methods to be polymorph with SelectionInListView
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4505
diff changeset
   465
    ^nil
bafd0c21df02 Added empty methods to be polymorph with SelectionInListView
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4505
diff changeset
   466
bafd0c21df02 Added empty methods to be polymorph with SelectionInListView
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4505
diff changeset
   467
    "Created: / 10-04-2014 / 11:53:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
bafd0c21df02 Added empty methods to be polymorph with SelectionInListView
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4505
diff changeset
   468
!
bafd0c21df02 Added empty methods to be polymorph with SelectionInListView
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4505
diff changeset
   469
bafd0c21df02 Added empty methods to be polymorph with SelectionInListView
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4505
diff changeset
   470
selectedVisualBlock: aBlockOrNil
bafd0c21df02 Added empty methods to be polymorph with SelectionInListView
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4505
diff changeset
   471
    "/ To be polymorph with SelectionInListView
bafd0c21df02 Added empty methods to be polymorph with SelectionInListView
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4505
diff changeset
   472
bafd0c21df02 Added empty methods to be polymorph with SelectionInListView
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4505
diff changeset
   473
    "Created: / 10-04-2014 / 11:53:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
bafd0c21df02 Added empty methods to be polymorph with SelectionInListView
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4505
diff changeset
   474
!
bafd0c21df02 Added empty methods to be polymorph with SelectionInListView
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4505
diff changeset
   475
2392
2e61452ae911 showIndicators; on default indicators are shown
ca
parents: 2383
diff changeset
   476
showIndicators
2e61452ae911 showIndicators; on default indicators are shown
ca
parents: 2383
diff changeset
   477
    "returns true if indicators are shown
2e61452ae911 showIndicators; on default indicators are shown
ca
parents: 2383
diff changeset
   478
    "
2e61452ae911 showIndicators; on default indicators are shown
ca
parents: 2383
diff changeset
   479
    ^ showIndicators
2e61452ae911 showIndicators; on default indicators are shown
ca
parents: 2383
diff changeset
   480
!
2e61452ae911 showIndicators; on default indicators are shown
ca
parents: 2383
diff changeset
   481
2e61452ae911 showIndicators; on default indicators are shown
ca
parents: 2383
diff changeset
   482
showIndicators:aBoolean
2e61452ae911 showIndicators; on default indicators are shown
ca
parents: 2383
diff changeset
   483
    "true if indicators are shown
2e61452ae911 showIndicators; on default indicators are shown
ca
parents: 2383
diff changeset
   484
    "
2e61452ae911 showIndicators; on default indicators are shown
ca
parents: 2383
diff changeset
   485
    showIndicators ~~ aBoolean ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   486
	showIndicators := aBoolean.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   487
	self invalidate.
2392
2e61452ae911 showIndicators; on default indicators are shown
ca
parents: 2383
diff changeset
   488
    ].
2e61452ae911 showIndicators; on default indicators are shown
ca
parents: 2383
diff changeset
   489
!
2e61452ae911 showIndicators; on default indicators are shown
ca
parents: 2383
diff changeset
   490
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   491
showLeftIndicators
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   492
    "show or hide the indicators for the most left items
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   493
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   494
    ^ showLeftIndicators
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   495
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   496
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   497
2307
4a9e9f71537a *** empty log message ***
ca
parents: 2303
diff changeset
   498
showLeftIndicators:aBoolean
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   499
    "show or hide the indicators for the most left items
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   500
    "
2392
2e61452ae911 showIndicators; on default indicators are shown
ca
parents: 2383
diff changeset
   501
    |oldInset newInset|
2e61452ae911 showIndicators; on default indicators are shown
ca
parents: 2383
diff changeset
   502
2e61452ae911 showIndicators; on default indicators are shown
ca
parents: 2383
diff changeset
   503
    aBoolean == showLeftIndicators ifTrue:[ ^ self ].
2e61452ae911 showIndicators; on default indicators are shown
ca
parents: 2383
diff changeset
   504
2408
8b0d11537dc0 accessing list indirect
ca
parents: 2392
diff changeset
   505
    (widthOfContents isNil or:[self size == 0]) ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   506
	showLeftIndicators := aBoolean.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   507
	^ self
2392
2e61452ae911 showIndicators; on default indicators are shown
ca
parents: 2383
diff changeset
   508
    ].
2383
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
   509
2392
2e61452ae911 showIndicators; on default indicators are shown
ca
parents: 2383
diff changeset
   510
    oldInset := self xVisibleOfIconAtLevel:3.
2e61452ae911 showIndicators; on default indicators are shown
ca
parents: 2383
diff changeset
   511
    showLeftIndicators := aBoolean.
2e61452ae911 showIndicators; on default indicators are shown
ca
parents: 2383
diff changeset
   512
    newInset := self xVisibleOfIconAtLevel:3.
2e61452ae911 showIndicators; on default indicators are shown
ca
parents: 2383
diff changeset
   513
2e61452ae911 showIndicators; on default indicators are shown
ca
parents: 2383
diff changeset
   514
    newInset ~~ oldInset ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   515
	widthOfContents := widthOfContents + (newInset - oldInset).
2392
2e61452ae911 showIndicators; on default indicators are shown
ca
parents: 2383
diff changeset
   516
    ].
2e61452ae911 showIndicators; on default indicators are shown
ca
parents: 2383
diff changeset
   517
2659
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2645
diff changeset
   518
    self invalidate.
2392
2e61452ae911 showIndicators; on default indicators are shown
ca
parents: 2383
diff changeset
   519
2e61452ae911 showIndicators; on default indicators are shown
ca
parents: 2383
diff changeset
   520
    newInset ~~ oldInset ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   521
	self contentsChanged
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   522
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   523
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   524
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   525
showLines
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   526
    "returns true if lines are shown
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   527
    "
2307
4a9e9f71537a *** empty log message ***
ca
parents: 2303
diff changeset
   528
    ^ showLines
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   529
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   530
2307
4a9e9f71537a *** empty log message ***
ca
parents: 2303
diff changeset
   531
showLines:aBoolean
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   532
    "show or hide lines
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   533
    "
2307
4a9e9f71537a *** empty log message ***
ca
parents: 2303
diff changeset
   534
    aBoolean ~~ showLines ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   535
	showLines := aBoolean.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   536
	self invalidate.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   537
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   538
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   539
2421
f5654eeb3118 test whether list is a hierachical item
ca
parents: 2417
diff changeset
   540
showRoot
f5654eeb3118 test whether list is a hierachical item
ca
parents: 2417
diff changeset
   541
    "true if the root is shown
f5654eeb3118 test whether list is a hierachical item
ca
parents: 2417
diff changeset
   542
    "
f5654eeb3118 test whether list is a hierachical item
ca
parents: 2417
diff changeset
   543
    ^ showRoot
f5654eeb3118 test whether list is a hierachical item
ca
parents: 2417
diff changeset
   544
!
f5654eeb3118 test whether list is a hierachical item
ca
parents: 2417
diff changeset
   545
f5654eeb3118 test whether list is a hierachical item
ca
parents: 2417
diff changeset
   546
showRoot:aBoolean
4178
ce92a9ae0fee class: HierarchicalListView
Claus Gittinger <cg@exept.de>
parents: 3982
diff changeset
   547
    "controls if the root is to be shown
2421
f5654eeb3118 test whether list is a hierachical item
ca
parents: 2417
diff changeset
   548
    "
f5654eeb3118 test whether list is a hierachical item
ca
parents: 2417
diff changeset
   549
    showRoot ~~ aBoolean ifTrue:[
4178
ce92a9ae0fee class: HierarchicalListView
Claus Gittinger <cg@exept.de>
parents: 3982
diff changeset
   550
        showRoot := aBoolean.
ce92a9ae0fee class: HierarchicalListView
Claus Gittinger <cg@exept.de>
parents: 3982
diff changeset
   551
        self list showRoot:showRoot.
ce92a9ae0fee class: HierarchicalListView
Claus Gittinger <cg@exept.de>
parents: 3982
diff changeset
   552
        self invalidate
2421
f5654eeb3118 test whether list is a hierachical item
ca
parents: 2417
diff changeset
   553
    ].
f5654eeb3118 test whether list is a hierachical item
ca
parents: 2417
diff changeset
   554
!
f5654eeb3118 test whether list is a hierachical item
ca
parents: 2417
diff changeset
   555
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   556
useDefaultIcons
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   557
    "use the default icons if no icon for an item is specified;
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   558
     ** default: true
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   559
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   560
    ^ useDefaultIcons
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   561
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   562
2307
4a9e9f71537a *** empty log message ***
ca
parents: 2303
diff changeset
   563
useDefaultIcons:aBoolean
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   564
    "use the default icons if no icon for an item is specified;
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   565
     ** default: true
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   566
    "
2307
4a9e9f71537a *** empty log message ***
ca
parents: 2303
diff changeset
   567
    useDefaultIcons ~~ aBoolean ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   568
	useDefaultIcons := aBoolean.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   569
	self invalidate.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   570
    ]
4565
bafd0c21df02 Added empty methods to be polymorph with SelectionInListView
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4505
diff changeset
   571
!
bafd0c21df02 Added empty methods to be polymorph with SelectionInListView
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4505
diff changeset
   572
bafd0c21df02 Added empty methods to be polymorph with SelectionInListView
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4505
diff changeset
   573
visualBlock
bafd0c21df02 Added empty methods to be polymorph with SelectionInListView
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4505
diff changeset
   574
    "/ To be polymorph with SelectionInListView
bafd0c21df02 Added empty methods to be polymorph with SelectionInListView
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4505
diff changeset
   575
bafd0c21df02 Added empty methods to be polymorph with SelectionInListView
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4505
diff changeset
   576
    ^nil
bafd0c21df02 Added empty methods to be polymorph with SelectionInListView
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4505
diff changeset
   577
bafd0c21df02 Added empty methods to be polymorph with SelectionInListView
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4505
diff changeset
   578
    "Created: / 10-04-2014 / 11:51:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
bafd0c21df02 Added empty methods to be polymorph with SelectionInListView
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4505
diff changeset
   579
!
bafd0c21df02 Added empty methods to be polymorph with SelectionInListView
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4505
diff changeset
   580
bafd0c21df02 Added empty methods to be polymorph with SelectionInListView
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4505
diff changeset
   581
visualBlock: aBlockOrNil
bafd0c21df02 Added empty methods to be polymorph with SelectionInListView
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4505
diff changeset
   582
    "/ To be polymorph with SelectionInListView
bafd0c21df02 Added empty methods to be polymorph with SelectionInListView
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4505
diff changeset
   583
bafd0c21df02 Added empty methods to be polymorph with SelectionInListView
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4505
diff changeset
   584
    "Created: / 10-04-2014 / 11:53:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   585
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   586
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   587
!HierarchicalListView methodsFor:'actions'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   588
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   589
indicatorAction
2392
2e61452ae911 showIndicators; on default indicators are shown
ca
parents: 2383
diff changeset
   590
    "the action evaluated if an indicator is pressed; otherwise
2e61452ae911 showIndicators; on default indicators are shown
ca
parents: 2383
diff changeset
   591
     if indicators are shown a default action is performed (toggle expand item).
2417
a0b7d30a4073 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2414
diff changeset
   592
a0b7d30a4073 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2414
diff changeset
   593
     The arguments to the block are:
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   594
	- no argument
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   595
	-  1 argument     index
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   596
	-  2 argument     index, self
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   597
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   598
    ^ indicatorAction
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   599
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   600
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   601
indicatorAction:anAction
2392
2e61452ae911 showIndicators; on default indicators are shown
ca
parents: 2383
diff changeset
   602
    "the action evaluated if an indicator is pressed; otherwise
2e61452ae911 showIndicators; on default indicators are shown
ca
parents: 2383
diff changeset
   603
     if indicators are shown a default action is performed (toggle expand item).
2417
a0b7d30a4073 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2414
diff changeset
   604
a0b7d30a4073 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2414
diff changeset
   605
     The arguments to the block are:
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   606
	- no argument
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   607
	-  1 argument     index
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   608
	-  2 argument     index, self
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   609
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   610
    indicatorAction := anAction.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   611
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   612
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   613
!HierarchicalListView methodsFor:'change & update'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   614
3279
b2bcf533add5 support different indicator icons
ca
parents: 3276
diff changeset
   615
indicatorIconChanged
b2bcf533add5 support different indicator icons
ca
parents: 3276
diff changeset
   616
    |w h|
b2bcf533add5 support different indicator icons
ca
parents: 3276
diff changeset
   617
b2bcf533add5 support different indicator icons
ca
parents: 3276
diff changeset
   618
    w := h := 9.
b2bcf533add5 support different indicator icons
ca
parents: 3276
diff changeset
   619
b2bcf533add5 support different indicator icons
ca
parents: 3276
diff changeset
   620
    openIndicator notNil ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   621
	w := w max:(openIndicator width).
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   622
	h := h max:(openIndicator height).
3279
b2bcf533add5 support different indicator icons
ca
parents: 3276
diff changeset
   623
    ].
b2bcf533add5 support different indicator icons
ca
parents: 3276
diff changeset
   624
    closeIndicator notNil ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   625
	w := w max:(closeIndicator width).
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   626
	h := h max:(closeIndicator height).
3279
b2bcf533add5 support different indicator icons
ca
parents: 3276
diff changeset
   627
    ].
b2bcf533add5 support different indicator icons
ca
parents: 3276
diff changeset
   628
b2bcf533add5 support different indicator icons
ca
parents: 3276
diff changeset
   629
    (w == indicatorWidth and:[h == indicatorHeight]) ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   630
	self invalidate.
3279
b2bcf533add5 support different indicator icons
ca
parents: 3276
diff changeset
   631
    ] ifFalse:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   632
	indicatorWidth  := w.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   633
	indicatorHeight := h.
3279
b2bcf533add5 support different indicator icons
ca
parents: 3276
diff changeset
   634
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   635
	self lostSynchronisation.   "/ must recompute all
3279
b2bcf533add5 support different indicator icons
ca
parents: 3276
diff changeset
   636
    ].
b2bcf533add5 support different indicator icons
ca
parents: 3276
diff changeset
   637
!
b2bcf533add5 support different indicator icons
ca
parents: 3276
diff changeset
   638
1782
4fa475b5037e allow space for indicatationPressed action
ca
parents: 1779
diff changeset
   639
indicatorPressedAt:aLnNr
2224
bfcabf142faa selection/indicator handling; scrolling horizontal
ca
parents: 2210
diff changeset
   640
    "handle indicator pressed action;
bfcabf142faa selection/indicator handling; scrolling horizontal
ca
parents: 2210
diff changeset
   641
     if the item changed expanded, we try to show all
2822
3538a17ef98c remove unused method vars
Stefan Vogel <sv@exept.de>
parents: 2814
diff changeset
   642
     new visible children"
3538a17ef98c remove unused method vars
Stefan Vogel <sv@exept.de>
parents: 2814
diff changeset
   643
3883
090387ed8844 comment/format in: #indicatorPressedAt:
Claus Gittinger <cg@exept.de>
parents: 3870
diff changeset
   644
    |item expanded dl sensor|
2224
bfcabf142faa selection/indicator handling; scrolling horizontal
ca
parents: 2210
diff changeset
   645
2392
2e61452ae911 showIndicators; on default indicators are shown
ca
parents: 2383
diff changeset
   646
    showIndicators ifFalse:[^ self].
2224
bfcabf142faa selection/indicator handling; scrolling horizontal
ca
parents: 2210
diff changeset
   647
2408
8b0d11537dc0 accessing list indirect
ca
parents: 2392
diff changeset
   648
    item := self at:aLnNr ifAbsent:nil.
2307
4a9e9f71537a *** empty log message ***
ca
parents: 2303
diff changeset
   649
    item isNil ifTrue:[^ self].
2224
bfcabf142faa selection/indicator handling; scrolling horizontal
ca
parents: 2210
diff changeset
   650
bfcabf142faa selection/indicator handling; scrolling horizontal
ca
parents: 2210
diff changeset
   651
    item hasIndicator ifFalse:[^ self].
bfcabf142faa selection/indicator handling; scrolling horizontal
ca
parents: 2210
diff changeset
   652
bfcabf142faa selection/indicator handling; scrolling horizontal
ca
parents: 2210
diff changeset
   653
    expanded := item isExpanded.
2392
2e61452ae911 showIndicators; on default indicators are shown
ca
parents: 2383
diff changeset
   654
2e61452ae911 showIndicators; on default indicators are shown
ca
parents: 2383
diff changeset
   655
    indicatorAction notNil ifTrue:[
3883
090387ed8844 comment/format in: #indicatorPressedAt:
Claus Gittinger <cg@exept.de>
parents: 3870
diff changeset
   656
        indicatorAction valueWithOptionalArgument:aLnNr and:self.
3241
e4ce2c9df9ac shift-right (shift-left) does a recursive-toggle-expand.
Claus Gittinger <cg@exept.de>
parents: 3234
diff changeset
   657
    ] ifFalse:[
3883
090387ed8844 comment/format in: #indicatorPressedAt:
Claus Gittinger <cg@exept.de>
parents: 3870
diff changeset
   658
        sensor := self sensor.
090387ed8844 comment/format in: #indicatorPressedAt:
Claus Gittinger <cg@exept.de>
parents: 3870
diff changeset
   659
        (sensor ctrlDown or:[sensor shiftDown]) ifTrue:[
090387ed8844 comment/format in: #indicatorPressedAt:
Claus Gittinger <cg@exept.de>
parents: 3870
diff changeset
   660
            item recursiveToggleExpand
090387ed8844 comment/format in: #indicatorPressedAt:
Claus Gittinger <cg@exept.de>
parents: 3870
diff changeset
   661
        ] ifFalse:[
090387ed8844 comment/format in: #indicatorPressedAt:
Claus Gittinger <cg@exept.de>
parents: 3870
diff changeset
   662
            item toggleExpand
090387ed8844 comment/format in: #indicatorPressedAt:
Claus Gittinger <cg@exept.de>
parents: 3870
diff changeset
   663
        ].
2392
2e61452ae911 showIndicators; on default indicators are shown
ca
parents: 2383
diff changeset
   664
    ].
2e61452ae911 showIndicators; on default indicators are shown
ca
parents: 2383
diff changeset
   665
2224
bfcabf142faa selection/indicator handling; scrolling horizontal
ca
parents: 2210
diff changeset
   666
    (expanded or:[item isExpanded not]) ifTrue:[^ self].
1783
ffe767ea66ea check whether children exists before calling indicatorPressed action
ca
parents: 1782
diff changeset
   667
2769
1315a31fa1e8 do not scroll when expanding
Claus Gittinger <cg@exept.de>
parents: 2726
diff changeset
   668
    (self yVisibleOfLine:aLnNr+1) > self height ifTrue:[
3883
090387ed8844 comment/format in: #indicatorPressedAt:
Claus Gittinger <cg@exept.de>
parents: 3870
diff changeset
   669
        dl := (self yVisibleOfLine:aLnNr+1) - (self yVisibleOfLine:aLnNr).
090387ed8844 comment/format in: #indicatorPressedAt:
Claus Gittinger <cg@exept.de>
parents: 3870
diff changeset
   670
        self scrollTo:(viewOrigin x @ (viewOrigin y + dl)).
2769
1315a31fa1e8 do not scroll when expanding
Claus Gittinger <cg@exept.de>
parents: 2726
diff changeset
   671
    ].
2224
bfcabf142faa selection/indicator handling; scrolling horizontal
ca
parents: 2210
diff changeset
   672
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   673
"/    numChildren := item numberOfVisibleChildren.
2769
1315a31fa1e8 do not scroll when expanding
Claus Gittinger <cg@exept.de>
parents: 2726
diff changeset
   674
"/    numChildren == 0 ifTrue:[
1315a31fa1e8 do not scroll when expanding
Claus Gittinger <cg@exept.de>
parents: 2726
diff changeset
   675
"/        ^ self
1315a31fa1e8 do not scroll when expanding
Claus Gittinger <cg@exept.de>
parents: 2726
diff changeset
   676
"/    ].
2224
bfcabf142faa selection/indicator handling; scrolling horizontal
ca
parents: 2210
diff changeset
   677
2769
1315a31fa1e8 do not scroll when expanding
Claus Gittinger <cg@exept.de>
parents: 2726
diff changeset
   678
"/    idx    := aLnNr + numChildren.
1315a31fa1e8 do not scroll when expanding
Claus Gittinger <cg@exept.de>
parents: 2726
diff changeset
   679
"/    vwOrgY := viewOrigin y.
1315a31fa1e8 do not scroll when expanding
Claus Gittinger <cg@exept.de>
parents: 2726
diff changeset
   680
"/    availY := (self yVisibleOfLine:aLnNr) - (self yVisibleOfLine:1).
1315a31fa1e8 do not scroll when expanding
Claus Gittinger <cg@exept.de>
parents: 2726
diff changeset
   681
"/
1315a31fa1e8 do not scroll when expanding
Claus Gittinger <cg@exept.de>
parents: 2726
diff changeset
   682
"/    availY > margin ifTrue:[
1315a31fa1e8 do not scroll when expanding
Claus Gittinger <cg@exept.de>
parents: 2726
diff changeset
   683
"/        usedY := (self yVisibleOfLine:(idx + 1)) - (height - margin - margin).
1315a31fa1e8 do not scroll when expanding
Claus Gittinger <cg@exept.de>
parents: 2726
diff changeset
   684
"/
1315a31fa1e8 do not scroll when expanding
Claus Gittinger <cg@exept.de>
parents: 2726
diff changeset
   685
"/        usedY > 1 ifTrue:[
1315a31fa1e8 do not scroll when expanding
Claus Gittinger <cg@exept.de>
parents: 2726
diff changeset
   686
"/            vwOrgY := vwOrgY + (usedY min:availY).
1315a31fa1e8 do not scroll when expanding
Claus Gittinger <cg@exept.de>
parents: 2726
diff changeset
   687
"/        ].
1315a31fa1e8 do not scroll when expanding
Claus Gittinger <cg@exept.de>
parents: 2726
diff changeset
   688
"/    ].
1315a31fa1e8 do not scroll when expanding
Claus Gittinger <cg@exept.de>
parents: 2726
diff changeset
   689
"/    vwOrgX := self computeViewOriginXat:aLnNr.
1315a31fa1e8 do not scroll when expanding
Claus Gittinger <cg@exept.de>
parents: 2726
diff changeset
   690
"/    self scrollTo:(vwOrgX @ vwOrgY).
3241
e4ce2c9df9ac shift-right (shift-left) does a recursive-toggle-expand.
Claus Gittinger <cg@exept.de>
parents: 3234
diff changeset
   691
e4ce2c9df9ac shift-right (shift-left) does a recursive-toggle-expand.
Claus Gittinger <cg@exept.de>
parents: 3234
diff changeset
   692
    "Modified: / 19-09-2007 / 08:48:15 / cg"
1782
4fa475b5037e allow space for indicatationPressed action
ca
parents: 1779
diff changeset
   693
!
4fa475b5037e allow space for indicatationPressed action
ca
parents: 1779
diff changeset
   694
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   695
lineChangedAt:aLnNr with:arg
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   696
    "line changed at position; check whether line height changed
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   697
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   698
    |item
2317
5f44d976c81f *** empty log message ***
ca
parents: 2316
diff changeset
   699
     level "{ Class:SmallInteger }"
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   700
     x0 "{ Class:SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   701
     x1 "{ Class:SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   702
     y0 "{ Class:SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   703
     y1 "{ Class:SmallInteger }"
2303
94ba4cf1376c must recompute width of contents if line changed
ca
parents: 2295
diff changeset
   704
     yB "{ Class:SmallInteger }"
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   705
    |
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   706
2408
8b0d11537dc0 accessing list indirect
ca
parents: 2392
diff changeset
   707
    item := self at:aLnNr ifAbsent:nil.
2317
5f44d976c81f *** empty log message ***
ca
parents: 2316
diff changeset
   708
    item isNil ifTrue:[^ self].
2316
f91a9635462e bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents: 2313
diff changeset
   709
1399
da1eed642569 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1391
diff changeset
   710
    (arg == #icon or:[arg == #hierarchy]) ifFalse:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   711
	super lineChangedAt:aLnNr with:arg.
2224
bfcabf142faa selection/indicator handling; scrolling horizontal
ca
parents: 2210
diff changeset
   712
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   713
	(arg ~~ #redraw and:[widthOfContents notNil]) ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   714
	    x0 := (self xVisibleOfTextAtLevel:(item level))
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   715
		+ (listRenderer widthFor:item)
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   716
		+ (viewOrigin x).
2224
bfcabf142faa selection/indicator handling; scrolling horizontal
ca
parents: 2210
diff changeset
   717
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   718
	    x0 > widthOfContents ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   719
		widthOfContents := x0.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   720
		self contentsChanged.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   721
	    ]
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   722
	].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   723
	^ self
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   724
    ].
2317
5f44d976c81f *** empty log message ***
ca
parents: 2316
diff changeset
   725
    level := item level.
2316
f91a9635462e bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents: 2313
diff changeset
   726
f91a9635462e bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents: 2313
diff changeset
   727
    (alignTextRight and:[arg == #hierarchy]) ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   728
	"/ must test whether alignTextRightX is enough
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   729
	(item isExpanded and:[item hasChildren]) ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   730
	    x0 := self xVisibleOfIconAtLevel:(level + 2).
2316
f91a9635462e bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents: 2313
diff changeset
   731
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   732
	    alignTextRightX < x0 ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   733
		alignTextRightX := x0.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   734
		self invalidate.
2316
f91a9635462e bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents: 2313
diff changeset
   735
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   736
		widthOfContents notNil ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   737
		    widthOfContents := alignTextRightX + maxWidthOfText.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   738
		    self contentsChanged.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   739
		].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   740
		^ self.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   741
	    ]
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   742
	]
2316
f91a9635462e bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents: 2313
diff changeset
   743
    ].
1568
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
   744
    shown ifFalse:[^ self].
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
   745
2303
94ba4cf1376c must recompute width of contents if line changed
ca
parents: 2295
diff changeset
   746
    yB := height - margin.
94ba4cf1376c must recompute width of contents if line changed
ca
parents: 2295
diff changeset
   747
    y0 := (self yVisibleOfLine:aLnNr) max:margin.
94ba4cf1376c must recompute width of contents if line changed
ca
parents: 2295
diff changeset
   748
    y0 < yB ifFalse:[ ^ self ].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   749
2303
94ba4cf1376c must recompute width of contents if line changed
ca
parents: 2295
diff changeset
   750
    y1 := (self yVisibleOfLine:(aLnNr + 1)) min:yB.
94ba4cf1376c must recompute width of contents if line changed
ca
parents: 2295
diff changeset
   751
    y1 > y0 ifFalse:[^ self].
1399
da1eed642569 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1391
diff changeset
   752
2327
73edf9e0d2aa *** empty log message ***
ca
parents: 2325
diff changeset
   753
    x1 := (self xVisibleOfTextAtLevel:level) - 1.
2317
5f44d976c81f *** empty log message ***
ca
parents: 2316
diff changeset
   754
    x1 > margin ifFalse:[^ self].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   755
2383
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
   756
    x0 := (self xVisibleOfIndicatorAtLevel:level) max:margin.
2317
5f44d976c81f *** empty log message ***
ca
parents: 2316
diff changeset
   757
    x1 := x1 min:(width - margin).
2303
94ba4cf1376c must recompute width of contents if line changed
ca
parents: 2295
diff changeset
   758
2317
5f44d976c81f *** empty log message ***
ca
parents: 2316
diff changeset
   759
    x0 < x1 ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   760
	self invalidate:(Rectangle left:x0 top:y0 width:(x1 - x0) height:(y1 - y0))
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   761
	      repairNow:false.
2303
94ba4cf1376c must recompute width of contents if line changed
ca
parents: 2295
diff changeset
   762
    ].
1976
1788b0045176 bug fix when adding new elements; must draw vertical lines above
ca
parents: 1916
diff changeset
   763
!
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   764
1976
1788b0045176 bug fix when adding new elements; must draw vertical lines above
ca
parents: 1916
diff changeset
   765
listChangedInsert:firstAddedIndex nItems:nLines
1788b0045176 bug fix when adding new elements; must draw vertical lines above
ca
parents: 1916
diff changeset
   766
    "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
   767
    "
2210
c2b830a14832 *** empty log message ***
ca
parents: 2208
diff changeset
   768
    |item level yTop yBot xLft start maxY|
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   769
1976
1788b0045176 bug fix when adding new elements; must draw vertical lines above
ca
parents: 1916
diff changeset
   770
    super listChangedInsert:firstAddedIndex nItems:nLines.
1788b0045176 bug fix when adding new elements; must draw vertical lines above
ca
parents: 1916
diff changeset
   771
2408
8b0d11537dc0 accessing list indirect
ca
parents: 2392
diff changeset
   772
    item := self last.
2210
c2b830a14832 *** empty log message ***
ca
parents: 2208
diff changeset
   773
    levelOfLastItem := item level.
c2b830a14832 *** empty log message ***
ca
parents: 2208
diff changeset
   774
1976
1788b0045176 bug fix when adding new elements; must draw vertical lines above
ca
parents: 1916
diff changeset
   775
    (     shown
1788b0045176 bug fix when adding new elements; must draw vertical lines above
ca
parents: 1916
diff changeset
   776
     and:[showLines
1788b0045176 bug fix when adding new elements; must draw vertical lines above
ca
parents: 1916
diff changeset
   777
     and:[firstAddedIndex > 1
1788b0045176 bug fix when adding new elements; must draw vertical lines above
ca
parents: 1916
diff changeset
   778
     and:[nLines ~~ 0
2408
8b0d11537dc0 accessing list indirect
ca
parents: 2392
diff changeset
   779
     and:[(item := self at:firstAddedIndex ifAbsent:nil) notNil
1976
1788b0045176 bug fix when adding new elements; must draw vertical lines above
ca
parents: 1916
diff changeset
   780
     and:[(level := item level) > 1]]]]]
1788b0045176 bug fix when adding new elements; must draw vertical lines above
ca
parents: 1916
diff changeset
   781
    ) ifFalse:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   782
	^ self.
1976
1788b0045176 bug fix when adding new elements; must draw vertical lines above
ca
parents: 1916
diff changeset
   783
    ].
2383
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
   784
    xLft := self xVisibleOfVerticalLineAt:level.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   785
1976
1788b0045176 bug fix when adding new elements; must draw vertical lines above
ca
parents: 1916
diff changeset
   786
    (xLft > margin and:[xLft < (width - margin)]) ifFalse:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   787
	^ self
1976
1788b0045176 bug fix when adding new elements; must draw vertical lines above
ca
parents: 1916
diff changeset
   788
    ].
1788b0045176 bug fix when adding new elements; must draw vertical lines above
ca
parents: 1916
diff changeset
   789
    start := firstAddedIndex - 1.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   790
1976
1788b0045176 bug fix when adding new elements; must draw vertical lines above
ca
parents: 1916
diff changeset
   791
    start to:1 by:-1 do:[:i| |el|
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   792
	el := self at:i.
1399
da1eed642569 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1391
diff changeset
   793
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   794
	el level <= level ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   795
	    i == start ifTrue:[^ self].
1976
1788b0045176 bug fix when adding new elements; must draw vertical lines above
ca
parents: 1916
diff changeset
   796
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   797
	    yTop := (self yVisibleOfLine:i + 1) max:margin.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   798
	    maxY := height - margin.
1976
1788b0045176 bug fix when adding new elements; must draw vertical lines above
ca
parents: 1916
diff changeset
   799
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   800
	    yTop < maxY ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   801
		yBot := (self yVisibleOfLine:firstAddedIndex) - 1 min:maxY.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   802
		self invalidate:(Rectangle left:xLft top:yTop width:2 height:(yBot - yTop))
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   803
	    ].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   804
	    ^ self
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   805
	]
1976
1788b0045176 bug fix when adding new elements; must draw vertical lines above
ca
parents: 1916
diff changeset
   806
    ].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   807
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   808
2208
ebd026780ad7 *** empty log message ***
ca
parents: 2201
diff changeset
   809
listChangedRemove:aStart toIndex:aStop
ebd026780ad7 *** empty log message ***
ca
parents: 2201
diff changeset
   810
    "test whether last items are deleted;
ebd026780ad7 *** empty log message ***
ca
parents: 2201
diff changeset
   811
     than we have to redraw lines because of different levels
ebd026780ad7 *** empty log message ***
ca
parents: 2201
diff changeset
   812
    "
2210
c2b830a14832 *** empty log message ***
ca
parents: 2208
diff changeset
   813
    |listSize index y0 searchLevel|
2208
ebd026780ad7 *** empty log message ***
ca
parents: 2201
diff changeset
   814
2408
8b0d11537dc0 accessing list indirect
ca
parents: 2392
diff changeset
   815
    listSize    := self size.
2210
c2b830a14832 *** empty log message ***
ca
parents: 2208
diff changeset
   816
    searchLevel := levelOfLastItem.
2208
ebd026780ad7 *** empty log message ***
ca
parents: 2201
diff changeset
   817
2307
4a9e9f71537a *** empty log message ***
ca
parents: 2303
diff changeset
   818
    listSize == 0 ifTrue:[ levelOfLastItem := 1 ]
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   819
		 ifFalse:[ levelOfLastItem := self last level ].
2208
ebd026780ad7 *** empty log message ***
ca
parents: 2201
diff changeset
   820
2307
4a9e9f71537a *** empty log message ***
ca
parents: 2303
diff changeset
   821
    (shown and:[showLines and:[listSize ~~ 0 and:[aStart > listSize]]]) ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   822
	index := self findLast:[:el| el level <= searchLevel ].
2208
ebd026780ad7 *** empty log message ***
ca
parents: 2201
diff changeset
   823
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   824
	(index ~~ 0 and:[index < listSize]) ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   825
	    y0 := (self yVisibleOfLine:index) max:margin.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   826
	    self invalidateX:0 y:y0 width:width height:(height - margin - y0).
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   827
	]
2208
ebd026780ad7 *** empty log message ***
ca
parents: 2201
diff changeset
   828
    ].
ebd026780ad7 *** empty log message ***
ca
parents: 2201
diff changeset
   829
    ^ super listChangedRemove:aStart toIndex:aStop
ebd026780ad7 *** empty log message ***
ca
parents: 2201
diff changeset
   830
!
ebd026780ad7 *** empty log message ***
ca
parents: 2201
diff changeset
   831
2644
78ca3bd5eef1 prepared for table
ca
parents: 2606
diff changeset
   832
updateFromList:what with:aPara
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   833
    "get the status of <showRoot> from the list
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   834
    "
2644
78ca3bd5eef1 prepared for table
ca
parents: 2606
diff changeset
   835
    |newState|
78ca3bd5eef1 prepared for table
ca
parents: 2606
diff changeset
   836
78ca3bd5eef1 prepared for table
ca
parents: 2606
diff changeset
   837
    newState := self list showRoot.
78ca3bd5eef1 prepared for table
ca
parents: 2606
diff changeset
   838
78ca3bd5eef1 prepared for table
ca
parents: 2606
diff changeset
   839
    showRoot ~~ newState ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   840
	showRoot := newState.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
   841
	self invalidate.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   842
    ].
2644
78ca3bd5eef1 prepared for table
ca
parents: 2606
diff changeset
   843
    super updateFromList:what with:aPara.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   844
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   845
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   846
!HierarchicalListView methodsFor:'drawing basics'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   847
1568
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
   848
drawElementsFrom:start to:stop x:xLeft y:yT w:w
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   849
    "draw the items between start to stop without clearing the background
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   850
    "
2383
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
   851
    |item prevParent icon showIndc showIcon showText
3614
86a6fdbadece changed #drawElementsFrom:to:x:y:w:
ca
parents: 3452
diff changeset
   852
     yTop yCtr yBot level xIndc xIcon yIcon xText xL xR height offIndcY icnWdt x|
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   853
2383
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
   854
    xL := xLeft.
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
   855
    xR := xL + w.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   856
2392
2e61452ae911 showIndicators; on default indicators are shown
ca
parents: 2383
diff changeset
   857
    showIndicators ifTrue:[
6253
733a1d1bc8fc `HierarchicalListView`: draw icon *after* the label itself
Jan Vrany <jan.vrany@labware.com>
parents: 5389
diff changeset
   858
        offIndcY := indicatorWidth // 2.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   859
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   860
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   861
    showLines ifTrue:[
6253
733a1d1bc8fc `HierarchicalListView`: draw icon *after* the label itself
Jan Vrany <jan.vrany@labware.com>
parents: 5389
diff changeset
   862
        self drawLinesFrom:start to:stop x:xL y:yT toX:xR
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   863
    ].
2383
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
   864
    prevParent := #NIL.         "/ to force a recompute
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
   865
    yBot       := yT.
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
   866
    showIndc   := false.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   867
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   868
    start to:stop do:[:anIndex|
6253
733a1d1bc8fc `HierarchicalListView`: draw icon *after* the label itself
Jan Vrany <jan.vrany@labware.com>
parents: 5389
diff changeset
   869
        (item := self at:anIndex ifAbsent:nil) isNil ifTrue:[
733a1d1bc8fc `HierarchicalListView`: draw icon *after* the label itself
Jan Vrany <jan.vrany@labware.com>
parents: 5389
diff changeset
   870
            ^ self      "/ list changed
733a1d1bc8fc `HierarchicalListView`: draw icon *after* the label itself
Jan Vrany <jan.vrany@labware.com>
parents: 5389
diff changeset
   871
        ].
733a1d1bc8fc `HierarchicalListView`: draw icon *after* the label itself
Jan Vrany <jan.vrany@labware.com>
parents: 5389
diff changeset
   872
        yTop   := yBot.
733a1d1bc8fc `HierarchicalListView`: draw icon *after* the label itself
Jan Vrany <jan.vrany@labware.com>
parents: 5389
diff changeset
   873
        yBot   := self yVisibleOfLine:(anIndex + 1).
733a1d1bc8fc `HierarchicalListView`: draw icon *after* the label itself
Jan Vrany <jan.vrany@labware.com>
parents: 5389
diff changeset
   874
        height := yBot - yTop.
733a1d1bc8fc `HierarchicalListView`: draw icon *after* the label itself
Jan Vrany <jan.vrany@labware.com>
parents: 5389
diff changeset
   875
        yCtr   := yTop + (height // 2).
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   876
6253
733a1d1bc8fc `HierarchicalListView`: draw icon *after* the label itself
Jan Vrany <jan.vrany@labware.com>
parents: 5389
diff changeset
   877
        item parent ~~ prevParent ifTrue:[
733a1d1bc8fc `HierarchicalListView`: draw icon *after* the label itself
Jan Vrany <jan.vrany@labware.com>
parents: 5389
diff changeset
   878
            prevParent  := item parent.
733a1d1bc8fc `HierarchicalListView`: draw icon *after* the label itself
Jan Vrany <jan.vrany@labware.com>
parents: 5389
diff changeset
   879
            level       := item level.
733a1d1bc8fc `HierarchicalListView`: draw icon *after* the label itself
Jan Vrany <jan.vrany@labware.com>
parents: 5389
diff changeset
   880
            xIcon       := self xVisibleOfIconAtLevel:level.
733a1d1bc8fc `HierarchicalListView`: draw icon *after* the label itself
Jan Vrany <jan.vrany@labware.com>
parents: 5389
diff changeset
   881
            xText       := self xVisibleOfTextAtLevel:level.
733a1d1bc8fc `HierarchicalListView`: draw icon *after* the label itself
Jan Vrany <jan.vrany@labware.com>
parents: 5389
diff changeset
   882
            showText    := (xText < xR).
733a1d1bc8fc `HierarchicalListView`: draw icon *after* the label itself
Jan Vrany <jan.vrany@labware.com>
parents: 5389
diff changeset
   883
            showIcon    := (xIcon < xR and:[xText > xL]).
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   884
6253
733a1d1bc8fc `HierarchicalListView`: draw icon *after* the label itself
Jan Vrany <jan.vrany@labware.com>
parents: 5389
diff changeset
   885
            showIndicators ifTrue:[
733a1d1bc8fc `HierarchicalListView`: draw icon *after* the label itself
Jan Vrany <jan.vrany@labware.com>
parents: 5389
diff changeset
   886
                xIndc  := self xVisibleOfIndicatorAtLevel:level.
733a1d1bc8fc `HierarchicalListView`: draw icon *after* the label itself
Jan Vrany <jan.vrany@labware.com>
parents: 5389
diff changeset
   887
                showIndc := (xIcon > xL and:[xIndc < xR]).
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   888
6253
733a1d1bc8fc `HierarchicalListView`: draw icon *after* the label itself
Jan Vrany <jan.vrany@labware.com>
parents: 5389
diff changeset
   889
                showIndc ifTrue:[
733a1d1bc8fc `HierarchicalListView`: draw icon *after* the label itself
Jan Vrany <jan.vrany@labware.com>
parents: 5389
diff changeset
   890
                    showIndc := prevParent notNil or:[showLeftIndicators]
733a1d1bc8fc `HierarchicalListView`: draw icon *after* the label itself
Jan Vrany <jan.vrany@labware.com>
parents: 5389
diff changeset
   891
                ]
733a1d1bc8fc `HierarchicalListView`: draw icon *after* the label itself
Jan Vrany <jan.vrany@labware.com>
parents: 5389
diff changeset
   892
            ]
733a1d1bc8fc `HierarchicalListView`: draw icon *after* the label itself
Jan Vrany <jan.vrany@labware.com>
parents: 5389
diff changeset
   893
        ].
3234
53f4c03b615a support icon alignment (default is left)
ca
parents: 3204
diff changeset
   894
6253
733a1d1bc8fc `HierarchicalListView`: draw icon *after* the label itself
Jan Vrany <jan.vrany@labware.com>
parents: 5389
diff changeset
   895
        showText ifTrue:[
733a1d1bc8fc `HierarchicalListView`: draw icon *after* the label itself
Jan Vrany <jan.vrany@labware.com>
parents: 5389
diff changeset
   896
            self drawLabelAt:anIndex x:xText y:yTop h:height
733a1d1bc8fc `HierarchicalListView`: draw icon *after* the label itself
Jan Vrany <jan.vrany@labware.com>
parents: 5389
diff changeset
   897
        ].
733a1d1bc8fc `HierarchicalListView`: draw icon *after* the label itself
Jan Vrany <jan.vrany@labware.com>
parents: 5389
diff changeset
   898
733a1d1bc8fc `HierarchicalListView`: draw icon *after* the label itself
Jan Vrany <jan.vrany@labware.com>
parents: 5389
diff changeset
   899
        (showIcon and:[(icon := self validateDrawableIconFor:item) notNil]) ifTrue:[
733a1d1bc8fc `HierarchicalListView`: draw icon *after* the label itself
Jan Vrany <jan.vrany@labware.com>
parents: 5389
diff changeset
   900
            icnWdt := icon width.
733a1d1bc8fc `HierarchicalListView`: draw icon *after* the label itself
Jan Vrany <jan.vrany@labware.com>
parents: 5389
diff changeset
   901
733a1d1bc8fc `HierarchicalListView`: draw icon *after* the label itself
Jan Vrany <jan.vrany@labware.com>
parents: 5389
diff changeset
   902
            (xIcon + icnWdt) > xL ifTrue:[
733a1d1bc8fc `HierarchicalListView`: draw icon *after* the label itself
Jan Vrany <jan.vrany@labware.com>
parents: 5389
diff changeset
   903
                iconAlignment == #left ifTrue:[
733a1d1bc8fc `HierarchicalListView`: draw icon *after* the label itself
Jan Vrany <jan.vrany@labware.com>
parents: 5389
diff changeset
   904
                    x := xIcon.
733a1d1bc8fc `HierarchicalListView`: draw icon *after* the label itself
Jan Vrany <jan.vrany@labware.com>
parents: 5389
diff changeset
   905
                ] ifFalse:[
733a1d1bc8fc `HierarchicalListView`: draw icon *after* the label itself
Jan Vrany <jan.vrany@labware.com>
parents: 5389
diff changeset
   906
                    x := xText - textStartLeft.
3234
53f4c03b615a support icon alignment (default is left)
ca
parents: 3204
diff changeset
   907
6253
733a1d1bc8fc `HierarchicalListView`: draw icon *after* the label itself
Jan Vrany <jan.vrany@labware.com>
parents: 5389
diff changeset
   908
                    iconAlignment == #center ifTrue:[
733a1d1bc8fc `HierarchicalListView`: draw icon *after* the label itself
Jan Vrany <jan.vrany@labware.com>
parents: 5389
diff changeset
   909
                        x := (x + xIcon - icnWdt) // 2.
733a1d1bc8fc `HierarchicalListView`: draw icon *after* the label itself
Jan Vrany <jan.vrany@labware.com>
parents: 5389
diff changeset
   910
                    ] ifFalse:[
733a1d1bc8fc `HierarchicalListView`: draw icon *after* the label itself
Jan Vrany <jan.vrany@labware.com>
parents: 5389
diff changeset
   911
                        x := x - icnWdt.
733a1d1bc8fc `HierarchicalListView`: draw icon *after* the label itself
Jan Vrany <jan.vrany@labware.com>
parents: 5389
diff changeset
   912
                    ].
733a1d1bc8fc `HierarchicalListView`: draw icon *after* the label itself
Jan Vrany <jan.vrany@labware.com>
parents: 5389
diff changeset
   913
                ].
733a1d1bc8fc `HierarchicalListView`: draw icon *after* the label itself
Jan Vrany <jan.vrany@labware.com>
parents: 5389
diff changeset
   914
                yIcon := yCtr - (icon height // 2).
733a1d1bc8fc `HierarchicalListView`: draw icon *after* the label itself
Jan Vrany <jan.vrany@labware.com>
parents: 5389
diff changeset
   915
                item displayIcon:icon atX:x y:yIcon on:self.
733a1d1bc8fc `HierarchicalListView`: draw icon *after* the label itself
Jan Vrany <jan.vrany@labware.com>
parents: 5389
diff changeset
   916
            ]
733a1d1bc8fc `HierarchicalListView`: draw icon *after* the label itself
Jan Vrany <jan.vrany@labware.com>
parents: 5389
diff changeset
   917
        ].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   918
6253
733a1d1bc8fc `HierarchicalListView`: draw icon *after* the label itself
Jan Vrany <jan.vrany@labware.com>
parents: 5389
diff changeset
   919
        (showIndc and:[item hasIndicator]) ifTrue:[
733a1d1bc8fc `HierarchicalListView`: draw icon *after* the label itself
Jan Vrany <jan.vrany@labware.com>
parents: 5389
diff changeset
   920
            item isExpanded ifTrue:[icon := openIndicator ]
733a1d1bc8fc `HierarchicalListView`: draw icon *after* the label itself
Jan Vrany <jan.vrany@labware.com>
parents: 5389
diff changeset
   921
                           ifFalse:[icon := closeIndicator].
2316
f91a9635462e bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents: 2313
diff changeset
   922
6253
733a1d1bc8fc `HierarchicalListView`: draw icon *after* the label itself
Jan Vrany <jan.vrany@labware.com>
parents: 5389
diff changeset
   923
            icon notNil ifTrue:[
733a1d1bc8fc `HierarchicalListView`: draw icon *after* the label itself
Jan Vrany <jan.vrany@labware.com>
parents: 5389
diff changeset
   924
                icon displayOn:self x:xIndc y:(yCtr - offIndcY).
733a1d1bc8fc `HierarchicalListView`: draw icon *after* the label itself
Jan Vrany <jan.vrany@labware.com>
parents: 5389
diff changeset
   925
            ].
733a1d1bc8fc `HierarchicalListView`: draw icon *after* the label itself
Jan Vrany <jan.vrany@labware.com>
parents: 5389
diff changeset
   926
        ].
2383
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
   927
    ].
2963
0e53c2bb4424 use isDirectoryItem to allow for drawing of empty directories
fm
parents: 2949
diff changeset
   928
0e53c2bb4424 use isDirectoryItem to allow for drawing of empty directories
fm
parents: 2949
diff changeset
   929
    "Modified: / 23-06-2006 / 12:49:26 / fm"
6253
733a1d1bc8fc `HierarchicalListView`: draw icon *after* the label itself
Jan Vrany <jan.vrany@labware.com>
parents: 5389
diff changeset
   930
    "Modified: / 01-06-2021 / 10:36:18 / Jan Vrany <jan.vrany@labware.com>"
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   931
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   932
1399
da1eed642569 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1391
diff changeset
   933
drawLinesFrom:start to:stop x:xL y:yT toX:xR
3977
e81ca26b8a23 bugfix: drawing lines dotted
ca
parents: 3937
diff changeset
   934
    "draw the lines between start to stop without clearing the background"
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   935
3977
e81ca26b8a23 bugfix: drawing lines dotted
ca
parents: 3937
diff changeset
   936
    |item yNext|
1570
c8baa4a17043 support configuration of length of vertical line
ca
parents: 1568
diff changeset
   937
3979
106b8988c1a6 changed: #drawLinesFrom:to:x:y:toX:
Claus Gittinger <cg@exept.de>
parents: 3978
diff changeset
   938
    UserPreferences current showDottedLinesInTree ifFalse:[^ self].
106b8988c1a6 changed: #drawLinesFrom:to:x:y:toX:
Claus Gittinger <cg@exept.de>
parents: 3978
diff changeset
   939
4909
b7c864b6d6d1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 4896
diff changeset
   940
    item := list at:start ifAbsent:nil.
b7c864b6d6d1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 4896
diff changeset
   941
    item isNil ifTrue:[^ nil].
b7c864b6d6d1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 4896
diff changeset
   942
    
3977
e81ca26b8a23 bugfix: drawing lines dotted
ca
parents: 3937
diff changeset
   943
    self paint:lineColor on:bgColor.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   944
3978
d3d9bdf72a52 changed: #drawLinesFrom:to:x:y:toX: use dotted for WIN
ca
parents: 3977
diff changeset
   945
    OperatingSystem isMSWINDOWSlike ifTrue:[
3977
e81ca26b8a23 bugfix: drawing lines dotted
ca
parents: 3937
diff changeset
   946
        self mask:nil.
3936
4c42f502f55c changed: #drawLinesFrom:to:x:y:toX:
Claus Gittinger <cg@exept.de>
parents: 3890
diff changeset
   947
        self lineStyle:#dotted.
4c42f502f55c changed: #drawLinesFrom:to:x:y:toX:
Claus Gittinger <cg@exept.de>
parents: 3890
diff changeset
   948
    ] ifFalse:[
3978
d3d9bdf72a52 changed: #drawLinesFrom:to:x:y:toX: use dotted for WIN
ca
parents: 3977
diff changeset
   949
        self maskOrigin:( (self viewOrigin + (0 @ 1)) \\ (lineMask extent)).
3936
4c42f502f55c changed: #drawLinesFrom:to:x:y:toX:
Claus Gittinger <cg@exept.de>
parents: 3890
diff changeset
   950
        self mask:lineMask.
4c42f502f55c changed: #drawLinesFrom:to:x:y:toX:
Claus Gittinger <cg@exept.de>
parents: 3890
diff changeset
   951
    ].
2383
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
   952
3977
e81ca26b8a23 bugfix: drawing lines dotted
ca
parents: 3937
diff changeset
   953
    "/ draw all vertical lines
e81ca26b8a23 bugfix: drawing lines dotted
ca
parents: 3937
diff changeset
   954
    list from:start to:stop do:[:eachItem|
e81ca26b8a23 bugfix: drawing lines dotted
ca
parents: 3937
diff changeset
   955
        self drawVericalLineForElement:eachItem minX:xL maxX:xR.
e81ca26b8a23 bugfix: drawing lines dotted
ca
parents: 3937
diff changeset
   956
    ].
4909
b7c864b6d6d1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 4896
diff changeset
   957
    item notNil ifTrue:[
b7c864b6d6d1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 4896
diff changeset
   958
        [ (item := item parent) notNil ] whileTrue:[
b7c864b6d6d1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 4896
diff changeset
   959
            self drawVericalLineForElement:item minX:xL maxX:xR.
b7c864b6d6d1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 4896
diff changeset
   960
        ].
2392
2e61452ae911 showIndicators; on default indicators are shown
ca
parents: 2383
diff changeset
   961
    ].
4909
b7c864b6d6d1 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 4896
diff changeset
   962
    
3977
e81ca26b8a23 bugfix: drawing lines dotted
ca
parents: 3937
diff changeset
   963
    "/ draw all the horizontal lines
e81ca26b8a23 bugfix: drawing lines dotted
ca
parents: 3937
diff changeset
   964
    yNext := self yVisibleOfLine:start.
1570
c8baa4a17043 support configuration of length of vertical line
ca
parents: 1568
diff changeset
   965
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   966
    start to:stop do:[:anIndex|
3977
e81ca26b8a23 bugfix: drawing lines dotted
ca
parents: 3937
diff changeset
   967
        |y0 index x0 x1 itemLevel|
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   968
4468
78122284aa8b class: HierarchicalListView
Claus Gittinger <cg@exept.de>
parents: 4443
diff changeset
   969
        item := list at:anIndex ifAbsent:nil.
78122284aa8b class: HierarchicalListView
Claus Gittinger <cg@exept.de>
parents: 4443
diff changeset
   970
        item isNil ifTrue:[
78122284aa8b class: HierarchicalListView
Claus Gittinger <cg@exept.de>
parents: 4443
diff changeset
   971
            self lineStyle:#solid.
78122284aa8b class: HierarchicalListView
Claus Gittinger <cg@exept.de>
parents: 4443
diff changeset
   972
            self mask:nil.
78122284aa8b class: HierarchicalListView
Claus Gittinger <cg@exept.de>
parents: 4443
diff changeset
   973
            ^ self
78122284aa8b class: HierarchicalListView
Claus Gittinger <cg@exept.de>
parents: 4443
diff changeset
   974
        ].
1570
c8baa4a17043 support configuration of length of vertical line
ca
parents: 1568
diff changeset
   975
3977
e81ca26b8a23 bugfix: drawing lines dotted
ca
parents: 3937
diff changeset
   976
        y0    := yNext.
e81ca26b8a23 bugfix: drawing lines dotted
ca
parents: 3937
diff changeset
   977
        yNext := self yVisibleOfLine:anIndex + 1.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   978
3977
e81ca26b8a23 bugfix: drawing lines dotted
ca
parents: 3937
diff changeset
   979
        item parent isNil ifTrue:[
e81ca26b8a23 bugfix: drawing lines dotted
ca
parents: 3937
diff changeset
   980
            index := showRoot ifTrue:[0] ifFalse:[-1].
e81ca26b8a23 bugfix: drawing lines dotted
ca
parents: 3937
diff changeset
   981
        ] ifFalse:[
e81ca26b8a23 bugfix: drawing lines dotted
ca
parents: 3937
diff changeset
   982
            index := list identityIndexOf:(item parent).
3936
4c42f502f55c changed: #drawLinesFrom:to:x:y:toX:
Claus Gittinger <cg@exept.de>
parents: 3890
diff changeset
   983
        ].
3977
e81ca26b8a23 bugfix: drawing lines dotted
ca
parents: 3937
diff changeset
   984
        index == 0 ifTrue:[
e81ca26b8a23 bugfix: drawing lines dotted
ca
parents: 3937
diff changeset
   985
            (showLeftIndicators and:[item hasIndicator]) ifTrue:[
e81ca26b8a23 bugfix: drawing lines dotted
ca
parents: 3937
diff changeset
   986
                index := 1.
3936
4c42f502f55c changed: #drawLinesFrom:to:x:y:toX:
Claus Gittinger <cg@exept.de>
parents: 3890
diff changeset
   987
            ]
4c42f502f55c changed: #drawLinesFrom:to:x:y:toX:
Claus Gittinger <cg@exept.de>
parents: 3890
diff changeset
   988
        ].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   989
3977
e81ca26b8a23 bugfix: drawing lines dotted
ca
parents: 3937
diff changeset
   990
        index > 0 ifTrue:[
e81ca26b8a23 bugfix: drawing lines dotted
ca
parents: 3937
diff changeset
   991
            itemLevel := item level.
e81ca26b8a23 bugfix: drawing lines dotted
ca
parents: 3937
diff changeset
   992
e81ca26b8a23 bugfix: drawing lines dotted
ca
parents: 3937
diff changeset
   993
            x0 := self xVisibleOfVerticalLineAt:itemLevel.
1897
5609f92e6d4a do not draw the first vertical line if the rootItem is not visible
ca
parents: 1843
diff changeset
   994
3977
e81ca26b8a23 bugfix: drawing lines dotted
ca
parents: 3937
diff changeset
   995
            item drawHorizontalLineUpToText ifTrue:[
e81ca26b8a23 bugfix: drawing lines dotted
ca
parents: 3937
diff changeset
   996
                x1 := (self xVisibleOfTextAtLevel:itemLevel) - textStartLeft.
e81ca26b8a23 bugfix: drawing lines dotted
ca
parents: 3937
diff changeset
   997
            ] ifFalse:[
e81ca26b8a23 bugfix: drawing lines dotted
ca
parents: 3937
diff changeset
   998
                x1 := self xVisibleOfVerticalLineAt:(itemLevel + 1).
e81ca26b8a23 bugfix: drawing lines dotted
ca
parents: 3937
diff changeset
   999
            ].                
e81ca26b8a23 bugfix: drawing lines dotted
ca
parents: 3937
diff changeset
  1000
            y0 := (y0 + yNext ) // 2.
e81ca26b8a23 bugfix: drawing lines dotted
ca
parents: 3937
diff changeset
  1001
            self displayLineFromX:x0 y:y0 toX:x1 y:y0.
e81ca26b8a23 bugfix: drawing lines dotted
ca
parents: 3937
diff changeset
  1002
        ].
e81ca26b8a23 bugfix: drawing lines dotted
ca
parents: 3937
diff changeset
  1003
    ].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1004
3977
e81ca26b8a23 bugfix: drawing lines dotted
ca
parents: 3937
diff changeset
  1005
    self lineStyle:#solid.
e81ca26b8a23 bugfix: drawing lines dotted
ca
parents: 3937
diff changeset
  1006
    self mask:nil.
3979
106b8988c1a6 changed: #drawLinesFrom:to:x:y:toX:
Claus Gittinger <cg@exept.de>
parents: 3978
diff changeset
  1007
106b8988c1a6 changed: #drawLinesFrom:to:x:y:toX:
Claus Gittinger <cg@exept.de>
parents: 3978
diff changeset
  1008
    "Modified: / 03-12-2010 / 19:28:23 / cg"
3977
e81ca26b8a23 bugfix: drawing lines dotted
ca
parents: 3937
diff changeset
  1009
!
2383
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
  1010
3977
e81ca26b8a23 bugfix: drawing lines dotted
ca
parents: 3937
diff changeset
  1011
drawVericalLineForElement:item minX:xL maxX:xR
e81ca26b8a23 bugfix: drawing lines dotted
ca
parents: 3937
diff changeset
  1012
    "draw the vertical line my children are connected to"
e81ca26b8a23 bugfix: drawing lines dotted
ca
parents: 3937
diff changeset
  1013
e81ca26b8a23 bugfix: drawing lines dotted
ca
parents: 3937
diff changeset
  1014
    |itemLevel y0 y1 x0|
2383
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
  1015
3977
e81ca26b8a23 bugfix: drawing lines dotted
ca
parents: 3937
diff changeset
  1016
    (item notNil and:[item isExpanded and:[item hasChildren]]) ifTrue:[
e81ca26b8a23 bugfix: drawing lines dotted
ca
parents: 3937
diff changeset
  1017
        itemLevel := item level.
e81ca26b8a23 bugfix: drawing lines dotted
ca
parents: 3937
diff changeset
  1018
        
e81ca26b8a23 bugfix: drawing lines dotted
ca
parents: 3937
diff changeset
  1019
        itemLevel == 1 ifTrue:[
e81ca26b8a23 bugfix: drawing lines dotted
ca
parents: 3937
diff changeset
  1020
            showRoot ifFalse:[^ self].
e81ca26b8a23 bugfix: drawing lines dotted
ca
parents: 3937
diff changeset
  1021
        ].
e81ca26b8a23 bugfix: drawing lines dotted
ca
parents: 3937
diff changeset
  1022
        x0 := self xVisibleOfVerticalLineAt:(itemLevel + 1).
e81ca26b8a23 bugfix: drawing lines dotted
ca
parents: 3937
diff changeset
  1023
e81ca26b8a23 bugfix: drawing lines dotted
ca
parents: 3937
diff changeset
  1024
        (x0 between:xL and:xR) ifTrue:[
e81ca26b8a23 bugfix: drawing lines dotted
ca
parents: 3937
diff changeset
  1025
            y0 := self yVisibleOfIndicatorForItem:item.
e81ca26b8a23 bugfix: drawing lines dotted
ca
parents: 3937
diff changeset
  1026
            y1 := self yVisibleOfIndicatorForItem:(item last).
e81ca26b8a23 bugfix: drawing lines dotted
ca
parents: 3937
diff changeset
  1027
e81ca26b8a23 bugfix: drawing lines dotted
ca
parents: 3937
diff changeset
  1028
            y1 > y0 ifTrue:[
e81ca26b8a23 bugfix: drawing lines dotted
ca
parents: 3937
diff changeset
  1029
                self displayLineFromX:x0 y:y0 toX:x0 y:y1.
3936
4c42f502f55c changed: #drawLinesFrom:to:x:y:toX:
Claus Gittinger <cg@exept.de>
parents: 3890
diff changeset
  1030
            ].
4c42f502f55c changed: #drawLinesFrom:to:x:y:toX:
Claus Gittinger <cg@exept.de>
parents: 3890
diff changeset
  1031
        ].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1032
    ].
2316
f91a9635462e bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents: 2313
diff changeset
  1033
!
f91a9635462e bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents: 2313
diff changeset
  1034
f91a9635462e bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents: 2313
diff changeset
  1035
validateDrawableIconFor:anItem
f91a9635462e bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents: 2313
diff changeset
  1036
    "returns the icon to be drawn for an item or nil
4625
b64d176d2bd6 class: HierarchicalListView
Stefan Vogel <sv@exept.de>
parents: 4590
diff changeset
  1037
     test the extent of the icon; on error an exception is raised
2316
f91a9635462e bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents: 2313
diff changeset
  1038
    "
2383
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
  1039
    |width needMore icon maxLevel startOfText oldX newX|
2316
f91a9635462e bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents: 2313
diff changeset
  1040
4443
c7f5e10435e9 class: HierarchicalListView
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  1041
    Error handle:[:ex |
4969
338e10e12404 #DOCUMENTATION
Stefan Vogel <sv@exept.de>
parents: 4949
diff changeset
  1042
        Transcript showCR:'HierachicalListView: error in redraw'.
4443
c7f5e10435e9 class: HierarchicalListView
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  1043
        ^ nil.
c7f5e10435e9 class: HierarchicalListView
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  1044
    ] do:[
c7f5e10435e9 class: HierarchicalListView
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  1045
        icon := self iconFor:anItem.
c7f5e10435e9 class: HierarchicalListView
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  1046
    ].
2316
f91a9635462e bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents: 2313
diff changeset
  1047
    icon isNil ifTrue:[^ nil].
f91a9635462e bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents: 2313
diff changeset
  1048
f91a9635462e bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents: 2313
diff changeset
  1049
    width := icon width.
f91a9635462e bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents: 2313
diff changeset
  1050
f91a9635462e bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents: 2313
diff changeset
  1051
    (constantHeight notNil and:[icon height > constantHeight]) ifTrue:[
4443
c7f5e10435e9 class: HierarchicalListView
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  1052
        constantHeight := icon height + lineSpacing.
c7f5e10435e9 class: HierarchicalListView
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  1053
        self recomputeHeightOfContents.
2316
f91a9635462e bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents: 2313
diff changeset
  1054
4443
c7f5e10435e9 class: HierarchicalListView
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  1055
        width <= imageWidth ifTrue:[
c7f5e10435e9 class: HierarchicalListView
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  1056
            self contentsChanged.
c7f5e10435e9 class: HierarchicalListView
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  1057
            StopRedrawSignal raiseRequest
c7f5e10435e9 class: HierarchicalListView
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  1058
        ].
2316
f91a9635462e bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents: 2313
diff changeset
  1059
    ] ifFalse:[
4443
c7f5e10435e9 class: HierarchicalListView
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  1060
        width <= imageWidth ifTrue:[ ^ icon ].
2316
f91a9635462e bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents: 2313
diff changeset
  1061
    ].
f91a9635462e bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents: 2313
diff changeset
  1062
2383
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
  1063
    maxLevel := 1.
2316
f91a9635462e bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents: 2313
diff changeset
  1064
2595
1ab5dc7d4796 create a default list; thus we have not to test for nil
ca
parents: 2554
diff changeset
  1065
    self list criticalDo:[
4443
c7f5e10435e9 class: HierarchicalListView
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  1066
        self list do:[:el| maxLevel := maxLevel max:(el level) ].
2316
f91a9635462e bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents: 2313
diff changeset
  1067
    ].
2383
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
  1068
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
  1069
    needMore        := (width - imageWidth) max:2.
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
  1070
    oldX            := self xVisibleOfIconAtLevel:(maxLevel + 1).
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
  1071
    imageWidth      := imageWidth + needMore.
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
  1072
    newX            := self xVisibleOfIconAtLevel:(maxLevel + 1).
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
  1073
    alignTextRightX := alignTextRightX max:newX.
2316
f91a9635462e bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents: 2313
diff changeset
  1074
f91a9635462e bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents: 2313
diff changeset
  1075
    widthOfContents notNil ifTrue:[
4443
c7f5e10435e9 class: HierarchicalListView
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  1076
        alignTextRight ifTrue:[
c7f5e10435e9 class: HierarchicalListView
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  1077
            widthOfContents := alignTextRightX + maxWidthOfText
c7f5e10435e9 class: HierarchicalListView
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  1078
        ] ifFalse:[
c7f5e10435e9 class: HierarchicalListView
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  1079
            widthOfContents := widthOfContents + (newX - oldX)
c7f5e10435e9 class: HierarchicalListView
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  1080
        ].
c7f5e10435e9 class: HierarchicalListView
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  1081
        width           := listRenderer widthFor:anItem.
c7f5e10435e9 class: HierarchicalListView
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  1082
        startOfText     := self xVisibleOfTextAtLevel:(anItem level).
c7f5e10435e9 class: HierarchicalListView
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  1083
        widthOfContents := widthOfContents max:(startOfText + width).
2316
f91a9635462e bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents: 2313
diff changeset
  1084
4443
c7f5e10435e9 class: HierarchicalListView
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  1085
        width > maxWidthOfText ifTrue:[
c7f5e10435e9 class: HierarchicalListView
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  1086
            maxWidthOfText := width
c7f5e10435e9 class: HierarchicalListView
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  1087
        ].
2316
f91a9635462e bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents: 2313
diff changeset
  1088
    ].
f91a9635462e bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents: 2313
diff changeset
  1089
    self contentsChanged.
2554
0df306e11170 raise -> raiseRequest
Claus Gittinger <cg@exept.de>
parents: 2551
diff changeset
  1090
    StopRedrawSignal raiseRequest.
2353
adc6843fbaa6 prepared for ListItemRenderer
ca
parents: 2351
diff changeset
  1091
    ^ icon
4443
c7f5e10435e9 class: HierarchicalListView
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  1092
c7f5e10435e9 class: HierarchicalListView
Claus Gittinger <cg@exept.de>
parents: 4202
diff changeset
  1093
    "Modified: / 05-11-2013 / 12:32:32 / cg"
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1094
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1095
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1096
!HierarchicalListView methodsFor:'event handling'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1097
1757
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
  1098
buttonPress:button x:x y:y
2791
ebf038543951 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2780
diff changeset
  1099
    "handle a button press event"
ebf038543951 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2780
diff changeset
  1100
3335
6b8fa9796f86 click on icon/label fixed;
Claus Gittinger <cg@exept.de>
parents: 3279
diff changeset
  1101
    |line item xIcon xLabel yItem x0|
2224
bfcabf142faa selection/indicator handling; scrolling horizontal
ca
parents: 2210
diff changeset
  1102
3204
3b6de876f7a2 *** empty log message ***
ca
parents: 3200
diff changeset
  1103
    modelChangedDuringButtonPress := nil.
3b6de876f7a2 *** empty log message ***
ca
parents: 3200
diff changeset
  1104
2224
bfcabf142faa selection/indicator handling; scrolling horizontal
ca
parents: 2210
diff changeset
  1105
    enabled ifFalse:[^ self].
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
  1106
    self closeEditor.
2224
bfcabf142faa selection/indicator handling; scrolling horizontal
ca
parents: 2210
diff changeset
  1107
2313
6e91bdaac5bc delegate buttonPress event to the item
ca
parents: 2312
diff changeset
  1108
    line := self yVisibleToLineNr:y.
6e91bdaac5bc delegate buttonPress event to the item
ca
parents: 2312
diff changeset
  1109
    line notNil ifTrue:[
3741
af2b69a16e04 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1110
        item := self at:line ifAbsent:nil.
af2b69a16e04 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1111
        item notNil ifTrue:[
af2b69a16e04 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1112
            "/ translate the coordinate relative to the items origin
4202
1d2e45fed359 class: HierarchicalListView
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4178
diff changeset
  1113
            (item processButtonPress:button visibleX:x visibleY: y on: self) ifTrue:[
1d2e45fed359 class: HierarchicalListView
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4178
diff changeset
  1114
                ^self
1d2e45fed359 class: HierarchicalListView
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4178
diff changeset
  1115
            ].
1d2e45fed359 class: HierarchicalListView
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4178
diff changeset
  1116
        
3741
af2b69a16e04 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1117
            xIcon := self xVisibleOfIconAtLevel:(item level).
af2b69a16e04 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1118
            x >= xIcon ifTrue:[
af2b69a16e04 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1119
                xLabel := self xVisibleOfTextAtLevel:(item level).
af2b69a16e04 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1120
                yItem := self yVisibleOfLine:line.
2224
bfcabf142faa selection/indicator handling; scrolling horizontal
ca
parents: 2210
diff changeset
  1121
3741
af2b69a16e04 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1122
                x >= xLabel ifTrue:[
af2b69a16e04 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1123
                    (item processButtonPress:button x:(x - xLabel) y:(y - yItem) on:self) == true ifTrue:[
af2b69a16e04 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1124
                        ^ self
af2b69a16e04 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1125
                    ]
af2b69a16e04 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1126
                ].
af2b69a16e04 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1127
                (item processButtonPressOnIcon:button on:self) == true ifTrue:[
af2b69a16e04 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1128
                    ^ self
af2b69a16e04 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1129
                ]
af2b69a16e04 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1130
            ].
af2b69a16e04 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1131
        ]
2313
6e91bdaac5bc delegate buttonPress event to the item
ca
parents: 2312
diff changeset
  1132
    ] ifFalse:[
3741
af2b69a16e04 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1133
        item := nil
2313
6e91bdaac5bc delegate buttonPress event to the item
ca
parents: 2312
diff changeset
  1134
    ].
6e91bdaac5bc delegate buttonPress event to the item
ca
parents: 2312
diff changeset
  1135
2392
2e61452ae911 showIndicators; on default indicators are shown
ca
parents: 2383
diff changeset
  1136
    showIndicators ifTrue:[
3741
af2b69a16e04 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1137
        (button == 1) ifTrue:[
af2b69a16e04 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1138
            (item notNil and:[item hasIndicator]) ifTrue:[
af2b69a16e04 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1139
                x0 := self xVisibleOfIndicatorAtLevel:(item level).
2313
6e91bdaac5bc delegate buttonPress event to the item
ca
parents: 2312
diff changeset
  1140
3741
af2b69a16e04 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1141
                (x between:x0 and:(x0 + indicatorWidth)) ifTrue:[
af2b69a16e04 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1142
                    (item isExpanded and:[item canCollapse not]) ifTrue:[
af2b69a16e04 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1143
                        "/ a special one (like a non-collapsable root)
af2b69a16e04 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1144
                    ] ifFalse:[
af2b69a16e04 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1145
                        self indicatorPressedAt:line.
af2b69a16e04 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1146
                        ^ self
af2b69a16e04 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1147
                    ].
af2b69a16e04 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1148
                ].
af2b69a16e04 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1149
            ].
af2b69a16e04 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1150
        ].
2224
bfcabf142faa selection/indicator handling; scrolling horizontal
ca
parents: 2210
diff changeset
  1151
    ].
2313
6e91bdaac5bc delegate buttonPress event to the item
ca
parents: 2312
diff changeset
  1152
2224
bfcabf142faa selection/indicator handling; scrolling horizontal
ca
parents: 2210
diff changeset
  1153
    super buttonPress:button x:x y:y.
4202
1d2e45fed359 class: HierarchicalListView
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4178
diff changeset
  1154
1d2e45fed359 class: HierarchicalListView
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4178
diff changeset
  1155
    "Modified: / 18-04-2013 / 09:56:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
2224
bfcabf142faa selection/indicator handling; scrolling horizontal
ca
parents: 2210
diff changeset
  1156
!
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1157
2224
bfcabf142faa selection/indicator handling; scrolling horizontal
ca
parents: 2210
diff changeset
  1158
buttonPressOrReleaseAtLine:aLnNr x:x y:y
bfcabf142faa selection/indicator handling; scrolling horizontal
ca
parents: 2210
diff changeset
  1159
    "handle a button press or release at a line
bfcabf142faa selection/indicator handling; scrolling horizontal
ca
parents: 2210
diff changeset
  1160
    "
bfcabf142faa selection/indicator handling; scrolling horizontal
ca
parents: 2210
diff changeset
  1161
    |oldIdx newIdx newItem|
bfcabf142faa selection/indicator handling; scrolling horizontal
ca
parents: 2210
diff changeset
  1162
bfcabf142faa selection/indicator handling; scrolling horizontal
ca
parents: 2210
diff changeset
  1163
    oldIdx := self selectedIndex.
bfcabf142faa selection/indicator handling; scrolling horizontal
ca
parents: 2210
diff changeset
  1164
    super buttonPressOrReleaseAtLine:aLnNr x:x y:y.
bfcabf142faa selection/indicator handling; scrolling horizontal
ca
parents: 2210
diff changeset
  1165
    newIdx := self selectedIndex.
bfcabf142faa selection/indicator handling; scrolling horizontal
ca
parents: 2210
diff changeset
  1166
bfcabf142faa selection/indicator handling; scrolling horizontal
ca
parents: 2210
diff changeset
  1167
    (newIdx ~~ oldIdx and:[newIdx ~~ 0]) ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
  1168
	expandOnSelect ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
  1169
	    newItem := self at:newIdx ifAbsent:nil.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
  1170
	    newItem isNil ifTrue:[^ self].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
  1171
	    newItem expand
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
  1172
	].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
  1173
	"/ done in buttonRelease
3200
c5f79c9b5bd8 bugfix - makeSelectionVisible in buttonRelease
ca
parents: 2963
diff changeset
  1174
"/        self makeLineVisible:newIdx.
c5f79c9b5bd8 bugfix - makeSelectionVisible in buttonRelease
ca
parents: 2963
diff changeset
  1175
    ].
c5f79c9b5bd8 bugfix - makeSelectionVisible in buttonRelease
ca
parents: 2963
diff changeset
  1176
!
c5f79c9b5bd8 bugfix - makeSelectionVisible in buttonRelease
ca
parents: 2963
diff changeset
  1177
1757
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
  1178
keyPress:aKey x:x y:y
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
  1179
    "a key was pressed - handle page-keys here
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
  1180
    "
1784
4b8a7a2811f5 *** empty log message ***
ca
parents: 1783
diff changeset
  1181
    <resource: #keyboard( #CursorLeft #CursorRight )>
1757
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
  1182
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2366
diff changeset
  1183
    |item lineNr isCursorLeft|
1757
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
  1184
1782
4fa475b5037e allow space for indicatationPressed action
ca
parents: 1779
diff changeset
  1185
    enabled ifFalse:[^ self].
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2366
diff changeset
  1186
6c368b8b0ec3 support cursor movements
ca
parents: 2366
diff changeset
  1187
    (    aKey == Character space
6c368b8b0ec3 support cursor movements
ca
parents: 2366
diff changeset
  1188
     or:[aKey == #CursorRight
6c368b8b0ec3 support cursor movements
ca
parents: 2366
diff changeset
  1189
     or:[aKey == #CursorLeft]]
6c368b8b0ec3 support cursor movements
ca
parents: 2366
diff changeset
  1190
    ) ifFalse:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
  1191
	super keyPress:aKey x:x y:y.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
  1192
	^ self
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2366
diff changeset
  1193
    ].
6c368b8b0ec3 support cursor movements
ca
parents: 2366
diff changeset
  1194
6c368b8b0ec3 support cursor movements
ca
parents: 2366
diff changeset
  1195
    lineNr := self cursorLine.
6c368b8b0ec3 support cursor movements
ca
parents: 2366
diff changeset
  1196
6c368b8b0ec3 support cursor movements
ca
parents: 2366
diff changeset
  1197
    lineNr ~~ 0 ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
  1198
	item := cursorItem
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2366
diff changeset
  1199
    ] ifFalse:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
  1200
	lineNr := self selectedIndex.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
  1201
	lineNr == 0 ifTrue:[^ self].
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2366
diff changeset
  1202
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
  1203
	item := self at:lineNr ifAbsent:nil.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
  1204
	item isNil ifTrue:[^ self].
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2366
diff changeset
  1205
    ].
1782
4fa475b5037e allow space for indicatationPressed action
ca
parents: 1779
diff changeset
  1206
4fa475b5037e allow space for indicatationPressed action
ca
parents: 1779
diff changeset
  1207
    aKey == Character space ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
  1208
	item toggleExpand.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
  1209
	^ self
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2366
diff changeset
  1210
    ].
3241
e4ce2c9df9ac shift-right (shift-left) does a recursive-toggle-expand.
Claus Gittinger <cg@exept.de>
parents: 3234
diff changeset
  1211
    isCursorLeft := (aKey == #CursorLeft).
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2366
diff changeset
  1212
6c368b8b0ec3 support cursor movements
ca
parents: 2366
diff changeset
  1213
    item isExpanded == isCursorLeft ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
  1214
	(self sensor ctrlDown or:[self sensor shiftDown]) ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
  1215
	    item recursiveToggleExpand.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
  1216
	] ifFalse:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
  1217
	    item toggleExpand.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
  1218
	].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
  1219
	^ self
1782
4fa475b5037e allow space for indicatationPressed action
ca
parents: 1779
diff changeset
  1220
    ].
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2366
diff changeset
  1221
    isCursorLeft ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
  1222
	(item := item parent) isNil ifTrue:[^ self].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
  1223
	lineNr := self identityIndexOf:item.
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2366
diff changeset
  1224
    ] ifFalse:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
  1225
	item hasChildren ifFalse:[^ self].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
  1226
	lineNr := lineNr + 1.
2179
e105597b0375 on press key left to parent if not expanded
penk
parents: 2134
diff changeset
  1227
    ].
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2366
diff changeset
  1228
2408
8b0d11537dc0 accessing list indirect
ca
parents: 2392
diff changeset
  1229
    item := self at:lineNr ifAbsent:nil.
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2366
diff changeset
  1230
    item isNil ifTrue:[^ self].
6c368b8b0ec3 support cursor movements
ca
parents: 2366
diff changeset
  1231
6c368b8b0ec3 support cursor movements
ca
parents: 2366
diff changeset
  1232
    (self canSelectIndex:lineNr forAdd:false) ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
  1233
	self selection:lineNr
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2366
diff changeset
  1234
    ].
3241
e4ce2c9df9ac shift-right (shift-left) does a recursive-toggle-expand.
Claus Gittinger <cg@exept.de>
parents: 3234
diff changeset
  1235
e4ce2c9df9ac shift-right (shift-left) does a recursive-toggle-expand.
Claus Gittinger <cg@exept.de>
parents: 3234
diff changeset
  1236
    "Modified: / 18-09-2007 / 23:02:09 / cg"
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1237
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1238
1757
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
  1239
!HierarchicalListView methodsFor:'fetch resources'!
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
  1240
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
  1241
fetchResources
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
  1242
    "fetch device colors and ..., to avoid reallocation at redraw time;
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
  1243
     *** called after a create or snapin to fetch all device resources
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
  1244
    "
2316
f91a9635462e bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents: 2313
diff changeset
  1245
    |image defaultWidth|
1757
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
  1246
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
  1247
    super fetchResources.
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
  1248
5003
3ad28e66c27e device access
Claus Gittinger <cg@exept.de>
parents: 4969
diff changeset
  1249
    lineColor      := lineColor onDevice:device.
2488
74c81c1e30d7 imageOnDevice -> imageOnMyDevice
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
  1250
    openIndicator  := self imageOnMyDevice:openIndicator.
74c81c1e30d7 imageOnDevice -> imageOnMyDevice
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
  1251
    closeIndicator := self imageOnMyDevice:closeIndicator.
2316
f91a9635462e bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents: 2313
diff changeset
  1252
    defaultWidth   := imageWidth.
1757
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
  1253
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
  1254
    icons keysAndValuesDo:[:aKey :anImage|
4505
8b2a3ebaeb25 class: HierarchicalListView
Stefan Vogel <sv@exept.de>
parents: 4499
diff changeset
  1255
        anImage isNil ifTrue:[
8b2a3ebaeb25 class: HierarchicalListView
Stefan Vogel <sv@exept.de>
parents: 4499
diff changeset
  1256
            ('HierachicalListView [warning]: missing image: ' , aKey) errorPrintCR.
8b2a3ebaeb25 class: HierarchicalListView
Stefan Vogel <sv@exept.de>
parents: 4499
diff changeset
  1257
        ] ifFalse:[
8b2a3ebaeb25 class: HierarchicalListView
Stefan Vogel <sv@exept.de>
parents: 4499
diff changeset
  1258
            image := self imageOnMyDevice:anImage.
8b2a3ebaeb25 class: HierarchicalListView
Stefan Vogel <sv@exept.de>
parents: 4499
diff changeset
  1259
            icons at:aKey put:image.
8b2a3ebaeb25 class: HierarchicalListView
Stefan Vogel <sv@exept.de>
parents: 4499
diff changeset
  1260
            imageWidth := image width max:imageWidth.
8b2a3ebaeb25 class: HierarchicalListView
Stefan Vogel <sv@exept.de>
parents: 4499
diff changeset
  1261
        ]
1757
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
  1262
    ].
5003
3ad28e66c27e device access
Claus Gittinger <cg@exept.de>
parents: 4969
diff changeset
  1263
    imageWidth      := ((imageWidth + 1) // 2 * 2) max:defaultWidth.
1904
84155d7a6011 access method for #alignTextRightX
ca
parents: 1898
diff changeset
  1264
    alignTextRightX := imageWidth + 20 max:alignTextRightX.
1757
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
  1265
! !
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
  1266
2500
1477b0a5a918 method category rename
Claus Gittinger <cg@exept.de>
parents: 2488
diff changeset
  1267
!HierarchicalListView methodsFor:'initialization & release'!
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1268
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1269
initStyle
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1270
    "setup viewStyle specifics
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1271
    "
2923
b46918a9f6b8 resource directive
Claus Gittinger <cg@exept.de>
parents: 2898
diff changeset
  1272
    <resource: #style (#'selection.highlightEnterItem'
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
  1273
		       #'selection.expandOnSelect'
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
  1274
		       #'selection.autoScrollHorizontal'
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
  1275
		       )>
2923
b46918a9f6b8 resource directive
Claus Gittinger <cg@exept.de>
parents: 2898
diff changeset
  1276
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1277
    |cls|
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1278
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1279
    super initStyle.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1280
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2366
diff changeset
  1281
    cls   := self class.
6c368b8b0ec3 support cursor movements
ca
parents: 2366
diff changeset
  1282
    icons := Dictionary new.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1283
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1284
    openIndicator      := self class openIndicator.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1285
    closeIndicator     := self class closeIndicator.
3279
b2bcf533add5 support different indicator icons
ca
parents: 3276
diff changeset
  1286
    indicatorHeight    := (openIndicator height) max:(closeIndicator height).
b2bcf533add5 support different indicator icons
ca
parents: 3276
diff changeset
  1287
    indicatorWidth     := (openIndicator width) max:(closeIndicator width).
2312
d795e9b4423d recompute width of contents if indicatorAction changed
ca
parents: 2311
diff changeset
  1288
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1289
    lineColor          := fgColor.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1290
    highlightMode      := #label.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1291
    showRoot           := true.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1292
    showLeftIndicators := true.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1293
    useDefaultIcons    := true.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1294
    showLines          := true.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1295
    imageInset         := 4.
2383
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
  1296
    imageWidth         := 0.
1568
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
  1297
    alignTextRight     := false.
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
  1298
    alignTextRightX    := 8.
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
  1299
    maxWidthOfText     := 0.
2224
bfcabf142faa selection/indicator handling; scrolling horizontal
ca
parents: 2210
diff changeset
  1300
3276
0a96cc232552 enableMotionEvents if highlightEnterItem is set to true
ca
parents: 3241
diff changeset
  1301
    self highlightEnterItem:(styleSheet at:#'selection.highlightEnterItem' default:false).
0a96cc232552 enableMotionEvents if highlightEnterItem is set to true
ca
parents: 3241
diff changeset
  1302
2310
b3a1b03a9647 read #expandOnSelect from styleSheet
ca
parents: 2307
diff changeset
  1303
    expandOnSelect       := styleSheet at:#'selection.expandOnSelect' default:false.
2898
745eeceeb6b5 autoScrollHoriz
Claus Gittinger <cg@exept.de>
parents: 2880
diff changeset
  1304
    autoScrollHorizontal := styleSheet at:#'selection.autoScrollHorizontal' default:nil.
2210
c2b830a14832 *** empty log message ***
ca
parents: 2208
diff changeset
  1305
!
c2b830a14832 *** empty log message ***
ca
parents: 2208
diff changeset
  1306
c2b830a14832 *** empty log message ***
ca
parents: 2208
diff changeset
  1307
initialize
c2b830a14832 *** empty log message ***
ca
parents: 2208
diff changeset
  1308
    super initialize.
c2b830a14832 *** empty log message ***
ca
parents: 2208
diff changeset
  1309
    levelOfLastItem := 1.
2898
745eeceeb6b5 autoScrollHoriz
Claus Gittinger <cg@exept.de>
parents: 2880
diff changeset
  1310
    autoScrollHorizontal := true.
3234
53f4c03b615a support icon alignment (default is left)
ca
parents: 3204
diff changeset
  1311
    iconAlignment        := #left.
2392
2e61452ae911 showIndicators; on default indicators are shown
ca
parents: 2383
diff changeset
  1312
2e61452ae911 showIndicators; on default indicators are shown
ca
parents: 2383
diff changeset
  1313
    self showIndicators:true.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1314
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1315
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1316
!HierarchicalListView methodsFor:'private'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1317
2327
73edf9e0d2aa *** empty log message ***
ca
parents: 2325
diff changeset
  1318
iconFor:anItem
73edf9e0d2aa *** empty log message ***
ca
parents: 2325
diff changeset
  1319
    "returns an icon or image for the item or nil if the item
3870
18c8952dc8cc changed: #iconFor:
Claus Gittinger <cg@exept.de>
parents: 3850
diff changeset
  1320
     provides no image and useDefaultIcons is switched off,
18c8952dc8cc changed: #iconFor:
Claus Gittinger <cg@exept.de>
parents: 3850
diff changeset
  1321
     or if anItem returns #none from the icon query.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1322
    "
2307
4a9e9f71537a *** empty log message ***
ca
parents: 2303
diff changeset
  1323
    |iconOrKey image|
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1324
2307
4a9e9f71537a *** empty log message ***
ca
parents: 2303
diff changeset
  1325
    "/ get the icon or access key from the item
4a9e9f71537a *** empty log message ***
ca
parents: 2303
diff changeset
  1326
    iconOrKey := anItem icon.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1327
2307
4a9e9f71537a *** empty log message ***
ca
parents: 2303
diff changeset
  1328
    iconOrKey notNil ifTrue:[
3870
18c8952dc8cc changed: #iconFor:
Claus Gittinger <cg@exept.de>
parents: 3850
diff changeset
  1329
        iconOrKey isImageOrForm ifTrue:[
18c8952dc8cc changed: #iconFor:
Claus Gittinger <cg@exept.de>
parents: 3850
diff changeset
  1330
            "/ got an image; have to register the image on my device
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1331
5003
3ad28e66c27e device access
Claus Gittinger <cg@exept.de>
parents: 4969
diff changeset
  1332
            iconOrKey device == device ifTrue:[
3870
18c8952dc8cc changed: #iconFor:
Claus Gittinger <cg@exept.de>
parents: 3850
diff changeset
  1333
                ^ iconOrKey
18c8952dc8cc changed: #iconFor:
Claus Gittinger <cg@exept.de>
parents: 3850
diff changeset
  1334
            ].
18c8952dc8cc changed: #iconFor:
Claus Gittinger <cg@exept.de>
parents: 3850
diff changeset
  1335
            ^ icons at:iconOrKey ifAbsentPut:[ self imageOnMyDevice:iconOrKey ].
18c8952dc8cc changed: #iconFor:
Claus Gittinger <cg@exept.de>
parents: 3850
diff changeset
  1336
        ].
18c8952dc8cc changed: #iconFor:
Claus Gittinger <cg@exept.de>
parents: 3850
diff changeset
  1337
        iconOrKey == #none ifTrue:[^ nil].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1338
3870
18c8952dc8cc changed: #iconFor:
Claus Gittinger <cg@exept.de>
parents: 3850
diff changeset
  1339
        image := icons at:iconOrKey ifAbsent:nil.
18c8952dc8cc changed: #iconFor:
Claus Gittinger <cg@exept.de>
parents: 3850
diff changeset
  1340
        image notNil ifTrue:[ ^ image ].
2307
4a9e9f71537a *** empty log message ***
ca
parents: 2303
diff changeset
  1341
    ].
4a9e9f71537a *** empty log message ***
ca
parents: 2303
diff changeset
  1342
4a9e9f71537a *** empty log message ***
ca
parents: 2303
diff changeset
  1343
    "/ test whether a default image should be returned
4a9e9f71537a *** empty log message ***
ca
parents: 2303
diff changeset
  1344
    useDefaultIcons ifFalse:[
3870
18c8952dc8cc changed: #iconFor:
Claus Gittinger <cg@exept.de>
parents: 3850
diff changeset
  1345
        ^ nil
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1346
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1347
2307
4a9e9f71537a *** empty log message ***
ca
parents: 2303
diff changeset
  1348
    anItem hasChildren ifFalse:[
3870
18c8952dc8cc changed: #iconFor:
Claus Gittinger <cg@exept.de>
parents: 3850
diff changeset
  1349
        anItem isDirectoryItem ifFalse:[
18c8952dc8cc changed: #iconFor:
Claus Gittinger <cg@exept.de>
parents: 3850
diff changeset
  1350
            ^ icons at:#empty ifAbsentPut:[ self imageOnMyDevice:(self class emptyIcon) ]
18c8952dc8cc changed: #iconFor:
Claus Gittinger <cg@exept.de>
parents: 3850
diff changeset
  1351
        ].
18c8952dc8cc changed: #iconFor:
Claus Gittinger <cg@exept.de>
parents: 3850
diff changeset
  1352
        ^ icons at:#collapsed ifAbsentPut:[ self imageOnMyDevice:(self class collapsedIcon) ].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1353
    ].
1898
4239a343dbe6 remove defaule icons from list of icons; create lazy
ca
parents: 1897
diff changeset
  1354
2307
4a9e9f71537a *** empty log message ***
ca
parents: 2303
diff changeset
  1355
    anItem isExpanded ifTrue:[
3870
18c8952dc8cc changed: #iconFor:
Claus Gittinger <cg@exept.de>
parents: 3850
diff changeset
  1356
        ^ icons at:#expanded ifAbsentPut:[ self imageOnMyDevice:(self class expandedIcon) ].
1898
4239a343dbe6 remove defaule icons from list of icons; create lazy
ca
parents: 1897
diff changeset
  1357
    ].
2488
74c81c1e30d7 imageOnDevice -> imageOnMyDevice
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
  1358
    ^ icons at:#collapsed ifAbsentPut:[ self imageOnMyDevice:(self class collapsedIcon) ].
2963
0e53c2bb4424 use isDirectoryItem to allow for drawing of empty directories
fm
parents: 2949
diff changeset
  1359
0e53c2bb4424 use isDirectoryItem to allow for drawing of empty directories
fm
parents: 2949
diff changeset
  1360
    "Modified: / 23-06-2006 / 12:47:33 / fm"
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1361
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1362
2353
adc6843fbaa6 prepared for ListItemRenderer
ca
parents: 2351
diff changeset
  1363
lineHeightFor:anItem
adc6843fbaa6 prepared for ListItemRenderer
ca
parents: 2351
diff changeset
  1364
    "returns the computed line height for an item
adc6843fbaa6 prepared for ListItemRenderer
ca
parents: 2351
diff changeset
  1365
    "
adc6843fbaa6 prepared for ListItemRenderer
ca
parents: 2351
diff changeset
  1366
    |image height|
adc6843fbaa6 prepared for ListItemRenderer
ca
parents: 2351
diff changeset
  1367
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
  1368
    height := listRenderer heightFor:anItem.
2353
adc6843fbaa6 prepared for ListItemRenderer
ca
parents: 2351
diff changeset
  1369
    image := self iconFor:anItem.
adc6843fbaa6 prepared for ListItemRenderer
ca
parents: 2351
diff changeset
  1370
adc6843fbaa6 prepared for ListItemRenderer
ca
parents: 2351
diff changeset
  1371
    image notNil ifTrue:[
4625
b64d176d2bd6 class: HierarchicalListView
Stefan Vogel <sv@exept.de>
parents: 4590
diff changeset
  1372
        height := image height max:height.
2353
adc6843fbaa6 prepared for ListItemRenderer
ca
parents: 2351
diff changeset
  1373
    ].
adc6843fbaa6 prepared for ListItemRenderer
ca
parents: 2351
diff changeset
  1374
adc6843fbaa6 prepared for ListItemRenderer
ca
parents: 2351
diff changeset
  1375
    hasConstantHeight ifTrue:[
4625
b64d176d2bd6 class: HierarchicalListView
Stefan Vogel <sv@exept.de>
parents: 4590
diff changeset
  1376
        icons size ~~ 0 ifTrue:[
b64d176d2bd6 class: HierarchicalListView
Stefan Vogel <sv@exept.de>
parents: 4590
diff changeset
  1377
            icons do:[:anIcon| height := anIcon height max:height ]
b64d176d2bd6 class: HierarchicalListView
Stefan Vogel <sv@exept.de>
parents: 4590
diff changeset
  1378
        ] ifFalse:[
b64d176d2bd6 class: HierarchicalListView
Stefan Vogel <sv@exept.de>
parents: 4590
diff changeset
  1379
            image isNil ifTrue:[ height := height max:16 ]
b64d176d2bd6 class: HierarchicalListView
Stefan Vogel <sv@exept.de>
parents: 4590
diff changeset
  1380
       ]
2353
adc6843fbaa6 prepared for ListItemRenderer
ca
parents: 2351
diff changeset
  1381
    ].
adc6843fbaa6 prepared for ListItemRenderer
ca
parents: 2351
diff changeset
  1382
    height := height + lineSpacing.
3279
b2bcf533add5 support different indicator icons
ca
parents: 3276
diff changeset
  1383
    ^ height max:indicatorHeight
2353
adc6843fbaa6 prepared for ListItemRenderer
ca
parents: 2351
diff changeset
  1384
!
adc6843fbaa6 prepared for ListItemRenderer
ca
parents: 2351
diff changeset
  1385
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1386
smallestLevelBetween:start and:stop
2327
73edf9e0d2aa *** empty log message ***
ca
parents: 2325
diff changeset
  1387
    "returns the smallest level of all items in a range
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1388
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1389
    |prevItem currParent nextParent item
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1391
     lvl "{ Class:SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1392
     min "{ Class:SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1393
     beg "{ Class:SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1394
    |
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1395
2408
8b0d11537dc0 accessing list indirect
ca
parents: 2392
diff changeset
  1396
    prevItem := self at:start ifAbsent:nil.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1397
1508
9c54f2e53da1 check whether #at:ifAbsent returns nil.
Claus Gittinger <cg@exept.de>
parents: 1431
diff changeset
  1398
    (prevItem isNil or:[(currParent := prevItem parent) isNil]) ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
  1399
	^ 1
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1400
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1401
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1402
    (min := prevItem level) == 2 ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
  1403
	^ min
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1404
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1405
    beg := start + 1.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1406
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1407
    beg to:stop do:[:i|
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
  1408
	item := self at:i ifAbsent:nil.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
  1409
	item isNil ifTrue:[^ min].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1410
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
  1411
	(nextParent := item parent) == currParent ifFalse:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
  1412
	    (currParent := nextParent) == prevItem ifFalse:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
  1413
		(lvl := item level) == 2 ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
  1414
		    ^ 2
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
  1415
		].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
  1416
		min := min min:lvl
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
  1417
	    ]
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
  1418
	].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
  1419
	prevItem := item
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1420
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1421
    ^ min
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1422
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1423
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1424
widthOfWidestLineBetween:firstLine and:lastLine
2327
73edf9e0d2aa *** empty log message ***
ca
parents: 2325
diff changeset
  1425
    "returns the width of the longest line in pixels in a range
4859
4c7eb9125cf2 #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 4828
diff changeset
  1426
     - used to optimize scrolling, by limiting the scrolled area;
4c7eb9125cf2 #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 4828
diff changeset
  1427
       not for scrollbar or other width related stuff which should be exact."
4c7eb9125cf2 #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 4828
diff changeset
  1428
    
2645
b3d3e7c3ee40 bugfix due to compilation (test SmallInteger for nil)
ca
parents: 2644
diff changeset
  1429
    |parent item textX level width widthOfLabel|
b3d3e7c3ee40 bugfix due to compilation (test SmallInteger for nil)
ca
parents: 2644
diff changeset
  1430
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
  1431
    width := listRenderer widthOfWidestLineBetween:firstLine and:lastLine.
2644
78ca3bd5eef1 prepared for table
ca
parents: 2606
diff changeset
  1432
    width notNil ifTrue:[^ width].
78ca3bd5eef1 prepared for table
ca
parents: 2606
diff changeset
  1433
2383
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
  1434
    width := 20.
1568
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
  1435
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
  1436
    alignTextRight ifTrue:[
4859
4c7eb9125cf2 #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 4828
diff changeset
  1437
        parent := nil.
4c7eb9125cf2 #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 4828
diff changeset
  1438
        level  := 1.
2383
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
  1439
4859
4c7eb9125cf2 #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 4828
diff changeset
  1440
        firstLine to:lastLine do:[:idx|
4c7eb9125cf2 #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 4828
diff changeset
  1441
            item := self at:idx ifAbsent:nil.
2316
f91a9635462e bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents: 2313
diff changeset
  1442
4859
4c7eb9125cf2 #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 4828
diff changeset
  1443
            item notNil ifTrue:[
4c7eb9125cf2 #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 4828
diff changeset
  1444
                width := (listRenderer widthFor:item) max:width.
1568
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
  1445
4859
4c7eb9125cf2 #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 4828
diff changeset
  1446
                item parent ~~ parent ifTrue:[
4c7eb9125cf2 #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 4828
diff changeset
  1447
                    level  := item level max:level.
4c7eb9125cf2 #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 4828
diff changeset
  1448
                    parent := item parent.
4c7eb9125cf2 #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 4828
diff changeset
  1449
                ].
4c7eb9125cf2 #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 4828
diff changeset
  1450
            ].
4c7eb9125cf2 #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 4828
diff changeset
  1451
        ].
4c7eb9125cf2 #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 4828
diff changeset
  1452
        maxWidthOfText := maxWidthOfText max:width.
4c7eb9125cf2 #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 4828
diff changeset
  1453
        textX := self xVisibleOfIconAtLevel:(level + 1).
2316
f91a9635462e bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents: 2313
diff changeset
  1454
4859
4c7eb9125cf2 #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 4828
diff changeset
  1455
        alignTextRightX < textX ifTrue:[
4c7eb9125cf2 #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 4828
diff changeset
  1456
            alignTextRightX := textX.
4c7eb9125cf2 #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 4828
diff changeset
  1457
            self invalidate.
4c7eb9125cf2 #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 4828
diff changeset
  1458
        ].
4c7eb9125cf2 #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 4828
diff changeset
  1459
        ^ alignTextRightX + width
1568
f349d6b00f77 support of align text right
ca
parents: 1567
diff changeset
  1460
    ].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1461
2383
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
  1462
    parent := 4711.  "/ force a computation
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1463
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1464
    firstLine to:lastLine do:[:idx|
4859
4c7eb9125cf2 #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 4828
diff changeset
  1465
        item := self at:idx ifAbsent:nil.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1466
4859
4c7eb9125cf2 #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 4828
diff changeset
  1467
        item notNil ifTrue:[
4c7eb9125cf2 #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 4828
diff changeset
  1468
            item parent ~~ parent ifTrue:[
4c7eb9125cf2 #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 4828
diff changeset
  1469
                textX  := self xVisibleOfTextAtLevel:(item level).
4c7eb9125cf2 #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 4828
diff changeset
  1470
                parent := item parent.
4c7eb9125cf2 #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 4828
diff changeset
  1471
            ].
4c7eb9125cf2 #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 4828
diff changeset
  1472
            widthOfLabel   := listRenderer widthFor:item.
4c7eb9125cf2 #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 4828
diff changeset
  1473
            maxWidthOfText := maxWidthOfText max:widthOfLabel.
4c7eb9125cf2 #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 4828
diff changeset
  1474
            width          := widthOfLabel + textX max:width
4c7eb9125cf2 #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 4828
diff changeset
  1475
        ].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1476
    ].
2383
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
  1477
    ^ width + viewOrigin x.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1478
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1479
2327
73edf9e0d2aa *** empty log message ***
ca
parents: 2325
diff changeset
  1480
xVisibleOfIconAtLevel:aLevel
73edf9e0d2aa *** empty log message ***
ca
parents: 2325
diff changeset
  1481
    "returns the visible origin x of the icon at a level.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1482
    "
2383
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
  1483
    |x|
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1484
2383
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
  1485
    x := self xVisibleOfVerticalLineAt:aLevel.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1486
2383
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
  1487
    (showRoot and:[aLevel == 1]) ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
  1488
	showLeftIndicators ifFalse:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
  1489
	    ^ x - (imageWidth // 2)
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
  1490
	].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1491
    ].
3279
b2bcf533add5 support different indicator icons
ca
parents: 3276
diff changeset
  1492
    ^ x + (indicatorWidth // 2) + imageInset
2383
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
  1493
!
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
  1494
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
  1495
xVisibleOfIndicatorAtLevel:aLevel
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
  1496
    "returns the visible origin x of the vertical line at a level.
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
  1497
    "
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
  1498
    |x|
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
  1499
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
  1500
    x := self xVisibleOfVerticalLineAt:aLevel.
3279
b2bcf533add5 support different indicator icons
ca
parents: 3276
diff changeset
  1501
    x := x - (indicatorWidth // 2).
2383
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
  1502
    ^ x
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1503
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1504
2327
73edf9e0d2aa *** empty log message ***
ca
parents: 2325
diff changeset
  1505
xVisibleOfItem:anItem
73edf9e0d2aa *** empty log message ***
ca
parents: 2325
diff changeset
  1506
    "returns the visible origin x of the item's label.
73edf9e0d2aa *** empty log message ***
ca
parents: 2325
diff changeset
  1507
    "
73edf9e0d2aa *** empty log message ***
ca
parents: 2325
diff changeset
  1508
    ^ self xVisibleOfTextAtLevel:(anItem level)
73edf9e0d2aa *** empty log message ***
ca
parents: 2325
diff changeset
  1509
!
73edf9e0d2aa *** empty log message ***
ca
parents: 2325
diff changeset
  1510
73edf9e0d2aa *** empty log message ***
ca
parents: 2325
diff changeset
  1511
xVisibleOfTextAtLevel:aLevel
73edf9e0d2aa *** empty log message ***
ca
parents: 2325
diff changeset
  1512
    "returns the visible origin x of the text label at a level.
1757
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
  1513
    "
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
  1514
    alignTextRight ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
  1515
	^ alignTextRightX - (viewOrigin x)
1757
6eb078ed6949 *** empty log message ***
ca
parents: 1756
diff changeset
  1516
    ].
2327
73edf9e0d2aa *** empty log message ***
ca
parents: 2325
diff changeset
  1517
    ^ (self xVisibleOfIconAtLevel:aLevel) + imageWidth + textStartLeft
2383
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
  1518
!
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
  1519
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
  1520
xVisibleOfVerticalLineAt:aLevel
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
  1521
    "returns the visible origin x of the vertical line assigned to a level.
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
  1522
    "
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
  1523
    |xOffset opWidth2 igWidth2 firstLevel|
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
  1524
3279
b2bcf533add5 support different indicator icons
ca
parents: 3276
diff changeset
  1525
    opWidth2 := indicatorWidth // 2.
2383
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
  1526
    igWidth2 := imageWidth // 2.
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
  1527
    xOffset  := igWidth2 + opWidth2 + imageInset.
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
  1528
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
  1529
    showRoot ifTrue:[ firstLevel := 1 ]
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
  1530
	    ifFalse:[ firstLevel := 2 ].
2383
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
  1531
2392
2e61452ae911 showIndicators; on default indicators are shown
ca
parents: 2383
diff changeset
  1532
    showLeftIndicators ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
  1533
	aLevel < firstLevel ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
  1534
	    xOffset := opWidth2 - (firstLevel * xOffset)
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
  1535
	] ifFalse:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
  1536
	    xOffset := opWidth2 + ((aLevel - firstLevel) * xOffset)
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
  1537
	]
2383
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
  1538
    ] ifFalse:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
  1539
	aLevel < 2 ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
  1540
	    xOffset := igWidth2 - ((aLevel - firstLevel) * xOffset)
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
  1541
	] ifFalse:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
  1542
	    xOffset := igWidth2 + ((aLevel - firstLevel - 1) * xOffset)
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
  1543
	].
2383
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
  1544
    ].
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
  1545
    "/ 2 := a left margin
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
  1546
    ^ xOffset + 2 - (viewOrigin x)
3977
e81ca26b8a23 bugfix: drawing lines dotted
ca
parents: 3937
diff changeset
  1547
!
e81ca26b8a23 bugfix: drawing lines dotted
ca
parents: 3937
diff changeset
  1548
e81ca26b8a23 bugfix: drawing lines dotted
ca
parents: 3937
diff changeset
  1549
yVisibleOfIndicatorForItem:anItem
e81ca26b8a23 bugfix: drawing lines dotted
ca
parents: 3937
diff changeset
  1550
    |index y0 y1|
e81ca26b8a23 bugfix: drawing lines dotted
ca
parents: 3937
diff changeset
  1551
e81ca26b8a23 bugfix: drawing lines dotted
ca
parents: 3937
diff changeset
  1552
    index := list identityIndexOf:anItem.
e81ca26b8a23 bugfix: drawing lines dotted
ca
parents: 3937
diff changeset
  1553
    index > 0 ifTrue:[
e81ca26b8a23 bugfix: drawing lines dotted
ca
parents: 3937
diff changeset
  1554
        y0 := self yVisibleOfLine:index.
e81ca26b8a23 bugfix: drawing lines dotted
ca
parents: 3937
diff changeset
  1555
        y1 := self yVisibleOfLine:(index + 1).
e81ca26b8a23 bugfix: drawing lines dotted
ca
parents: 3937
diff changeset
  1556
e81ca26b8a23 bugfix: drawing lines dotted
ca
parents: 3937
diff changeset
  1557
        ^ (y0 + y1) // 2.
e81ca26b8a23 bugfix: drawing lines dotted
ca
parents: 3937
diff changeset
  1558
    ].
e81ca26b8a23 bugfix: drawing lines dotted
ca
parents: 3937
diff changeset
  1559
    ^ 0
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1560
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1561
2224
bfcabf142faa selection/indicator handling; scrolling horizontal
ca
parents: 2210
diff changeset
  1562
!HierarchicalListView methodsFor:'scrolling'!
bfcabf142faa selection/indicator handling; scrolling horizontal
ca
parents: 2210
diff changeset
  1563
bfcabf142faa selection/indicator handling; scrolling horizontal
ca
parents: 2210
diff changeset
  1564
computeViewOriginXat:aLnrNr
2327
73edf9e0d2aa *** empty log message ***
ca
parents: 2325
diff changeset
  1565
    "returns the viewOrigin x to make the item at a line visisble
2224
bfcabf142faa selection/indicator handling; scrolling horizontal
ca
parents: 2210
diff changeset
  1566
    "
2383
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
  1567
    |item xLft xRgt level vwOrgX useX|
2224
bfcabf142faa selection/indicator handling; scrolling horizontal
ca
parents: 2210
diff changeset
  1568
2233
ebeefdebf761 *** empty log message ***
ca
parents: 2229
diff changeset
  1569
    vwOrgX := viewOrigin x.
2224
bfcabf142faa selection/indicator handling; scrolling horizontal
ca
parents: 2210
diff changeset
  1570
2866
01d609cfb3d9 autoscrollHorizontal confusion cleanup
Claus Gittinger <cg@exept.de>
parents: 2822
diff changeset
  1571
    self autoScrollHorizontal ifFalse:[^ vwOrgX ].
2644
78ca3bd5eef1 prepared for table
ca
parents: 2606
diff changeset
  1572
2383
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
  1573
    alignTextRight ifTrue:[ ^ vwOrgX ].
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
  1574
    aLnrNr == 1    ifTrue:[ ^ 0 ].
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
  1575
2408
8b0d11537dc0 accessing list indirect
ca
parents: 2392
diff changeset
  1576
    item := self at:aLnrNr ifAbsent:nil.
2307
4a9e9f71537a *** empty log message ***
ca
parents: 2303
diff changeset
  1577
    item isNil ifTrue:[ ^ vwOrgX ].
2224
bfcabf142faa selection/indicator handling; scrolling horizontal
ca
parents: 2210
diff changeset
  1578
bfcabf142faa selection/indicator handling; scrolling horizontal
ca
parents: 2210
diff changeset
  1579
    level := item level.
2383
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
  1580
    level == 1 ifTrue:[ ^ 0 ].                                  "/ is root item
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
  1581
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
  1582
    level == 2 ifTrue:[                                         "/ parent is root
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
  1583
	(showRoot and:[showLeftIndicators]) ifFalse:[ ^ 0 ].
2383
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
  1584
    ].
2224
bfcabf142faa selection/indicator handling; scrolling horizontal
ca
parents: 2210
diff changeset
  1585
2327
73edf9e0d2aa *** empty log message ***
ca
parents: 2325
diff changeset
  1586
    xLft := self xVisibleOfIconAtLevel:(level - 1).
2383
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
  1587
    xLft > 0 ifFalse:[ ^ vwOrgX + xLft max:0 ].
2224
bfcabf142faa selection/indicator handling; scrolling horizontal
ca
parents: 2210
diff changeset
  1588
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
  1589
    xRgt := (self xVisibleOfTextAtLevel:level) + (listRenderer widthFor:item).
2383
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
  1590
    useX := xRgt - width.
2224
bfcabf142faa selection/indicator handling; scrolling horizontal
ca
parents: 2210
diff changeset
  1591
2383
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
  1592
    useX > 0 ifFalse:[ ^ vwOrgX ].
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
  1593
    useX := useX + 16 min:xLft.
ed5e995b7dc4 support of no images
ca
parents: 2378
diff changeset
  1594
    ^ vwOrgX + useX.
2224
bfcabf142faa selection/indicator handling; scrolling horizontal
ca
parents: 2210
diff changeset
  1595
!
bfcabf142faa selection/indicator handling; scrolling horizontal
ca
parents: 2210
diff changeset
  1596
2726
9a9900c1372b *** empty log message ***
martin
parents: 2659
diff changeset
  1597
makeItemVisible:anItem withMinimumLines:aNumber
9a9900c1372b *** empty log message ***
martin
parents: 2659
diff changeset
  1598
    "handle indicator pressed action;
9a9900c1372b *** empty log message ***
martin
parents: 2659
diff changeset
  1599
     if the item changed expanded, we try to show all
9a9900c1372b *** empty log message ***
martin
parents: 2659
diff changeset
  1600
     new visible children
9a9900c1372b *** empty log message ***
martin
parents: 2659
diff changeset
  1601
    "
9a9900c1372b *** empty log message ***
martin
parents: 2659
diff changeset
  1602
    |availY usedY vwOrgX vwOrgY lineNr numLines|
9a9900c1372b *** empty log message ***
martin
parents: 2659
diff changeset
  1603
9a9900c1372b *** empty log message ***
martin
parents: 2659
diff changeset
  1604
    lineNr := list identityIndexOf:anItem.
9a9900c1372b *** empty log message ***
martin
parents: 2659
diff changeset
  1605
    lineNr == 0 ifTrue:[ ^ self].
9a9900c1372b *** empty log message ***
martin
parents: 2659
diff changeset
  1606
9a9900c1372b *** empty log message ***
martin
parents: 2659
diff changeset
  1607
    numLines := anItem numberOfVisibleChildren.
9a9900c1372b *** empty log message ***
martin
parents: 2659
diff changeset
  1608
    numLines := numLines max:(aNumber ? 5).
9a9900c1372b *** empty log message ***
martin
parents: 2659
diff changeset
  1609
    numLines := lineNr + numLines min:(list size).
9a9900c1372b *** empty log message ***
martin
parents: 2659
diff changeset
  1610
9a9900c1372b *** empty log message ***
martin
parents: 2659
diff changeset
  1611
    vwOrgY := viewOrigin y.
9a9900c1372b *** empty log message ***
martin
parents: 2659
diff changeset
  1612
    availY := (self yVisibleOfLine:lineNr) - (self yVisibleOfLine:1).
9a9900c1372b *** empty log message ***
martin
parents: 2659
diff changeset
  1613
9a9900c1372b *** empty log message ***
martin
parents: 2659
diff changeset
  1614
    availY > margin ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
  1615
	usedY := (self yVisibleOfLine:(numLines + 1)) - (height - margin - margin).
2726
9a9900c1372b *** empty log message ***
martin
parents: 2659
diff changeset
  1616
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
  1617
	usedY > 1 ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
  1618
	    vwOrgY := vwOrgY + (usedY min:availY).
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3614
diff changeset
  1619
	].
2726
9a9900c1372b *** empty log message ***
martin
parents: 2659
diff changeset
  1620
    ].
9a9900c1372b *** empty log message ***
martin
parents: 2659
diff changeset
  1621
    vwOrgX := self computeViewOriginXat:lineNr.
9a9900c1372b *** empty log message ***
martin
parents: 2659
diff changeset
  1622
9a9900c1372b *** empty log message ***
martin
parents: 2659
diff changeset
  1623
    self scrollTo:(vwOrgX @ vwOrgY).
9a9900c1372b *** empty log message ***
martin
parents: 2659
diff changeset
  1624
!
9a9900c1372b *** empty log message ***
martin
parents: 2659
diff changeset
  1625
2780
692ba895ad57 hor. scroll on selection: changed algorithm
ca
parents: 2769
diff changeset
  1626
makeLineVisible:aLineNumber
3890
be7397c40a60 changed: #makeLineVisible:
fm
parents: 3883
diff changeset
  1627
    "make the line horizontally and vertically visible"
be7397c40a60 changed: #makeLineVisible:
fm
parents: 3883
diff changeset
  1628
2780
692ba895ad57 hor. scroll on selection: changed algorithm
ca
parents: 2769
diff changeset
  1629
    |newY item y0 oldX newX wLine|
2224
bfcabf142faa selection/indicator handling; scrolling horizontal
ca
parents: 2210
diff changeset
  1630
3890
be7397c40a60 changed: #makeLineVisible:
fm
parents: 3883
diff changeset
  1631
    "/ alignTextRight ifTrue:[^ self].
2780
692ba895ad57 hor. scroll on selection: changed algorithm
ca
parents: 2769
diff changeset
  1632
    aLineNumber < 1 ifTrue:[
3890
be7397c40a60 changed: #makeLineVisible:
fm
parents: 3883
diff changeset
  1633
        ^ self
2224
bfcabf142faa selection/indicator handling; scrolling horizontal
ca
parents: 2210
diff changeset
  1634
    ].
bfcabf142faa selection/indicator handling; scrolling horizontal
ca
parents: 2210
diff changeset
  1635
2780
692ba895ad57 hor. scroll on selection: changed algorithm
ca
parents: 2769
diff changeset
  1636
    newX := oldX := viewOrigin x.
2224
bfcabf142faa selection/indicator handling; scrolling horizontal
ca
parents: 2210
diff changeset
  1637
2780
692ba895ad57 hor. scroll on selection: changed algorithm
ca
parents: 2769
diff changeset
  1638
    aLineNumber == 1 ifTrue:[
3890
be7397c40a60 changed: #makeLineVisible:
fm
parents: 3883
diff changeset
  1639
        newX := self computeViewOriginXat:1.
be7397c40a60 changed: #makeLineVisible:
fm
parents: 3883
diff changeset
  1640
        newY := 0.
2780
692ba895ad57 hor. scroll on selection: changed algorithm
ca
parents: 2769
diff changeset
  1641
    ] ifFalse:[
3890
be7397c40a60 changed: #makeLineVisible:
fm
parents: 3883
diff changeset
  1642
        item := self at:aLineNumber ifAbsent:nil.
be7397c40a60 changed: #makeLineVisible:
fm
parents: 3883
diff changeset
  1643
        item isNil ifTrue:[^ self].
2780
692ba895ad57 hor. scroll on selection: changed algorithm
ca
parents: 2769
diff changeset
  1644
3890
be7397c40a60 changed: #makeLineVisible:
fm
parents: 3883
diff changeset
  1645
        y0 := self yVisibleOfLine:aLineNumber.
2224
bfcabf142faa selection/indicator handling; scrolling horizontal
ca
parents: 2210
diff changeset
  1646
3890
be7397c40a60 changed: #makeLineVisible:
fm
parents: 3883
diff changeset
  1647
        (     y0 < margin
be7397c40a60 changed: #makeLineVisible:
fm
parents: 3883
diff changeset
  1648
         or:[(y0 + (listRenderer heightFor:item)) > (height - margin)]
be7397c40a60 changed: #makeLineVisible:
fm
parents: 3883
diff changeset
  1649
        ) ifTrue:[
be7397c40a60 changed: #makeLineVisible:
fm
parents: 3883
diff changeset
  1650
            newY := ((self yAbsoluteOfLine:aLineNumber) - (height // 2)) max:0.
be7397c40a60 changed: #makeLineVisible:
fm
parents: 3883
diff changeset
  1651
        ] ifFalse:[
be7397c40a60 changed: #makeLineVisible:
fm
parents: 3883
diff changeset
  1652
            newY := viewOrigin y.
be7397c40a60 changed: #makeLineVisible:
fm
parents: 3883
diff changeset
  1653
        ].
2224
bfcabf142faa selection/indicator handling; scrolling horizontal
ca
parents: 2210
diff changeset
  1654
3890
be7397c40a60 changed: #makeLineVisible:
fm
parents: 3883
diff changeset
  1655
        self autoScrollHorizontal ifTrue:[
be7397c40a60 changed: #makeLineVisible:
fm
parents: 3883
diff changeset
  1656
            wLine := self widthOfWidestLineBetween:aLineNumber and:aLineNumber.
be7397c40a60 changed: #makeLineVisible:
fm
parents: 3883
diff changeset
  1657
            (wLine < self innerWidth) ifTrue:[
be7397c40a60 changed: #makeLineVisible:
fm
parents: 3883
diff changeset
  1658
                (oldX == 0) ifTrue:[
be7397c40a60 changed: #makeLineVisible:
fm
parents: 3883
diff changeset
  1659
                    newX := self computeViewOriginXat:aLineNumber.
be7397c40a60 changed: #makeLineVisible:
fm
parents: 3883
diff changeset
  1660
                ] ifFalse:[
be7397c40a60 changed: #makeLineVisible:
fm
parents: 3883
diff changeset
  1661
                    newX := 0
be7397c40a60 changed: #makeLineVisible:
fm
parents: 3883
diff changeset
  1662
                ].
be7397c40a60 changed: #makeLineVisible:
fm
parents: 3883
diff changeset
  1663
            ] ifFalse:[
be7397c40a60 changed: #makeLineVisible:
fm
parents: 3883
diff changeset
  1664
                newX := self computeViewOriginXat:aLineNumber.
be7397c40a60 changed: #makeLineVisible:
fm
parents: 3883
diff changeset
  1665
            ].
be7397c40a60 changed: #makeLineVisible:
fm
parents: 3883
diff changeset
  1666
        ].
2224
bfcabf142faa selection/indicator handling; scrolling horizontal
ca
parents: 2210
diff changeset
  1667
    ].
bfcabf142faa selection/indicator handling; scrolling horizontal
ca
parents: 2210
diff changeset
  1668
    self scrollTo:(newX @ newY).
bfcabf142faa selection/indicator handling; scrolling horizontal
ca
parents: 2210
diff changeset
  1669
! !
bfcabf142faa selection/indicator handling; scrolling horizontal
ca
parents: 2210
diff changeset
  1670
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1671
!HierarchicalListView class methodsFor:'documentation'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1672
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1673
version
4828
f0578de62d07 comment only
Claus Gittinger <cg@exept.de>
parents: 4625
diff changeset
  1674
    ^ '$Header$'
3850
c9b77f759762 changed:
Stefan Vogel <sv@exept.de>
parents: 3741
diff changeset
  1675
!
c9b77f759762 changed:
Stefan Vogel <sv@exept.de>
parents: 3741
diff changeset
  1676
c9b77f759762 changed:
Stefan Vogel <sv@exept.de>
parents: 3741
diff changeset
  1677
version_CVS
4828
f0578de62d07 comment only
Claus Gittinger <cg@exept.de>
parents: 4625
diff changeset
  1678
    ^ '$Header$'
6253
733a1d1bc8fc `HierarchicalListView`: draw icon *after* the label itself
Jan Vrany <jan.vrany@labware.com>
parents: 5389
diff changeset
  1679
!
733a1d1bc8fc `HierarchicalListView`: draw icon *after* the label itself
Jan Vrany <jan.vrany@labware.com>
parents: 5389
diff changeset
  1680
733a1d1bc8fc `HierarchicalListView`: draw icon *after* the label itself
Jan Vrany <jan.vrany@labware.com>
parents: 5389
diff changeset
  1681
version_HG
733a1d1bc8fc `HierarchicalListView`: draw icon *after* the label itself
Jan Vrany <jan.vrany@labware.com>
parents: 5389
diff changeset
  1682
733a1d1bc8fc `HierarchicalListView`: draw icon *after* the label itself
Jan Vrany <jan.vrany@labware.com>
parents: 5389
diff changeset
  1683
    ^ '$Changeset: <not expanded> $'
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1684
! !
4178
ce92a9ae0fee class: HierarchicalListView
Claus Gittinger <cg@exept.de>
parents: 3982
diff changeset
  1685