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