SelectionInListModelView.st
author ca
Thu, 17 Oct 2002 18:04:42 +0200
changeset 2308 c012b16422f0
parent 2302 5a2a1d5d09f8
child 2309 a2d331797c7a
permissions -rw-r--r--
replace ifNotNil: by notNil ifTrue:
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1431
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
     1
"
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
     2
 COPYRIGHT (c) 1999 by eXept Software AG
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
     3
              All Rights Reserved
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
     4
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
     5
 This software is furnished under a license and may be used
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
     6
 only in accordance with the terms of that license and with the
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
     8
 be provided or otherwise made available to, or used by, any
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
     9
 other person.  No title to or ownership of the software is
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    10
 hereby transferred.
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    11
"
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    12
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    13
1752
1c11b6e4ab37 use isHierarchicalItem instead of hack variable
ca
parents: 1748
diff changeset
    14
"{ Package: 'stx:libwidg2' }"
1c11b6e4ab37 use isHierarchicalItem instead of hack variable
ca
parents: 1748
diff changeset
    15
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
ListModelView subclass:#SelectionInListModelView
2228
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
    17
	instanceVariableNames:'selection multipleSelectOk selectOnButtomMenu actionBlock
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
    18
		doubleClickActionBlock selectConditionBlock clickLine
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
    19
		highlightMode useIndex ignoreReselect toggleSelect hilightFgColor
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
    20
		hilightBgColor hilightLevel hilightFrameColor hilightStyle
2250
e95303644fac add an closeEditor action to allow the user to accept the contents
james
parents: 2245
diff changeset
    21
		dragAccessPoint dropTarget dropSource editorView openEditorAction
e95303644fac add an closeEditor action to allow the user to accept the contents
james
parents: 2245
diff changeset
    22
		closeEditorAction'
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
	classVariableNames:'DefaultHilightStyle DefaultHilightBackgroundColor
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
		DefaultHilightForegroundColor DefaultHilightLevel
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
		DefaultHilightFrameColor'
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
	poolDictionaries:''
1430
ae9e48cc7b9d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1423
diff changeset
    27
	category:'Views-Lists'
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
!SelectionInListModelView class methodsFor:'documentation'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
1431
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    32
copyright
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    33
"
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    34
 COPYRIGHT (c) 1999 by eXept Software AG
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    35
              All Rights Reserved
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    36
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    37
 This software is furnished under a license and may be used
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    38
 only in accordance with the terms of that license and with the
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    39
 inclusion of the above copyright notice.   This software may not
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    40
 be provided or otherwise made available to, or used by, any
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    41
 other person.  No title to or ownership of the software is
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    42
 hereby transferred.
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    43
"
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    44
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    45
!
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    46
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
documentation
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
    SelectionInListModelView is mostly like SelectionInListView,
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
    but derives from the ListModelView and thus the list is kept
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
    by the model.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
    [Instance variables:]
2228
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
    54
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
    55
        selection               <misc>       the current selection. nil, a number or collection of numbers
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
    56
        multipleSelectOk        <Boolean>    allow/disallow multiple selections( default:false )
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
    57
        selectOnButtomMenu      <Boolean>    enable/disable selection will change on menu pressed
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
    58
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
    59
        actionBlock             <Block>      action evaluated on single click
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
    60
        doubleClickActionBlock  <Block>      action evaluated on double click
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
    61
        selectConditionBlock
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
    62
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
    63
        clickLine               <Number>     clicked line during button motion
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
    64
        useIndex                <Boolean>    representation of the model selection
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
    65
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
    66
        ignoreReselect          <Boolean>    if set, a click on an already selected entry is ignored
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
    67
        toggleSelect            <Boolean>    a click on an entry unselects it and vice versa
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
    68
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
    69
        highlightMode           <Symbol>     how to draw the selection
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
    70
        hilightFgColor          <Color>      foregroundColor of highlighted items       
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
    71
        hilightBgColor          <Color>      backgroundColor of highlighted items
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
    72
        hilightLevel            <Integer>    level to draw selections (i.e. for 3D effect)
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
    73
        hilightFrameColor       <Color>      rectangle around highlighted items
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
    74
        hilightStyle            <Boolean>    actions on widget are enabled/disabled
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
    75
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
    76
        dragAccessPoint         <Point>      point where the drag operation starts from
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
    77
        dropTarget              <DropTarget> keeps information about the drop operation
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
    78
        dropSource              <DropSource> keeps information about the drag operation
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
    79
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
    80
        editorView              <View>       editor on current selected item
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
    81
        openEditorAction        <Action>     action to get an editor on the current selection from user
2250
e95303644fac add an closeEditor action to allow the user to accept the contents
james
parents: 2245
diff changeset
    82
        closeEditorAction       <Action>     action invoked before the editor is closed.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
    [author:]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
        Claus Atzkern
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    87
    [see also:]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
        ListModelView
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    90
        HierarchicalListView
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    91
"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    93
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
examples
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
                                                                        [exBegin]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
    |top list view|
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
    list := List new.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
    1 to:100 do:[:i| list add:('element: ', i printString) ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
    top  := StandardSystemView new; extent:300@300.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   103
    view := ScrollableView for:SelectionInListModelView miniScroller:true
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
                        origin:0.0@0.0 corner:1.0@1.0 in:top.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
    view list:list.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   106
    top  open.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
                                                                        [exEnd]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   109
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   110
                                                                        [exBegin]
1915
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
   111
    |top list view|
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
   112
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
   113
    list := List new.
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
   114
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
   115
    1 to:100 do:[:i| list add:('element: ', i printString) ].
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
   116
    top  := StandardSystemView new; extent:300@300.
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
   117
    view := ScrollableView for:SelectionInListModelView miniScroller:true
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
   118
                        origin:0.0@0.0 corner:1.0@1.0 in:top.
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
   119
    view list:list.
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
   120
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
   121
    view openEditorAction:[:ln :aGC| |field|
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
   122
        field := EditField new.
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
   123
        field level:0.
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
   124
        field acceptOnLostFocus:true.
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
   125
        field acceptAction:[:x| list at:ln put:(field contents) ].
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
   126
        field font:(aGC font).
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
   127
        field contents:(list at:ln).
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
   128
        field
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
   129
    ].
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
   130
    top open.
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
   131
                                                                        [exEnd]
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
   132
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
   133
                                                                        [exBegin]
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   134
    |top list view item|
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   136
    list := HierarchicalList new.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   137
    item := HierarchicalItem::Example labeled:'Test'.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   138
    item expand.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   139
    list showRoot:false.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   140
    list root:item.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   141
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   142
    top  := StandardSystemView new; extent:300@300.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   143
    view := ScrollableView for:SelectionInListModelView miniScroller:true
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   144
                        origin:0.0@0.0 corner:1.0@1.0 in:top.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   145
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   146
    view list:list.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   147
    view doubleClickAction:[:i| (list at:i) toggleExpand ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   148
    top  open.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   149
                                                                        [exEnd]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   150
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   151
"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   152
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   153
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   154
!SelectionInListModelView class methodsFor:'defaults'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   155
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   156
updateStyleCache
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   157
    "extract values from the styleSheet and cache them in class variables"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   158
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   159
    <resource: #style   (
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   160
                        #'selection.hilightForegroundColor' #'selection.hilightBackgroundColor'
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   161
                        #'selection.hilightFrameColor'      #'selection.hilightLevel'
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   162
                        #'selection.foregroundColor'        #'selection.backgroundColor'
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   163
                        #'selection.shadowColor'            #'selection.lightColor'
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   164
                        #'selection.font'                   #'selection.hilightStyle'
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   165
                        #'text.foregroundColor'
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   166
                        )>
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   167
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   168
    DefaultHilightForegroundColor  := StyleSheet colorAt:'selection.hilightForegroundColor'.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   169
    DefaultHilightBackgroundColor  := StyleSheet colorAt:'selection.hilightBackgroundColor'.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   170
    DefaultHilightFrameColor       := StyleSheet colorAt:'selection.hilightFrameColor'.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   171
    DefaultHilightLevel            := StyleSheet at:'selection.hilightLevel' default:0.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   172
    DefaultHilightStyle            := StyleSheet at:'selection.hilightStyle' default:(StyleSheet name).
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   173
    DefaultForegroundColor         := StyleSheet colorAt:'selection.foregroundColor'.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   174
    DefaultBackgroundColor         := StyleSheet colorAt:'selection.backgroundColor'.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   175
    DefaultShadowColor             := StyleSheet colorAt:'selection.shadowColor'.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   176
    DefaultLightColor              := StyleSheet colorAt:'selection.lightColor'.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   177
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   178
    DefaultForegroundColor isNil ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   179
        DefaultForegroundColor := StyleSheet colorAt:'text.foregroundColor' default:Black
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   180
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   181
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   182
     self updateStyleCache
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   183
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   184
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   185
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   186
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   187
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   188
!SelectionInListModelView methodsFor:'accessing'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   189
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   190
list:aList
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   191
    "get the status of <showRoot> from the list
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   192
    "
1547
f72d75aaec14 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
   193
    self deselectWithoutRedraw.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   194
  ^ super list:aList
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   195
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   196
2225
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
   197
!SelectionInListModelView methodsFor:'accessing editor'!
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
   198
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
   199
closeEditor
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
   200
    "close the current editor
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
   201
    "
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
   202
    |editor|
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
   203
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
   204
    (editor := editorView) notNil ifTrue:[
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
   205
        editorView := nil.
2308
c012b16422f0 replace ifNotNil: by notNil ifTrue:
ca
parents: 2302
diff changeset
   206
        closeEditorAction notNil ifTrue:[
2250
e95303644fac add an closeEditor action to allow the user to accept the contents
james
parents: 2245
diff changeset
   207
            closeEditorAction value:editor.
e95303644fac add an closeEditor action to allow the user to accept the contents
james
parents: 2245
diff changeset
   208
        ].
2225
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
   209
        editor destroy.
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
   210
    ].
2250
e95303644fac add an closeEditor action to allow the user to accept the contents
james
parents: 2245
diff changeset
   211
!
2225
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
   212
2250
e95303644fac add an closeEditor action to allow the user to accept the contents
james
parents: 2245
diff changeset
   213
closeEditorAction
e95303644fac add an closeEditor action to allow the user to accept the contents
james
parents: 2245
diff changeset
   214
    "get the block which is evaluated before the editor is closed; the argument
e95303644fac add an closeEditor action to allow the user to accept the contents
james
parents: 2245
diff changeset
   215
     to the action is the editor.
e95303644fac add an closeEditor action to allow the user to accept the contents
james
parents: 2245
diff changeset
   216
    "
e95303644fac add an closeEditor action to allow the user to accept the contents
james
parents: 2245
diff changeset
   217
    ^ closeEditorAction
e95303644fac add an closeEditor action to allow the user to accept the contents
james
parents: 2245
diff changeset
   218
!
2225
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
   219
2250
e95303644fac add an closeEditor action to allow the user to accept the contents
james
parents: 2245
diff changeset
   220
closeEditorAction:anOneArgAction
e95303644fac add an closeEditor action to allow the user to accept the contents
james
parents: 2245
diff changeset
   221
    "get the block which is evaluated before the editor is closed; the argument
e95303644fac add an closeEditor action to allow the user to accept the contents
james
parents: 2245
diff changeset
   222
     to the action is the editor.
e95303644fac add an closeEditor action to allow the user to accept the contents
james
parents: 2245
diff changeset
   223
    "
e95303644fac add an closeEditor action to allow the user to accept the contents
james
parents: 2245
diff changeset
   224
    closeEditorAction := anOneArgAction.
2225
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
   225
!
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
   226
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
   227
openEditor
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
   228
    "opens the editor on the current selection;
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
   229
     returns the editorView or nil if no openEditorAction is defined
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
   230
     or no single selection exists ...
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
   231
    "
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
   232
    |numArgs lnNr|
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
   233
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
   234
    self closeEditor.
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
   235
    shown ifFalse:[^ nil].
2308
c012b16422f0 replace ifNotNil: by notNil ifTrue:
ca
parents: 2302
diff changeset
   236
    openEditorAction isNil ifTrue:[^ nil].
2225
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
   237
    lnNr := self selectedIndex.
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
   238
    lnNr == 0 ifTrue:[^ nil].
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
   239
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
   240
    self makeSelectionVisible.
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
   241
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
   242
    numArgs := openEditorAction numArgs.
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
   243
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
   244
    numArgs == 0 ifTrue:[
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
   245
        editorView := openEditorAction value
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
   246
    ] ifFalse:[
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
   247
        numArgs == 1 ifTrue:[editorView := openEditorAction value:lnNr]
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
   248
                    ifFalse:[editorView := openEditorAction value:lnNr value:self]
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
   249
    ].
2308
c012b16422f0 replace ifNotNil: by notNil ifTrue:
ca
parents: 2302
diff changeset
   250
    editorView isNil ifTrue:[^ nil].
2225
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
   251
2308
c012b16422f0 replace ifNotNil: by notNil ifTrue:
ca
parents: 2302
diff changeset
   252
    editorView superView isNil ifTrue:[
2225
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
   253
        self addSubView:editorView
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
   254
    ].
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
   255
    self computeEditorLayout.
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
   256
    editorView realize.
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
   257
    self windowGroup focusView:editorView.
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
   258
  ^ editorView
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
   259
!
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
   260
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
   261
openEditorAction
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
   262
    "get the block which is evaluated to get the editor which is set for the
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
   263
     line; the arguments to the block is the line number and the widget itself
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
   264
    "
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
   265
    ^ openEditorAction
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
   266
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
   267
!
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
   268
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
   269
openEditorAction:aTwoArgAction
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
   270
    "set the block which is evaluated to get the editor which is set for the
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
   271
     line; the arguments to the block is the line number and the widget itself
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
   272
    "
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
   273
    openEditorAction := aTwoArgAction.
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
   274
! !
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
   275
1818
fe99c5c721e9 category changes
Claus Gittinger <cg@exept.de>
parents: 1772
diff changeset
   276
!SelectionInListModelView methodsFor:'accessing-actions'!
1641
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   277
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   278
action
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   279
    "get the action block to be performed on select
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   280
    "
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   281
    ^ actionBlock
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   282
!
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   283
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   284
action:aOneArgAction
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   285
    "set the action block to be performed on select
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   286
    "
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   287
    actionBlock := aOneArgAction
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   288
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   289
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   290
!
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   291
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   292
doubleClickAction
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   293
    "get the action block to be performed on doubleclick
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   294
    "
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   295
    ^ doubleClickActionBlock
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   296
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   297
!
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   298
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   299
doubleClickAction:aOneArgAction
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   300
    "set the action block to be performed on doubleclick
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   301
    "
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   302
    doubleClickActionBlock := aOneArgAction
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   303
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   304
!
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   305
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   306
selectConditionBlock
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   307
    "set the conditionBlock; this block is evaluated before a selection
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   308
     change is performed; the change will not be done, if the evaluation
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   309
     returns false
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   310
    "
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   311
    ^ selectConditionBlock
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   312
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   313
!
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   314
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   315
selectConditionBlock:aOneArgBlock
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   316
    "set the conditionBlock; this block is evaluated before a selection
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   317
     change is performed; the change will not be done, if the evaluation
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   318
     returns false
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   319
    "
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   320
    selectConditionBlock := aOneArgBlock.
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   321
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   322
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   323
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   324
! !
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   325
1818
fe99c5c721e9 category changes
Claus Gittinger <cg@exept.de>
parents: 1772
diff changeset
   326
!SelectionInListModelView methodsFor:'accessing-behavior'!
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   327
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   328
highlightMode
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   329
    "get the mode how to draw a selected line:
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   330
        #line           draw whole line selected
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   331
        #label          draw label selected
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   332
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   333
    ^ highlightMode
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   334
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   335
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   336
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   337
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   338
highlightMode:aMode
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   339
    "set the mode how to draw a selected line:
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   340
        #line           draw whole line selected
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   341
        #label          draw label selected
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   342
    "
1561
edac7f38341b use toggle selection insteat of addTo or remove from
ca
parents: 1557
diff changeset
   343
    highlightMode := aMode.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   344
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   345
1741
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   346
ignoreReselect
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   347
    "get the ignoreReselect flag - see method #ignoreReselect: for more details
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   348
    "
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   349
    ^ ignoreReselect
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   350
!
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   351
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   352
ignoreReselect:aBoolean
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   353
    "set/clear the ignoreReselect flag - 
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   354
     if set, a click on an already selected entry is ignored.
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   355
     Otherwise the notification is done, even if no
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   356
     change in the selection occurs.
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   357
     (for example, in browser to update a method).
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   358
     Setting ignoreReselect to false makes sense if data is shown
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   359
     which may change by itself (i.e. without the user doing anything)
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   360
     For example, the inspector uses this, and redisplays the value,
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   361
     if the selection is the same.
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   362
     The default is true, meaning that a click on an already selected
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   363
     does not lead to a notification via the actionBlock/change mechanism.
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   364
    "
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   365
    ignoreReselect := aBoolean
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   366
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   367
!
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   368
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   369
multipleSelectOk
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   370
    "allow/disallow multiple selections; the default is false
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   371
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   372
    ^ multipleSelectOk
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   373
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   374
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   375
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   376
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   377
multipleSelectOk:aState
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   378
    "allow/disallow multiple selections; the default is false
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   379
    "
1537
c59c720d16a2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1533
diff changeset
   380
    multipleSelectOk := aState ? false.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   381
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   382
2228
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
   383
selectOnButtomMenu
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
   384
    "define the button-menu-press behavior; if true the line under the mouse
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
   385
     will be selected before the menu is opened. Otherwise the menu is opened
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
   386
     on the current selection.
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
   387
    "
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
   388
    ^ selectOnButtomMenu
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
   389
!
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
   390
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
   391
selectOnButtomMenu:aBoolean
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
   392
    "define the button-menu-press behavior; if true the line under the mouse
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
   393
     will be selected before the menu is opened. Otherwise the menu is opened
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
   394
     on the current selection.
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
   395
    "
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
   396
    selectOnButtomMenu := aBoolean.
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
   397
!
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
   398
1741
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   399
toggleSelect
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   400
    "get the toggleSelect flag - see method #toggleSelect: for more details
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   401
    "
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   402
    ^ toggleSelect
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   403
!
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   404
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   405
toggleSelect:aBoolean
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   406
    "turn on/off toggle select. If true, clicking on a selected entry
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   407
     unselects it and vice versa. The default is false, which means
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   408
     that clicking on an already selected entry does not change its
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   409
     select status (see also ignoreReselect:).
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   410
    "
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   411
    toggleSelect := aBoolean.
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   412
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   413
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   414
!
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   415
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   416
useIndex
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   417
    "set/clear the useIndex flag.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   418
     the selection writen to the model are the indices into the list
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   419
     or the elements selected.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   420
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   421
    ^ useIndex
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   422
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   423
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   424
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   425
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   426
useIndex:aBoolean
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   427
    "set/clear the useIndex flag.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   428
     the selection writen to the model are the indices into the list
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   429
     or the elements selected.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   430
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   431
    useIndex := aBoolean ? true
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   432
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   433
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   434
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   435
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   436
!SelectionInListModelView methodsFor:'change & update'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   437
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   438
argForChangeMessage
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   439
    "return the argument for a selectionChange;
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   440
     depending on the setting of useIndex, this is either the numeric
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   441
     index of the selection or the value (i.e. the string)
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   442
    "
1554
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
   443
    selection isNil ifTrue:[
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
   444
        multipleSelectOk ifTrue:[^ #()].
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
   445
        ^ useIndex ifTrue:[0] ifFalse:[nil]
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   446
    ].
1564
6c73d2b8c0e7 checkin from browser
ca
parents: 1563
diff changeset
   447
    useIndex ifTrue:[^ selection].
1554
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
   448
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
   449
    multipleSelectOk ifFalse:[
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
   450
        ^ list at:selection ifAbsent:nil
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   451
    ].
1554
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
   452
    ^ selection collect:[:nr| list at:nr ifAbsent:nil ]
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   453
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   454
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   455
contentsChanged
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   456
    super contentsChanged.
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   457
    self  computeEditorLayout.
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   458
!
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   459
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   460
lineChangedAt:aLnNr with:arg
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   461
    super lineChangedAt:aLnNr with:arg.
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   462
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   463
    (editorView notNil and:[aLnNr == self selectedIndex]) ifTrue:[
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   464
        self computeEditorLayout.
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   465
    ]
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   466
!
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   467
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   468
listSizeChanged:aLnNr nLines:aDeltaLines
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   469
    "update selection
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   470
    "
1563
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   471
    |changed cnts|
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   472
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   473
    super listSizeChanged:aLnNr nLines:aDeltaLines.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   474
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   475
    selection isNil ifTrue:[^ self].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   476
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   477
    list size == 0 ifTrue:[
1563
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   478
        selection := nil.
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   479
      ^ self selectionChanged
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   480
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   481
1563
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   482
    multipleSelectOk ifFalse:[
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   483
        selection < aLnNr ifTrue:[^ self].
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   484
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   485
        selection := selection + aDeltaLines.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   486
1563
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   487
        (aDeltaLines < 0 and:[selection < aLnNr]) ifTrue:[
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   488
            selection := nil.
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   489
          ^ self selectionChanged
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   490
        ]
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   491
    ] ifTrue:[
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   492
        changed := false.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   493
1563
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   494
        aDeltaLines < 0  ifFalse:[
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   495
            selection keysAndValuesDo:[:i :ln|
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   496
                ln >= aLnNr ifTrue:[
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   497
                    changed := true.
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   498
                    selection at:i put:(ln + aDeltaLines)
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   499
                ]
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   500
            ]
1563
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   501
        ] ifTrue:[
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   502
            cnts := 0.
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   503
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   504
            selection keysAndValuesDo:[:i :ln||new|
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   505
                ln >= aLnNr ifTrue:[
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   506
                    changed := true.
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   507
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   508
                    (new := ln + aDeltaLines) < aLnNr ifTrue:[
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   509
                        cnts := cnts + 1.
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   510
                        new  := nil
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   511
                    ].
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   512
                    selection at:i put:new
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   513
                ]
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   514
            ].
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   515
            cnts ~~ 0 ifTrue:[
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   516
                cnts == selection size ifTrue:[
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   517
                    selection := nil
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   518
                ] ifFalse:[
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   519
                    selection := selection select:[:ln| ln notNil]
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   520
                ].
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   521
              ^ self selectionChanged.
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   522
            ].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   523
        ].
1563
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   524
        changed ifFalse:[^ self].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   525
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   526
1563
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   527
    (useIndex and:[model notNil]) ifTrue:[
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   528
        model setValue:(self argForChangeMessage)
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   529
    ].
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   530
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   531
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   532
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   533
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   534
originChanged:delta
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   535
    "setup the origin of the editing view
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   536
    "
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   537
    self computeEditorLayout.
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   538
    super originChanged:delta.
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   539
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   540
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   541
!
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   542
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   543
selectionChanged
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   544
    "selection has changed. Call actionblock and/or send changeMessage if defined
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   545
    "
1554
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
   546
    |arg|
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   547
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   548
    self closeEditor.
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   549
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   550
    (model isNil and:[actionBlock isNil]) ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   551
        ^ self
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   552
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   553
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   554
    arg := self argForChangeMessage.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   555
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   556
    model notNil ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   557
        model removeDependent:self.
1741
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   558
        "/ change models value to force a change notification: reselect mode
1758
d8d45bbbd3ba check whether model value differs from current selection.
ca
parents: 1755
diff changeset
   559
        arg = model value ifTrue:[
d8d45bbbd3ba check whether model value differs from current selection.
ca
parents: 1755
diff changeset
   560
            model setValue:(arg isNil ifTrue:[0] ifFalse:[nil]).
d8d45bbbd3ba check whether model value differs from current selection.
ca
parents: 1755
diff changeset
   561
        ].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   562
        self sendChangeMessage:#value: with:arg.
2225
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
   563
        model notNil ifTrue:[  "/ argggh could be nilled
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
   564
            model addDependent:self.
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
   565
        ]
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   566
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   567
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   568
    actionBlock notNil ifTrue:[
2070
cb8b952f7214 use new #valueWithOptionalArg
Claus Gittinger <cg@exept.de>
parents: 2055
diff changeset
   569
        actionBlock valueWithOptionalArgument:arg
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   570
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   571
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   572
1554
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
   573
updateFromModel
2302
5a2a1d5d09f8 remove asynchronous handling of changes; always disabled because doesn't work
ca
parents: 2275
diff changeset
   574
    "update selection from the model
5a2a1d5d09f8 remove asynchronous handling of changes; always disabled because doesn't work
ca
parents: 2275
diff changeset
   575
    "
5a2a1d5d09f8 remove asynchronous handling of changes; always disabled because doesn't work
ca
parents: 2275
diff changeset
   576
    |value nsel sensor|
5a2a1d5d09f8 remove asynchronous handling of changes; always disabled because doesn't work
ca
parents: 2275
diff changeset
   577
5a2a1d5d09f8 remove asynchronous handling of changes; always disabled because doesn't work
ca
parents: 2275
diff changeset
   578
    model isNil ifTrue:[
5a2a1d5d09f8 remove asynchronous handling of changes; always disabled because doesn't work
ca
parents: 2275
diff changeset
   579
        ^ self
5a2a1d5d09f8 remove asynchronous handling of changes; always disabled because doesn't work
ca
parents: 2275
diff changeset
   580
    ].
5a2a1d5d09f8 remove asynchronous handling of changes; always disabled because doesn't work
ca
parents: 2275
diff changeset
   581
    (     multipleSelectOk
5a2a1d5d09f8 remove asynchronous handling of changes; always disabled because doesn't work
ca
parents: 2275
diff changeset
   582
     and:[clickLine notNil
5a2a1d5d09f8 remove asynchronous handling of changes; always disabled because doesn't work
ca
parents: 2275
diff changeset
   583
     and:[(sensor := self sensor) notNil
5a2a1d5d09f8 remove asynchronous handling of changes; always disabled because doesn't work
ca
parents: 2275
diff changeset
   584
     and:[sensor leftButtonPressed]]]
5a2a1d5d09f8 remove asynchronous handling of changes; always disabled because doesn't work
ca
parents: 2275
diff changeset
   585
    ) ifTrue:[
5a2a1d5d09f8 remove asynchronous handling of changes; always disabled because doesn't work
ca
parents: 2275
diff changeset
   586
        "running in button motion; discard change notification
5a2a1d5d09f8 remove asynchronous handling of changes; always disabled because doesn't work
ca
parents: 2275
diff changeset
   587
        "
5a2a1d5d09f8 remove asynchronous handling of changes; always disabled because doesn't work
ca
parents: 2275
diff changeset
   588
        ^ self
5a2a1d5d09f8 remove asynchronous handling of changes; always disabled because doesn't work
ca
parents: 2275
diff changeset
   589
    ].
5a2a1d5d09f8 remove asynchronous handling of changes; always disabled because doesn't work
ca
parents: 2275
diff changeset
   590
5a2a1d5d09f8 remove asynchronous handling of changes; always disabled because doesn't work
ca
parents: 2275
diff changeset
   591
    value := model value.
5a2a1d5d09f8 remove asynchronous handling of changes; always disabled because doesn't work
ca
parents: 2275
diff changeset
   592
5a2a1d5d09f8 remove asynchronous handling of changes; always disabled because doesn't work
ca
parents: 2275
diff changeset
   593
    (useIndex or:[value isNil or:[value isNumber]]) ifFalse:[
5a2a1d5d09f8 remove asynchronous handling of changes; always disabled because doesn't work
ca
parents: 2275
diff changeset
   594
        multipleSelectOk ifFalse:[
5a2a1d5d09f8 remove asynchronous handling of changes; always disabled because doesn't work
ca
parents: 2275
diff changeset
   595
            value := list identityIndexOf:value
5a2a1d5d09f8 remove asynchronous handling of changes; always disabled because doesn't work
ca
parents: 2275
diff changeset
   596
        ] ifTrue:[
5a2a1d5d09f8 remove asynchronous handling of changes; always disabled because doesn't work
ca
parents: 2275
diff changeset
   597
            value isEmpty ifTrue:[
5a2a1d5d09f8 remove asynchronous handling of changes; always disabled because doesn't work
ca
parents: 2275
diff changeset
   598
                value := nil
5a2a1d5d09f8 remove asynchronous handling of changes; always disabled because doesn't work
ca
parents: 2275
diff changeset
   599
            ] ifFalse:[
5a2a1d5d09f8 remove asynchronous handling of changes; always disabled because doesn't work
ca
parents: 2275
diff changeset
   600
                nsel := OrderedCollection new.
5a2a1d5d09f8 remove asynchronous handling of changes; always disabled because doesn't work
ca
parents: 2275
diff changeset
   601
                value do:[:e||i|(i := list identityIndexOf:e) ~~ 0 ifTrue:[nsel add:i]].
5a2a1d5d09f8 remove asynchronous handling of changes; always disabled because doesn't work
ca
parents: 2275
diff changeset
   602
                value := nsel notEmpty ifTrue:[nsel] ifFalse:[nil]
5a2a1d5d09f8 remove asynchronous handling of changes; always disabled because doesn't work
ca
parents: 2275
diff changeset
   603
            ]
5a2a1d5d09f8 remove asynchronous handling of changes; always disabled because doesn't work
ca
parents: 2275
diff changeset
   604
        ].
5a2a1d5d09f8 remove asynchronous handling of changes; always disabled because doesn't work
ca
parents: 2275
diff changeset
   605
    ].
5a2a1d5d09f8 remove asynchronous handling of changes; always disabled because doesn't work
ca
parents: 2275
diff changeset
   606
    self setSelection:value.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   607
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   608
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   609
!SelectionInListModelView methodsFor:'drag & drop'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   610
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   611
canDrag
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   612
    "returns true if dragging is enabled
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   613
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   614
    ^ dropSource notNil
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   615
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   616
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   617
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   618
dropSource
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   619
    "returns the dropSource or nil
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   620
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   621
    ^ dropSource
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   622
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   623
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   624
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   625
dropSource:aDropSourceOrNil
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   626
    "set the dropSource or nil
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   627
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   628
    dropSource := aDropSourceOrNil.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   629
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   630
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   631
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   632
dropTarget
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   633
    "returns the dropTarget or nil
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   634
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   635
    ^ dropTarget
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   636
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   637
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   638
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   639
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   640
dropTarget:aDropTragetOrNil
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   641
    "set the dropTarget or nil
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   642
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   643
    dropTarget := aDropTragetOrNil.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   644
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   645
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   646
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   647
startDragAt:aPoint
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   648
    "start drag at a point
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   649
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   650
    dropSource notNil ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   651
        dropSource startDragSelector notNil ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   652
            dropSource startDragIn:self at:aPoint
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   653
        ] ifFalse:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   654
            DragAndDropManager new startDragFrom:self
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   655
                                      dropSource:dropSource
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   656
                                          offset:#center
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   657
        ]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   658
    ]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   659
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   660
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   661
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   662
!SelectionInListModelView methodsFor:'drawing'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   663
1533
609fce5df829 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1508
diff changeset
   664
drawFrom:start to:stop x:x y:y w:w
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   665
    "draw the lines between start to stop without clearing the background
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   666
    "
1557
e3feb8bc17b0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1554
diff changeset
   667
    highlightMode notNil ifTrue:[
e3feb8bc17b0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1554
diff changeset
   668
        self selectionDo:[:lnNr|
e3feb8bc17b0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1554
diff changeset
   669
            (lnNr between:start and:stop) ifTrue:[
e3feb8bc17b0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1554
diff changeset
   670
                self drawSelectionFrameAt:lnNr x:x w:w
e3feb8bc17b0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1554
diff changeset
   671
            ]
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   672
        ]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   673
    ].
1533
609fce5df829 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1508
diff changeset
   674
    self drawElementsFrom:start to:stop x:x y:y w:w.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   675
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   676
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   677
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   678
1533
609fce5df829 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1508
diff changeset
   679
drawLabelAt:anIndex x:x y:y h:h
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   680
    "draw the label at position x/y without clearing the background
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   681
    "
1554
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
   682
    |item|
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
   683
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   684
    editorView notNil ifTrue:[
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   685
        "/ there is an open editor for the line; thus no redraw for the label (hidden by editor)
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   686
        self selectedIndex == anIndex ifTrue:[^ self].
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   687
    ].
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   688
1508
9c54f2e53da1 check whether #at:ifAbsent returns nil.
Claus Gittinger <cg@exept.de>
parents: 1468
diff changeset
   689
    item := list at:anIndex ifAbsent:nil.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   690
1557
e3feb8bc17b0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1554
diff changeset
   691
    item notNil ifTrue:[
e3feb8bc17b0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1554
diff changeset
   692
        (highlightMode notNil and:[self isInSelection:anIndex]) ifTrue:[
e3feb8bc17b0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1554
diff changeset
   693
            self paint:hilightFgColor on:hilightBgColor
e3feb8bc17b0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1554
diff changeset
   694
        ] ifFalse:[
e3feb8bc17b0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1554
diff changeset
   695
            self paint:fgColor on:bgColor.
e3feb8bc17b0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1554
diff changeset
   696
        ].
e3feb8bc17b0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1554
diff changeset
   697
        self displayElement:item x:x y:y h:h.
e3feb8bc17b0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1554
diff changeset
   698
    ]
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   699
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   700
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   701
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   702
1554
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
   703
drawSelectionFrameAt:lnNr x:x w:w
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
   704
    "draw the background and foreground of the selection frame
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
   705
     at a lineNr.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   706
    "
1554
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
   707
    |item
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
   708
     x0 "{ Class:SmallInteger }"
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   709
     x1 "{ Class: SmallInteger }"
1554
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
   710
     y0 "{ Class:SmallInteger }"
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
   711
     y1 "{ Class:SmallInteger }"
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
   712
     hL "{ Class:SmallInteger }"
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
   713
     wL "{ Class:SmallInteger }"
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   714
    |
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   715
    editorView notNil ifTrue:[
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   716
        "/ there is an open editor; do not redraw selected
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   717
        ^ self
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   718
    ].
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   719
1554
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
   720
    (item := list at:lnNr ifAbsent:nil) isNil ifTrue:[
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   721
        "/ list might change during drawing; item no longer visible
1554
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
   722
        ^ self
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
   723
    ].
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
   724
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
   725
    "/ CLEAR THE BACKGROUND
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
   726
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
   727
    y0 := self yVisibleOfLine:lnNr.
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
   728
    y1 := self yVisibleOfLine:(lnNr + 1).
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
   729
    hL := y1 - y0.
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
   730
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
   731
    highlightMode == #line ifTrue:[
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
   732
        x0 := x.
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
   733
        x1 := x0 + w.
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
   734
    ] ifFalse:[
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
   735
        highlightMode == #label ifFalse:[^ self].
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
   736
        x0 := (self xVisibleOfItem:item) - (textStartLeft // 2).
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
   737
        x1 := x0 + (item widthOn:self) + textStartLeft.
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
   738
    ].
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
   739
    wL := x1 - x0.
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
   740
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
   741
    wL > 0 ifFalse:[^ self].
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
   742
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
   743
    self paint:hilightBgColor.
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
   744
    self fillRectangleX:x0 y:y0 width:wL height:hL.
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
   745
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
   746
    "/ DRAW THE FRAME
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   747
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   748
    hilightFrameColor notNil ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   749
        hilightLevel == 0 ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   750
            self paint:hilightFrameColor.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   751
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   752
            highlightMode == #line ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   753
                self displayLineFromX:x0 y:y0 toX:x1 y:y0.
1554
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
   754
                y1 := y0 + hL - 1.
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
   755
                self displayLineFromX:x0 y:y1 toX:x1 y:y1.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   756
            ] ifFalse:[
1554
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
   757
                self displayRectangleX:x0 y:y0 width:wL height:hL
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   758
            ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   759
            ^ self.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   760
        ]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   761
    ] ifFalse:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   762
        hilightStyle == #motif ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   763
            self paint:bgColor.
1554
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
   764
            y1 := y0 + 1.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   765
            highlightMode == #line ifTrue:[
1554
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
   766
                self displayLineFromX:x0 y:y1 toX:x1 y:y1.
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
   767
                y1 := y0 + hL - 2.
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
   768
                self displayLineFromX:x0 y:y1 toX:x1 y:y1.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   769
            ] ifFalse:[
1554
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
   770
                self displayRectangleX:x0 + 1 y:y1 width:wL - 2 height:hL - 2
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   771
            ]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   772
        ]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   773
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   774
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   775
    hilightLevel ~~ 0 ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   776
        "/ draw edge
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   777
        highlightMode == #line ifTrue:[
1554
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
   778
            x0 := margin.
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
   779
            wL := width - x0 - x0.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   780
        ].
1554
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
   781
        self drawEdgesForX:x0 y:y0 width:wL height:hL level:hilightLevel.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   782
    ]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   783
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   784
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   785
2245
546c6e5d0951 change #redrawSelectionAt: to #invalidateSelectionAt: (because is a invalidate)
ca
parents: 2228
diff changeset
   786
invalidateSelectionAt:aLineNr
1569
447b0cafc1db drawing selected or unselected
ca
parents: 1564
diff changeset
   787
    "redraw a line which changed its selection status.
447b0cafc1db drawing selected or unselected
ca
parents: 1564
diff changeset
   788
     optimized when drawing only the label.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   789
    "
1569
447b0cafc1db drawing selected or unselected
ca
parents: 1564
diff changeset
   790
    |item
447b0cafc1db drawing selected or unselected
ca
parents: 1564
diff changeset
   791
     y0 "{ Class:SmallInteger }"
447b0cafc1db drawing selected or unselected
ca
parents: 1564
diff changeset
   792
     y1 "{ Class:SmallInteger }"
447b0cafc1db drawing selected or unselected
ca
parents: 1564
diff changeset
   793
     yB "{ Class:SmallInteger }"
447b0cafc1db drawing selected or unselected
ca
parents: 1564
diff changeset
   794
     x0 "{ Class:SmallInteger }"
447b0cafc1db drawing selected or unselected
ca
parents: 1564
diff changeset
   795
     x1 "{ Class:SmallInteger }"
447b0cafc1db drawing selected or unselected
ca
parents: 1564
diff changeset
   796
    |
447b0cafc1db drawing selected or unselected
ca
parents: 1564
diff changeset
   797
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   798
    editorView notNil ifTrue:[
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   799
        "/ there is an open editor; do not redraw selected
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   800
        ^ self
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   801
    ].
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   802
1569
447b0cafc1db drawing selected or unselected
ca
parents: 1564
diff changeset
   803
    (shown and:[aLineNr notNil and:[highlightMode notNil]]) ifFalse:[
447b0cafc1db drawing selected or unselected
ca
parents: 1564
diff changeset
   804
        ^ self
1557
e3feb8bc17b0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1554
diff changeset
   805
    ].
e3feb8bc17b0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1554
diff changeset
   806
1569
447b0cafc1db drawing selected or unselected
ca
parents: 1564
diff changeset
   807
    yB := height - margin.
447b0cafc1db drawing selected or unselected
ca
parents: 1564
diff changeset
   808
    y0 := (self yVisibleOfLine:aLineNr) max:margin.
447b0cafc1db drawing selected or unselected
ca
parents: 1564
diff changeset
   809
447b0cafc1db drawing selected or unselected
ca
parents: 1564
diff changeset
   810
    y0 >= yB ifTrue:[
447b0cafc1db drawing selected or unselected
ca
parents: 1564
diff changeset
   811
        ^ self
447b0cafc1db drawing selected or unselected
ca
parents: 1564
diff changeset
   812
    ].
447b0cafc1db drawing selected or unselected
ca
parents: 1564
diff changeset
   813
447b0cafc1db drawing selected or unselected
ca
parents: 1564
diff changeset
   814
    y1 := (self yVisibleOfLine:(aLineNr + 1)) min:yB.
447b0cafc1db drawing selected or unselected
ca
parents: 1564
diff changeset
   815
447b0cafc1db drawing selected or unselected
ca
parents: 1564
diff changeset
   816
    y1 <= margin ifTrue:[
447b0cafc1db drawing selected or unselected
ca
parents: 1564
diff changeset
   817
        ^ self
447b0cafc1db drawing selected or unselected
ca
parents: 1564
diff changeset
   818
    ].
447b0cafc1db drawing selected or unselected
ca
parents: 1564
diff changeset
   819
1739
195eefc3656f invalidate line in label mode to width of view (bug fix for detemobil)
ca
parents: 1649
diff changeset
   820
    x1 := width.
195eefc3656f invalidate line in label mode to width of view (bug fix for detemobil)
ca
parents: 1649
diff changeset
   821
1569
447b0cafc1db drawing selected or unselected
ca
parents: 1564
diff changeset
   822
    (     highlightMode == #label
447b0cafc1db drawing selected or unselected
ca
parents: 1564
diff changeset
   823
     and:[(item := list at:aLineNr ifAbsent:nil) notNil]
447b0cafc1db drawing selected or unselected
ca
parents: 1564
diff changeset
   824
    ) ifTrue:[
447b0cafc1db drawing selected or unselected
ca
parents: 1564
diff changeset
   825
        x0 := (self xVisibleOfItem:item) - (textStartLeft // 2).
447b0cafc1db drawing selected or unselected
ca
parents: 1564
diff changeset
   826
        x0 := x0 max:0.
447b0cafc1db drawing selected or unselected
ca
parents: 1564
diff changeset
   827
        x1 > x0 ifFalse:[^ self].
447b0cafc1db drawing selected or unselected
ca
parents: 1564
diff changeset
   828
    ] ifFalse:[
447b0cafc1db drawing selected or unselected
ca
parents: 1564
diff changeset
   829
        x0 := 0.
447b0cafc1db drawing selected or unselected
ca
parents: 1564
diff changeset
   830
        x1 := width.
447b0cafc1db drawing selected or unselected
ca
parents: 1564
diff changeset
   831
    ].
2148
4e7157e02e9e invalide: leftover pixel-row under win32 (how did this happen ?)
Claus Gittinger <cg@exept.de>
parents: 2125
diff changeset
   832
    self invalidateX:x0 y:y0 width:(x1 - x0) height:(y1 - y0+1).
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   833
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   834
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   835
!SelectionInListModelView methodsFor:'event handling'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   836
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   837
buttonMotion:buttonMask x:x y:y
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   838
    "mouse-move while button was pressed - handle selection changes
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   839
    "
1747
f46c5941c028 better alghorithm for button motion in multipleSelection mode
ca
parents: 1745
diff changeset
   840
    |dragPoint lnNr dY d0 nsel viewOrgY yAbsLine
f46c5941c028 better alghorithm for button motion in multipleSelection mode
ca
parents: 1745
diff changeset
   841
     step  "{ Class:SmallInteger }"
f46c5941c028 better alghorithm for button motion in multipleSelection mode
ca
parents: 1745
diff changeset
   842
    |
f46c5941c028 better alghorithm for button motion in multipleSelection mode
ca
parents: 1745
diff changeset
   843
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   844
1542
8607d072c319 accessing selection through to selector
Claus Gittinger <cg@exept.de>
parents: 1537
diff changeset
   845
    (enabled and:[self hasSelection]) ifFalse:[^ self].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   846
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   847
    dragAccessPoint notNil ifTrue:[
1747
f46c5941c028 better alghorithm for button motion in multipleSelection mode
ca
parents: 1745
diff changeset
   848
        dragPoint := x @ y.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   849
1747
f46c5941c028 better alghorithm for button motion in multipleSelection mode
ca
parents: 1745
diff changeset
   850
        (dragAccessPoint dist:dragPoint) > 5.0 ifTrue:[
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   851
            dragAccessPoint := nil.
1747
f46c5941c028 better alghorithm for button motion in multipleSelection mode
ca
parents: 1745
diff changeset
   852
            self startDragAt:dragPoint
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   853
        ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   854
        ^ self
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   855
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   856
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   857
    (multipleSelectOk and:[self sensor leftButtonPressed]) ifFalse:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   858
        ^ self
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   859
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   860
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   861
    clickLine isNil ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   862
        ^ self
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   863
    ].
1747
f46c5941c028 better alghorithm for button motion in multipleSelection mode
ca
parents: 1745
diff changeset
   864
    (lnNr := self yVisibleToLineNr:y) isNil ifTrue:[
f46c5941c028 better alghorithm for button motion in multipleSelection mode
ca
parents: 1745
diff changeset
   865
        lnNr := list size
f46c5941c028 better alghorithm for button motion in multipleSelection mode
ca
parents: 1745
diff changeset
   866
    ] ifFalse:[
f46c5941c028 better alghorithm for button motion in multipleSelection mode
ca
parents: 1745
diff changeset
   867
        lnNr := lnNr max:1
f46c5941c028 better alghorithm for button motion in multipleSelection mode
ca
parents: 1745
diff changeset
   868
    ].
f46c5941c028 better alghorithm for button motion in multipleSelection mode
ca
parents: 1745
diff changeset
   869
    lnNr == clickLine ifTrue:[^ self].
f46c5941c028 better alghorithm for button motion in multipleSelection mode
ca
parents: 1745
diff changeset
   870
1748
0a2213a15e06 support of auto scrolling
ca
parents: 1747
diff changeset
   871
    autoScroll ifTrue:[
0a2213a15e06 support of auto scrolling
ca
parents: 1747
diff changeset
   872
        "/ if moved outside of view, start autoscroll
0a2213a15e06 support of auto scrolling
ca
parents: 1747
diff changeset
   873
        (y < 0) ifTrue:[
0a2213a15e06 support of auto scrolling
ca
parents: 1747
diff changeset
   874
            ^ self startAutoScroll:[self scrollUp] distance:y.
0a2213a15e06 support of auto scrolling
ca
parents: 1747
diff changeset
   875
        ].
0a2213a15e06 support of auto scrolling
ca
parents: 1747
diff changeset
   876
        (y > height) ifTrue:[
0a2213a15e06 support of auto scrolling
ca
parents: 1747
diff changeset
   877
            ^ self startAutoScroll:[self scrollDown] distance:(y - height).
0a2213a15e06 support of auto scrolling
ca
parents: 1747
diff changeset
   878
        ].
0a2213a15e06 support of auto scrolling
ca
parents: 1747
diff changeset
   879
    ].
0a2213a15e06 support of auto scrolling
ca
parents: 1747
diff changeset
   880
0a2213a15e06 support of auto scrolling
ca
parents: 1747
diff changeset
   881
    "move inside - stop autoscroll if any"
0a2213a15e06 support of auto scrolling
ca
parents: 1747
diff changeset
   882
    self stopAutoScroll.
0a2213a15e06 support of auto scrolling
ca
parents: 1747
diff changeset
   883
1747
f46c5941c028 better alghorithm for button motion in multipleSelection mode
ca
parents: 1745
diff changeset
   884
    nsel := OrderedCollection new.
f46c5941c028 better alghorithm for button motion in multipleSelection mode
ca
parents: 1745
diff changeset
   885
    step := lnNr > clickLine ifTrue:[1] ifFalse:[-1].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   886
1747
f46c5941c028 better alghorithm for button motion in multipleSelection mode
ca
parents: 1745
diff changeset
   887
    clickLine to:lnNr by:step do:[:i|
1920
e3994a83fb16 selectConditionBlock can be a 2-arg block;
martin
parents: 1917
diff changeset
   888
        ((self isInSelection:i) or:[self canSelectIndex:i forAdd:true]) ifTrue:[nsel add:i].
1747
f46c5941c028 better alghorithm for button motion in multipleSelection mode
ca
parents: 1745
diff changeset
   889
    ].
f46c5941c028 better alghorithm for button motion in multipleSelection mode
ca
parents: 1745
diff changeset
   890
    (self selectWithoutScroll:nsel redraw:true) ifFalse:[^ self].
f46c5941c028 better alghorithm for button motion in multipleSelection mode
ca
parents: 1745
diff changeset
   891
f46c5941c028 better alghorithm for button motion in multipleSelection mode
ca
parents: 1745
diff changeset
   892
    viewOrgY := viewOrigin y.
f46c5941c028 better alghorithm for button motion in multipleSelection mode
ca
parents: 1745
diff changeset
   893
    yAbsLine := self yAbsoluteOfLine:lnNr.
f46c5941c028 better alghorithm for button motion in multipleSelection mode
ca
parents: 1745
diff changeset
   894
f46c5941c028 better alghorithm for button motion in multipleSelection mode
ca
parents: 1745
diff changeset
   895
    yAbsLine < viewOrgY ifTrue:[
f46c5941c028 better alghorithm for button motion in multipleSelection mode
ca
parents: 1745
diff changeset
   896
        self scrollTo:( viewOrigin x @ yAbsLine) redraw:true
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   897
    ] ifFalse:[
1747
f46c5941c028 better alghorithm for button motion in multipleSelection mode
ca
parents: 1745
diff changeset
   898
        yAbsLine - viewOrgY > height ifTrue:[
f46c5941c028 better alghorithm for button motion in multipleSelection mode
ca
parents: 1745
diff changeset
   899
            d0 := yAbsLine - height.
f46c5941c028 better alghorithm for button motion in multipleSelection mode
ca
parents: 1745
diff changeset
   900
            self scrollTo:( viewOrigin x @ d0) redraw:true.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   901
        ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   902
    ].
1747
f46c5941c028 better alghorithm for button motion in multipleSelection mode
ca
parents: 1745
diff changeset
   903
    self repairDamage.
f46c5941c028 better alghorithm for button motion in multipleSelection mode
ca
parents: 1745
diff changeset
   904
    self selectionChanged.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   905
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   906
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   907
buttonMultiPress:button x:x y:y
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   908
    "button was pressed multiple - handle a doubleClick action
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   909
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   910
    clickLine := nil.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   911
    dragAccessPoint := nil.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   912
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   913
    enabled ifFalse:[^ self].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   914
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   915
    ((button == 1) or:[button == #select]) ifFalse:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   916
        ^ super buttonMultiPress:button x:x y:y
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   917
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   918
    self doubleClicked
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   919
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   920
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   921
buttonPress:button x:x y:y
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   922
    "a button was pressed - handle selection here
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   923
    "
2228
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
   924
    |sensor nsel start step item menu appl isInSelection lineNr|
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   925
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   926
    clickLine       := nil.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   927
    dragAccessPoint := nil.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   928
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   929
    enabled ifFalse:[^ self].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   930
2228
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
   931
    sensor := self sensor.
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
   932
    sensor notNil ifTrue:[ lineNr := self yVisibleToLineNr:y ]
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
   933
                 ifFalse:[ lineNr := nil ].
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
   934
1578
cfa573485242 ask for middleButtonMenu if menuButton pressed
ca
parents: 1569
diff changeset
   935
    ((button == 2) or:[button == #menu]) ifTrue:[
2228
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
   936
        selectOnButtomMenu ifTrue:[
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
   937
            (     lineNr notNil
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
   938
             and:[lineNr ~~ self selectedIndex
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
   939
             and:[self canSelectIndex:lineNr forAdd:false ]]
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
   940
            ) ifTrue:[
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
   941
                (self selectWithoutScroll:lineNr redraw:true) ifTrue:[
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
   942
                    self selectionChanged
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
   943
                ].
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
   944
                item := self selectedElement.
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
   945
            ] ifFalse:[
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
   946
                item := nil
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
   947
            ]
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
   948
        ] ifFalse:[
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
   949
            item := self selectedElement.
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
   950
        ].
1578
cfa573485242 ask for middleButtonMenu if menuButton pressed
ca
parents: 1569
diff changeset
   951
2308
c012b16422f0 replace ifNotNil: by notNil ifTrue:
ca
parents: 2302
diff changeset
   952
        item notNil ifTrue:[
c012b16422f0 replace ifNotNil: by notNil ifTrue:
ca
parents: 2302
diff changeset
   953
            self makeSelectionVisible.
2228
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
   954
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
   955
            menu := item perform:#middleButtonMenu ifNotUnderstood:nil.
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
   956
2308
c012b16422f0 replace ifNotNil: by notNil ifTrue:
ca
parents: 2302
diff changeset
   957
            menu notNil ifTrue:[
2228
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
   958
                menu isCollection ifTrue:[
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
   959
                    menu := Menu new fromLiteralArrayEncoding:menu.
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
   960
                    appl := self application.
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
   961
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
   962
                    appl notNil ifTrue:[
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
   963
                        menu findGuiResourcesIn:appl.
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
   964
                        "/ menu receiver:appl  -- now done in findGuiResources ...
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
   965
                    ] ifFalse:[
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
   966
                        menu receiver:item
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
   967
                    ]
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
   968
                ].
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
   969
                menu startUp.
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
   970
              ^ self
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
   971
            ]
1578
cfa573485242 ask for middleButtonMenu if menuButton pressed
ca
parents: 1569
diff changeset
   972
        ].
2228
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
   973
        super buttonPress:button x:x y:y.
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
   974
      ^ self
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   975
    ].
1578
cfa573485242 ask for middleButtonMenu if menuButton pressed
ca
parents: 1569
diff changeset
   976
2308
c012b16422f0 replace ifNotNil: by notNil ifTrue:
ca
parents: 2302
diff changeset
   977
    (clickLine := lineNr) isNil ifTrue:[ ^ self ].
2228
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
   978
1644
d35b53c3d7d5 checkin from browser
ps
parents: 1641
diff changeset
   979
    isInSelection := self isInSelection:clickLine.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   980
1741
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   981
    multipleSelectOk ifTrue:[
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   982
        sensor ctrlDown ifTrue:[
1920
e3994a83fb16 selectConditionBlock can be a 2-arg block;
martin
parents: 1917
diff changeset
   983
            (isInSelection or:[self canSelectIndex:clickLine forAdd:true]) ifTrue:[
1644
d35b53c3d7d5 checkin from browser
ps
parents: 1641
diff changeset
   984
                self toggleSelection:clickLine.
d35b53c3d7d5 checkin from browser
ps
parents: 1641
diff changeset
   985
                self selectionChanged
d35b53c3d7d5 checkin from browser
ps
parents: 1641
diff changeset
   986
            ].
d35b53c3d7d5 checkin from browser
ps
parents: 1641
diff changeset
   987
            ^ self
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   988
        ].
1920
e3994a83fb16 selectConditionBlock can be a 2-arg block;
martin
parents: 1917
diff changeset
   989
e3994a83fb16 selectConditionBlock can be a 2-arg block;
martin
parents: 1917
diff changeset
   990
        (self canSelectIndex:clickLine forAdd:sensor shiftDown) ifFalse:[^ self].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   991
1545
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
   992
        (sensor shiftDown and:[(start := self firstInSelection) notNil]) ifTrue:[
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
   993
            step := clickLine < start ifTrue:[-1] ifFalse:[1].
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
   994
            nsel := OrderedCollection new.
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
   995
1641
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   996
            start to:clickLine by:step do:[:i|
1920
e3994a83fb16 selectConditionBlock can be a 2-arg block;
martin
parents: 1917
diff changeset
   997
                ((self isInSelection:i) or:[self canSelectIndex:i forAdd:true]) ifTrue:[nsel add:i]
1641
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   998
            ].
1545
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
   999
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  1000
            (self selectWithoutScroll:nsel redraw:true) ifTrue:[
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1001
                self selectionChanged
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1002
            ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1003
            ^ self
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1004
        ]
1644
d35b53c3d7d5 checkin from browser
ps
parents: 1641
diff changeset
  1005
    ] ifFalse:[
1920
e3994a83fb16 selectConditionBlock can be a 2-arg block;
martin
parents: 1917
diff changeset
  1006
        (self canSelectIndex:clickLine forAdd:false) ifFalse:[^ self]
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1007
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1008
1915
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
  1009
    (isInSelection and:[self canDrag]) ifTrue:[
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
  1010
        dragAccessPoint := x @ y.
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
  1011
    ] ifFalse:[
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
  1012
        self buttonPressOrReleaseAtLine:clickLine x:x y:y
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
  1013
    ].
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
  1014
!
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
  1015
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
  1016
buttonPressOrReleaseAtLine:aLnNr x:x y:y
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
  1017
    "handle a button press or release at a line
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
  1018
    "
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
  1019
    aLnNr == self selectedIndex ifTrue:[
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
  1020
        editorView notNil ifTrue:[^ self].
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
  1021
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
  1022
        openEditorAction notNil ifTrue:[
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
  1023
            self openEditorAtX:x y:y.
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
  1024
            editorView notNil ifTrue:[^ self].
1741
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
  1025
        ].
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
  1026
1915
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
  1027
        ignoreReselect ifFalse:[
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
  1028
            (toggleSelect and:[self sensor ctrlDown]) ifTrue:[
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
  1029
                self selection:nil
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
  1030
            ] ifFalse:[
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
  1031
                self selectionChanged
1741
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
  1032
            ].
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
  1033
        ].
1915
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
  1034
    ] ifFalse:[
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
  1035
        (self selectWithoutScroll:aLnNr redraw:true) ifTrue:[
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
  1036
            self selectionChanged
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
  1037
        ]
1741
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
  1038
    ].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1039
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1040
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1041
buttonRelease:button x:x y:y
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1042
    "a button was released
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1043
    "
1915
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
  1044
    |dragPoint clickLnNr|
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
  1045
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
  1046
    dragPoint := dragAccessPoint.
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
  1047
    clickLnNr := clickLine.
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
  1048
    clickLine := dragAccessPoint := nil.
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
  1049
1748
0a2213a15e06 support of auto scrolling
ca
parents: 1747
diff changeset
  1050
    self stopAutoScroll.
0a2213a15e06 support of auto scrolling
ca
parents: 1747
diff changeset
  1051
1915
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
  1052
    (enabled and:[dragPoint notNil and:[clickLnNr notNil]]) ifTrue:[
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
  1053
        self buttonPressOrReleaseAtLine:clickLnNr x:(dragPoint x) y:(dragPoint y).
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1054
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1055
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1056
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1057
characterPress:aKey x:x y:y
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1058
    " a character is pressed - lookup and change selection
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1059
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1060
    |lnNr size idx sensor stp to1 fr2|
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1061
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1062
    (enabled and:[(size := self size) > 1]) ifFalse:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1063
        ^ self
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1064
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1065
    lnNr := self firstInSelection ? 0.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1066
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1067
    ((sensor := self sensor) notNil and:[sensor shiftDown]) ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1068
        stp := -1.              "/ search backward
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1069
        to1 :=  1.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1070
        fr2 := size.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1071
    ] ifFalse:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1072
        stp := 1.               "/ search forward
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1073
        to1 := size.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1074
        fr2 := 1.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1075
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1076
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1077
    idx := self findLineFrom:lnNr+stp to:to1 by:stp startingWithCharacter:aKey.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1078
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1079
    idx == 0 ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1080
        idx := self findLineFrom:fr2 to:lnNr-stp by:stp startingWithCharacter:aKey
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1081
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1082
    idx ~~ 0 ifTrue:[^ self selection:idx]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1083
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1084
1768
04b330a75f75 allow for subclasses to redefine character search
Claus Gittinger <cg@exept.de>
parents: 1758
diff changeset
  1085
characterSearchItemStringAt:anIndex
04b330a75f75 allow for subclasses to redefine character search
Claus Gittinger <cg@exept.de>
parents: 1758
diff changeset
  1086
    |item|
04b330a75f75 allow for subclasses to redefine character search
Claus Gittinger <cg@exept.de>
parents: 1758
diff changeset
  1087
04b330a75f75 allow for subclasses to redefine character search
Claus Gittinger <cg@exept.de>
parents: 1758
diff changeset
  1088
    item := list at:anIndex ifAbsent:nil.
04b330a75f75 allow for subclasses to redefine character search
Claus Gittinger <cg@exept.de>
parents: 1758
diff changeset
  1089
    item isNil ifTrue:[^ item]. 
04b330a75f75 allow for subclasses to redefine character search
Claus Gittinger <cg@exept.de>
parents: 1758
diff changeset
  1090
04b330a75f75 allow for subclasses to redefine character search
Claus Gittinger <cg@exept.de>
parents: 1758
diff changeset
  1091
    ^ item perform:#string ifNotUnderstood:nil.
04b330a75f75 allow for subclasses to redefine character search
Claus Gittinger <cg@exept.de>
parents: 1758
diff changeset
  1092
04b330a75f75 allow for subclasses to redefine character search
Claus Gittinger <cg@exept.de>
parents: 1758
diff changeset
  1093
!
04b330a75f75 allow for subclasses to redefine character search
Claus Gittinger <cg@exept.de>
parents: 1758
diff changeset
  1094
1917
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1095
containerChangedSize
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1096
    "/ stupid kludge for motif-style (which draws a frame at the right-edge)
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1097
    "/ cg: I think it should not (see normal SelectionInListView, which does only
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1098
    "/     draw the frame at the top and bottom, but NOT at the left and right
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1099
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1100
    selection notNil ifTrue:[
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1101
        (hilightFrameColor notNil 
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1102
        or:[hilightStyle == #motif
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1103
        or:[hilightLevel ~~ 0]]) ifTrue:[
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1104
           "/ invalidate the right-edge
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1105
            self invalidate:(((width-3) @ 0) corner:((width-1) @ (height-1))).
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1106
        ]
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1107
    ].
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1108
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1109
    super containerChangedSize.
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1110
!
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1111
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1112
doubleClicked
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1113
    "handle a double click
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1114
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1115
    (doubleClickActionBlock notNil and:[self numberOfSelections == 1]) ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1116
        (doubleClickActionBlock numArgs == 1) ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1117
            doubleClickActionBlock value:(self selectedIndex)
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1118
        ] ifFalse:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1119
            doubleClickActionBlock value
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1120
        ]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1121
    ]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1122
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1123
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1124
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1125
findLineFrom:aStart to:aStop by:aStep startingWithCharacter:aCharacter
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1126
    "find a line starting with a character
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1127
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1128
    |item char lbl cmp
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1129
     size     "{ Class:SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1130
     start    "{ Class:SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1131
     stop     "{ Class:SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1132
    |
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1133
    (size := list size) ~~ 0 ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1134
        aStep > 0 ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1135
            aStart > aStop ifTrue:[^ 0].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1136
        ] ifFalse:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1137
            (aStep == 0 or:[aStop > aStart]) ifTrue:[^ 0]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1138
        ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1139
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1140
        start := aStart < 0 ifTrue:[1] ifFalse:[aStart min:size].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1141
        stop  := aStop  < 0 ifTrue:[1] ifFalse:[aStop  min:size].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1142
        char  := aCharacter asUppercase.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1143
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1144
        start to:stop by:aStep do:[:anIndex|
1920
e3994a83fb16 selectConditionBlock can be a 2-arg block;
martin
parents: 1917
diff changeset
  1145
            (self canSelectIndex:anIndex forAdd:false) ifTrue:[
1772
709e1ad163c0 checkin from browser
tm
parents: 1768
diff changeset
  1146
                lbl := self characterSearchItemStringAt:anIndex.
709e1ad163c0 checkin from browser
tm
parents: 1768
diff changeset
  1147
                lbl notNil ifTrue:[
709e1ad163c0 checkin from browser
tm
parents: 1768
diff changeset
  1148
                    cmp := lbl string at:1 ifAbsent:nil.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1149
1772
709e1ad163c0 checkin from browser
tm
parents: 1768
diff changeset
  1150
                    cmp notNil ifTrue:[
709e1ad163c0 checkin from browser
tm
parents: 1768
diff changeset
  1151
                        (char == cmp or:[char == cmp asUppercase]) ifTrue:[
709e1ad163c0 checkin from browser
tm
parents: 1768
diff changeset
  1152
                            ^ anIndex
709e1ad163c0 checkin from browser
tm
parents: 1768
diff changeset
  1153
                        ]
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1154
                    ]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1155
                ]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1156
            ]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1157
        ]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1158
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1159
    ^ 0
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1160
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1161
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1162
keyPress:aKey x:x y:y
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1163
    "a key was pressed - handle page-keys here
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1164
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1165
    <resource: #keyboard( #Return #CursorUp #CursorDown )>
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1166
1920
e3994a83fb16 selectConditionBlock can be a 2-arg block;
martin
parents: 1917
diff changeset
  1167
    |sensor n size lineNr delta|
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1168
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1169
    enabled ifFalse:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1170
        ^ super keyPress:aKey x:x y:y
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1171
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1172
    aKey == #Return ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1173
        self numberOfSelections == 1 ifTrue:[self doubleClicked].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1174
      ^ self
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1175
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1176
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1177
    aKey isCharacter ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1178
        ^ self characterPress:aKey x:x y:y
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1179
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1180
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1181
    (aKey == #CursorUp or:[aKey == #CursorDown]) ifFalse:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1182
        ^ super keyPress:aKey x:x y:y
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1183
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1184
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1185
    (size := self size) == 0 ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1186
        ^ self
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1187
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1188
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1189
    lineNr := self selectedIndex.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1190
    sensor := self sensor.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1191
1909
c6178de69699 bug fix; handle cursorUp/down
ca
parents: 1818
diff changeset
  1192
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1193
    sensor notNil ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1194
        n := (1 + (sensor compressKeyPressEventsWithKey:aKey)) \\ size.
1909
c6178de69699 bug fix; handle cursorUp/down
ca
parents: 1818
diff changeset
  1195
        n == 0 ifTrue:[n := 1].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1196
    ] ifFalse:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1197
        n := 1
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1198
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1199
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1200
    aKey == #CursorUp ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1201
        lineNr == 0 ifTrue:[lineNr := size + 1].
1772
709e1ad163c0 checkin from browser
tm
parents: 1768
diff changeset
  1202
        (n := lineNr - n) <= 0 ifTrue:[n := size + n].
709e1ad163c0 checkin from browser
tm
parents: 1768
diff changeset
  1203
        lineNr > size ifTrue:[lineNr := size].
1920
e3994a83fb16 selectConditionBlock can be a 2-arg block;
martin
parents: 1917
diff changeset
  1204
        delta := -1.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1205
    ] ifFalse:[
1772
709e1ad163c0 checkin from browser
tm
parents: 1768
diff changeset
  1206
        (n := lineNr + n) > size ifTrue:[n := n - size].
1909
c6178de69699 bug fix; handle cursorUp/down
ca
parents: 1818
diff changeset
  1207
1772
709e1ad163c0 checkin from browser
tm
parents: 1768
diff changeset
  1208
        lineNr == 0 ifTrue:[lineNr := 1].
1920
e3994a83fb16 selectConditionBlock can be a 2-arg block;
martin
parents: 1917
diff changeset
  1209
        delta := 1.
e3994a83fb16 selectConditionBlock can be a 2-arg block;
martin
parents: 1917
diff changeset
  1210
    ].
1772
709e1ad163c0 checkin from browser
tm
parents: 1768
diff changeset
  1211
1920
e3994a83fb16 selectConditionBlock can be a 2-arg block;
martin
parents: 1917
diff changeset
  1212
    "/ TODO: care for shift-Down (add-to-selection)
e3994a83fb16 selectConditionBlock can be a 2-arg block;
martin
parents: 1917
diff changeset
  1213
    [
e3994a83fb16 selectConditionBlock can be a 2-arg block;
martin
parents: 1917
diff changeset
  1214
        self canSelectIndex:n forAdd:false
e3994a83fb16 selectConditionBlock can be a 2-arg block;
martin
parents: 1917
diff changeset
  1215
    ] whileFalse:[
e3994a83fb16 selectConditionBlock can be a 2-arg block;
martin
parents: 1917
diff changeset
  1216
        n := n + delta.
e3994a83fb16 selectConditionBlock can be a 2-arg block;
martin
parents: 1917
diff changeset
  1217
        n > size ifTrue:[n := 1].
e3994a83fb16 selectConditionBlock can be a 2-arg block;
martin
parents: 1917
diff changeset
  1218
        n == 0 ifTrue:[n := size].
e3994a83fb16 selectConditionBlock can be a 2-arg block;
martin
parents: 1917
diff changeset
  1219
        n == lineNr ifTrue:[^ self]
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1220
    ].
1920
e3994a83fb16 selectConditionBlock can be a 2-arg block;
martin
parents: 1917
diff changeset
  1221
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1222
    self selection:n
1917
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1223
!
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1224
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1225
sizeChanged:how
2274
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  1226
    |selectionWasVisible|
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  1227
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  1228
    selectionWasVisible := false.
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  1229
1917
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1230
    "/ stupid kludge for motif-style (which draws a frame at the right-edge)
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1231
    "/ cg: I think it should not (see normal SelectionInListView, which does only
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1232
    "/     draw the frame at the top and bottom, but NOT at the left and right
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1233
    selection notNil ifTrue:[
2275
ca
parents: 2274
diff changeset
  1234
        selectionWasVisible := self isSelectionVisibleIn:(previousExtent ? self extent).
2274
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  1235
1917
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1236
        (hilightFrameColor notNil 
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1237
        or:[hilightStyle == #motif
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1238
        or:[hilightLevel ~~ 0]]) ifTrue:[
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1239
           "/ invalidate the right-edge
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1240
            self invalidate:(((width-3) @ 0) corner:((width-1) @ (height-1))).
2225
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
  1241
        ].
1917
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1242
    ].
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1243
    super sizeChanged:how.
2274
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  1244
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  1245
    selectionWasVisible ifTrue:[
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  1246
        self makeSelectionVisible
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  1247
    ].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1248
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1249
1421
95ac3092660a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1409
diff changeset
  1250
!SelectionInListModelView methodsFor:'focus handling'!
95ac3092660a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1409
diff changeset
  1251
95ac3092660a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1409
diff changeset
  1252
wantsFocusWithPointerEnter
95ac3092660a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1409
diff changeset
  1253
    "return true, if I want the focus when
95ac3092660a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1409
diff changeset
  1254
     the mouse pointer enters"
95ac3092660a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1409
diff changeset
  1255
95ac3092660a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1409
diff changeset
  1256
    |pref|
95ac3092660a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1409
diff changeset
  1257
95ac3092660a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1409
diff changeset
  1258
    pref := UserPreferences current focusFollowsMouse.
95ac3092660a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1409
diff changeset
  1259
    (pref ~~ false
95ac3092660a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1409
diff changeset
  1260
    and:[(styleSheet at:#'selection.requestFocusOnPointerEnter' default:true)
95ac3092660a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1409
diff changeset
  1261
    ]) ifTrue:[
2055
964a2cac4e55 take focus on pointer enter only if the list is not empty.
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
  1262
        list size > 0 ifTrue:[
964a2cac4e55 take focus on pointer enter only if the list is not empty.
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
  1263
            ^ true
964a2cac4e55 take focus on pointer enter only if the list is not empty.
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
  1264
        ]
1421
95ac3092660a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1409
diff changeset
  1265
    ].
95ac3092660a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1409
diff changeset
  1266
    ^ false
95ac3092660a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1409
diff changeset
  1267
! !
95ac3092660a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1409
diff changeset
  1268
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1269
!SelectionInListModelView methodsFor:'initialize / release'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1270
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1271
fetchResources
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1272
    "fetch device colors and ..., to avoid reallocation at redraw time;
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1273
     *** called after a create or snapin to fetch all device resources
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1274
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1275
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1276
    super fetchResources.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1277
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1278
    hilightFgColor    := self colorOnDevice:hilightFgColor.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1279
    hilightBgColor    := self colorOnDevice:hilightBgColor.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1280
    hilightFrameColor := self colorOnDevice:hilightFrameColor.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1281
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1282
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1283
initStyle
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1284
    "setup viewStyle specifics
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1285
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1286
    super initStyle.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1287
2228
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
  1288
    hilightFrameColor   := nil.
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
  1289
    hilightStyle        := DefaultHilightStyle.
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
  1290
    highlightMode       := #label.
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
  1291
    textStartLeft       := 4.
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
  1292
    selectOnButtomMenu  := false.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1293
1741
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
  1294
    super font:(styleSheet fontAt:#'selection.font').
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
  1295
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1296
    device hasGrayscales ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1297
        "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1298
         must get rid of these hard codings
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1299
        "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1300
        (hilightStyle == #next) ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1301
            hilightFgColor := fgColor.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1302
            hilightBgColor := White.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1303
            hilightFrameColor := fgColor
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1304
        ] ifFalse:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1305
            (hilightStyle == #motif) ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1306
                fgColor := White.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1307
                bgColor := Grey.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1308
                viewBackground := bgColor.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1309
                hilightFgColor := bgColor.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1310
                hilightBgColor := fgColor.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1311
            ] ifFalse:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1312
                (hilightStyle == #openwin) ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1313
                    hilightFgColor := fgColor.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1314
                    hilightBgColor := Color grey.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1315
                ]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1316
            ]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1317
        ]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1318
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1319
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1320
    hilightFgColor isNil ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1321
        hilightFgColor := bgColor.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1322
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1323
    hilightBgColor isNil ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1324
        hilightBgColor := fgColor.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1325
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1326
    DefaultForegroundColor notNil ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1327
        fgColor := DefaultForegroundColor
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1328
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1329
    DefaultBackgroundColor notNil ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1330
        bgColor := viewBackground := DefaultBackgroundColor
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1331
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1332
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1333
    DefaultHilightForegroundColor notNil ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1334
        hilightFgColor := DefaultHilightForegroundColor
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1335
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1336
    DefaultHilightBackgroundColor notNil ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1337
        hilightBgColor := DefaultHilightBackgroundColor
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1338
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1339
    DefaultHilightFrameColor notNil ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1340
        hilightFrameColor := DefaultHilightFrameColor
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1341
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1342
1741
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
  1343
    hilightLevel := DefaultHilightLevel ? 0.
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
  1344
    lineSpacing  := (hilightLevel abs > 0) ifTrue:[3] ifFalse:[2].
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
  1345
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1346
    hilightFgColor isNil ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1347
        hilightFgColor := bgColor.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1348
        hilightBgColor := fgColor
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1349
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1350
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1351
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1352
initialize
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1353
    "setup default attributes/behavior
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1354
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1355
    super initialize.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1356
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1357
    multipleSelectOk := false.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1358
    useIndex         := true.
1741
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
  1359
    ignoreReselect   := true.
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
  1360
    toggleSelect     := false.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1361
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1362
1745
4eb3b6b12c99 make selection visible after mapped
ca
parents: 1741
diff changeset
  1363
mapped
4eb3b6b12c99 make selection visible after mapped
ca
parents: 1741
diff changeset
  1364
    "get selection from model; scroll to selection
4eb3b6b12c99 make selection visible after mapped
ca
parents: 1741
diff changeset
  1365
    "
4eb3b6b12c99 make selection visible after mapped
ca
parents: 1741
diff changeset
  1366
    super mapped.
4eb3b6b12c99 make selection visible after mapped
ca
parents: 1741
diff changeset
  1367
    self makeSelectionVisible.
4eb3b6b12c99 make selection visible after mapped
ca
parents: 1741
diff changeset
  1368
!
4eb3b6b12c99 make selection visible after mapped
ca
parents: 1741
diff changeset
  1369
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1370
realize
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1371
    "get selection from model; scroll to selection
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1372
    "
2302
5a2a1d5d09f8 remove asynchronous handling of changes; always disabled because doesn't work
ca
parents: 2275
diff changeset
  1373
    self updateFromModel.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1374
    super realize.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1375
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1376
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  1377
!SelectionInListModelView methodsFor:'private editor'!
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  1378
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  1379
computeEditorLayout
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  1380
    "update the layout of the editor
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  1381
    "
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  1382
    |lnNr item y x h|
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  1383
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  1384
    editorView isNil ifTrue:[
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  1385
        ^ self
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  1386
    ].
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  1387
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  1388
    (    (lnNr := self selectedIndex) == 0
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  1389
     or:[(item := list at:lnNr ifAbsent:nil) isNil]
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  1390
    ) ifTrue:[
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  1391
        "/ there is no more single selection; thus close the editor
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  1392
        ^ self closeEditor
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  1393
    ].
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  1394
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  1395
    y := self yVisibleOfLine:lnNr.
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  1396
    x := (self xVisibleOfItem:item) - (textStartLeft // 2).
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  1397
    h := self yVisibleOfLine:(lnNr + 1).
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  1398
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  1399
    editorView layout:( Rectangle left:x top:y right:(width - 1 - margin) bottom:(h - 1) ).
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  1400
!
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  1401
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  1402
openEditorAtX:x y:y
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  1403
    "opens an editor on the current single selection
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  1404
    "
2225
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
  1405
    |item lnNr x0 y0 editor|
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  1406
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  1407
    self closeEditor.
2308
c012b16422f0 replace ifNotNil: by notNil ifTrue:
ca
parents: 2302
diff changeset
  1408
    shown ifFalse:[^ self ].
c012b16422f0 replace ifNotNil: by notNil ifTrue:
ca
parents: 2302
diff changeset
  1409
    openEditorAction isNil ifTrue:[^ self].
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  1410
2225
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
  1411
    lnNr := self selectedIndex.
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
  1412
    lnNr == 0 ifTrue:[^ self].
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
  1413
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
  1414
    item := list at:lnNr ifAbsent:nil.
2308
c012b16422f0 replace ifNotNil: by notNil ifTrue:
ca
parents: 2302
diff changeset
  1415
    item isNil ifTrue:[^ self].
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  1416
1915
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
  1417
    x < (self xVisibleOfItem:item) ifTrue:[
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
  1418
        "/ not part of the selection frame; ignorre
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
  1419
        ^ self
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  1420
    ].
2225
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
  1421
    editor := self openEditor.
2308
c012b16422f0 replace ifNotNil: by notNil ifTrue:
ca
parents: 2302
diff changeset
  1422
    editor isNil ifTrue:[^ self].
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  1423
2225
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
  1424
    y0 := (y - editor origin y) max:0.
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
  1425
    x0 := (x - editor origin x) max:0.
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  1426
2125
67e0f2c9ad4d event types are private to WindowEvent;
ca
parents: 2070
diff changeset
  1427
    "/ simulate clicking into the editor
2225
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
  1428
    self sensor pushEvent:(WindowEvent buttonPress:#select x:x0 y:y0 view:editor).
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
  1429
    self sensor pushEvent:(WindowEvent buttonRelease:#select x:x0 y:y0 view:editor).
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  1430
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  1431
    "/ to clear the selection
2245
546c6e5d0951 change #redrawSelectionAt: to #invalidateSelectionAt: (because is a invalidate)
ca
parents: 2228
diff changeset
  1432
    self invalidateLineAt:lnNr.
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  1433
! !
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  1434
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1435
!SelectionInListModelView methodsFor:'protocol'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1436
1533
609fce5df829 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1508
diff changeset
  1437
drawElementsFrom:start to:stop x:x y:y w:w
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1438
    "draw the items between start to stop without clearing the background
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1439
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1440
    |y0 "{ Class:SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1441
     y1 "{ Class:SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1442
     x0 "{ Class:SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1443
    |
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1444
    x0 := textStartLeft - viewOrigin x.
1533
609fce5df829 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1508
diff changeset
  1445
    y1 := y.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1446
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1447
    start to:stop do:[:i|
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1448
        y0 := y1.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1449
        y1 := self yVisibleOfLine:(i + 1).
1533
609fce5df829 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1508
diff changeset
  1450
        self drawLabelAt:i x:x0 y:y0 h:(y1 - y0)
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1451
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1452
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1453
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1454
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1455
1458
02d7889dfb9a lostSynchronisation
Claus Gittinger <cg@exept.de>
parents: 1431
diff changeset
  1456
lostSynchronisation
02d7889dfb9a lostSynchronisation
Claus Gittinger <cg@exept.de>
parents: 1431
diff changeset
  1457
    "called when the changes derived from the model are faster than the handling
02d7889dfb9a lostSynchronisation
Claus Gittinger <cg@exept.de>
parents: 1431
diff changeset
  1458
    "
1547
f72d75aaec14 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
  1459
    self deselectWithoutRedraw.
1458
02d7889dfb9a lostSynchronisation
Claus Gittinger <cg@exept.de>
parents: 1431
diff changeset
  1460
    super lostSynchronisation.
1554
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1461
!
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1462
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1463
xVisibleOfItem:anItem
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1464
    "returns the visible x of the labeled text
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1465
    "
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1466
    ^ textStartLeft - viewOrigin x
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1467
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1468
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1469
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1470
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1471
!SelectionInListModelView methodsFor:'selection'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1472
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1473
deselect
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1474
    "clear selection
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1475
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1476
    self selection:nil
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1477
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1478
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1479
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1480
firstInSelection
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1481
    "returns line number of first element selected or nil
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1482
    "
1545
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  1483
    multipleSelectOk ifFalse:[
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  1484
        ^ selection
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1485
    ].
1545
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  1486
    ^ selection isNil ifTrue:[nil] ifFalse:[selection at:1]
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1487
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1488
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1489
hasSelection
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1490
    "returns true if a selection exists
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1491
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1492
    ^ selection notNil
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1493
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1494
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1495
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1496
isInSelection:aNumber
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1497
    "return true, if line, aNumber is in the selection
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1498
    "
1545
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  1499
    multipleSelectOk ifFalse:[
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  1500
        ^ aNumber == selection
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  1501
    ].
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  1502
    ^ selection isNil ifTrue:[false]
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  1503
                     ifFalse:[selection includesIdentical:aNumber]
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1504
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1505
2274
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  1506
isSelectionVisible
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  1507
    "returns true if any selected element is visible"
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  1508
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  1509
    ^ self isSelectionVisibleIn:self extent
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  1510
!
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  1511
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  1512
isSelectionVisibleIn:anExtentPoint
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  1513
    "returns true if any selected element is visible"
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  1514
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  1515
    self selectionDo:[:aLineNr|
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  1516
        (self isLineVisible:aLineNr in:anExtentPoint) ifTrue:[^ true].
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  1517
    ].
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  1518
    ^ false
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  1519
!
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  1520
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1521
numberOfSelections
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1522
    "return the number of selected items
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1523
    "
1545
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  1524
    selection notNil ifTrue:[
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  1525
        ^ multipleSelectOk ifFalse:[1] ifTrue:[selection size]
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  1526
    ].
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  1527
    ^ 0
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1528
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1529
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1530
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1531
selectElement:anElement
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1532
    "select the element. Scroll to make the new selection visible.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1533
     Model and/or actionBlock notification IS done.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1534
    "
2178
f02ca1516c04 selectElement changed
penk
parents: 2148
diff changeset
  1535
    self selectElement:anElement ifAbsent:[self deselect]
f02ca1516c04 selectElement changed
penk
parents: 2148
diff changeset
  1536
!
f02ca1516c04 selectElement changed
penk
parents: 2148
diff changeset
  1537
f02ca1516c04 selectElement changed
penk
parents: 2148
diff changeset
  1538
selectElement:anElement ifAbsent:exceptionalValue
f02ca1516c04 selectElement changed
penk
parents: 2148
diff changeset
  1539
    |idx|
f02ca1516c04 selectElement changed
penk
parents: 2148
diff changeset
  1540
f02ca1516c04 selectElement changed
penk
parents: 2148
diff changeset
  1541
    idx := list identityIndexOf:anElement.
f02ca1516c04 selectElement changed
penk
parents: 2148
diff changeset
  1542
    idx == 0 ifTrue:[
f02ca1516c04 selectElement changed
penk
parents: 2148
diff changeset
  1543
        ^ exceptionalValue value
f02ca1516c04 selectElement changed
penk
parents: 2148
diff changeset
  1544
    ].
f02ca1516c04 selectElement changed
penk
parents: 2148
diff changeset
  1545
    self selection:idx
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1546
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1547
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1548
selectedElement
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1549
    "return the single selected item or nil
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1550
    "
1545
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  1551
    |index|
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1552
1545
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  1553
    (index := self selectedIndex) ~~ 0 ifTrue:[
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  1554
        ^ list at:index ifAbsent:nil
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  1555
    ].
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  1556
    ^ nil
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1557
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1558
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1559
selectedIndex
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1560
    "returns the index of the selected line or 0. If more
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1561
     lines are selected, 0 is returned
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1562
    "
1545
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  1563
    self numberOfSelections == 1 ifTrue:[
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  1564
        ^ self firstInSelection
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  1565
    ].
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  1566
    ^ 0
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1567
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1568
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1569
selection
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1570
    "return the selection index or collection of indices 
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1571
     in case of multiple selection enabled
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1572
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1573
    ^ selection
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1574
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1575
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1576
1545
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  1577
selection:something
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  1578
    "select something or deselect if the argument is nil;
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1579
     scroll to make the selected line visible.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1580
     The model and/or actionBlock IS notified.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1581
    "
1545
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  1582
    (self selectWithoutScroll:something redraw:true) ifTrue:[
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  1583
        self makeSelectionVisible.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1584
        self selectionChanged
1545
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  1585
    ].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1586
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1587
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1588
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1589
selectionDo:aBlock
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1590
    "perform aBlock for each nr in the selection.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1591
     For single selection, it is called once for the items nr.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1592
     For multiple selections, it is called for each.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1593
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1594
    selection notNil ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1595
        multipleSelectOk ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1596
            selection do:aBlock
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1597
        ] ifFalse:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1598
            aBlock value:selection
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1599
        ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1600
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1601
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1602
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1603
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1604
1542
8607d072c319 accessing selection through to selector
Claus Gittinger <cg@exept.de>
parents: 1537
diff changeset
  1605
setSelection:something
1545
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  1606
    "select something or deselect if the argument is nil;
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1607
     scroll to make the selected line visible.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1608
     *** No model and/or actionBlock notification is done here.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1609
    "
1545
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  1610
    (self selectWithoutScroll:something redraw:true) ifTrue:[
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1611
        self makeSelectionVisible
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1612
    ]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1613
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1614
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1615
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1616
!SelectionInListModelView methodsFor:'selection private'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1617
1641
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
  1618
canSelectIndex:anIndex
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
  1619
    "return true, if the object identified by its index is selectable
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
  1620
    "
1920
e3994a83fb16 selectConditionBlock can be a 2-arg block;
martin
parents: 1917
diff changeset
  1621
    ^ self canSelectIndex:anIndex forAdd:false
e3994a83fb16 selectConditionBlock can be a 2-arg block;
martin
parents: 1917
diff changeset
  1622
!
e3994a83fb16 selectConditionBlock can be a 2-arg block;
martin
parents: 1917
diff changeset
  1623
e3994a83fb16 selectConditionBlock can be a 2-arg block;
martin
parents: 1917
diff changeset
  1624
canSelectIndex:anIndex forAdd:isForAdd
e3994a83fb16 selectConditionBlock can be a 2-arg block;
martin
parents: 1917
diff changeset
  1625
    "return true, if the object identified by its index is selectable
e3994a83fb16 selectConditionBlock can be a 2-arg block;
martin
parents: 1917
diff changeset
  1626
    "
e3994a83fb16 selectConditionBlock can be a 2-arg block;
martin
parents: 1917
diff changeset
  1627
    |item isOk|
1649
60cf82a7d585 checkin from browser
ps
parents: 1644
diff changeset
  1628
60cf82a7d585 checkin from browser
ps
parents: 1644
diff changeset
  1629
    selectConditionBlock notNil ifTrue:[
1920
e3994a83fb16 selectConditionBlock can be a 2-arg block;
martin
parents: 1917
diff changeset
  1630
        selectConditionBlock numArgs == 2 ifTrue:[
e3994a83fb16 selectConditionBlock can be a 2-arg block;
martin
parents: 1917
diff changeset
  1631
            isOk := selectConditionBlock value:anIndex value:isForAdd.
e3994a83fb16 selectConditionBlock can be a 2-arg block;
martin
parents: 1917
diff changeset
  1632
        ] ifFalse:[
e3994a83fb16 selectConditionBlock can be a 2-arg block;
martin
parents: 1917
diff changeset
  1633
            isOk := selectConditionBlock value:anIndex.
e3994a83fb16 selectConditionBlock can be a 2-arg block;
martin
parents: 1917
diff changeset
  1634
        ].
e3994a83fb16 selectConditionBlock can be a 2-arg block;
martin
parents: 1917
diff changeset
  1635
        isOk ifFalse:[
1649
60cf82a7d585 checkin from browser
ps
parents: 1644
diff changeset
  1636
            ^ false
60cf82a7d585 checkin from browser
ps
parents: 1644
diff changeset
  1637
        ]
1641
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
  1638
    ].
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
  1639
1752
1c11b6e4ab37 use isHierarchicalItem instead of hack variable
ca
parents: 1748
diff changeset
  1640
    item := list at:anIndex ifAbsent:nil.
1c11b6e4ab37 use isHierarchicalItem instead of hack variable
ca
parents: 1748
diff changeset
  1641
    item isNil ifTrue:[^ false].
1c11b6e4ab37 use isHierarchicalItem instead of hack variable
ca
parents: 1748
diff changeset
  1642
    item isHierarchicalItem ifTrue:[
1649
60cf82a7d585 checkin from browser
ps
parents: 1644
diff changeset
  1643
      ^ item isSelectable
60cf82a7d585 checkin from browser
ps
parents: 1644
diff changeset
  1644
    ].
60cf82a7d585 checkin from browser
ps
parents: 1644
diff changeset
  1645
    ^ true
1641
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
  1646
!
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
  1647
1547
f72d75aaec14 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
  1648
deselectWithoutRedraw
f72d75aaec14 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
  1649
    "clear the selection without redraw and scrolling;
f72d75aaec14 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
  1650
     the model and/or actionBlock is notified
f72d75aaec14 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
  1651
    "
f72d75aaec14 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
  1652
    (self selectWithoutScroll:nil redraw:false) ifTrue:[
f72d75aaec14 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
  1653
        self selectionChanged
f72d75aaec14 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
  1654
    ]
f72d75aaec14 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
  1655
!
f72d75aaec14 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
  1656
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1657
makeSelectionVisible
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1658
    "scroll to make the selection line visible
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1659
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1660
    |lineNr|
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1661
1564
6c73d2b8c0e7 checkin from browser
ca
parents: 1563
diff changeset
  1662
    lineNr := self firstInSelection.
6c73d2b8c0e7 checkin from browser
ca
parents: 1563
diff changeset
  1663
6c73d2b8c0e7 checkin from browser
ca
parents: 1563
diff changeset
  1664
    lineNr notNil ifTrue:[
6c73d2b8c0e7 checkin from browser
ca
parents: 1563
diff changeset
  1665
        self scrollToLine:lineNr
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1666
    ]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1667
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1668
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1669
1545
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  1670
selectWithoutScroll:something redraw:doRedraw
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  1671
    "change selection to something; returns true if selection changed
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1672
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1673
    |oldSelect|
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1674
1554
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1675
    selection = something ifTrue:[^ false].
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1676
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1677
    oldSelect := selection.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1678
1545
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  1679
    (something isNil or:[something == 0]) ifTrue:[
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  1680
        selection := nil
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  1681
    ] ifFalse:[
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  1682
        something isNumber ifTrue:[
1564
6c73d2b8c0e7 checkin from browser
ca
parents: 1563
diff changeset
  1683
            selection := multipleSelectOk ifTrue:[Array with:something]
6c73d2b8c0e7 checkin from browser
ca
parents: 1563
diff changeset
  1684
                                         ifFalse:[something]
1545
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  1685
        ] ifFalse:[
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  1686
            something size == 0 ifTrue:[
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  1687
                selection := nil
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  1688
            ] ifFalse:[
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  1689
                selection := multipleSelectOk ifTrue:[something]
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  1690
                                             ifFalse:[something at:1]
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  1691
            ]
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  1692
        ]
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  1693
    ].
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  1694
    selection = oldSelect ifTrue:[^ false].
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  1695
    self closeEditor.
1545
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  1696
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  1697
    (doRedraw and:[shown]) ifFalse:[
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  1698
        ^ true
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1699
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1700
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1701
    multipleSelectOk ifFalse:[
2245
546c6e5d0951 change #redrawSelectionAt: to #invalidateSelectionAt: (because is a invalidate)
ca
parents: 2228
diff changeset
  1702
        oldSelect notNil ifTrue:[self invalidateSelectionAt:oldSelect].
546c6e5d0951 change #redrawSelectionAt: to #invalidateSelectionAt: (because is a invalidate)
ca
parents: 2228
diff changeset
  1703
        selection notNil ifTrue:[self invalidateSelectionAt:selection].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1704
    ] ifTrue:[
1545
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  1705
        (selection notNil and:[oldSelect notNil]) ifTrue:[
2245
546c6e5d0951 change #redrawSelectionAt: to #invalidateSelectionAt: (because is a invalidate)
ca
parents: 2228
diff changeset
  1706
            selection do:[:i|(oldSelect includesIdentical:i) ifFalse:[self invalidateSelectionAt:i]].
546c6e5d0951 change #redrawSelectionAt: to #invalidateSelectionAt: (because is a invalidate)
ca
parents: 2228
diff changeset
  1707
            oldSelect do:[:i|(selection includesIdentical:i) ifFalse:[self invalidateSelectionAt:i]].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1708
        ] ifFalse:[
1545
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  1709
            oldSelect isNil ifTrue:[oldSelect := selection].
2245
546c6e5d0951 change #redrawSelectionAt: to #invalidateSelectionAt: (because is a invalidate)
ca
parents: 2228
diff changeset
  1710
            oldSelect do:[:i|self invalidateSelectionAt:i]
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1711
        ]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1712
    ].
1545
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  1713
    ^ true
1561
edac7f38341b use toggle selection insteat of addTo or remove from
ca
parents: 1557
diff changeset
  1714
!
edac7f38341b use toggle selection insteat of addTo or remove from
ca
parents: 1557
diff changeset
  1715
edac7f38341b use toggle selection insteat of addTo or remove from
ca
parents: 1557
diff changeset
  1716
toggleSelection:aNumber
edac7f38341b use toggle selection insteat of addTo or remove from
ca
parents: 1557
diff changeset
  1717
    "add a number to the selection. No scrolling is done.
edac7f38341b use toggle selection insteat of addTo or remove from
ca
parents: 1557
diff changeset
  1718
     *** No model and/or actionBlock notification is done here.
edac7f38341b use toggle selection insteat of addTo or remove from
ca
parents: 1557
diff changeset
  1719
    "
2245
546c6e5d0951 change #redrawSelectionAt: to #invalidateSelectionAt: (because is a invalidate)
ca
parents: 2228
diff changeset
  1720
    |oldSelect doRemove|
1561
edac7f38341b use toggle selection insteat of addTo or remove from
ca
parents: 1557
diff changeset
  1721
edac7f38341b use toggle selection insteat of addTo or remove from
ca
parents: 1557
diff changeset
  1722
    multipleSelectOk ifFalse:[
edac7f38341b use toggle selection insteat of addTo or remove from
ca
parents: 1557
diff changeset
  1723
        aNumber == selection ifTrue:[                   "/ remove from selection
edac7f38341b use toggle selection insteat of addTo or remove from
ca
parents: 1557
diff changeset
  1724
            selection := nil.
edac7f38341b use toggle selection insteat of addTo or remove from
ca
parents: 1557
diff changeset
  1725
        ] ifFalse:[                                     "/ add to selection
edac7f38341b use toggle selection insteat of addTo or remove from
ca
parents: 1557
diff changeset
  1726
            oldSelect := selection.
edac7f38341b use toggle selection insteat of addTo or remove from
ca
parents: 1557
diff changeset
  1727
            selection := aNumber.
edac7f38341b use toggle selection insteat of addTo or remove from
ca
parents: 1557
diff changeset
  1728
edac7f38341b use toggle selection insteat of addTo or remove from
ca
parents: 1557
diff changeset
  1729
            oldSelect notNil ifTrue:[
2245
546c6e5d0951 change #redrawSelectionAt: to #invalidateSelectionAt: (because is a invalidate)
ca
parents: 2228
diff changeset
  1730
                self invalidateSelectionAt:oldSelect
1561
edac7f38341b use toggle selection insteat of addTo or remove from
ca
parents: 1557
diff changeset
  1731
            ]
edac7f38341b use toggle selection insteat of addTo or remove from
ca
parents: 1557
diff changeset
  1732
        ].
2245
546c6e5d0951 change #redrawSelectionAt: to #invalidateSelectionAt: (because is a invalidate)
ca
parents: 2228
diff changeset
  1733
        self invalidateSelectionAt:aNumber.
1561
edac7f38341b use toggle selection insteat of addTo or remove from
ca
parents: 1557
diff changeset
  1734
      ^ self
edac7f38341b use toggle selection insteat of addTo or remove from
ca
parents: 1557
diff changeset
  1735
    ].
edac7f38341b use toggle selection insteat of addTo or remove from
ca
parents: 1557
diff changeset
  1736
edac7f38341b use toggle selection insteat of addTo or remove from
ca
parents: 1557
diff changeset
  1737
    selection isNil ifTrue:[                            "/ add to empty selection
edac7f38341b use toggle selection insteat of addTo or remove from
ca
parents: 1557
diff changeset
  1738
        selection := OrderedCollection with:aNumber.
2245
546c6e5d0951 change #redrawSelectionAt: to #invalidateSelectionAt: (because is a invalidate)
ca
parents: 2228
diff changeset
  1739
        self invalidateSelectionAt:aNumber.
1561
edac7f38341b use toggle selection insteat of addTo or remove from
ca
parents: 1557
diff changeset
  1740
      ^ self
edac7f38341b use toggle selection insteat of addTo or remove from
ca
parents: 1557
diff changeset
  1741
    ].
edac7f38341b use toggle selection insteat of addTo or remove from
ca
parents: 1557
diff changeset
  1742
edac7f38341b use toggle selection insteat of addTo or remove from
ca
parents: 1557
diff changeset
  1743
    doRemove := selection includesIdentical:aNumber.
edac7f38341b use toggle selection insteat of addTo or remove from
ca
parents: 1557
diff changeset
  1744
edac7f38341b use toggle selection insteat of addTo or remove from
ca
parents: 1557
diff changeset
  1745
    (doRemove and:[selection size == 1]) ifTrue:[       "/ remove selection
edac7f38341b use toggle selection insteat of addTo or remove from
ca
parents: 1557
diff changeset
  1746
        selection := nil.
2245
546c6e5d0951 change #redrawSelectionAt: to #invalidateSelectionAt: (because is a invalidate)
ca
parents: 2228
diff changeset
  1747
        self invalidateSelectionAt:aNumber.
1561
edac7f38341b use toggle selection insteat of addTo or remove from
ca
parents: 1557
diff changeset
  1748
      ^ self
edac7f38341b use toggle selection insteat of addTo or remove from
ca
parents: 1557
diff changeset
  1749
    ].
edac7f38341b use toggle selection insteat of addTo or remove from
ca
parents: 1557
diff changeset
  1750
edac7f38341b use toggle selection insteat of addTo or remove from
ca
parents: 1557
diff changeset
  1751
    selection := selection asOrderedCollection.
edac7f38341b use toggle selection insteat of addTo or remove from
ca
parents: 1557
diff changeset
  1752
edac7f38341b use toggle selection insteat of addTo or remove from
ca
parents: 1557
diff changeset
  1753
    doRemove ifTrue:[
edac7f38341b use toggle selection insteat of addTo or remove from
ca
parents: 1557
diff changeset
  1754
        selection removeIdentical:aNumber.
edac7f38341b use toggle selection insteat of addTo or remove from
ca
parents: 1557
diff changeset
  1755
    ] ifFalse:[
edac7f38341b use toggle selection insteat of addTo or remove from
ca
parents: 1557
diff changeset
  1756
        selection add:aNumber.
edac7f38341b use toggle selection insteat of addTo or remove from
ca
parents: 1557
diff changeset
  1757
    ].
2245
546c6e5d0951 change #redrawSelectionAt: to #invalidateSelectionAt: (because is a invalidate)
ca
parents: 2228
diff changeset
  1758
    self invalidateSelectionAt:aNumber.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1759
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1760
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1761
!SelectionInListModelView class methodsFor:'documentation'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1762
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1763
version
2308
c012b16422f0 replace ifNotNil: by notNil ifTrue:
ca
parents: 2302
diff changeset
  1764
    ^ '$Header: /cvs/stx/stx/libwidg2/SelectionInListModelView.st,v 1.58 2002-10-17 16:04:42 ca Exp $'
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1765
! !