SelectionInListModelView.st
author Stefan Vogel <sv@exept.de>
Fri, 06 Mar 2020 12:57:19 +0100
changeset 6236 ddfc83270532
parent 6201 f62406ae4f1e
permissions -rw-r--r--
#REFACTORING by stefan class: DSVColumnView changed: #initStyle (send #passiveLevel instead of #offLevel) obsolete method usage
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
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
     3
	      All Rights Reserved
1431
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
"
1752
1c11b6e4ab37 use isHierarchicalItem instead of hack variable
ca
parents: 1748
diff changeset
    12
"{ Package: 'stx:libwidg2' }"
1c11b6e4ab37 use isHierarchicalItem instead of hack variable
ca
parents: 1748
diff changeset
    13
4692
433047d28c93 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
    14
"{ NameSpace: Smalltalk }"
433047d28c93 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
    15
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
ListModelView subclass:#SelectionInListModelView
4571
bf04b7618d7c class: SelectionInListModelView
Stefan Vogel <sv@exept.de>
parents: 4570
diff changeset
    17
	instanceVariableNames:'selection multipleSelectOk actionBlock doubleClickActionBlock
bf04b7618d7c class: SelectionInListModelView
Stefan Vogel <sv@exept.de>
parents: 4570
diff changeset
    18
		selectConditionBlock buttonMotionAction buttonReleaseAction
bf04b7618d7c class: SelectionInListModelView
Stefan Vogel <sv@exept.de>
parents: 4570
diff changeset
    19
		highlightMode useIndex ignoreReselect toggleSelect hilightFgColor
bf04b7618d7c class: SelectionInListModelView
Stefan Vogel <sv@exept.de>
parents: 4570
diff changeset
    20
		hilightBgColor hilightFgColorNoFocus hilightBgColorNoFocus
bf04b7618d7c class: SelectionInListModelView
Stefan Vogel <sv@exept.de>
parents: 4570
diff changeset
    21
		hilightLevel hilightFrameColor hilightStyle dropSource editorView
bf04b7618d7c class: SelectionInListModelView
Stefan Vogel <sv@exept.de>
parents: 4570
diff changeset
    22
		openEditorAction closeEditorAction highlightEnterItem enterItem
bf04b7618d7c class: SelectionInListModelView
Stefan Vogel <sv@exept.de>
parents: 4570
diff changeset
    23
		cursorItem lineMask keyActionStyle returnKeyActionStyle strikeOut
bf04b7618d7c class: SelectionInListModelView
Stefan Vogel <sv@exept.de>
parents: 4570
diff changeset
    24
		modelChangedDuringButtonPress selectOnButtonPress
bf04b7618d7c class: SelectionInListModelView
Stefan Vogel <sv@exept.de>
parents: 4570
diff changeset
    25
		selectOnMenuButton minimumEditorHeight extraSpaceAtBottomForDrop'
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
	classVariableNames:'DefaultHilightStyle DefaultHilightBackgroundColor
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
		DefaultHilightForegroundColor DefaultHilightLevel
4648
5c5c17b052fb class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4647
diff changeset
    28
		DefaultHilightFrameColor DefaultHilightBackgroundColorNoFocus
6201
f62406ae4f1e #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6167
diff changeset
    29
		DefaultHilightForegroundColorNoFocus DefaultHilightMode'
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
	poolDictionaries:''
1430
ae9e48cc7b9d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1423
diff changeset
    31
	category:'Views-Lists'
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
!SelectionInListModelView class methodsFor:'documentation'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
1431
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    36
copyright
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    37
"
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    38
 COPYRIGHT (c) 1999 by eXept Software AG
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
    39
	      All Rights Reserved
1431
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    40
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    41
 This software is furnished under a license and may be used
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    42
 only in accordance with the terms of that license and with the
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    43
 inclusion of the above copyright notice.   This software may not
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    44
 be provided or otherwise made available to, or used by, any
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    45
 other person.  No title to or ownership of the software is
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    46
 hereby transferred.
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    47
"
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    48
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    49
!
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    50
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
documentation
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
    SelectionInListModelView is mostly like SelectionInListView,
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
    but derives from the ListModelView and thus the list is kept
3387
6da21b625d1e warning comments
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
    55
    in the list.
6da21b625d1e warning comments
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
    56
6024
97bae68dd170 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
    57
    ATTENTION (warning by cg):
97bae68dd170 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
    58
        in contrast to its inappropriate name, this class COMPLETELY ignores the model
97bae68dd170 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
    59
        instance variable - all is through the list/listHolder.
97bae68dd170 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
    60
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
    [Instance variables:]
2228
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
    62
4571
bf04b7618d7c class: SelectionInListModelView
Stefan Vogel <sv@exept.de>
parents: 4570
diff changeset
    63
        selection               <misc>       the current selection. nil, a number or collection of numbers
bf04b7618d7c class: SelectionInListModelView
Stefan Vogel <sv@exept.de>
parents: 4570
diff changeset
    64
        multipleSelectOk        <Boolean>    allow/disallow multiple selections( default:false )
bf04b7618d7c class: SelectionInListModelView
Stefan Vogel <sv@exept.de>
parents: 4570
diff changeset
    65
        selectMenuButton        <Boolean>    enable/disable selection will change on menu pressed
bf04b7618d7c class: SelectionInListModelView
Stefan Vogel <sv@exept.de>
parents: 4570
diff changeset
    66
bf04b7618d7c class: SelectionInListModelView
Stefan Vogel <sv@exept.de>
parents: 4570
diff changeset
    67
        buttonReleaseAction     <Action>     called if the mouse button is released
bf04b7618d7c class: SelectionInListModelView
Stefan Vogel <sv@exept.de>
parents: 4570
diff changeset
    68
        buttonMotionAction      <Action>     called during mouse motion with one argument the point
bf04b7618d7c class: SelectionInListModelView
Stefan Vogel <sv@exept.de>
parents: 4570
diff changeset
    69
                                             under the mouse.
bf04b7618d7c class: SelectionInListModelView
Stefan Vogel <sv@exept.de>
parents: 4570
diff changeset
    70
bf04b7618d7c class: SelectionInListModelView
Stefan Vogel <sv@exept.de>
parents: 4570
diff changeset
    71
        actionBlock             <Block>      action evaluated on single click (0/1/2 arguments)
bf04b7618d7c class: SelectionInListModelView
Stefan Vogel <sv@exept.de>
parents: 4570
diff changeset
    72
        doubleClickActionBlock  <Block>      action evaluated on double click (0/1/2 arguments)
bf04b7618d7c class: SelectionInListModelView
Stefan Vogel <sv@exept.de>
parents: 4570
diff changeset
    73
        selectConditionBlock    <Block>      action evaluated before selection changed (0/1/2 arguments)
bf04b7618d7c class: SelectionInListModelView
Stefan Vogel <sv@exept.de>
parents: 4570
diff changeset
    74
bf04b7618d7c class: SelectionInListModelView
Stefan Vogel <sv@exept.de>
parents: 4570
diff changeset
    75
        keyActionStyle          <Symbol>     controls how to respond to keyboard selects
bf04b7618d7c class: SelectionInListModelView
Stefan Vogel <sv@exept.de>
parents: 4570
diff changeset
    76
        returnKeyActionStyle    <Symbol>     controls how to respond to return key
bf04b7618d7c class: SelectionInListModelView
Stefan Vogel <sv@exept.de>
parents: 4570
diff changeset
    77
bf04b7618d7c class: SelectionInListModelView
Stefan Vogel <sv@exept.de>
parents: 4570
diff changeset
    78
        useIndex                <Boolean>    representation of the model selection
bf04b7618d7c class: SelectionInListModelView
Stefan Vogel <sv@exept.de>
parents: 4570
diff changeset
    79
bf04b7618d7c class: SelectionInListModelView
Stefan Vogel <sv@exept.de>
parents: 4570
diff changeset
    80
        ignoreReselect          <Boolean>    if set, a click on an already selected entry is ignored
bf04b7618d7c class: SelectionInListModelView
Stefan Vogel <sv@exept.de>
parents: 4570
diff changeset
    81
        toggleSelect            <Boolean>    a click on an entry unselects it and vice versa
bf04b7618d7c class: SelectionInListModelView
Stefan Vogel <sv@exept.de>
parents: 4570
diff changeset
    82
bf04b7618d7c class: SelectionInListModelView
Stefan Vogel <sv@exept.de>
parents: 4570
diff changeset
    83
        highlightMode           <Symbol>     how to draw the selection
bf04b7618d7c class: SelectionInListModelView
Stefan Vogel <sv@exept.de>
parents: 4570
diff changeset
    84
        hilightFgColor          <Color>      foregroundColor of highlighted items
bf04b7618d7c class: SelectionInListModelView
Stefan Vogel <sv@exept.de>
parents: 4570
diff changeset
    85
        hilightBgColor          <Color>      backgroundColor of highlighted items
bf04b7618d7c class: SelectionInListModelView
Stefan Vogel <sv@exept.de>
parents: 4570
diff changeset
    86
        hilightLevel            <Integer>    level to draw selections (i.e. for 3D effect)
bf04b7618d7c class: SelectionInListModelView
Stefan Vogel <sv@exept.de>
parents: 4570
diff changeset
    87
        hilightFrameColor       <Color>      rectangle around highlighted items
bf04b7618d7c class: SelectionInListModelView
Stefan Vogel <sv@exept.de>
parents: 4570
diff changeset
    88
        hilightStyle            <Boolean>    actions on widget are enabled/disabled
bf04b7618d7c class: SelectionInListModelView
Stefan Vogel <sv@exept.de>
parents: 4570
diff changeset
    89
        strikeOut               <Boolean>    turn on/off strikeOut mode
bf04b7618d7c class: SelectionInListModelView
Stefan Vogel <sv@exept.de>
parents: 4570
diff changeset
    90
bf04b7618d7c class: SelectionInListModelView
Stefan Vogel <sv@exept.de>
parents: 4570
diff changeset
    91
        dropTarget              <DropTarget> keeps information about the drop operation
bf04b7618d7c class: SelectionInListModelView
Stefan Vogel <sv@exept.de>
parents: 4570
diff changeset
    92
        dropSource              <DropSource> keeps information about the drag operation
bf04b7618d7c class: SelectionInListModelView
Stefan Vogel <sv@exept.de>
parents: 4570
diff changeset
    93
bf04b7618d7c class: SelectionInListModelView
Stefan Vogel <sv@exept.de>
parents: 4570
diff changeset
    94
        editorView              <View>       editor on current selected item
bf04b7618d7c class: SelectionInListModelView
Stefan Vogel <sv@exept.de>
parents: 4570
diff changeset
    95
        openEditorAction        <Action>     action to get an editor on the current selection from user
bf04b7618d7c class: SelectionInListModelView
Stefan Vogel <sv@exept.de>
parents: 4570
diff changeset
    96
        closeEditorAction       <Action>     action invoked before the editor is closed.
bf04b7618d7c class: SelectionInListModelView
Stefan Vogel <sv@exept.de>
parents: 4570
diff changeset
    97
bf04b7618d7c class: SelectionInListModelView
Stefan Vogel <sv@exept.de>
parents: 4570
diff changeset
    98
        enterItem               <Item/nil>   item over which the mouse pointer is located
bf04b7618d7c class: SelectionInListModelView
Stefan Vogel <sv@exept.de>
parents: 4570
diff changeset
    99
                                             or nil
bf04b7618d7c class: SelectionInListModelView
Stefan Vogel <sv@exept.de>
parents: 4570
diff changeset
   100
        highlightEnterItem      <Boolean>    enable or disable highlight of enterItem
2323
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
   101
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
    [author:]
4571
bf04b7618d7c class: SelectionInListModelView
Stefan Vogel <sv@exept.de>
parents: 4570
diff changeset
   103
        Claus Atzkern
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
    [see also:]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   106
4571
bf04b7618d7c class: SelectionInListModelView
Stefan Vogel <sv@exept.de>
parents: 4570
diff changeset
   107
        ListModelView
bf04b7618d7c class: SelectionInListModelView
Stefan Vogel <sv@exept.de>
parents: 4570
diff changeset
   108
        HierarchicalListView
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   109
"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   110
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
examples
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
"
5810
458783339a12 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5807
diff changeset
   114
                                                                        [exBegin]
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   115
    |top list view|
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   116
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   117
    list := List new.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
    1 to:100 do:[:i| list add:('element: ', i printString) ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   120
    top  := StandardSystemView new; extent:300@300.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   121
    view := ScrollableView for:SelectionInListModelView miniScroller:true
5810
458783339a12 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5807
diff changeset
   122
                        origin:0.0@0.0 corner:1.0@1.0 in:top.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   123
    view list:list.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   124
    top  open.
5810
458783339a12 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5807
diff changeset
   125
                                                                        [exEnd]
458783339a12 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5807
diff changeset
   126
458783339a12 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5807
diff changeset
   127
458783339a12 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5807
diff changeset
   128
                                                                        [exBegin]
1915
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
   129
    |top list view|
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
   130
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
   131
    list := List new.
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
   132
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
   133
    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
   134
    top  := StandardSystemView new; extent:300@300.
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
   135
    view := ScrollableView for:SelectionInListModelView miniScroller:true
5810
458783339a12 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5807
diff changeset
   136
                        origin:0.0@0.0 corner:1.0@1.0 in:top.
1915
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
   137
    view list:list.
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
   138
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
   139
    view openEditorAction:[:ln :aGC| |field|
5810
458783339a12 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5807
diff changeset
   140
        field := EditField new.
458783339a12 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5807
diff changeset
   141
        field level:0.
458783339a12 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5807
diff changeset
   142
        field acceptOnLostFocus:true.
458783339a12 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5807
diff changeset
   143
        field acceptAction:[:x| list at:ln put:(field contents) ].
458783339a12 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5807
diff changeset
   144
        field font:(aGC font).
458783339a12 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5807
diff changeset
   145
        field contents:(list at:ln).
458783339a12 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5807
diff changeset
   146
        field
1915
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
   147
    ].
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
   148
    top open.
5810
458783339a12 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5807
diff changeset
   149
                                                                        [exEnd]
458783339a12 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5807
diff changeset
   150
458783339a12 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5807
diff changeset
   151
                                                                        [exBegin]
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   152
    |top list view item|
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   153
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   154
    list := HierarchicalList new.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   155
    item := HierarchicalItem::Example labeled:'Test'.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   156
    item expand.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   157
    list showRoot:false.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   158
    list root:item.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   159
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   160
    top  := StandardSystemView new; extent:300@300.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   161
    view := ScrollableView for:SelectionInListModelView miniScroller:true
5810
458783339a12 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5807
diff changeset
   162
                        origin:0.0@0.0 corner:1.0@1.0 in:top.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   163
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   164
    view list:list.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   165
    view doubleClickAction:[:i| (list at:i) toggleExpand ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   166
    top  open.
5810
458783339a12 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5807
diff changeset
   167
                                                                        [exEnd]
458783339a12 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5807
diff changeset
   168
458783339a12 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5807
diff changeset
   169
  ca
458783339a12 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5807
diff changeset
   170
    |top list view|
458783339a12 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5807
diff changeset
   171
458783339a12 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5807
diff changeset
   172
    list := List new.
458783339a12 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5807
diff changeset
   173
458783339a12 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5807
diff changeset
   174
    1 to:100 do:[:i| list add:('element: ', i printString) ].
458783339a12 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5807
diff changeset
   175
458783339a12 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5807
diff changeset
   176
    top  := StandardSystemView extent:300@300.
458783339a12 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5807
diff changeset
   177
    view := ScrollableView for:SelectionInListModelView miniScroller:true
458783339a12 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5807
diff changeset
   178
                        origin:0.0@0.0 corner:1.0@1.0 in:top.
458783339a12 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5807
diff changeset
   179
458783339a12 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5807
diff changeset
   180
    view minimumEditorHeight:100.
458783339a12 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5807
diff changeset
   181
    view openEditorAction:[:ln :aGC| |f|
458783339a12 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5807
diff changeset
   182
        f := SimpleView in:aGC.
458783339a12 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5807
diff changeset
   183
        f viewBackground:(Color red).
458783339a12 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5807
diff changeset
   184
        f
458783339a12 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5807
diff changeset
   185
    ].
458783339a12 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5807
diff changeset
   186
    view list:list.
458783339a12 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5807
diff changeset
   187
    top  open.
1390
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
!SelectionInListModelView class methodsFor:'defaults'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   192
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   193
updateStyleCache
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   194
    "extract values from the styleSheet and cache them in class variables"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   195
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   196
    <resource: #style   (
3927
Claus Gittinger <cg@exept.de>
parents: 3918
diff changeset
   197
                        #'selection.hilightForegroundColor' #'selection.hilightBackgroundColor'
4648
5c5c17b052fb class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4647
diff changeset
   198
                        #'selection.hilightForegroundColorNoFocus' #'selection.hilightBackgroundColorNoFocus'
3927
Claus Gittinger <cg@exept.de>
parents: 3918
diff changeset
   199
                        #'selection.hilightFrameColor'      #'selection.hilightLevel'
Claus Gittinger <cg@exept.de>
parents: 3918
diff changeset
   200
                        #'selection.foregroundColor'        #'selection.backgroundColor'
Claus Gittinger <cg@exept.de>
parents: 3918
diff changeset
   201
                        #'selection.shadowColor'            #'selection.lightColor'
6201
f62406ae4f1e #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6167
diff changeset
   202
                        #'selection.font'                   
f62406ae4f1e #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6167
diff changeset
   203
                        #'selection.hilightStyle'
f62406ae4f1e #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6167
diff changeset
   204
                        #'selection.highlightMode'
3927
Claus Gittinger <cg@exept.de>
parents: 3918
diff changeset
   205
                        #'text.foregroundColor'
Claus Gittinger <cg@exept.de>
parents: 3918
diff changeset
   206
                        )>
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   207
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   208
    DefaultHilightForegroundColor  := StyleSheet colorAt:'selection.hilightForegroundColor'.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   209
    DefaultHilightBackgroundColor  := StyleSheet colorAt:'selection.hilightBackgroundColor'.
4648
5c5c17b052fb class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4647
diff changeset
   210
    DefaultHilightForegroundColorNoFocus  := StyleSheet colorAt:'selection.hilightForegroundColorNoFocus'.
5c5c17b052fb class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4647
diff changeset
   211
    DefaultHilightBackgroundColorNoFocus  := StyleSheet colorAt:'selection.hilightBackgroundColorNoFocus'.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   212
    DefaultHilightFrameColor       := StyleSheet colorAt:'selection.hilightFrameColor'.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   213
    DefaultHilightLevel            := StyleSheet at:'selection.hilightLevel' default:0.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   214
    DefaultHilightStyle            := StyleSheet at:'selection.hilightStyle' default:(StyleSheet name).
6201
f62406ae4f1e #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6167
diff changeset
   215
    DefaultHilightMode             := StyleSheet at:'selection.hilightMode' default:#label. "/ or #line
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   216
    DefaultForegroundColor         := StyleSheet colorAt:'selection.foregroundColor'.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   217
    DefaultBackgroundColor         := StyleSheet colorAt:'selection.backgroundColor'.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   218
    DefaultShadowColor             := StyleSheet colorAt:'selection.shadowColor'.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   219
    DefaultLightColor              := StyleSheet colorAt:'selection.lightColor'.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   220
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   221
    DefaultForegroundColor isNil ifTrue:[
4515
6ca475e94989 class: SelectionInListModelView
Stefan Vogel <sv@exept.de>
parents: 4512
diff changeset
   222
        DefaultForegroundColor := StyleSheet colorAt:'text.foregroundColor' default:Color black
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   223
    ].
3927
Claus Gittinger <cg@exept.de>
parents: 3918
diff changeset
   224
Claus Gittinger <cg@exept.de>
parents: 3918
diff changeset
   225
    DefaultFont := SelectionInListView defaultFont. 
Claus Gittinger <cg@exept.de>
parents: 3918
diff changeset
   226
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   227
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   228
     self updateStyleCache
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   229
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   230
3927
Claus Gittinger <cg@exept.de>
parents: 3918
diff changeset
   231
    "Modified: / 14-08-2010 / 11:55:20 / cg"
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   232
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   233
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   234
!SelectionInListModelView methodsFor:'accessing'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   235
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
   236
cursorLine
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
   237
    "returns the index of the cursor line or 0
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
   238
    "
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
   239
    |index|
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
   240
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
   241
    cursorItem isNil ifTrue:[^ 0 ].
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
   242
2408
8b0d11537dc0 accessing list indirect
ca
parents: 2404
diff changeset
   243
    index := self identityIndexOf:cursorItem.
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
   244
    index == 0 ifTrue:[ cursorItem := nil ].
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
   245
    ^ index
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
   246
!
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
   247
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   248
list:aList
1547
f72d75aaec14 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
   249
    self deselectWithoutRedraw.
2867
bbdc2721ec0b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2856
diff changeset
   250
    ^ super list:aList
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   251
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   252
1818
fe99c5c721e9 category changes
Claus Gittinger <cg@exept.de>
parents: 1772
diff changeset
   253
!SelectionInListModelView methodsFor:'accessing-actions'!
1641
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   254
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   255
action
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   256
    "get the action block to be performed on select
2416
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
   257
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
   258
     The arguments to the block are:
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   259
	- no argument
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   260
	-  1 argument     index or item
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   261
	-  2 argument     index or item, self
1641
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   262
    "
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   263
    ^ actionBlock
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   264
!
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   265
4700
29ddd6d5a8e7 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4692
diff changeset
   266
action:anUpToTwoArgBlock
1641
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   267
    "set the action block to be performed on select
2416
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
   268
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
   269
     The arguments to the block are:
4700
29ddd6d5a8e7 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4692
diff changeset
   270
        - no argument
29ddd6d5a8e7 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4692
diff changeset
   271
        -  1 argument     index or item
29ddd6d5a8e7 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4692
diff changeset
   272
        -  2 argument     index or item, self
1641
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   273
    "
4700
29ddd6d5a8e7 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4692
diff changeset
   274
    actionBlock := anUpToTwoArgBlock
1641
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   275
!
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   276
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   277
doubleClickAction
2416
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
   278
    "get the action block to be performed on doubleclick.
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
   279
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
   280
     The arguments to the block are:
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   281
	- no argument
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   282
	-  1 argument     selectedIndex
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   283
	-  2 argument     selectedIndex, self
1641
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   284
    "
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   285
    ^ doubleClickActionBlock
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   286
!
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   287
4700
29ddd6d5a8e7 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4692
diff changeset
   288
doubleClickAction:anUpToTwoArgBlock
2416
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
   289
    "set the action block to be performed on doubleclick.
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
   290
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
   291
     The arguments to the block are:
4700
29ddd6d5a8e7 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4692
diff changeset
   292
        - no argument
29ddd6d5a8e7 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4692
diff changeset
   293
        -  1 argument     selectedIndex
29ddd6d5a8e7 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4692
diff changeset
   294
        -  2 argument     selectedIndex, self
1641
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   295
    "
4700
29ddd6d5a8e7 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4692
diff changeset
   296
    doubleClickActionBlock := anUpToTwoArgBlock
1641
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   297
!
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   298
2418
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   299
keyActionStyle
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   300
    "defines how the view should respond to alpha-keys pressed.
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   301
     Possible values are:
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   302
	#select               -> will select next entry starting with that
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   303
				 character and perform the click-action
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   304
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   305
	#selectAndDoubleclick -> will select next & perform double-click action
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   306
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   307
	#pass                 -> will pass key to superclass (i.e. no special treatment)
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   308
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   309
	nil                   -> will ignore key
2418
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   310
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   311
     the default (set in #initialize) is #select
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   312
    "
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   313
    ^ keyActionStyle
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   314
!
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   315
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   316
keyActionStyle:aSymbol
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   317
    "defines how the view should respond to alpha-keys pressed.
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   318
     Possible values are:
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   319
	#select               -> will select next entry starting with that
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   320
				 character and perform the click-action
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   321
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   322
	#selectAndDoubleclick -> will select next & perform double-click action
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   323
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   324
	#pass                 -> will pass key to superclass (i.e. no special treatment)
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   325
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   326
	nil                   -> will ignore key
2418
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   327
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   328
     the default (set in #initialize) is #select
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   329
    "
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   330
    keyActionStyle := aSymbol
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   331
!
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   332
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   333
returnKeyActionStyle
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   334
    "defines how the view should respond to a return key pressed.
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   335
     Possible values are:
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   336
	#doubleClick          -> perform double-click action
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   337
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   338
	#pass                 -> will pass key to superclass (i.e. no special treatment)
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   339
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   340
	nil                   -> will ignore key
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   341
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   342
     the default (set in #initialize) is #doubleClick
2418
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   343
    "
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   344
    ^ returnKeyActionStyle
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   345
!
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   346
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   347
returnKeyActionStyle:aSymbol
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   348
    "defines how the view should respond to a return key pressed.
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   349
     Possible values are:
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   350
	#doubleClick          -> perform double-click action
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   351
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   352
	#pass                 -> will pass key to superclass (i.e. no special treatment)
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   353
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   354
	nil                   -> will ignore key
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   355
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   356
     the default (set in #initialize) is #doubleClick
2418
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   357
    "
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   358
    returnKeyActionStyle := aSymbol
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   359
!
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   360
1641
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   361
selectConditionBlock
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   362
    "set the conditionBlock; this block is evaluated before a selection
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   363
     change is performed; the change will not be done, if the evaluation
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   364
     returns false
2416
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
   365
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
   366
     The arguments to the block are:
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   367
	- no argument
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   368
	-  1 argument     index
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   369
	-  2 argument     index, isForAdd
1641
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   370
    "
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   371
    ^ selectConditionBlock
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   372
!
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   373
4700
29ddd6d5a8e7 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4692
diff changeset
   374
selectConditionBlock:anUpToTwoArgBlock
1641
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   375
    "set the conditionBlock; this block is evaluated before a selection
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   376
     change is performed; the change will not be done, if the evaluation
2416
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
   377
     returns false.
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
   378
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
   379
     The arguments to the block are:
4700
29ddd6d5a8e7 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4692
diff changeset
   380
        - no argument
29ddd6d5a8e7 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4692
diff changeset
   381
        -  1 argument     index
29ddd6d5a8e7 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4692
diff changeset
   382
        -  2 argument     index, isForAdd
1641
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   383
    "
4700
29ddd6d5a8e7 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4692
diff changeset
   384
    selectConditionBlock := anUpToTwoArgBlock.
1641
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   385
! !
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   386
2418
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   387
!SelectionInListModelView methodsFor:'accessing-attributes'!
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   388
2323
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
   389
highlightEnterItem
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
   390
    "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
   391
    "
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
   392
    ^ highlightEnterItem
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
   393
!
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
   394
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
   395
highlightEnterItem:aBool
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
   396
    "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
   397
    "
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
   398
    highlightEnterItem ~~ aBool ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   399
	highlightEnterItem := aBool.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   400
	self pointerEntersItem:nil.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   401
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   402
	highlightEnterItem ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   403
	    self enableMotionEvents
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   404
	].
2323
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
   405
    ].
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
   406
!
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
   407
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   408
highlightMode
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   409
    "get the mode how to draw a selected line:
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   410
	#line           draw whole line selected
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   411
	#label          draw label selected
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   412
	#dropMode       set during drop
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   413
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   414
    ^ highlightMode
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   415
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   416
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   417
highlightMode:aMode
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   418
    "set the mode how to draw a selected line:
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   419
	#line           draw whole line selected
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   420
	#label          draw label selected
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   421
	#dropMode       set during drop
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   422
    "
2418
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   423
    highlightMode ~~ aMode ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   424
	highlightMode := aMode.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   425
	self invalidateSelection.
2418
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   426
    ].
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   427
!
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   428
3338
01ad784543fc no underline-highlighting
Claus Gittinger <cg@exept.de>
parents: 3275
diff changeset
   429
highlightWithUnderline
01ad784543fc no underline-highlighting
Claus Gittinger <cg@exept.de>
parents: 3275
diff changeset
   430
    ^ false
01ad784543fc no underline-highlighting
Claus Gittinger <cg@exept.de>
parents: 3275
diff changeset
   431
!
01ad784543fc no underline-highlighting
Claus Gittinger <cg@exept.de>
parents: 3275
diff changeset
   432
2644
78ca3bd5eef1 prepared for table
ca
parents: 2642
diff changeset
   433
hilightBackgroundColor
78ca3bd5eef1 prepared for table
ca
parents: 2642
diff changeset
   434
    "returns the color used for the hilighted background
78ca3bd5eef1 prepared for table
ca
parents: 2642
diff changeset
   435
    "
78ca3bd5eef1 prepared for table
ca
parents: 2642
diff changeset
   436
    ^ hilightBgColor
78ca3bd5eef1 prepared for table
ca
parents: 2642
diff changeset
   437
!
78ca3bd5eef1 prepared for table
ca
parents: 2642
diff changeset
   438
78ca3bd5eef1 prepared for table
ca
parents: 2642
diff changeset
   439
hilightForegroundColor
78ca3bd5eef1 prepared for table
ca
parents: 2642
diff changeset
   440
    "returns the color used for the hilighted foreground
78ca3bd5eef1 prepared for table
ca
parents: 2642
diff changeset
   441
    "
78ca3bd5eef1 prepared for table
ca
parents: 2642
diff changeset
   442
    ^ hilightFgColor
78ca3bd5eef1 prepared for table
ca
parents: 2642
diff changeset
   443
!
78ca3bd5eef1 prepared for table
ca
parents: 2642
diff changeset
   444
2418
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   445
strikeout
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   446
    "turn on/off strikeOut mode
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   447
    "
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   448
    ^ strikeOut
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   449
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   450
2418
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   451
strikeout:aBoolean
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   452
    "turn on/off strikeOut mode
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   453
    "
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   454
    strikeOut ~~ aBoolean ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   455
	strikeOut := aBoolean.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   456
	self invalidateSelection.
2418
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   457
    ].
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   458
! !
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   459
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   460
!SelectionInListModelView methodsFor:'accessing-behavior'!
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   461
1741
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   462
ignoreReselect
5663
6d448f6cb44d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5550
diff changeset
   463
    "controls if clicking on an already selected item should
6d448f6cb44d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5550
diff changeset
   464
     be ignored or should perform the select action again.
6d448f6cb44d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5550
diff changeset
   465
     By default, these are ignored"
6d448f6cb44d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5550
diff changeset
   466
1741
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   467
    ^ ignoreReselect
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   468
!
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   469
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   470
ignoreReselect:aBoolean
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   471
    "set/clear the ignoreReselect flag -
1741
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   472
     if set, a click on an already selected entry is ignored.
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   473
     Otherwise the notification is done, even if no
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   474
     change in the selection occurs.
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   475
     (for example, in browser to update a method).
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   476
     Setting ignoreReselect to false makes sense if data is shown
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   477
     which may change by itself (i.e. without the user doing anything)
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   478
     For example, the inspector uses this, and redisplays the value,
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   479
     if the selection is the same.
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   480
     The default is true, meaning that a click on an already selected
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   481
     does not lead to a notification via the actionBlock/change mechanism.
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   482
    "
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   483
    ignoreReselect := aBoolean
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   484
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   485
!
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   486
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   487
multipleSelectOk
4667
dc071f35a463 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4652
diff changeset
   488
    "return true if multiple selections are allowed; the default is false"
dc071f35a463 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4652
diff changeset
   489
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   490
    ^ multipleSelectOk
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   491
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   492
4667
dc071f35a463 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4652
diff changeset
   493
multipleSelectOk:aBoolean
2381
713c81fd86ad bugfix: update selection if multipleSelecktOk changed
ca
parents: 2377
diff changeset
   494
    "allow/disallow multiple selections. If enabled, the
713c81fd86ad bugfix: update selection if multipleSelecktOk changed
ca
parents: 2377
diff changeset
   495
     user may select multiple entries in the list, and the program
713c81fd86ad bugfix: update selection if multipleSelecktOk changed
ca
parents: 2377
diff changeset
   496
     always gets a collection of selected items (indexes if useIndex is true,
4667
dc071f35a463 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4652
diff changeset
   497
     values otherwise). The default is false, for single selections."
dc071f35a463 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4652
diff changeset
   498
2381
713c81fd86ad bugfix: update selection if multipleSelecktOk changed
ca
parents: 2377
diff changeset
   499
    |state|
713c81fd86ad bugfix: update selection if multipleSelecktOk changed
ca
parents: 2377
diff changeset
   500
4667
dc071f35a463 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4652
diff changeset
   501
    state := aBoolean ? false.
2381
713c81fd86ad bugfix: update selection if multipleSelecktOk changed
ca
parents: 2377
diff changeset
   502
713c81fd86ad bugfix: update selection if multipleSelecktOk changed
ca
parents: 2377
diff changeset
   503
    multipleSelectOk == state ifTrue:[ ^ self ].
713c81fd86ad bugfix: update selection if multipleSelecktOk changed
ca
parents: 2377
diff changeset
   504
713c81fd86ad bugfix: update selection if multipleSelecktOk changed
ca
parents: 2377
diff changeset
   505
    selection isNil ifTrue:[
4667
dc071f35a463 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4652
diff changeset
   506
        multipleSelectOk := state.
dc071f35a463 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4652
diff changeset
   507
        ^ self.
2381
713c81fd86ad bugfix: update selection if multipleSelecktOk changed
ca
parents: 2377
diff changeset
   508
    ].
713c81fd86ad bugfix: update selection if multipleSelecktOk changed
ca
parents: 2377
diff changeset
   509
713c81fd86ad bugfix: update selection if multipleSelecktOk changed
ca
parents: 2377
diff changeset
   510
    multipleSelectOk ifFalse:[
4667
dc071f35a463 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4652
diff changeset
   511
        selection := Array with:selection.
dc071f35a463 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4652
diff changeset
   512
        multipleSelectOk := true.
dc071f35a463 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4652
diff changeset
   513
        ^ self
2381
713c81fd86ad bugfix: update selection if multipleSelecktOk changed
ca
parents: 2377
diff changeset
   514
    ].
713c81fd86ad bugfix: update selection if multipleSelecktOk changed
ca
parents: 2377
diff changeset
   515
713c81fd86ad bugfix: update selection if multipleSelecktOk changed
ca
parents: 2377
diff changeset
   516
    selection size == 1 ifTrue:[
4667
dc071f35a463 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4652
diff changeset
   517
        selection := selection first.
2381
713c81fd86ad bugfix: update selection if multipleSelecktOk changed
ca
parents: 2377
diff changeset
   518
    ] ifFalse:[
4667
dc071f35a463 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4652
diff changeset
   519
        self selection:nil
2381
713c81fd86ad bugfix: update selection if multipleSelecktOk changed
ca
parents: 2377
diff changeset
   520
    ].
713c81fd86ad bugfix: update selection if multipleSelecktOk changed
ca
parents: 2377
diff changeset
   521
    multipleSelectOk := false.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   522
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   523
2815
0c05fbd33df6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
   524
selectOnButtonMenu
3438
a8ce9823cc1e english
Claus Gittinger <cg@exept.de>
parents: 3391
diff changeset
   525
    <resource: #obsolete>
a8ce9823cc1e english
Claus Gittinger <cg@exept.de>
parents: 3391
diff changeset
   526
    self obsoleteMethodWarning:'use selectOnMenuButton'.
a8ce9823cc1e english
Claus Gittinger <cg@exept.de>
parents: 3391
diff changeset
   527
    ^ self selectOnMenuButton
2228
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
   528
!
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
   529
2815
0c05fbd33df6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
   530
selectOnButtonMenu:aBoolean
3438
a8ce9823cc1e english
Claus Gittinger <cg@exept.de>
parents: 3391
diff changeset
   531
    <resource: #obsolete>
a8ce9823cc1e english
Claus Gittinger <cg@exept.de>
parents: 3391
diff changeset
   532
    self obsoleteMethodWarning:'use selectOnMenuButton:'.
a8ce9823cc1e english
Claus Gittinger <cg@exept.de>
parents: 3391
diff changeset
   533
    self selectOnMenuButton:aBoolean.
2228
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
   534
!
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
   535
3370
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
   536
selectOnButtonPress
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
   537
    "get the selectOnButtonPress flag - see method #selectOnButtonPress: for more details
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
   538
    "
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
   539
    ^ selectOnButtonPress ? true
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
   540
!
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
   541
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
   542
selectOnButtonPress:aBoolean
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   543
    "set/clear the selectOnButtonPress flag -
3370
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
   544
     if set (default), the selection changed on button press. This was the
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
   545
     behaviour until now.
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
   546
     if cleared, the selection is changed on button release. This new behaviour allows to start
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
   547
     a drag without changing the real selection. The selection is changed during the
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
   548
     drag and restored after the drop.
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
   549
    "
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
   550
    selectOnButtonPress := aBoolean
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
   551
!
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
   552
3438
a8ce9823cc1e english
Claus Gittinger <cg@exept.de>
parents: 3391
diff changeset
   553
selectOnMenuButton
5776
409b615d0cf5 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5733
diff changeset
   554
    "define the menu-button (middle button) press behavior; 
409b615d0cf5 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5733
diff changeset
   555
     if true, the line under the mouse
409b615d0cf5 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5733
diff changeset
   556
     will be selected before the menu is opened (Windows behavior). 
409b615d0cf5 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5733
diff changeset
   557
     Otherwise the selection is unchanged and the menu is opened 
409b615d0cf5 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5733
diff changeset
   558
     for the current selection (Unix behavior)."
3438
a8ce9823cc1e english
Claus Gittinger <cg@exept.de>
parents: 3391
diff changeset
   559
3461
eb3980ed82ad bugfix: selectTreeElementOnRightClick behaviour
ca
parents: 3455
diff changeset
   560
    selectOnMenuButton isNil ifTrue:[
5776
409b615d0cf5 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5733
diff changeset
   561
        ^ UserPreferences current selectOnRightClick
3461
eb3980ed82ad bugfix: selectTreeElementOnRightClick behaviour
ca
parents: 3455
diff changeset
   562
    ].
3438
a8ce9823cc1e english
Claus Gittinger <cg@exept.de>
parents: 3391
diff changeset
   563
    ^ selectOnMenuButton
5776
409b615d0cf5 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5733
diff changeset
   564
409b615d0cf5 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5733
diff changeset
   565
    "Modified (comment): / 28-05-2018 / 10:12:41 / Claus Gittinger"
3438
a8ce9823cc1e english
Claus Gittinger <cg@exept.de>
parents: 3391
diff changeset
   566
!
a8ce9823cc1e english
Claus Gittinger <cg@exept.de>
parents: 3391
diff changeset
   567
a8ce9823cc1e english
Claus Gittinger <cg@exept.de>
parents: 3391
diff changeset
   568
selectOnMenuButton:aBoolean
5776
409b615d0cf5 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5733
diff changeset
   569
    "define the menu-button (middle button) press behavior; 
409b615d0cf5 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5733
diff changeset
   570
     if true, the line under the mouse
409b615d0cf5 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5733
diff changeset
   571
     will be selected before the menu is opened (Windows behavior). 
409b615d0cf5 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5733
diff changeset
   572
     Otherwise the selection is unchanged and the menu is opened 
409b615d0cf5 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5733
diff changeset
   573
     for the current selection (Unix behavior)."
3438
a8ce9823cc1e english
Claus Gittinger <cg@exept.de>
parents: 3391
diff changeset
   574
a8ce9823cc1e english
Claus Gittinger <cg@exept.de>
parents: 3391
diff changeset
   575
    selectOnMenuButton := aBoolean.
5776
409b615d0cf5 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5733
diff changeset
   576
409b615d0cf5 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5733
diff changeset
   577
    "Modified (comment): / 28-05-2018 / 10:12:52 / Claus Gittinger"
3438
a8ce9823cc1e english
Claus Gittinger <cg@exept.de>
parents: 3391
diff changeset
   578
!
a8ce9823cc1e english
Claus Gittinger <cg@exept.de>
parents: 3391
diff changeset
   579
1741
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   580
toggleSelect
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   581
    "get the toggleSelect flag - see method #toggleSelect: for more details
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   582
    "
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   583
    ^ toggleSelect
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   584
!
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   585
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   586
toggleSelect:aBoolean
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   587
    "turn on/off toggle select. If true, clicking on a selected entry
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   588
     unselects it and vice versa. The default is false, which means
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   589
     that clicking on an already selected entry does not change its
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   590
     select status (see also ignoreReselect:).
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   591
    "
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   592
    toggleSelect := aBoolean.
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   593
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   594
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   595
!
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   596
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   597
useIndex
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   598
    "set/clear the useIndex flag.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   599
     the selection writen to the model are the indices into the list
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   600
     or the elements selected.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   601
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   602
    ^ useIndex
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   603
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   604
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   605
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   606
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   607
useIndex:aBoolean
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   608
    "set/clear the useIndex flag.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   609
     the selection writen to the model are the indices into the list
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   610
     or the elements selected.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   611
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   612
    useIndex := aBoolean ? true
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   613
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   614
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   615
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   616
2404
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   617
!SelectionInListModelView methodsFor:'accessing-editor'!
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   618
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   619
closeEditor
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   620
    "close the current editor
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   621
    "
2596
771e23c6d9cf access actions by call and not by reference
ca
parents: 2572
diff changeset
   622
    |editor action|
2404
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   623
5733
7b192c9c2a99 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5729
diff changeset
   624
    "/ cg: due to the closeEditorAction,
7b192c9c2a99 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5729
diff changeset
   625
    "/ there is a posiibility of recursive invocation,
7b192c9c2a99 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5729
diff changeset
   626
    "/ iff the closeEditorAction opens a dialog and the editor looses its focus
7b192c9c2a99 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5729
diff changeset
   627
    "/ (again).
7b192c9c2a99 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5729
diff changeset
   628
    thisContext isRecursive ifTrue:[^ self].
7b192c9c2a99 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5729
diff changeset
   629
2404
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   630
    (editor := editorView) notNil ifTrue:[
5733
7b192c9c2a99 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5729
diff changeset
   631
        "/ clear editorView after calling the closeEditorAction;
7b192c9c2a99 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5729
diff changeset
   632
        "/ it might abort the operation (after some confirmation dialog)
7b192c9c2a99 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5729
diff changeset
   633
        "/ editorView := nil.
7b192c9c2a99 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5729
diff changeset
   634
        action := self closeEditorAction.
7b192c9c2a99 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5729
diff changeset
   635
        action notNil ifTrue:[action value:editor].
7b192c9c2a99 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5729
diff changeset
   636
        editor destroy.
7b192c9c2a99 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5729
diff changeset
   637
        editorView := nil.
2404
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   638
    ].
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   639
!
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   640
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   641
closeEditorAction
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   642
    "get the block which is evaluated before the editor is closed; the argument
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   643
     to the action is the editor.
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   644
    "
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   645
    ^ closeEditorAction
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   646
!
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   647
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   648
closeEditorAction:anOneArgAction
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   649
    "get the block which is evaluated before the editor is closed; the argument
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   650
     to the action is the editor.
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   651
    "
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   652
    closeEditorAction := anOneArgAction.
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   653
!
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   654
2527
a07a74ff7e3e add a hasOpenEditor selector
penk
parents: 2522
diff changeset
   655
hasOpenEditor
a07a74ff7e3e add a hasOpenEditor selector
penk
parents: 2522
diff changeset
   656
a07a74ff7e3e add a hasOpenEditor selector
penk
parents: 2522
diff changeset
   657
    ^ editorView notNil
a07a74ff7e3e add a hasOpenEditor selector
penk
parents: 2522
diff changeset
   658
!
a07a74ff7e3e add a hasOpenEditor selector
penk
parents: 2522
diff changeset
   659
3524
854b6484c001 minimumEditorHeight
ca
parents: 3482
diff changeset
   660
minimumEditorHeight
854b6484c001 minimumEditorHeight
ca
parents: 3482
diff changeset
   661
    "answer the minumium height of the editor or nil.
854b6484c001 minimumEditorHeight
ca
parents: 3482
diff changeset
   662
     If the height is nil the height of the line is used"
854b6484c001 minimumEditorHeight
ca
parents: 3482
diff changeset
   663
854b6484c001 minimumEditorHeight
ca
parents: 3482
diff changeset
   664
    ^ minimumEditorHeight
854b6484c001 minimumEditorHeight
ca
parents: 3482
diff changeset
   665
!
854b6484c001 minimumEditorHeight
ca
parents: 3482
diff changeset
   666
854b6484c001 minimumEditorHeight
ca
parents: 3482
diff changeset
   667
minimumEditorHeight:aHeightOrNil
854b6484c001 minimumEditorHeight
ca
parents: 3482
diff changeset
   668
    "set the minumium height of the editor or nil.
854b6484c001 minimumEditorHeight
ca
parents: 3482
diff changeset
   669
     If the height is nil the height of the line is used"
854b6484c001 minimumEditorHeight
ca
parents: 3482
diff changeset
   670
854b6484c001 minimumEditorHeight
ca
parents: 3482
diff changeset
   671
    minimumEditorHeight := aHeightOrNil.
854b6484c001 minimumEditorHeight
ca
parents: 3482
diff changeset
   672
!
854b6484c001 minimumEditorHeight
ca
parents: 3482
diff changeset
   673
2404
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   674
openEditor
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   675
    "opens the editor on the current selection;
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   676
     returns the editorView or nil if no openEditorAction is defined
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   677
     or no single selection exists ...
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   678
    "
2596
771e23c6d9cf access actions by call and not by reference
ca
parents: 2572
diff changeset
   679
    |lnNr action|
2404
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   680
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   681
    self closeEditor.
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   682
    shown ifFalse:[^ nil].
2596
771e23c6d9cf access actions by call and not by reference
ca
parents: 2572
diff changeset
   683
771e23c6d9cf access actions by call and not by reference
ca
parents: 2572
diff changeset
   684
    action := self openEditorAction.
771e23c6d9cf access actions by call and not by reference
ca
parents: 2572
diff changeset
   685
    action isNil ifTrue:[^ nil].
771e23c6d9cf access actions by call and not by reference
ca
parents: 2572
diff changeset
   686
2404
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   687
    lnNr := self selectedIndex.
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   688
    lnNr == 0 ifTrue:[^ nil].
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   689
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   690
    self makeSelectionVisible.
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   691
2596
771e23c6d9cf access actions by call and not by reference
ca
parents: 2572
diff changeset
   692
    editorView := action valueWithOptionalArgument:lnNr and:self.
2404
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   693
    editorView isNil ifTrue:[^ nil].
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   694
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   695
    editorView superView isNil ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   696
	self addSubView:editorView
2404
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   697
    ].
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   698
    self computeEditorLayout.
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   699
    editorView realize.
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   700
    self windowGroup focusView:editorView.
2416
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
   701
    ^ editorView
2404
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   702
!
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   703
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   704
openEditorAction
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   705
    "get the block which is evaluated to get the editor which is set for the
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   706
     line; the arguments to the block is the line number and the widget itself
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   707
    "
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   708
    ^ openEditorAction
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   709
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   710
!
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   711
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   712
openEditorAction:aTwoArgAction
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   713
    "set the block which is evaluated to get the editor which is set for the
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   714
     line; the arguments to the block is the line number and the widget itself
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   715
    "
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   716
    openEditorAction := aTwoArgAction.
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   717
! !
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   718
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   719
!SelectionInListModelView methodsFor:'change & update'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   720
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   721
argForChangeMessage
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   722
    "return the argument for a selectionChange;
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   723
     depending on the setting of useIndex, this is either the numeric
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   724
     index of the selection or the value (i.e. the string)
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   725
    "
2409
68095c891ceb reuse selection methods (prepared for common controller)
ca
parents: 2408
diff changeset
   726
    useIndex         ifFalse:[ ^ self selectionValue ].
68095c891ceb reuse selection methods (prepared for common controller)
ca
parents: 2408
diff changeset
   727
    multipleSelectOk ifFalse:[ ^ selection ? 0 ].
68095c891ceb reuse selection methods (prepared for common controller)
ca
parents: 2408
diff changeset
   728
    ^ selection ? #()
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
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   731
contentsChanged
4258
d6ea83906c4e class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4242
diff changeset
   732
    "this one is sent, whenever contents changes its size"
d6ea83906c4e class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4242
diff changeset
   733
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   734
    super contentsChanged.
3482
1ee6b7daa983 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3461
diff changeset
   735
    self computeEditorLayout.
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   736
!
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   737
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   738
lineChangedAt:aLnNr with:arg
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   739
    super lineChangedAt:aLnNr with:arg.
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   740
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   741
    (editorView notNil and:[aLnNr == self selectedIndex]) ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   742
	self computeEditorLayout.
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   743
    ]
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   744
!
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   745
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   746
listSizeChanged:aLnNr nLines:aDeltaLines
1563
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   747
    |changed cnts|
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   748
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   749
    super listSizeChanged:aLnNr nLines:aDeltaLines.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   750
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   751
    selection isNil ifTrue:[^ self].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   752
2408
8b0d11537dc0 accessing list indirect
ca
parents: 2404
diff changeset
   753
    self size == 0 ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   754
	selection := nil.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   755
	^ self selectionChanged
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   756
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   757
1563
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   758
    multipleSelectOk ifFalse:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   759
	selection < aLnNr ifTrue:[^ self].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   760
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   761
	selection := selection + aDeltaLines.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   762
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   763
	(aDeltaLines < 0 and:[selection < aLnNr]) ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   764
	    selection := nil.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   765
	    ^ self selectionChanged
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   766
	]
1563
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   767
    ] ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   768
	changed := false.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   769
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   770
	aDeltaLines < 0  ifFalse:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   771
	    selection keysAndValuesDo:[:i :ln|
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   772
		ln >= aLnNr ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   773
		    changed := true.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   774
		    selection at:i put:(ln + aDeltaLines)
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   775
		]
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   776
	    ]
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   777
	] ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   778
	    cnts := 0.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   779
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   780
	    selection keysAndValuesDo:[:i :ln||new|
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   781
		ln >= aLnNr ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   782
		    changed := true.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   783
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   784
		    (new := ln + aDeltaLines) < aLnNr ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   785
			cnts := cnts + 1.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   786
			new  := nil
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   787
		    ].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   788
		    selection at:i put:new
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   789
		]
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   790
	    ].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   791
	    cnts ~~ 0 ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   792
		cnts == selection size ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   793
		    selection := nil
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   794
		] ifFalse:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   795
		    selection := selection select:[:ln| ln notNil]
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   796
		].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   797
		^ self selectionChanged.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   798
	    ].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   799
	].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   800
	changed ifFalse:[^ self].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   801
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   802
1563
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   803
    (useIndex and:[model notNil]) ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   804
	model setValue:(self argForChangeMessage)
1563
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   805
    ].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   806
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   807
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   808
originChanged:delta
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   809
    "setup the origin of the editing view
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   810
    "
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   811
    self computeEditorLayout.
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   812
    super originChanged:delta.
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   813
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   814
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   815
!
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   816
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   817
selectionChanged
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   818
    "selection has changed. Call actionblock and/or send changeMessage if defined
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   819
    "
1554
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
   820
    |arg|
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   821
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   822
    self closeEditor.
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   823
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   824
    (model isNil and:[actionBlock isNil]) ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   825
	^ self
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   826
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   827
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   828
    arg := self argForChangeMessage.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   829
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   830
    model notNil ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   831
	model removeDependent:self.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   832
	"/ change models value to force a change notification: reselect mode
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   833
	arg = model value ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   834
	    model setValue:(arg isNil ifTrue:[0] ifFalse:[nil]).
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   835
	].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   836
	self sendChangeMessage:#value: with:arg.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   837
	model notNil ifTrue:[  "/ argggh could be nilled
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   838
	    model addDependent:self.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   839
	    self updateFromModel. "/ care for possibly lost change notification, due to #removeDependent
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   840
	]
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   841
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   842
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   843
    actionBlock notNil ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   844
	actionBlock valueWithOptionalArgument:arg and:self
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   845
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   846
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   847
1554
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
   848
updateFromModel
2302
5a2a1d5d09f8 remove asynchronous handling of changes; always disabled because doesn't work
ca
parents: 2275
diff changeset
   849
    "update selection from the model
5a2a1d5d09f8 remove asynchronous handling of changes; always disabled because doesn't work
ca
parents: 2275
diff changeset
   850
    "
2522
a3ddd460ea91 copy selection from model in #updateFromModel
james
parents: 2501
diff changeset
   851
    |value newSelection|
2302
5a2a1d5d09f8 remove asynchronous handling of changes; always disabled because doesn't work
ca
parents: 2275
diff changeset
   852
5a2a1d5d09f8 remove asynchronous handling of changes; always disabled because doesn't work
ca
parents: 2275
diff changeset
   853
    model isNil ifTrue:[
4273
d56dfb04df83 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4258
diff changeset
   854
        ^ self
2302
5a2a1d5d09f8 remove asynchronous handling of changes; always disabled because doesn't work
ca
parents: 2275
diff changeset
   855
    ].
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
   856
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
   857
    buttonMotionAction notNil ifTrue:[
4273
d56dfb04df83 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4258
diff changeset
   858
        "running in button motion; discard change notification
d56dfb04df83 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4258
diff changeset
   859
        "
d56dfb04df83 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4258
diff changeset
   860
        ^ self
2302
5a2a1d5d09f8 remove asynchronous handling of changes; always disabled because doesn't work
ca
parents: 2275
diff changeset
   861
    ].
5a2a1d5d09f8 remove asynchronous handling of changes; always disabled because doesn't work
ca
parents: 2275
diff changeset
   862
5a2a1d5d09f8 remove asynchronous handling of changes; always disabled because doesn't work
ca
parents: 2275
diff changeset
   863
    value := model value.
5a2a1d5d09f8 remove asynchronous handling of changes; always disabled because doesn't work
ca
parents: 2275
diff changeset
   864
5a2a1d5d09f8 remove asynchronous handling of changes; always disabled because doesn't work
ca
parents: 2275
diff changeset
   865
    (useIndex or:[value isNil or:[value isNumber]]) ifFalse:[
4273
d56dfb04df83 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4258
diff changeset
   866
        multipleSelectOk ifFalse:[
d56dfb04df83 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4258
diff changeset
   867
            newSelection := self identityIndexOf:value
d56dfb04df83 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4258
diff changeset
   868
        ] ifTrue:[
d56dfb04df83 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4258
diff changeset
   869
            value size == 0 ifTrue:[
d56dfb04df83 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4258
diff changeset
   870
                newSelection := nil
d56dfb04df83 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4258
diff changeset
   871
            ] ifFalse:[
d56dfb04df83 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4258
diff changeset
   872
                newSelection := OrderedCollection new.
d56dfb04df83 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4258
diff changeset
   873
d56dfb04df83 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4258
diff changeset
   874
                value do:[:e||index|
d56dfb04df83 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4258
diff changeset
   875
                    index := self identityIndexOf:e.
d56dfb04df83 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4258
diff changeset
   876
                    index ~~ 0 ifTrue:[ newSelection add:index ].
d56dfb04df83 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4258
diff changeset
   877
                ].
d56dfb04df83 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4258
diff changeset
   878
                newSelection := newSelection asNilIfEmpty.
d56dfb04df83 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4258
diff changeset
   879
            ]
d56dfb04df83 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4258
diff changeset
   880
        ].
2522
a3ddd460ea91 copy selection from model in #updateFromModel
james
parents: 2501
diff changeset
   881
    ] ifTrue:[
4273
d56dfb04df83 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4258
diff changeset
   882
        newSelection := value copy
2302
5a2a1d5d09f8 remove asynchronous handling of changes; always disabled because doesn't work
ca
parents: 2275
diff changeset
   883
    ].
2522
a3ddd460ea91 copy selection from model in #updateFromModel
james
parents: 2501
diff changeset
   884
    self setSelection:newSelection.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   885
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   886
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   887
!SelectionInListModelView methodsFor:'drag & drop'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   888
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   889
canDrag
3918
612f8c92da9a comment/format
Claus Gittinger <cg@exept.de>
parents: 3899
diff changeset
   890
    "returns true if dragging is enabled"
612f8c92da9a comment/format
Claus Gittinger <cg@exept.de>
parents: 3899
diff changeset
   891
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   892
    ^ dropSource notNil
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   893
3918
612f8c92da9a comment/format
Claus Gittinger <cg@exept.de>
parents: 3899
diff changeset
   894
    "Modified: / 18-07-2010 / 09:07:20 / cg"
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   895
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   896
5810
458783339a12 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5807
diff changeset
   897
dragAutoScroll:aDropContext
2572
e370dbc5fbcb support autoScroll during drag operation
ca
parents: 2527
diff changeset
   898
    "called by the DragAndDropManager to scroll during a drag/drop operation
5807
0781fe0f6da9 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5796
diff changeset
   899
     if required (decided by the widget itself). 
0781fe0f6da9 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5796
diff changeset
   900
     If a scroll was done, return true;
0781fe0f6da9 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5796
diff changeset
   901
     otherwise false (used to restore the background)"
3918
612f8c92da9a comment/format
Claus Gittinger <cg@exept.de>
parents: 3899
diff changeset
   902
3899
ef976a181075 changed: #dragAutoScroll: Call q986469 scrool in tree
ca
parents: 3889
diff changeset
   903
    |scrollUp targetY deltaY pixels|
ef976a181075 changed: #dragAutoScroll: Call q986469 scrool in tree
ca
parents: 3889
diff changeset
   904
5810
458783339a12 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5807
diff changeset
   905
    ^ super dragAutoScroll:aDropContext.
458783339a12 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5807
diff changeset
   906
5812
9560db337582 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5810
diff changeset
   907
    targetY  := aDropContext targetPointInDeviceCoordinates y.
3899
ef976a181075 changed: #dragAutoScroll: Call q986469 scrool in tree
ca
parents: 3889
diff changeset
   908
    scrollUp := (targetY < (height // 2)).
ef976a181075 changed: #dragAutoScroll: Call q986469 scrool in tree
ca
parents: 3889
diff changeset
   909
ef976a181075 changed: #dragAutoScroll: Call q986469 scrool in tree
ca
parents: 3889
diff changeset
   910
    scrollUp ifTrue:[
ef976a181075 changed: #dragAutoScroll: Call q986469 scrool in tree
ca
parents: 3889
diff changeset
   911
        self yOriginOfContents = 0 ifTrue:[ ^ false].
ef976a181075 changed: #dragAutoScroll: Call q986469 scrool in tree
ca
parents: 3889
diff changeset
   912
        deltaY := targetY.
2572
e370dbc5fbcb support autoScroll during drag operation
ca
parents: 2527
diff changeset
   913
    ] ifFalse:[
3899
ef976a181075 changed: #dragAutoScroll: Call q986469 scrool in tree
ca
parents: 3889
diff changeset
   914
        deltaY := height - targetY.
ef976a181075 changed: #dragAutoScroll: Call q986469 scrool in tree
ca
parents: 3889
diff changeset
   915
        self yOriginOfContents < self maxViewOriginY ifFalse:[ ^ false ].
2572
e370dbc5fbcb support autoScroll during drag operation
ca
parents: 2527
diff changeset
   916
    ].
3899
ef976a181075 changed: #dragAutoScroll: Call q986469 scrool in tree
ca
parents: 3889
diff changeset
   917
    pixels := 24 min:(height // 4).
ef976a181075 changed: #dragAutoScroll: Call q986469 scrool in tree
ca
parents: 3889
diff changeset
   918
    deltaY > pixels ifTrue:[^ false].
ef976a181075 changed: #dragAutoScroll: Call q986469 scrool in tree
ca
parents: 3889
diff changeset
   919
ef976a181075 changed: #dragAutoScroll: Call q986469 scrool in tree
ca
parents: 3889
diff changeset
   920
    deltaY <= (pixels // 2) ifTrue:[
ef976a181075 changed: #dragAutoScroll: Call q986469 scrool in tree
ca
parents: 3889
diff changeset
   921
        deltaY <= (pixels // 4)
ef976a181075 changed: #dragAutoScroll: Call q986469 scrool in tree
ca
parents: 3889
diff changeset
   922
            ifTrue:[ pixels := pixels * 3]
ef976a181075 changed: #dragAutoScroll: Call q986469 scrool in tree
ca
parents: 3889
diff changeset
   923
            ifFalse:[ pixels := pixels * 2 ].            
ef976a181075 changed: #dragAutoScroll: Call q986469 scrool in tree
ca
parents: 3889
diff changeset
   924
    ].
5810
458783339a12 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5807
diff changeset
   925
    aDropContext contentsWillChange.
2572
e370dbc5fbcb support autoScroll during drag operation
ca
parents: 2527
diff changeset
   926
3918
612f8c92da9a comment/format
Claus Gittinger <cg@exept.de>
parents: 3899
diff changeset
   927
    scrollUp 
612f8c92da9a comment/format
Claus Gittinger <cg@exept.de>
parents: 3899
diff changeset
   928
        ifTrue:[ self scrollUp:pixels ]
612f8c92da9a comment/format
Claus Gittinger <cg@exept.de>
parents: 3899
diff changeset
   929
        ifFalse:[ self scrollDown:pixels ].
2572
e370dbc5fbcb support autoScroll during drag operation
ca
parents: 2527
diff changeset
   930
e370dbc5fbcb support autoScroll during drag operation
ca
parents: 2527
diff changeset
   931
    ^ true
3918
612f8c92da9a comment/format
Claus Gittinger <cg@exept.de>
parents: 3899
diff changeset
   932
612f8c92da9a comment/format
Claus Gittinger <cg@exept.de>
parents: 3899
diff changeset
   933
    "Modified: / 18-07-2010 / 09:08:29 / cg"
5812
9560db337582 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5810
diff changeset
   934
    "Modified: / 15-06-2018 / 02:25:57 / Claus Gittinger"
2572
e370dbc5fbcb support autoScroll during drag operation
ca
parents: 2527
diff changeset
   935
!
e370dbc5fbcb support autoScroll during drag operation
ca
parents: 2527
diff changeset
   936
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   937
dropSource
2891
78a14c0ed73c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2886
diff changeset
   938
    "returns the dropSource or nil"
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   939
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   940
    ^ dropSource
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   941
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   942
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   943
dropSource:aDropSourceOrNil
2891
78a14c0ed73c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2886
diff changeset
   944
    "set the dropSource or nil"
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   945
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   946
    dropSource := aDropSourceOrNil.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   947
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   948
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   949
startDragAt:aPoint
3918
612f8c92da9a comment/format
Claus Gittinger <cg@exept.de>
parents: 3899
diff changeset
   950
    "start drag at a point"
612f8c92da9a comment/format
Claus Gittinger <cg@exept.de>
parents: 3899
diff changeset
   951
2976
136d983423ab drag & drop activation if moving horizontal n pixels
ca
parents: 2964
diff changeset
   952
    buttonMotionAction := buttonReleaseAction := nil.
136d983423ab drag & drop activation if moving horizontal n pixels
ca
parents: 2964
diff changeset
   953
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   954
    dropSource notNil ifTrue:[
3918
612f8c92da9a comment/format
Claus Gittinger <cg@exept.de>
parents: 3899
diff changeset
   955
        dropSource startDragSelector notNil ifTrue:[
612f8c92da9a comment/format
Claus Gittinger <cg@exept.de>
parents: 3899
diff changeset
   956
            ^ dropSource startDragIn:self at:aPoint
5810
458783339a12 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5807
diff changeset
   957
        ].
458783339a12 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5807
diff changeset
   958
        ^ DragAndDropManager startDragFrom:self dropSource:dropSource offset:#center
3370
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
   959
    ].
3684
8e409d2d8a52 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3608
diff changeset
   960
    ^ nil
3918
612f8c92da9a comment/format
Claus Gittinger <cg@exept.de>
parents: 3899
diff changeset
   961
612f8c92da9a comment/format
Claus Gittinger <cg@exept.de>
parents: 3899
diff changeset
   962
    "Modified: / 18-07-2010 / 09:07:26 / cg"
5810
458783339a12 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5807
diff changeset
   963
    "Modified: / 14-06-2018 / 10:49:50 / Claus Gittinger"
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   964
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   965
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   966
!SelectionInListModelView methodsFor:'drawing'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   967
2642
27174081058f move methods to super class; prepared for table
ca
parents: 2641
diff changeset
   968
drawElementsFrom:start to:stop x:x y:y w:w
27174081058f move methods to super class; prepared for table
ca
parents: 2641
diff changeset
   969
    "draw the items between start to stop without clearing the background
27174081058f move methods to super class; prepared for table
ca
parents: 2641
diff changeset
   970
    "
27174081058f move methods to super class; prepared for table
ca
parents: 2641
diff changeset
   971
    |y0 "{ Class:SmallInteger }"
27174081058f move methods to super class; prepared for table
ca
parents: 2641
diff changeset
   972
     y1 "{ Class:SmallInteger }"
27174081058f move methods to super class; prepared for table
ca
parents: 2641
diff changeset
   973
     x0 "{ Class:SmallInteger }"
27174081058f move methods to super class; prepared for table
ca
parents: 2641
diff changeset
   974
    |
27174081058f move methods to super class; prepared for table
ca
parents: 2641
diff changeset
   975
    x0 := textStartLeft - viewOrigin x.
27174081058f move methods to super class; prepared for table
ca
parents: 2641
diff changeset
   976
    y1 := y.
27174081058f move methods to super class; prepared for table
ca
parents: 2641
diff changeset
   977
27174081058f move methods to super class; prepared for table
ca
parents: 2641
diff changeset
   978
    start to:stop do:[:i|
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   979
	y0 := y1.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   980
	y1 := self yVisibleOfLine:(i + 1).
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   981
	self drawLabelAt:i x:x0 y:y0 h:(y1 - y0)
2642
27174081058f move methods to super class; prepared for table
ca
parents: 2641
diff changeset
   982
    ].
27174081058f move methods to super class; prepared for table
ca
parents: 2641
diff changeset
   983
27174081058f move methods to super class; prepared for table
ca
parents: 2641
diff changeset
   984
27174081058f move methods to super class; prepared for table
ca
parents: 2641
diff changeset
   985
!
27174081058f move methods to super class; prepared for table
ca
parents: 2641
diff changeset
   986
1533
609fce5df829 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1508
diff changeset
   987
drawFrom:start to:stop x:x y:y w:w
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   988
    "draw the lines between start to stop without clearing the background
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   989
    "
1557
e3feb8bc17b0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1554
diff changeset
   990
    highlightMode notNil ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   991
	self selectionDo:[:lnNr|
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   992
	    (lnNr between:start and:stop) ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   993
		self drawSelectionFrameAt:lnNr x:x w:w
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   994
	    ]
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
   995
	]
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   996
    ].
2642
27174081058f move methods to super class; prepared for table
ca
parents: 2641
diff changeset
   997
    super drawFrom:start to:stop x:x y:y w:w.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   998
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   999
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1000
drawLabelAt:anIndex x:xI y:y h:h
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1001
    "draw the label at position x/y without clearing the background
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1002
    "
4702
e7e4cf796487 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4700
diff changeset
  1003
    |item y0 x1 x w drawStrikeOut xOut0 xOut1 isHighlightedAsSelected|
1554
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1004
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1005
    x := xI + 1.
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  1006
    editorView notNil ifTrue:[
4702
e7e4cf796487 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4700
diff changeset
  1007
        "/ there is an open editor for the line; thus no redraw for the label (hidden by editor)
e7e4cf796487 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4700
diff changeset
  1008
        self selectedIndex == anIndex ifTrue:[^ self].
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  1009
    ].
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  1010
2408
8b0d11537dc0 accessing list indirect
ca
parents: 2404
diff changeset
  1011
    item := self at:anIndex ifAbsent:nil.
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1012
    item isNil ifTrue:[^ self].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1013
2418
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1014
    drawStrikeOut := false.
4702
e7e4cf796487 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4700
diff changeset
  1015
    isHighlightedAsSelected := false.
2418
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1016
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1017
    (highlightMode notNil and:[self isInSelection:anIndex]) ifTrue:[
4702
e7e4cf796487 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4700
diff changeset
  1018
        strikeOut ifTrue:[
e7e4cf796487 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4700
diff changeset
  1019
            drawStrikeOut := true.
5426
ac12d5426c18 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5381
diff changeset
  1020
            gc paint:fgColor on:bgColor
4702
e7e4cf796487 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4700
diff changeset
  1021
        ] ifFalse:[
e7e4cf796487 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4700
diff changeset
  1022
            (highlightMode == #dropMode or:[self hasFocus not]) ifTrue:[
5426
ac12d5426c18 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5381
diff changeset
  1023
                gc paint:hilightFgColorNoFocus on:hilightBgColorNoFocus.
4702
e7e4cf796487 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4700
diff changeset
  1024
            ] ifFalse:[
5426
ac12d5426c18 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5381
diff changeset
  1025
                gc paint:hilightFgColor on:hilightBgColor
4702
e7e4cf796487 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4700
diff changeset
  1026
            ].
e7e4cf796487 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4700
diff changeset
  1027
            isHighlightedAsSelected := true.
e7e4cf796487 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4700
diff changeset
  1028
        ]
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1029
    ] ifFalse:[
4702
e7e4cf796487 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4700
diff changeset
  1030
        enterItem == item ifTrue:[
5426
ac12d5426c18 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5381
diff changeset
  1031
            gc paint:hilightBgColor on:bgColor.
4702
e7e4cf796487 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4700
diff changeset
  1032
        ] ifFalse:[
5426
ac12d5426c18 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5381
diff changeset
  1033
            gc paint:fgColor on:bgColor.
4702
e7e4cf796487 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4700
diff changeset
  1034
        ].
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1035
    ].
4702
e7e4cf796487 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4700
diff changeset
  1036
    listRenderer display:item atX:x y:y lineHeight:h isHighlightedAsSelected:isHighlightedAsSelected.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1037
2418
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1038
    drawStrikeOut ifTrue:[
4702
e7e4cf796487 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4700
diff changeset
  1039
        xOut0 := self xVisibleOfItem:item.
e7e4cf796487 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4700
diff changeset
  1040
        highlightMode == #label ifTrue:[
e7e4cf796487 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4700
diff changeset
  1041
            xOut1 := xOut0 + (listRenderer widthFor:item).
e7e4cf796487 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4700
diff changeset
  1042
        ] ifFalse:[
e7e4cf796487 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4700
diff changeset
  1043
            xOut1 := width - margin.
e7e4cf796487 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4700
diff changeset
  1044
        ].
e7e4cf796487 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4700
diff changeset
  1045
        y0 := y + (h // 2).
5426
ac12d5426c18 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5381
diff changeset
  1046
        gc displayLineFromX:xOut0 y:y0 toX:xOut1 y:y0.
4702
e7e4cf796487 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4700
diff changeset
  1047
        y0 := y0 - 1.
5426
ac12d5426c18 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5381
diff changeset
  1048
        gc displayLineFromX:xOut0 y:y0 toX:xOut1 y:y0.
2418
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1049
    ].
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1050
3338
01ad784543fc no underline-highlighting
Claus Gittinger <cg@exept.de>
parents: 3275
diff changeset
  1051
    cursorItem == item ifTrue:[
4702
e7e4cf796487 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4700
diff changeset
  1052
        "/ textStartLeft
5426
ac12d5426c18 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5381
diff changeset
  1053
        gc maskOrigin:((self viewOrigin + (0 @ 1)) \\ (lineMask extent)).
ac12d5426c18 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5381
diff changeset
  1054
        gc mask:lineMask.
4702
e7e4cf796487 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4700
diff changeset
  1055
        w := listRenderer widthFor:item.
5426
ac12d5426c18 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5381
diff changeset
  1056
        gc displayRectangleX:x -1 y:(y+2) width:w+2 height:(h - 4).
ac12d5426c18 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5381
diff changeset
  1057
        gc mask:nil.
3338
01ad784543fc no underline-highlighting
Claus Gittinger <cg@exept.de>
parents: 3275
diff changeset
  1058
    ] ifFalse:[
4702
e7e4cf796487 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4700
diff changeset
  1059
        enterItem == item ifTrue:[
e7e4cf796487 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4700
diff changeset
  1060
            self highlightWithUnderline ifTrue:[
e7e4cf796487 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4700
diff changeset
  1061
                "/ underline the hilite...
e7e4cf796487 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4700
diff changeset
  1062
                y0 := y + h - 2.
e7e4cf796487 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4700
diff changeset
  1063
                x1 := x + (listRenderer widthFor:item).
e7e4cf796487 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4700
diff changeset
  1064
5426
ac12d5426c18 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5381
diff changeset
  1065
                gc displayLineFromX:x y:y0 toX:x1 y:y0.
4702
e7e4cf796487 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4700
diff changeset
  1066
            ]
e7e4cf796487 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4700
diff changeset
  1067
        ].
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1068
    ].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1069
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1070
1554
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1071
drawSelectionFrameAt:lnNr x:x w:w
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1072
    "draw the background and foreground of the selection frame
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1073
     at a lineNr.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1074
    "
2646
8be2becc5152 drawSelectionFrameAt:.. clear damaged background not items background
ca
parents: 2644
diff changeset
  1075
    |item xMax xLftDmg xRgtDmg x0 x1 y0 y1 hL wL|
8be2becc5152 drawSelectionFrameAt:.. clear damaged background not items background
ca
parents: 2644
diff changeset
  1076
8be2becc5152 drawSelectionFrameAt:.. clear damaged background not items background
ca
parents: 2644
diff changeset
  1077
    (strikeOut or:[highlightMode isNil]) ifTrue:[
4318
ee2c154ee065 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4273
diff changeset
  1078
        ^ self
2646
8be2becc5152 drawSelectionFrameAt:.. clear damaged background not items background
ca
parents: 2644
diff changeset
  1079
    ].
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  1080
    editorView notNil ifTrue:[
4318
ee2c154ee065 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4273
diff changeset
  1081
        "/ there is an open editor; do not redraw selected
ee2c154ee065 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4273
diff changeset
  1082
        ^ self
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  1083
    ].
3367
29f38ac1bac1 support highlightMode (selection) #dropMode
ca
parents: 3345
diff changeset
  1084
29f38ac1bac1 support highlightMode (selection) #dropMode
ca
parents: 3345
diff changeset
  1085
    (    highlightMode == #line
29f38ac1bac1 support highlightMode (selection) #dropMode
ca
parents: 3345
diff changeset
  1086
     or:[highlightMode == #label
29f38ac1bac1 support highlightMode (selection) #dropMode
ca
parents: 3345
diff changeset
  1087
     or:[highlightMode == #dropMode]]
29f38ac1bac1 support highlightMode (selection) #dropMode
ca
parents: 3345
diff changeset
  1088
    ) ifFalse:[
4318
ee2c154ee065 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4273
diff changeset
  1089
        "/ highlightMode not supported
ee2c154ee065 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4273
diff changeset
  1090
        ^ self
2646
8be2becc5152 drawSelectionFrameAt:.. clear damaged background not items background
ca
parents: 2644
diff changeset
  1091
    ].
2408
8b0d11537dc0 accessing list indirect
ca
parents: 2404
diff changeset
  1092
    (item := self at:lnNr ifAbsent:nil) isNil ifTrue:[
4318
ee2c154ee065 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4273
diff changeset
  1093
        "/ list might change during drawing; item no longer visible
ee2c154ee065 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4273
diff changeset
  1094
        ^ self
1554
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1095
    ].
2646
8be2becc5152 drawSelectionFrameAt:.. clear damaged background not items background
ca
parents: 2644
diff changeset
  1096
    xMax := x + w.
1554
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1097
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1098
    "/ CLEAR THE BACKGROUND
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1099
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1100
    y0 := self yVisibleOfLine:lnNr.
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1101
    y1 := self yVisibleOfLine:(lnNr + 1).
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1102
    hL := y1 - y0.
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1103
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1104
    highlightMode == #line ifTrue:[
4318
ee2c154ee065 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4273
diff changeset
  1105
        x0 := x.
ee2c154ee065 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4273
diff changeset
  1106
        x1 := xMax.
3367
29f38ac1bac1 support highlightMode (selection) #dropMode
ca
parents: 3345
diff changeset
  1107
    ] ifFalse:[ "/ is #label or #rectangle
4318
ee2c154ee065 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4273
diff changeset
  1108
        x0 := (self xVisibleOfItem:item) - (textStartLeft // 2).
ee2c154ee065 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4273
diff changeset
  1109
        x0 >= xMax ifTrue:[ ^ self ].
ee2c154ee065 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4273
diff changeset
  1110
ee2c154ee065 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4273
diff changeset
  1111
        x1 := x0 + (listRenderer widthFor:item) + textStartLeft + 1.
ee2c154ee065 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4273
diff changeset
  1112
        x1 < x ifTrue:[ ^ self ].
1554
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1113
    ].
2646
8be2becc5152 drawSelectionFrameAt:.. clear damaged background not items background
ca
parents: 2644
diff changeset
  1114
    xLftDmg := x0 max:x.
8be2becc5152 drawSelectionFrameAt:.. clear damaged background not items background
ca
parents: 2644
diff changeset
  1115
    xRgtDmg := x1 min:xMax.
8be2becc5152 drawSelectionFrameAt:.. clear damaged background not items background
ca
parents: 2644
diff changeset
  1116
    xRgtDmg > xLftDmg ifFalse:[^ self].
1554
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1117
3367
29f38ac1bac1 support highlightMode (selection) #dropMode
ca
parents: 3345
diff changeset
  1118
    (highlightMode == #dropMode or:[self hasFocus not]) ifTrue:[
5426
ac12d5426c18 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5381
diff changeset
  1119
        gc paint:hilightBgColorNoFocus.
3367
29f38ac1bac1 support highlightMode (selection) #dropMode
ca
parents: 3345
diff changeset
  1120
    ] ifFalse:[
5426
ac12d5426c18 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5381
diff changeset
  1121
        gc paint:hilightBgColor.
3137
7e8fae56b94c highlight selection dependent on has focus
ca
parents: 3081
diff changeset
  1122
    ].
5426
ac12d5426c18 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5381
diff changeset
  1123
    gc fillRectangleX:xLftDmg y:y0 width:(xRgtDmg - xLftDmg) height:hL.
2646
8be2becc5152 drawSelectionFrameAt:.. clear damaged background not items background
ca
parents: 2644
diff changeset
  1124
    wL := x1 - x0.
1554
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1125
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1126
    "/ DRAW THE FRAME
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1127
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1128
    hilightFrameColor notNil ifTrue:[
4318
ee2c154ee065 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4273
diff changeset
  1129
        hilightLevel == 0 ifTrue:[
6201
f62406ae4f1e #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6167
diff changeset
  1130
            gc paint:(self hasFocus ifTrue:[hilightFrameColor] ifFalse:[hilightBgColorNoFocus]).
4318
ee2c154ee065 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4273
diff changeset
  1131
ee2c154ee065 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4273
diff changeset
  1132
            highlightMode == #line ifTrue:[
5426
ac12d5426c18 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5381
diff changeset
  1133
                gc displayLineFromX:x0 y:y0 toX:x1 y:y0.
4318
ee2c154ee065 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4273
diff changeset
  1134
                y1 := y0 + hL - 1.
5426
ac12d5426c18 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5381
diff changeset
  1135
                gc displayLineFromX:x0 y:y1 toX:x1 y:y1.
4318
ee2c154ee065 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4273
diff changeset
  1136
            ] ifFalse:[
5426
ac12d5426c18 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5381
diff changeset
  1137
                gc displayRectangleX:x0 y:y0 width:wL height:hL
4318
ee2c154ee065 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4273
diff changeset
  1138
            ].
ee2c154ee065 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4273
diff changeset
  1139
            ^ self.
ee2c154ee065 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4273
diff changeset
  1140
        ]
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1141
    ] ifFalse:[
4318
ee2c154ee065 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4273
diff changeset
  1142
        hilightStyle == #motif ifTrue:[
5426
ac12d5426c18 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5381
diff changeset
  1143
            gc paint:bgColor.
4318
ee2c154ee065 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4273
diff changeset
  1144
            y1 := y0 + 1.
ee2c154ee065 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4273
diff changeset
  1145
            highlightMode == #line ifTrue:[
5426
ac12d5426c18 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5381
diff changeset
  1146
                gc displayLineFromX:x0 y:y1 toX:x1 y:y1.
4318
ee2c154ee065 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4273
diff changeset
  1147
                y1 := y0 + hL - 2.
5426
ac12d5426c18 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5381
diff changeset
  1148
                gc displayLineFromX:x0 y:y1 toX:x1 y:y1.
4318
ee2c154ee065 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4273
diff changeset
  1149
            ] ifFalse:[
5426
ac12d5426c18 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5381
diff changeset
  1150
                gc displayRectangleX:x0 + 1 y:y1 width:wL - 2 height:hL - 2
4318
ee2c154ee065 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4273
diff changeset
  1151
            ]
ee2c154ee065 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4273
diff changeset
  1152
        ].
ee2c154ee065 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4273
diff changeset
  1153
        hilightLevel == 0 ifTrue:[ ^ self ].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1154
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1155
2646
8be2becc5152 drawSelectionFrameAt:.. clear damaged background not items background
ca
parents: 2644
diff changeset
  1156
    "/ draw edge
8be2becc5152 drawSelectionFrameAt:.. clear damaged background not items background
ca
parents: 2644
diff changeset
  1157
    highlightMode == #line ifTrue:[
4318
ee2c154ee065 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4273
diff changeset
  1158
        x0 := margin.
ee2c154ee065 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4273
diff changeset
  1159
        wL := width - margin - margin.
2646
8be2becc5152 drawSelectionFrameAt:.. clear damaged background not items background
ca
parents: 2644
diff changeset
  1160
    ].
8be2becc5152 drawSelectionFrameAt:.. clear damaged background not items background
ca
parents: 2644
diff changeset
  1161
    self drawEdgesForX:x0 y:y0 width:wL height:hL level:hilightLevel.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1162
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1163
4206
95f294d62b07 Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4181
diff changeset
  1164
drawSelectionFrameFrom:start to:stop x:x y:y w:w
95f294d62b07 Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4181
diff changeset
  1165
    "draw the selection frame between start to stop without clearing the background
95f294d62b07 Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4181
diff changeset
  1166
    "
95f294d62b07 Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4181
diff changeset
  1167
    highlightMode notNil ifTrue:[
95f294d62b07 Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4181
diff changeset
  1168
        self selectionDo:[:lnNr|
95f294d62b07 Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4181
diff changeset
  1169
            (lnNr between:start and:stop) ifTrue:[
95f294d62b07 Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4181
diff changeset
  1170
                self drawSelectionFrameAt:lnNr x:x w:w
95f294d62b07 Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4181
diff changeset
  1171
            ]
95f294d62b07 Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4181
diff changeset
  1172
        ]
95f294d62b07 Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4181
diff changeset
  1173
    ].
95f294d62b07 Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4181
diff changeset
  1174
95f294d62b07 Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4181
diff changeset
  1175
    "Created: / 24-04-2013 / 14:06:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
95f294d62b07 Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4181
diff changeset
  1176
!
95f294d62b07 Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4181
diff changeset
  1177
2418
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1178
invalidateSelection
5215
949e2a560b6c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5158
diff changeset
  1179
    "invalidate (force async redraw) the current selection
2418
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1180
    "
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1181
    shown ifTrue:[
5215
949e2a560b6c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5158
diff changeset
  1182
        self selectionDo:[:aLnNr| self invalidateLineAt:aLnNr].
2418
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1183
    ].
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1184
!
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1185
2245
546c6e5d0951 change #redrawSelectionAt: to #invalidateSelectionAt: (because is a invalidate)
ca
parents: 2228
diff changeset
  1186
invalidateSelectionAt:aLineNr
1569
447b0cafc1db drawing selected or unselected
ca
parents: 1564
diff changeset
  1187
    "redraw a line which changed its selection status.
447b0cafc1db drawing selected or unselected
ca
parents: 1564
diff changeset
  1188
     optimized when drawing only the label.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1189
    "
2323
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
  1190
    |item x|
1569
447b0cafc1db drawing selected or unselected
ca
parents: 1564
diff changeset
  1191
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  1192
    editorView notNil ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1193
	"/ there is an open editor; do not redraw selected
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1194
	^ self
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  1195
    ].
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  1196
1569
447b0cafc1db drawing selected or unselected
ca
parents: 1564
diff changeset
  1197
    (shown and:[aLineNr notNil and:[highlightMode notNil]]) ifFalse:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1198
	^ self
1557
e3feb8bc17b0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1554
diff changeset
  1199
    ].
e3feb8bc17b0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1554
diff changeset
  1200
2323
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
  1201
    highlightMode == #label ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1202
	item := self at:aLineNr ifAbsent:nil.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1203
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1204
	item isNil ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1205
	    ^ self
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1206
	].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1207
	x := (self xVisibleOfItem:item) - (textStartLeft // 2)
1569
447b0cafc1db drawing selected or unselected
ca
parents: 1564
diff changeset
  1208
    ] ifFalse:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1209
	x := 0.
1569
447b0cafc1db drawing selected or unselected
ca
parents: 1564
diff changeset
  1210
    ].
2323
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
  1211
    self invalidateLineAt:aLineNr fromX:x
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1212
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1213
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1214
!SelectionInListModelView methodsFor:'event handling'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1215
3750
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1216
activateMenu
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1217
    |item menu appl|
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1218
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1219
    enabled ifFalse:[^ self].
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1220
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1221
    item := self selectedElement.
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1222
    item notNil ifTrue:[
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1223
        menu := item perform:#middleButtonMenu ifNotUnderstood:nil.
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1224
        menu notNil ifTrue:[
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1225
            menu isCollection ifTrue:[
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1226
                menu := Menu decodeFromLiteralArray:menu.
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1227
                appl := self application.
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1228
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1229
                appl notNil ifTrue:[
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1230
                    menu findGuiResourcesIn:appl.
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1231
                    "/ menu receiver:appl  -- now done in findGuiResources ...
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1232
                ] ifFalse:[
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1233
                    menu receiver:item
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1234
                ]
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1235
            ].
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1236
            self startUpMenu:menu.
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1237
            ^ self
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1238
        ].
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1239
    ].
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1240
    super activateMenu
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1241
!
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1242
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1243
buttonControlPressAtLine:lineNr x:x y:y
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1244
    "handle a button control press
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1245
    "
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1246
    |isInSelection prvLine chgSet doAdd|
1747
f46c5941c028 better alghorithm for button motion in multipleSelection mode
ca
parents: 1745
diff changeset
  1247
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1248
    isInSelection := self isInSelection:lineNr.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1249
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1250
    multipleSelectOk ifFalse:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1251
	isInSelection ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1252
	    self deselect
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1253
	]ifFalse:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1254
	    (self canSelectIndex:lineNr forAdd:false) ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1255
		self buttonPressOrReleaseAtLine:lineNr x:x y:y.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1256
	    ].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1257
	].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1258
	^ self
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1259
    ].
2410
39ec0844e7d6 discard #toggleSelection:
ca
parents: 2409
diff changeset
  1260
    isInSelection ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1261
	self removeFromSelection:lineNr
2410
39ec0844e7d6 discard #toggleSelection:
ca
parents: 2409
diff changeset
  1262
    ] ifFalse:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1263
	self addToSelection:lineNr.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1264
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1265
	(self isInSelection:lineNr) ifFalse:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1266
	    "/ cannot add to selection
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1267
	    ^ self
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1268
	].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1269
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1270
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1271
    prvLine := lineNr.
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1272
    chgSet  := IdentitySet new.
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1273
    doAdd   := isInSelection not.
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1274
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1275
    buttonMotionAction := [:p| |rowNr mustRestore step f|
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1276
	rowNr := self yVisibleToLineNr:(p y).
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1277
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1278
	(rowNr notNil and:[rowNr ~~ prvLine]) ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1279
	    rowNr == lineNr ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1280
		mustRestore := true
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1281
	    ] ifFalse:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1282
		rowNr > lineNr ifTrue:[ mustRestore := (rowNr < prvLine) ]
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1283
			      ifFalse:[ mustRestore := (rowNr > prvLine) ].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1284
	    ].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1285
	    prvLine > rowNr ifTrue:[ step := -1 ]
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1286
			  ifFalse:[ step :=  1 ].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1287
	    mustRestore ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1288
		[ prvLine ~~ rowNr ] whileTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1289
		    (chgSet removeIdentical:prvLine ifAbsent:nil) notNil ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1290
			doAdd ifFalse:[ self addToSelection:prvLine ]
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1291
			       ifTrue:[ self removeFromSelection:prvLine ].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1292
		    ].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1293
		    prvLine := prvLine + step.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1294
		].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1295
	    ] ifFalse:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1296
		[ prvLine ~~ rowNr ] whileTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1297
		    prvLine := prvLine + step.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1298
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1299
		    doAdd ~~ (self isInSelection:rowNr) ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1300
			chgSet add:prvLine.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1301
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1302
			doAdd ifTrue:[ self addToSelection:prvLine ]
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1303
			     ifFalse:[ self removeFromSelection:prvLine ].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1304
		    ]
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1305
		].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1306
	    ].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1307
	].
1748
0a2213a15e06 support of auto scrolling
ca
parents: 1747
diff changeset
  1308
    ].
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1309
!
1748
0a2213a15e06 support of auto scrolling
ca
parents: 1747
diff changeset
  1310
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1311
buttonMotion:buttonMask x:x y:y
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1312
    "mouse-move while button was pressed - handle selection changes
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1313
    "
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1314
    |lnNr item|
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1315
1748
0a2213a15e06 support of auto scrolling
ca
parents: 1747
diff changeset
  1316
    self stopAutoScroll.
0a2213a15e06 support of auto scrolling
ca
parents: 1747
diff changeset
  1317
2441
9ca40d634ff8 attention - do no motionAction, if no button is pressed
Claus Gittinger <cg@exept.de>
parents: 2418
diff changeset
  1318
    (buttonMask ~~ 0 and:[buttonMotionAction notNil]) ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1319
	buttonMotionAction value:(x@y).
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1320
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1321
	(autoScroll and:[buttonMotionAction notNil]) ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1322
	    "/ if moved outside of view, start autoscroll
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1323
	    (y between:0 and:height) ifFalse:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1324
		y < 0 ifTrue:[ self startAutoScroll:#scrollUp distance:y ]
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1325
		     ifFalse:[ self startAutoScroll:#scrollDown distance:(y - height) ].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1326
	    ].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1327
	].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1328
	^ self
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1329
    ].
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1330
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1331
    (enabled and:[highlightEnterItem]) ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1332
	self sensor anyButtonPressed ifFalse:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1333
	    lnNr := self yVisibleToLineNr:y.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1334
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1335
	    lnNr notNil ifTrue:[ item := self at:lnNr ifAbsent:nil ]
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1336
		       ifFalse:[ item := nil ].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1337
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1338
	    self pointerEntersItem:item.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1339
	]
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1340
    ].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1341
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1342
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1343
buttonMultiPress:button x:x y:y
2948
9b7b7b2e0dcd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2947
diff changeset
  1344
    "button was pressed multiple - handle a doubleClick action"
9b7b7b2e0dcd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2947
diff changeset
  1345
4571
bf04b7618d7c class: SelectionInListModelView
Stefan Vogel <sv@exept.de>
parents: 4570
diff changeset
  1346
    |lnNr|
3704
c9b2102bfd1c handle doubleClick - element under point is not selected
ca
parents: 3684
diff changeset
  1347
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1348
    buttonMotionAction := buttonReleaseAction := nil.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1349
    enabled ifFalse:[^ self].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1350
5817
7779078ac861 #BUGFIX by sr
sr
parents: 5812
diff changeset
  1351
    (self hasToSkipButtonMultiPress:button x:x y:y) ifTrue:[
7779078ac861 #BUGFIX by sr
sr
parents: 5812
diff changeset
  1352
        self buttonPress:button x:x y:y.
7779078ac861 #BUGFIX by sr
sr
parents: 5812
diff changeset
  1353
        ^ self
7779078ac861 #BUGFIX by sr
sr
parents: 5812
diff changeset
  1354
    ].    
7779078ac861 #BUGFIX by sr
sr
parents: 5812
diff changeset
  1355
5158
ed46714ec203 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 5083
diff changeset
  1356
    button == 1 ifTrue:[
4043
532a328a9e0e changed: #buttonMultiPress:x:y:
Claus Gittinger <cg@exept.de>
parents: 3963
diff changeset
  1357
        (     (lnNr := self yVisibleToLineNr:y)   notNil
4571
bf04b7618d7c class: SelectionInListModelView
Stefan Vogel <sv@exept.de>
parents: 4570
diff changeset
  1358
         and:[(self at:lnNr ifAbsent:nil) notNil]
4043
532a328a9e0e changed: #buttonMultiPress:x:y:
Claus Gittinger <cg@exept.de>
parents: 3963
diff changeset
  1359
        ) ifTrue:[
5158
ed46714ec203 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 5083
diff changeset
  1360
            self selectedIndex ~~ lnNr ifTrue:[
4043
532a328a9e0e changed: #buttonMultiPress:x:y:
Claus Gittinger <cg@exept.de>
parents: 3963
diff changeset
  1361
                self breakPoint:#ca
3740
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1362
            ].
4043
532a328a9e0e changed: #buttonMultiPress:x:y:
Claus Gittinger <cg@exept.de>
parents: 3963
diff changeset
  1363
            self doubleClicked.
3740
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1364
        ].
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1365
        ^ self.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1366
    ].
2947
caa98c08d3cf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2920
diff changeset
  1367
2948
9b7b7b2e0dcd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2947
diff changeset
  1368
    super buttonMultiPress:button x:x y:y
4043
532a328a9e0e changed: #buttonMultiPress:x:y:
Claus Gittinger <cg@exept.de>
parents: 3963
diff changeset
  1369
532a328a9e0e changed: #buttonMultiPress:x:y:
Claus Gittinger <cg@exept.de>
parents: 3963
diff changeset
  1370
    "Modified: / 30-06-2011 / 20:04:28 / cg"
5817
7779078ac861 #BUGFIX by sr
sr
parents: 5812
diff changeset
  1371
    "Modified: / 22-06-2018 / 14:46:50 / sr"
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1372
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1373
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1374
buttonPress:button x:x y:y
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1375
    "a button was pressed - handle selection here
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1376
    "
3146
b7294baadfb7 button press, move and release behaviour
ca
parents: 3137
diff changeset
  1377
    |sensor item menu appl isSelected lineNr startLine dragDistance|
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1378
3205
7ff2e20b37d4 *** empty log message ***
ca
parents: 3202
diff changeset
  1379
    modelChangedDuringButtonPress := buttonMotionAction := buttonReleaseAction := nil.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1380
2323
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
  1381
    self pointerEntersItem:nil.
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1382
    self cursorEntersItem:nil.
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1383
    self closeEditor.
2323
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
  1384
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1385
    enabled ifFalse:[^ self].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1386
2228
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
  1387
    sensor := self sensor.
2399
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  1388
    lineNr := self yVisibleToLineNr:y.
2228
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
  1389
3740
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1390
    (button == 2) ifTrue:[
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1391
        (self selectOnMenuButton and:[self numberOfSelections <= 1]) ifTrue:[
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1392
            (     lineNr notNil
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1393
             and:[self canSelectIndex:lineNr forAdd:false ]
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1394
            ) ifTrue:[
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1395
                (lineNr ~~ self selectedIndex) ifTrue: [
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1396
                    (self selectWithoutScroll:lineNr redraw:true) ifTrue:[
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1397
                        self selectionChanged
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1398
                    ].
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1399
                ].
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1400
            ]
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1401
        ].
3750
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1402
        item := self selectedElement.
3740
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1403
        item notNil ifTrue:[
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1404
            self makeSelectionVisible.
3750
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1405
"/ now in activateMenu...
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1406
"/            menu := item perform:#middleButtonMenu ifNotUnderstood:nil.
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1407
"/            menu notNil ifTrue:[
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1408
"/                menu isCollection ifTrue:[
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1409
"/                    menu := Menu decodeFromLiteralArray:menu.
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1410
"/                    appl := self application.
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1411
"/
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1412
"/                    appl notNil ifTrue:[
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1413
"/                        menu findGuiResourcesIn:appl.
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1414
"/                        "/ menu receiver:appl  -- now done in findGuiResources ...
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1415
"/                    ] ifFalse:[
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1416
"/                        menu receiver:item
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1417
"/                    ]
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1418
"/                ].
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1419
"/                self startUpMenu:menu.
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1420
"/                ^ self
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1421
"/            ].
3740
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1422
        ].
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1423
        super buttonPress:button x:x y:y.
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1424
        ^ self
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1425
    ].
3750
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1426
2399
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  1427
    lineNr isNil ifTrue:[ ^ self ].
3205
7ff2e20b37d4 *** empty log message ***
ca
parents: 3202
diff changeset
  1428
    modelChangedDuringButtonPress := false.
1578
cfa573485242 ask for middleButtonMenu if menuButton pressed
ca
parents: 1569
diff changeset
  1429
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1430
    sensor ctrlDown ifTrue:[
3740
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1431
        self buttonControlPressAtLine:lineNr x:x y:y.
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1432
        ^ self
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1433
    ].
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1434
2976
136d983423ab drag & drop activation if moving horizontal n pixels
ca
parents: 2964
diff changeset
  1435
    isSelected  := self isInSelection:lineNr.
136d983423ab drag & drop activation if moving horizontal n pixels
ca
parents: 2964
diff changeset
  1436
136d983423ab drag & drop activation if moving horizontal n pixels
ca
parents: 2964
diff changeset
  1437
    (self canDrag and:[sensor shiftDown not]) ifTrue:[
3740
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1438
        dragDistance := UserPreferences current motionDistanceToStartDrag.
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1439
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1440
        isSelected ifTrue:[
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1441
            buttonMotionAction :=
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1442
                [:p|
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1443
                    ((x@y) dist:p) > dragDistance ifTrue:[
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1444
                        self startDragAt:p.
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1445
                    ]
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1446
                ].
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1447
            buttonReleaseAction := [ self buttonPressOrReleaseAtLine:lineNr x:x y:y ].
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1448
            ^ self.
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1449
        ].
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1450
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1451
        self selectOnButtonPress ifFalse: [
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1452
            |oldSelection|
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1453
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1454
            "/ set selection to line;
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1455
            "/ set the model without change notification (objects to drag)
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1456
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1457
            oldSelection := selection copy.
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1458
            self selectAndUpdateModelWithoutChangeNotification: lineNr.
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1459
            self windowGroup processExposeEvents.
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1460
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1461
            buttonMotionAction :=
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1462
                [:p|
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1463
                    ((x@y) dist:p) > dragDistance ifTrue:[
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1464
                        |handler|
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1465
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1466
                        handler := self startDragAt:p.
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1467
                        handler contentsWillChange.
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1468
                        "/ restore old selection
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1469
                        self selectAndUpdateModelWithoutChangeNotification: oldSelection.
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1470
                        self windowGroup processExposeEvents.
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1471
                    ].
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1472
                ].
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1473
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1474
            buttonReleaseAction := [
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1475
                (self canSelectIndex:lineNr forAdd:false) ifTrue:[
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1476
                    "/ notify selection change
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1477
                    self selectionChanged.
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1478
                ] ifFalse:[
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1479
                    "/ restore old selection
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1480
                    self selectAndUpdateModelWithoutChangeNotification: oldSelection.
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1481
                ].
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1482
            ].
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1483
            ^ self
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1484
        ].
2976
136d983423ab drag & drop activation if moving horizontal n pixels
ca
parents: 2964
diff changeset
  1485
    ].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1486
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1487
    multipleSelectOk ifFalse:[
3740
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1488
        (isSelected or:[self canSelectIndex:lineNr forAdd:false]) ifTrue:[
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1489
            self buttonPressOrReleaseAtLine:lineNr x:x y:y.
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1490
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1491
            (dragDistance notNil and:[self isInSelection:lineNr]) ifTrue:[
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1492
                buttonMotionAction :=
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1493
                    [:p|
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1494
                        ((x@y) dist:p) > dragDistance ifTrue:[
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1495
                            self startDragAt:p.
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1496
                        ].
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1497
                    ].
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1498
            ].
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1499
        ].
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1500
        ^ self
2399
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  1501
    ].
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1502
    startLine := lineNr.
2399
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  1503
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1504
    sensor shiftDown ifTrue:[ |min max|
3740
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1505
        (isSelected or:[self canSelectIndex:lineNr forAdd:true]) ifFalse:[
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1506
            ^ self
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1507
        ].
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1508
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1509
        multipleSelectOk ifTrue:[
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1510
            startLine := self firstInSelection.
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1511
            startLine isNil ifTrue:[ startLine := lineNr ].
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1512
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1513
            startLine <= lineNr ifTrue:[
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1514
                self selectFrom:startLine to:lineNr.
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1515
            ] ifFalse:[
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1516
                startLine := self lastInSelection.
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1517
                self selectFrom:lineNr to:startLine.
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1518
            ].
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1519
        ]
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1520
    ] ifFalse:[
3740
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1521
        (isSelected or:[self canSelectIndex:lineNr forAdd:false]) ifFalse:[
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1522
            ^ self
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1523
        ].
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1524
        self buttonPressOrReleaseAtLine:lineNr x:x y:y.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1525
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1526
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1527
    multipleSelectOk ifTrue:[
3740
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1528
        buttonMotionAction :=
4483
b3f21fdb636c class: SelectionInListModelView
Stefan Vogel <sv@exept.de>
parents: 4318
diff changeset
  1529
            [:p| 
3740
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1530
                (p y between:0 and:height) ifTrue:[ |ln|
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1531
                    ln := self yVisibleToLineNr:p y.
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1532
                    ln isNil ifTrue:[ln := self size].
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1533
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1534
                    (ln ~~ self lastInSelection and:[ln ~~ self firstInSelection]) ifTrue:[
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1535
                        self selectFrom:startLine to:ln.
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1536
                        dragDistance := nil.   "/ selection changed - no longer dragable
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1537
                    ]
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1538
                ].
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1539
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1540
                (dragDistance notNil and:[(x dist:p x) > dragDistance]) ifTrue:[
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1541
                    self startDragAt:p.
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1542
                ].
67a77c2fcb03 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3728
diff changeset
  1543
            ].
1915
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
  1544
    ].
3221
af3fae427c7e use decodeFromLiteralArray
Claus Gittinger <cg@exept.de>
parents: 3205
diff changeset
  1545
af3fae427c7e use decodeFromLiteralArray
Claus Gittinger <cg@exept.de>
parents: 3205
diff changeset
  1546
    "Modified: / 27-03-2007 / 08:43:58 / cg"
1915
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
  1547
!
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
  1548
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
  1549
buttonPressOrReleaseAtLine:aLnNr x:x y:y
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
  1550
    "handle a button press or release at a line
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
  1551
    "
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
  1552
    aLnNr == self selectedIndex ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1553
	editorView notNil ifTrue:[^ self].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1554
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1555
	self openEditorAction notNil ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1556
	    self openEditorAtX:x y:y.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1557
	    editorView notNil ifTrue:[^ self].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1558
	].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1559
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1560
	ignoreReselect ifFalse:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1561
	    (toggleSelect and:[self sensor ctrlDown]) ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1562
		self selection:nil
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1563
	    ] ifFalse:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1564
		self selectionChanged
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1565
	    ].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1566
	].
1915
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
  1567
    ] ifFalse:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1568
	(self selectWithoutScroll:aLnNr redraw:true) ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1569
	    self selectionChanged
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1570
	]
1741
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
  1571
    ].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1572
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1573
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1574
buttonRelease:button x:x y:y
3750
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1575
    "a button was released"
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1576
3205
7ff2e20b37d4 *** empty log message ***
ca
parents: 3202
diff changeset
  1577
    |makeSelectionVisible|
7ff2e20b37d4 *** empty log message ***
ca
parents: 3202
diff changeset
  1578
3750
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1579
    button == 1 ifTrue:[
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1580
        makeSelectionVisible := modelChangedDuringButtonPress.
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1581
        buttonMotionAction   := modelChangedDuringButtonPress := nil.
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1582
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1583
        buttonReleaseAction notNil ifTrue:[
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1584
            buttonReleaseAction value.
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1585
            buttonReleaseAction := nil.
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1586
        ].
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1587
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1588
        self cursorEntersItem:nil.
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1589
    ].
1748
0a2213a15e06 support of auto scrolling
ca
parents: 1747
diff changeset
  1590
    self stopAutoScroll.
3205
7ff2e20b37d4 *** empty log message ***
ca
parents: 3202
diff changeset
  1591
7ff2e20b37d4 *** empty log message ***
ca
parents: 3202
diff changeset
  1592
    (makeSelectionVisible == true and:[self hasSelection]) ifTrue:[
3750
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1593
        self makeSelectionVisible
3205
7ff2e20b37d4 *** empty log message ***
ca
parents: 3202
diff changeset
  1594
    ].
3750
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1595
948546ea76a5 fixed handling of menu button (fire on release)
Claus Gittinger <cg@exept.de>
parents: 3740
diff changeset
  1596
    super buttonRelease:button x:x y:y
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1597
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1598
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1599
characterPress:aKey x:x y:y
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1600
    " a character is pressed - lookup and change selection
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1601
    "
2482
13acaaf02528 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2455
diff changeset
  1602
    |lnNr size idx stp to1 fr2|
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1603
2418
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1604
    size := self size.
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1605
    size > 1 ifFalse:[^ self].
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1606
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1607
    lnNr := self firstInSelection.
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1608
    lnNr isNil ifTrue:[lnNr := 0].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1609
2482
13acaaf02528 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2455
diff changeset
  1610
    self sensor shiftDown ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1611
	stp := -1.              "/ search backward
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1612
	to1 :=  1.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1613
	fr2 := size.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1614
    ] ifFalse:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1615
	stp := 1.               "/ search forward
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1616
	to1 := size.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1617
	fr2 := 1.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1618
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1619
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1620
    idx := self findLineFrom:lnNr+stp to:to1 by:stp startingWithCharacter:aKey.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1621
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1622
    idx == 0 ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1623
	idx := self findLineFrom:fr2 to:lnNr-stp by:stp startingWithCharacter:aKey.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1624
	idx == 0 ifTrue:[^ self].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1625
    ].
2418
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1626
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1627
    self selection:idx.
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1628
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1629
    keyActionStyle == #selectAndDoubleClick ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1630
	self doubleClicked
2418
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1631
    ].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1632
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1633
1768
04b330a75f75 allow for subclasses to redefine character search
Claus Gittinger <cg@exept.de>
parents: 1758
diff changeset
  1634
characterSearchItemStringAt:anIndex
2418
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1635
    "for first-character search:
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1636
     return a lines item-string.
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1637
     For multi-col items, this may be different from the actual string
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1638
    "
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1639
    |item s|
1768
04b330a75f75 allow for subclasses to redefine character search
Claus Gittinger <cg@exept.de>
parents: 1758
diff changeset
  1640
2408
8b0d11537dc0 accessing list indirect
ca
parents: 2404
diff changeset
  1641
    item := self at:anIndex ifAbsent:nil.
2418
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1642
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1643
    item isHierarchicalItem ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1644
	item := item string
2418
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1645
    ].
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1646
    item isNil ifTrue:[^ nil].
1768
04b330a75f75 allow for subclasses to redefine character search
Claus Gittinger <cg@exept.de>
parents: 1758
diff changeset
  1647
2455
44300555526c Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 2447
diff changeset
  1648
    (Error catch:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1649
	s := item asString
2418
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1650
    ]) ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1651
	s := item displayString
2418
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1652
    ].
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1653
    ^ s
1768
04b330a75f75 allow for subclasses to redefine character search
Claus Gittinger <cg@exept.de>
parents: 1758
diff changeset
  1654
!
04b330a75f75 allow for subclasses to redefine character search
Claus Gittinger <cg@exept.de>
parents: 1758
diff changeset
  1655
1917
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1656
containerChangedSize
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1657
    "/ 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
  1658
    "/ 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
  1659
    "/     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
  1660
2409
68095c891ceb reuse selection methods (prepared for common controller)
ca
parents: 2408
diff changeset
  1661
    self hasSelection ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1662
	(hilightFrameColor notNil
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1663
	or:[hilightStyle == #motif
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1664
	or:[hilightLevel ~~ 0]]) ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1665
	   "/ invalidate the right-edge
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1666
	    self invalidate:(((width-3) @ 0) corner:((width-1) @ (height-1))).
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1667
	]
1917
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1668
    ].
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1669
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1670
    super containerChangedSize.
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1671
!
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1672
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1673
cursorEntersItem:anItemOrNil
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1674
    "the cursor enters an item or nil
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1675
    "
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1676
    |lnNr x|
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1677
2408
8b0d11537dc0 accessing list indirect
ca
parents: 2404
diff changeset
  1678
    (shown and:[self size ~~ 0]) ifFalse:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1679
	cursorItem := nil.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1680
	^ self.
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1681
    ].
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1682
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1683
    anItemOrNil == cursorItem ifTrue:[ ^ self ].
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1684
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1685
    2 timesRepeat:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1686
	cursorItem notNil ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1687
	    lnNr := self identityIndexOf:cursorItem.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1688
	    lnNr notNil ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1689
		x := self xVisibleOfItem:cursorItem.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1690
		self invalidateLineAt:lnNr fromX:x
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1691
	    ].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1692
	].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1693
	"/ set the new item
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1694
	cursorItem := anItemOrNil.
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1695
    ].
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1696
    cursorItem notNil ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1697
	self makeLineVisible:lnNr
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1698
    ].
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1699
!
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1700
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1701
doubleClicked
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1702
    "handle a double click
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1703
    "
2416
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
  1704
    |arg|
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
  1705
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
  1706
    doubleClickActionBlock notNil ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1707
	arg := self selectedIndex.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1708
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1709
	arg ~~ 0 ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1710
	    doubleClickActionBlock valueWithOptionalArgument:arg and:self.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1711
	]
2416
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
  1712
    ].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1713
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1714
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1715
findLineFrom:aStart to:aStop by:aStep startingWithCharacter:aCharacter
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1716
    "find a line starting with a character
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1717
    "
2408
8b0d11537dc0 accessing list indirect
ca
parents: 2404
diff changeset
  1718
    |char lbl cmp
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1719
     size     "{ Class:SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1720
     start    "{ Class:SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1721
     stop     "{ Class:SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1722
    |
2408
8b0d11537dc0 accessing list indirect
ca
parents: 2404
diff changeset
  1723
    (size := self size) ~~ 0 ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1724
	aStep > 0 ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1725
	    aStart > aStop ifTrue:[^ 0].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1726
	] ifFalse:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1727
	    (aStep == 0 or:[aStop > aStart]) ifTrue:[^ 0]
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1728
	].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1729
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1730
	start := aStart < 0 ifTrue:[1] ifFalse:[aStart min:size].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1731
	stop  := aStop  < 0 ifTrue:[1] ifFalse:[aStop  min:size].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1732
	char  := aCharacter asUppercase.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1733
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1734
	start to:stop by:aStep do:[:anIndex|
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1735
	    lbl := self characterSearchItemStringAt:anIndex.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1736
	    lbl notNil ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1737
		cmp := lbl string at:1 ifAbsent:nil.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1738
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1739
		cmp notNil ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1740
		    (char == cmp or:[char == cmp asUppercase]) ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1741
			(self canSelectIndex:anIndex forAdd:false) ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1742
			    ^ anIndex
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1743
			].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1744
			^ 0
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1745
		    ]
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1746
		]
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1747
	    ]
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1748
	]
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1749
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1750
    ^ 0
3081
0af6dce8cbf0 first look for the next item then do a select check
fm
parents: 2976
diff changeset
  1751
0af6dce8cbf0 first look for the next item then do a select check
fm
parents: 2976
diff changeset
  1752
    "Modified: / 15-09-2006 / 11:26:29 / User"
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1753
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1754
3338
01ad784543fc no underline-highlighting
Claus Gittinger <cg@exept.de>
parents: 3275
diff changeset
  1755
invalidateLineOfItem:anItem
01ad784543fc no underline-highlighting
Claus Gittinger <cg@exept.de>
parents: 3275
diff changeset
  1756
    |lnNr x|
01ad784543fc no underline-highlighting
Claus Gittinger <cg@exept.de>
parents: 3275
diff changeset
  1757
01ad784543fc no underline-highlighting
Claus Gittinger <cg@exept.de>
parents: 3275
diff changeset
  1758
    lnNr := self identityIndexOf:enterItem.
01ad784543fc no underline-highlighting
Claus Gittinger <cg@exept.de>
parents: 3275
diff changeset
  1759
    lnNr notNil ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1760
	x := self xVisibleOfItem:enterItem.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1761
	self invalidateLineAt:lnNr fromX:x
3338
01ad784543fc no underline-highlighting
Claus Gittinger <cg@exept.de>
parents: 3275
diff changeset
  1762
    ].
01ad784543fc no underline-highlighting
Claus Gittinger <cg@exept.de>
parents: 3275
diff changeset
  1763
!
01ad784543fc no underline-highlighting
Claus Gittinger <cg@exept.de>
parents: 3275
diff changeset
  1764
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1765
keyPress:aKey x:x y:y
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1766
    "a key was pressed - handle page-keys here
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1767
    "
2365
bdf6954a0358 key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents: 2361
diff changeset
  1768
    <resource: #keyboard( #CursorUp #CursorDown #EndOfText #EndOfLine
4181
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1769
                          #BeginOfText #BeginOfLine #Return
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1770
                          #CmdReturn #CmdCursorUp #CmdCursorDown #SelectAll)>
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1771
2413
49f5c28b1364 key handling
ca
parents: 2410
diff changeset
  1772
    |lineNr listSize shifted newSel step start|
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1773
5794
1de9ace50ec4 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5792
diff changeset
  1774
    enabled ifFalse:[ 
1de9ace50ec4 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5792
diff changeset
  1775
        super keyPress:aKey x:x y:y.
1de9ace50ec4 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5792
diff changeset
  1776
        ^ self 
1de9ace50ec4 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5792
diff changeset
  1777
    ].
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1778
2408
8b0d11537dc0 accessing list indirect
ca
parents: 2404
diff changeset
  1779
    listSize := self size.
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1780
    listSize == 0 ifTrue:[^ self].
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1781
2365
bdf6954a0358 key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents: 2361
diff changeset
  1782
    aKey isCharacter ifTrue:[
4181
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1783
        keyActionStyle notNil ifTrue:[
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1784
            keyActionStyle == #pass ifTrue:[
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1785
                super keyPress:aKey x:x y:y
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1786
            ] ifFalse:[
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1787
                self characterPress:aKey x:x y:y.
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1788
            ].
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1789
        ].
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1790
        ^ self
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1791
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1792
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1793
    aKey == #Escape ifTrue:[
4181
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1794
        cursorItem notNil ifTrue:[
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1795
            self cursorEntersItem:nil.
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1796
            self makeSelectionVisible.
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1797
        ].
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1798
        super keyPress:aKey x:x y:y.
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1799
        ^ self
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1800
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1801
2365
bdf6954a0358 key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents: 2361
diff changeset
  1802
    ((aKey == #BeginOfText) or:[aKey == #BeginOfLine]) ifTrue:[
4181
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1803
        self cursorEntersItem:nil.
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1804
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1805
        1 to:listSize do:[:i|
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1806
            (self canSelectIndex:i forAdd:false) ifTrue:[
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1807
                self selection:i.
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1808
                ^ self
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1809
            ].
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1810
        ].
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1811
        ^ self
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1812
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1813
2365
bdf6954a0358 key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents: 2361
diff changeset
  1814
    ((aKey == #EndOfText) or:[aKey == #EndOfLine]) ifTrue:[
4181
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1815
        self cursorEntersItem:nil.
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1816
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1817
        listSize to:1 by:-1 do:[:i|
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1818
            (self canSelectIndex:i forAdd:false) ifTrue:[
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1819
                self selection:i.
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1820
                ^ self
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1821
            ].
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1822
        ].
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1823
        ^ self
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1824
    ].
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1825
    lineNr := self cursorLine.
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1826
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1827
    aKey == #Return ifTrue:[
4181
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1828
        returnKeyActionStyle == #pass ifTrue:[
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1829
            super keyPress:aKey x:x y:y
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1830
        ] ifFalse:[
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1831
            lineNr ~~ 0 ifTrue:[
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1832
                self cursorEntersItem:nil.
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1833
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1834
                (self canSelectIndex:lineNr forAdd:false) ifTrue:[
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1835
                    self selection:lineNr
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1836
                ].
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1837
            ].
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1838
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1839
            returnKeyActionStyle == #doubleClick ifTrue:[
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1840
                self doubleClicked
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1841
            ].
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1842
        ].
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1843
        ^ self
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1844
    ].
2413
49f5c28b1364 key handling
ca
parents: 2410
diff changeset
  1845
3607
bec9e4c71bf4 implemented #selectAll
Claus Gittinger <cg@exept.de>
parents: 3526
diff changeset
  1846
    aKey == #SelectAll ifTrue:[
4181
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1847
        self selectAll.
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1848
        ^ self
3607
bec9e4c71bf4 implemented #selectAll
Claus Gittinger <cg@exept.de>
parents: 3526
diff changeset
  1849
    ].
bec9e4c71bf4 implemented #selectAll
Claus Gittinger <cg@exept.de>
parents: 3526
diff changeset
  1850
2413
49f5c28b1364 key handling
ca
parents: 2410
diff changeset
  1851
    (lineNr == 0 and:[selection notNil]) ifTrue:[
4181
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1852
        multipleSelectOk ifFalse:[lineNr := selection]
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1853
                          ifTrue:[lineNr := selection last].
2413
49f5c28b1364 key handling
ca
parents: 2410
diff changeset
  1854
    ].
49f5c28b1364 key handling
ca
parents: 2410
diff changeset
  1855
49f5c28b1364 key handling
ca
parents: 2410
diff changeset
  1856
    aKey == #CmdReturn ifTrue:[
4181
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1857
        "/ toggle selection of the item
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1858
        lineNr ~~ 0 ifTrue:[
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1859
            (self isInSelection:lineNr) ifTrue:[ self removeFromSelection:lineNr ]
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1860
                                       ifFalse:[ self addToSelection:lineNr ].
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1861
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1862
            self cursorEntersItem:(self at:lineNr).
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1863
        ].
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1864
        ^ self
2413
49f5c28b1364 key handling
ca
parents: 2410
diff changeset
  1865
    ].
49f5c28b1364 key handling
ca
parents: 2410
diff changeset
  1866
49f5c28b1364 key handling
ca
parents: 2410
diff changeset
  1867
    (aKey == #CmdCursorDown or:[aKey == #CmdCursorUp]) ifTrue:[
4181
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1868
        aKey == #CmdCursorDown ifTrue:[
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1869
            lineNr := lineNr + 1.
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1870
            lineNr > listSize ifTrue:[lineNr := 1].
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1871
        ] ifFalse:[
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1872
            lineNr := lineNr - 1.
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1873
            lineNr < 1 ifTrue:[lineNr := listSize].
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1874
        ].
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1875
        self cursorEntersItem:(self at:lineNr).
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1876
        ^ self
2413
49f5c28b1364 key handling
ca
parents: 2410
diff changeset
  1877
    ].
49f5c28b1364 key handling
ca
parents: 2410
diff changeset
  1878
49f5c28b1364 key handling
ca
parents: 2410
diff changeset
  1879
    (aKey == #CursorUp or:[aKey == #CursorDown]) ifFalse:[
4181
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1880
        super keyPress:aKey x:x y:y.
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1881
        ^ self
2365
bdf6954a0358 key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents: 2361
diff changeset
  1882
    ].
2413
49f5c28b1364 key handling
ca
parents: 2410
diff changeset
  1883
    shifted := (multipleSelectOk and:[self sensor shiftDown]).
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1884
    self cursorEntersItem:nil.
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1885
2671
bba7717907bb compress keyEvents cursor Up and Down
ca
parents: 2670
diff changeset
  1886
    aKey == #CursorDown ifTrue:[ step :=  1.]
4181
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1887
                       ifFalse:[ step := -1.].
2671
bba7717907bb compress keyEvents cursor Up and Down
ca
parents: 2670
diff changeset
  1888
bba7717907bb compress keyEvents cursor Up and Down
ca
parents: 2670
diff changeset
  1889
    shifted ifFalse:[ |compressed|
4181
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1890
        compressed := self sensor compressKeyPressEventsWithKey:aKey.
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1891
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1892
        compressed ~~ 0 ifTrue:[
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1893
            aKey == #CursorDown ifTrue:[
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1894
                lineNr := lineNr + compressed.
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1895
                lineNr > listSize ifTrue:[lineNr := 1].
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1896
            ] ifFalse:[
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1897
                lineNr := lineNr - compressed.
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1898
                lineNr < 1 ifTrue:[lineNr := listSize].
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1899
            ].
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1900
        ].
2671
bba7717907bb compress keyEvents cursor Up and Down
ca
parents: 2670
diff changeset
  1901
    ].
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1902
    start  := lineNr.
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1903
    lineNr := lineNr + step.
2368
8101aa8d50d2 cursor select behaviour in: #keyPress:x:y:
ca
parents: 2365
diff changeset
  1904
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1905
    [ lineNr ~~ start ] whileTrue:[
4181
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1906
        (lineNr between:1 and:listSize) ifFalse:[
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1907
            lineNr < 1 ifTrue:[ lineNr := listSize ]
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1908
                      ifFalse:[ lineNr := 1 ].
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1909
        ] ifTrue:[
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1910
            (self canSelectIndex:lineNr forAdd:shifted) ifTrue:[
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1911
                shifted ifFalse:[
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1912
                    self selection:lineNr.
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1913
                    ^ self
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1914
                ].
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1915
                (self isInSelection:lineNr) ifFalse:[
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1916
                    selection isNil ifTrue:[ newSel := Array with:lineNr ]
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1917
                                   ifFalse:[ newSel := selection copyWith:lineNr ].
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1918
                ] ifTrue:[
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1919
                    (start ~~ 0 and:[selection size > 1]) ifFalse:[
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1920
                        ^ self
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1921
                    ].
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1922
                    newSel := selection copyWithout:start.
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1923
                ].
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1924
                self selection:newSel.
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1925
"/                self selectWithoutScroll:newSel redraw:true.
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1926
"/                self makeLineVisible:lineNr.
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1927
"/                self selectionChanged.
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1928
                ^ self
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1929
            ].
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1930
            lineNr := lineNr + step.
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  1931
        ]
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1932
    ].
5794
1de9ace50ec4 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5792
diff changeset
  1933
1de9ace50ec4 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5792
diff changeset
  1934
    "Modified: / 09-06-2018 / 09:28:00 / Claus Gittinger"
1917
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1935
!
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1936
2323
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
  1937
pointerEntersItem:anItemOrNil
4571
bf04b7618d7c class: SelectionInListModelView
Stefan Vogel <sv@exept.de>
parents: 4570
diff changeset
  1938
    "the pointer moves over an item or nil"
2323
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
  1939
2408
8b0d11537dc0 accessing list indirect
ca
parents: 2404
diff changeset
  1940
    (shown and:[self size ~~ 0]) ifFalse:[
4571
bf04b7618d7c class: SelectionInListModelView
Stefan Vogel <sv@exept.de>
parents: 4570
diff changeset
  1941
        enterItem := nil.
bf04b7618d7c class: SelectionInListModelView
Stefan Vogel <sv@exept.de>
parents: 4570
diff changeset
  1942
        ^ self.
2323
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
  1943
    ].
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
  1944
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
  1945
    anItemOrNil == enterItem ifTrue:[ ^ self ].
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
  1946
3338
01ad784543fc no underline-highlighting
Claus Gittinger <cg@exept.de>
parents: 3275
diff changeset
  1947
    enterItem notNil ifTrue:[ self invalidateLineOfItem:enterItem ].
01ad784543fc no underline-highlighting
Claus Gittinger <cg@exept.de>
parents: 3275
diff changeset
  1948
    enterItem := anItemOrNil.
01ad784543fc no underline-highlighting
Claus Gittinger <cg@exept.de>
parents: 3275
diff changeset
  1949
    enterItem notNil ifTrue:[ self invalidateLineOfItem:enterItem ].
2323
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
  1950
!
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
  1951
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
  1952
pointerLeave:state
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
  1953
    self pointerEntersItem:nil.
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
  1954
    super pointerLeave:state.
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
  1955
!
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
  1956
1917
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1957
sizeChanged:how
2274
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  1958
    |selectionWasVisible|
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  1959
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  1960
    selectionWasVisible := false.
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  1961
1917
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1962
    "/ 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
  1963
    "/ 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
  1964
    "/     draw the frame at the top and bottom, but NOT at the left and right
2409
68095c891ceb reuse selection methods (prepared for common controller)
ca
parents: 2408
diff changeset
  1965
68095c891ceb reuse selection methods (prepared for common controller)
ca
parents: 2408
diff changeset
  1966
    self hasSelection ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1967
	selectionWasVisible := self isSelectionVisibleIn:(previousExtent ? self extent).
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1968
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1969
	(hilightFrameColor notNil
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1970
	or:[hilightStyle == #motif
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1971
	or:[hilightLevel ~~ 0]]) ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1972
	   "/ invalidate the right-edge
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1973
	    self invalidate:(((width-3) @ 0) corner:((width-1) @ (height-1))).
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1974
	].
1917
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1975
    ].
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1976
    super sizeChanged:how.
2274
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  1977
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  1978
    selectionWasVisible ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  1979
	self makeSelectionVisible
2274
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  1980
    ].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1981
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1982
1421
95ac3092660a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1409
diff changeset
  1983
!SelectionInListModelView methodsFor:'focus handling'!
95ac3092660a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1409
diff changeset
  1984
3137
7e8fae56b94c highlight selection dependent on has focus
ca
parents: 3081
diff changeset
  1985
showFocus:explicit
7e8fae56b94c highlight selection dependent on has focus
ca
parents: 3081
diff changeset
  1986
    self invalidateSelection.
7e8fae56b94c highlight selection dependent on has focus
ca
parents: 3081
diff changeset
  1987
    super showFocus:explicit
7e8fae56b94c highlight selection dependent on has focus
ca
parents: 3081
diff changeset
  1988
!
7e8fae56b94c highlight selection dependent on has focus
ca
parents: 3081
diff changeset
  1989
7e8fae56b94c highlight selection dependent on has focus
ca
parents: 3081
diff changeset
  1990
showNoFocus:explicit
7e8fae56b94c highlight selection dependent on has focus
ca
parents: 3081
diff changeset
  1991
    self invalidateSelection.
7e8fae56b94c highlight selection dependent on has focus
ca
parents: 3081
diff changeset
  1992
    super showNoFocus:explicit
7e8fae56b94c highlight selection dependent on has focus
ca
parents: 3081
diff changeset
  1993
!
7e8fae56b94c highlight selection dependent on has focus
ca
parents: 3081
diff changeset
  1994
1421
95ac3092660a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1409
diff changeset
  1995
wantsFocusWithPointerEnter
95ac3092660a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1409
diff changeset
  1996
    "return true, if I want the focus when
95ac3092660a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1409
diff changeset
  1997
     the mouse pointer enters"
95ac3092660a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1409
diff changeset
  1998
2701
d95a0a764f4d do return false in #wantsFocusWithPointerEnter if an ecitor is open
ca
parents: 2671
diff changeset
  1999
    (editorView notNil and:[editorView realized]) ifTrue:[
6015
2eabdcac77fb #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5918
diff changeset
  2000
        ^ false
2701
d95a0a764f4d do return false in #wantsFocusWithPointerEnter if an ecitor is open
ca
parents: 2671
diff changeset
  2001
    ].
d95a0a764f4d do return false in #wantsFocusWithPointerEnter if an ecitor is open
ca
parents: 2671
diff changeset
  2002
2959
afaf27dffcc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2948
diff changeset
  2003
    (UserPreferences current focusFollowsMouse ~~ false
1421
95ac3092660a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1409
diff changeset
  2004
    and:[(styleSheet at:#'selection.requestFocusOnPointerEnter' default:true)
95ac3092660a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1409
diff changeset
  2005
    ]) ifTrue:[
6015
2eabdcac77fb #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5918
diff changeset
  2006
        self size ~~ 0 ifTrue:[
2eabdcac77fb #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5918
diff changeset
  2007
            ^ true
2eabdcac77fb #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5918
diff changeset
  2008
        ]
1421
95ac3092660a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1409
diff changeset
  2009
    ].
95ac3092660a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1409
diff changeset
  2010
    ^ false
6015
2eabdcac77fb #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5918
diff changeset
  2011
2eabdcac77fb #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5918
diff changeset
  2012
    "Modified: / 01-03-2019 / 16:10:12 / Claus Gittinger"
1421
95ac3092660a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1409
diff changeset
  2013
! !
95ac3092660a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1409
diff changeset
  2014
5069
fac483ef2664 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5065
diff changeset
  2015
!SelectionInListModelView methodsFor:'help'!
fac483ef2664 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5065
diff changeset
  2016
5677
6b247ffd5944 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5663
diff changeset
  2017
helpTextAt:aPoint
5069
fac483ef2664 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5065
diff changeset
  2018
    "for lines which are clipped, provide the full line as a tooltip
5790
d588526dd9b7 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5776
diff changeset
  2019
     (as in other listviews)"
5069
fac483ef2664 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5065
diff changeset
  2020
     
5790
d588526dd9b7 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5776
diff changeset
  2021
    |lineNr len item line text text2|
5069
fac483ef2664 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5065
diff changeset
  2022
5083
6cd08a5a19a6 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5073
diff changeset
  2023
    lineNr := self yVisibleToLineNr:aPoint y.
5069
fac483ef2664 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5065
diff changeset
  2024
    lineNr isNil ifTrue:[ ^ nil ].
fac483ef2664 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5065
diff changeset
  2025
5790
d588526dd9b7 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5776
diff changeset
  2026
    item := self at:lineNr ifAbsent:nil.
d588526dd9b7 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5776
diff changeset
  2027
    item notNil ifTrue:[
d588526dd9b7 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5776
diff changeset
  2028
        line := item perform:#label ifNotUnderstood:[item displayString].
5796
10442dd55669 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5794
diff changeset
  2029
        (line isString or:[line isLabelAndIcon]) ifTrue:[
5792
3a3d58d1a9da #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5791
diff changeset
  2030
            line := line string.
3a3d58d1a9da #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5791
diff changeset
  2031
            line := line withoutSeparators.
3a3d58d1a9da #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5791
diff changeset
  2032
        ].
5790
d588526dd9b7 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5776
diff changeset
  2033
    ].
d588526dd9b7 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5776
diff changeset
  2034
    line notNil ifTrue:[
d588526dd9b7 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5776
diff changeset
  2035
        len := self widthOfWidestLineBetween:lineNr and:lineNr.
d588526dd9b7 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5776
diff changeset
  2036
        len > width ifTrue:[
5796
10442dd55669 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5794
diff changeset
  2037
            (line isString or:[line isLabelAndIcon]) ifTrue:[
6046
076bfb11d13d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6039
diff changeset
  2038
                "/ replace tabs and newlines by spaces
076bfb11d13d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6039
diff changeset
  2039
                text := line asStringCollection
076bfb11d13d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6039
diff changeset
  2040
                            collect:[:eachLine |
076bfb11d13d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6039
diff changeset
  2041
                                eachLine string collect:[:ch | ch isSeparator ifTrue:[Character space] ifFalse:[ch]].
076bfb11d13d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6039
diff changeset
  2042
                            ].
076bfb11d13d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6039
diff changeset
  2043
                text size > 20 ifTrue:[
076bfb11d13d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6039
diff changeset
  2044
                    text := (text copyTo:20),'...'
076bfb11d13d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6039
diff changeset
  2045
                ].
076bfb11d13d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6039
diff changeset
  2046
                text := text asString.
5796
10442dd55669 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5794
diff changeset
  2047
            ].
5790
d588526dd9b7 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5776
diff changeset
  2048
        ].
5918
904274a738a8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5898
diff changeset
  2049
    ].    
904274a738a8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5898
diff changeset
  2050
    "/ a hack; maybe we'll find a better solution...
904274a738a8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5898
diff changeset
  2051
    ((item ? line) respondsTo:#helpText) ifTrue:[
904274a738a8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5898
diff changeset
  2052
        (text2 := (item ? line) helpText) notEmptyOrNil ifTrue:[
904274a738a8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5898
diff changeset
  2053
            text2 := text2 withCRs.
904274a738a8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5898
diff changeset
  2054
            text isEmptyOrNil ifTrue:[
904274a738a8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5898
diff changeset
  2055
                text := text2
904274a738a8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5898
diff changeset
  2056
            ] ifFalse:[
904274a738a8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5898
diff changeset
  2057
                text := text , Character cr , text2.
904274a738a8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5898
diff changeset
  2058
            ].    
904274a738a8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5898
diff changeset
  2059
        ]
5069
fac483ef2664 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5065
diff changeset
  2060
    ].
5381
cb54dd13c7c3 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5316
diff changeset
  2061
    
cb54dd13c7c3 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5316
diff changeset
  2062
    ^ text
5496
0a189e9110c4 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5426
diff changeset
  2063
0a189e9110c4 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5426
diff changeset
  2064
    "Modified: / 20-02-2017 / 10:11:58 / cg"
6046
076bfb11d13d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6039
diff changeset
  2065
    "Modified: / 02-05-2019 / 16:36:58 / Claus Gittinger"
5069
fac483ef2664 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5065
diff changeset
  2066
! !
fac483ef2664 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5065
diff changeset
  2067
2501
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2493
diff changeset
  2068
!SelectionInListModelView methodsFor:'initialization & release'!
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2069
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2070
fetchResources
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2071
    "fetch device colors and ..., to avoid reallocation at redraw time;
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2072
     *** called after a create or snapin to fetch all device resources
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2073
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2074
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2075
    super fetchResources.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2076
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2077
    hilightFgColor    := self colorOnDevice:hilightFgColor.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2078
    hilightBgColor    := self colorOnDevice:hilightBgColor.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2079
    hilightFrameColor := self colorOnDevice:hilightFrameColor.
5002
ab6066bcf4d7 device access
Claus Gittinger <cg@exept.de>
parents: 4948
diff changeset
  2080
    lineMask          := lineMask  onDevice:device.
3137
7e8fae56b94c highlight selection dependent on has focus
ca
parents: 3081
diff changeset
  2081
7e8fae56b94c highlight selection dependent on has focus
ca
parents: 3081
diff changeset
  2082
    hilightFgColorNoFocus := self colorOnDevice:hilightFgColorNoFocus.
7e8fae56b94c highlight selection dependent on has focus
ca
parents: 3081
diff changeset
  2083
    hilightBgColorNoFocus := self colorOnDevice:hilightBgColorNoFocus.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2084
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2085
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2086
initStyle
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2087
    "setup viewStyle specifics
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2088
    "
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2089
    <resource: #style (#'selection.selectOnMenuButton'
3851
03296acbf762 changed: #initStyle
Stefan Vogel <sv@exept.de>
parents: 3778
diff changeset
  2090
                       #'selection.font')>
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2091
    super initStyle.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2092
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  2093
    lineMask isNil ifTrue:[
3851
03296acbf762 changed: #initStyle
Stefan Vogel <sv@exept.de>
parents: 3778
diff changeset
  2094
        lineMask := Form width:2 height:2 fromArray:#[16rAA 16r55].
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  2095
    ].
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  2096
2228
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
  2097
    hilightFrameColor   := nil.
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
  2098
    hilightStyle        := DefaultHilightStyle.
6201
f62406ae4f1e #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6167
diff changeset
  2099
    highlightMode       := DefaultHilightMode ? #label.
2228
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
  2100
    textStartLeft       := 4.
3461
eb3980ed82ad bugfix: selectTreeElementOnRightClick behaviour
ca
parents: 3455
diff changeset
  2101
    selectOnMenuButton  := styleSheet at:#'selection.selectOnMenuButton' default:nil.
eb3980ed82ad bugfix: selectTreeElementOnRightClick behaviour
ca
parents: 3455
diff changeset
  2102
    selectOnMenuButton isNil ifTrue:[
3851
03296acbf762 changed: #initStyle
Stefan Vogel <sv@exept.de>
parents: 3778
diff changeset
  2103
        selectOnMenuButton := UserPreferences current selectOnRightClick
3461
eb3980ed82ad bugfix: selectTreeElementOnRightClick behaviour
ca
parents: 3455
diff changeset
  2104
    ].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2105
3927
Claus Gittinger <cg@exept.de>
parents: 3918
diff changeset
  2106
    self font:(SelectionInListView defaultFont).
1741
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
  2107
5002
ab6066bcf4d7 device access
Claus Gittinger <cg@exept.de>
parents: 4948
diff changeset
  2108
    device hasGrayscales ifTrue:[
3851
03296acbf762 changed: #initStyle
Stefan Vogel <sv@exept.de>
parents: 3778
diff changeset
  2109
        "
03296acbf762 changed: #initStyle
Stefan Vogel <sv@exept.de>
parents: 3778
diff changeset
  2110
         must get rid of these hard codings
03296acbf762 changed: #initStyle
Stefan Vogel <sv@exept.de>
parents: 3778
diff changeset
  2111
        "
03296acbf762 changed: #initStyle
Stefan Vogel <sv@exept.de>
parents: 3778
diff changeset
  2112
        (hilightStyle == #next) ifTrue:[
03296acbf762 changed: #initStyle
Stefan Vogel <sv@exept.de>
parents: 3778
diff changeset
  2113
            hilightFgColor := fgColor.
4512
0b737fe17eea class: SelectionInListModelView
Stefan Vogel <sv@exept.de>
parents: 4483
diff changeset
  2114
            hilightBgColor := self whiteColor.
3851
03296acbf762 changed: #initStyle
Stefan Vogel <sv@exept.de>
parents: 3778
diff changeset
  2115
            hilightFrameColor := fgColor
03296acbf762 changed: #initStyle
Stefan Vogel <sv@exept.de>
parents: 3778
diff changeset
  2116
        ] ifFalse:[
03296acbf762 changed: #initStyle
Stefan Vogel <sv@exept.de>
parents: 3778
diff changeset
  2117
            (hilightStyle == #motif) ifTrue:[
4512
0b737fe17eea class: SelectionInListModelView
Stefan Vogel <sv@exept.de>
parents: 4483
diff changeset
  2118
                fgColor := self whiteColor.
3851
03296acbf762 changed: #initStyle
Stefan Vogel <sv@exept.de>
parents: 3778
diff changeset
  2119
                bgColor := Grey.
03296acbf762 changed: #initStyle
Stefan Vogel <sv@exept.de>
parents: 3778
diff changeset
  2120
                viewBackground := bgColor.
03296acbf762 changed: #initStyle
Stefan Vogel <sv@exept.de>
parents: 3778
diff changeset
  2121
                hilightFgColor := bgColor.
03296acbf762 changed: #initStyle
Stefan Vogel <sv@exept.de>
parents: 3778
diff changeset
  2122
                hilightBgColor := fgColor.
03296acbf762 changed: #initStyle
Stefan Vogel <sv@exept.de>
parents: 3778
diff changeset
  2123
            ] ifFalse:[
03296acbf762 changed: #initStyle
Stefan Vogel <sv@exept.de>
parents: 3778
diff changeset
  2124
                (hilightStyle == #openwin) ifTrue:[
03296acbf762 changed: #initStyle
Stefan Vogel <sv@exept.de>
parents: 3778
diff changeset
  2125
                    hilightFgColor := fgColor.
4647
caf78f4a0548 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4638
diff changeset
  2126
                    hilightBgColor := Color gray.
3851
03296acbf762 changed: #initStyle
Stefan Vogel <sv@exept.de>
parents: 3778
diff changeset
  2127
                ]
03296acbf762 changed: #initStyle
Stefan Vogel <sv@exept.de>
parents: 3778
diff changeset
  2128
            ]
03296acbf762 changed: #initStyle
Stefan Vogel <sv@exept.de>
parents: 3778
diff changeset
  2129
        ]
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2130
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2131
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2132
    hilightFgColor isNil ifTrue:[
3851
03296acbf762 changed: #initStyle
Stefan Vogel <sv@exept.de>
parents: 3778
diff changeset
  2133
        hilightFgColor := bgColor.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2134
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2135
    hilightBgColor isNil ifTrue:[
3851
03296acbf762 changed: #initStyle
Stefan Vogel <sv@exept.de>
parents: 3778
diff changeset
  2136
        hilightBgColor := fgColor.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2137
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2138
    DefaultForegroundColor notNil ifTrue:[
3851
03296acbf762 changed: #initStyle
Stefan Vogel <sv@exept.de>
parents: 3778
diff changeset
  2139
        fgColor := DefaultForegroundColor
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2140
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2141
    DefaultBackgroundColor notNil ifTrue:[
3851
03296acbf762 changed: #initStyle
Stefan Vogel <sv@exept.de>
parents: 3778
diff changeset
  2142
        bgColor := viewBackground := DefaultBackgroundColor
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2143
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2144
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2145
    DefaultHilightForegroundColor notNil ifTrue:[
3851
03296acbf762 changed: #initStyle
Stefan Vogel <sv@exept.de>
parents: 3778
diff changeset
  2146
        hilightFgColor := DefaultHilightForegroundColor
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2147
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2148
    DefaultHilightBackgroundColor notNil ifTrue:[
3851
03296acbf762 changed: #initStyle
Stefan Vogel <sv@exept.de>
parents: 3778
diff changeset
  2149
        hilightBgColor := DefaultHilightBackgroundColor
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2150
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2151
    DefaultHilightFrameColor notNil ifTrue:[
3851
03296acbf762 changed: #initStyle
Stefan Vogel <sv@exept.de>
parents: 3778
diff changeset
  2152
        hilightFrameColor := DefaultHilightFrameColor
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2153
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2154
1741
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
  2155
    hilightLevel := DefaultHilightLevel ? 0.
4570
4da74a5c2f14 class: SelectionInListModelView
Stefan Vogel <sv@exept.de>
parents: 4568
diff changeset
  2156
    lineSpacing := gc font descent.
4568
664bbb1743ff class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4515
diff changeset
  2157
    lineSpacing := lineSpacing + ((hilightLevel abs > 0) ifTrue:[1] ifFalse:[0]).
1741
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
  2158
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2159
    hilightFgColor isNil ifTrue:[
3851
03296acbf762 changed: #initStyle
Stefan Vogel <sv@exept.de>
parents: 3778
diff changeset
  2160
        hilightFgColor := bgColor.
03296acbf762 changed: #initStyle
Stefan Vogel <sv@exept.de>
parents: 3778
diff changeset
  2161
        hilightBgColor := fgColor.
3137
7e8fae56b94c highlight selection dependent on has focus
ca
parents: 3081
diff changeset
  2162
    ].
7e8fae56b94c highlight selection dependent on has focus
ca
parents: 3081
diff changeset
  2163
7e8fae56b94c highlight selection dependent on has focus
ca
parents: 3081
diff changeset
  2164
    hilightFgColorNoFocus isNil ifTrue:[
4652
1a4f9ee861c1 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4648
diff changeset
  2165
        hilightFgColorNoFocus := DefaultHilightForegroundColorNoFocus.
1a4f9ee861c1 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4648
diff changeset
  2166
        hilightFgColorNoFocus isNil ifTrue:[
1a4f9ee861c1 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4648
diff changeset
  2167
            hilightFgColorNoFocus := hilightFgColor slightlyLightened.
1a4f9ee861c1 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4648
diff changeset
  2168
        ]
3137
7e8fae56b94c highlight selection dependent on has focus
ca
parents: 3081
diff changeset
  2169
    ].
7e8fae56b94c highlight selection dependent on has focus
ca
parents: 3081
diff changeset
  2170
    hilightBgColorNoFocus isNil ifTrue:[
4648
5c5c17b052fb class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4647
diff changeset
  2171
        hilightBgColorNoFocus := DefaultHilightBackgroundColorNoFocus.
5c5c17b052fb class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4647
diff changeset
  2172
        hilightBgColorNoFocus isNil ifTrue:[ 
4652
1a4f9ee861c1 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4648
diff changeset
  2173
            hilightBgColorNoFocus := hilightBgColor slightlyLightened.
4648
5c5c17b052fb class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4647
diff changeset
  2174
        ].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2175
    ].
3927
Claus Gittinger <cg@exept.de>
parents: 3918
diff changeset
  2176
Claus Gittinger <cg@exept.de>
parents: 3918
diff changeset
  2177
    "Modified: / 14-08-2010 / 12:23:09 / cg"
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2178
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2179
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2180
initialize
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2181
    "setup default attributes/behavior
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2182
    "
2418
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  2183
    multipleSelectOk     := false.
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  2184
    useIndex             := true.
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  2185
    ignoreReselect       := true.
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  2186
    toggleSelect         := false.
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  2187
    highlightEnterItem   := false.
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  2188
    strikeOut            := false.
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  2189
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  2190
    keyActionStyle       := #select.
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  2191
    returnKeyActionStyle := #doubleClick.
2324
ada66df6ac14 support of highlighting items under mouse
ca
parents: 2323
diff changeset
  2192
3963
9fd5330c7e40 fix to allow dropping at the bottom
Claus Gittinger <cg@exept.de>
parents: 3927
diff changeset
  2193
    extraSpaceAtBottomForDrop := 20.
9fd5330c7e40 fix to allow dropping at the bottom
Claus Gittinger <cg@exept.de>
parents: 3927
diff changeset
  2194
2324
ada66df6ac14 support of highlighting items under mouse
ca
parents: 2323
diff changeset
  2195
    super initialize.
3963
9fd5330c7e40 fix to allow dropping at the bottom
Claus Gittinger <cg@exept.de>
parents: 3927
diff changeset
  2196
9fd5330c7e40 fix to allow dropping at the bottom
Claus Gittinger <cg@exept.de>
parents: 3927
diff changeset
  2197
    "Modified: / 03-11-2010 / 01:34:54 / cg"
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2198
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2199
1745
4eb3b6b12c99 make selection visible after mapped
ca
parents: 1741
diff changeset
  2200
mapped
4eb3b6b12c99 make selection visible after mapped
ca
parents: 1741
diff changeset
  2201
    "get selection from model; scroll to selection
4eb3b6b12c99 make selection visible after mapped
ca
parents: 1741
diff changeset
  2202
    "
4eb3b6b12c99 make selection visible after mapped
ca
parents: 1741
diff changeset
  2203
    super mapped.
4eb3b6b12c99 make selection visible after mapped
ca
parents: 1741
diff changeset
  2204
    self makeSelectionVisible.
4eb3b6b12c99 make selection visible after mapped
ca
parents: 1741
diff changeset
  2205
!
4eb3b6b12c99 make selection visible after mapped
ca
parents: 1741
diff changeset
  2206
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2207
realize
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2208
    "get selection from model; scroll to selection
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2209
    "
2302
5a2a1d5d09f8 remove asynchronous handling of changes; always disabled because doesn't work
ca
parents: 2275
diff changeset
  2210
    self updateFromModel.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2211
    super realize.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2212
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2213
2493
8b70a26f1694 method category rename
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  2214
!SelectionInListModelView methodsFor:'private-editor'!
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2215
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2216
computeEditorLayout
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2217
    "update the layout of the editor
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2218
    "
3526
826547ea5ecc *** empty log message ***
ca
parents: 3525
diff changeset
  2219
    |lnNr item y0 x0 y1|
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2220
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2221
    editorView isNil ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2222
	^ self
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2223
    ].
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2224
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2225
    (    (lnNr := self selectedIndex) == 0
2408
8b0d11537dc0 accessing list indirect
ca
parents: 2404
diff changeset
  2226
     or:[(item := self at:lnNr ifAbsent:nil) isNil]
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2227
    ) ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2228
	"/ there is no more single selection; thus close the editor
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2229
	^ self closeEditor
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2230
    ].
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2231
3526
826547ea5ecc *** empty log message ***
ca
parents: 3525
diff changeset
  2232
    x0 := (self xVisibleOfItem:item) - (textStartLeft // 2).
826547ea5ecc *** empty log message ***
ca
parents: 3525
diff changeset
  2233
    y0 := self yVisibleOfLine:lnNr.
826547ea5ecc *** empty log message ***
ca
parents: 3525
diff changeset
  2234
    y1 := self yVisibleOfLine:(lnNr + 1).
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2235
3524
854b6484c001 minimumEditorHeight
ca
parents: 3482
diff changeset
  2236
    minimumEditorHeight notNil ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2237
	y1 := y0 + ((y1 - y0) max:minimumEditorHeight).
3524
854b6484c001 minimumEditorHeight
ca
parents: 3482
diff changeset
  2238
    ].
2632
48a2b5f7d091 *** empty log message ***
martin
parents: 2613
diff changeset
  2239
    "/ Changed by cg:
48a2b5f7d091 *** empty log message ***
martin
parents: 2613
diff changeset
  2240
    "/ editorView layout:( Rectangle left:x top:y right:(width - 1 - margin) bottom:(h + 2 "- 1") ).
3526
826547ea5ecc *** empty log message ***
ca
parents: 3525
diff changeset
  2241
    editorView layout:( Rectangle left:x0 top:y0-2 right:(width - 1 - margin) bottom:y1 ).
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2242
!
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2243
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2244
openEditorAtX:x y:y
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2245
    "opens an editor on the current single selection
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2246
    "
2225
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
  2247
    |item lnNr x0 y0 editor|
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2248
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2249
    self closeEditor.
2308
c012b16422f0 replace ifNotNil: by notNil ifTrue:
ca
parents: 2302
diff changeset
  2250
    shown ifFalse:[^ self ].
2596
771e23c6d9cf access actions by call and not by reference
ca
parents: 2572
diff changeset
  2251
    self openEditorAction isNil ifTrue:[^ self].
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2252
2225
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
  2253
    lnNr := self selectedIndex.
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
  2254
    lnNr == 0 ifTrue:[^ self].
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
  2255
2408
8b0d11537dc0 accessing list indirect
ca
parents: 2404
diff changeset
  2256
    item := self at:lnNr ifAbsent:nil.
2308
c012b16422f0 replace ifNotNil: by notNil ifTrue:
ca
parents: 2302
diff changeset
  2257
    item isNil ifTrue:[^ self].
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2258
1915
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
  2259
    x < (self xVisibleOfItem:item) ifTrue:[
3778
ccbe7479c97b changed: #openEditorAtX:y:
Claus Gittinger <cg@exept.de>
parents: 3750
diff changeset
  2260
        "/ not part of the selection frame; ignorre
ccbe7479c97b changed: #openEditorAtX:y:
Claus Gittinger <cg@exept.de>
parents: 3750
diff changeset
  2261
        ^ self
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2262
    ].
2225
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
  2263
    editor := self openEditor.
2308
c012b16422f0 replace ifNotNil: by notNil ifTrue:
ca
parents: 2302
diff changeset
  2264
    editor isNil ifTrue:[^ self].
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2265
2225
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
  2266
    y0 := (y - editor origin y) max:0.
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
  2267
    x0 := (x - editor origin x) max:0.
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2268
2125
67e0f2c9ad4d event types are private to WindowEvent;
ca
parents: 2070
diff changeset
  2269
    "/ simulate clicking into the editor
2632
48a2b5f7d091 *** empty log message ***
martin
parents: 2613
diff changeset
  2270
48a2b5f7d091 *** empty log message ***
martin
parents: 2613
diff changeset
  2271
    "/ Changed by cg:
48a2b5f7d091 *** empty log message ***
martin
parents: 2613
diff changeset
  2272
    "/ but only if there was no initial selection
48a2b5f7d091 *** empty log message ***
martin
parents: 2613
diff changeset
  2273
    editor isInputField ifTrue:[
3778
ccbe7479c97b changed: #openEditorAtX:y:
Claus Gittinger <cg@exept.de>
parents: 3750
diff changeset
  2274
        editor hasSelection ifFalse:[
ccbe7479c97b changed: #openEditorAtX:y:
Claus Gittinger <cg@exept.de>
parents: 3750
diff changeset
  2275
            self sensor
ccbe7479c97b changed: #openEditorAtX:y:
Claus Gittinger <cg@exept.de>
parents: 3750
diff changeset
  2276
                pushEvent:(WindowEvent buttonPress:1 x:x0 y:y0 view:editor);
ccbe7479c97b changed: #openEditorAtX:y:
Claus Gittinger <cg@exept.de>
parents: 3750
diff changeset
  2277
                pushEvent:(WindowEvent buttonRelease:1 x:x0 y:y0 view:editor).
ccbe7479c97b changed: #openEditorAtX:y:
Claus Gittinger <cg@exept.de>
parents: 3750
diff changeset
  2278
        ]
2632
48a2b5f7d091 *** empty log message ***
martin
parents: 2613
diff changeset
  2279
    ].
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2280
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2281
    "/ to clear the selection
2245
546c6e5d0951 change #redrawSelectionAt: to #invalidateSelectionAt: (because is a invalidate)
ca
parents: 2228
diff changeset
  2282
    self invalidateLineAt:lnNr.
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2283
! !
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2284
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2285
!SelectionInListModelView methodsFor:'protocol'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2286
1458
02d7889dfb9a lostSynchronisation
Claus Gittinger <cg@exept.de>
parents: 1431
diff changeset
  2287
lostSynchronisation
02d7889dfb9a lostSynchronisation
Claus Gittinger <cg@exept.de>
parents: 1431
diff changeset
  2288
    "called when the changes derived from the model are faster than the handling
02d7889dfb9a lostSynchronisation
Claus Gittinger <cg@exept.de>
parents: 1431
diff changeset
  2289
    "
1547
f72d75aaec14 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
  2290
    self deselectWithoutRedraw.
1458
02d7889dfb9a lostSynchronisation
Claus Gittinger <cg@exept.de>
parents: 1431
diff changeset
  2291
    super lostSynchronisation.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2292
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2293
2330
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2294
!SelectionInListModelView methodsFor:'queries'!
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2295
4638
21fee5ee9af2 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4574
diff changeset
  2296
elementsForWhich:aBlock
21fee5ee9af2 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4574
diff changeset
  2297
    |result|
21fee5ee9af2 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4574
diff changeset
  2298
21fee5ee9af2 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4574
diff changeset
  2299
    result := OrderedCollection new.
21fee5ee9af2 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4574
diff changeset
  2300
    1 to:self size do:[:idx |
21fee5ee9af2 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4574
diff changeset
  2301
        |el|
21fee5ee9af2 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4574
diff changeset
  2302
21fee5ee9af2 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4574
diff changeset
  2303
        el := self at:idx.
21fee5ee9af2 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4574
diff changeset
  2304
        (aBlock value:el) ifTrue:[ result add:el].
21fee5ee9af2 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4574
diff changeset
  2305
    ].
21fee5ee9af2 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4574
diff changeset
  2306
    ^ result
21fee5ee9af2 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4574
diff changeset
  2307
!
21fee5ee9af2 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4574
diff changeset
  2308
5817
7779078ac861 #BUGFIX by sr
sr
parents: 5812
diff changeset
  2309
hasToSkipButtonMultiPress:button x:x y:y
7779078ac861 #BUGFIX by sr
sr
parents: 5812
diff changeset
  2310
    "return true if a button multi press at x@y should be skipped"
7779078ac861 #BUGFIX by sr
sr
parents: 5812
diff changeset
  2311
    ^ false
7779078ac861 #BUGFIX by sr
sr
parents: 5812
diff changeset
  2312
7779078ac861 #BUGFIX by sr
sr
parents: 5812
diff changeset
  2313
    "Created: / 22-06-2018 / 14:32:38 / sr"
7779078ac861 #BUGFIX by sr
sr
parents: 5812
diff changeset
  2314
!
7779078ac861 #BUGFIX by sr
sr
parents: 5812
diff changeset
  2315
2330
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2316
isCursorKeyConsumer
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2317
    "return true, if the receiver can be controlled by cursor keys;
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2318
     i.e. it can handle some keyboard input,
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2319
     isCursorKeyConsumer are potential candidates for getting the keyboard
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2320
     focus initially within dialogBoxes, or when the focus-follows-pointer
4692
433047d28c93 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4667
diff changeset
  2321
     mode is off."
2330
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2322
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2323
    ^ true
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2324
! !
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2325
3526
826547ea5ecc *** empty log message ***
ca
parents: 3525
diff changeset
  2326
!SelectionInListModelView methodsFor:'scroller interface'!
826547ea5ecc *** empty log message ***
ca
parents: 3525
diff changeset
  2327
826547ea5ecc *** empty log message ***
ca
parents: 3525
diff changeset
  2328
heightOfContents
826547ea5ecc *** empty log message ***
ca
parents: 3525
diff changeset
  2329
    "answer the height of the contents in pixels.
826547ea5ecc *** empty log message ***
ca
parents: 3525
diff changeset
  2330
     If the minimumEditorHeight and the openEditorAction is defined,
826547ea5ecc *** empty log message ***
ca
parents: 3525
diff changeset
  2331
     we have to involve the minimumEditorHeight in the computation,
826547ea5ecc *** empty log message ***
ca
parents: 3525
diff changeset
  2332
     to allow opening the editor fullyvisible at the last line."
826547ea5ecc *** empty log message ***
ca
parents: 3525
diff changeset
  2333
826547ea5ecc *** empty log message ***
ca
parents: 3525
diff changeset
  2334
    |cachedLinesY cachedMaxIdx y0 y1|
826547ea5ecc *** empty log message ***
ca
parents: 3525
diff changeset
  2335
5898
a0cae09e9108 #BUGFIX by ab
ab
parents: 5817
diff changeset
  2336
    cachedLinesY := startOfLinesY.
3526
826547ea5ecc *** empty log message ***
ca
parents: 3525
diff changeset
  2337
    cachedMaxIdx := cachedLinesY size.
826547ea5ecc *** empty log message ***
ca
parents: 3525
diff changeset
  2338
    cachedMaxIdx == 0 ifTrue:[ ^ 0 ].
826547ea5ecc *** empty log message ***
ca
parents: 3525
diff changeset
  2339
4796
6c35c2439ca3 class: SelectionInListModelView
ca
parents: 4702
diff changeset
  2340
    "/ !!!! cachedLinesY at:cachedMaxIdx might return nil (async reorg)
6c35c2439ca3 class: SelectionInListModelView
ca
parents: 4702
diff changeset
  2341
    y1 := cachedLinesY at:cachedMaxIdx ifAbsent:nil.
6c35c2439ca3 class: SelectionInListModelView
ca
parents: 4702
diff changeset
  2342
    y1 isNil ifTrue:[^ 0 ]. "/ is under construction due ro async. events
3526
826547ea5ecc *** empty log message ***
ca
parents: 3525
diff changeset
  2343
826547ea5ecc *** empty log message ***
ca
parents: 3525
diff changeset
  2344
    (minimumEditorHeight notNil and:[openEditorAction notNil]) ifTrue:[
3963
9fd5330c7e40 fix to allow dropping at the bottom
Claus Gittinger <cg@exept.de>
parents: 3927
diff changeset
  2345
        y0 := cachedLinesY at:(cachedMaxIdx - 1) ifAbsent:0.
9fd5330c7e40 fix to allow dropping at the bottom
Claus Gittinger <cg@exept.de>
parents: 3927
diff changeset
  2346
        y1 := y0 + ((y1 - y0) max:minimumEditorHeight).
3526
826547ea5ecc *** empty log message ***
ca
parents: 3525
diff changeset
  2347
    ].
3963
9fd5330c7e40 fix to allow dropping at the bottom
Claus Gittinger <cg@exept.de>
parents: 3927
diff changeset
  2348
    ^ y1 + extraSpaceAtBottomForDrop.
9fd5330c7e40 fix to allow dropping at the bottom
Claus Gittinger <cg@exept.de>
parents: 3927
diff changeset
  2349
9fd5330c7e40 fix to allow dropping at the bottom
Claus Gittinger <cg@exept.de>
parents: 3927
diff changeset
  2350
    "Modified: / 03-11-2010 / 01:35:05 / cg"
3526
826547ea5ecc *** empty log message ***
ca
parents: 3525
diff changeset
  2351
! !
826547ea5ecc *** empty log message ***
ca
parents: 3525
diff changeset
  2352
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2353
!SelectionInListModelView methodsFor:'selection'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2354
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  2355
addToSelection:lineNr
2410
39ec0844e7d6 discard #toggleSelection:
ca
parents: 2409
diff changeset
  2356
    "add line to selection without scrolling but raise a change notification
39ec0844e7d6 discard #toggleSelection:
ca
parents: 2409
diff changeset
  2357
    "
39ec0844e7d6 discard #toggleSelection:
ca
parents: 2409
diff changeset
  2358
    |oldSelect forAdd|
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  2359
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  2360
    (self isInSelection:lineNr) ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2361
	^ self
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  2362
    ].
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  2363
2410
39ec0844e7d6 discard #toggleSelection:
ca
parents: 2409
diff changeset
  2364
    multipleSelectOk ifTrue:[ forAdd := selection notNil ]
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2365
		    ifFalse:[ forAdd := false ].
2410
39ec0844e7d6 discard #toggleSelection:
ca
parents: 2409
diff changeset
  2366
39ec0844e7d6 discard #toggleSelection:
ca
parents: 2409
diff changeset
  2367
    (self canSelectIndex:lineNr forAdd:forAdd) ifFalse:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2368
	^ self
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  2369
    ].
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  2370
2410
39ec0844e7d6 discard #toggleSelection:
ca
parents: 2409
diff changeset
  2371
    self closeEditor.
39ec0844e7d6 discard #toggleSelection:
ca
parents: 2409
diff changeset
  2372
    self cursorEntersItem:nil.
39ec0844e7d6 discard #toggleSelection:
ca
parents: 2409
diff changeset
  2373
39ec0844e7d6 discard #toggleSelection:
ca
parents: 2409
diff changeset
  2374
    multipleSelectOk ifFalse:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2375
	oldSelect := selection.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2376
	selection := lineNr.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2377
	oldSelect notNil ifTrue:[ self invalidateSelectionAt:oldSelect ].
2410
39ec0844e7d6 discard #toggleSelection:
ca
parents: 2409
diff changeset
  2378
    ] ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2379
	selection notNil ifTrue:[ selection := selection copyWith:lineNr ]
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2380
			ifFalse:[ selection := OrderedCollection with:lineNr ].
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  2381
    ].
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  2382
    self invalidateSelectionAt:lineNr.
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  2383
    self selectionChanged.
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  2384
!
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  2385
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2386
deselect
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2387
    "clear selection
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2388
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2389
    self selection:nil
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2391
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2392
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2393
firstInSelection
2399
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2394
    "returns the minimum index of selected indices or nil if nothing is selected
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2395
    "
2409
68095c891ceb reuse selection methods (prepared for common controller)
ca
parents: 2408
diff changeset
  2396
    |min|
2365
bdf6954a0358 key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents: 2361
diff changeset
  2397
2409
68095c891ceb reuse selection methods (prepared for common controller)
ca
parents: 2408
diff changeset
  2398
    multipleSelectOk   ifFalse:[ ^ selection ].
68095c891ceb reuse selection methods (prepared for common controller)
ca
parents: 2408
diff changeset
  2399
    selection size == 0 ifTrue:[ ^ nil ].
2365
bdf6954a0358 key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents: 2361
diff changeset
  2400
bdf6954a0358 key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents: 2361
diff changeset
  2401
    min := selection at:1.
2409
68095c891ceb reuse selection methods (prepared for common controller)
ca
parents: 2408
diff changeset
  2402
    selection do:[:aNumber| min := min min:aNumber ].
2365
bdf6954a0358 key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents: 2361
diff changeset
  2403
    ^ min
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2404
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2405
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2406
hasSelection
5684
bba053081b4e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5677
diff changeset
  2407
    "true if an item is selected"
bba053081b4e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5677
diff changeset
  2408
    
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2409
    ^ selection notNil
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2410
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2411
6167
8106bb36e30e #REFACTORING by exept
Claus Gittinger <cg@exept.de>
parents: 6165
diff changeset
  2412
indexOfElementForWhich:aBlock
8106bb36e30e #REFACTORING by exept
Claus Gittinger <cg@exept.de>
parents: 6165
diff changeset
  2413
    1 to:self size do:[:idx |
8106bb36e30e #REFACTORING by exept
Claus Gittinger <cg@exept.de>
parents: 6165
diff changeset
  2414
        (aBlock value:(self at:idx)) ifTrue:[^idx].
8106bb36e30e #REFACTORING by exept
Claus Gittinger <cg@exept.de>
parents: 6165
diff changeset
  2415
    ].
8106bb36e30e #REFACTORING by exept
Claus Gittinger <cg@exept.de>
parents: 6165
diff changeset
  2416
    ^ 0
8106bb36e30e #REFACTORING by exept
Claus Gittinger <cg@exept.de>
parents: 6165
diff changeset
  2417
8106bb36e30e #REFACTORING by exept
Claus Gittinger <cg@exept.de>
parents: 6165
diff changeset
  2418
    "Created: / 06-10-2011 / 13:32:28 / cg"
8106bb36e30e #REFACTORING by exept
Claus Gittinger <cg@exept.de>
parents: 6165
diff changeset
  2419
!
8106bb36e30e #REFACTORING by exept
Claus Gittinger <cg@exept.de>
parents: 6165
diff changeset
  2420
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2421
isInSelection:aNumber
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2422
    "return true, if line, aNumber is in the selection
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2423
    "
1545
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  2424
    multipleSelectOk ifFalse:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2425
	^ (aNumber == selection)
1545
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  2426
    ].
2409
68095c891ceb reuse selection methods (prepared for common controller)
ca
parents: 2408
diff changeset
  2427
    selection notNil ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2428
	^ selection includesIdentical:aNumber
2409
68095c891ceb reuse selection methods (prepared for common controller)
ca
parents: 2408
diff changeset
  2429
    ].
68095c891ceb reuse selection methods (prepared for common controller)
ca
parents: 2408
diff changeset
  2430
    ^ false
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2431
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2432
2274
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  2433
isSelectionVisible
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  2434
    "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
  2435
2409
68095c891ceb reuse selection methods (prepared for common controller)
ca
parents: 2408
diff changeset
  2436
    ^ self isSelectionVisibleIn:(self extent)
2274
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  2437
!
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  2438
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  2439
isSelectionVisibleIn:anExtentPoint
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  2440
    "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
  2441
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  2442
    self selectionDo:[:aLineNr|
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2443
	(self isLineVisible:aLineNr in:anExtentPoint) ifTrue:[^ true].
2274
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  2444
    ].
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  2445
    ^ false
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  2446
!
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  2447
2330
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2448
lastInSelection
2399
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2449
    "returns the maximum index of selected indices or nil if nothing is selected
2330
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2450
    "
2409
68095c891ceb reuse selection methods (prepared for common controller)
ca
parents: 2408
diff changeset
  2451
    |max|
2330
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2452
2409
68095c891ceb reuse selection methods (prepared for common controller)
ca
parents: 2408
diff changeset
  2453
    multipleSelectOk   ifFalse:[ ^ selection ].
68095c891ceb reuse selection methods (prepared for common controller)
ca
parents: 2408
diff changeset
  2454
    selection size == 0 ifTrue:[ ^ nil ].
2330
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2455
2365
bdf6954a0358 key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents: 2361
diff changeset
  2456
    max := 1.
bdf6954a0358 key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents: 2361
diff changeset
  2457
    selection do:[:aNumber| max := max max:aNumber ].
bdf6954a0358 key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents: 2361
diff changeset
  2458
    ^ max
2330
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2459
!
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2460
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2461
makeSelectionVisible
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2462
    "scroll to make the selection line visible
5316
14cfa2ba3604 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5215
diff changeset
  2463
     don't scroll, if any in the selection isVisible
2330
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2464
    "
3202
11de451bc538 *** empty log message ***
ca
parents: 3146
diff changeset
  2465
    |firstLine|
11de451bc538 *** empty log message ***
ca
parents: 3146
diff changeset
  2466
6049
d064dc363de8 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6046
diff changeset
  2467
    "/ modelChangedDuringButtonPress notNil ifTrue:[^ self].
3205
7ff2e20b37d4 *** empty log message ***
ca
parents: 3202
diff changeset
  2468
3202
11de451bc538 *** empty log message ***
ca
parents: 3146
diff changeset
  2469
    firstLine := self firstInSelection.
11de451bc538 *** empty log message ***
ca
parents: 3146
diff changeset
  2470
    (firstLine isNil or:[firstLine == 0]) ifTrue:[^ self].
11de451bc538 *** empty log message ***
ca
parents: 3146
diff changeset
  2471
11de451bc538 *** empty log message ***
ca
parents: 3146
diff changeset
  2472
    self selectionDo:[:aLnNr|
6092
24193361cde8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6049
diff changeset
  2473
        (self isLineFullyVisible:aLnNr) ifTrue:[^ self].
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2474
    ].
2368
8101aa8d50d2 cursor select behaviour in: #keyPress:x:y:
ca
parents: 2365
diff changeset
  2475
    self makeLineVisible:(self firstInSelection).
6049
d064dc363de8 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6046
diff changeset
  2476
6092
24193361cde8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6049
diff changeset
  2477
    "Modified: / 20-07-2019 / 07:50:57 / Claus Gittinger"
2365
bdf6954a0358 key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents: 2361
diff changeset
  2478
!
bdf6954a0358 key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents: 2361
diff changeset
  2479
4574
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2480
nextAfterSelection
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2481
    "return the index of the next selectable entry after the selection.
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2482
     Wrap at end."
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2483
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2484
    ^ self nextSelectableAfter:selection
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2485
!
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2486
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2487
nextSelectableAfter:indexOrIndexCollection
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2488
    "return the index of the next selectable entry after the indexOrIndexCollection.
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2489
     Wrap at end."
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2490
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2491
    |next sz|
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2492
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2493
    indexOrIndexCollection isNil ifTrue:[
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2494
        next := 1
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2495
    ] ifFalse:[
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2496
        indexOrIndexCollection isCollection ifTrue:[
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2497
            indexOrIndexCollection size == 0 ifTrue:[
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2498
                next := 1
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2499
            ] ifFalse:[
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2500
                next := indexOrIndexCollection max + 1
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2501
            ]
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2502
        ] ifFalse:[
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2503
            next := indexOrIndexCollection + 1
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2504
        ].
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2505
    ].
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2506
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2507
    (self canSelectIndex:next) ifFalse:[
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2508
        sz := self size.
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2509
        next > sz ifTrue:[
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2510
            next := 1.
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2511
        ] ifFalse:[
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2512
            [next <= sz
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2513
             and:[(self canSelectIndex:next) not ]] whileTrue:[
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2514
                next := next + 1
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2515
            ].
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2516
        ].
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2517
    ].
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2518
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2519
    (self canSelectIndex:next) ifFalse:[
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2520
        next := nil
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2521
    ].
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2522
    ^ next
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2523
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2524
    "Modified: / 08-08-1998 / 03:36:55 / cg"
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2525
    "Modified: / 22-04-2014 / 12:15:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2526
!
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2527
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2528
numberOfSelections
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2529
    "return the number of selected items
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2530
    "
2330
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2531
    selection isNil   ifTrue:[ ^ 0 ].
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2532
    multipleSelectOk ifFalse:[ ^ 1 ].
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2533
  ^ selection size
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2534
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2535
4574
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2536
previousBeforeSelection
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2537
    "return the index of the previous selectable entry before the selection.
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2538
     Wrap at beginning."
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2539
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2540
    ^ self previousSelectableBefore:selection
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2541
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2542
!
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2543
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2544
previousSelectableBefore:indexOrIndexCollection
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2545
    "return the index of the previous selectable entry before the indexOrIndexCollection.
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2546
     Wrap at beginning."
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2547
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2548
    |prev|
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2549
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2550
    indexOrIndexCollection isNil ifTrue:[
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2551
        prev := list size 
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2552
    ] ifFalse:[
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2553
        indexOrIndexCollection isCollection ifTrue:[
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2554
            indexOrIndexCollection size == 0 ifTrue:[
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2555
                prev := list size
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2556
            ] ifFalse:[
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2557
                prev := indexOrIndexCollection min - 1
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2558
            ]
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2559
        ] ifFalse:[
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2560
            prev := indexOrIndexCollection - 1
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2561
        ].
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2562
    ].
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2563
    (self canSelectIndex:prev) ifFalse:[
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2564
        prev < 1 ifTrue:[
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2565
            prev := self size.
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2566
        ] ifFalse:[
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2567
            [prev >= 1
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2568
             and:[(self canSelectIndex:prev) not]] whileTrue:[
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2569
                prev := prev - 1
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2570
            ].
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2571
        ].
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2572
    ].
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2573
    (self canSelectIndex:prev) ifFalse:[
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2574
        prev := nil
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2575
    ].
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2576
    ^ prev
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2577
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2578
    "Modified: / 22-04-2014 / 12:16:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2579
!
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2580
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  2581
removeFromSelection:lineNr
2410
39ec0844e7d6 discard #toggleSelection:
ca
parents: 2409
diff changeset
  2582
    "remove line from selection without scrolling but raise a change notification
39ec0844e7d6 discard #toggleSelection:
ca
parents: 2409
diff changeset
  2583
    "
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  2584
    (self isInSelection:lineNr) ifFalse:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2585
	^ self
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  2586
    ].
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  2587
    self closeEditor.
2410
39ec0844e7d6 discard #toggleSelection:
ca
parents: 2409
diff changeset
  2588
    self cursorEntersItem:nil.
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  2589
2410
39ec0844e7d6 discard #toggleSelection:
ca
parents: 2409
diff changeset
  2590
    (multipleSelectOk and:[self numberOfSelections > 1]) ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2591
	selection := selection copyWithout:lineNr.
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  2592
    ] ifFalse:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2593
	selection := nil
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  2594
    ].
2410
39ec0844e7d6 discard #toggleSelection:
ca
parents: 2409
diff changeset
  2595
    self invalidateSelectionAt:lineNr.
39ec0844e7d6 discard #toggleSelection:
ca
parents: 2409
diff changeset
  2596
    self selectionChanged.
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  2597
!
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  2598
3607
bec9e4c71bf4 implemented #selectAll
Claus Gittinger <cg@exept.de>
parents: 3526
diff changeset
  2599
selectAll
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2600
    "select all entries.
3607
bec9e4c71bf4 implemented #selectAll
Claus Gittinger <cg@exept.de>
parents: 3526
diff changeset
  2601
     Model and/or actionBlock notification IS done."
bec9e4c71bf4 implemented #selectAll
Claus Gittinger <cg@exept.de>
parents: 3526
diff changeset
  2602
bec9e4c71bf4 implemented #selectAll
Claus Gittinger <cg@exept.de>
parents: 3526
diff changeset
  2603
    self selectFrom:1 to:self size.
bec9e4c71bf4 implemented #selectAll
Claus Gittinger <cg@exept.de>
parents: 3526
diff changeset
  2604
!
bec9e4c71bf4 implemented #selectAll
Claus Gittinger <cg@exept.de>
parents: 3526
diff changeset
  2605
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2606
selectElement:anElement
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2607
    "select the element. Scroll to make the new selection visible.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2608
     Model and/or actionBlock notification IS done.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2609
    "
2178
f02ca1516c04 selectElement changed
penk
parents: 2148
diff changeset
  2610
    self selectElement:anElement ifAbsent:[self deselect]
f02ca1516c04 selectElement changed
penk
parents: 2148
diff changeset
  2611
!
f02ca1516c04 selectElement changed
penk
parents: 2148
diff changeset
  2612
f02ca1516c04 selectElement changed
penk
parents: 2148
diff changeset
  2613
selectElement:anElement ifAbsent:exceptionalValue
f02ca1516c04 selectElement changed
penk
parents: 2148
diff changeset
  2614
    |idx|
f02ca1516c04 selectElement changed
penk
parents: 2148
diff changeset
  2615
2408
8b0d11537dc0 accessing list indirect
ca
parents: 2404
diff changeset
  2616
    idx := self identityIndexOf:anElement.
2178
f02ca1516c04 selectElement changed
penk
parents: 2148
diff changeset
  2617
    idx == 0 ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2618
	^ exceptionalValue value
2178
f02ca1516c04 selectElement changed
penk
parents: 2148
diff changeset
  2619
    ].
f02ca1516c04 selectElement changed
penk
parents: 2148
diff changeset
  2620
    self selection:idx
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2621
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2622
4085
532e33c6a5e6 added: #selectElementForWhich:ifAbsent:
Claus Gittinger <cg@exept.de>
parents: 4043
diff changeset
  2623
selectElementForWhich:aBlock ifAbsent:exceptionalValue
6167
8106bb36e30e #REFACTORING by exept
Claus Gittinger <cg@exept.de>
parents: 6165
diff changeset
  2624
    |idx|
8106bb36e30e #REFACTORING by exept
Claus Gittinger <cg@exept.de>
parents: 6165
diff changeset
  2625
8106bb36e30e #REFACTORING by exept
Claus Gittinger <cg@exept.de>
parents: 6165
diff changeset
  2626
    idx := self indexOfElementForWhich:aBlock.
8106bb36e30e #REFACTORING by exept
Claus Gittinger <cg@exept.de>
parents: 6165
diff changeset
  2627
    idx ~~ 0 ifTrue:[
8106bb36e30e #REFACTORING by exept
Claus Gittinger <cg@exept.de>
parents: 6165
diff changeset
  2628
        self selection:idx.
8106bb36e30e #REFACTORING by exept
Claus Gittinger <cg@exept.de>
parents: 6165
diff changeset
  2629
        ^ self
4085
532e33c6a5e6 added: #selectElementForWhich:ifAbsent:
Claus Gittinger <cg@exept.de>
parents: 4043
diff changeset
  2630
    ].
532e33c6a5e6 added: #selectElementForWhich:ifAbsent:
Claus Gittinger <cg@exept.de>
parents: 4043
diff changeset
  2631
    ^ exceptionalValue value
532e33c6a5e6 added: #selectElementForWhich:ifAbsent:
Claus Gittinger <cg@exept.de>
parents: 4043
diff changeset
  2632
532e33c6a5e6 added: #selectElementForWhich:ifAbsent:
Claus Gittinger <cg@exept.de>
parents: 4043
diff changeset
  2633
    "Created: / 06-10-2011 / 13:32:28 / cg"
532e33c6a5e6 added: #selectElementForWhich:ifAbsent:
Claus Gittinger <cg@exept.de>
parents: 4043
diff changeset
  2634
!
532e33c6a5e6 added: #selectElementForWhich:ifAbsent:
Claus Gittinger <cg@exept.de>
parents: 4043
diff changeset
  2635
5729
2bbfe888300a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5684
diff changeset
  2636
selectElements:aCollectionOfElement
2bbfe888300a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5684
diff changeset
  2637
    "select the elements. 
2bbfe888300a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5684
diff changeset
  2638
     Scroll to make the new selection visible.
2bbfe888300a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5684
diff changeset
  2639
     Model and/or actionBlock notification IS done.
2bbfe888300a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5684
diff changeset
  2640
    "
2bbfe888300a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5684
diff changeset
  2641
    self selectElements:aCollectionOfElement ifAnyAbsent:[]
2bbfe888300a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5684
diff changeset
  2642
!
2bbfe888300a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5684
diff changeset
  2643
2bbfe888300a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5684
diff changeset
  2644
selectElements:aCollectionOfElements ifAnyAbsent:exceptionalValue
6037
d446c3eccc41 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 6024
diff changeset
  2645
    |indices setOfElements searchStart|
d446c3eccc41 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 6024
diff changeset
  2646
6039
121d71b79bda #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 6038
diff changeset
  2647
"/ Transcript show:'view index search time:'; showCR:(Time millisecondsToRun:[
6038
a26af42fdc1f #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 6037
diff changeset
  2648
    aCollectionOfElements size > 10 ifTrue:[
6037
d446c3eccc41 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 6024
diff changeset
  2649
        setOfElements := aCollectionOfElements asIdentitySet.
d446c3eccc41 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 6024
diff changeset
  2650
        indices := (1 to:list size) select:[:idx |
d446c3eccc41 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 6024
diff changeset
  2651
                        setOfElements includes:(list at:idx).
d446c3eccc41 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 6024
diff changeset
  2652
                   ].
d446c3eccc41 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 6024
diff changeset
  2653
        (indices size < aCollectionOfElements size) ifTrue:[
d446c3eccc41 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 6024
diff changeset
  2654
            ^ exceptionalValue value
d446c3eccc41 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 6024
diff changeset
  2655
        ].
d446c3eccc41 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 6024
diff changeset
  2656
    ] ifFalse:[
d446c3eccc41 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 6024
diff changeset
  2657
        "/ another O(n^2) algorithm...
d446c3eccc41 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 6024
diff changeset
  2658
        "/ tuned to be O(n) IFF the elements come in sorted
d446c3eccc41 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 6024
diff changeset
  2659
        searchStart := 1.
d446c3eccc41 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 6024
diff changeset
  2660
        indices := aCollectionOfElements collect:[:each |
d446c3eccc41 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 6024
diff changeset
  2661
                        |idx|
d446c3eccc41 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 6024
diff changeset
  2662
d446c3eccc41 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 6024
diff changeset
  2663
                        idx := list identityIndexOf:each startingAt:searchStart.
d446c3eccc41 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 6024
diff changeset
  2664
                        idx == 0 ifTrue:[
d446c3eccc41 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 6024
diff changeset
  2665
                            searchStart ~~ 1 ifTrue:[
d446c3eccc41 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 6024
diff changeset
  2666
                                idx := list identityIndexOf:each startingAt:1.
d446c3eccc41 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 6024
diff changeset
  2667
                            ].
d446c3eccc41 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 6024
diff changeset
  2668
                            idx == 0 ifTrue:[
d446c3eccc41 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 6024
diff changeset
  2669
                                ^ exceptionalValue value
d446c3eccc41 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 6024
diff changeset
  2670
                            ].
d446c3eccc41 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 6024
diff changeset
  2671
                        ].
d446c3eccc41 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 6024
diff changeset
  2672
                        searchStart := idx+1.
d446c3eccc41 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 6024
diff changeset
  2673
                        idx.
d446c3eccc41 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 6024
diff changeset
  2674
                   ].
5729
2bbfe888300a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5684
diff changeset
  2675
    ].
6039
121d71b79bda #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 6038
diff changeset
  2676
"/ ]).
5729
2bbfe888300a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5684
diff changeset
  2677
    self selection:indices
2bbfe888300a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5684
diff changeset
  2678
!
2bbfe888300a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5684
diff changeset
  2679
4574
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2680
selectFirst
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2681
    "select the first selectable element.
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2682
     Model and/or actionBlock notification IS done."
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2683
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2684
    self selection:(self nextSelectableAfter:0)
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2685
!
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2686
4873
576dc9a44d18 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 4796
diff changeset
  2687
selectFirstVisibleLine
576dc9a44d18 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 4796
diff changeset
  2688
    "select the first visible selectable element.
576dc9a44d18 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 4796
diff changeset
  2689
     Model and/or actionBlock notification IS done."
576dc9a44d18 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 4796
diff changeset
  2690
576dc9a44d18 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 4796
diff changeset
  2691
    |firstLineShown|
576dc9a44d18 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 4796
diff changeset
  2692
    
576dc9a44d18 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 4796
diff changeset
  2693
    firstLineShown := self yVisibleToLineNr:1.
576dc9a44d18 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 4796
diff changeset
  2694
    self selection:(self nextSelectableAfter:firstLineShown-1)
576dc9a44d18 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 4796
diff changeset
  2695
!
576dc9a44d18 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 4796
diff changeset
  2696
2399
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2697
selectFrom:aStart to:aStop
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2698
    "select lines between start and stop
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2699
    "
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2700
    |start stop step nsel|
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2701
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2702
    multipleSelectOk ifFalse:[^ self].
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2703
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2704
    start := aStart.
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2705
    stop  := aStop.
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2706
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2707
    aStart < aStop ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2708
	start := aStart max:1.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2709
	stop  := aStop  min:(self size).
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2710
	step  := 1.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2711
	start > stop ifTrue:[^ self].
2399
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2712
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2713
    ] ifFalse:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2714
	start := aStart min:(self size).
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2715
	stop  := aStop  max:1.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2716
	step  := -1.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2717
	start < stop ifTrue:[^ self].
2399
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2718
    ].
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2719
    nsel := OrderedCollection new.
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2720
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2721
    start to:stop by:step do:[:i|
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2722
	(self canSelectIndex:i forAdd:true) ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2723
	    nsel add:i.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2724
	].
2399
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2725
    ].
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2726
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2727
    (self selectWithoutScroll:nsel redraw:true) ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2728
	self selectionChanged
2399
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2729
    ].
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2730
!
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2731
4574
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2732
selectLast
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2733
    "select the last selectable element.
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2734
     Model and/or actionBlock notification IS done."
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2735
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2736
    self selection:(self previousSelectableBefore:list size + 1)
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2737
!
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2738
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2739
selectNext
5550
055cf25539f5 #DOCUMENTATION by mawalch
mawalch
parents: 5496
diff changeset
  2740
    "select next line or first visible if there is currently no selection.
055cf25539f5 #DOCUMENTATION by mawalch
mawalch
parents: 5496
diff changeset
  2741
     Wrap at end.
4574
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2742
     Model and/or actionBlock notification IS done."
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2743
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2744
    self selection:(self nextAfterSelection)
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2745
5550
055cf25539f5 #DOCUMENTATION by mawalch
mawalch
parents: 5496
diff changeset
  2746
    "Modified: / 15-11-1996 / 17:01:27 / cg"
055cf25539f5 #DOCUMENTATION by mawalch
mawalch
parents: 5496
diff changeset
  2747
    "Modified (comment): / 07-06-2017 / 17:20:33 / mawalch"
4574
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2748
!
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2749
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2750
selectPrevious
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2751
    "select previous line or previous visible if there is currently no selection.
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2752
     Wrap at beginning. 
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2753
     Model and/or actionBlock notification IS done."
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2754
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2755
    self selection:(self previousBeforeSelection).
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2756
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2757
    "Modified: 26.9.1995 / 09:41:16 / stefan"
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2758
    "Modified: 15.11.1996 / 17:01:34 / cg"
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2759
!
4ccc6b5caf8c Added selectFirst/Next/Last/Prev to make it polymorph with SelectionInListView.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4571
diff changeset
  2760
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2761
selectedElement
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2762
    "return the single selected item or nil
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2763
    "
1545
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  2764
    |index|
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2765
1545
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  2766
    (index := self selectedIndex) ~~ 0 ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2767
	^ self at:index ifAbsent:nil
1545
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  2768
    ].
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  2769
    ^ nil
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2770
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2771
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2772
selectedIndex
5729
2bbfe888300a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5684
diff changeset
  2773
    "returns the index of the selected line or 0. 
2bbfe888300a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5684
diff changeset
  2774
     If multiple lines are selected, 0 is returned
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2775
    "
2365
bdf6954a0358 key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents: 2361
diff changeset
  2776
    selection notNil ifTrue:[
5729
2bbfe888300a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5684
diff changeset
  2777
        multipleSelectOk ifFalse:[ ^ selection ].
2bbfe888300a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5684
diff changeset
  2778
2bbfe888300a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5684
diff changeset
  2779
        selection size == 1 ifTrue:[
2bbfe888300a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5684
diff changeset
  2780
            ^ selection at:1
2bbfe888300a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5684
diff changeset
  2781
        ]
1545
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  2782
    ].
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  2783
    ^ 0
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2784
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2785
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2786
selection
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2787
    "return the selection index or collection of indices
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2788
     in case of multiple selection enabled
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2789
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2790
    ^ selection
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2791
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2792
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2793
6092
24193361cde8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6049
diff changeset
  2794
selection:indexOrIndexCollection
1545
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  2795
    "select something or deselect if the argument is nil;
6092
24193361cde8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6049
diff changeset
  2796
     indexOrIndexCollection is either an individual index 
5729
2bbfe888300a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5684
diff changeset
  2797
     or (if multiSelect is enabled) a collection of indices.
6092
24193361cde8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6049
diff changeset
  2798
     Scroll to make the selected line visible.
3873
ec4ba667fe41 comment/format in: #selection:
Claus Gittinger <cg@exept.de>
parents: 3851
diff changeset
  2799
     The model and/or actionBlock IS notified."
ec4ba667fe41 comment/format in: #selection:
Claus Gittinger <cg@exept.de>
parents: 3851
diff changeset
  2800
6092
24193361cde8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6049
diff changeset
  2801
    (self selectWithoutScroll:indexOrIndexCollection redraw:true) ifTrue:[
3873
ec4ba667fe41 comment/format in: #selection:
Claus Gittinger <cg@exept.de>
parents: 3851
diff changeset
  2802
        self makeSelectionVisible.
ec4ba667fe41 comment/format in: #selection:
Claus Gittinger <cg@exept.de>
parents: 3851
diff changeset
  2803
        self selectionChanged
1545
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  2804
    ].
6092
24193361cde8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6049
diff changeset
  2805
24193361cde8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6049
diff changeset
  2806
    "Modified (comment): / 20-07-2019 / 07:37:26 / Claus Gittinger"
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2807
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2808
2330
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2809
selectionAsCollection
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2810
    "return the selection as a collection of line numbers.
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2811
     This allows users of this class to enumerate independent of
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2812
     the multipleSelect style.
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2813
    "
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2814
    selection isNil  ifTrue:[ ^ #() ].
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2815
    multipleSelectOk ifTrue:[ ^ selection ].
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2816
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2817
  ^ OrderedCollection with:selection
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2818
!
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2819
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2820
selectionDo:aBlock
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2821
    "perform aBlock for each nr in the selection.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2822
     For single selection, it is called once for the items nr.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2823
     For multiple selections, it is called for each.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2824
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2825
    selection notNil ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2826
	multipleSelectOk ifTrue:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2827
	    selection do:aBlock
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2828
	] ifFalse:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2829
	    aBlock value:selection
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2830
	].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2831
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2832
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2833
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2834
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2835
2330
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2836
selectionValue
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2837
    "return the selection value i.e. the text in the selected line.
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2838
     For multiple selections a collection containing the entries is returned.
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2839
    "
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2840
    multipleSelectOk ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2841
	selection isNil ifTrue:[^ #()].
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2842
	^ selection collect:[:nr| self at:nr ]
2330
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2843
    ].
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2844
    selection isNil ifTrue:[^ nil].
2408
8b0d11537dc0 accessing list indirect
ca
parents: 2404
diff changeset
  2845
    ^ self at:selection ifAbsent:nil.
2330
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2846
!
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2847
2346
b15af0e8dacc add #selectionValueAsCollection
ca
parents: 2333
diff changeset
  2848
selectionValueAsCollection
b15af0e8dacc add #selectionValueAsCollection
ca
parents: 2333
diff changeset
  2849
    "return the selection values as a collection - allows selectionValues to
b15af0e8dacc add #selectionValueAsCollection
ca
parents: 2333
diff changeset
  2850
     be enumerated independent of the multiSelect settings
b15af0e8dacc add #selectionValueAsCollection
ca
parents: 2333
diff changeset
  2851
    "
b15af0e8dacc add #selectionValueAsCollection
ca
parents: 2333
diff changeset
  2852
    |value|
b15af0e8dacc add #selectionValueAsCollection
ca
parents: 2333
diff changeset
  2853
b15af0e8dacc add #selectionValueAsCollection
ca
parents: 2333
diff changeset
  2854
    value := self selectionValue.
b15af0e8dacc add #selectionValueAsCollection
ca
parents: 2333
diff changeset
  2855
    multipleSelectOk ifTrue:[^ value].
b15af0e8dacc add #selectionValueAsCollection
ca
parents: 2333
diff changeset
  2856
b15af0e8dacc add #selectionValueAsCollection
ca
parents: 2333
diff changeset
  2857
    value notNil ifTrue:[^ Array with:value ].
b15af0e8dacc add #selectionValueAsCollection
ca
parents: 2333
diff changeset
  2858
  ^ #()
b15af0e8dacc add #selectionValueAsCollection
ca
parents: 2333
diff changeset
  2859
!
b15af0e8dacc add #selectionValueAsCollection
ca
parents: 2333
diff changeset
  2860
6165
79773ea4a039 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 6092
diff changeset
  2861
setSelection:indexOrIndexCollection
1545
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  2862
    "select something or deselect if the argument is nil;
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2863
     scroll to make the selected line visible.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2864
     *** No model and/or actionBlock notification is done here.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2865
    "
6165
79773ea4a039 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 6092
diff changeset
  2866
    (self selectWithoutScroll:indexOrIndexCollection redraw:true) ifTrue:[
79773ea4a039 #DOCUMENTATION by exept
Claus Gittinger <cg@exept.de>
parents: 6092
diff changeset
  2867
        self makeSelectionVisible
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2868
    ]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2869
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2870
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2871
!SelectionInListModelView methodsFor:'selection private'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2872
1641
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
  2873
canSelectIndex:anIndex
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
  2874
    "return true, if the object identified by its index is selectable
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
  2875
    "
1920
e3994a83fb16 selectConditionBlock can be a 2-arg block;
martin
parents: 1917
diff changeset
  2876
    ^ self canSelectIndex:anIndex forAdd:false
e3994a83fb16 selectConditionBlock can be a 2-arg block;
martin
parents: 1917
diff changeset
  2877
!
e3994a83fb16 selectConditionBlock can be a 2-arg block;
martin
parents: 1917
diff changeset
  2878
e3994a83fb16 selectConditionBlock can be a 2-arg block;
martin
parents: 1917
diff changeset
  2879
canSelectIndex:anIndex forAdd:isForAdd
e3994a83fb16 selectConditionBlock can be a 2-arg block;
martin
parents: 1917
diff changeset
  2880
    "return true, if the object identified by its index is selectable
e3994a83fb16 selectConditionBlock can be a 2-arg block;
martin
parents: 1917
diff changeset
  2881
    "
e3994a83fb16 selectConditionBlock can be a 2-arg block;
martin
parents: 1917
diff changeset
  2882
    |item isOk|
1649
60cf82a7d585 checkin from browser
ps
parents: 1644
diff changeset
  2883
60cf82a7d585 checkin from browser
ps
parents: 1644
diff changeset
  2884
    selectConditionBlock notNil ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2885
	isOk := selectConditionBlock valueWithOptionalArgument:anIndex and:isForAdd.
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2886
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2887
	isOk ifFalse:[
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2888
	    ^ false
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2889
	]
1641
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
  2890
    ].
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
  2891
2408
8b0d11537dc0 accessing list indirect
ca
parents: 2404
diff changeset
  2892
    item := self at:anIndex ifAbsent:nil.
1752
1c11b6e4ab37 use isHierarchicalItem instead of hack variable
ca
parents: 1748
diff changeset
  2893
    item isNil ifTrue:[^ false].
2408
8b0d11537dc0 accessing list indirect
ca
parents: 2404
diff changeset
  2894
1752
1c11b6e4ab37 use isHierarchicalItem instead of hack variable
ca
parents: 1748
diff changeset
  2895
    item isHierarchicalItem ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2896
	^ item isSelectable
1649
60cf82a7d585 checkin from browser
ps
parents: 1644
diff changeset
  2897
    ].
60cf82a7d585 checkin from browser
ps
parents: 1644
diff changeset
  2898
    ^ true
1641
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
  2899
!
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
  2900
1547
f72d75aaec14 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
  2901
deselectWithoutRedraw
f72d75aaec14 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
  2902
    "clear the selection without redraw and scrolling;
f72d75aaec14 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
  2903
     the model and/or actionBlock is notified
f72d75aaec14 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
  2904
    "
f72d75aaec14 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
  2905
    (self selectWithoutScroll:nil redraw:false) ifTrue:[
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2906
	self selectionChanged
1547
f72d75aaec14 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
  2907
    ]
f72d75aaec14 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
  2908
!
f72d75aaec14 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
  2909
3370
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
  2910
selectAndUpdateModelWithoutChangeNotification: aLineNo
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
  2911
    |arg|
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
  2912
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
  2913
    self selectWithoutScroll:aLineNo redraw:true.
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
  2914
    modelChangedDuringButtonPress := false.
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
  2915
    model isNil ifTrue:[ ^ self ].
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
  2916
    arg := self argForChangeMessage.
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
  2917
    self sendChangeMessage:#setValue: with:arg.
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
  2918
!
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
  2919
6092
24193361cde8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6049
diff changeset
  2920
selectWithoutScroll:newSelection redraw:doRedraw
5729
2bbfe888300a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5684
diff changeset
  2921
    "change selection to something; 
6092
24193361cde8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6049
diff changeset
  2922
     newSelection is either an individual index 
5729
2bbfe888300a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5684
diff changeset
  2923
     or (if multiSelect is enabled) a collection of indices.
6092
24193361cde8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6049
diff changeset
  2924
     Returns true if selection changed"
24193361cde8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6049
diff changeset
  2925
24193361cde8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6049
diff changeset
  2926
    |indexOrIndexCollection oldSelect size|
24193361cde8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6049
diff changeset
  2927
24193361cde8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6049
diff changeset
  2928
    indexOrIndexCollection := newSelection.
24193361cde8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6049
diff changeset
  2929
    multipleSelectOk ifTrue:[
24193361cde8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6049
diff changeset
  2930
        newSelection isCollection ifFalse:[
24193361cde8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6049
diff changeset
  2931
            indexOrIndexCollection := { newSelection }
24193361cde8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6049
diff changeset
  2932
        ].    
24193361cde8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6049
diff changeset
  2933
    ] ifFalse:[
24193361cde8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6049
diff changeset
  2934
        newSelection size > 0 ifTrue:[
24193361cde8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6049
diff changeset
  2935
            indexOrIndexCollection := newSelection first
24193361cde8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6049
diff changeset
  2936
        ].    
24193361cde8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6049
diff changeset
  2937
    ].    
24193361cde8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6049
diff changeset
  2938
    selection = indexOrIndexCollection ifTrue:[^ false].
1554
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  2939
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2940
    oldSelect := selection.
4242
20d8ff7dc6a9 class: SelectionInListModelView
ca
parents: 4206
diff changeset
  2941
    selection := nil.   "/reset selection
20d8ff7dc6a9 class: SelectionInListModelView
ca
parents: 4206
diff changeset
  2942
    size := self size.
20d8ff7dc6a9 class: SelectionInListModelView
ca
parents: 4206
diff changeset
  2943
6092
24193361cde8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6049
diff changeset
  2944
    ( size > 0 and:[ indexOrIndexCollection notNil ] ) ifTrue:[
24193361cde8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6049
diff changeset
  2945
        indexOrIndexCollection isNumber ifTrue:[
24193361cde8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6049
diff changeset
  2946
            (indexOrIndexCollection between:1 and:size) ifTrue:[
24193361cde8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6049
diff changeset
  2947
                selection := multipleSelectOk ifTrue:[Array with:indexOrIndexCollection]
24193361cde8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6049
diff changeset
  2948
                                             ifFalse:[indexOrIndexCollection]
4242
20d8ff7dc6a9 class: SelectionInListModelView
ca
parents: 4206
diff changeset
  2949
            ]
20d8ff7dc6a9 class: SelectionInListModelView
ca
parents: 4206
diff changeset
  2950
        ] ifFalse:[
6092
24193361cde8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6049
diff changeset
  2951
            indexOrIndexCollection size ~~ 0 ifTrue:[
4242
20d8ff7dc6a9 class: SelectionInListModelView
ca
parents: 4206
diff changeset
  2952
                selection := OrderedCollection new.
6092
24193361cde8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6049
diff changeset
  2953
                indexOrIndexCollection do:[:each|
4242
20d8ff7dc6a9 class: SelectionInListModelView
ca
parents: 4206
diff changeset
  2954
                    each isNumber ifTrue:[
20d8ff7dc6a9 class: SelectionInListModelView
ca
parents: 4206
diff changeset
  2955
                        (each between:1 and:size) ifTrue:[
20d8ff7dc6a9 class: SelectionInListModelView
ca
parents: 4206
diff changeset
  2956
                            selection add: each.
20d8ff7dc6a9 class: SelectionInListModelView
ca
parents: 4206
diff changeset
  2957
                        ]
20d8ff7dc6a9 class: SelectionInListModelView
ca
parents: 4206
diff changeset
  2958
                    ]
20d8ff7dc6a9 class: SelectionInListModelView
ca
parents: 4206
diff changeset
  2959
                ].
20d8ff7dc6a9 class: SelectionInListModelView
ca
parents: 4206
diff changeset
  2960
                selection isEmpty ifTrue:[
20d8ff7dc6a9 class: SelectionInListModelView
ca
parents: 4206
diff changeset
  2961
                    selection := nil.
20d8ff7dc6a9 class: SelectionInListModelView
ca
parents: 4206
diff changeset
  2962
                ] ifFalse:[
20d8ff7dc6a9 class: SelectionInListModelView
ca
parents: 4206
diff changeset
  2963
                    multipleSelectOk ifFalse:[ selection := selection first ].
20d8ff7dc6a9 class: SelectionInListModelView
ca
parents: 4206
diff changeset
  2964
                ].
20d8ff7dc6a9 class: SelectionInListModelView
ca
parents: 4206
diff changeset
  2965
            ].
20d8ff7dc6a9 class: SelectionInListModelView
ca
parents: 4206
diff changeset
  2966
        ].
1545
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  2967
    ].
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  2968
    selection = oldSelect ifTrue:[^ false].
3205
7ff2e20b37d4 *** empty log message ***
ca
parents: 3202
diff changeset
  2969
7ff2e20b37d4 *** empty log message ***
ca
parents: 3202
diff changeset
  2970
    modelChangedDuringButtonPress notNil ifTrue:[
4242
20d8ff7dc6a9 class: SelectionInListModelView
ca
parents: 4206
diff changeset
  2971
        modelChangedDuringButtonPress := true.
3205
7ff2e20b37d4 *** empty log message ***
ca
parents: 3202
diff changeset
  2972
    ].
7ff2e20b37d4 *** empty log message ***
ca
parents: 3202
diff changeset
  2973
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2974
    self closeEditor.
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  2975
    self cursorEntersItem:nil.
1545
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  2976
3728
8858b3571313 oops: licenceBox dependency was missing;
sr
parents: 3704
diff changeset
  2977
1545
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  2978
    (doRedraw and:[shown]) ifFalse:[
4242
20d8ff7dc6a9 class: SelectionInListModelView
ca
parents: 4206
diff changeset
  2979
        ^ true
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2980
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2981
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2982
    multipleSelectOk ifFalse:[
4242
20d8ff7dc6a9 class: SelectionInListModelView
ca
parents: 4206
diff changeset
  2983
        oldSelect notNil ifTrue:[self invalidateSelectionAt:oldSelect].
20d8ff7dc6a9 class: SelectionInListModelView
ca
parents: 4206
diff changeset
  2984
        selection notNil ifTrue:[self invalidateSelectionAt:selection].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2985
    ] ifTrue:[
4242
20d8ff7dc6a9 class: SelectionInListModelView
ca
parents: 4206
diff changeset
  2986
        (selection notNil and:[oldSelect notNil]) ifTrue:[
20d8ff7dc6a9 class: SelectionInListModelView
ca
parents: 4206
diff changeset
  2987
            selection do:[:i|(oldSelect includesIdentical:i) ifFalse:[self invalidateSelectionAt:i]].
20d8ff7dc6a9 class: SelectionInListModelView
ca
parents: 4206
diff changeset
  2988
            oldSelect do:[:i|(selection includesIdentical:i) ifFalse:[self invalidateSelectionAt:i]].
20d8ff7dc6a9 class: SelectionInListModelView
ca
parents: 4206
diff changeset
  2989
        ] ifFalse:[
20d8ff7dc6a9 class: SelectionInListModelView
ca
parents: 4206
diff changeset
  2990
            oldSelect isNil ifTrue:[oldSelect := selection].
20d8ff7dc6a9 class: SelectionInListModelView
ca
parents: 4206
diff changeset
  2991
            oldSelect do:[:i|self invalidateSelectionAt:i]
20d8ff7dc6a9 class: SelectionInListModelView
ca
parents: 4206
diff changeset
  2992
        ]
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2993
    ].
1545
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  2994
    ^ true
6015
2eabdcac77fb #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5918
diff changeset
  2995
6092
24193361cde8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6049
diff changeset
  2996
    "Modified: / 20-07-2019 / 07:40:58 / Claus Gittinger"
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2997
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2998
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2999
!SelectionInListModelView class methodsFor:'documentation'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3000
4515
6ca475e94989 class: SelectionInListModelView
Stefan Vogel <sv@exept.de>
parents: 4512
diff changeset
  3001
version
4796
6c35c2439ca3 class: SelectionInListModelView
ca
parents: 4702
diff changeset
  3002
    ^ '$Header$'
4515
6ca475e94989 class: SelectionInListModelView
Stefan Vogel <sv@exept.de>
parents: 4512
diff changeset
  3003
!
6ca475e94989 class: SelectionInListModelView
Stefan Vogel <sv@exept.de>
parents: 4512
diff changeset
  3004
3778
ccbe7479c97b changed: #openEditorAtX:y:
Claus Gittinger <cg@exept.de>
parents: 3750
diff changeset
  3005
version_CVS
4796
6c35c2439ca3 class: SelectionInListModelView
ca
parents: 4702
diff changeset
  3006
    ^ '$Header$'
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3007
! !
4181
34f4fd818a18 class: SelectionInListModelView
Claus Gittinger <cg@exept.de>
parents: 4085
diff changeset
  3008