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