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