SelectionInTreeView.st
author Jan Vrany <jan.vrany@labware.com>
Fri, 02 Sep 2022 11:25:39 +0100
branchjv
changeset 6261 9b7eb7159d29
parent 5427 3178b508e257
child 5449 31a0fa48835f
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:
444
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
     1
"
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
     2
 COPYRIGHT (c) 1997 by eXept Software AG / Claus Gittinger
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
     3
              All Rights Reserved
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
     4
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
     5
 This software is furnished under a license and may be used
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
    10
 hereby transferred.
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
    11
"
1813
c25b1a3476b2 comment only
Claus Gittinger <cg@exept.de>
parents: 1624
diff changeset
    12
"{ Package: 'stx:libwidg2' }"
c25b1a3476b2 comment only
Claus Gittinger <cg@exept.de>
parents: 1624
diff changeset
    13
5004
fc2a53728ebf device access
Claus Gittinger <cg@exept.de>
parents: 4608
diff changeset
    14
"{ NameSpace: Smalltalk }"
fc2a53728ebf device access
Claus Gittinger <cg@exept.de>
parents: 4608
diff changeset
    15
444
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
    16
SelectionInListView subclass:#SelectionInTreeView
847
8395a2d05464 recompute image height whenever list changed
ca
parents: 846
diff changeset
    17
	instanceVariableNames:'validateDoubleClickBlock selectionHolder rootHolder imageWidth
1815
a5f2bd36e179 double click on expandable item does not perform
Claus Gittinger <cg@exept.de>
parents: 1813
diff changeset
    18
		showLines showLinesForRoot listOfNodes imageInset textInset
a5f2bd36e179 double click on expandable item does not perform
Claus Gittinger <cg@exept.de>
parents: 1813
diff changeset
    19
		labelOffsetY lineMask itemClass lineColor computeResources
a5f2bd36e179 double click on expandable item does not perform
Claus Gittinger <cg@exept.de>
parents: 1813
diff changeset
    20
		showRoot showDirectoryIndicator closeIndicator openIndicator
1171
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
    21
		showDirectoryIndicatorForRoot imageOpened imageClosed imageItem
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
    22
		discardMotionEvents registeredImages supportsExpandAll
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
    23
		buildInArray drawVLinesFromLevel highlightMode editorWidget
1202
b9a3beb20ca7 added an extra validateExpandability block,
Claus Gittinger <cg@exept.de>
parents: 1191
diff changeset
    24
		editorIndex editValueFgColor validateExpandabilityBlock'
1171
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
    25
	classVariableNames:'DefaultHilightMode SelectionInset'
847
8395a2d05464 recompute image height whenever list changed
ca
parents: 846
diff changeset
    26
	poolDictionaries:''
1233
ba2244433fd4 category change
Claus Gittinger <cg@exept.de>
parents: 1214
diff changeset
    27
	category:'Views-Trees'
444
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
    28
!
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
    29
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
    30
!SelectionInTreeView class methodsFor:'documentation'!
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
    31
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
    32
copyright
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
    33
"
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
    34
 COPYRIGHT (c) 1997 by eXept Software AG / Claus Gittinger
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
    35
              All Rights Reserved
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
    36
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
    37
 This software is furnished under a license and may be used
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
    38
 only in accordance with the terms of that license and with the
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
    39
 inclusion of the above copyright notice.   This software may not
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
    40
 be provided or otherwise made available to, or used by, any
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
    41
 other person.  No title to or ownership of the software is
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
    42
 hereby transferred.
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
    43
"
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
    44
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
    45
!
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
    46
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
    47
documentation
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
    48
"
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
    49
    somewhat like a SelectionInListView; but specialized for hierarchical (i.e. tree-like)
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
    50
    lists and adds the functions to show/hide subtrees. 
456
d46a10de4380 change model; supports multiple selection
ca
parents: 448
diff changeset
    51
    Requires SelectionInTree as model and TreeItem (or compatible) list entries.
444
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
    52
1431
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
    53
    Notice: 
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
    54
        This class obsoletes SelectionInHierarchyView, which is no longer
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
    55
        maintained but kept for backward compatibility.
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
    56
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
    57
    Notice2: 
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
    58
        Even for this class, an improved replacement now exists:
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
    59
        HierarchicalListView.
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
    60
        Please consider using that one.
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
    61
        (however, this class is kept for backward compatibility).
446
b6ac0f279b2f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 444
diff changeset
    62
444
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
    63
    [see also:]
456
d46a10de4380 change model; supports multiple selection
ca
parents: 448
diff changeset
    64
        SelectionInTree
d46a10de4380 change model; supports multiple selection
ca
parents: 448
diff changeset
    65
        TreeItem
444
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
    66
        SelectionInListView
494
76d8c4e0b612 directory indicator; set a path to be selected
ca
parents: 490
diff changeset
    67
        FileSelectionTree
444
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
    68
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
    69
    [author:]
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
    70
        Claus Atzkern
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
    71
"
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
    72
!
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
    73
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
    74
examples
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
    75
"
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
    76
    shows the tree of smalltalk classes:
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
    77
                                                                        [exBegin]
514
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
    78
      |top sel|
456
d46a10de4380 change model; supports multiple selection
ca
parents: 448
diff changeset
    79
514
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
    80
      top := StandardSystemView new; extent:300@300.
456
d46a10de4380 change model; supports multiple selection
ca
parents: 448
diff changeset
    81
      sel := SelectionInTreeView new.
514
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
    82
      sel root:(TreeItem newAsTreeFromSmalltalkClass:Object).
456
d46a10de4380 change model; supports multiple selection
ca
parents: 448
diff changeset
    83
      sel action:[:nr | Transcript show:'selected:'; showCR:nr].
d46a10de4380 change model; supports multiple selection
ca
parents: 448
diff changeset
    84
      top add:(ScrollableView forView:sel) in:((0.0 @ 0.0 ) corner:( 1.0 @ 1.0)).
d46a10de4380 change model; supports multiple selection
ca
parents: 448
diff changeset
    85
      top open.
d46a10de4380 change model; supports multiple selection
ca
parents: 448
diff changeset
    86
                                                                        [exEnd]
d46a10de4380 change model; supports multiple selection
ca
parents: 448
diff changeset
    87
d46a10de4380 change model; supports multiple selection
ca
parents: 448
diff changeset
    88
485
26e87be7210f showDirectoryIndicator
ca
parents: 483
diff changeset
    89
456
d46a10de4380 change model; supports multiple selection
ca
parents: 448
diff changeset
    90
    same, including nil-subclasses (i.e. really all classes):
d46a10de4380 change model; supports multiple selection
ca
parents: 448
diff changeset
    91
                                                                        [exBegin]
514
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
    92
      |top sel|
444
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
    93
514
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
    94
      top := StandardSystemView new; extent:300@300.
456
d46a10de4380 change model; supports multiple selection
ca
parents: 448
diff changeset
    95
      sel := SelectionInTreeView new.
514
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
    96
      sel root:(TreeItem newAsTreeFromSmalltalkClass:nil).
456
d46a10de4380 change model; supports multiple selection
ca
parents: 448
diff changeset
    97
      sel action:[:nr | Transcript show:'selected:'; showCR:nr].
685
80751cda3340 lines as point
ca
parents: 659
diff changeset
    98
      sel lineColor:(Color red).
456
d46a10de4380 change model; supports multiple selection
ca
parents: 448
diff changeset
    99
      top add:(ScrollableView forView:sel) in:((0.0 @ 0.0 ) corner:( 1.0 @ 1.0)).
d46a10de4380 change model; supports multiple selection
ca
parents: 448
diff changeset
   100
      top open.
d46a10de4380 change model; supports multiple selection
ca
parents: 448
diff changeset
   101
                                                                        [exEnd]
d46a10de4380 change model; supports multiple selection
ca
parents: 448
diff changeset
   102
485
26e87be7210f showDirectoryIndicator
ca
parents: 483
diff changeset
   103
483
1dad61b63e9d optimize doubleClicked & redrawing
ca
parents: 481
diff changeset
   104
485
26e87be7210f showDirectoryIndicator
ca
parents: 483
diff changeset
   105
    shows the tree of smalltalk classes; show directory indication and no
26e87be7210f showDirectoryIndicator
ca
parents: 483
diff changeset
   106
    lines.
26e87be7210f showDirectoryIndicator
ca
parents: 483
diff changeset
   107
                                                                        [exBegin]
514
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
   108
      |top sel|
483
1dad61b63e9d optimize doubleClicked & redrawing
ca
parents: 481
diff changeset
   109
514
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
   110
      top := StandardSystemView new; extent:300@300.
483
1dad61b63e9d optimize doubleClicked & redrawing
ca
parents: 481
diff changeset
   111
      sel := SelectionInTreeView new.
485
26e87be7210f showDirectoryIndicator
ca
parents: 483
diff changeset
   112
      sel showLines:false.
26e87be7210f showDirectoryIndicator
ca
parents: 483
diff changeset
   113
      sel showDirectoryIndicator:true.
514
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
   114
      sel root:(TreeItem newAsTreeFromSmalltalkClass:Object).
485
26e87be7210f showDirectoryIndicator
ca
parents: 483
diff changeset
   115
      sel action:[:nr | Transcript show:'selected:'; showCR:nr].
483
1dad61b63e9d optimize doubleClicked & redrawing
ca
parents: 481
diff changeset
   116
      top add:(ScrollableView forView:sel) in:((0.0 @ 0.0 ) corner:( 1.0 @ 1.0)).
1dad61b63e9d optimize doubleClicked & redrawing
ca
parents: 481
diff changeset
   117
      top open.
485
26e87be7210f showDirectoryIndicator
ca
parents: 483
diff changeset
   118
                                                                        [exEnd]
26e87be7210f showDirectoryIndicator
ca
parents: 483
diff changeset
   119
"
26e87be7210f showDirectoryIndicator
ca
parents: 483
diff changeset
   120
514
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
   121
444
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
   122
! !
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
   123
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
   124
!SelectionInTreeView class methodsFor:'constants'!
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
   125
494
76d8c4e0b612 directory indicator; set a path to be selected
ca
parents: 490
diff changeset
   126
minImageInset
76d8c4e0b612 directory indicator; set a path to be selected
ca
parents: 490
diff changeset
   127
    "returns minimum inset from directory indication to image
471
6fe41e3caca1 add showLines;
ca
parents: 470
diff changeset
   128
    "
494
76d8c4e0b612 directory indicator; set a path to be selected
ca
parents: 490
diff changeset
   129
  ^ 6
490
1129f3cf5cea add directory open/close indication
ca
parents: 485
diff changeset
   130
1129f3cf5cea add directory open/close indication
ca
parents: 485
diff changeset
   131
1129f3cf5cea add directory open/close indication
ca
parents: 485
diff changeset
   132
! !
1129f3cf5cea add directory open/close indication
ca
parents: 485
diff changeset
   133
900
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
   134
!SelectionInTreeView class methodsFor:'defaults'!
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
   135
1171
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
   136
defaultModelClass
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
   137
    "returns the default model
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
   138
    "
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
   139
    ^ SelectionInTree
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
   140
!
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
   141
900
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
   142
updateStyleCache
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
   143
    "extract values from the styleSheet and cache them in class variables"
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
   144
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
   145
    <resource: #style (#'selection.highlightMode')>
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
   146
1171
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
   147
    SelectionInset     := 4.
900
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
   148
    DefaultHilightMode := StyleSheet at:'selection.highlightMode' default:#line.
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
   149
    "
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
   150
     self updateStyleCache
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
   151
    "
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
   152
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
   153
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
   154
! !
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
   155
811
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
   156
!SelectionInTreeView class methodsFor:'resources'!
490
1129f3cf5cea add directory open/close indication
ca
parents: 485
diff changeset
   157
1129f3cf5cea add directory open/close indication
ca
parents: 485
diff changeset
   158
closeIndicator
1278
7083a9583174 comments
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   159
    "returns a little [+] bitmap"
7083a9583174 comments
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   160
1624
1062c88430f9 icon fetch changed
Claus Gittinger <cg@exept.de>
parents: 1620
diff changeset
   161
    ^ HierarchicalListView closeIndicator
811
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
   162
589
979ea44d23ae checkin from browser
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   163
811
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
   164
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
   165
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
   166
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
   167
471
6fe41e3caca1 add showLines;
ca
parents: 470
diff changeset
   168
!
6fe41e3caca1 add showLines;
ca
parents: 470
diff changeset
   169
444
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
   170
imageClosed
1278
7083a9583174 comments
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   171
    "returns a closed file-directory bitmap"
7083a9583174 comments
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   172
1624
1062c88430f9 icon fetch changed
Claus Gittinger <cg@exept.de>
parents: 1620
diff changeset
   173
    ^ HierarchicalListView collapsedIcon
444
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
   174
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
   175
!
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
   176
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
   177
imageItem
1278
7083a9583174 comments
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   178
    "returns a regular file bitmap"
7083a9583174 comments
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   179
1624
1062c88430f9 icon fetch changed
Claus Gittinger <cg@exept.de>
parents: 1620
diff changeset
   180
    ^ HierarchicalListView emptyIcon
444
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
   181
811
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
   182
444
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
   183
811
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
   184
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
   185
444
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
   186
!
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
   187
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
   188
imageOpened
1278
7083a9583174 comments
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   189
    "returns an opened file-directory bitmap"
7083a9583174 comments
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   190
1624
1062c88430f9 icon fetch changed
Claus Gittinger <cg@exept.de>
parents: 1620
diff changeset
   191
    ^ HierarchicalListView expandedIcon
444
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
   192
490
1129f3cf5cea add directory open/close indication
ca
parents: 485
diff changeset
   193
!
1129f3cf5cea add directory open/close indication
ca
parents: 485
diff changeset
   194
1129f3cf5cea add directory open/close indication
ca
parents: 485
diff changeset
   195
openIndicator
1278
7083a9583174 comments
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   196
    "returns a little [-] bitmap"
7083a9583174 comments
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   197
1624
1062c88430f9 icon fetch changed
Claus Gittinger <cg@exept.de>
parents: 1620
diff changeset
   198
    ^ HierarchicalListView openIndicator
490
1129f3cf5cea add directory open/close indication
ca
parents: 485
diff changeset
   199
811
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
   200
444
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
   201
! !
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
   202
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
   203
!SelectionInTreeView methodsFor:'accessing'!
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
   204
900
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
   205
highlightMode
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
   206
    "get the mode how to draw a selected line:
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
   207
        #line           draw whole line selected
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
   208
        #label          draw label selected
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
   209
    "
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
   210
    ^ highlightMode
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
   211
!
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
   212
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
   213
highlightMode:aMode
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
   214
    "set the mode how to draw a selected line:
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
   215
        #line           draw whole line selected
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
   216
        #label          draw label selected
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
   217
    "
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
   218
    |mode|
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
   219
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
   220
    (mode := aMode) == #label ifFalse:[
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
   221
        mode := #line
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
   222
    ].
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
   223
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
   224
    mode ~~ highlightMode ifTrue:[
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
   225
        highlightMode := mode.
2659
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2501
diff changeset
   226
        self invalidate
900
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
   227
    ]
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
   228
!
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
   229
1171
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
   230
itemClass
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
   231
    "returns current itemClass used
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
   232
    "
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
   233
    ^ itemClass
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
   234
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
   235
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
   236
!
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
   237
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
   238
itemClass:anItemClass
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
   239
    "set itemClass to be used
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
   240
    "
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
   241
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
   242
    (anItemClass notNil and:[anItemClass ~~ itemClass]) ifTrue:[
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
   243
        itemClass := anItemClass.
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
   244
        computeResources := true.
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
   245
        self refetchDeviceResources.
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
   246
    ].
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
   247
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
   248
!
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
   249
685
80751cda3340 lines as point
ca
parents: 659
diff changeset
   250
lineColor
80751cda3340 lines as point
ca
parents: 659
diff changeset
   251
    "returns user configured line color or nil
80751cda3340 lines as point
ca
parents: 659
diff changeset
   252
    "
80751cda3340 lines as point
ca
parents: 659
diff changeset
   253
    ^ lineColor
80751cda3340 lines as point
ca
parents: 659
diff changeset
   254
80751cda3340 lines as point
ca
parents: 659
diff changeset
   255
!
80751cda3340 lines as point
ca
parents: 659
diff changeset
   256
80751cda3340 lines as point
ca
parents: 659
diff changeset
   257
lineColor:aColor
80751cda3340 lines as point
ca
parents: 659
diff changeset
   258
    "returns user configured line color or nil
80751cda3340 lines as point
ca
parents: 659
diff changeset
   259
    "
80751cda3340 lines as point
ca
parents: 659
diff changeset
   260
    |col|
80751cda3340 lines as point
ca
parents: 659
diff changeset
   261
80751cda3340 lines as point
ca
parents: 659
diff changeset
   262
    col := aColor = fgColor ifTrue:[nil] ifFalse:[aColor].
80751cda3340 lines as point
ca
parents: 659
diff changeset
   263
80751cda3340 lines as point
ca
parents: 659
diff changeset
   264
    col = lineColor ifFalse:[
80751cda3340 lines as point
ca
parents: 659
diff changeset
   265
        lineColor := col.
5004
fc2a53728ebf device access
Claus Gittinger <cg@exept.de>
parents: 4608
diff changeset
   266
        lineColor notNil ifTrue:[lineColor := lineColor onDevice:device].
2659
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2501
diff changeset
   267
        self invalidate
685
80751cda3340 lines as point
ca
parents: 659
diff changeset
   268
    ]
80751cda3340 lines as point
ca
parents: 659
diff changeset
   269
!
80751cda3340 lines as point
ca
parents: 659
diff changeset
   270
490
1129f3cf5cea add directory open/close indication
ca
parents: 485
diff changeset
   271
nodeAtIndex:anIndex
1129f3cf5cea add directory open/close indication
ca
parents: 485
diff changeset
   272
    "returns node at an index or nil
1129f3cf5cea add directory open/close indication
ca
parents: 485
diff changeset
   273
    "
785
ca
parents: 782
diff changeset
   274
    (anIndex notNil and:[anIndex between:1 and:listOfNodes size]) ifTrue:[
490
1129f3cf5cea add directory open/close indication
ca
parents: 485
diff changeset
   275
        ^ listOfNodes at:anIndex
1129f3cf5cea add directory open/close indication
ca
parents: 485
diff changeset
   276
    ].
1129f3cf5cea add directory open/close indication
ca
parents: 485
diff changeset
   277
  ^ nil
1129f3cf5cea add directory open/close indication
ca
parents: 485
diff changeset
   278
!
1129f3cf5cea add directory open/close indication
ca
parents: 485
diff changeset
   279
507
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
   280
root
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
   281
    "gets the root of the model; the first item into list.
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
   282
    "
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
   283
    ^ self nodeAtIndex:1
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
   284
!
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
   285
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
   286
root:aRoot
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
   287
    "sets the root of the model; the first item into list.
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
   288
    "
514
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
   289
    aRoot notNil ifTrue:[aRoot expand].
507
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
   290
    model root:aRoot
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
   291
!
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
   292
490
1129f3cf5cea add directory open/close indication
ca
parents: 485
diff changeset
   293
textInset
1129f3cf5cea add directory open/close indication
ca
parents: 485
diff changeset
   294
    "get the left inset of the text label
1129f3cf5cea add directory open/close indication
ca
parents: 485
diff changeset
   295
    "
1129f3cf5cea add directory open/close indication
ca
parents: 485
diff changeset
   296
    ^ textInset
1129f3cf5cea add directory open/close indication
ca
parents: 485
diff changeset
   297
!
1129f3cf5cea add directory open/close indication
ca
parents: 485
diff changeset
   298
1129f3cf5cea add directory open/close indication
ca
parents: 485
diff changeset
   299
textInset:anInset
1129f3cf5cea add directory open/close indication
ca
parents: 485
diff changeset
   300
    "set the left inset of the text label
1129f3cf5cea add directory open/close indication
ca
parents: 485
diff changeset
   301
    "
1129f3cf5cea add directory open/close indication
ca
parents: 485
diff changeset
   302
    anInset ~~ textInset ifTrue:[
1129f3cf5cea add directory open/close indication
ca
parents: 485
diff changeset
   303
        anInset >= 0 ifTrue:[
1129f3cf5cea add directory open/close indication
ca
parents: 485
diff changeset
   304
            textInset := anInset.
1129f3cf5cea add directory open/close indication
ca
parents: 485
diff changeset
   305
            self invalidate
1129f3cf5cea add directory open/close indication
ca
parents: 485
diff changeset
   306
        ] ifFalse:[
1129f3cf5cea add directory open/close indication
ca
parents: 485
diff changeset
   307
            self error
1129f3cf5cea add directory open/close indication
ca
parents: 485
diff changeset
   308
        ]
1129f3cf5cea add directory open/close indication
ca
parents: 485
diff changeset
   309
    ].
1129f3cf5cea add directory open/close indication
ca
parents: 485
diff changeset
   310
! !
1129f3cf5cea add directory open/close indication
ca
parents: 485
diff changeset
   311
1129f3cf5cea add directory open/close indication
ca
parents: 485
diff changeset
   312
!SelectionInTreeView methodsFor:'accessing-behavior'!
1129f3cf5cea add directory open/close indication
ca
parents: 485
diff changeset
   313
855
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   314
drawVLinesFromLevel
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   315
    "returns the level vertical lines are drawn from;
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   316
     starting at 1 up to n
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   317
    "
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   318
    ^ drawVLinesFromLevel
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   319
!
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   320
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   321
drawVLinesFromLevel:aLevel
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   322
    "set the level vertical lines are drawn from;
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   323
     starting at 1 up to n
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   324
    "
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   325
    |lv|
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   326
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   327
    lv := (aLevel ? 1) max:1.
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   328
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   329
    lv ~~ drawVLinesFromLevel ifTrue:[
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   330
        drawVLinesFromLevel := lv.
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   331
        self invalidate
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   332
    ]
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   333
!
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   334
835
36202285352f support of expandAll/collapseAll if the indicator
ca
parents: 825
diff changeset
   335
supportsExpandAll
36202285352f support of expandAll/collapseAll if the indicator
ca
parents: 825
diff changeset
   336
    ^ supportsExpandAll
36202285352f support of expandAll/collapseAll if the indicator
ca
parents: 825
diff changeset
   337
!
36202285352f support of expandAll/collapseAll if the indicator
ca
parents: 825
diff changeset
   338
36202285352f support of expandAll/collapseAll if the indicator
ca
parents: 825
diff changeset
   339
supportsExpandAll:aBool
36202285352f support of expandAll/collapseAll if the indicator
ca
parents: 825
diff changeset
   340
36202285352f support of expandAll/collapseAll if the indicator
ca
parents: 825
diff changeset
   341
    supportsExpandAll := aBool
36202285352f support of expandAll/collapseAll if the indicator
ca
parents: 825
diff changeset
   342
!
36202285352f support of expandAll/collapseAll if the indicator
ca
parents: 825
diff changeset
   343
517
14a46095db49 add validateDoubleClickBlock
ca
parents: 514
diff changeset
   344
validateDoubleClickBlock
1202
b9a3beb20ca7 added an extra validateExpandability block,
Claus Gittinger <cg@exept.de>
parents: 1191
diff changeset
   345
    "return the conditionBlock; this block is evaluated before a doubleClick action
517
14a46095db49 add validateDoubleClickBlock
ca
parents: 514
diff changeset
   346
     on a node will be performed. In case of returning false, the doubleClick will
14a46095db49 add validateDoubleClickBlock
ca
parents: 514
diff changeset
   347
     not be handled.
14a46095db49 add validateDoubleClickBlock
ca
parents: 514
diff changeset
   348
   "
14a46095db49 add validateDoubleClickBlock
ca
parents: 514
diff changeset
   349
   ^ validateDoubleClickBlock
14a46095db49 add validateDoubleClickBlock
ca
parents: 514
diff changeset
   350
14a46095db49 add validateDoubleClickBlock
ca
parents: 514
diff changeset
   351
14a46095db49 add validateDoubleClickBlock
ca
parents: 514
diff changeset
   352
!
14a46095db49 add validateDoubleClickBlock
ca
parents: 514
diff changeset
   353
14a46095db49 add validateDoubleClickBlock
ca
parents: 514
diff changeset
   354
validateDoubleClickBlock:aOneArgBlock
14a46095db49 add validateDoubleClickBlock
ca
parents: 514
diff changeset
   355
    "set the conditionBlock; this block is evaluated before a doubleClick action
14a46095db49 add validateDoubleClickBlock
ca
parents: 514
diff changeset
   356
     on a node will be performed. In case of returning false, the doubleClick will
14a46095db49 add validateDoubleClickBlock
ca
parents: 514
diff changeset
   357
     not be handled.
14a46095db49 add validateDoubleClickBlock
ca
parents: 514
diff changeset
   358
   "
14a46095db49 add validateDoubleClickBlock
ca
parents: 514
diff changeset
   359
   validateDoubleClickBlock := aOneArgBlock
14a46095db49 add validateDoubleClickBlock
ca
parents: 514
diff changeset
   360
14a46095db49 add validateDoubleClickBlock
ca
parents: 514
diff changeset
   361
1202
b9a3beb20ca7 added an extra validateExpandability block,
Claus Gittinger <cg@exept.de>
parents: 1191
diff changeset
   362
!
b9a3beb20ca7 added an extra validateExpandability block,
Claus Gittinger <cg@exept.de>
parents: 1191
diff changeset
   363
b9a3beb20ca7 added an extra validateExpandability block,
Claus Gittinger <cg@exept.de>
parents: 1191
diff changeset
   364
validateExpandabilityBlock
b9a3beb20ca7 added an extra validateExpandability block,
Claus Gittinger <cg@exept.de>
parents: 1191
diff changeset
   365
    "return the expand conditionBlock; this block is evaluated before an expand due to
b9a3beb20ca7 added an extra validateExpandability block,
Claus Gittinger <cg@exept.de>
parents: 1191
diff changeset
   366
     a doubleClick on a node will be performed. In case of returning false, 
b9a3beb20ca7 added an extra validateExpandability block,
Claus Gittinger <cg@exept.de>
parents: 1191
diff changeset
   367
     the node will not be expanded.
b9a3beb20ca7 added an extra validateExpandability block,
Claus Gittinger <cg@exept.de>
parents: 1191
diff changeset
   368
   "
b9a3beb20ca7 added an extra validateExpandability block,
Claus Gittinger <cg@exept.de>
parents: 1191
diff changeset
   369
   ^ validateExpandabilityBlock
b9a3beb20ca7 added an extra validateExpandability block,
Claus Gittinger <cg@exept.de>
parents: 1191
diff changeset
   370
b9a3beb20ca7 added an extra validateExpandability block,
Claus Gittinger <cg@exept.de>
parents: 1191
diff changeset
   371
b9a3beb20ca7 added an extra validateExpandability block,
Claus Gittinger <cg@exept.de>
parents: 1191
diff changeset
   372
!
b9a3beb20ca7 added an extra validateExpandability block,
Claus Gittinger <cg@exept.de>
parents: 1191
diff changeset
   373
b9a3beb20ca7 added an extra validateExpandability block,
Claus Gittinger <cg@exept.de>
parents: 1191
diff changeset
   374
validateExpandabilityBlock:aOneArgBlock
b9a3beb20ca7 added an extra validateExpandability block,
Claus Gittinger <cg@exept.de>
parents: 1191
diff changeset
   375
    "set the expand conditionBlock; this block is evaluated before an expand due to
b9a3beb20ca7 added an extra validateExpandability block,
Claus Gittinger <cg@exept.de>
parents: 1191
diff changeset
   376
     a doubleClick on a node will be performed. In case of returning false, 
b9a3beb20ca7 added an extra validateExpandability block,
Claus Gittinger <cg@exept.de>
parents: 1191
diff changeset
   377
     the node will not be expanded.
b9a3beb20ca7 added an extra validateExpandability block,
Claus Gittinger <cg@exept.de>
parents: 1191
diff changeset
   378
   "
b9a3beb20ca7 added an extra validateExpandability block,
Claus Gittinger <cg@exept.de>
parents: 1191
diff changeset
   379
   validateExpandabilityBlock := aOneArgBlock
b9a3beb20ca7 added an extra validateExpandability block,
Claus Gittinger <cg@exept.de>
parents: 1191
diff changeset
   380
b9a3beb20ca7 added an extra validateExpandability block,
Claus Gittinger <cg@exept.de>
parents: 1191
diff changeset
   381
514
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
   382
! !
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
   383
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
   384
!SelectionInTreeView methodsFor:'accessing-channels'!
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
   385
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
   386
rootHolder
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
   387
    "get the holder which keeps the hierarchical list entry or nil
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
   388
    "
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
   389
    ^ rootHolder
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
   390
!
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
   391
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
   392
rootHolder:aValueHolder
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
   393
    "set the holder which keeps the hierarchical list entry or nil
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
   394
    "
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
   395
    rootHolder notNil ifTrue:[
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
   396
        rootHolder removeDependent:self
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
   397
    ].
855
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   398
514
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
   399
    (rootHolder := aValueHolder) notNil ifTrue:[
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
   400
        rootHolder addDependent:self.
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
   401
        self rootFromModel.
494
76d8c4e0b612 directory indicator; set a path to be selected
ca
parents: 490
diff changeset
   402
    ].
514
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
   403
!
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
   404
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
   405
selectionHolder
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
   406
    "get the holder which keeps a list of selected items or nil
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
   407
    "
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
   408
    ^ selectionHolder
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
   409
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
   410
!
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
   411
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
   412
selectionHolder:aHolder
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
   413
    "set the holder which keeps a list of selected items or nil
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
   414
    "
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
   415
    selectionHolder notNil ifTrue:[
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
   416
        selectionHolder removeDependent:self
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
   417
    ].
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
   418
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
   419
    (selectionHolder := aHolder) notNil ifTrue:[
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
   420
        selectionHolder addDependent:self.
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
   421
        self selectionFromModel
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
   422
    ].
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
   423
490
1129f3cf5cea add directory open/close indication
ca
parents: 485
diff changeset
   424
! !
1129f3cf5cea add directory open/close indication
ca
parents: 485
diff changeset
   425
1129f3cf5cea add directory open/close indication
ca
parents: 485
diff changeset
   426
!SelectionInTreeView methodsFor:'accessing-images'!
1129f3cf5cea add directory open/close indication
ca
parents: 485
diff changeset
   427
448
7f9f3531660c cache device images for fast drawing
Claus Gittinger <cg@exept.de>
parents: 446
diff changeset
   428
imageClosed
1278
7083a9583174 comments
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   429
    "return the value of the instance variable 'imageClosed'.
5258
77a3633f2b18 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5213
diff changeset
   430
     That's the (default) bitmap image shown for closed folders
1278
7083a9583174 comments
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   431
     (initialized to a file-directory bitmap)"
448
7f9f3531660c cache device images for fast drawing
Claus Gittinger <cg@exept.de>
parents: 446
diff changeset
   432
7f9f3531660c cache device images for fast drawing
Claus Gittinger <cg@exept.de>
parents: 446
diff changeset
   433
    ^ imageClosed
7f9f3531660c cache device images for fast drawing
Claus Gittinger <cg@exept.de>
parents: 446
diff changeset
   434
7f9f3531660c cache device images for fast drawing
Claus Gittinger <cg@exept.de>
parents: 446
diff changeset
   435
    "Created: 3.7.1997 / 12:34:31 / cg"
7f9f3531660c cache device images for fast drawing
Claus Gittinger <cg@exept.de>
parents: 446
diff changeset
   436
!
7f9f3531660c cache device images for fast drawing
Claus Gittinger <cg@exept.de>
parents: 446
diff changeset
   437
7f9f3531660c cache device images for fast drawing
Claus Gittinger <cg@exept.de>
parents: 446
diff changeset
   438
imageItem
1278
7083a9583174 comments
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   439
    "return the value of the instance variable 'imageItem'.
5258
77a3633f2b18 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5213
diff changeset
   440
     That's the (default) bitmap image shown for regular items
1278
7083a9583174 comments
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   441
     (initialized to a plain-file bitmap)"
448
7f9f3531660c cache device images for fast drawing
Claus Gittinger <cg@exept.de>
parents: 446
diff changeset
   442
7f9f3531660c cache device images for fast drawing
Claus Gittinger <cg@exept.de>
parents: 446
diff changeset
   443
    ^ imageItem
7f9f3531660c cache device images for fast drawing
Claus Gittinger <cg@exept.de>
parents: 446
diff changeset
   444
7f9f3531660c cache device images for fast drawing
Claus Gittinger <cg@exept.de>
parents: 446
diff changeset
   445
    "Created: 3.7.1997 / 12:34:34 / cg"
7f9f3531660c cache device images for fast drawing
Claus Gittinger <cg@exept.de>
parents: 446
diff changeset
   446
!
7f9f3531660c cache device images for fast drawing
Claus Gittinger <cg@exept.de>
parents: 446
diff changeset
   447
2488
74c81c1e30d7 imageOnDevice -> imageOnMyDevice
Claus Gittinger <cg@exept.de>
parents: 2483
diff changeset
   448
imageOnMyDevice:anImage
4608
5e3a4af3be36 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 4516
diff changeset
   449
    "associate image to device and returns the new image."
5e3a4af3be36 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 4516
diff changeset
   450
5e3a4af3be36 Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents: 4516
diff changeset
   451
    anImage isNil ifTrue:[^ nil].
5004
fc2a53728ebf device access
Claus Gittinger <cg@exept.de>
parents: 4608
diff changeset
   452
    ^ anImage onDevice:device.
846
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
   453
1070
856d037fe133 care for non-existing images.
Claus Gittinger <cg@exept.de>
parents: 1061
diff changeset
   454
    "Modified: / 12.8.1998 / 12:46:38 / cg"
448
7f9f3531660c cache device images for fast drawing
Claus Gittinger <cg@exept.de>
parents: 446
diff changeset
   455
!
7f9f3531660c cache device images for fast drawing
Claus Gittinger <cg@exept.de>
parents: 446
diff changeset
   456
7f9f3531660c cache device images for fast drawing
Claus Gittinger <cg@exept.de>
parents: 446
diff changeset
   457
imageOpened
1278
7083a9583174 comments
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   458
    "return the value of the instance variable 'imageOpened'.
5258
77a3633f2b18 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5213
diff changeset
   459
     That's the (default) bitmap image shown for opened folders
1278
7083a9583174 comments
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   460
     (initialized to an open file-directory bitmap)"
448
7f9f3531660c cache device images for fast drawing
Claus Gittinger <cg@exept.de>
parents: 446
diff changeset
   461
7f9f3531660c cache device images for fast drawing
Claus Gittinger <cg@exept.de>
parents: 446
diff changeset
   462
    ^ imageOpened
7f9f3531660c cache device images for fast drawing
Claus Gittinger <cg@exept.de>
parents: 446
diff changeset
   463
7f9f3531660c cache device images for fast drawing
Claus Gittinger <cg@exept.de>
parents: 446
diff changeset
   464
    "Created: 3.7.1997 / 12:34:28 / cg"
471
6fe41e3caca1 add showLines;
ca
parents: 470
diff changeset
   465
! !
6fe41e3caca1 add showLines;
ca
parents: 470
diff changeset
   466
1275
cc62615ed032 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   467
!SelectionInTreeView methodsFor:'accessing-look'!
cc62615ed032 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   468
cc62615ed032 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   469
showDirectoryIndicator
cc62615ed032 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   470
    "returns true if directories has an open/closed indicator
cc62615ed032 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   471
    "
cc62615ed032 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   472
  ^ showDirectoryIndicator
cc62615ed032 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   473
!
cc62615ed032 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   474
cc62615ed032 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   475
showDirectoryIndicator:aState
cc62615ed032 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   476
    "set or clear open/closed indicator for directories
cc62615ed032 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   477
    "
cc62615ed032 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   478
    "show or hide lines
cc62615ed032 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   479
    "
cc62615ed032 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   480
    aState ~~ showDirectoryIndicator ifTrue:[
cc62615ed032 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   481
        showDirectoryIndicator := aState.
cc62615ed032 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   482
        self recomputeDirectoryIndicator.
cc62615ed032 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   483
        self invalidate
cc62615ed032 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   484
    ].
cc62615ed032 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   485
!
cc62615ed032 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   486
cc62615ed032 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   487
showDirectoryIndicatorForRoot
cc62615ed032 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   488
    "returns true if root directory has an open/closed indicator if
cc62615ed032 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   489
     the common showDirectoryIndicator is enabled
cc62615ed032 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   490
    "
cc62615ed032 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   491
    ^ showDirectoryIndicatorForRoot
cc62615ed032 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   492
!
cc62615ed032 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   493
cc62615ed032 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   494
showDirectoryIndicatorForRoot:aState
cc62615ed032 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   495
    "true if root directory has an open/closed indicator if
cc62615ed032 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   496
     the common showDirectoryIndicator is enabled
cc62615ed032 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   497
    "
cc62615ed032 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   498
    aState ~~ showDirectoryIndicatorForRoot ifTrue:[
cc62615ed032 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   499
        showDirectoryIndicatorForRoot := aState.
cc62615ed032 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   500
        self recomputeDirectoryIndicator.
cc62615ed032 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   501
        self invalidate
cc62615ed032 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   502
    ].
cc62615ed032 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   503
!
cc62615ed032 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   504
cc62615ed032 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   505
showLines
cc62615ed032 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   506
    "returns true if lines are shown
cc62615ed032 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   507
    "
cc62615ed032 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   508
  ^ showLines
cc62615ed032 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   509
!
cc62615ed032 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   510
cc62615ed032 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   511
showLines:aState
cc62615ed032 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   512
    "show or hide lines
cc62615ed032 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   513
    "
cc62615ed032 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   514
    aState ~~ showLines ifTrue:[
cc62615ed032 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   515
        showLines := aState.
cc62615ed032 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   516
        self invalidate
cc62615ed032 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   517
    ].
cc62615ed032 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   518
!
cc62615ed032 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   519
1815
a5f2bd36e179 double click on expandable item does not perform
Claus Gittinger <cg@exept.de>
parents: 1813
diff changeset
   520
showLinesForRoot
a5f2bd36e179 double click on expandable item does not perform
Claus Gittinger <cg@exept.de>
parents: 1813
diff changeset
   521
    "returns true if root-lines are shown
a5f2bd36e179 double click on expandable item does not perform
Claus Gittinger <cg@exept.de>
parents: 1813
diff changeset
   522
    "
a5f2bd36e179 double click on expandable item does not perform
Claus Gittinger <cg@exept.de>
parents: 1813
diff changeset
   523
  ^ showLinesForRoot
a5f2bd36e179 double click on expandable item does not perform
Claus Gittinger <cg@exept.de>
parents: 1813
diff changeset
   524
!
a5f2bd36e179 double click on expandable item does not perform
Claus Gittinger <cg@exept.de>
parents: 1813
diff changeset
   525
a5f2bd36e179 double click on expandable item does not perform
Claus Gittinger <cg@exept.de>
parents: 1813
diff changeset
   526
showLinesForRoot:aState
a5f2bd36e179 double click on expandable item does not perform
Claus Gittinger <cg@exept.de>
parents: 1813
diff changeset
   527
    "show or hide lines for root(s)
a5f2bd36e179 double click on expandable item does not perform
Claus Gittinger <cg@exept.de>
parents: 1813
diff changeset
   528
    "
a5f2bd36e179 double click on expandable item does not perform
Claus Gittinger <cg@exept.de>
parents: 1813
diff changeset
   529
    aState ~~ showLinesForRoot ifTrue:[
a5f2bd36e179 double click on expandable item does not perform
Claus Gittinger <cg@exept.de>
parents: 1813
diff changeset
   530
        showLinesForRoot := aState.
a5f2bd36e179 double click on expandable item does not perform
Claus Gittinger <cg@exept.de>
parents: 1813
diff changeset
   531
        self invalidate
a5f2bd36e179 double click on expandable item does not perform
Claus Gittinger <cg@exept.de>
parents: 1813
diff changeset
   532
    ].
a5f2bd36e179 double click on expandable item does not perform
Claus Gittinger <cg@exept.de>
parents: 1813
diff changeset
   533
!
a5f2bd36e179 double click on expandable item does not perform
Claus Gittinger <cg@exept.de>
parents: 1813
diff changeset
   534
1275
cc62615ed032 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   535
showRoot
cc62615ed032 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   536
    "list with or without root
cc62615ed032 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   537
    "
cc62615ed032 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   538
  ^ showRoot
cc62615ed032 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   539
!
cc62615ed032 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   540
cc62615ed032 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   541
showRoot:aState
cc62615ed032 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   542
    "list with or without root
cc62615ed032 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   543
    "
cc62615ed032 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   544
    showRoot ~~ aState ifTrue:[
cc62615ed032 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   545
        model showRoot:(showRoot := aState).
cc62615ed032 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   546
    ].
cc62615ed032 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   547
! !
cc62615ed032 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   548
514
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
   549
!SelectionInTreeView methodsFor:'change & update'!
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
   550
855
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   551
modelChanged:what with:aPara
2483
1589203d52f3 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2333
diff changeset
   552
    "hierarchical list changed"
1589203d52f3 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2333
diff changeset
   553
855
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   554
    |start size visLn h y0 y1 cY parent pvLv ndLv|
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   555
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   556
    aPara isNil ifTrue:[
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   557
        what == #list ifTrue:[ self getListFromModel ]
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   558
                     ifFalse:[ super update:what with:aPara from:model ].
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   559
        ^ self
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   560
    ].
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   561
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   562
    (what == #insertCollection: or:[what == #removeFrom:]) ifFalse:[
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   563
        what == #at:     ifTrue:[ ^ self redrawLine:aPara ].
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   564
        what == #replace ifTrue:[ ^ self invalidateRepairNow:true ].
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   565
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   566
        ^ super update:what with:aPara from:model.
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   567
    ].
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   568
    list := self listFromModel.
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   569
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   570
    shown ifFalse:[
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   571
        ^ self contentsChanged
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   572
    ].
2483
1589203d52f3 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2333
diff changeset
   573
    (self sensor hasExposeEventFor:self) ifTrue:[       
1589203d52f3 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2333
diff changeset
   574
        "/ outstanding expose events
855
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   575
        self invalidateRepairNow:true.
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   576
        ^ self contentsChanged
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   577
    ].
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   578
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   579
    start  := aPara at:1.
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   580
    size   := aPara at:2.
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   581
    parent := aPara at:3.
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   582
860
64d52b8e3dbd bug fix in remove:
ca
parents: 855
diff changeset
   583
    what == #removeFrom: ifTrue:[
64d52b8e3dbd bug fix in remove:
ca
parents: 855
diff changeset
   584
        size := size - start + 1
64d52b8e3dbd bug fix in remove:
ca
parents: 855
diff changeset
   585
    ].
64d52b8e3dbd bug fix in remove:
ca
parents: 855
diff changeset
   586
855
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   587
    start > 1 ifTrue:[
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   588
        pvLv  := (list at:start - 1) level.
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   589
        ndLv  := parent level + 1.
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   590
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   591
        ndLv < pvLv ifTrue:[
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   592
            what == #insertCollection: ifTrue:[
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   593
                visLn := start + size.
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   594
            ] ifFalse:[
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   595
                visLn := start.
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   596
            ].
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   597
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   598
            (visLn > list size or:[(list at:visLn) level ~~ ndLv]) ifTrue:[
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   599
                [(start := start - 1) ~~ 1] whileTrue:[
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   600
                    (list at:start) level <= ndLv ifTrue:[
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   601
                        self redrawFromLine:start.
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   602
                      ^ self contentsChanged.
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   603
                    ]
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   604
                ].
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   605
                self invalidateRepairNow:true.
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   606
              ^ self contentsChanged
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   607
            ]
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   608
        ].
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   609
        self redrawIconAndIndicatorAt:(start - 1)
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   610
    ].
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   611
    (visLn := self listLineToVisibleLine:start) isNil ifTrue:[
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   612
        ^ self contentsChanged
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   613
    ].
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   614
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   615
    h  := size * fontHeight.
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   616
    y0 := self yOfVisibleLine:visLn.
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   617
    y1 := y0 + h.
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   618
    cY := height - y1 - 1.
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   619
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   620
    cY < 40 ifTrue:[
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   621
        self redrawFromLine:start.
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   622
    ] ifFalse:[
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   623
        self catchExpose.
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   624
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   625
        what == #insertCollection: ifTrue:[
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   626
            self copyFrom:self x:0 y:y0 toX:0 y:y1 width:width height:cY async:true.
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   627
        ] ifFalse:[
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   628
            self copyFrom:self x:0 y:y1 toX:0 y:y0 width:width height:cY async:true.
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   629
            y0 := y0 + cY.
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   630
            h  := height - y0.
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   631
        ].
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   632
        self redrawX:0 y:y0 width:width height:h.
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   633
        self waitForExpose.
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   634
    ].
4516
1e8e11a8465c class: SelectionInTreeView
Stefan Vogel <sv@exept.de>
parents: 4380
diff changeset
   635
    self flush.
855
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   636
    self contentsChanged.
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   637
!
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   638
514
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
   639
update:something with:aParameter from:aModel
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
   640
    "one of my models changed its value
785
ca
parents: 782
diff changeset
   641
    "
ca
parents: 782
diff changeset
   642
    |idx|
ca
parents: 782
diff changeset
   643
514
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
   644
    aModel == rootHolder ifTrue:[
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
   645
        ^ self rootFromModel
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
   646
    ].
855
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   647
514
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
   648
    aModel == selectionHolder ifTrue:[
763
dd29c58e8ea6 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 760
diff changeset
   649
        ^ self selectionFromModel   
514
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
   650
    ].
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
   651
763
dd29c58e8ea6 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 760
diff changeset
   652
    aModel == model ifTrue:[
855
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   653
        ^ self modelChanged:something with:aParameter
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   654
    ].
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   655
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   656
    (aModel isKindOf:TreeItem) ifTrue:[
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   657
        (something == #size or:[something == #children]) ifTrue:[
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   658
            model recomputeList.
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   659
            ^ self
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   660
        ].
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   661
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   662
        (idx := self indexOfNode:aModel) ~~ 0 ifTrue:[
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   663
            something == #value ifTrue:[  
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   664
                ^ self redrawLine:idx.
785
ca
parents: 782
diff changeset
   665
            ].
811
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
   666
855
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   667
            something == #indication ifTrue:[
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   668
                ^ self redrawIndicatorLine:idx.
811
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
   669
            ].
1308
b04e4fb53fb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1305
diff changeset
   670
            "/ assume that the nodes string has changed
b04e4fb53fb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1305
diff changeset
   671
            ^ self redrawLine:idx.
855
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   672
        ].
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   673
        ^ self
763
dd29c58e8ea6 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 760
diff changeset
   674
    ].
855
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   675
    super update:something with:aParameter from:aModel.
811
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
   676
514
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
   677
! !
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
   678
444
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
   679
!SelectionInTreeView methodsFor:'drawing'!
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
   680
481
91b3f1788cea redraw mechanism
ca
parents: 480
diff changeset
   681
drawLine:line atX:atX inVisible:visLineNr with:fg and:bg
91b3f1788cea redraw mechanism
ca
parents: 480
diff changeset
   682
    self drawFromVisibleLine:visLineNr to:visLineNr with:fg and:bg
444
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
   683
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
   684
!
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
   685
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
   686
drawLine:line fromX:x inVisible:visLineNr with:fg and:bg
481
91b3f1788cea redraw mechanism
ca
parents: 480
diff changeset
   687
    self drawFromVisibleLine:visLineNr to:visLineNr with:fg and:bg
444
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
   688
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
   689
!
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
   690
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
   691
drawLine:line inVisible:visLineNr with:fg and:bg
481
91b3f1788cea redraw mechanism
ca
parents: 480
diff changeset
   692
    self drawFromVisibleLine:visLineNr to:visLineNr with:fg and:bg
444
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
   693
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
   694
!
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
   695
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
   696
drawVisibleLine:visLineNr col:col with:fg and:bg
481
91b3f1788cea redraw mechanism
ca
parents: 480
diff changeset
   697
    self drawFromVisibleLine:visLineNr to:visLineNr with:fg and:bg
444
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
   698
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
   699
!
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
   700
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
   701
drawVisibleLine:visLineNr from:startCol to:endCol with:fg and:bg
481
91b3f1788cea redraw mechanism
ca
parents: 480
diff changeset
   702
    self drawFromVisibleLine:visLineNr to:visLineNr with:fg and:bg
91b3f1788cea redraw mechanism
ca
parents: 480
diff changeset
   703
444
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
   704
!
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
   705
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
   706
drawVisibleLine:visLineNr from:startCol with:fg and:bg
481
91b3f1788cea redraw mechanism
ca
parents: 480
diff changeset
   707
    self drawFromVisibleLine:visLineNr to:visLineNr with:fg and:bg
444
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
   708
846
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
   709
!
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
   710
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
   711
redrawFromVisibleLine:startVisLineNr to:endVisLineNr
5427
3178b508e257 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5408
diff changeset
   712
    self redrawX:0 y:(self yOfVisibleLine:startVisLineNr)
3178b508e257 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5408
diff changeset
   713
         width:width height:(endVisLineNr - startVisLineNr + 1 * fontHeight)
848
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   714
!
444
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
   715
848
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   716
redrawIconAndIndicatorAt:aLnNr
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   717
    |visLineNr x0 x1 lv|
481
91b3f1788cea redraw mechanism
ca
parents: 480
diff changeset
   718
769
15fafccfed86 optimize redraw routine
ca
parents: 764
diff changeset
   719
    shown ifTrue:[
848
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   720
        visLineNr := self listLineToVisibleLine:aLnNr.
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   721
        visLineNr notNil ifTrue:[
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   722
            lv := (listOfNodes at:aLnNr) level.
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   723
            x1 := (imageWidth + (self xOfFigureLevel:lv)) min:width.
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   724
            x0 := (self xOfFigureLevel:(lv - 1)) max:0.
769
15fafccfed86 optimize redraw routine
ca
parents: 764
diff changeset
   725
848
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   726
            (x0 > width or:[x1 < 0]) ifFalse:[
5427
3178b508e257 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5408
diff changeset
   727
                self redrawX:x0 y:(self yOfVisibleLine:visLineNr)
3178b508e257 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5408
diff changeset
   728
                     width:(x1 - x0) height:fontHeight
848
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   729
            ]
769
15fafccfed86 optimize redraw routine
ca
parents: 764
diff changeset
   730
        ]
848
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   731
    ].
769
15fafccfed86 optimize redraw routine
ca
parents: 764
diff changeset
   732
!
15fafccfed86 optimize redraw routine
ca
parents: 764
diff changeset
   733
811
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
   734
redrawIndicatorLine:aLineNr
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
   735
    "redraw the directory indicator for a line
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
   736
    "
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
   737
    |node ext img visLn
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
   738
     x  "{ Class:SmallInteger }"
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
   739
     y  "{ Class:SmallInteger }"
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
   740
     dX "{ Class:SmallInteger }"
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
   741
    |
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
   742
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
   743
    (     shown
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
   744
     and:[showDirectoryIndicator
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
   745
     and:[(visLn := self listLineToVisibleLine:aLineNr) notNil]]
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
   746
    ) ifFalse:[
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
   747
        ^ self
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
   748
    ].
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
   749
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
   750
    node := listOfNodes at:aLineNr.
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
   751
846
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
   752
    (node parent notNil or:[showDirectoryIndicatorForRoot]) ifFalse:[
811
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
   753
        ^ self
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
   754
    ].
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
   755
846
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
   756
    x := imageWidth // 2.
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
   757
    x := x + (self xOfFigureLevel:(node level - 1)).
811
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
   758
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
   759
    "/ draw directory indicator
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
   760
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
   761
    img := node isCollapsable ifTrue:[openIndicator] ifFalse:[closeIndicator].
1620
99124a1a1342 care for nil-image when drawing indicator line
Claus Gittinger <cg@exept.de>
parents: 1477
diff changeset
   762
    img notNil ifTrue:[
99124a1a1342 care for nil-image when drawing indicator line
Claus Gittinger <cg@exept.de>
parents: 1477
diff changeset
   763
        ext := img extent // 2.
99124a1a1342 care for nil-image when drawing indicator line
Claus Gittinger <cg@exept.de>
parents: 1477
diff changeset
   764
        dX  := ext x.
99124a1a1342 care for nil-image when drawing indicator line
Claus Gittinger <cg@exept.de>
parents: 1477
diff changeset
   765
99124a1a1342 care for nil-image when drawing indicator line
Claus Gittinger <cg@exept.de>
parents: 1477
diff changeset
   766
        (x + dX > 0 and:[(x := x - dX) < (width - margin)]) ifTrue:[
3176
4785f8b58e64 support focus highlighting
ca
parents: 2689
diff changeset
   767
            self paintOnIsSelected:(self isInSelection:aLineNr).
1620
99124a1a1342 care for nil-image when drawing indicator line
Claus Gittinger <cg@exept.de>
parents: 1477
diff changeset
   768
99124a1a1342 care for nil-image when drawing indicator line
Claus Gittinger <cg@exept.de>
parents: 1477
diff changeset
   769
            y := (self yOfVisibleLine:visLn) + (fontHeight // 2) - 1.
99124a1a1342 care for nil-image when drawing indicator line
Claus Gittinger <cg@exept.de>
parents: 1477
diff changeset
   770
            self displayForm:img x:x y:(y - ext y)
99124a1a1342 care for nil-image when drawing indicator line
Claus Gittinger <cg@exept.de>
parents: 1477
diff changeset
   771
        ].
811
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
   772
    ].
900
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
   773
!
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
   774
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
   775
redrawVisibleLine:visLineNr
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
   776
    self drawFromVisibleLine:visLineNr to:visLineNr with:fgColor and:bgColor
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
   777
!
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
   778
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
   779
redrawVisibleLine:visLineNr from:startCol to:endCol
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
   780
    self drawFromVisibleLine:visLineNr to:visLineNr with:fgColor and:bgColor
848
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   781
! !
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   782
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   783
!SelectionInTreeView methodsFor:'drawing basics'!
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   784
900
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
   785
drawFromVisibleLine:startVisLineNr to:endVisLineNr with:fg and:bg
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
   786
    "redraw a visible line range with clearing the background
848
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   787
    "
900
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
   788
    |y h|
848
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   789
900
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
   790
    y := self yOfVisibleLine:startVisLineNr.
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
   791
    h := endVisLineNr - startVisLineNr + 1 * fontHeight.
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
   792
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
   793
    y + h > height ifTrue:[
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
   794
        h := height - y
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
   795
    ].
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
   796
    self redrawX:0 y:y width:width height:h.
848
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   797
!
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   798
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   799
drawVHLinesX:x0 y:y0 toX:x1 start:start stop:stop
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   800
    "redraw from line to line without clearing the background
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   801
    "
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   802
    |node prevNode parent p1 p2 showVLines showHLine lv nxtPrnt
1305
c8f2fe1fac85 fix drawing horizontal lines for the root element(s)
Claus Gittinger <cg@exept.de>
parents: 1278
diff changeset
   803
     showRootNot isFirst
848
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   804
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   805
     x        "{ Class:SmallInteger }"
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   806
     y        "{ Class:SmallInteger }"
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   807
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   808
     yTop     "{ Class:SmallInteger }"
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   809
     yBot     "{ Class:SmallInteger }"
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   810
     yCtr     "{ Class:SmallInteger }"
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   811
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   812
     begHLnY  "{ Class:SmallInteger }"
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   813
     begHLnX  "{ Class:SmallInteger }"
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   814
     endHLnX  "{ Class:SmallInteger }"
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   815
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   816
     widthLvl "{ Class:SmallInteger }"
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   817
     offsHLnX "{ Class:SmallInteger }"
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   818
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   819
     level    "{ Class:SmallInteger }"
855
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   820
     startLvI "{ Class:SmallInteger }"
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   821
     startLvX "{ Class:SmallInteger }"
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   822
     limitLvI "{ Class:SmallInteger }"
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   823
     limitLvX "{ Class:SmallInteger }"
3692
af710a4ee08a do not draw dotted line under the icon (for transparent icons)
Claus Gittinger <cg@exept.de>
parents: 3690
diff changeset
   824
     xIcon
848
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   825
    |
1305
c8f2fe1fac85 fix drawing horizontal lines for the root element(s)
Claus Gittinger <cg@exept.de>
parents: 1278
diff changeset
   826
848
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   827
    yBot     := y0.
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   828
    yCtr     := yBot - (fontHeight // 2).
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   829
    widthLvl := imageInset + imageWidth.
3692
af710a4ee08a do not draw dotted line under the icon (for transparent icons)
Claus Gittinger <cg@exept.de>
parents: 3690
diff changeset
   830
    offsHLnX := (imageWidth // 2) + (self xOfFigureLevel:-1).
af710a4ee08a do not draw dotted line under the icon (for transparent icons)
Claus Gittinger <cg@exept.de>
parents: 3690
diff changeset
   831
    xIcon := imageWidth // 2.
848
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   832
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   833
    parent   := 4711.                           "/ to force a recompute
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   834
    prevNode := 4711.                           "/ to force a recomputation of the level
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   835
5427
3178b508e257 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5408
diff changeset
   836
    gc maskOrigin:(self viewOrigin + (0 @ 1) \\ (lineMask extent)).
3178b508e257 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5408
diff changeset
   837
    gc paint:lineColor on:bgColor.
3178b508e257 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5408
diff changeset
   838
    gc mask:lineMask.
848
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   839
    begHLnY  := y0.
855
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   840
    startLvI := self smallestLevelOfNodesBetween:start and:stop.
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   841
    startLvX := self xOfFigureLevel:startLvI.
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   842
    limitLvI := drawVLinesFromLevel + 1.
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   843
    limitLvX := limitLvI * widthLvl + offsHLnX.
848
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   844
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   845
    buildInArray atAllPut:0.
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   846
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   847
    start == 1 ifTrue:[
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   848
        begHLnY := yCtr + fontHeight.
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   849
    ].
1305
c8f2fe1fac85 fix drawing horizontal lines for the root element(s)
Claus Gittinger <cg@exept.de>
parents: 1278
diff changeset
   850
    showRootNot := showRoot not.
848
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   851
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   852
    start to:stop do:[:anIndex|
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   853
        node := listOfNodes at:anIndex.
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   854
        yTop := yBot - 1.
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   855
        yBot := yBot + fontHeight.
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   856
        yCtr := yCtr + fontHeight.
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   857
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   858
        (nxtPrnt := node parent) ~~ parent ifTrue:[
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   859
            parent := nxtPrnt.
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   860
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   861
            prevNode == parent ifTrue:[
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   862
                level := level + 1.
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   863
                begHLnX := endHLnX.
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   864
            ] ifFalse:[
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   865
                level   := node level.
1309
d87d431dad62 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
   866
                begHLnX := level * widthLvl + offsHLnX.
848
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   867
            ].
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   868
1305
c8f2fe1fac85 fix drawing horizontal lines for the root element(s)
Claus Gittinger <cg@exept.de>
parents: 1278
diff changeset
   869
            isFirst    := parent isNil or:[(showRootNot and:[level == 2])].
c8f2fe1fac85 fix drawing horizontal lines for the root element(s)
Claus Gittinger <cg@exept.de>
parents: 1278
diff changeset
   870
            endHLnX    := begHLnX + widthLvl.
855
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   871
            showVLines := begHLnX >= x0 and:[level > drawVLinesFromLevel].
1305
c8f2fe1fac85 fix drawing horizontal lines for the root element(s)
Claus Gittinger <cg@exept.de>
parents: 1278
diff changeset
   872
            showHLine  := x0 < endHLnX and:[x1 > begHLnX].
c8f2fe1fac85 fix drawing horizontal lines for the root element(s)
Claus Gittinger <cg@exept.de>
parents: 1278
diff changeset
   873
c8f2fe1fac85 fix drawing horizontal lines for the root element(s)
Claus Gittinger <cg@exept.de>
parents: 1278
diff changeset
   874
            (showHLine and:[isFirst]) ifTrue:[
c8f2fe1fac85 fix drawing horizontal lines for the root element(s)
Claus Gittinger <cg@exept.de>
parents: 1278
diff changeset
   875
                showHLine := showDirectoryIndicatorForRoot and:[showDirectoryIndicator]
c8f2fe1fac85 fix drawing horizontal lines for the root element(s)
Claus Gittinger <cg@exept.de>
parents: 1278
diff changeset
   876
            ]
848
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   877
        ].
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   878
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   879
        showHLine ifTrue:[
5427
3178b508e257 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5408
diff changeset
   880
            gc displayLineFromX:begHLnX y:yCtr toX:endHLnX-xIcon y:yCtr
848
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   881
        ].
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   882
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   883
        showVLines ifTrue:[
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   884
            y  := (parent basicLastChild == node) ifTrue:[yCtr] ifFalse:[yBot].
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   885
            x  := begHLnX.
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   886
            p2 := parent.
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   887
            lv := level - 1.
5427
3178b508e257 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5408
diff changeset
   888
            gc displayLineFromX:x y:begHLnY toX:x y:y.
848
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   889
855
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   890
            [((p1 := p2 parent) notNil and:[(x := x - widthLvl) >= limitLvX])] whileTrue:[
848
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   891
                (p1 basicLastChild ~~ p2 and:[x <= x1]) ifTrue:[
855
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   892
                    x >= startLvX ifTrue:[
1815
a5f2bd36e179 double click on expandable item does not perform
Claus Gittinger <cg@exept.de>
parents: 1813
diff changeset
   893
                        (isFirst not or:[showLinesForRoot]) ifTrue:[
5427
3178b508e257 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5408
diff changeset
   894
                            gc displayLineFromX:x y:yTop toX:x y:yBot
1815
a5f2bd36e179 double click on expandable item does not perform
Claus Gittinger <cg@exept.de>
parents: 1813
diff changeset
   895
                        ]
848
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   896
                    ] ifFalse:[
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   897
                        buildInArray at:lv put:yBot
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   898
                    ].
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   899
                ].
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   900
                lv := lv - 1.
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   901
                p2 := p1
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   902
            ]
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   903
        ].
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   904
        prevNode := node.
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   905
        begHLnY  := yCtr.
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   906
    ].
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   907
855
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   908
    "/
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   909
    "/ draw outstanding verical lines to left
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   910
    "/
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   911
    x := limitLvX.
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   912
    y := (start ~~ 1) ifTrue:[y0] ifFalse:[y0 + (fontHeight // 2)].
848
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   913
855
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   914
    limitLvI to:startLvI do:[:i|
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   915
        (yBot := buildInArray at:i) ~~ 0 ifTrue:[
5427
3178b508e257 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5408
diff changeset
   916
            gc displayLineFromX:x y:y toX:x y:yBot
855
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   917
        ].
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
   918
        x := x + widthLvl.
848
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
   919
    ].
5427
3178b508e257 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5408
diff changeset
   920
    gc mask:nil.
811
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
   921
!
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
   922
900
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
   923
drawVisibleLineSelected:visLineNr with:fg and:bg
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
   924
    "redraw a single line as selected."
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
   925
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
   926
    (self visibleLineToListLine:visLineNr) isNil ifTrue:[
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
   927
        ^ super drawVisibleLine:visLineNr with:fg and:bg
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
   928
    ].
5427
3178b508e257 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5408
diff changeset
   929
    self redrawX:0 y:(self yOfVisibleLine:visLineNr)
3178b508e257 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5408
diff changeset
   930
         width:width height:fontHeight
900
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
   931
!
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
   932
3176
4785f8b58e64 support focus highlighting
ca
parents: 2689
diff changeset
   933
paintOnIsSelected:isSelected
4785f8b58e64 support focus highlighting
ca
parents: 2689
diff changeset
   934
    isSelected ifTrue:[
4785f8b58e64 support focus highlighting
ca
parents: 2689
diff changeset
   935
        self hasFocus ifTrue:[
5427
3178b508e257 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5408
diff changeset
   936
            gc paint:hilightFgColor on:hilightBgColor
3176
4785f8b58e64 support focus highlighting
ca
parents: 2689
diff changeset
   937
        ] ifFalse:[
5427
3178b508e257 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5408
diff changeset
   938
            gc paint:hilightFgColorNoFocus on:hilightBgColorNoFocus
3176
4785f8b58e64 support focus highlighting
ca
parents: 2689
diff changeset
   939
        ]
4785f8b58e64 support focus highlighting
ca
parents: 2689
diff changeset
   940
    ] ifFalse:[
5427
3178b508e257 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5408
diff changeset
   941
        gc paint:fgColor on:bgColor.
3176
4785f8b58e64 support focus highlighting
ca
parents: 2689
diff changeset
   942
    ].
4785f8b58e64 support focus highlighting
ca
parents: 2689
diff changeset
   943
!
4785f8b58e64 support focus highlighting
ca
parents: 2689
diff changeset
   944
902
de7a2459bd3b faster drawing of select/unselect changes
ca
parents: 900
diff changeset
   945
redrawElement:anIndex
de7a2459bd3b faster drawing of select/unselect changes
ca
parents: 900
diff changeset
   946
de7a2459bd3b faster drawing of select/unselect changes
ca
parents: 900
diff changeset
   947
    |vln x0 xT y|
de7a2459bd3b faster drawing of select/unselect changes
ca
parents: 900
diff changeset
   948
de7a2459bd3b faster drawing of select/unselect changes
ca
parents: 900
diff changeset
   949
    shown ifTrue:[
de7a2459bd3b faster drawing of select/unselect changes
ca
parents: 900
diff changeset
   950
        (     highlightMode ~~ #label
908
749621e1a1d6 bugFix in redrawElement:
ca
parents: 902
diff changeset
   951
          or:[(vln := self listLineToVisibleLine:anIndex) isNil
749621e1a1d6 bugFix in redrawElement:
ca
parents: 902
diff changeset
   952
          or:[anIndex > listOfNodes size]]
902
de7a2459bd3b faster drawing of select/unselect changes
ca
parents: 900
diff changeset
   953
        ) ifTrue:[
de7a2459bd3b faster drawing of select/unselect changes
ca
parents: 900
diff changeset
   954
            super redrawElement:anIndex
de7a2459bd3b faster drawing of select/unselect changes
ca
parents: 900
diff changeset
   955
        ] ifFalse:[
de7a2459bd3b faster drawing of select/unselect changes
ca
parents: 900
diff changeset
   956
            y := self yOfVisibleLine:vln.
de7a2459bd3b faster drawing of select/unselect changes
ca
parents: 900
diff changeset
   957
            xT := self xOfStringLevel:((listOfNodes at:anIndex) level).
de7a2459bd3b faster drawing of select/unselect changes
ca
parents: 900
diff changeset
   958
            x0 := xT - textInset.
5427
3178b508e257 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5408
diff changeset
   959
            gc paint:bgColor.
3178b508e257 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5408
diff changeset
   960
            gc fillRectangleX:x0 y:y width:(width - x0) height:fontHeight.
902
de7a2459bd3b faster drawing of select/unselect changes
ca
parents: 900
diff changeset
   961
            self redrawLabelAt:xT y:y index:anIndex
de7a2459bd3b faster drawing of select/unselect changes
ca
parents: 900
diff changeset
   962
        ]
de7a2459bd3b faster drawing of select/unselect changes
ca
parents: 900
diff changeset
   963
    ]
de7a2459bd3b faster drawing of select/unselect changes
ca
parents: 900
diff changeset
   964
!
de7a2459bd3b faster drawing of select/unselect changes
ca
parents: 900
diff changeset
   965
900
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
   966
redrawLabelAt:x y:yTop index:anIndex
1171
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
   967
    |isSel y0 x0 w label node value xV wV|
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
   968
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
   969
    node  := listOfNodes at:anIndex.
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
   970
    label := node name.
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
   971
    isSel := self isInSelection:anIndex.
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
   972
    xV    := 0.
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
   973
    wV    := 0.
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
   974
    y0    := yTop + (fontHeight // 2) + labelOffsetY.
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
   975
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
   976
    (value := node printableEditValue) notNil ifTrue:[
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
   977
        xV := (self xOfValueNode:node) - SelectionInset
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
   978
    ].
900
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
   979
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
   980
    highlightMode == #label ifTrue:[
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
   981
        x0 := x + 4.
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
   982
1171
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
   983
        isSel ifTrue:[
900
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
   984
            w  := (label notNil ifTrue:[label widthOn:self] ifFalse:[60]) + 8.
3176
4785f8b58e64 support focus highlighting
ca
parents: 2689
diff changeset
   985
4785f8b58e64 support focus highlighting
ca
parents: 2689
diff changeset
   986
            self hasFocus ifTrue:[
5427
3178b508e257 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5408
diff changeset
   987
                gc paint:hilightBgColor.
3176
4785f8b58e64 support focus highlighting
ca
parents: 2689
diff changeset
   988
            ] ifFalse:[
5427
3178b508e257 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5408
diff changeset
   989
                gc paint:hilightBgColorNoFocus.
3176
4785f8b58e64 support focus highlighting
ca
parents: 2689
diff changeset
   990
            ].                
5427
3178b508e257 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5408
diff changeset
   991
            gc fillRectangleX:x y:yTop width:w height:fontHeight.
1171
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
   992
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
   993
            (value notNil and:[(editorWidget isNil or:[editorIndex ~~ anIndex])]) ifTrue:[
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
   994
                wV := SelectionInset + SelectionInset + (value widthOn:self).
5427
3178b508e257 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5408
diff changeset
   995
                gc fillRectangleX:xV y:yTop width:wV height:fontHeight.
1171
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
   996
            ]
900
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
   997
        ]
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
   998
    ] ifFalse:[
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
   999
        x0 := x
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
  1000
    ].
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
  1001
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
  1002
    label notNil ifTrue:[
3176
4785f8b58e64 support focus highlighting
ca
parents: 2689
diff changeset
  1003
        self paintOnIsSelected:isSel.
5427
3178b508e257 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5408
diff changeset
  1004
        gc displayOpaqueString:label x:x0 y:y0.
1171
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1005
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1006
        value notNil ifTrue:[
1175
1fa0de353686 add new color used by editValue
ca
parents: 1171
diff changeset
  1007
            isSel ifFalse:[
5427
3178b508e257 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5408
diff changeset
  1008
                gc paint:editValueFgColor on:bgColor
1175
1fa0de353686 add new color used by editValue
ca
parents: 1171
diff changeset
  1009
            ].
5427
3178b508e257 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5408
diff changeset
  1010
            gc displayOpaqueString:value x:(xV + SelectionInset) y:y0
1171
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1011
        ].
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1012
900
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
  1013
    ].
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
  1014
1171
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1015
    (isSel and:[highlightMode == #label]) ifTrue:[
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1016
        self redrawSelFrameAtX:x y:yTop toX:(x + w).
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1017
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1018
        wV ~~ 0 ifTrue:[
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1019
            self redrawSelFrameAtX:xV y:yTop toX:(xV + wV)
3176
4785f8b58e64 support focus highlighting
ca
parents: 2689
diff changeset
  1020
        ].
900
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
  1021
    ].
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
  1022
!
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
  1023
769
15fafccfed86 optimize redraw routine
ca
parents: 764
diff changeset
  1024
redrawLinesX:x0 y:y0 toX:x1 start:start stop:stop
15fafccfed86 optimize redraw routine
ca
parents: 764
diff changeset
  1025
    "redraw from line to line without clearing the background
15fafccfed86 optimize redraw routine
ca
parents: 764
diff changeset
  1026
    "
848
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  1027
    |node prevNode parent icon showIndc showIcon showText nxtPrnt
846
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  1028
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  1029
     end      "{ Class:SmallInteger }"
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  1030
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  1031
     yBot     "{ Class:SmallInteger }"
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  1032
     yCtr     "{ Class:SmallInteger }"
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  1033
848
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  1034
     xIndc    "{ Class:SmallInteger }"
846
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  1035
     xIcon    "{ Class:SmallInteger }"
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  1036
     xText    "{ Class:SmallInteger }"
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  1037
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  1038
     widthLvl "{ Class:SmallInteger }"
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  1039
     insetTxt "{ Class:SmallInteger }"
848
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  1040
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  1041
     offIndcX "{ Class:SmallInteger }"
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  1042
     offIndcY "{ Class:SmallInteger }"
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  1043
     offIconX "{ Class:SmallInteger }"
769
15fafccfed86 optimize redraw routine
ca
parents: 764
diff changeset
  1044
    |
848
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  1045
    (end := stop min:(listOfNodes size)) < start ifTrue:[
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  1046
        ^ self
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  1047
    ].
846
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  1048
    yBot     := y0.
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  1049
    yCtr     := yBot - (fontHeight // 2).
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  1050
    widthLvl := imageInset + imageWidth.
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  1051
    insetTxt := imageWidth + textInset.
848
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  1052
    offIconX := self xOfFigureLevel:0.
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  1053
    showIndc := false.
846
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  1054
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  1055
    showDirectoryIndicator ifTrue:[
1072
1888703adc18 care for non-existing open/close indicators.
Claus Gittinger <cg@exept.de>
parents: 1070
diff changeset
  1056
        offIndcX := imageWidth // 2 - widthLvl.
1888703adc18 care for non-existing open/close indicators.
Claus Gittinger <cg@exept.de>
parents: 1070
diff changeset
  1057
        offIndcY := 0.
1888703adc18 care for non-existing open/close indicators.
Claus Gittinger <cg@exept.de>
parents: 1070
diff changeset
  1058
        openIndicator notNil ifTrue:[
1888703adc18 care for non-existing open/close indicators.
Claus Gittinger <cg@exept.de>
parents: 1070
diff changeset
  1059
            icon     := openIndicator extent // 2.
1888703adc18 care for non-existing open/close indicators.
Claus Gittinger <cg@exept.de>
parents: 1070
diff changeset
  1060
            offIndcX := offIndcX - icon x.
1888703adc18 care for non-existing open/close indicators.
Claus Gittinger <cg@exept.de>
parents: 1070
diff changeset
  1061
            offIndcY := icon y.
1888703adc18 care for non-existing open/close indicators.
Claus Gittinger <cg@exept.de>
parents: 1070
diff changeset
  1062
        ]
846
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  1063
    ].
785
ca
parents: 782
diff changeset
  1064
ca
parents: 782
diff changeset
  1065
    showLines ifTrue:[
848
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  1066
        self drawVHLinesX:x0 y:y0 toX:x1 start:start stop:end
785
ca
parents: 782
diff changeset
  1067
    ].
485
26e87be7210f showDirectoryIndicator
ca
parents: 483
diff changeset
  1068
846
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  1069
    parent   := 4711.                           "/ to force a recompute
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  1070
    prevNode := 4711.                           "/ to force a recomputation of the level
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  1071
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  1072
    start to:end do:[:anIndex|
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  1073
        node := listOfNodes at:anIndex.
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  1074
        yBot := yBot + fontHeight.
494
76d8c4e0b612 directory indicator; set a path to be selected
ca
parents: 490
diff changeset
  1075
        yCtr := yCtr + fontHeight.
485
26e87be7210f showDirectoryIndicator
ca
parents: 483
diff changeset
  1076
848
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  1077
        (nxtPrnt := node parent) ~~ parent ifTrue:[
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  1078
            parent := nxtPrnt.
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  1079
            xIcon  := prevNode == parent ifTrue:[xIcon + widthLvl]
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  1080
                                        ifFalse:[node level * widthLvl + offIconX].
481
91b3f1788cea redraw mechanism
ca
parents: 480
diff changeset
  1081
848
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  1082
            xText    := xIcon + insetTxt.
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  1083
            showIcon := xIcon < x1 and:[xText > x0].
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  1084
            showText := xText < x1.
769
15fafccfed86 optimize redraw routine
ca
parents: 764
diff changeset
  1085
848
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  1086
            showDirectoryIndicator ifTrue:[
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  1087
                xIndc := xIcon + offIndcX.
481
91b3f1788cea redraw mechanism
ca
parents: 480
diff changeset
  1088
848
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  1089
                showIndc := (      (parent notNil or:[showDirectoryIndicatorForRoot])
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  1090
                              and:[(xIcon > x0 and:[xIndc < x1])]
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  1091
                            )
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  1092
            ]
785
ca
parents: 782
diff changeset
  1093
        ].
481
91b3f1788cea redraw mechanism
ca
parents: 480
diff changeset
  1094
846
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  1095
        (showIcon and:[(icon := self figureFor:node) notNil]) ifTrue:[
5427
3178b508e257 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5408
diff changeset
  1096
            gc displayForm:icon x:xIcon y:(yCtr - (icon height // 2))
770
f197d1f5a246 fix clipping
ca
parents: 769
diff changeset
  1097
        ].
848
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  1098
846
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  1099
        showText ifTrue:[
900
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
  1100
            self redrawLabelAt:xText y:(yBot - fontHeight) index:anIndex
485
26e87be7210f showDirectoryIndicator
ca
parents: 483
diff changeset
  1101
        ].
848
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  1102
        (showIndc and:[node showIndicator]) ifTrue:[
846
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  1103
            icon := node isCollapsable ifTrue:[openIndicator] ifFalse:[closeIndicator].
1091
2e86163cfb17 care for non-existing icon image
Claus Gittinger <cg@exept.de>
parents: 1072
diff changeset
  1104
            icon notNil ifTrue:[
5427
3178b508e257 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5408
diff changeset
  1105
                gc displayForm:icon x:xIndc y:(yCtr - offIndcY)
1091
2e86163cfb17 care for non-existing icon image
Claus Gittinger <cg@exept.de>
parents: 1072
diff changeset
  1106
            ]
846
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  1107
        ].
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  1108
        prevNode := node.
769
15fafccfed86 optimize redraw routine
ca
parents: 764
diff changeset
  1109
    ]
1072
1888703adc18 care for non-existing open/close indicators.
Claus Gittinger <cg@exept.de>
parents: 1070
diff changeset
  1110
1091
2e86163cfb17 care for non-existing icon image
Claus Gittinger <cg@exept.de>
parents: 1072
diff changeset
  1111
    "Modified: / 22.8.1998 / 12:56:50 / cg"
792
5a0af910519e bug fix:
ca
parents: 785
diff changeset
  1112
!
5a0af910519e bug fix:
ca
parents: 785
diff changeset
  1113
900
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
  1114
redrawSelFrameAtX:x0 y:y0 toX:x1
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
  1115
    "redraw selection frame for a line
792
5a0af910519e bug fix:
ca
parents: 785
diff changeset
  1116
    "
900
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
  1117
    |
792
5a0af910519e bug fix:
ca
parents: 785
diff changeset
  1118
     w   "{ Class: SmallInteger }"
5a0af910519e bug fix:
ca
parents: 785
diff changeset
  1119
     y   "{ Class: SmallInteger }" 
5a0af910519e bug fix:
ca
parents: 785
diff changeset
  1120
     x   "{ Class: SmallInteger }" 
5a0af910519e bug fix:
ca
parents: 785
diff changeset
  1121
    |
5a0af910519e bug fix:
ca
parents: 785
diff changeset
  1122
5a0af910519e bug fix:
ca
parents: 785
diff changeset
  1123
    hilightFrameColor notNil ifTrue:[
5a0af910519e bug fix:
ca
parents: 785
diff changeset
  1124
        hilightLevel == 0 ifTrue:[
5427
3178b508e257 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5408
diff changeset
  1125
            gc paint:hilightFrameColor.
3176
4785f8b58e64 support focus highlighting
ca
parents: 2689
diff changeset
  1126
1105
c79bb5824b74 draw closed frames around selections if highlightMode ~~ #line
tz
parents: 1091
diff changeset
  1127
            highlightMode == #line ifTrue:[
5427
3178b508e257 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5408
diff changeset
  1128
                gc displayLineFromX:x0 y:y0 toX:x1 y:y0.
1105
c79bb5824b74 draw closed frames around selections if highlightMode ~~ #line
tz
parents: 1091
diff changeset
  1129
                y := y0 + fontHeight - 1.
5427
3178b508e257 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5408
diff changeset
  1130
                gc displayLineFromX:x0 y:y toX:x1 y:y.
1105
c79bb5824b74 draw closed frames around selections if highlightMode ~~ #line
tz
parents: 1091
diff changeset
  1131
            ] ifFalse:[
5427
3178b508e257 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5408
diff changeset
  1132
                gc displayRectangleX:x0 y:y0 width:x1 - x0 height:fontHeight.
3176
4785f8b58e64 support focus highlighting
ca
parents: 2689
diff changeset
  1133
            ].
4785f8b58e64 support focus highlighting
ca
parents: 2689
diff changeset
  1134
            ^ self
4785f8b58e64 support focus highlighting
ca
parents: 2689
diff changeset
  1135
        ].
792
5a0af910519e bug fix:
ca
parents: 785
diff changeset
  1136
    ] ifFalse:[
5a0af910519e bug fix:
ca
parents: 785
diff changeset
  1137
        hilightStyle == #motif ifTrue:[
5427
3178b508e257 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5408
diff changeset
  1138
            gc paint:bgColor.
900
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
  1139
            y := y0 + 1.
1105
c79bb5824b74 draw closed frames around selections if highlightMode ~~ #line
tz
parents: 1091
diff changeset
  1140
            highlightMode == #line ifTrue:[
5427
3178b508e257 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5408
diff changeset
  1141
                gc displayLineFromX:x0 y:y toX:x1 y:y.
1105
c79bb5824b74 draw closed frames around selections if highlightMode ~~ #line
tz
parents: 1091
diff changeset
  1142
                y := y0 + fontHeight - 2.
5427
3178b508e257 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5408
diff changeset
  1143
                gc displayLineFromX:x0 y:y toX:x1 y:y.
1105
c79bb5824b74 draw closed frames around selections if highlightMode ~~ #line
tz
parents: 1091
diff changeset
  1144
            ] ifFalse:[
5427
3178b508e257 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5408
diff changeset
  1145
                gc displayRectangleX:x0 + 1 y:y width:x1 - x0 - 2 height:fontHeight - 2
1105
c79bb5824b74 draw closed frames around selections if highlightMode ~~ #line
tz
parents: 1091
diff changeset
  1146
            ]
792
5a0af910519e bug fix:
ca
parents: 785
diff changeset
  1147
        ]
5a0af910519e bug fix:
ca
parents: 785
diff changeset
  1148
    ].
5a0af910519e bug fix:
ca
parents: 785
diff changeset
  1149
5a0af910519e bug fix:
ca
parents: 785
diff changeset
  1150
    hilightLevel ~~ 0 ifTrue:[
5a0af910519e bug fix:
ca
parents: 785
diff changeset
  1151
        "/ draw edge
5a0af910519e bug fix:
ca
parents: 785
diff changeset
  1152
900
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
  1153
        highlightMode == #line ifTrue:[
2015
5a83ee792cc3 eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents: 2014
diff changeset
  1154
            w := ((width - (2 * margin)) max:(self widthOfContents)) + viewOrigin x.
5a83ee792cc3 eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents: 2014
diff changeset
  1155
            x := margin - viewOrigin x.
900
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
  1156
        ] ifFalse:[
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
  1157
            w := x1 - x0.
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
  1158
            x := x0.
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
  1159
        ].
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
  1160
        self drawEdgesForX:x y:y0 width:w height:fontHeight level:hilightLevel.
792
5a0af910519e bug fix:
ca
parents: 785
diff changeset
  1161
    ]
900
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
  1162
!
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
  1163
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
  1164
redrawX:x y:y width:w height:h
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
  1165
    "a region must be redrawn"
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
  1166
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
  1167
    |savClip startLn sel
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
  1168
     y0       "{ Class:SmallInteger }"
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
  1169
     y1       "{ Class:SmallInteger }"
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
  1170
     visStart "{ Class:SmallInteger }"
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
  1171
     visEnd   "{ Class:SmallInteger }"
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
  1172
     stopLn   "{ Class:SmallInteger }"
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
  1173
     maxY     "{ Class:SmallInteger }"
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
  1174
     maxX     "{ Class:SmallInteger }"
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
  1175
     dltLine  "{ Class:SmallInteger }"
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
  1176
     startY   "{ Class:SmallInteger }"|
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
  1177
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
  1178
    shown ifFalse:[^ self].
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
  1179
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
  1180
    visStart := self visibleLineOfY:(y + 1).
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
  1181
    startLn  := self visibleLineToAbsoluteLine:visStart.
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
  1182
5427
3178b508e257 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5408
diff changeset
  1183
    gc paint:bgColor.
3178b508e257 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5408
diff changeset
  1184
    gc fillRectangleX:x y:y width:w height:h.
900
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
  1185
    startLn isNil ifTrue:[ ^ self ].
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
  1186
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
  1187
    sel     := nil.
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
  1188
    maxX    := x + w.
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
  1189
    maxY    := y + h.
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
  1190
    visEnd  := self visibleLineOfY:maxY.
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
  1191
    startY  := self yOfVisibleLine:visStart.
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
  1192
    dltLine := startLn - visStart.
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
  1193
    stopLn  := dltLine + visEnd.
5408
a10927558000 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5258
diff changeset
  1194
    
4516
1e8e11a8465c class: SelectionInTreeView
Stefan Vogel <sv@exept.de>
parents: 4380
diff changeset
  1195
    savClip := self clippingBoundsOrNil.
5408
a10927558000 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5258
diff changeset
  1196
    self clippingBounds:(Rectangle left:x top:y width:w height:h).
900
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
  1197
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
  1198
    (highlightMode == #line and:[self hasSelection]) ifTrue:[
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
  1199
        "/ redraw the background for all selected lines in the invalid range
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
  1200
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
  1201
        self selectionDo:[:lnNr|
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
  1202
            (lnNr between:startLn and:stopLn) ifTrue:[
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
  1203
                sel isNil ifTrue:[
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
  1204
                    sel := OrderedCollection new.
5427
3178b508e257 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5408
diff changeset
  1205
                    gc paint:(self hasFocus ifTrue:[hilightBgColor] ifFalse:[hilightBgColorNoFocus]).
900
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
  1206
                ].
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
  1207
                sel add:(y0 := self yOfVisibleLine:(lnNr - dltLine)).
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
  1208
                y1 := y0 + fontHeight min:maxY.
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
  1209
                y0 := y0 max:y.
5427
3178b508e257 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5408
diff changeset
  1210
                gc fillRectangleX:x y:y0 width:w height:y1 - y0.
900
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
  1211
            ]
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
  1212
        ]
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
  1213
    ].
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
  1214
    self redrawLinesX:x y:startY toX:maxX start:startLn stop:stopLn.
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
  1215
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
  1216
    "/ draw selection frames
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
  1217
    sel notNil ifTrue:[
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
  1218
        sel do:[:y0| self redrawSelFrameAtX:x y:y0 toX:maxX]
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
  1219
    ].
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
  1220
5408
a10927558000 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5258
diff changeset
  1221
    self clippingBounds:savClip.
444
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
  1222
! !
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
  1223
494
76d8c4e0b612 directory indicator; set a path to be selected
ca
parents: 490
diff changeset
  1224
!SelectionInTreeView methodsFor:'enumerating'!
490
1129f3cf5cea add directory open/close indication
ca
parents: 485
diff changeset
  1225
494
76d8c4e0b612 directory indicator; set a path to be selected
ca
parents: 490
diff changeset
  1226
detectNode:aOneArgBlock
76d8c4e0b612 directory indicator; set a path to be selected
ca
parents: 490
diff changeset
  1227
    "evaluate the argument, aBlock for each node in the list until
76d8c4e0b612 directory indicator; set a path to be selected
ca
parents: 490
diff changeset
  1228
     the block returns true; in this case return the node which caused
76d8c4e0b612 directory indicator; set a path to be selected
ca
parents: 490
diff changeset
  1229
     the true evaluation. If none node is detected, nil is returned.
76d8c4e0b612 directory indicator; set a path to be selected
ca
parents: 490
diff changeset
  1230
    "
76d8c4e0b612 directory indicator; set a path to be selected
ca
parents: 490
diff changeset
  1231
  ^ listOfNodes detect:aOneArgBlock ifNone:nil
507
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  1232
!
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  1233
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  1234
selectedNodesDo:aOneArgBlock
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  1235
    "evaluate the block on each node selected
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  1236
    "
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  1237
    self selectionDo:[:i| aOneArgBlock value:(listOfNodes at:i) ]
490
1129f3cf5cea add directory open/close indication
ca
parents: 485
diff changeset
  1238
! !
1129f3cf5cea add directory open/close indication
ca
parents: 485
diff changeset
  1239
569
2a1014d6697c checkin from browser
ca
parents: 552
diff changeset
  1240
!SelectionInTreeView methodsFor:'event handling'!
2a1014d6697c checkin from browser
ca
parents: 552
diff changeset
  1241
3744
b956bec8751b cleanup
Claus Gittinger <cg@exept.de>
parents: 3739
diff changeset
  1242
activateMenu
b956bec8751b cleanup
Claus Gittinger <cg@exept.de>
parents: 3739
diff changeset
  1243
    |node menu|
b956bec8751b cleanup
Claus Gittinger <cg@exept.de>
parents: 3739
diff changeset
  1244
b956bec8751b cleanup
Claus Gittinger <cg@exept.de>
parents: 3739
diff changeset
  1245
    node := self selectedNode.
b956bec8751b cleanup
Claus Gittinger <cg@exept.de>
parents: 3739
diff changeset
  1246
    node notNil ifTrue:[
b956bec8751b cleanup
Claus Gittinger <cg@exept.de>
parents: 3739
diff changeset
  1247
        menu := node middleButtonMenu.
b956bec8751b cleanup
Claus Gittinger <cg@exept.de>
parents: 3739
diff changeset
  1248
        menu notNil ifTrue:[
b956bec8751b cleanup
Claus Gittinger <cg@exept.de>
parents: 3739
diff changeset
  1249
            menu isCollection ifTrue:[
b956bec8751b cleanup
Claus Gittinger <cg@exept.de>
parents: 3739
diff changeset
  1250
                |appl|
b956bec8751b cleanup
Claus Gittinger <cg@exept.de>
parents: 3739
diff changeset
  1251
b956bec8751b cleanup
Claus Gittinger <cg@exept.de>
parents: 3739
diff changeset
  1252
                menu := Menu decodeFromLiteralArray:menu.
b956bec8751b cleanup
Claus Gittinger <cg@exept.de>
parents: 3739
diff changeset
  1253
b956bec8751b cleanup
Claus Gittinger <cg@exept.de>
parents: 3739
diff changeset
  1254
                (appl := self application) notNil ifTrue:[
b956bec8751b cleanup
Claus Gittinger <cg@exept.de>
parents: 3739
diff changeset
  1255
                    menu findGuiResourcesIn:appl
b956bec8751b cleanup
Claus Gittinger <cg@exept.de>
parents: 3739
diff changeset
  1256
                ].
b956bec8751b cleanup
Claus Gittinger <cg@exept.de>
parents: 3739
diff changeset
  1257
                "/ menu receiver:appl. -- now done in findGuiResources ...
b956bec8751b cleanup
Claus Gittinger <cg@exept.de>
parents: 3739
diff changeset
  1258
            ].
b956bec8751b cleanup
Claus Gittinger <cg@exept.de>
parents: 3739
diff changeset
  1259
            self startUpMenu:menu.
b956bec8751b cleanup
Claus Gittinger <cg@exept.de>
parents: 3739
diff changeset
  1260
            ^ self.
b956bec8751b cleanup
Claus Gittinger <cg@exept.de>
parents: 3739
diff changeset
  1261
        ].
b956bec8751b cleanup
Claus Gittinger <cg@exept.de>
parents: 3739
diff changeset
  1262
    ].
b956bec8751b cleanup
Claus Gittinger <cg@exept.de>
parents: 3739
diff changeset
  1263
    super activateMenu
b956bec8751b cleanup
Claus Gittinger <cg@exept.de>
parents: 3739
diff changeset
  1264
!
b956bec8751b cleanup
Claus Gittinger <cg@exept.de>
parents: 3739
diff changeset
  1265
639
663a913ec30b discard motion events if +/- is pressed
ca
parents: 623
diff changeset
  1266
buttonMotion:buttonMask x:x y:y
663a913ec30b discard motion events if +/- is pressed
ca
parents: 623
diff changeset
  1267
    "mouse-move while button was pressed - handle selection changes"
663a913ec30b discard motion events if +/- is pressed
ca
parents: 623
diff changeset
  1268
663a913ec30b discard motion events if +/- is pressed
ca
parents: 623
diff changeset
  1269
    discardMotionEvents ifFalse:[
663a913ec30b discard motion events if +/- is pressed
ca
parents: 623
diff changeset
  1270
        super buttonMotion:buttonMask x:x y:y
663a913ec30b discard motion events if +/- is pressed
ca
parents: 623
diff changeset
  1271
    ]
663a913ec30b discard motion events if +/- is pressed
ca
parents: 623
diff changeset
  1272
663a913ec30b discard motion events if +/- is pressed
ca
parents: 623
diff changeset
  1273
663a913ec30b discard motion events if +/- is pressed
ca
parents: 623
diff changeset
  1274
!
663a913ec30b discard motion events if +/- is pressed
ca
parents: 623
diff changeset
  1275
569
2a1014d6697c checkin from browser
ca
parents: 552
diff changeset
  1276
buttonMultiPress:button x:x y:y
2a1014d6697c checkin from browser
ca
parents: 552
diff changeset
  1277
2a1014d6697c checkin from browser
ca
parents: 552
diff changeset
  1278
    (self indicatiorLineForButton:button atX:x y:y) == 0 ifTrue:[
2a1014d6697c checkin from browser
ca
parents: 552
diff changeset
  1279
        ^ super buttonMultiPress:button x:x y:y
2a1014d6697c checkin from browser
ca
parents: 552
diff changeset
  1280
    ].
2a1014d6697c checkin from browser
ca
parents: 552
diff changeset
  1281
    "/ discard doubleClick on indicator
2a1014d6697c checkin from browser
ca
parents: 552
diff changeset
  1282
!
2a1014d6697c checkin from browser
ca
parents: 552
diff changeset
  1283
2a1014d6697c checkin from browser
ca
parents: 552
diff changeset
  1284
buttonPress:button x:x y:y
3744
b956bec8751b cleanup
Claus Gittinger <cg@exept.de>
parents: 3739
diff changeset
  1285
    "handle button press event"
b956bec8751b cleanup
Claus Gittinger <cg@exept.de>
parents: 3739
diff changeset
  1286
b956bec8751b cleanup
Claus Gittinger <cg@exept.de>
parents: 3739
diff changeset
  1287
    |node|
b956bec8751b cleanup
Claus Gittinger <cg@exept.de>
parents: 3739
diff changeset
  1288
b956bec8751b cleanup
Claus Gittinger <cg@exept.de>
parents: 3739
diff changeset
  1289
    (button == 1) ifTrue:[
1171
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1290
        self handleSelectButtonAtX:x y:y.
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1291
3744
b956bec8751b cleanup
Claus Gittinger <cg@exept.de>
parents: 3739
diff changeset
  1292
        (editorWidget isNil
1171
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1293
         and:[(node := self selectedNode) notNil
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1294
         and:[node canEdit
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1295
         and:[x >= (self xOfValueNode:node)]]]
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1296
        ) ifTrue:[
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1297
            self openEditor
3744
b956bec8751b cleanup
Claus Gittinger <cg@exept.de>
parents: 3739
diff changeset
  1298
        ].
b956bec8751b cleanup
Claus Gittinger <cg@exept.de>
parents: 3739
diff changeset
  1299
        ^ self.
b956bec8751b cleanup
Claus Gittinger <cg@exept.de>
parents: 3739
diff changeset
  1300
    ].
b956bec8751b cleanup
Claus Gittinger <cg@exept.de>
parents: 3739
diff changeset
  1301
    super buttonPress:button x:x y:y
1171
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1302
!
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1303
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1304
buttonRelease:button x:x y:y
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1305
    "stop any autoscroll"
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1306
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1307
    discardMotionEvents ifTrue:[
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1308
        clickPosition := nil.
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1309
        discardMotionEvents := false.
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1310
    ].
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1311
    super buttonRelease:button x:x y:y
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1312
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1313
!
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1314
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1315
doubleClicked
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1316
    "handle a double click; collapse or expand selected entry
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1317
     in case of having children
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1318
    "
1815
a5f2bd36e179 double click on expandable item does not perform
Claus Gittinger <cg@exept.de>
parents: 1813
diff changeset
  1319
    |node |
1171
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1320
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1321
    (node := self selectedNode) notNil ifTrue:[
1202
b9a3beb20ca7 added an extra validateExpandability block,
Claus Gittinger <cg@exept.de>
parents: 1191
diff changeset
  1322
        (validateDoubleClickBlock isNil
b9a3beb20ca7 added an extra validateExpandability block,
Claus Gittinger <cg@exept.de>
parents: 1191
diff changeset
  1323
         or:[(validateDoubleClickBlock value:node) ~~ false]) ifTrue:[
b9a3beb20ca7 added an extra validateExpandability block,
Claus Gittinger <cg@exept.de>
parents: 1191
diff changeset
  1324
            (validateExpandabilityBlock isNil
b9a3beb20ca7 added an extra validateExpandability block,
Claus Gittinger <cg@exept.de>
parents: 1191
diff changeset
  1325
             or:[(validateExpandabilityBlock value:node) ~~ false]) ifTrue:[
b9a3beb20ca7 added an extra validateExpandability block,
Claus Gittinger <cg@exept.de>
parents: 1191
diff changeset
  1326
                self selectedNodeExpand:(node isExpandable).
b9a3beb20ca7 added an extra validateExpandability block,
Claus Gittinger <cg@exept.de>
parents: 1191
diff changeset
  1327
            ].
1815
a5f2bd36e179 double click on expandable item does not perform
Claus Gittinger <cg@exept.de>
parents: 1813
diff changeset
  1328
            node hasChildren ifFalse:[
a5f2bd36e179 double click on expandable item does not perform
Claus Gittinger <cg@exept.de>
parents: 1813
diff changeset
  1329
                super doubleClicked
a5f2bd36e179 double click on expandable item does not perform
Claus Gittinger <cg@exept.de>
parents: 1813
diff changeset
  1330
            ]
1171
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1331
        ]
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1332
    ]
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1333
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1334
!
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1335
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1336
handleSelectButtonAtX:x y:y
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1337
    "handle a select button click
569
2a1014d6697c checkin from browser
ca
parents: 552
diff changeset
  1338
    "
1268
37066c039eb3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
  1339
    |node lineNr sensor isExpd|
569
2a1014d6697c checkin from browser
ca
parents: 552
diff changeset
  1340
1171
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1341
    lineNr := self indicatiorLineForButton:#select atX:x y:y.
569
2a1014d6697c checkin from browser
ca
parents: 552
diff changeset
  1342
2a1014d6697c checkin from browser
ca
parents: 552
diff changeset
  1343
    lineNr == 0 ifTrue:[
3744
b956bec8751b cleanup
Claus Gittinger <cg@exept.de>
parents: 3739
diff changeset
  1344
        ^ super buttonPress:1 x:x y:y
569
2a1014d6697c checkin from browser
ca
parents: 552
diff changeset
  1345
    ].
2a1014d6697c checkin from browser
ca
parents: 552
diff changeset
  1346
    node := listOfNodes at:lineNr.
2a1014d6697c checkin from browser
ca
parents: 552
diff changeset
  1347
639
663a913ec30b discard motion events if +/- is pressed
ca
parents: 623
diff changeset
  1348
    discardMotionEvents := true.
569
2a1014d6697c checkin from browser
ca
parents: 552
diff changeset
  1349
    dragIsActive  := false.
2a1014d6697c checkin from browser
ca
parents: 552
diff changeset
  1350
    clickPosition := nil.
2a1014d6697c checkin from browser
ca
parents: 552
diff changeset
  1351
639
663a913ec30b discard motion events if +/- is pressed
ca
parents: 623
diff changeset
  1352
    self hasSelection ifTrue:[
663a913ec30b discard motion events if +/- is pressed
ca
parents: 623
diff changeset
  1353
        (selectConditionBlock isNil or:[selectConditionBlock value:lineNr]) ifTrue:[
663a913ec30b discard motion events if +/- is pressed
ca
parents: 623
diff changeset
  1354
            self selection:lineNr
663a913ec30b discard motion events if +/- is pressed
ca
parents: 623
diff changeset
  1355
        ] ifFalse:[
663a913ec30b discard motion events if +/- is pressed
ca
parents: 623
diff changeset
  1356
            self selection:nil
569
2a1014d6697c checkin from browser
ca
parents: 552
diff changeset
  1357
        ]
2a1014d6697c checkin from browser
ca
parents: 552
diff changeset
  1358
    ].
855
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
  1359
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
  1360
    isExpd := node isExpandable.
835
36202285352f support of expandAll/collapseAll if the indicator
ca
parents: 825
diff changeset
  1361
2483
1589203d52f3 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2333
diff changeset
  1362
    (supportsExpandAll
1589203d52f3 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2333
diff changeset
  1363
     and:[(sensor := self sensor) ctrlDown or:[sensor shiftDown]]
855
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
  1364
    ) ifTrue:[
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
  1365
        isExpd ifTrue:[model doExpandAll:node]
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
  1366
              ifFalse:[model doCollapseAll:node]
835
36202285352f support of expandAll/collapseAll if the indicator
ca
parents: 825
diff changeset
  1367
    ] ifFalse:[
855
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
  1368
        isExpd ifTrue:[model doExpand:node]
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
  1369
              ifFalse:[model doCollapse:node].
835
36202285352f support of expandAll/collapseAll if the indicator
ca
parents: 825
diff changeset
  1370
    ].
639
663a913ec30b discard motion events if +/- is pressed
ca
parents: 623
diff changeset
  1371
!
663a913ec30b discard motion events if +/- is pressed
ca
parents: 623
diff changeset
  1372
569
2a1014d6697c checkin from browser
ca
parents: 552
diff changeset
  1373
indicatiorLineForButton:aButton atX:x y:y
2a1014d6697c checkin from browser
ca
parents: 552
diff changeset
  1374
    "returns linenumber assigned to indicator at x/y or 0
2a1014d6697c checkin from browser
ca
parents: 552
diff changeset
  1375
    "
1268
37066c039eb3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
  1376
    |nr x0 node|
569
2a1014d6697c checkin from browser
ca
parents: 552
diff changeset
  1377
2a1014d6697c checkin from browser
ca
parents: 552
diff changeset
  1378
    (     enabled
2a1014d6697c checkin from browser
ca
parents: 552
diff changeset
  1379
     and:[showDirectoryIndicator
2a1014d6697c checkin from browser
ca
parents: 552
diff changeset
  1380
     and:[aButton == 1 or:[aButton == #select]]]
2a1014d6697c checkin from browser
ca
parents: 552
diff changeset
  1381
    ) ifTrue:[
2014
3052fe815bcb use #lineAtY:
Claus Gittinger <cg@exept.de>
parents: 1972
diff changeset
  1382
        nr := self lineAtY:y. "/ self visibleLineToListLine:(self visibleLineOfY:y).
569
2a1014d6697c checkin from browser
ca
parents: 552
diff changeset
  1383
835
36202285352f support of expandAll/collapseAll if the indicator
ca
parents: 825
diff changeset
  1384
        nr notNil ifTrue:[
36202285352f support of expandAll/collapseAll if the indicator
ca
parents: 825
diff changeset
  1385
            node := listOfNodes at:nr.
36202285352f support of expandAll/collapseAll if the indicator
ca
parents: 825
diff changeset
  1386
            node hasChildren ifTrue:[
36202285352f support of expandAll/collapseAll if the indicator
ca
parents: 825
diff changeset
  1387
                x0   := self xOfFigureLevel:(node level - 1).
569
2a1014d6697c checkin from browser
ca
parents: 552
diff changeset
  1388
835
36202285352f support of expandAll/collapseAll if the indicator
ca
parents: 825
diff changeset
  1389
                (x > x0 and:[(x0 + imageWidth) > x and:[node children notEmpty]]) ifTrue:[
36202285352f support of expandAll/collapseAll if the indicator
ca
parents: 825
diff changeset
  1390
                    ^ nr
569
2a1014d6697c checkin from browser
ca
parents: 552
diff changeset
  1391
                ]
2a1014d6697c checkin from browser
ca
parents: 552
diff changeset
  1392
            ]
2a1014d6697c checkin from browser
ca
parents: 552
diff changeset
  1393
        ]
2a1014d6697c checkin from browser
ca
parents: 552
diff changeset
  1394
    ].            
2a1014d6697c checkin from browser
ca
parents: 552
diff changeset
  1395
    ^ 0
756
204971de9150 key:key select:index x:x y:y
ca
parents: 695
diff changeset
  1396
!
204971de9150 key:key select:index x:x y:y
ca
parents: 695
diff changeset
  1397
835
36202285352f support of expandAll/collapseAll if the indicator
ca
parents: 825
diff changeset
  1398
isCtrlMetaAltOrShiftPressed
2483
1589203d52f3 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2333
diff changeset
  1399
    "returns true if CTRL, META, ALT or SHIFT is pressed"
1589203d52f3 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2333
diff changeset
  1400
1589203d52f3 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2333
diff changeset
  1401
    ^ self sensor anyModifierKeyDown.
835
36202285352f support of expandAll/collapseAll if the indicator
ca
parents: 825
diff changeset
  1402
!
36202285352f support of expandAll/collapseAll if the indicator
ca
parents: 825
diff changeset
  1403
756
204971de9150 key:key select:index x:x y:y
ca
parents: 695
diff changeset
  1404
key:key select:index x:x y:y
204971de9150 key:key select:index x:x y:y
ca
parents: 695
diff changeset
  1405
    "select an entry by a keyboard action. This is treated like a doubleClick
204971de9150 key:key select:index x:x y:y
ca
parents: 695
diff changeset
  1406
     on that entry.
204971de9150 key:key select:index x:x y:y
ca
parents: 695
diff changeset
  1407
     Add on: In case that the entry is not selectable, scroll to the entry
204971de9150 key:key select:index x:x y:y
ca
parents: 695
diff changeset
  1408
    "
204971de9150 key:key select:index x:x y:y
ca
parents: 695
diff changeset
  1409
    (enabled and:[keyActionStyle notNil]) ifFalse:[
204971de9150 key:key select:index x:x y:y
ca
parents: 695
diff changeset
  1410
        ^ self
204971de9150 key:key select:index x:x y:y
ca
parents: 695
diff changeset
  1411
    ].
204971de9150 key:key select:index x:x y:y
ca
parents: 695
diff changeset
  1412
204971de9150 key:key select:index x:x y:y
ca
parents: 695
diff changeset
  1413
    (selectConditionBlock isNil or:[selectConditionBlock value:index]) ifTrue:[
1887
b47b3cb2515b does not inherit #key:select:x:y:
Claus Gittinger <cg@exept.de>
parents: 1822
diff changeset
  1414
        ^ super keyPress:key x:x y:y
b47b3cb2515b does not inherit #key:select:x:y:
Claus Gittinger <cg@exept.de>
parents: 1822
diff changeset
  1415
        "/ ^ super key:key select:index x:x y:y
756
204971de9150 key:key select:index x:x y:y
ca
parents: 695
diff changeset
  1416
    ].
204971de9150 key:key select:index x:x y:y
ca
parents: 695
diff changeset
  1417
204971de9150 key:key select:index x:x y:y
ca
parents: 695
diff changeset
  1418
    keyActionStyle == #pass ifTrue:[
204971de9150 key:key select:index x:x y:y
ca
parents: 695
diff changeset
  1419
        ^ self
204971de9150 key:key select:index x:x y:y
ca
parents: 695
diff changeset
  1420
    ].
204971de9150 key:key select:index x:x y:y
ca
parents: 695
diff changeset
  1421
204971de9150 key:key select:index x:x y:y
ca
parents: 695
diff changeset
  1422
    self gotoLine:index
785
ca
parents: 782
diff changeset
  1423
!
ca
parents: 782
diff changeset
  1424
811
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1425
keyPress:key x:x y:y
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1426
    "handle keyboard input"
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1427
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1428
    <resource: #keyboard ( #CursorLeft #CursorRight ) >
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1429
4253
85c181bb2c96 class: SelectionInTreeView
Stefan Vogel <sv@exept.de>
parents: 4246
diff changeset
  1430
    |node|     
811
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1431
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1432
    enabled ifFalse:[
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1433
        ^ self
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1434
    ].
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1435
2065
845bd5d2523c crsrLeft/right behavior changed
Claus Gittinger <cg@exept.de>
parents: 2056
diff changeset
  1436
    "/ cg: its nicer to expand/collaps on these keys
845bd5d2523c crsrLeft/right behavior changed
Claus Gittinger <cg@exept.de>
parents: 2056
diff changeset
  1437
    key == #CursorRight ifTrue:[
845bd5d2523c crsrLeft/right behavior changed
Claus Gittinger <cg@exept.de>
parents: 2056
diff changeset
  1438
        (node := self selectedNode) notNil ifTrue:[
845bd5d2523c crsrLeft/right behavior changed
Claus Gittinger <cg@exept.de>
parents: 2056
diff changeset
  1439
            model doExpand:node.
845bd5d2523c crsrLeft/right behavior changed
Claus Gittinger <cg@exept.de>
parents: 2056
diff changeset
  1440
            ^ self.
845bd5d2523c crsrLeft/right behavior changed
Claus Gittinger <cg@exept.de>
parents: 2056
diff changeset
  1441
        ].
845bd5d2523c crsrLeft/right behavior changed
Claus Gittinger <cg@exept.de>
parents: 2056
diff changeset
  1442
    ].
845bd5d2523c crsrLeft/right behavior changed
Claus Gittinger <cg@exept.de>
parents: 2056
diff changeset
  1443
    key == #CursorLeft ifTrue:[
845bd5d2523c crsrLeft/right behavior changed
Claus Gittinger <cg@exept.de>
parents: 2056
diff changeset
  1444
        (node := self selectedNode) notNil ifTrue:[
845bd5d2523c crsrLeft/right behavior changed
Claus Gittinger <cg@exept.de>
parents: 2056
diff changeset
  1445
            model doCollapse:node.
845bd5d2523c crsrLeft/right behavior changed
Claus Gittinger <cg@exept.de>
parents: 2056
diff changeset
  1446
            ^ self.
811
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1447
        ].
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1448
    ].
2065
845bd5d2523c crsrLeft/right behavior changed
Claus Gittinger <cg@exept.de>
parents: 2056
diff changeset
  1449
845bd5d2523c crsrLeft/right behavior changed
Claus Gittinger <cg@exept.de>
parents: 2056
diff changeset
  1450
    "/ search fwd/bwd for a node with children
845bd5d2523c crsrLeft/right behavior changed
Claus Gittinger <cg@exept.de>
parents: 2056
diff changeset
  1451
845bd5d2523c crsrLeft/right behavior changed
Claus Gittinger <cg@exept.de>
parents: 2056
diff changeset
  1452
"/    (key == #CursorLeft or:[key == #CursorRight]) ifTrue:[
845bd5d2523c crsrLeft/right behavior changed
Claus Gittinger <cg@exept.de>
parents: 2056
diff changeset
  1453
"/        (idx := self selectedIndex) == 0 ifTrue:[ ^ self ].
845bd5d2523c crsrLeft/right behavior changed
Claus Gittinger <cg@exept.de>
parents: 2056
diff changeset
  1454
"/
845bd5d2523c crsrLeft/right behavior changed
Claus Gittinger <cg@exept.de>
parents: 2056
diff changeset
  1455
"/        (key == #CursorLeft) ifTrue:[ inc := -1. end := 0 ]
845bd5d2523c crsrLeft/right behavior changed
Claus Gittinger <cg@exept.de>
parents: 2056
diff changeset
  1456
"/                            ifFalse:[ inc :=  1. end := 1 + listOfNodes size ].
845bd5d2523c crsrLeft/right behavior changed
Claus Gittinger <cg@exept.de>
parents: 2056
diff changeset
  1457
"/
845bd5d2523c crsrLeft/right behavior changed
Claus Gittinger <cg@exept.de>
parents: 2056
diff changeset
  1458
"/        [(idx := idx + inc) ~~ end] whileTrue:[
845bd5d2523c crsrLeft/right behavior changed
Claus Gittinger <cg@exept.de>
parents: 2056
diff changeset
  1459
"/            node := listOfNodes at:idx.
845bd5d2523c crsrLeft/right behavior changed
Claus Gittinger <cg@exept.de>
parents: 2056
diff changeset
  1460
"/            node hasChildren ifTrue:[
845bd5d2523c crsrLeft/right behavior changed
Claus Gittinger <cg@exept.de>
parents: 2056
diff changeset
  1461
"/                ^ self key:key select:idx x:x y:y
845bd5d2523c crsrLeft/right behavior changed
Claus Gittinger <cg@exept.de>
parents: 2056
diff changeset
  1462
"/            ]
845bd5d2523c crsrLeft/right behavior changed
Claus Gittinger <cg@exept.de>
parents: 2056
diff changeset
  1463
"/        ].
845bd5d2523c crsrLeft/right behavior changed
Claus Gittinger <cg@exept.de>
parents: 2056
diff changeset
  1464
"/        ^ self
845bd5d2523c crsrLeft/right behavior changed
Claus Gittinger <cg@exept.de>
parents: 2056
diff changeset
  1465
"/    ].
811
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1466
    ^ super keyPress:key x:x y:y
569
2a1014d6697c checkin from browser
ca
parents: 552
diff changeset
  1467
! !
2a1014d6697c checkin from browser
ca
parents: 552
diff changeset
  1468
2501
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2494
diff changeset
  1469
!SelectionInTreeView methodsFor:'initialization & release'!
444
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
  1470
685
80751cda3340 lines as point
ca
parents: 659
diff changeset
  1471
create
80751cda3340 lines as point
ca
parents: 659
diff changeset
  1472
    super create.
5004
fc2a53728ebf device access
Claus Gittinger <cg@exept.de>
parents: 4608
diff changeset
  1473
    lineMask := lineMask onDevice:device.
685
80751cda3340 lines as point
ca
parents: 659
diff changeset
  1474
846
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  1475
    lineColor := lineColor isNil ifTrue:[fgColor]
5004
fc2a53728ebf device access
Claus Gittinger <cg@exept.de>
parents: 4608
diff changeset
  1476
                                ifFalse:[lineColor onDevice:device].
fc2a53728ebf device access
Claus Gittinger <cg@exept.de>
parents: 4608
diff changeset
  1477
fc2a53728ebf device access
Claus Gittinger <cg@exept.de>
parents: 4608
diff changeset
  1478
    editValueFgColor := editValueFgColor onDevice:device.
685
80751cda3340 lines as point
ca
parents: 659
diff changeset
  1479
!
80751cda3340 lines as point
ca
parents: 659
diff changeset
  1480
785
ca
parents: 782
diff changeset
  1481
fetchDefaultImages
ca
parents: 782
diff changeset
  1482
    "returns a directory with default keys and images; could be
ca
parents: 782
diff changeset
  1483
     redefined by subclass.
ca
parents: 782
diff changeset
  1484
    "
1171
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1485
    ^ itemClass notNil ifTrue:[itemClass keysAndIcons]
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1486
                      ifFalse:[nil]
785
ca
parents: 782
diff changeset
  1487
!
ca
parents: 782
diff changeset
  1488
448
7f9f3531660c cache device images for fast drawing
Claus Gittinger <cg@exept.de>
parents: 446
diff changeset
  1489
fetchDeviceResources
7f9f3531660c cache device images for fast drawing
Claus Gittinger <cg@exept.de>
parents: 446
diff changeset
  1490
    "initialize heavily used device resources - to avoid rendering
7f9f3531660c cache device images for fast drawing
Claus Gittinger <cg@exept.de>
parents: 446
diff changeset
  1491
     images again and again later"
7f9f3531660c cache device images for fast drawing
Claus Gittinger <cg@exept.de>
parents: 446
diff changeset
  1492
7f9f3531660c cache device images for fast drawing
Claus Gittinger <cg@exept.de>
parents: 446
diff changeset
  1493
    super fetchDeviceResources.
478
ca
parents: 471
diff changeset
  1494
    self refetchDeviceResources
448
7f9f3531660c cache device images for fast drawing
Claus Gittinger <cg@exept.de>
parents: 446
diff changeset
  1495
!
7f9f3531660c cache device images for fast drawing
Claus Gittinger <cg@exept.de>
parents: 446
diff changeset
  1496
478
ca
parents: 471
diff changeset
  1497
fetchImageResources
ca
parents: 471
diff changeset
  1498
    "initialize heavily used device resources - to avoid rendering
ca
parents: 471
diff changeset
  1499
     images again and again later; returns maximum extent of the images used.
ca
parents: 471
diff changeset
  1500
     Could be redefined by subclass
471
6fe41e3caca1 add showLines;
ca
parents: 470
diff changeset
  1501
    "
785
ca
parents: 782
diff changeset
  1502
    |img x y keysAndIcons|
494
76d8c4e0b612 directory indicator; set a path to be selected
ca
parents: 490
diff changeset
  1503
1070
856d037fe133 care for non-existing images.
Claus Gittinger <cg@exept.de>
parents: 1061
diff changeset
  1504
    x := y := 0.
494
76d8c4e0b612 directory indicator; set a path to be selected
ca
parents: 490
diff changeset
  1505
    imageOpened isNil ifTrue:[
2488
74c81c1e30d7 imageOnDevice -> imageOnMyDevice
Claus Gittinger <cg@exept.de>
parents: 2483
diff changeset
  1506
        imageOpened := self imageOnMyDevice:(self class imageOpened)
494
76d8c4e0b612 directory indicator; set a path to be selected
ca
parents: 490
diff changeset
  1507
    ].
1070
856d037fe133 care for non-existing images.
Claus Gittinger <cg@exept.de>
parents: 1061
diff changeset
  1508
    imageOpened notNil ifTrue:[
856d037fe133 care for non-existing images.
Claus Gittinger <cg@exept.de>
parents: 1061
diff changeset
  1509
        x := x max:(imageOpened width).
856d037fe133 care for non-existing images.
Claus Gittinger <cg@exept.de>
parents: 1061
diff changeset
  1510
        y := y max:(imageOpened height).
856d037fe133 care for non-existing images.
Claus Gittinger <cg@exept.de>
parents: 1061
diff changeset
  1511
    ].
444
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
  1512
494
76d8c4e0b612 directory indicator; set a path to be selected
ca
parents: 490
diff changeset
  1513
    imageClosed isNil ifTrue:[
2488
74c81c1e30d7 imageOnDevice -> imageOnMyDevice
Claus Gittinger <cg@exept.de>
parents: 2483
diff changeset
  1514
        imageClosed := self imageOnMyDevice:(self class imageClosed)
533
d7867efb6f60 #fetchImageResources returned the max extent only on the first invocation
Stefan Vogel <sv@exept.de>
parents: 532
diff changeset
  1515
    ].
1070
856d037fe133 care for non-existing images.
Claus Gittinger <cg@exept.de>
parents: 1061
diff changeset
  1516
    imageClosed notNil ifTrue:[
856d037fe133 care for non-existing images.
Claus Gittinger <cg@exept.de>
parents: 1061
diff changeset
  1517
        x := x max:(imageClosed width).
856d037fe133 care for non-existing images.
Claus Gittinger <cg@exept.de>
parents: 1061
diff changeset
  1518
        y := y max:(imageClosed height).
856d037fe133 care for non-existing images.
Claus Gittinger <cg@exept.de>
parents: 1061
diff changeset
  1519
    ].
494
76d8c4e0b612 directory indicator; set a path to be selected
ca
parents: 490
diff changeset
  1520
76d8c4e0b612 directory indicator; set a path to be selected
ca
parents: 490
diff changeset
  1521
    imageItem isNil ifTrue:[
2488
74c81c1e30d7 imageOnDevice -> imageOnMyDevice
Claus Gittinger <cg@exept.de>
parents: 2483
diff changeset
  1522
        imageItem := self imageOnMyDevice:(self class imageItem)
533
d7867efb6f60 #fetchImageResources returned the max extent only on the first invocation
Stefan Vogel <sv@exept.de>
parents: 532
diff changeset
  1523
    ].
1070
856d037fe133 care for non-existing images.
Claus Gittinger <cg@exept.de>
parents: 1061
diff changeset
  1524
    imageItem notNil ifTrue:[
856d037fe133 care for non-existing images.
Claus Gittinger <cg@exept.de>
parents: 1061
diff changeset
  1525
        x := x max:(imageItem width).
856d037fe133 care for non-existing images.
Claus Gittinger <cg@exept.de>
parents: 1061
diff changeset
  1526
        y := y max:(imageItem height).
856d037fe133 care for non-existing images.
Claus Gittinger <cg@exept.de>
parents: 1061
diff changeset
  1527
    ].
763
dd29c58e8ea6 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 760
diff changeset
  1528
785
ca
parents: 782
diff changeset
  1529
    (keysAndIcons := self fetchDefaultImages) notNil ifTrue:[
ca
parents: 782
diff changeset
  1530
        keysAndIcons keysAndValuesDo:[:aKey :anIcon|
ca
parents: 782
diff changeset
  1531
            (anIcon isImage and:[aKey notNil]) ifTrue:[
2488
74c81c1e30d7 imageOnDevice -> imageOnMyDevice
Claus Gittinger <cg@exept.de>
parents: 2483
diff changeset
  1532
                registeredImages at:aKey put:(self imageOnMyDevice:anIcon)
785
ca
parents: 782
diff changeset
  1533
            ]
ca
parents: 782
diff changeset
  1534
        ]
ca
parents: 782
diff changeset
  1535
    ].
ca
parents: 782
diff changeset
  1536
    registeredImages keysAndValuesDo:[:k :img|
ca
parents: 782
diff changeset
  1537
        x := (img width)  max:x.
ca
parents: 782
diff changeset
  1538
        y := (img height) max:y.
ca
parents: 782
diff changeset
  1539
    ].
763
dd29c58e8ea6 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 760
diff changeset
  1540
785
ca
parents: 782
diff changeset
  1541
    (listOfNodes size > 0 and:[(img := listOfNodes first icon) isImage]) ifTrue:[
ca
parents: 782
diff changeset
  1542
        x := (img width)  max:x.
ca
parents: 782
diff changeset
  1543
        y := (img height) max:y.
ca
parents: 782
diff changeset
  1544
    ].
ca
parents: 782
diff changeset
  1545
    ^ x @ y
1070
856d037fe133 care for non-existing images.
Claus Gittinger <cg@exept.de>
parents: 1061
diff changeset
  1546
856d037fe133 care for non-existing images.
Claus Gittinger <cg@exept.de>
parents: 1061
diff changeset
  1547
    "Modified: / 12.8.1998 / 12:45:53 / cg"
444
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
  1548
!
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
  1549
480
982c2ad4f6a2 getFontParameters
ca
parents: 478
diff changeset
  1550
getFontParameters
546
8d274d70c2c3 fetch resources only if list of nodes not nil otherwise
ca
parents: 545
diff changeset
  1551
    "save old computed height derived from images
8d274d70c2c3 fetch resources only if list of nodes not nil otherwise
ca
parents: 545
diff changeset
  1552
    "
8d274d70c2c3 fetch resources only if list of nodes not nil otherwise
ca
parents: 545
diff changeset
  1553
    |lineHeight|
8d274d70c2c3 fetch resources only if list of nodes not nil otherwise
ca
parents: 545
diff changeset
  1554
8d274d70c2c3 fetch resources only if list of nodes not nil otherwise
ca
parents: 545
diff changeset
  1555
    lineHeight := fontHeight ? 0.
480
982c2ad4f6a2 getFontParameters
ca
parents: 478
diff changeset
  1556
    super getFontParameters.
569
2a1014d6697c checkin from browser
ca
parents: 552
diff changeset
  1557
    labelOffsetY := fontAscent - (fontHeight - lineSpacing // 2).
480
982c2ad4f6a2 getFontParameters
ca
parents: 478
diff changeset
  1558
546
8d274d70c2c3 fetch resources only if list of nodes not nil otherwise
ca
parents: 545
diff changeset
  1559
    lineHeight > fontHeight ifTrue:[
8d274d70c2c3 fetch resources only if list of nodes not nil otherwise
ca
parents: 545
diff changeset
  1560
        fontHeight := lineHeight
8d274d70c2c3 fetch resources only if list of nodes not nil otherwise
ca
parents: 545
diff changeset
  1561
    ].
685
80751cda3340 lines as point
ca
parents: 659
diff changeset
  1562
    fontHeight odd ifTrue:[
80751cda3340 lines as point
ca
parents: 659
diff changeset
  1563
        fontHeight := fontHeight + 1
80751cda3340 lines as point
ca
parents: 659
diff changeset
  1564
    ]
480
982c2ad4f6a2 getFontParameters
ca
parents: 478
diff changeset
  1565
!
982c2ad4f6a2 getFontParameters
ca
parents: 478
diff changeset
  1566
900
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
  1567
initStyle
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
  1568
    "setup viewStyle specifics"
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
  1569
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
  1570
    super initStyle.
1171
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1571
    highlightMode := DefaultHilightMode ? #label.
900
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
  1572
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
  1573
!
cd74dcab7e3f support hightlightMode
ca
parents: 860
diff changeset
  1574
444
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
  1575
initialize
471
6fe41e3caca1 add showLines;
ca
parents: 470
diff changeset
  1576
    "setup instance attributes
6fe41e3caca1 add showLines;
ca
parents: 470
diff changeset
  1577
    "
444
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
  1578
    super initialize.
1171
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1579
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1580
    itemClass isNil ifTrue:[
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1581
        itemClass := TreeItem
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1582
    ].
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1583
835
36202285352f support of expandAll/collapseAll if the indicator
ca
parents: 825
diff changeset
  1584
    supportsExpandAll := true.
569
2a1014d6697c checkin from browser
ca
parents: 552
diff changeset
  1585
    self bitGravity:#NorthWest.
773
b3596157f97d register the icons and put them into a caching dict
tz
parents: 771
diff changeset
  1586
    showRoot := showDirectoryIndicatorForRoot      := showLines := computeResources := true.
1815
a5f2bd36e179 double click on expandable item does not perform
Claus Gittinger <cg@exept.de>
parents: 1813
diff changeset
  1587
    showDirectoryIndicator := discardMotionEvents := showLinesForRoot := false.
1275
cc62615ed032 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
  1588
    leftMargin := 2.
cc62615ed032 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
  1589
    lineMask   := Form width:2 height:2 fromArray:#[16rAA 16r55].
773
b3596157f97d register the icons and put them into a caching dict
tz
parents: 771
diff changeset
  1590
    registeredImages := IdentityDictionary new.
855
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
  1591
    drawVLinesFromLevel := 1.
659
16bb1d26f658 add showDirectoryIndicatorForRoot
ca
parents: 639
diff changeset
  1592
    textInset  := 4.
494
76d8c4e0b612 directory indicator; set a path to be selected
ca
parents: 490
diff changeset
  1593
    imageInset := 0.    "/ set during indication enabled
76d8c4e0b612 directory indicator; set a path to be selected
ca
parents: 490
diff changeset
  1594
    imageWidth := 8.    "/ default: will change during startup
848
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  1595
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  1596
    buildInArray := Array new:50.       "/ used for temporary calculation
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  1597
                                        "/ suppress garbage collection
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  1598
514
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
  1599
    self model:nil.     "/ creates a default model.
1171
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1600
    highlightMode := #label.
1175
1fa0de353686 add new color used by editValue
ca
parents: 1171
diff changeset
  1601
    editValueFgColor := Color blue.
478
ca
parents: 471
diff changeset
  1602
!
ca
parents: 471
diff changeset
  1603
569
2a1014d6697c checkin from browser
ca
parents: 552
diff changeset
  1604
realize
2a1014d6697c checkin from browser
ca
parents: 552
diff changeset
  1605
    super realize.
2a1014d6697c checkin from browser
ca
parents: 552
diff changeset
  1606
    self  refetchDeviceResources.
2a1014d6697c checkin from browser
ca
parents: 552
diff changeset
  1607
!
2a1014d6697c checkin from browser
ca
parents: 552
diff changeset
  1608
811
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1609
recomputeDirectoryIndicator
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1610
    "setup attributes used by directory indicator
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1611
    "
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1612
    |x w|
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1613
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1614
    imageInset := 0.
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1615
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1616
    (showDirectoryIndicator and:[computeResources not]) ifFalse:[
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1617
        ^ self
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1618
    ].
1072
1888703adc18 care for non-existing open/close indicators.
Claus Gittinger <cg@exept.de>
parents: 1070
diff changeset
  1619
1888703adc18 care for non-existing open/close indicators.
Claus Gittinger <cg@exept.de>
parents: 1070
diff changeset
  1620
    x := 0.
811
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1621
    openIndicator isNil ifTrue:[
2488
74c81c1e30d7 imageOnDevice -> imageOnMyDevice
Claus Gittinger <cg@exept.de>
parents: 2483
diff changeset
  1622
        openIndicator  := self imageOnMyDevice:(self class openIndicator)
811
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1623
    ].
1072
1888703adc18 care for non-existing open/close indicators.
Claus Gittinger <cg@exept.de>
parents: 1070
diff changeset
  1624
    openIndicator notNil ifTrue:[
1888703adc18 care for non-existing open/close indicators.
Claus Gittinger <cg@exept.de>
parents: 1070
diff changeset
  1625
        x := openIndicator width
1888703adc18 care for non-existing open/close indicators.
Claus Gittinger <cg@exept.de>
parents: 1070
diff changeset
  1626
    ].
1888703adc18 care for non-existing open/close indicators.
Claus Gittinger <cg@exept.de>
parents: 1070
diff changeset
  1627
811
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1628
    closeIndicator isNil ifTrue:[
2488
74c81c1e30d7 imageOnDevice -> imageOnMyDevice
Claus Gittinger <cg@exept.de>
parents: 2483
diff changeset
  1629
        closeIndicator := self imageOnMyDevice:(self class closeIndicator)
811
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1630
    ].
1072
1888703adc18 care for non-existing open/close indicators.
Claus Gittinger <cg@exept.de>
parents: 1070
diff changeset
  1631
    closeIndicator notNil ifTrue:[
1888703adc18 care for non-existing open/close indicators.
Claus Gittinger <cg@exept.de>
parents: 1070
diff changeset
  1632
        x := x max:(closeIndicator width)
1888703adc18 care for non-existing open/close indicators.
Claus Gittinger <cg@exept.de>
parents: 1070
diff changeset
  1633
    ].
1888703adc18 care for non-existing open/close indicators.
Claus Gittinger <cg@exept.de>
parents: 1070
diff changeset
  1634
811
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1635
    x := x // 2.
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1636
    w := imageWidth // 2.
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1637
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1638
    (x := x + self class minImageInset) > w ifTrue:[
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1639
        imageInset := x - w.
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1640
    ].
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1641
1072
1888703adc18 care for non-existing open/close indicators.
Claus Gittinger <cg@exept.de>
parents: 1070
diff changeset
  1642
    "Modified: / 13.8.1998 / 12:02:04 / cg"
811
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1643
!
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1644
478
ca
parents: 471
diff changeset
  1645
refetchDeviceResources
ca
parents: 471
diff changeset
  1646
    "reinitialize heavily used device resources - to avoid rendering
ca
parents: 471
diff changeset
  1647
     images again and again later
ca
parents: 471
diff changeset
  1648
    "
551
b9d3ddbc3365 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 546
diff changeset
  1649
    |extent|
478
ca
parents: 471
diff changeset
  1650
569
2a1014d6697c checkin from browser
ca
parents: 552
diff changeset
  1651
    (realized and:[computeResources and:[listOfNodes size ~~ 0]]) ifTrue:[
546
8d274d70c2c3 fetch resources only if list of nodes not nil otherwise
ca
parents: 545
diff changeset
  1652
        computeResources := false.
8d274d70c2c3 fetch resources only if list of nodes not nil otherwise
ca
parents: 545
diff changeset
  1653
        extent := self fetchImageResources.
494
76d8c4e0b612 directory indicator; set a path to be selected
ca
parents: 490
diff changeset
  1654
546
8d274d70c2c3 fetch resources only if list of nodes not nil otherwise
ca
parents: 545
diff changeset
  1655
        extent y >= fontHeight ifTrue:[
8d274d70c2c3 fetch resources only if list of nodes not nil otherwise
ca
parents: 545
diff changeset
  1656
            fontHeight := 1 + extent y.
494
76d8c4e0b612 directory indicator; set a path to be selected
ca
parents: 490
diff changeset
  1657
        ].
685
80751cda3340 lines as point
ca
parents: 659
diff changeset
  1658
        fontHeight odd ifTrue:[
80751cda3340 lines as point
ca
parents: 659
diff changeset
  1659
            fontHeight := fontHeight + 1
80751cda3340 lines as point
ca
parents: 659
diff changeset
  1660
        ].
846
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  1661
        "/ round and not odd: because of line drawing
685
80751cda3340 lines as point
ca
parents: 659
diff changeset
  1662
846
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  1663
        imageWidth := (extent x) // 2.
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  1664
        imageWidth odd ifTrue:[imageWidth := imageWidth + 1].
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  1665
        imageWidth := imageWidth * 2.
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  1666
546
8d274d70c2c3 fetch resources only if list of nodes not nil otherwise
ca
parents: 545
diff changeset
  1667
        self recomputeDirectoryIndicator.
569
2a1014d6697c checkin from browser
ca
parents: 552
diff changeset
  1668
        self computeNumberOfLinesShown.
546
8d274d70c2c3 fetch resources only if list of nodes not nil otherwise
ca
parents: 545
diff changeset
  1669
    ]
2156
e16dc409ecf2 destroy - release
Claus Gittinger <cg@exept.de>
parents: 2065
diff changeset
  1670
!
e16dc409ecf2 destroy - release
Claus Gittinger <cg@exept.de>
parents: 2065
diff changeset
  1671
e16dc409ecf2 destroy - release
Claus Gittinger <cg@exept.de>
parents: 2065
diff changeset
  1672
release
e16dc409ecf2 destroy - release
Claus Gittinger <cg@exept.de>
parents: 2065
diff changeset
  1673
    "remove dependencies
e16dc409ecf2 destroy - release
Claus Gittinger <cg@exept.de>
parents: 2065
diff changeset
  1674
    "
e16dc409ecf2 destroy - release
Claus Gittinger <cg@exept.de>
parents: 2065
diff changeset
  1675
    rootHolder removeDependent:self.
e16dc409ecf2 destroy - release
Claus Gittinger <cg@exept.de>
parents: 2065
diff changeset
  1676
    selectionHolder removeDependent:self.
e16dc409ecf2 destroy - release
Claus Gittinger <cg@exept.de>
parents: 2065
diff changeset
  1677
e16dc409ecf2 destroy - release
Claus Gittinger <cg@exept.de>
parents: 2065
diff changeset
  1678
    model notNil ifTrue:[
e16dc409ecf2 destroy - release
Claus Gittinger <cg@exept.de>
parents: 2065
diff changeset
  1679
        model stopRunningTasks
e16dc409ecf2 destroy - release
Claus Gittinger <cg@exept.de>
parents: 2065
diff changeset
  1680
    ].
e16dc409ecf2 destroy - release
Claus Gittinger <cg@exept.de>
parents: 2065
diff changeset
  1681
    super release.
444
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
  1682
! !
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
  1683
483
1dad61b63e9d optimize doubleClicked & redrawing
ca
parents: 481
diff changeset
  1684
!SelectionInTreeView methodsFor:'model'!
444
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
  1685
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
  1686
getListFromModel
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
  1687
    "if I have a model, get my list from it using the listMessage.
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
  1688
     If listMessage is nil, try aspectMessage for backward compatibilty.
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
  1689
    "
483
1dad61b63e9d optimize doubleClicked & redrawing
ca
parents: 481
diff changeset
  1690
    super list:(self listFromModel) keepSelection:true
1dad61b63e9d optimize doubleClicked & redrawing
ca
parents: 481
diff changeset
  1691
!
444
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
  1692
483
1dad61b63e9d optimize doubleClicked & redrawing
ca
parents: 481
diff changeset
  1693
listFromModel
1dad61b63e9d optimize doubleClicked & redrawing
ca
parents: 481
diff changeset
  1694
    "get list from model and return the new list.
1dad61b63e9d optimize doubleClicked & redrawing
ca
parents: 481
diff changeset
  1695
     If listMessage is nil, try aspectMessage for backward compatibilty.
1dad61b63e9d optimize doubleClicked & redrawing
ca
parents: 481
diff changeset
  1696
    "
846
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  1697
    |msg|
838
d15daece0c54 optimize algorithm to get list from model and to
ca
parents: 835
diff changeset
  1698
846
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  1699
    widthOfWidestLine := nil.
847
8395a2d05464 recompute image height whenever list changed
ca
parents: 846
diff changeset
  1700
    list := listOfNodes := (msg := listMsg ? aspectMsg) notNil ifTrue:[model perform:msg] ifFalse:[#()].
8395a2d05464 recompute image height whenever list changed
ca
parents: 846
diff changeset
  1701
    self refetchDeviceResources.
846
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  1702
  ^ listOfNodes
494
76d8c4e0b612 directory indicator; set a path to be selected
ca
parents: 490
diff changeset
  1703
!
76d8c4e0b612 directory indicator; set a path to be selected
ca
parents: 490
diff changeset
  1704
76d8c4e0b612 directory indicator; set a path to be selected
ca
parents: 490
diff changeset
  1705
model:aModel
514
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
  1706
    "check whether model is nil; than a default model is created
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
  1707
    "
855
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
  1708
    |model root|
514
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
  1709
811
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1710
    model notNil ifTrue:[
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1711
        model stopRunningTasks
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1712
    ].
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1713
1171
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1714
    model := aModel ? (self class defaultModelClass new).
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1715
    self itemClass:(model class defaultItemClass).
855
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
  1716
    root  := model root.
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
  1717
514
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
  1718
    model showRoot:showRoot.
855
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
  1719
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
  1720
    root notNil ifTrue:[
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
  1721
        root expand
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
  1722
    ].
514
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
  1723
    super model:model.
855
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
  1724
    self getListFromModel
811
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1725
514
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
  1726
!
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
  1727
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
  1728
rootFromModel
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
  1729
    "update hierarchical list from root model; 'rootHolder'
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
  1730
    "
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
  1731
    |root|
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
  1732
585
5a0ed2305998 bug fixes:
ca
parents: 569
diff changeset
  1733
    root := rootHolder root.
514
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
  1734
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
  1735
    self root == root ifFalse:[
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
  1736
        self selection:nil.
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
  1737
        self root:root.
585
5a0ed2305998 bug fixes:
ca
parents: 569
diff changeset
  1738
    ].
514
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
  1739
!
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
  1740
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
  1741
selectionFromModel
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
  1742
    "set the selection derived from the selectionHolder
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
  1743
    "
855
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
  1744
    |coll value size idx|
514
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
  1745
4246
b2aeabea341b class: SelectionInTreeView
Claus Gittinger <cg@exept.de>
parents: 3985
diff changeset
  1746
    (value := selectionHolder value) notNil ifTrue:[
1214
6aa740fb636c code cleanup.
Claus Gittinger <cg@exept.de>
parents: 1202
diff changeset
  1747
        (multipleSelectOk and:[value isCollection]) ifFalse:[
2688
2d853020325f bugfix: catch recursion if selection changed through to the model
ca
parents: 2659
diff changeset
  1748
            ^ self selectNode:value withNotify:false.
860
64d52b8e3dbd bug fix in remove:
ca
parents: 855
diff changeset
  1749
        ].
1214
6aa740fb636c code cleanup.
Claus Gittinger <cg@exept.de>
parents: 1202
diff changeset
  1750
6aa740fb636c code cleanup.
Claus Gittinger <cg@exept.de>
parents: 1202
diff changeset
  1751
        (size := value size) ~~ 0 ifTrue:[
6aa740fb636c code cleanup.
Claus Gittinger <cg@exept.de>
parents: 1202
diff changeset
  1752
            size == 1 ifTrue:[
2688
2d853020325f bugfix: catch recursion if selection changed through to the model
ca
parents: 2659
diff changeset
  1753
                ^ self selectNode:(value at:1) withNotify:false
1214
6aa740fb636c code cleanup.
Claus Gittinger <cg@exept.de>
parents: 1202
diff changeset
  1754
            ].
6aa740fb636c code cleanup.
Claus Gittinger <cg@exept.de>
parents: 1202
diff changeset
  1755
6aa740fb636c code cleanup.
Claus Gittinger <cg@exept.de>
parents: 1202
diff changeset
  1756
            model doMakeVisible:value.
6aa740fb636c code cleanup.
Claus Gittinger <cg@exept.de>
parents: 1202
diff changeset
  1757
6aa740fb636c code cleanup.
Claus Gittinger <cg@exept.de>
parents: 1202
diff changeset
  1758
            coll := OrderedCollection new:size.
6aa740fb636c code cleanup.
Claus Gittinger <cg@exept.de>
parents: 1202
diff changeset
  1759
6aa740fb636c code cleanup.
Claus Gittinger <cg@exept.de>
parents: 1202
diff changeset
  1760
            value do:[:el|
6aa740fb636c code cleanup.
Claus Gittinger <cg@exept.de>
parents: 1202
diff changeset
  1761
                idx := el isNumber ifTrue:[el] ifFalse:[self indexOfNode:el].
6aa740fb636c code cleanup.
Claus Gittinger <cg@exept.de>
parents: 1202
diff changeset
  1762
6aa740fb636c code cleanup.
Claus Gittinger <cg@exept.de>
parents: 1202
diff changeset
  1763
                idx ~~ 0 ifTrue:[
6aa740fb636c code cleanup.
Claus Gittinger <cg@exept.de>
parents: 1202
diff changeset
  1764
                    coll add:idx
6aa740fb636c code cleanup.
Claus Gittinger <cg@exept.de>
parents: 1202
diff changeset
  1765
                ].
6aa740fb636c code cleanup.
Claus Gittinger <cg@exept.de>
parents: 1202
diff changeset
  1766
            ].
6aa740fb636c code cleanup.
Claus Gittinger <cg@exept.de>
parents: 1202
diff changeset
  1767
4272
7372fb880713 class: SelectionInTreeView
Claus Gittinger <cg@exept.de>
parents: 4253
diff changeset
  1768
            coll := coll asNilIfEmpty.
1214
6aa740fb636c code cleanup.
Claus Gittinger <cg@exept.de>
parents: 1202
diff changeset
  1769
        ].
848
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  1770
    ].
2688
2d853020325f bugfix: catch recursion if selection changed through to the model
ca
parents: 2659
diff changeset
  1771
    self setSelection:coll
514
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
  1772
!
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
  1773
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
  1774
selectionToModel
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
  1775
    "write selection to selection holder
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
  1776
    "
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
  1777
    |newSel oldSel|
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
  1778
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
  1779
    oldSel := selectionHolder value.
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
  1780
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
  1781
    multipleSelectOk ifFalse:[
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
  1782
        (newSel := self selectedNode) ~~ oldSel ifTrue:[
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
  1783
            selectionHolder value:newSel
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
  1784
        ]
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
  1785
    ] ifTrue:[
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
  1786
        selection size == 0 ifTrue:[
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
  1787
            oldSel notNil ifTrue:[
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
  1788
                selectionHolder value:nil
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
  1789
            ]
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
  1790
        ] ifFalse:[
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
  1791
            newSel := selection collect:[:i| listOfNodes at:i].
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
  1792
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
  1793
            newSel size ~~ oldSel size ifTrue:[
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
  1794
                selectionHolder value:newSel.
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
  1795
            ] ifFalse:[
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
  1796
                newSel do:[:aNode|
785
ca
parents: 782
diff changeset
  1797
                    (oldSel includesIdentical:aNode) ifFalse:[
514
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
  1798
                        ^ selectionHolder value:newSel
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
  1799
                    ]
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
  1800
                ]
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
  1801
            ]
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
  1802
        ]
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
  1803
    ]
444
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
  1804
! !
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
  1805
490
1129f3cf5cea add directory open/close indication
ca
parents: 485
diff changeset
  1806
!SelectionInTreeView methodsFor:'private'!
1129f3cf5cea add directory open/close indication
ca
parents: 485
diff changeset
  1807
1171
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1808
closeEditor
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1809
    "close the editor
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1810
    "
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1811
    editorWidget notNil ifTrue:[
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1812
        editorWidget destroy.
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1813
        editorIndex  := 0.
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1814
        editorWidget := nil.
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1815
    ].
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1816
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1817
!
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1818
490
1129f3cf5cea add directory open/close indication
ca
parents: 485
diff changeset
  1819
list:aList keepSelection:keepSelection
585
5a0ed2305998 bug fixes:
ca
parents: 569
diff changeset
  1820
    "setup new list; keep selection dependent on the boolean state
5a0ed2305998 bug fixes:
ca
parents: 569
diff changeset
  1821
     keepSelection
5a0ed2305998 bug fixes:
ca
parents: 569
diff changeset
  1822
    "
1268
37066c039eb3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1233
diff changeset
  1823
    |list|
490
1129f3cf5cea add directory open/close indication
ca
parents: 485
diff changeset
  1824
846
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  1825
    list := (aList size == 0) ifTrue:[#()] ifFalse:[aList].
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  1826
    super list:list keepSelection:keepSelection.
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  1827
    self refetchDeviceResources.
490
1129f3cf5cea add directory open/close indication
ca
parents: 485
diff changeset
  1828
1171
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1829
!
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1830
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1831
openEditor
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1832
    "open an editor on selection
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1833
    "
1175
1fa0de353686 add new color used by editValue
ca
parents: 1171
diff changeset
  1834
    |node x0 x1 y0|
1171
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1835
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1836
    editorWidget notNil ifTrue:[
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1837
        ^ self
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1838
    ].
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1839
    editorIndex := self selectedIndex.
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1840
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1841
    (    (node         := listOfNodes at:editorIndex ifAbsent:nil) isNil
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1842
     or:[(y0           := self listLineToVisibleLine:editorIndex) isNil
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1843
     or:[(editorWidget := node editor) isNil]]
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1844
    ) ifTrue:[   
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1845
        ^ self
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1846
    ].
4516
1e8e11a8465c class: SelectionInTreeView
Stefan Vogel <sv@exept.de>
parents: 4380
diff changeset
  1847
    editorWidget withAllSubViewsDo:[:v| v font:gc font ].
1175
1fa0de353686 add new color used by editValue
ca
parents: 1171
diff changeset
  1848
1171
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1849
    y0 := self yOfVisibleLine:y0.
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1850
    x0 := self xOfValueNode:node.
3423
5870494fda6b added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3220
diff changeset
  1851
    x1 := (editorWidget preferredWidth) max:50.
1171
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1852
    x1 := (x0 + x1) min:(self width - 5).
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1853
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1854
    editorWidget geometryLayout:(Rectangle left:x0 right:x1 top:y0 bottom:y0 + fontHeight).
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1855
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1856
    self addComponent:editorWidget.
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  1857
    editorWidget realize.
5427
3178b508e257 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5408
diff changeset
  1858
    gc paint:bgColor.
3178b508e257 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5408
diff changeset
  1859
3178b508e257 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5408
diff changeset
  1860
    gc fillRectangleX:(x0 - SelectionInset) y:y0
3178b508e257 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5408
diff changeset
  1861
       width:SelectionInset + SelectionInset + (x1 - x0)
3178b508e257 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5408
diff changeset
  1862
       height:fontHeight.
811
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1863
! !
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1864
2494
87ae868b836a method category rename
Claus Gittinger <cg@exept.de>
parents: 2488
diff changeset
  1865
!SelectionInTreeView methodsFor:'private-drag and drop'!
569
2a1014d6697c checkin from browser
ca
parents: 552
diff changeset
  1866
811
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1867
collectionOfDragObjects
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1868
    "returns collection of dragable objects assigned to selection
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1869
     Here, by default, a collection of text-dragObjects is generated;
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1870
     however, if a dragObjectConverter is defined, that one gets a chance
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1871
     to convert as appropriate."
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1872
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1873
    |collection converted selection dLbl dObj node|
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1874
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1875
    selection  := self selectionAsCollection.
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1876
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1877
    collection := selection collect:[:nr|
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1878
        node := listOfNodes at:nr.
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1879
        dObj := self dragObjectForNode:node.
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1880
        dObj theObject:(node contents).
846
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  1881
        dLbl := LabelAndIcon icon:(self figureFor:node) string:(node name).
811
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1882
        dObj displayObject:dLbl.
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1883
        dObj
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1884
    ].
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1885
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1886
    dragObjectConverter notNil ifTrue:[
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1887
        converted := OrderedCollection new.
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1888
        collection keysAndValuesDo:[:nr :obj | 
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1889
            (dObj := dragObjectConverter value:obj) notNil ifTrue:[
846
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  1890
                node := listOfNodes at:nr.
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  1891
                dLbl := LabelAndIcon icon:(self figureFor:node) string:(node name).
811
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1892
                converted displayObject:dLbl.
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1893
                converted add:dObj
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1894
            ]
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1895
        ].
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1896
        collection := converted
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1897
    ].
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1898
    ^ collection.
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1899
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1900
569
2a1014d6697c checkin from browser
ca
parents: 552
diff changeset
  1901
2a1014d6697c checkin from browser
ca
parents: 552
diff changeset
  1902
!
2a1014d6697c checkin from browser
ca
parents: 552
diff changeset
  1903
811
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1904
dragObjectForNode:aNode
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1905
    "returns the dragable object for a node; could be redefined in subclass
546
8d274d70c2c3 fetch resources only if list of nodes not nil otherwise
ca
parents: 545
diff changeset
  1906
    "
811
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1907
    ^ DropObject new:aNode.
546
8d274d70c2c3 fetch resources only if list of nodes not nil otherwise
ca
parents: 545
diff changeset
  1908
811
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1909
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1910
!
546
8d274d70c2c3 fetch resources only if list of nodes not nil otherwise
ca
parents: 545
diff changeset
  1911
811
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1912
startDragX:x y:y
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1913
    "start drag
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1914
    "
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1915
    dragIsActive := true.
546
8d274d70c2c3 fetch resources only if list of nodes not nil otherwise
ca
parents: 545
diff changeset
  1916
811
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1917
    DragAndDropManager startDrag:(self collectionOfDragObjects)
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1918
                            from:self
a688e8f11bc6 async. reading of directory indicators
ca
parents: 792
diff changeset
  1919
                           atEnd:endDragAction
546
8d274d70c2c3 fetch resources only if list of nodes not nil otherwise
ca
parents: 545
diff changeset
  1920
8d274d70c2c3 fetch resources only if list of nodes not nil otherwise
ca
parents: 545
diff changeset
  1921
490
1129f3cf5cea add directory open/close indication
ca
parents: 485
diff changeset
  1922
! !
1129f3cf5cea add directory open/close indication
ca
parents: 485
diff changeset
  1923
2494
87ae868b836a method category rename
Claus Gittinger <cg@exept.de>
parents: 2488
diff changeset
  1924
!SelectionInTreeView methodsFor:'private-queries'!
468
9c54016f159d support of vertical scrollbar
ca
parents: 456
diff changeset
  1925
9c54016f159d support of vertical scrollbar
ca
parents: 456
diff changeset
  1926
lengthOfLongestLineBetween:firstLine and:lastLine
9c54016f159d support of vertical scrollbar
ca
parents: 456
diff changeset
  1927
    "return the length (in characters) of the longest line in a line-range
9c54016f159d support of vertical scrollbar
ca
parents: 456
diff changeset
  1928
    "
846
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  1929
    ^ self widthOfContents // fontWidth + 1
468
9c54016f159d support of vertical scrollbar
ca
parents: 456
diff changeset
  1930
!
9c54016f159d support of vertical scrollbar
ca
parents: 456
diff changeset
  1931
848
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  1932
smallestLevelOfNodesBetween:start and:stop
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  1933
    "returns the smallest level of the nodes in a line range
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  1934
    "
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  1935
    |prevNode currParent nextParent
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  1936
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  1937
     lvl "{ Class:SmallInteger }"
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  1938
     min "{ Class:SmallInteger }"
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  1939
     end "{ Class:SmallInteger }"
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  1940
     beg "{ Class:SmallInteger }"
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  1941
    |
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  1942
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  1943
    (end := stop min:(listOfNodes size)) < start ifTrue:[
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  1944
        ^ 0
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  1945
    ].
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  1946
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  1947
    prevNode   := listOfNodes at:start.
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  1948
    currParent := prevNode parent.
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  1949
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  1950
    currParent isNil ifTrue:[
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  1951
        ^ 1
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  1952
    ].
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  1953
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  1954
    (min := prevNode level) == 2 ifTrue:[
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  1955
        ^ min
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  1956
    ].
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  1957
    beg := start + 1.
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  1958
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  1959
    listOfNodes from:beg to:end do:[:currNode|
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  1960
        (nextParent := currNode parent) == currParent ifFalse:[
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  1961
            (currParent := nextParent) == prevNode ifFalse:[
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  1962
                (lvl := currNode level) == 2 ifTrue:[
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  1963
                    ^ 2
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  1964
                ].
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  1965
                min := min min:lvl
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  1966
            ]
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  1967
        ].
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  1968
        prevNode := currNode
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  1969
    ].
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  1970
    ^ min
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  1971
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  1972
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  1973
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  1974
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  1975
!
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  1976
468
9c54016f159d support of vertical scrollbar
ca
parents: 456
diff changeset
  1977
widthOfContents
9c54016f159d support of vertical scrollbar
ca
parents: 456
diff changeset
  1978
    "return the width of the contents in pixels
9c54016f159d support of vertical scrollbar
ca
parents: 456
diff changeset
  1979
     - used for scrollbar interface"
9c54016f159d support of vertical scrollbar
ca
parents: 456
diff changeset
  1980
846
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  1981
    listOfNodes isNil ifTrue:[^ 0].
468
9c54016f159d support of vertical scrollbar
ca
parents: 456
diff changeset
  1982
9c54016f159d support of vertical scrollbar
ca
parents: 456
diff changeset
  1983
    (widthOfWidestLine isNil or:[widthOfWidestLine == 0]) ifTrue:[
846
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  1984
        widthOfWidestLine := self widthOfLongestLine
468
9c54016f159d support of vertical scrollbar
ca
parents: 456
diff changeset
  1985
    ].
9c54016f159d support of vertical scrollbar
ca
parents: 456
diff changeset
  1986
  ^ widthOfWidestLine + (leftMargin * 2)
9c54016f159d support of vertical scrollbar
ca
parents: 456
diff changeset
  1987
9c54016f159d support of vertical scrollbar
ca
parents: 456
diff changeset
  1988
!
9c54016f159d support of vertical scrollbar
ca
parents: 456
diff changeset
  1989
846
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  1990
widthOfLongestLine
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  1991
    "return the width of the longest line in pixels
468
9c54016f159d support of vertical scrollbar
ca
parents: 456
diff changeset
  1992
    "
848
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  1993
    |parent pItem p
846
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  1994
     startX   "{ Class: SmallInteger }"
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  1995
     deltaX   "{ Class: SmallInteger }"
838
d15daece0c54 optimize algorithm to get list from model and to
ca
parents: 835
diff changeset
  1996
     level    "{ Class: SmallInteger }"
d15daece0c54 optimize algorithm to get list from model and to
ca
parents: 835
diff changeset
  1997
     width    "{ Class: SmallInteger }"
d15daece0c54 optimize algorithm to get list from model and to
ca
parents: 835
diff changeset
  1998
     maxSz    "{ Class: SmallInteger }"|
468
9c54016f159d support of vertical scrollbar
ca
parents: 456
diff changeset
  1999
848
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  2000
    buildInArray atAllPut:0.
846
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  2001
    parent := nil.
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  2002
    maxSz  := 1.
838
d15daece0c54 optimize algorithm to get list from model and to
ca
parents: 835
diff changeset
  2003
    level  := 1.
846
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  2004
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  2005
    listOfNodes do:[:anItem|
848
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  2006
        (p := anItem parent) ~~ parent ifTrue:[
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  2007
            buildInArray at:level put:maxSz.
846
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  2008
848
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  2009
            (parent := p) == pItem ifTrue:[level := level + 1]
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  2010
                                  ifFalse:[level := anItem level].
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  2011
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  2012
            maxSz := buildInArray at:level.
846
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  2013
        ].
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  2014
        pItem := anItem.
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  2015
        maxSz := maxSz max:(anItem name size).
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  2016
    ].
848
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  2017
    buildInArray at:level put:maxSz.
468
9c54016f159d support of vertical scrollbar
ca
parents: 456
diff changeset
  2018
846
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  2019
    startX := self xOfStringLevel:1.
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  2020
    deltaX := imageInset + imageWidth.
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  2021
    width  := '1' widthOn:self.
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  2022
    maxSz  := 0.
468
9c54016f159d support of vertical scrollbar
ca
parents: 456
diff changeset
  2023
848
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  2024
    buildInArray do:[:el|
2015
5a83ee792cc3 eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents: 2014
diff changeset
  2025
        el == 0 ifTrue:[ ^ maxSz + viewOrigin x ].
846
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  2026
        maxSz  := maxSz max:(el * width + startX).
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  2027
        startX := startX + deltaX.
468
9c54016f159d support of vertical scrollbar
ca
parents: 456
diff changeset
  2028
    ].
846
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  2029
! !
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  2030
2494
87ae868b836a method category rename
Claus Gittinger <cg@exept.de>
parents: 2488
diff changeset
  2031
!SelectionInTreeView methodsFor:'private-redefinitions'!
846
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  2032
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  2033
expandTabs
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  2034
    "nothing to do
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  2035
    "
838
d15daece0c54 optimize algorithm to get list from model and to
ca
parents: 835
diff changeset
  2036
d15daece0c54 optimize algorithm to get list from model and to
ca
parents: 835
diff changeset
  2037
468
9c54016f159d support of vertical scrollbar
ca
parents: 456
diff changeset
  2038
!
9c54016f159d support of vertical scrollbar
ca
parents: 456
diff changeset
  2039
846
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  2040
list:aCollection expandTabs:expand scanForNonStrings:scan
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  2041
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  2042
    includesNonStrings := false.
4380
0c043b8a8b4b class: SelectionInTreeView
Claus Gittinger <cg@exept.de>
parents: 4272
diff changeset
  2043
    self list:aCollection expandTabs:false scanForNonStrings:false includesNonStrings:nil
846
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  2044
!
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  2045
468
9c54016f159d support of vertical scrollbar
ca
parents: 456
diff changeset
  2046
withoutRedrawAt:anIndex put:aString
1813
c25b1a3476b2 comment only
Claus Gittinger <cg@exept.de>
parents: 1624
diff changeset
  2047
    "change a line without redisplay and WITHOUT any sizeChange notifications.
c25b1a3476b2 comment only
Claus Gittinger <cg@exept.de>
parents: 1624
diff changeset
  2048
     Somewhat dangerous, since scrollBars will not be informed about contents-changes.
c25b1a3476b2 comment only
Claus Gittinger <cg@exept.de>
parents: 1624
diff changeset
  2049
     Use only if multiple lines are to be changed, and a sizeChanged is invoked by some other
c25b1a3476b2 comment only
Claus Gittinger <cg@exept.de>
parents: 1624
diff changeset
  2050
     means at the end."
468
9c54016f159d support of vertical scrollbar
ca
parents: 456
diff changeset
  2051
9c54016f159d support of vertical scrollbar
ca
parents: 456
diff changeset
  2052
    |width|
9c54016f159d support of vertical scrollbar
ca
parents: 456
diff changeset
  2053
9c54016f159d support of vertical scrollbar
ca
parents: 456
diff changeset
  2054
    width := widthOfWidestLine.
9c54016f159d support of vertical scrollbar
ca
parents: 456
diff changeset
  2055
    widthOfWidestLine := nil.
9c54016f159d support of vertical scrollbar
ca
parents: 456
diff changeset
  2056
    super withoutRedrawAt:anIndex put:aString.
846
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  2057
    widthOfWidestLine := width.
468
9c54016f159d support of vertical scrollbar
ca
parents: 456
diff changeset
  2058
846
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  2059
    (widthOfWidestLine notNil and:[aString size ~~ 0]) ifTrue:[
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  2060
        width := self xOfStringNode:(listOfNodes at:anIndex)
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  2061
               + (aString widthOn:self)
2015
5a83ee792cc3 eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents: 2014
diff changeset
  2062
               + viewOrigin x.
846
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  2063
838
d15daece0c54 optimize algorithm to get list from model and to
ca
parents: 835
diff changeset
  2064
        widthOfWidestLine := widthOfWidestLine max:width.
468
9c54016f159d support of vertical scrollbar
ca
parents: 456
diff changeset
  2065
    ].
9c54016f159d support of vertical scrollbar
ca
parents: 456
diff changeset
  2066
! !
9c54016f159d support of vertical scrollbar
ca
parents: 456
diff changeset
  2067
483
1dad61b63e9d optimize doubleClicked & redrawing
ca
parents: 481
diff changeset
  2068
!SelectionInTreeView methodsFor:'queries'!
1dad61b63e9d optimize doubleClicked & redrawing
ca
parents: 481
diff changeset
  2069
1dad61b63e9d optimize doubleClicked & redrawing
ca
parents: 481
diff changeset
  2070
figureFor:aNode
1278
7083a9583174 comments
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
  2071
    "return a (bitmap) figure for a node"
7083a9583174 comments
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
  2072
785
ca
parents: 782
diff changeset
  2073
    |icon img|
ca
parents: 782
diff changeset
  2074
1278
7083a9583174 comments
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
  2075
    "/ the item may provide an icon
7083a9583174 comments
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
  2076
    "/ (it knows for itself if its open or closed)
7083a9583174 comments
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
  2077
785
ca
parents: 782
diff changeset
  2078
    (icon := aNode icon) notNil ifTrue:[
ca
parents: 782
diff changeset
  2079
        img := registeredImages at:icon ifAbsent:nil.
ca
parents: 782
diff changeset
  2080
        img notNil ifTrue:[
ca
parents: 782
diff changeset
  2081
            ^ img
763
dd29c58e8ea6 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 760
diff changeset
  2082
        ].
785
ca
parents: 782
diff changeset
  2083
        icon isImage ifTrue:[
2488
74c81c1e30d7 imageOnDevice -> imageOnMyDevice
Claus Gittinger <cg@exept.de>
parents: 2483
diff changeset
  2084
            img := self imageOnMyDevice:icon.
785
ca
parents: 782
diff changeset
  2085
            registeredImages at:icon put:img.
1278
7083a9583174 comments
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
  2086
            ^ img
785
ca
parents: 782
diff changeset
  2087
        ]
763
dd29c58e8ea6 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 760
diff changeset
  2088
    ].
dd29c58e8ea6 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 760
diff changeset
  2089
1278
7083a9583174 comments
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
  2090
    "/ ok, node did not return an icon - use default.
7083a9583174 comments
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
  2091
846
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  2092
    aNode hasChildren ifFalse:[
1278
7083a9583174 comments
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
  2093
        "/ regular
7083a9583174 comments
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
  2094
        ^ imageItem 
846
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  2095
    ].
1278
7083a9583174 comments
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
  2096
    "/ folder
846
368acc8d9258 optimize widthOfContents and drawing
ca
parents: 838
diff changeset
  2097
    ^ aNode hidden ifTrue:[imageClosed] ifFalse:[imageOpened]
483
1dad61b63e9d optimize doubleClicked & redrawing
ca
parents: 481
diff changeset
  2098
!
1dad61b63e9d optimize doubleClicked & redrawing
ca
parents: 481
diff changeset
  2099
1dad61b63e9d optimize doubleClicked & redrawing
ca
parents: 481
diff changeset
  2100
indexOfNode:aNode
1dad61b63e9d optimize doubleClicked & redrawing
ca
parents: 481
diff changeset
  2101
    "returns index of a node
1dad61b63e9d optimize doubleClicked & redrawing
ca
parents: 481
diff changeset
  2102
    "
785
ca
parents: 782
diff changeset
  2103
    ^ listOfNodes identityIndexOf:aNode
483
1dad61b63e9d optimize doubleClicked & redrawing
ca
parents: 481
diff changeset
  2104
!
1dad61b63e9d optimize doubleClicked & redrawing
ca
parents: 481
diff changeset
  2105
494
76d8c4e0b612 directory indicator; set a path to be selected
ca
parents: 490
diff changeset
  2106
xOfFigureLevel:aLevel
76d8c4e0b612 directory indicator; set a path to be selected
ca
parents: 490
diff changeset
  2107
    "origin x where to draw the icon
76d8c4e0b612 directory indicator; set a path to be selected
ca
parents: 490
diff changeset
  2108
    "
785
ca
parents: 782
diff changeset
  2109
    |l "{ Class:SmallInteger }"|
494
76d8c4e0b612 directory indicator; set a path to be selected
ca
parents: 490
diff changeset
  2110
785
ca
parents: 782
diff changeset
  2111
    l := showRoot ifTrue:[aLevel] ifFalse:[aLevel - 1].
494
76d8c4e0b612 directory indicator; set a path to be selected
ca
parents: 490
diff changeset
  2112
659
16bb1d26f658 add showDirectoryIndicatorForRoot
ca
parents: 639
diff changeset
  2113
    showDirectoryIndicator ifFalse:[
16bb1d26f658 add showDirectoryIndicatorForRoot
ca
parents: 639
diff changeset
  2114
        l := l - 1
16bb1d26f658 add showDirectoryIndicatorForRoot
ca
parents: 639
diff changeset
  2115
    ] ifTrue:[
16bb1d26f658 add showDirectoryIndicatorForRoot
ca
parents: 639
diff changeset
  2116
        showDirectoryIndicatorForRoot ifFalse:[
16bb1d26f658 add showDirectoryIndicatorForRoot
ca
parents: 639
diff changeset
  2117
            l := l - 1
16bb1d26f658 add showDirectoryIndicatorForRoot
ca
parents: 639
diff changeset
  2118
        ]
16bb1d26f658 add showDirectoryIndicatorForRoot
ca
parents: 639
diff changeset
  2119
    ].
2015
5a83ee792cc3 eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents: 2014
diff changeset
  2120
  ^ (l * (imageInset + imageWidth)) + imageInset - viewOrigin x + leftMargin
494
76d8c4e0b612 directory indicator; set a path to be selected
ca
parents: 490
diff changeset
  2121
!
76d8c4e0b612 directory indicator; set a path to be selected
ca
parents: 490
diff changeset
  2122
483
1dad61b63e9d optimize doubleClicked & redrawing
ca
parents: 481
diff changeset
  2123
xOfFigureNode:aNode
1dad61b63e9d optimize doubleClicked & redrawing
ca
parents: 481
diff changeset
  2124
    "origin x where to draw the icon
1dad61b63e9d optimize doubleClicked & redrawing
ca
parents: 481
diff changeset
  2125
    "
494
76d8c4e0b612 directory indicator; set a path to be selected
ca
parents: 490
diff changeset
  2126
    ^ self xOfFigureLevel:(aNode level)
76d8c4e0b612 directory indicator; set a path to be selected
ca
parents: 490
diff changeset
  2127
!
490
1129f3cf5cea add directory open/close indication
ca
parents: 485
diff changeset
  2128
494
76d8c4e0b612 directory indicator; set a path to be selected
ca
parents: 490
diff changeset
  2129
xOfStringLevel:aLevel
76d8c4e0b612 directory indicator; set a path to be selected
ca
parents: 490
diff changeset
  2130
    "origin x where to draw the text( label )
76d8c4e0b612 directory indicator; set a path to be selected
ca
parents: 490
diff changeset
  2131
    "
76d8c4e0b612 directory indicator; set a path to be selected
ca
parents: 490
diff changeset
  2132
    ^ (self xOfFigureLevel:aLevel) + imageWidth + textInset
483
1dad61b63e9d optimize doubleClicked & redrawing
ca
parents: 481
diff changeset
  2133
1dad61b63e9d optimize doubleClicked & redrawing
ca
parents: 481
diff changeset
  2134
!
1dad61b63e9d optimize doubleClicked & redrawing
ca
parents: 481
diff changeset
  2135
1dad61b63e9d optimize doubleClicked & redrawing
ca
parents: 481
diff changeset
  2136
xOfStringNode:aNode
1dad61b63e9d optimize doubleClicked & redrawing
ca
parents: 481
diff changeset
  2137
    "origin x where to draw the text( label )
1dad61b63e9d optimize doubleClicked & redrawing
ca
parents: 481
diff changeset
  2138
    "
494
76d8c4e0b612 directory indicator; set a path to be selected
ca
parents: 490
diff changeset
  2139
    ^ self xOfStringLevel:(aNode level)
483
1dad61b63e9d optimize doubleClicked & redrawing
ca
parents: 481
diff changeset
  2140
1171
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  2141
!
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  2142
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  2143
xOfValueNode:aNode
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  2144
    "returns the left x position of the start of the value
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  2145
    "
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  2146
    |p x|
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  2147
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  2148
    p := aNode parent.
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  2149
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  2150
    x := p notNil ifTrue:[30 + (p childrenWidthOn:self)]
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  2151
                 ifFalse:[0].
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  2152
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  2153
    ^ x + (self xOfStringNode:aNode)
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  2154
483
1dad61b63e9d optimize doubleClicked & redrawing
ca
parents: 481
diff changeset
  2155
! !
1dad61b63e9d optimize doubleClicked & redrawing
ca
parents: 481
diff changeset
  2156
1061
8eba9d898259 scroll to bring selection into upper half of view
Claus Gittinger <cg@exept.de>
parents: 908
diff changeset
  2157
!SelectionInTreeView methodsFor:'scrolling'!
8eba9d898259 scroll to bring selection into upper half of view
Claus Gittinger <cg@exept.de>
parents: 908
diff changeset
  2158
8eba9d898259 scroll to bring selection into upper half of view
Claus Gittinger <cg@exept.de>
parents: 908
diff changeset
  2159
needScrollToMakeLine:aListLineNr
8eba9d898259 scroll to bring selection into upper half of view
Claus Gittinger <cg@exept.de>
parents: 908
diff changeset
  2160
    "redefined to scroll whenever line is not in top half"
8eba9d898259 scroll to bring selection into upper half of view
Claus Gittinger <cg@exept.de>
parents: 908
diff changeset
  2161
8eba9d898259 scroll to bring selection into upper half of view
Claus Gittinger <cg@exept.de>
parents: 908
diff changeset
  2162
    (aListLineNr >= firstLineShown) ifTrue:[
1162
b1aee7c3fd98 no need of scrolling for one item if selecting an item
tz
parents: 1105
diff changeset
  2163
        (aListLineNr < (firstLineShown + nFullLinesShown)) ifTrue:[
1061
8eba9d898259 scroll to bring selection into upper half of view
Claus Gittinger <cg@exept.de>
parents: 908
diff changeset
  2164
            ^ false
8eba9d898259 scroll to bring selection into upper half of view
Claus Gittinger <cg@exept.de>
parents: 908
diff changeset
  2165
        ]
8eba9d898259 scroll to bring selection into upper half of view
Claus Gittinger <cg@exept.de>
parents: 908
diff changeset
  2166
    ].
8eba9d898259 scroll to bring selection into upper half of view
Claus Gittinger <cg@exept.de>
parents: 908
diff changeset
  2167
    ^ true
8eba9d898259 scroll to bring selection into upper half of view
Claus Gittinger <cg@exept.de>
parents: 908
diff changeset
  2168
1171
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  2169
!
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  2170
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  2171
originChanged:delta
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  2172
    "sent after scrolling - have to update origin of editor
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  2173
    "
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  2174
    super originChanged:delta.
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  2175
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  2176
    editorWidget notNil ifTrue:[
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  2177
        editorWidget origin:(editorWidget origin - delta)
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  2178
    ]
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  2179
1061
8eba9d898259 scroll to bring selection into upper half of view
Claus Gittinger <cg@exept.de>
parents: 908
diff changeset
  2180
! !
8eba9d898259 scroll to bring selection into upper half of view
Claus Gittinger <cg@exept.de>
parents: 908
diff changeset
  2181
444
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
  2182
!SelectionInTreeView methodsFor:'selection'!
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
  2183
468
9c54016f159d support of vertical scrollbar
ca
parents: 456
diff changeset
  2184
selectNode:aNode
9c54016f159d support of vertical scrollbar
ca
parents: 456
diff changeset
  2185
    "change selection to a node
9c54016f159d support of vertical scrollbar
ca
parents: 456
diff changeset
  2186
    "
2688
2d853020325f bugfix: catch recursion if selection changed through to the model
ca
parents: 2659
diff changeset
  2187
    ^ self selectNode:aNode withNotify:true.
2d853020325f bugfix: catch recursion if selection changed through to the model
ca
parents: 2659
diff changeset
  2188
!
2d853020325f bugfix: catch recursion if selection changed through to the model
ca
parents: 2659
diff changeset
  2189
2d853020325f bugfix: catch recursion if selection changed through to the model
ca
parents: 2659
diff changeset
  2190
selectNode:aNode withNotify:withNotify
2d853020325f bugfix: catch recursion if selection changed through to the model
ca
parents: 2659
diff changeset
  2191
    "change selection to a node
2d853020325f bugfix: catch recursion if selection changed through to the model
ca
parents: 2659
diff changeset
  2192
    "
855
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
  2193
    |index|
848
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  2194
860
64d52b8e3dbd bug fix in remove:
ca
parents: 855
diff changeset
  2195
    (index := aNode) notNil ifTrue:[
64d52b8e3dbd bug fix in remove:
ca
parents: 855
diff changeset
  2196
        index isNumber ifFalse:[
64d52b8e3dbd bug fix in remove:
ca
parents: 855
diff changeset
  2197
            (index := self indexOfNode:aNode) == 0 ifTrue:[
64d52b8e3dbd bug fix in remove:
ca
parents: 855
diff changeset
  2198
                model doMakeVisible:aNode.
64d52b8e3dbd bug fix in remove:
ca
parents: 855
diff changeset
  2199
                index := self indexOfNode:aNode.
64d52b8e3dbd bug fix in remove:
ca
parents: 855
diff changeset
  2200
            ]
855
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
  2201
        ].
848
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  2202
        index == 0 ifTrue:[
855
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
  2203
            index := nil
848
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  2204
        ]
29f1947578b8 expand selected nodes automatically
ca
parents: 847
diff changeset
  2205
    ].
2688
2d853020325f bugfix: catch recursion if selection changed through to the model
ca
parents: 2659
diff changeset
  2206
    withNotify ifFalse:[
2d853020325f bugfix: catch recursion if selection changed through to the model
ca
parents: 2659
diff changeset
  2207
        self setSelection:index
2d853020325f bugfix: catch recursion if selection changed through to the model
ca
parents: 2659
diff changeset
  2208
    ] ifTrue:[
2d853020325f bugfix: catch recursion if selection changed through to the model
ca
parents: 2659
diff changeset
  2209
        self selection:index 
2d853020325f bugfix: catch recursion if selection changed through to the model
ca
parents: 2659
diff changeset
  2210
    ].
468
9c54016f159d support of vertical scrollbar
ca
parents: 456
diff changeset
  2211
!
9c54016f159d support of vertical scrollbar
ca
parents: 456
diff changeset
  2212
1972
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2213
selectNodes:aCollectionOfNodes
2689
c382886ddb08 bugfix: catch recursion if selection changed through to the model
ca
parents: 2688
diff changeset
  2214
    ^ self selectNodes:aCollectionOfNodes withNotify:true.
2688
2d853020325f bugfix: catch recursion if selection changed through to the model
ca
parents: 2659
diff changeset
  2215
!
2d853020325f bugfix: catch recursion if selection changed through to the model
ca
parents: 2659
diff changeset
  2216
2d853020325f bugfix: catch recursion if selection changed through to the model
ca
parents: 2659
diff changeset
  2217
selectNodes:aCollectionOfNodes withNotify:withNotify
1972
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2218
    |selIndexCollection|
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2219
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2220
    selIndexCollection := aCollectionOfNodes collect:[:eachNode | listOfNodes identityIndexOf:eachNode].
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2221
    selIndexCollection := selIndexCollection reject:[:eachIndex | eachIndex == 0].
2688
2d853020325f bugfix: catch recursion if selection changed through to the model
ca
parents: 2659
diff changeset
  2222
2d853020325f bugfix: catch recursion if selection changed through to the model
ca
parents: 2659
diff changeset
  2223
    withNotify ifTrue:[
2d853020325f bugfix: catch recursion if selection changed through to the model
ca
parents: 2659
diff changeset
  2224
        self selection:selIndexCollection.
2d853020325f bugfix: catch recursion if selection changed through to the model
ca
parents: 2659
diff changeset
  2225
    ] ifFalse:[
2d853020325f bugfix: catch recursion if selection changed through to the model
ca
parents: 2659
diff changeset
  2226
        self setSelection:selIndexCollection.
2d853020325f bugfix: catch recursion if selection changed through to the model
ca
parents: 2659
diff changeset
  2227
    ].
1972
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2228
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2229
"/    first := true.
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2230
"/    aCollectionOfNodes do:[:eachNode |
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2231
"/        first ifTrue:[
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2232
"/            self selectNode:eachNode.
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2233
"/            first := false.
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2234
"/        ] ifFalse:[
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2235
"/            self selectedNodeAdd:eachNode
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2236
"/        ]
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2237
"/    ].
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2238
"/
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2239
!
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2240
456
d46a10de4380 change model; supports multiple selection
ca
parents: 448
diff changeset
  2241
selectedIndex
d46a10de4380 change model; supports multiple selection
ca
parents: 448
diff changeset
  2242
    "get single selected index or 0
d46a10de4380 change model; supports multiple selection
ca
parents: 448
diff changeset
  2243
    "
483
1dad61b63e9d optimize doubleClicked & redrawing
ca
parents: 481
diff changeset
  2244
    selection size == 1 ifTrue:[^ selection first].
1dad61b63e9d optimize doubleClicked & redrawing
ca
parents: 481
diff changeset
  2245
    selection isNumber  ifTrue:[^ selection].
456
d46a10de4380 change model; supports multiple selection
ca
parents: 448
diff changeset
  2246
  ^ 0
444
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
  2247
!
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
  2248
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
  2249
selectedNode
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
  2250
    "get the single selected node or nil
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
  2251
    "
456
d46a10de4380 change model; supports multiple selection
ca
parents: 448
diff changeset
  2252
    |idx|
d46a10de4380 change model; supports multiple selection
ca
parents: 448
diff changeset
  2253
d46a10de4380 change model; supports multiple selection
ca
parents: 448
diff changeset
  2254
    (idx := self selectedIndex) ~~ 0 ifTrue:[
3985
4638e9fbb842 changed: #selectedNode
Claus Gittinger <cg@exept.de>
parents: 3744
diff changeset
  2255
        ^ listOfNodes at:idx ifAbsent:nil
444
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
  2256
    ].
3985
4638e9fbb842 changed: #selectedNode
Claus Gittinger <cg@exept.de>
parents: 3744
diff changeset
  2257
    ^ nil
4638e9fbb842 changed: #selectedNode
Claus Gittinger <cg@exept.de>
parents: 3744
diff changeset
  2258
4638e9fbb842 changed: #selectedNode
Claus Gittinger <cg@exept.de>
parents: 3744
diff changeset
  2259
    "Modified: / 19-01-2011 / 18:41:02 / cg"
514
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
  2260
!
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
  2261
1972
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2262
selectedNodes
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2263
    "get a collection of selected nodes
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2264
    "
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2265
    |selIndexCollection|
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2266
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2267
    (selIndexCollection := self selection) size == 0 ifTrue:[^ #() ].
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2268
    ^ selIndexCollection collect:[:eachIndex | listOfNodes at:eachIndex].
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2269
!
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2270
514
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
  2271
selectionChangedFrom:oldSelection
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
  2272
    "update selectionHolder if not nil
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
  2273
    "
1171
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  2274
    self closeEditor.
514
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
  2275
623
4de870640523 first change selectionHolders value,
Claus Gittinger <cg@exept.de>
parents: 589
diff changeset
  2276
    "/ first change my selectionHolders value ...
514
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
  2277
    selectionHolder notNil ifTrue:[
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
  2278
        self selectionToModel.
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
  2279
    ].
c25e078ed84c add selectionHolder and hierarchical list holder
ca
parents: 507
diff changeset
  2280
623
4de870640523 first change selectionHolders value,
Claus Gittinger <cg@exept.de>
parents: 589
diff changeset
  2281
    "/ ... then make notifications.
4de870640523 first change selectionHolders value,
Claus Gittinger <cg@exept.de>
parents: 589
diff changeset
  2282
    super selectionChangedFrom:oldSelection.
4de870640523 first change selectionHolders value,
Claus Gittinger <cg@exept.de>
parents: 589
diff changeset
  2283
4de870640523 first change selectionHolders value,
Claus Gittinger <cg@exept.de>
parents: 589
diff changeset
  2284
1171
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  2285
!
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  2286
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  2287
setSelection:aSelection
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  2288
    "if no selection exists, close the editor
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  2289
    "
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  2290
    (aSelection isNil or:[aSelection == 0]) ifTrue:[
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  2291
        self closeEditor
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  2292
    ].
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  2293
    super setSelection:aSelection
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  2294
0199f65bc8ce add editable value
ca
parents: 1162
diff changeset
  2295
444
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
  2296
! !
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
  2297
855
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
  2298
!SelectionInTreeView methodsFor:'selection actions'!
507
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2299
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2300
selectedNodeAdd:something
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2301
    "add a node or collection of nodes after selected node
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2302
    "
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2303
    |node|
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2304
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2305
    something notNil ifTrue:[
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2306
        (node := self selectedNode) notNil ifTrue:[
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2307
            node parent notNil ifTrue:[
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2308
                node isCollapsable ifTrue:[
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2309
                    model add:something beforeIndex:1 below:node
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2310
                ] ifFalse:[
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2311
                    model add:something after:node
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2312
                ]
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2313
            ] ifFalse:[
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2314
                model add:something beforeIndex:1 below:(self root)
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2315
            ]
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2316
        ]
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2317
    ]
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2318
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2319
!
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2320
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2321
selectedNodeBecomeChildOfNext
1972
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2322
    "make the selected node a child of the next node
507
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2323
    "
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2324
    |idx node cprt nprt|
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2325
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2326
    ((node := self selectedNode) isNil or:[(cprt := node parent) isNil]) ifFalse:[
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2327
        idx := cprt indexOfChild:node.
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2328
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2329
        idx == cprt children size ifFalse:[
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2330
            nprt := cprt childAt:(idx + 1).
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2331
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2332
            nprt notNil ifTrue:[
855
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
  2333
                self  setSelection:nil.
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
  2334
                model remove:node.
507
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2335
                model add:node beforeIndex:1 below:nprt.
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2336
                self selectNode:node.
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2337
            ]
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2338
        ]
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2339
    ]
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2340
!
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2341
1972
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2342
selectedNodeBecomeChildOfPrevious
4253
85c181bb2c96 class: SelectionInTreeView
Stefan Vogel <sv@exept.de>
parents: 4246
diff changeset
  2343
    "make the selected node a child of the previous node"
85c181bb2c96 class: SelectionInTreeView
Stefan Vogel <sv@exept.de>
parents: 4246
diff changeset
  2344
1972
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2345
    |idx node cprt nprt|
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2346
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2347
    ((node := self selectedNode) isNil or:[(cprt := node parent) isNil]) ifFalse:[
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2348
        idx := cprt indexOfChild:node.
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2349
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2350
        idx == cprt children size ifFalse:[
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2351
            nprt := cprt childAt:(idx - 1).
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2352
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2353
            nprt notNil ifTrue:[
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2354
                self  setSelection:nil.
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2355
                model remove:node.
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2356
                model add:node below:nprt.
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2357
                self selectNode:node.
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2358
            ]
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2359
        ]
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2360
    ]
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2361
!
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2362
507
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2363
selectedNodeBecomeSisterOfParent
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2364
    "become node a sister of its current parent
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2365
    "
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2366
    |node cprt nprt|
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2367
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2368
    (    (node := self selectedNode) isNil
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2369
     or:[(cprt := node parent) isNil
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2370
     or:[(nprt := cprt parent) isNil]]
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2371
    ) ifFalse:[
855
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
  2372
        self  setSelection:nil.
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
  2373
        model remove:node.
507
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2374
        model add:node afterIndex:(nprt indexOfChild:cprt) below:nprt.
855
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
  2375
        self  selectNode:node.
507
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2376
    ]
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2377
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2378
!
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2379
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2380
selectedNodeChangeSequenceOrder:anOffset
3690
867272f708bc comment
Claus Gittinger <cg@exept.de>
parents: 3456
diff changeset
  2381
    "move child 'anOffset' forward or backward in list of children"
867272f708bc comment
Claus Gittinger <cg@exept.de>
parents: 3456
diff changeset
  2382
507
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2383
    |idx node size parent|
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2384
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2385
    (      (node   := self selectedNode) notNil
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2386
      and:[(parent := node parent) notNil
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2387
      and:[(size   := parent children size) > 1]]
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2388
    ) ifTrue:[
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2389
        idx := parent indexOfChild:node.
855
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
  2390
        self setSelection:nil.
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
  2391
        model remove:node.
507
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2392
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2393
        (idx := idx + anOffset) < 1 ifTrue:[
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2394
            idx := size
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2395
        ] ifFalse:[
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2396
            idx > size ifTrue:[idx := 1]
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2397
        ].
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2398
        model add:node beforeIndex:idx below:parent.
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2399
        self selectNode:node.
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2400
    ]
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2401
!
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2402
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2403
selectedNodeExpand:doExpand
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2404
    "collapse or expand selected node
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2405
    "
855
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
  2406
    |node|
507
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2407
855
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
  2408
    (node := self selectedNode) notNil ifTrue:[
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
  2409
        doExpand ifTrue:[model doExpand:node]
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
  2410
                ifFalse:[model doCollapse:node]
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
  2411
    ]
507
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2412
!
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2413
1972
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2414
selectedNodesBecomeChildrenOfNext
4253
85c181bb2c96 class: SelectionInTreeView
Stefan Vogel <sv@exept.de>
parents: 4246
diff changeset
  2415
    "make the selected nodes children of the next node"
85c181bb2c96 class: SelectionInTreeView
Stefan Vogel <sv@exept.de>
parents: 4246
diff changeset
  2416
85c181bb2c96 class: SelectionInTreeView
Stefan Vogel <sv@exept.de>
parents: 4246
diff changeset
  2417
    |indices maxIndex nodes newParent|
1972
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2418
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2419
    nodes := self selectedNodes.
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2420
    nodes size == 0 ifTrue:[^ self].
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2421
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2422
    indices := nodes collect:[:eachNode | listOfNodes identityIndexOf:eachNode].
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2423
    maxIndex := indices max.
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2424
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2425
    newParent := listOfNodes at:(maxIndex + 1) ifAbsent:nil.
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2426
    newParent isNil ifTrue:[^ self].
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2427
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2428
    indices sortWith:nodes.
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2429
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2430
    nodes reverseDo:[:eachNodeToMove |
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2431
        model remove:eachNodeToMove.
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2432
        model add:eachNodeToMove beforeIndex:1 below:newParent.
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2433
    ].
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2434
    self selectNodes:nodes.
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2435
!
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2436
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2437
selectedNodesBecomeSistersOfParent
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2438
    "move selected nodes up (out of their parent to their grandparent).
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2439
     I.e. nodes become sisters of their current parent
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2440
    "
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2441
    |nodes parent grandParent indices|
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2442
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2443
    nodes := self selectedNodes.
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2444
    nodes size == 0 ifTrue:[^ self].
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2445
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2446
    "/ common parent ?
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2447
    parent := nodes first parent.
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2448
    (nodes conform:[:eachNode | eachNode parent == parent]) ifFalse:[^ self].
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2449
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2450
    "/ is there a grandparent ?
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2451
    grandParent := parent parent.
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2452
    grandParent isNil ifTrue:[^ self].
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2453
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2454
    self  setSelection:nil.
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2455
    indices := nodes collect:[:eachNode | listOfNodes identityIndexOf:eachNode].
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2456
    indices sortWith:nodes.
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2457
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2458
    nodes reverseDo:[:eachNodeToMove |
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2459
        model remove:eachNodeToMove.
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2460
        model add:eachNodeToMove afterIndex:(grandParent indexOfChild:parent) below:grandParent.
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2461
    ].
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2462
    self selectNodes:nodes.
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2463
!
d88252f4c668 group-move (for menuEditor)
Claus Gittinger <cg@exept.de>
parents: 1887
diff changeset
  2464
507
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2465
selectedNodesRemove
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2466
    "remove selected nodes
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2467
    "
855
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
  2468
    |selection|
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
  2469
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
  2470
    selection := self selection.
507
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2471
    self selection:nil.
855
1714ba38f374 add/remove item operation are moved to the model
ca
parents: 850
diff changeset
  2472
    model remove:selection.
507
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2473
! !
546f43d75275 add more functionality based on selection
ca
parents: 497
diff changeset
  2474
444
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
  2475
!SelectionInTreeView class methodsFor:'documentation'!
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
  2476
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
  2477
version
5004
fc2a53728ebf device access
Claus Gittinger <cg@exept.de>
parents: 4608
diff changeset
  2478
    ^ '$Header$'
3985
4638e9fbb842 changed: #selectedNode
Claus Gittinger <cg@exept.de>
parents: 3744
diff changeset
  2479
!
4638e9fbb842 changed: #selectedNode
Claus Gittinger <cg@exept.de>
parents: 3744
diff changeset
  2480
4638e9fbb842 changed: #selectedNode
Claus Gittinger <cg@exept.de>
parents: 3744
diff changeset
  2481
version_CVS
5004
fc2a53728ebf device access
Claus Gittinger <cg@exept.de>
parents: 4608
diff changeset
  2482
    ^ '$Header$'
444
6d40e2c4ed53 intitial checkin
ca
parents:
diff changeset
  2483
! !
4246
b2aeabea341b class: SelectionInTreeView
Claus Gittinger <cg@exept.de>
parents: 3985
diff changeset
  2484