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