SelectionInListModelView.st
author Claus Gittinger <cg@exept.de>
Fri, 06 Jun 2008 10:41:00 +0200
changeset 3438 a8ce9823cc1e
parent 3391 eb009a36b8e4
child 3455 825b5e491106
permissions -rw-r--r--
english
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1431
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
     1
"
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
     2
 COPYRIGHT (c) 1999 by eXept Software AG
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
     3
              All Rights Reserved
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
     4
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
     5
 This software is furnished under a license and may be used
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
     6
 only in accordance with the terms of that license and with the
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
     8
 be provided or otherwise made available to, or used by, any
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
     9
 other person.  No title to or ownership of the software is
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    10
 hereby transferred.
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    11
"
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
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
ListModelView subclass:#SelectionInListModelView
2821
ea7f6fdb8c95 Fix bas spelling Buttom -> Button
Stefan Vogel <sv@exept.de>
parents: 2815
diff changeset
    15
	instanceVariableNames:'selection multipleSelectOk selectOnButtonMenu actionBlock
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
    16
		doubleClickActionBlock selectConditionBlock buttonMotionAction
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
    17
		buttonReleaseAction highlightMode useIndex ignoreReselect
3137
7e8fae56b94c highlight selection dependent on has focus
ca
parents: 3081
diff changeset
    18
		toggleSelect hilightFgColor hilightBgColor hilightFgColorNoFocus
7e8fae56b94c highlight selection dependent on has focus
ca
parents: 3081
diff changeset
    19
		hilightBgColorNoFocus hilightLevel hilightFrameColor hilightStyle
7e8fae56b94c highlight selection dependent on has focus
ca
parents: 3081
diff changeset
    20
		dropSource editorView openEditorAction closeEditorAction
7e8fae56b94c highlight selection dependent on has focus
ca
parents: 3081
diff changeset
    21
		highlightEnterItem enterItem cursorItem lineMask keyActionStyle
3370
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
    22
		returnKeyActionStyle strikeOut modelChangedDuringButtonPress
3438
a8ce9823cc1e english
Claus Gittinger <cg@exept.de>
parents: 3391
diff changeset
    23
		selectOnButtonPress selectOnMenuButton'
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
	classVariableNames:'DefaultHilightStyle DefaultHilightBackgroundColor
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
		DefaultHilightForegroundColor DefaultHilightLevel
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
		DefaultHilightFrameColor'
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
	poolDictionaries:''
1430
ae9e48cc7b9d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1423
diff changeset
    28
	category:'Views-Lists'
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
!SelectionInListModelView class methodsFor:'documentation'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
1431
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    33
copyright
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    34
"
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    35
 COPYRIGHT (c) 1999 by eXept Software AG
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    36
              All Rights Reserved
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
 This software is furnished under a license and may be used
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    39
 only in accordance with the terms of that license and with the
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    40
 inclusion of the above copyright notice.   This software may not
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    41
 be provided or otherwise made available to, or used by, any
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    42
 other person.  No title to or ownership of the software is
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    43
 hereby transferred.
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    44
"
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    45
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    46
!
0cc20a8f2f7c docu & copyright
Claus Gittinger <cg@exept.de>
parents: 1430
diff changeset
    47
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
documentation
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
    SelectionInListModelView is mostly like SelectionInListView,
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
    but derives from the ListModelView and thus the list is kept
3387
6da21b625d1e warning comments
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
    52
    in the list.
6da21b625d1e warning comments
Claus Gittinger <cg@exept.de>
parents: 3385
diff changeset
    53
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
    [Instance variables:]
2228
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
    55
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
    56
        selection               <misc>       the current selection. nil, a number or collection of numbers
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
    57
        multipleSelectOk        <Boolean>    allow/disallow multiple selections( default:false )
2821
ea7f6fdb8c95 Fix bas spelling Buttom -> Button
Stefan Vogel <sv@exept.de>
parents: 2815
diff changeset
    58
        selectOnButtonMenu      <Boolean>    enable/disable selection will change on menu pressed
2228
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
    59
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
    60
        buttonReleaseAction     <Action>     called if the mouse button is released
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
    61
        buttonMotionAction      <Action>     called during mouse motion with one argument the point
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
    62
                                             under the mouse.
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
    63
2416
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
    64
        actionBlock             <Block>      action evaluated on single click (0/1/2 arguments)
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
    65
        doubleClickActionBlock  <Block>      action evaluated on double click (0/1/2 arguments)
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
    66
        selectConditionBlock    <Block>      action evaluated before selection changed (0/1/2 arguments)
2228
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
    67
2418
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
    68
        keyActionStyle          <Symbol>     controls how to respond to keyboard selects
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
    69
        returnKeyActionStyle    <Symbol>     controls how to respond to return key
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
    70
2228
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
    71
        useIndex                <Boolean>    representation of the model selection
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
    72
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
    73
        ignoreReselect          <Boolean>    if set, a click on an already selected entry is ignored
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
    74
        toggleSelect            <Boolean>    a click on an entry unselects it and vice versa
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
    75
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
    76
        highlightMode           <Symbol>     how to draw the selection
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
    77
        hilightFgColor          <Color>      foregroundColor of highlighted items       
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
    78
        hilightBgColor          <Color>      backgroundColor of highlighted items
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
    79
        hilightLevel            <Integer>    level to draw selections (i.e. for 3D effect)
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
    80
        hilightFrameColor       <Color>      rectangle around highlighted items
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
    81
        hilightStyle            <Boolean>    actions on widget are enabled/disabled
2418
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
    82
        strikeOut               <Boolean>    turn on/off strikeOut mode
2228
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
    83
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
    84
        dropTarget              <DropTarget> keeps information about the drop operation
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
    85
        dropSource              <DropSource> keeps information about the drag operation
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
    86
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
    87
        editorView              <View>       editor on current selected item
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
    88
        openEditorAction        <Action>     action to get an editor on the current selection from user
2250
e95303644fac add an closeEditor action to allow the user to accept the contents
james
parents: 2245
diff changeset
    89
        closeEditorAction       <Action>     action invoked before the editor is closed.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    90
2323
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
    91
        enterItem               <Item/nil>   item over which the mouse pointer is located
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
    92
                                             or nil
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
    93
        highlightEnterItem      <Boolean>    enable or disable highlight of enterItem
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
    94
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
    [author:]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
        Claus Atzkern
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
    [see also:]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
        ListModelView
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
        HierarchicalListView
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   103
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
examples
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   106
"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
                                                                        [exBegin]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
    |top list view|
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   109
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   110
    list := List new.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
    1 to:100 do:[:i| list add:('element: ', i printString) ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
    top  := StandardSystemView new; extent:300@300.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
    view := ScrollableView for:SelectionInListModelView miniScroller:true
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   115
                        origin:0.0@0.0 corner:1.0@1.0 in:top.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   116
    view list:list.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   117
    top  open.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
                                                                        [exEnd]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   120
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   121
                                                                        [exBegin]
1915
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
   122
    |top list view|
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
   123
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
   124
    list := List new.
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
   125
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
   126
    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
   127
    top  := StandardSystemView new; extent:300@300.
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
   128
    view := ScrollableView for:SelectionInListModelView miniScroller:true
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
   129
                        origin:0.0@0.0 corner:1.0@1.0 in:top.
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
   130
    view list:list.
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
   131
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
   132
    view openEditorAction:[:ln :aGC| |field|
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
   133
        field := EditField new.
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
   134
        field level:0.
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
   135
        field acceptOnLostFocus:true.
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
   136
        field acceptAction:[:x| list at:ln put:(field contents) ].
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
   137
        field font:(aGC font).
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
   138
        field contents:(list at:ln).
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
   139
        field
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
   140
    ].
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
   141
    top open.
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
   142
                                                                        [exEnd]
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
   143
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
   144
                                                                        [exBegin]
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   145
    |top list view item|
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   146
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   147
    list := HierarchicalList new.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   148
    item := HierarchicalItem::Example labeled:'Test'.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   149
    item expand.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   150
    list showRoot:false.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   151
    list root:item.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   152
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   153
    top  := StandardSystemView new; extent:300@300.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   154
    view := ScrollableView for:SelectionInListModelView miniScroller:true
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   155
                        origin:0.0@0.0 corner:1.0@1.0 in:top.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   156
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   157
    view list:list.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   158
    view doubleClickAction:[:i| (list at:i) toggleExpand ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   159
    top  open.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   160
                                                                        [exEnd]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   161
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   162
"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   163
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   164
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   165
!SelectionInListModelView class methodsFor:'defaults'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   166
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   167
updateStyleCache
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   168
    "extract values from the styleSheet and cache them in class variables"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   169
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   170
    <resource: #style   (
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   171
                        #'selection.hilightForegroundColor' #'selection.hilightBackgroundColor'
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   172
                        #'selection.hilightFrameColor'      #'selection.hilightLevel'
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   173
                        #'selection.foregroundColor'        #'selection.backgroundColor'
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   174
                        #'selection.shadowColor'            #'selection.lightColor'
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   175
                        #'selection.font'                   #'selection.hilightStyle'
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   176
                        #'text.foregroundColor'
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   177
                        )>
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   178
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   179
    DefaultHilightForegroundColor  := StyleSheet colorAt:'selection.hilightForegroundColor'.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   180
    DefaultHilightBackgroundColor  := StyleSheet colorAt:'selection.hilightBackgroundColor'.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   181
    DefaultHilightFrameColor       := StyleSheet colorAt:'selection.hilightFrameColor'.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   182
    DefaultHilightLevel            := StyleSheet at:'selection.hilightLevel' default:0.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   183
    DefaultHilightStyle            := StyleSheet at:'selection.hilightStyle' default:(StyleSheet name).
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   184
    DefaultForegroundColor         := StyleSheet colorAt:'selection.foregroundColor'.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   185
    DefaultBackgroundColor         := StyleSheet colorAt:'selection.backgroundColor'.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   186
    DefaultShadowColor             := StyleSheet colorAt:'selection.shadowColor'.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   187
    DefaultLightColor              := StyleSheet colorAt:'selection.lightColor'.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   188
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   189
    DefaultForegroundColor isNil ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   190
        DefaultForegroundColor := StyleSheet colorAt:'text.foregroundColor' default:Black
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   191
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   192
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   193
     self updateStyleCache
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   194
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   195
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   196
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   197
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   198
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   199
!SelectionInListModelView methodsFor:'accessing'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   200
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
   201
cursorLine
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
   202
    "returns the index of the cursor line or 0
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
   203
    "
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
   204
    |index|
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
   205
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
   206
    cursorItem isNil ifTrue:[^ 0 ].
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
   207
2408
8b0d11537dc0 accessing list indirect
ca
parents: 2404
diff changeset
   208
    index := self identityIndexOf:cursorItem.
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
   209
    index == 0 ifTrue:[ cursorItem := nil ].
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
   210
    ^ index
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
   211
!
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
   212
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   213
list:aList
1547
f72d75aaec14 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
   214
    self deselectWithoutRedraw.
2867
bbdc2721ec0b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2856
diff changeset
   215
    ^ super list:aList
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   216
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   217
1818
fe99c5c721e9 category changes
Claus Gittinger <cg@exept.de>
parents: 1772
diff changeset
   218
!SelectionInListModelView methodsFor:'accessing-actions'!
1641
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   219
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   220
action
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   221
    "get the action block to be performed on select
2416
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
   222
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
   223
     The arguments to the block are:
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
   224
        - no argument
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
   225
        -  1 argument     index or item
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
   226
        -  2 argument     index or item, self
1641
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   227
    "
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   228
    ^ actionBlock
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   229
!
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   230
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   231
action:aOneArgAction
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   232
    "set the action block to be performed on select
2416
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
   233
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
   234
     The arguments to the block are:
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
   235
        - no argument
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
   236
        -  1 argument     index or item
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
   237
        -  2 argument     index or item, self
1641
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   238
    "
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   239
    actionBlock := aOneArgAction
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   240
!
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   241
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   242
doubleClickAction
2416
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
   243
    "get the action block to be performed on doubleclick.
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
   244
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
   245
     The arguments to the block are:
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
   246
        - no argument
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
   247
        -  1 argument     selectedIndex
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
   248
        -  2 argument     selectedIndex, self
1641
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   249
    "
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   250
    ^ doubleClickActionBlock
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   251
!
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   252
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   253
doubleClickAction:aOneArgAction
2416
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
   254
    "set the action block to be performed on doubleclick.
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
   255
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
   256
     The arguments to the block are:
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
   257
        - no argument
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
   258
        -  1 argument     selectedIndex
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
   259
        -  2 argument     selectedIndex, self
1641
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   260
    "
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   261
    doubleClickActionBlock := aOneArgAction
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   262
!
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   263
2418
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   264
keyActionStyle
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   265
    "defines how the view should respond to alpha-keys pressed.
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   266
     Possible values are:
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   267
        #select               -> will select next entry starting with that
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   268
                                 character and perform the click-action
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   269
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   270
        #selectAndDoubleclick -> will select next & perform double-click action
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   271
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   272
        #pass                 -> will pass key to superclass (i.e. no special treatment)
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   273
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   274
        nil                   -> will ignore key
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   275
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   276
     the default (set in #initialize) is #select
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   277
    "
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   278
    ^ keyActionStyle
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   279
!
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   280
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   281
keyActionStyle:aSymbol
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   282
    "defines how the view should respond to alpha-keys pressed.
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   283
     Possible values are:
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   284
        #select               -> will select next entry starting with that
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   285
                                 character and perform the click-action
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   286
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   287
        #selectAndDoubleclick -> will select next & perform double-click action
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   288
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   289
        #pass                 -> will pass key to superclass (i.e. no special treatment)
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   290
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   291
        nil                   -> will ignore key
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   292
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   293
     the default (set in #initialize) is #select
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   294
    "
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   295
    keyActionStyle := aSymbol
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   296
!
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   297
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   298
returnKeyActionStyle
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   299
    "defines how the view should respond to a return key pressed.
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   300
     Possible values are:
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   301
        #doubleClick          -> perform double-click action
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   302
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   303
        #pass                 -> will pass key to superclass (i.e. no special treatment)
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   304
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   305
        nil                   -> will ignore key
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   306
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   307
     the default (set in #initialize) is #doubleClick 
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   308
    "
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   309
    ^ returnKeyActionStyle
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   310
!
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   311
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   312
returnKeyActionStyle:aSymbol
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   313
    "defines how the view should respond to a return key pressed.
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   314
     Possible values are:
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   315
        #doubleClick          -> perform double-click action
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   316
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   317
        #pass                 -> will pass key to superclass (i.e. no special treatment)
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   318
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   319
        nil                   -> will ignore key
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   320
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   321
     the default (set in #initialize) is #doubleClick 
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   322
    "
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   323
    returnKeyActionStyle := aSymbol
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   324
!
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   325
1641
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   326
selectConditionBlock
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   327
    "set the conditionBlock; this block is evaluated before a selection
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   328
     change is performed; the change will not be done, if the evaluation
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   329
     returns false
2416
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
   330
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
   331
     The arguments to the block are:
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
   332
        - no argument
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
   333
        -  1 argument     index
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
   334
        -  2 argument     index, isForAdd
1641
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   335
    "
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   336
    ^ selectConditionBlock
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   337
!
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   338
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   339
selectConditionBlock:aOneArgBlock
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   340
    "set the conditionBlock; this block is evaluated before a selection
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   341
     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
   342
     returns false.
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
   343
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
   344
     The arguments to the block are:
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
   345
        - no argument
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
   346
        -  1 argument     index
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
   347
        -  2 argument     index, isForAdd
1641
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   348
    "
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   349
    selectConditionBlock := aOneArgBlock.
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   350
! !
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
   351
2418
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   352
!SelectionInListModelView methodsFor:'accessing-attributes'!
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   353
2323
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
   354
highlightEnterItem
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
   355
    "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
   356
    "
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
   357
    ^ highlightEnterItem
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
   358
!
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
   359
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
   360
highlightEnterItem:aBool
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
   361
    "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
   362
    "
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
   363
    highlightEnterItem ~~ aBool ifTrue:[
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
   364
        highlightEnterItem := aBool.
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
   365
        self pointerEntersItem:nil.
3275
e40404564ccc enableMotionEvents if highlightEnterItem is set to true
ca
parents: 3221
diff changeset
   366
e40404564ccc enableMotionEvents if highlightEnterItem is set to true
ca
parents: 3221
diff changeset
   367
        highlightEnterItem ifTrue:[
e40404564ccc enableMotionEvents if highlightEnterItem is set to true
ca
parents: 3221
diff changeset
   368
            self enableMotionEvents
e40404564ccc enableMotionEvents if highlightEnterItem is set to true
ca
parents: 3221
diff changeset
   369
        ].
2323
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
   370
    ].
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
   371
!
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
   372
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   373
highlightMode
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   374
    "get the mode how to draw a selected line:
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   375
        #line           draw whole line selected
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   376
        #label          draw label selected
3367
29f38ac1bac1 support highlightMode (selection) #dropMode
ca
parents: 3345
diff changeset
   377
        #dropMode       set during drop
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   378
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   379
    ^ highlightMode
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   380
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   381
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   382
highlightMode:aMode
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   383
    "set the mode how to draw a selected line:
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   384
        #line           draw whole line selected
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   385
        #label          draw label selected
3367
29f38ac1bac1 support highlightMode (selection) #dropMode
ca
parents: 3345
diff changeset
   386
        #dropMode       set during drop
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   387
    "
2418
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   388
    highlightMode ~~ aMode ifTrue:[
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   389
        highlightMode := aMode.
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   390
        self invalidateSelection.
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   391
    ].
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   392
!
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   393
3338
01ad784543fc no underline-highlighting
Claus Gittinger <cg@exept.de>
parents: 3275
diff changeset
   394
highlightWithUnderline
01ad784543fc no underline-highlighting
Claus Gittinger <cg@exept.de>
parents: 3275
diff changeset
   395
    ^ false
01ad784543fc no underline-highlighting
Claus Gittinger <cg@exept.de>
parents: 3275
diff changeset
   396
!
01ad784543fc no underline-highlighting
Claus Gittinger <cg@exept.de>
parents: 3275
diff changeset
   397
2644
78ca3bd5eef1 prepared for table
ca
parents: 2642
diff changeset
   398
hilightBackgroundColor
78ca3bd5eef1 prepared for table
ca
parents: 2642
diff changeset
   399
    "returns the color used for the hilighted background
78ca3bd5eef1 prepared for table
ca
parents: 2642
diff changeset
   400
    "
78ca3bd5eef1 prepared for table
ca
parents: 2642
diff changeset
   401
    ^ hilightBgColor
78ca3bd5eef1 prepared for table
ca
parents: 2642
diff changeset
   402
!
78ca3bd5eef1 prepared for table
ca
parents: 2642
diff changeset
   403
78ca3bd5eef1 prepared for table
ca
parents: 2642
diff changeset
   404
hilightForegroundColor
78ca3bd5eef1 prepared for table
ca
parents: 2642
diff changeset
   405
    "returns the color used for the hilighted foreground
78ca3bd5eef1 prepared for table
ca
parents: 2642
diff changeset
   406
    "
78ca3bd5eef1 prepared for table
ca
parents: 2642
diff changeset
   407
    ^ hilightFgColor
78ca3bd5eef1 prepared for table
ca
parents: 2642
diff changeset
   408
!
78ca3bd5eef1 prepared for table
ca
parents: 2642
diff changeset
   409
2418
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   410
strikeout
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   411
    "turn on/off strikeOut mode
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   412
    "
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   413
    ^ strikeOut
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   414
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   415
2418
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   416
strikeout:aBoolean
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   417
    "turn on/off strikeOut mode
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   418
    "
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   419
    strikeOut ~~ aBoolean ifTrue:[
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   420
        strikeOut := aBoolean.
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   421
        self invalidateSelection.
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   422
    ].
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   423
! !
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   424
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   425
!SelectionInListModelView methodsFor:'accessing-behavior'!
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   426
1741
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   427
ignoreReselect
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   428
    "get the ignoreReselect flag - see method #ignoreReselect: for more details
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   429
    "
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   430
    ^ ignoreReselect
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   431
!
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   432
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   433
ignoreReselect:aBoolean
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   434
    "set/clear the ignoreReselect flag - 
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   435
     if set, a click on an already selected entry is ignored.
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   436
     Otherwise the notification is done, even if no
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   437
     change in the selection occurs.
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   438
     (for example, in browser to update a method).
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   439
     Setting ignoreReselect to false makes sense if data is shown
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   440
     which may change by itself (i.e. without the user doing anything)
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   441
     For example, the inspector uses this, and redisplays the value,
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   442
     if the selection is the same.
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   443
     The default is true, meaning that a click on an already selected
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   444
     does not lead to a notification via the actionBlock/change mechanism.
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   445
    "
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   446
    ignoreReselect := aBoolean
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   447
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   448
!
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   449
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   450
multipleSelectOk
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   451
    "allow/disallow multiple selections; the default is false
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   452
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   453
    ^ multipleSelectOk
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   454
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   455
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   456
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   457
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   458
multipleSelectOk:aState
2381
713c81fd86ad bugfix: update selection if multipleSelecktOk changed
ca
parents: 2377
diff changeset
   459
    "allow/disallow multiple selections. If enabled, the
713c81fd86ad bugfix: update selection if multipleSelecktOk changed
ca
parents: 2377
diff changeset
   460
     user may select multiple entries in the list, and the program
713c81fd86ad bugfix: update selection if multipleSelecktOk changed
ca
parents: 2377
diff changeset
   461
     always gets a collection of selected items (indexes if useIndex is true,
713c81fd86ad bugfix: update selection if multipleSelecktOk changed
ca
parents: 2377
diff changeset
   462
     values otherwise). The default is false, for single selections.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   463
    "
2381
713c81fd86ad bugfix: update selection if multipleSelecktOk changed
ca
parents: 2377
diff changeset
   464
    |state|
713c81fd86ad bugfix: update selection if multipleSelecktOk changed
ca
parents: 2377
diff changeset
   465
713c81fd86ad bugfix: update selection if multipleSelecktOk changed
ca
parents: 2377
diff changeset
   466
    state := aState ? false.
713c81fd86ad bugfix: update selection if multipleSelecktOk changed
ca
parents: 2377
diff changeset
   467
713c81fd86ad bugfix: update selection if multipleSelecktOk changed
ca
parents: 2377
diff changeset
   468
    multipleSelectOk == state ifTrue:[ ^ self ].
713c81fd86ad bugfix: update selection if multipleSelecktOk changed
ca
parents: 2377
diff changeset
   469
713c81fd86ad bugfix: update selection if multipleSelecktOk changed
ca
parents: 2377
diff changeset
   470
    selection isNil ifTrue:[
713c81fd86ad bugfix: update selection if multipleSelecktOk changed
ca
parents: 2377
diff changeset
   471
        multipleSelectOk := state.
713c81fd86ad bugfix: update selection if multipleSelecktOk changed
ca
parents: 2377
diff changeset
   472
        ^ self.
713c81fd86ad bugfix: update selection if multipleSelecktOk changed
ca
parents: 2377
diff changeset
   473
    ].
713c81fd86ad bugfix: update selection if multipleSelecktOk changed
ca
parents: 2377
diff changeset
   474
713c81fd86ad bugfix: update selection if multipleSelecktOk changed
ca
parents: 2377
diff changeset
   475
    multipleSelectOk ifFalse:[
713c81fd86ad bugfix: update selection if multipleSelecktOk changed
ca
parents: 2377
diff changeset
   476
        selection := Array with:selection.
713c81fd86ad bugfix: update selection if multipleSelecktOk changed
ca
parents: 2377
diff changeset
   477
        multipleSelectOk := true.
713c81fd86ad bugfix: update selection if multipleSelecktOk changed
ca
parents: 2377
diff changeset
   478
        ^ self
713c81fd86ad bugfix: update selection if multipleSelecktOk changed
ca
parents: 2377
diff changeset
   479
    ].
713c81fd86ad bugfix: update selection if multipleSelecktOk changed
ca
parents: 2377
diff changeset
   480
713c81fd86ad bugfix: update selection if multipleSelecktOk changed
ca
parents: 2377
diff changeset
   481
    selection size == 1 ifTrue:[
713c81fd86ad bugfix: update selection if multipleSelecktOk changed
ca
parents: 2377
diff changeset
   482
        selection := selection first.
713c81fd86ad bugfix: update selection if multipleSelecktOk changed
ca
parents: 2377
diff changeset
   483
    ] ifFalse:[
713c81fd86ad bugfix: update selection if multipleSelecktOk changed
ca
parents: 2377
diff changeset
   484
        self selection:nil
713c81fd86ad bugfix: update selection if multipleSelecktOk changed
ca
parents: 2377
diff changeset
   485
    ].
713c81fd86ad bugfix: update selection if multipleSelecktOk changed
ca
parents: 2377
diff changeset
   486
    multipleSelectOk := false.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   487
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   488
2228
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
   489
selectOnButtomMenu
2821
ea7f6fdb8c95 Fix bas spelling Buttom -> Button
Stefan Vogel <sv@exept.de>
parents: 2815
diff changeset
   490
    <resource: #obsolete>
2815
0c05fbd33df6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
   491
    self obsoleteMethodWarning:'use selectOnButtonMenu'.
0c05fbd33df6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
   492
    ^ self selectOnButtonMenu
0c05fbd33df6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
   493
!
0c05fbd33df6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
   494
0c05fbd33df6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
   495
selectOnButtomMenu:aBoolean
2821
ea7f6fdb8c95 Fix bas spelling Buttom -> Button
Stefan Vogel <sv@exept.de>
parents: 2815
diff changeset
   496
    <resource: #obsolete>
2815
0c05fbd33df6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
   497
    self obsoleteMethodWarning:'use selectOnButtonMenu:'.
0c05fbd33df6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
   498
    ^ self selectOnButtonMenu:aBoolean
0c05fbd33df6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
   499
!
0c05fbd33df6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
   500
0c05fbd33df6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
   501
selectOnButtonMenu
3438
a8ce9823cc1e english
Claus Gittinger <cg@exept.de>
parents: 3391
diff changeset
   502
    <resource: #obsolete>
2228
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
   503
    "define the button-menu-press behavior; if true the line under the mouse
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
   504
     will be selected before the menu is opened. Otherwise the menu is opened
2821
ea7f6fdb8c95 Fix bas spelling Buttom -> Button
Stefan Vogel <sv@exept.de>
parents: 2815
diff changeset
   505
     on the current selection."
ea7f6fdb8c95 Fix bas spelling Buttom -> Button
Stefan Vogel <sv@exept.de>
parents: 2815
diff changeset
   506
3438
a8ce9823cc1e english
Claus Gittinger <cg@exept.de>
parents: 3391
diff changeset
   507
    self obsoleteMethodWarning:'use selectOnMenuButton'.
a8ce9823cc1e english
Claus Gittinger <cg@exept.de>
parents: 3391
diff changeset
   508
    ^ self selectOnMenuButton
2228
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
   509
!
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
   510
2815
0c05fbd33df6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
   511
selectOnButtonMenu:aBoolean
3438
a8ce9823cc1e english
Claus Gittinger <cg@exept.de>
parents: 3391
diff changeset
   512
    <resource: #obsolete>
2228
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
   513
    "define the button-menu-press behavior; if true the line under the mouse
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
   514
     will be selected before the menu is opened. Otherwise the menu is opened
2821
ea7f6fdb8c95 Fix bas spelling Buttom -> Button
Stefan Vogel <sv@exept.de>
parents: 2815
diff changeset
   515
     on the current selection."
ea7f6fdb8c95 Fix bas spelling Buttom -> Button
Stefan Vogel <sv@exept.de>
parents: 2815
diff changeset
   516
3438
a8ce9823cc1e english
Claus Gittinger <cg@exept.de>
parents: 3391
diff changeset
   517
    self obsoleteMethodWarning:'use selectOnMenuButton:'.
a8ce9823cc1e english
Claus Gittinger <cg@exept.de>
parents: 3391
diff changeset
   518
    self selectOnMenuButton:aBoolean.
2228
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
   519
!
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
   520
3370
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
   521
selectOnButtonPress
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
   522
    "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
   523
    "
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
   524
    ^ selectOnButtonPress ? true
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
   525
!
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
   526
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
   527
selectOnButtonPress:aBoolean
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
   528
    "set/clear the selectOnButtonPress flag - 
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
   529
     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
   530
     behaviour until now.
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
   531
     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
   532
     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
   533
     drag and restored after the drop.
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
   534
    "
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
   535
    selectOnButtonPress := aBoolean
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
   536
!
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
   537
3438
a8ce9823cc1e english
Claus Gittinger <cg@exept.de>
parents: 3391
diff changeset
   538
selectOnMenuButton
a8ce9823cc1e english
Claus Gittinger <cg@exept.de>
parents: 3391
diff changeset
   539
    "define the button-menu-press behavior; if true the line under the mouse
a8ce9823cc1e english
Claus Gittinger <cg@exept.de>
parents: 3391
diff changeset
   540
     will be selected before the menu is opened. Otherwise the menu is opened
a8ce9823cc1e english
Claus Gittinger <cg@exept.de>
parents: 3391
diff changeset
   541
     on the current selection."
a8ce9823cc1e english
Claus Gittinger <cg@exept.de>
parents: 3391
diff changeset
   542
a8ce9823cc1e english
Claus Gittinger <cg@exept.de>
parents: 3391
diff changeset
   543
    ^ selectOnMenuButton
a8ce9823cc1e english
Claus Gittinger <cg@exept.de>
parents: 3391
diff changeset
   544
!
a8ce9823cc1e english
Claus Gittinger <cg@exept.de>
parents: 3391
diff changeset
   545
a8ce9823cc1e english
Claus Gittinger <cg@exept.de>
parents: 3391
diff changeset
   546
selectOnMenuButton:aBoolean
a8ce9823cc1e english
Claus Gittinger <cg@exept.de>
parents: 3391
diff changeset
   547
    "define the button-menu-press behavior; if true the line under the mouse
a8ce9823cc1e english
Claus Gittinger <cg@exept.de>
parents: 3391
diff changeset
   548
     will be selected before the menu is opened. Otherwise the menu is opened
a8ce9823cc1e english
Claus Gittinger <cg@exept.de>
parents: 3391
diff changeset
   549
     on the current selection."
a8ce9823cc1e english
Claus Gittinger <cg@exept.de>
parents: 3391
diff changeset
   550
a8ce9823cc1e english
Claus Gittinger <cg@exept.de>
parents: 3391
diff changeset
   551
    selectOnMenuButton := aBoolean.
a8ce9823cc1e english
Claus Gittinger <cg@exept.de>
parents: 3391
diff changeset
   552
!
a8ce9823cc1e english
Claus Gittinger <cg@exept.de>
parents: 3391
diff changeset
   553
1741
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   554
toggleSelect
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   555
    "get the toggleSelect flag - see method #toggleSelect: for more details
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   556
    "
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   557
    ^ toggleSelect
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   558
!
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   559
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   560
toggleSelect:aBoolean
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   561
    "turn on/off toggle select. If true, clicking on a selected entry
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   562
     unselects it and vice versa. The default is false, which means
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   563
     that clicking on an already selected entry does not change its
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   564
     select status (see also ignoreReselect:).
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   565
    "
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   566
    toggleSelect := aBoolean.
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   567
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   568
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   569
!
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   570
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   571
useIndex
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   572
    "set/clear the useIndex flag.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   573
     the selection writen to the model are the indices into the list
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   574
     or the elements selected.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   575
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   576
    ^ useIndex
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   577
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   578
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   579
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   580
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   581
useIndex:aBoolean
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   582
    "set/clear the useIndex flag.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   583
     the selection writen to the model are the indices into the list
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   584
     or the elements selected.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   585
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   586
    useIndex := aBoolean ? true
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   587
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   588
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   589
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   590
2404
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   591
!SelectionInListModelView methodsFor:'accessing-editor'!
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   592
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   593
closeEditor
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   594
    "close the current editor
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   595
    "
2596
771e23c6d9cf access actions by call and not by reference
ca
parents: 2572
diff changeset
   596
    |editor action|
2404
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   597
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   598
    (editor := editorView) notNil ifTrue:[
2856
d3a3253d3851 forget editor after it really did close itself.
Claus Gittinger <cg@exept.de>
parents: 2821
diff changeset
   599
"/        editorView := nil.
2596
771e23c6d9cf access actions by call and not by reference
ca
parents: 2572
diff changeset
   600
        action := self closeEditorAction.
771e23c6d9cf access actions by call and not by reference
ca
parents: 2572
diff changeset
   601
        action notNil ifTrue:[action value:editor.].
2404
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   602
        editor destroy.
2856
d3a3253d3851 forget editor after it really did close itself.
Claus Gittinger <cg@exept.de>
parents: 2821
diff changeset
   603
        editorView := nil.
2404
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   604
    ].
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   605
!
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   606
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   607
closeEditorAction
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   608
    "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
   609
     to the action is the editor.
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   610
    "
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   611
    ^ closeEditorAction
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   612
!
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   613
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   614
closeEditorAction:anOneArgAction
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   615
    "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
   616
     to the action is the editor.
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   617
    "
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   618
    closeEditorAction := anOneArgAction.
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   619
!
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   620
2527
a07a74ff7e3e add a hasOpenEditor selector
penk
parents: 2522
diff changeset
   621
hasOpenEditor
a07a74ff7e3e add a hasOpenEditor selector
penk
parents: 2522
diff changeset
   622
a07a74ff7e3e add a hasOpenEditor selector
penk
parents: 2522
diff changeset
   623
    ^ editorView notNil
a07a74ff7e3e add a hasOpenEditor selector
penk
parents: 2522
diff changeset
   624
!
a07a74ff7e3e add a hasOpenEditor selector
penk
parents: 2522
diff changeset
   625
2404
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   626
openEditor
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   627
    "opens the editor on the current selection;
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   628
     returns the editorView or nil if no openEditorAction is defined
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   629
     or no single selection exists ...
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   630
    "
2596
771e23c6d9cf access actions by call and not by reference
ca
parents: 2572
diff changeset
   631
    |lnNr action|
2404
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   632
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   633
    self closeEditor.
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   634
    shown ifFalse:[^ nil].
2596
771e23c6d9cf access actions by call and not by reference
ca
parents: 2572
diff changeset
   635
771e23c6d9cf access actions by call and not by reference
ca
parents: 2572
diff changeset
   636
    action := self openEditorAction.
771e23c6d9cf access actions by call and not by reference
ca
parents: 2572
diff changeset
   637
    action isNil ifTrue:[^ nil].
771e23c6d9cf access actions by call and not by reference
ca
parents: 2572
diff changeset
   638
2404
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   639
    lnNr := self selectedIndex.
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   640
    lnNr == 0 ifTrue:[^ nil].
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   641
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   642
    self makeSelectionVisible.
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   643
2596
771e23c6d9cf access actions by call and not by reference
ca
parents: 2572
diff changeset
   644
    editorView := action valueWithOptionalArgument:lnNr and:self.
2404
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   645
    editorView isNil ifTrue:[^ nil].
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
    editorView superView isNil ifTrue:[
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   648
        self addSubView:editorView
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   649
    ].
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   650
    self computeEditorLayout.
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   651
    editorView realize.
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   652
    self windowGroup focusView:editorView.
2416
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
   653
    ^ editorView
2404
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   654
!
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   655
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   656
openEditorAction
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   657
    "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
   658
     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
   659
    "
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   660
    ^ openEditorAction
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   661
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   662
!
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   663
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   664
openEditorAction:aTwoArgAction
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   665
    "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
   666
     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
   667
    "
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   668
    openEditorAction := aTwoArgAction.
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   669
! !
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2401
diff changeset
   670
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   671
!SelectionInListModelView methodsFor:'change & update'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   672
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   673
argForChangeMessage
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   674
    "return the argument for a selectionChange;
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   675
     depending on the setting of useIndex, this is either the numeric
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   676
     index of the selection or the value (i.e. the string)
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   677
    "
2409
68095c891ceb reuse selection methods (prepared for common controller)
ca
parents: 2408
diff changeset
   678
    useIndex         ifFalse:[ ^ self selectionValue ].
68095c891ceb reuse selection methods (prepared for common controller)
ca
parents: 2408
diff changeset
   679
    multipleSelectOk ifFalse:[ ^ selection ? 0 ].
68095c891ceb reuse selection methods (prepared for common controller)
ca
parents: 2408
diff changeset
   680
    ^ selection ? #()
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   681
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   682
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   683
contentsChanged
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   684
    super contentsChanged.
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   685
    self  computeEditorLayout.
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   686
!
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   687
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   688
lineChangedAt:aLnNr with:arg
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   689
    super lineChangedAt:aLnNr with:arg.
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   690
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   691
    (editorView notNil and:[aLnNr == self selectedIndex]) ifTrue:[
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   692
        self computeEditorLayout.
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   693
    ]
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   694
!
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   695
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   696
listSizeChanged:aLnNr nLines:aDeltaLines
1563
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   697
    |changed cnts|
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   698
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   699
    super listSizeChanged:aLnNr nLines:aDeltaLines.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   700
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   701
    selection isNil ifTrue:[^ self].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   702
2408
8b0d11537dc0 accessing list indirect
ca
parents: 2404
diff changeset
   703
    self size == 0 ifTrue:[
1563
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   704
        selection := nil.
2408
8b0d11537dc0 accessing list indirect
ca
parents: 2404
diff changeset
   705
        ^ self selectionChanged
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   706
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   707
1563
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   708
    multipleSelectOk ifFalse:[
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   709
        selection < aLnNr ifTrue:[^ self].
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   710
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   711
        selection := selection + aDeltaLines.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   712
1563
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   713
        (aDeltaLines < 0 and:[selection < aLnNr]) ifTrue:[
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   714
            selection := nil.
2408
8b0d11537dc0 accessing list indirect
ca
parents: 2404
diff changeset
   715
            ^ self selectionChanged
1563
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   716
        ]
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   717
    ] ifTrue:[
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   718
        changed := false.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   719
1563
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   720
        aDeltaLines < 0  ifFalse:[
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   721
            selection keysAndValuesDo:[:i :ln|
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   722
                ln >= aLnNr ifTrue:[
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   723
                    changed := true.
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   724
                    selection at:i put:(ln + aDeltaLines)
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   725
                ]
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   726
            ]
1563
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   727
        ] ifTrue:[
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   728
            cnts := 0.
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   729
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   730
            selection keysAndValuesDo:[:i :ln||new|
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   731
                ln >= aLnNr ifTrue:[
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   732
                    changed := true.
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   733
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   734
                    (new := ln + aDeltaLines) < aLnNr ifTrue:[
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   735
                        cnts := cnts + 1.
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   736
                        new  := nil
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   737
                    ].
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   738
                    selection at:i put:new
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   739
                ]
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   740
            ].
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   741
            cnts ~~ 0 ifTrue:[
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   742
                cnts == selection size ifTrue:[
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   743
                    selection := nil
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   744
                ] ifFalse:[
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   745
                    selection := selection select:[:ln| ln notNil]
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   746
                ].
2408
8b0d11537dc0 accessing list indirect
ca
parents: 2404
diff changeset
   747
                ^ self selectionChanged.
1563
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   748
            ].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   749
        ].
1563
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   750
        changed ifFalse:[^ self].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   751
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   752
1563
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   753
    (useIndex and:[model notNil]) ifTrue:[
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   754
        model setValue:(self argForChangeMessage)
f67940c89977 checkin from browser
ca
parents: 1561
diff changeset
   755
    ].
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
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   758
originChanged:delta
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   759
    "setup the origin of the editing view
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   760
    "
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   761
    self computeEditorLayout.
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   762
    super originChanged:delta.
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   763
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   764
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   765
!
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   766
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   767
selectionChanged
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   768
    "selection has changed. Call actionblock and/or send changeMessage if defined
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   769
    "
1554
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
   770
    |arg|
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   771
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   772
    self closeEditor.
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   773
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   774
    (model isNil and:[actionBlock isNil]) ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   775
        ^ self
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   776
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   777
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   778
    arg := self argForChangeMessage.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   779
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   780
    model notNil ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   781
        model removeDependent:self.
1741
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
   782
        "/ change models value to force a change notification: reselect mode
1758
d8d45bbbd3ba check whether model value differs from current selection.
ca
parents: 1755
diff changeset
   783
        arg = model value ifTrue:[
d8d45bbbd3ba check whether model value differs from current selection.
ca
parents: 1755
diff changeset
   784
            model setValue:(arg isNil ifTrue:[0] ifFalse:[nil]).
d8d45bbbd3ba check whether model value differs from current selection.
ca
parents: 1755
diff changeset
   785
        ].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   786
        self sendChangeMessage:#value: with:arg.
2225
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
   787
        model notNil ifTrue:[  "/ argggh could be nilled
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
   788
            model addDependent:self.
3391
eb009a36b8e4 must update from model, if removing myself from dependents
Claus Gittinger <cg@exept.de>
parents: 3389
diff changeset
   789
            self updateFromModel. "/ care for possibly lost change notification, due to #removeDependent
2225
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
   790
        ]
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   791
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   792
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   793
    actionBlock notNil ifTrue:[
2416
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
   794
        actionBlock valueWithOptionalArgument:arg and:self
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   795
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   796
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   797
1554
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
   798
updateFromModel
2302
5a2a1d5d09f8 remove asynchronous handling of changes; always disabled because doesn't work
ca
parents: 2275
diff changeset
   799
    "update selection from the model
5a2a1d5d09f8 remove asynchronous handling of changes; always disabled because doesn't work
ca
parents: 2275
diff changeset
   800
    "
2522
a3ddd460ea91 copy selection from model in #updateFromModel
james
parents: 2501
diff changeset
   801
    |value newSelection|
2302
5a2a1d5d09f8 remove asynchronous handling of changes; always disabled because doesn't work
ca
parents: 2275
diff changeset
   802
5a2a1d5d09f8 remove asynchronous handling of changes; always disabled because doesn't work
ca
parents: 2275
diff changeset
   803
    model isNil ifTrue:[
5a2a1d5d09f8 remove asynchronous handling of changes; always disabled because doesn't work
ca
parents: 2275
diff changeset
   804
        ^ self
5a2a1d5d09f8 remove asynchronous handling of changes; always disabled because doesn't work
ca
parents: 2275
diff changeset
   805
    ].
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
   806
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
   807
    buttonMotionAction notNil ifTrue:[
2302
5a2a1d5d09f8 remove asynchronous handling of changes; always disabled because doesn't work
ca
parents: 2275
diff changeset
   808
        "running in button motion; discard change notification
5a2a1d5d09f8 remove asynchronous handling of changes; always disabled because doesn't work
ca
parents: 2275
diff changeset
   809
        "
5a2a1d5d09f8 remove asynchronous handling of changes; always disabled because doesn't work
ca
parents: 2275
diff changeset
   810
        ^ self
5a2a1d5d09f8 remove asynchronous handling of changes; always disabled because doesn't work
ca
parents: 2275
diff changeset
   811
    ].
5a2a1d5d09f8 remove asynchronous handling of changes; always disabled because doesn't work
ca
parents: 2275
diff changeset
   812
5a2a1d5d09f8 remove asynchronous handling of changes; always disabled because doesn't work
ca
parents: 2275
diff changeset
   813
    value := model value.
5a2a1d5d09f8 remove asynchronous handling of changes; always disabled because doesn't work
ca
parents: 2275
diff changeset
   814
5a2a1d5d09f8 remove asynchronous handling of changes; always disabled because doesn't work
ca
parents: 2275
diff changeset
   815
    (useIndex or:[value isNil or:[value isNumber]]) ifFalse:[
5a2a1d5d09f8 remove asynchronous handling of changes; always disabled because doesn't work
ca
parents: 2275
diff changeset
   816
        multipleSelectOk ifFalse:[
2522
a3ddd460ea91 copy selection from model in #updateFromModel
james
parents: 2501
diff changeset
   817
            newSelection := self identityIndexOf:value
2302
5a2a1d5d09f8 remove asynchronous handling of changes; always disabled because doesn't work
ca
parents: 2275
diff changeset
   818
        ] ifTrue:[
2522
a3ddd460ea91 copy selection from model in #updateFromModel
james
parents: 2501
diff changeset
   819
            value size == 0 ifTrue:[
a3ddd460ea91 copy selection from model in #updateFromModel
james
parents: 2501
diff changeset
   820
                newSelection := nil
2302
5a2a1d5d09f8 remove asynchronous handling of changes; always disabled because doesn't work
ca
parents: 2275
diff changeset
   821
            ] ifFalse:[
2522
a3ddd460ea91 copy selection from model in #updateFromModel
james
parents: 2501
diff changeset
   822
                newSelection := OrderedCollection new.
a3ddd460ea91 copy selection from model in #updateFromModel
james
parents: 2501
diff changeset
   823
a3ddd460ea91 copy selection from model in #updateFromModel
james
parents: 2501
diff changeset
   824
                value do:[:e||index|
a3ddd460ea91 copy selection from model in #updateFromModel
james
parents: 2501
diff changeset
   825
                    index := self identityIndexOf:e.
a3ddd460ea91 copy selection from model in #updateFromModel
james
parents: 2501
diff changeset
   826
                    index ~~ 0 ifTrue:[ newSelection add:index ].
a3ddd460ea91 copy selection from model in #updateFromModel
james
parents: 2501
diff changeset
   827
                ].
a3ddd460ea91 copy selection from model in #updateFromModel
james
parents: 2501
diff changeset
   828
a3ddd460ea91 copy selection from model in #updateFromModel
james
parents: 2501
diff changeset
   829
                newSelection isEmpty ifTrue:[
a3ddd460ea91 copy selection from model in #updateFromModel
james
parents: 2501
diff changeset
   830
                    newSelection := nil
a3ddd460ea91 copy selection from model in #updateFromModel
james
parents: 2501
diff changeset
   831
                ].
2302
5a2a1d5d09f8 remove asynchronous handling of changes; always disabled because doesn't work
ca
parents: 2275
diff changeset
   832
            ]
5a2a1d5d09f8 remove asynchronous handling of changes; always disabled because doesn't work
ca
parents: 2275
diff changeset
   833
        ].
2522
a3ddd460ea91 copy selection from model in #updateFromModel
james
parents: 2501
diff changeset
   834
    ] ifTrue:[
a3ddd460ea91 copy selection from model in #updateFromModel
james
parents: 2501
diff changeset
   835
        newSelection := value copy
2302
5a2a1d5d09f8 remove asynchronous handling of changes; always disabled because doesn't work
ca
parents: 2275
diff changeset
   836
    ].
2522
a3ddd460ea91 copy selection from model in #updateFromModel
james
parents: 2501
diff changeset
   837
    self setSelection:newSelection.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   838
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   839
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   840
!SelectionInListModelView methodsFor:'drag & drop'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   841
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   842
canDrag
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   843
    "returns true if dragging is enabled
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   844
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   845
    ^ dropSource notNil
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   846
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   847
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   848
2572
e370dbc5fbcb support autoScroll during drag operation
ca
parents: 2527
diff changeset
   849
dragAutoScroll:aContext
e370dbc5fbcb support autoScroll during drag operation
ca
parents: 2527
diff changeset
   850
    "called by the DragAndDropManager to scroll during a drag/drop operation
e370dbc5fbcb support autoScroll during drag operation
ca
parents: 2527
diff changeset
   851
     if necassery (decided by the widget itself); If a scroll is done return
e370dbc5fbcb support autoScroll during drag operation
ca
parents: 2527
diff changeset
   852
     true otherwise false (used to restore the background)
e370dbc5fbcb support autoScroll during drag operation
ca
parents: 2527
diff changeset
   853
    "
e370dbc5fbcb support autoScroll during drag operation
ca
parents: 2527
diff changeset
   854
    |visibleY yOrigin inset|
e370dbc5fbcb support autoScroll during drag operation
ca
parents: 2527
diff changeset
   855
e370dbc5fbcb support autoScroll during drag operation
ca
parents: 2527
diff changeset
   856
    visibleY := aContext targetPoint y.
e370dbc5fbcb support autoScroll during drag operation
ca
parents: 2527
diff changeset
   857
    yOrigin  := self yOriginOfContents.
e370dbc5fbcb support autoScroll during drag operation
ca
parents: 2527
diff changeset
   858
    inset    := 15 + margin.
e370dbc5fbcb support autoScroll during drag operation
ca
parents: 2527
diff changeset
   859
e370dbc5fbcb support autoScroll during drag operation
ca
parents: 2527
diff changeset
   860
    visibleY <= inset ifTrue:[
e370dbc5fbcb support autoScroll during drag operation
ca
parents: 2527
diff changeset
   861
        self yOriginOfContents == 0 ifTrue:[ ^ false ].
e370dbc5fbcb support autoScroll during drag operation
ca
parents: 2527
diff changeset
   862
    ] ifFalse:[
e370dbc5fbcb support autoScroll during drag operation
ca
parents: 2527
diff changeset
   863
        visibleY < (self height - inset) ifTrue:[ ^ false ].
e370dbc5fbcb support autoScroll during drag operation
ca
parents: 2527
diff changeset
   864
        self yOriginOfContents < self maxViewOriginY ifFalse:[ ^ false ].
e370dbc5fbcb support autoScroll during drag operation
ca
parents: 2527
diff changeset
   865
    ].
e370dbc5fbcb support autoScroll during drag operation
ca
parents: 2527
diff changeset
   866
e370dbc5fbcb support autoScroll during drag operation
ca
parents: 2527
diff changeset
   867
    aContext contentsWillChange.
e370dbc5fbcb support autoScroll during drag operation
ca
parents: 2527
diff changeset
   868
e370dbc5fbcb support autoScroll during drag operation
ca
parents: 2527
diff changeset
   869
    visibleY <= inset ifTrue:[ self scrollUp:inset ]
e370dbc5fbcb support autoScroll during drag operation
ca
parents: 2527
diff changeset
   870
                     ifFalse:[ self scrollDown:inset ].
e370dbc5fbcb support autoScroll during drag operation
ca
parents: 2527
diff changeset
   871
e370dbc5fbcb support autoScroll during drag operation
ca
parents: 2527
diff changeset
   872
    ^ true
e370dbc5fbcb support autoScroll during drag operation
ca
parents: 2527
diff changeset
   873
!
e370dbc5fbcb support autoScroll during drag operation
ca
parents: 2527
diff changeset
   874
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   875
dropSource
2891
78a14c0ed73c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2886
diff changeset
   876
    "returns the dropSource or nil"
78a14c0ed73c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2886
diff changeset
   877
    
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   878
    ^ dropSource
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   879
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   880
2891
78a14c0ed73c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2886
diff changeset
   881
dropSource:aDropSourceOrNil 
78a14c0ed73c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2886
diff changeset
   882
    "set the dropSource or nil"
78a14c0ed73c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2886
diff changeset
   883
    
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   884
    dropSource := aDropSourceOrNil.
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
startDragAt:aPoint
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   888
    "start drag at a point
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   889
    "
2976
136d983423ab drag & drop activation if moving horizontal n pixels
ca
parents: 2964
diff changeset
   890
    buttonMotionAction := buttonReleaseAction := nil.
136d983423ab drag & drop activation if moving horizontal n pixels
ca
parents: 2964
diff changeset
   891
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   892
    dropSource notNil ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   893
        dropSource startDragSelector notNil ifTrue:[
3370
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
   894
            ^ dropSource startDragIn:self at:aPoint
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   895
        ] ifFalse:[
3370
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
   896
            ^ DragAndDropManager new startDragFrom:self
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   897
                                      dropSource:dropSource
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   898
                                          offset:#center
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   899
        ]
3370
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
   900
    ].
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
   901
^ nil
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   902
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   903
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   904
!SelectionInListModelView methodsFor:'drawing'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   905
2642
27174081058f move methods to super class; prepared for table
ca
parents: 2641
diff changeset
   906
drawElementsFrom:start to:stop x:x y:y w:w
27174081058f move methods to super class; prepared for table
ca
parents: 2641
diff changeset
   907
    "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
   908
    "
27174081058f move methods to super class; prepared for table
ca
parents: 2641
diff changeset
   909
    |y0 "{ Class:SmallInteger }"
27174081058f move methods to super class; prepared for table
ca
parents: 2641
diff changeset
   910
     y1 "{ Class:SmallInteger }"
27174081058f move methods to super class; prepared for table
ca
parents: 2641
diff changeset
   911
     x0 "{ Class:SmallInteger }"
27174081058f move methods to super class; prepared for table
ca
parents: 2641
diff changeset
   912
    |
27174081058f move methods to super class; prepared for table
ca
parents: 2641
diff changeset
   913
    x0 := textStartLeft - viewOrigin x.
27174081058f move methods to super class; prepared for table
ca
parents: 2641
diff changeset
   914
    y1 := y.
27174081058f move methods to super class; prepared for table
ca
parents: 2641
diff changeset
   915
27174081058f move methods to super class; prepared for table
ca
parents: 2641
diff changeset
   916
    start to:stop do:[:i|
27174081058f move methods to super class; prepared for table
ca
parents: 2641
diff changeset
   917
        y0 := y1.
27174081058f move methods to super class; prepared for table
ca
parents: 2641
diff changeset
   918
        y1 := self yVisibleOfLine:(i + 1).
27174081058f move methods to super class; prepared for table
ca
parents: 2641
diff changeset
   919
        self drawLabelAt:i x:x0 y:y0 h:(y1 - y0)
27174081058f move methods to super class; prepared for table
ca
parents: 2641
diff changeset
   920
    ].
27174081058f move methods to super class; prepared for table
ca
parents: 2641
diff changeset
   921
27174081058f move methods to super class; prepared for table
ca
parents: 2641
diff changeset
   922
27174081058f move methods to super class; prepared for table
ca
parents: 2641
diff changeset
   923
!
27174081058f move methods to super class; prepared for table
ca
parents: 2641
diff changeset
   924
1533
609fce5df829 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1508
diff changeset
   925
drawFrom:start to:stop x:x y:y w:w
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   926
    "draw the lines between start to stop without clearing the background
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   927
    "
1557
e3feb8bc17b0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1554
diff changeset
   928
    highlightMode notNil ifTrue:[
e3feb8bc17b0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1554
diff changeset
   929
        self selectionDo:[:lnNr|
e3feb8bc17b0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1554
diff changeset
   930
            (lnNr between:start and:stop) ifTrue:[
e3feb8bc17b0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1554
diff changeset
   931
                self drawSelectionFrameAt:lnNr x:x w:w
e3feb8bc17b0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1554
diff changeset
   932
            ]
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   933
        ]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   934
    ].
2642
27174081058f move methods to super class; prepared for table
ca
parents: 2641
diff changeset
   935
    super drawFrom:start to:stop x:x y:y w:w.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   936
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   937
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
   938
drawLabelAt:anIndex x:xI y:y h:h
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   939
    "draw the label at position x/y without clearing the background
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   940
    "
2418
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   941
    |item y0 x1 x w drawStrikeOut xOut0 xOut1|
1554
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
   942
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
   943
    x := xI + 1.
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   944
    editorView notNil ifTrue:[
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   945
        "/ there is an open editor for the line; thus no redraw for the label (hidden by editor)
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   946
        self selectedIndex == anIndex ifTrue:[^ self].
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   947
    ].
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
   948
2408
8b0d11537dc0 accessing list indirect
ca
parents: 2404
diff changeset
   949
    item := self at:anIndex ifAbsent:nil.
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
   950
    item isNil ifTrue:[^ self].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   951
2418
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   952
    drawStrikeOut := false.
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   953
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
   954
    (highlightMode notNil and:[self isInSelection:anIndex]) ifTrue:[
2418
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   955
        strikeOut ifTrue:[
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   956
            drawStrikeOut := true.
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   957
            self paint:fgColor on:bgColor
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   958
        ] ifFalse:[
3367
29f38ac1bac1 support highlightMode (selection) #dropMode
ca
parents: 3345
diff changeset
   959
            (highlightMode == #dropMode or:[self hasFocus not]) ifTrue:[
29f38ac1bac1 support highlightMode (selection) #dropMode
ca
parents: 3345
diff changeset
   960
                self paint:hilightFgColorNoFocus on:hilightBgColorNoFocus.
29f38ac1bac1 support highlightMode (selection) #dropMode
ca
parents: 3345
diff changeset
   961
            ] ifFalse:[
3137
7e8fae56b94c highlight selection dependent on has focus
ca
parents: 3081
diff changeset
   962
                self paint:hilightFgColor on:hilightBgColor
7e8fae56b94c highlight selection dependent on has focus
ca
parents: 3081
diff changeset
   963
            ].
2418
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   964
        ]
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
   965
    ] ifFalse:[
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
   966
        enterItem == item ifTrue:[
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
   967
            self paint:hilightBgColor on:bgColor.
1557
e3feb8bc17b0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1554
diff changeset
   968
        ] ifFalse:[
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
   969
            self paint:fgColor on:bgColor.
1557
e3feb8bc17b0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1554
diff changeset
   970
        ].
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
   971
    ].
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
   972
    renderer display:item atX:x y:y lineHeight:h.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   973
2418
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   974
    drawStrikeOut ifTrue:[
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   975
        xOut0 := self xVisibleOfItem:item.
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   976
        highlightMode == #label ifTrue:[
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   977
            xOut1 := xOut0 + (renderer widthFor:item).
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   978
        ] ifFalse:[
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   979
            xOut1 := width - margin.
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   980
        ].
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   981
        y0 := y + (h // 2).
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   982
        self displayLineFromX:xOut0 y:y0 toX:xOut1 y:y0.
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   983
        y0 := y0 - 1.
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   984
        self displayLineFromX:xOut0 y:y0 toX:xOut1 y:y0.
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   985
    ].
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
   986
3338
01ad784543fc no underline-highlighting
Claus Gittinger <cg@exept.de>
parents: 3275
diff changeset
   987
    cursorItem == item ifTrue:[
01ad784543fc no underline-highlighting
Claus Gittinger <cg@exept.de>
parents: 3275
diff changeset
   988
        "/ textStartLeft
01ad784543fc no underline-highlighting
Claus Gittinger <cg@exept.de>
parents: 3275
diff changeset
   989
        self setMaskOrigin:((self viewOrigin + (0 @ 1)) \\ (lineMask extent)).
01ad784543fc no underline-highlighting
Claus Gittinger <cg@exept.de>
parents: 3275
diff changeset
   990
        self mask:lineMask.
01ad784543fc no underline-highlighting
Claus Gittinger <cg@exept.de>
parents: 3275
diff changeset
   991
        w := renderer widthFor:item.
01ad784543fc no underline-highlighting
Claus Gittinger <cg@exept.de>
parents: 3275
diff changeset
   992
        self displayRectangleX:x -1 y:(y+2) width:w+2 height:(h - 4).
01ad784543fc no underline-highlighting
Claus Gittinger <cg@exept.de>
parents: 3275
diff changeset
   993
        self mask:nil.
01ad784543fc no underline-highlighting
Claus Gittinger <cg@exept.de>
parents: 3275
diff changeset
   994
    ] ifFalse:[
2323
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
   995
        enterItem == item ifTrue:[
3338
01ad784543fc no underline-highlighting
Claus Gittinger <cg@exept.de>
parents: 3275
diff changeset
   996
            self highlightWithUnderline ifTrue:[
01ad784543fc no underline-highlighting
Claus Gittinger <cg@exept.de>
parents: 3275
diff changeset
   997
                "/ underline the hilite...
01ad784543fc no underline-highlighting
Claus Gittinger <cg@exept.de>
parents: 3275
diff changeset
   998
                y0 := y + h - 2.
01ad784543fc no underline-highlighting
Claus Gittinger <cg@exept.de>
parents: 3275
diff changeset
   999
                x1 := x + (renderer widthFor:item).
01ad784543fc no underline-highlighting
Claus Gittinger <cg@exept.de>
parents: 3275
diff changeset
  1000
01ad784543fc no underline-highlighting
Claus Gittinger <cg@exept.de>
parents: 3275
diff changeset
  1001
                self displayLineFromX:x y:y0 toX:x1 y:y0.
01ad784543fc no underline-highlighting
Claus Gittinger <cg@exept.de>
parents: 3275
diff changeset
  1002
            ]
2323
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
  1003
        ].
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1004
    ].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1005
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1006
1554
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1007
drawSelectionFrameAt:lnNr x:x w:w
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1008
    "draw the background and foreground of the selection frame
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1009
     at a lineNr.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1010
    "
2646
8be2becc5152 drawSelectionFrameAt:.. clear damaged background not items background
ca
parents: 2644
diff changeset
  1011
    |item xMax xLftDmg xRgtDmg x0 x1 y0 y1 hL wL|
8be2becc5152 drawSelectionFrameAt:.. clear damaged background not items background
ca
parents: 2644
diff changeset
  1012
8be2becc5152 drawSelectionFrameAt:.. clear damaged background not items background
ca
parents: 2644
diff changeset
  1013
    (strikeOut or:[highlightMode isNil]) ifTrue:[
8be2becc5152 drawSelectionFrameAt:.. clear damaged background not items background
ca
parents: 2644
diff changeset
  1014
        ^ self
8be2becc5152 drawSelectionFrameAt:.. clear damaged background not items background
ca
parents: 2644
diff changeset
  1015
    ].
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  1016
    editorView notNil ifTrue:[
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  1017
        "/ there is an open editor; do not redraw selected
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  1018
        ^ self
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  1019
    ].
3367
29f38ac1bac1 support highlightMode (selection) #dropMode
ca
parents: 3345
diff changeset
  1020
29f38ac1bac1 support highlightMode (selection) #dropMode
ca
parents: 3345
diff changeset
  1021
    (    highlightMode == #line
29f38ac1bac1 support highlightMode (selection) #dropMode
ca
parents: 3345
diff changeset
  1022
     or:[highlightMode == #label
29f38ac1bac1 support highlightMode (selection) #dropMode
ca
parents: 3345
diff changeset
  1023
     or:[highlightMode == #dropMode]]
29f38ac1bac1 support highlightMode (selection) #dropMode
ca
parents: 3345
diff changeset
  1024
    ) ifFalse:[
2646
8be2becc5152 drawSelectionFrameAt:.. clear damaged background not items background
ca
parents: 2644
diff changeset
  1025
        "/ highlightMode not supported
8be2becc5152 drawSelectionFrameAt:.. clear damaged background not items background
ca
parents: 2644
diff changeset
  1026
        ^ self
8be2becc5152 drawSelectionFrameAt:.. clear damaged background not items background
ca
parents: 2644
diff changeset
  1027
    ].
2408
8b0d11537dc0 accessing list indirect
ca
parents: 2404
diff changeset
  1028
    (item := self at:lnNr ifAbsent:nil) isNil ifTrue:[
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  1029
        "/ list might change during drawing; item no longer visible
1554
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1030
        ^ self
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1031
    ].
2646
8be2becc5152 drawSelectionFrameAt:.. clear damaged background not items background
ca
parents: 2644
diff changeset
  1032
    xMax := x + w.
1554
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1033
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1034
    "/ CLEAR THE BACKGROUND
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1035
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1036
    y0 := self yVisibleOfLine:lnNr.
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1037
    y1 := self yVisibleOfLine:(lnNr + 1).
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1038
    hL := y1 - y0.
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1039
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1040
    highlightMode == #line ifTrue:[
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1041
        x0 := x.
2646
8be2becc5152 drawSelectionFrameAt:.. clear damaged background not items background
ca
parents: 2644
diff changeset
  1042
        x1 := xMax.
3367
29f38ac1bac1 support highlightMode (selection) #dropMode
ca
parents: 3345
diff changeset
  1043
    ] ifFalse:[ "/ is #label or #rectangle
1554
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1044
        x0 := (self xVisibleOfItem:item) - (textStartLeft // 2).
2646
8be2becc5152 drawSelectionFrameAt:.. clear damaged background not items background
ca
parents: 2644
diff changeset
  1045
        x0 >= xMax ifTrue:[ ^ self ].
8be2becc5152 drawSelectionFrameAt:.. clear damaged background not items background
ca
parents: 2644
diff changeset
  1046
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1047
        x1 := x0 + (renderer widthFor:item) + textStartLeft + 1.
2646
8be2becc5152 drawSelectionFrameAt:.. clear damaged background not items background
ca
parents: 2644
diff changeset
  1048
        x1 < x ifTrue:[ ^ self ].
1554
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1049
    ].
2646
8be2becc5152 drawSelectionFrameAt:.. clear damaged background not items background
ca
parents: 2644
diff changeset
  1050
    xLftDmg := x0 max:x.
8be2becc5152 drawSelectionFrameAt:.. clear damaged background not items background
ca
parents: 2644
diff changeset
  1051
    xRgtDmg := x1 min:xMax.
8be2becc5152 drawSelectionFrameAt:.. clear damaged background not items background
ca
parents: 2644
diff changeset
  1052
    xRgtDmg > xLftDmg ifFalse:[^ self].
1554
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1053
3367
29f38ac1bac1 support highlightMode (selection) #dropMode
ca
parents: 3345
diff changeset
  1054
    (highlightMode == #dropMode or:[self hasFocus not]) ifTrue:[
3137
7e8fae56b94c highlight selection dependent on has focus
ca
parents: 3081
diff changeset
  1055
        self paint:hilightBgColorNoFocus.
3367
29f38ac1bac1 support highlightMode (selection) #dropMode
ca
parents: 3345
diff changeset
  1056
    ] ifFalse:[
3137
7e8fae56b94c highlight selection dependent on has focus
ca
parents: 3081
diff changeset
  1057
        self paint:hilightBgColor.
7e8fae56b94c highlight selection dependent on has focus
ca
parents: 3081
diff changeset
  1058
    ].
2646
8be2becc5152 drawSelectionFrameAt:.. clear damaged background not items background
ca
parents: 2644
diff changeset
  1059
    self fillRectangleX:xLftDmg y:y0 width:(xRgtDmg - xLftDmg) height:hL.
8be2becc5152 drawSelectionFrameAt:.. clear damaged background not items background
ca
parents: 2644
diff changeset
  1060
    wL := x1 - x0.
1554
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1061
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1062
    "/ DRAW THE FRAME
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1063
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1064
    hilightFrameColor notNil ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1065
        hilightLevel == 0 ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1066
            self paint:hilightFrameColor.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1067
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1068
            highlightMode == #line ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1069
                self displayLineFromX:x0 y:y0 toX:x1 y:y0.
1554
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1070
                y1 := y0 + hL - 1.
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1071
                self displayLineFromX:x0 y:y1 toX:x1 y:y1.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1072
            ] ifFalse:[
1554
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1073
                self displayRectangleX:x0 y:y0 width:wL height:hL
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1074
            ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1075
            ^ self.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1076
        ]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1077
    ] ifFalse:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1078
        hilightStyle == #motif ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1079
            self paint:bgColor.
1554
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1080
            y1 := y0 + 1.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1081
            highlightMode == #line ifTrue:[
1554
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1082
                self displayLineFromX:x0 y:y1 toX:x1 y:y1.
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1083
                y1 := y0 + hL - 2.
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1084
                self displayLineFromX:x0 y:y1 toX:x1 y:y1.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1085
            ] ifFalse:[
1554
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  1086
                self displayRectangleX:x0 + 1 y:y1 width:wL - 2 height:hL - 2
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1087
            ]
2646
8be2becc5152 drawSelectionFrameAt:.. clear damaged background not items background
ca
parents: 2644
diff changeset
  1088
        ].
8be2becc5152 drawSelectionFrameAt:.. clear damaged background not items background
ca
parents: 2644
diff changeset
  1089
        hilightLevel == 0 ifTrue:[ ^ self ].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1090
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1091
2646
8be2becc5152 drawSelectionFrameAt:.. clear damaged background not items background
ca
parents: 2644
diff changeset
  1092
    "/ draw edge
8be2becc5152 drawSelectionFrameAt:.. clear damaged background not items background
ca
parents: 2644
diff changeset
  1093
    highlightMode == #line ifTrue:[
8be2becc5152 drawSelectionFrameAt:.. clear damaged background not items background
ca
parents: 2644
diff changeset
  1094
        x0 := margin.
8be2becc5152 drawSelectionFrameAt:.. clear damaged background not items background
ca
parents: 2644
diff changeset
  1095
        wL := width - x0 - x0.
8be2becc5152 drawSelectionFrameAt:.. clear damaged background not items background
ca
parents: 2644
diff changeset
  1096
    ].
8be2becc5152 drawSelectionFrameAt:.. clear damaged background not items background
ca
parents: 2644
diff changeset
  1097
    self drawEdgesForX:x0 y:y0 width:wL height:hL level:hilightLevel.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1098
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1099
2418
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1100
invalidateSelection
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1101
    "invalidate the current selection
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1102
    "
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1103
    shown ifTrue:[
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1104
        self selectionDo:[:aLnNr|
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1105
            self invalidateLineAt:aLnNr
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1106
        ].
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1107
    ].
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1108
!
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1109
2245
546c6e5d0951 change #redrawSelectionAt: to #invalidateSelectionAt: (because is a invalidate)
ca
parents: 2228
diff changeset
  1110
invalidateSelectionAt:aLineNr
1569
447b0cafc1db drawing selected or unselected
ca
parents: 1564
diff changeset
  1111
    "redraw a line which changed its selection status.
447b0cafc1db drawing selected or unselected
ca
parents: 1564
diff changeset
  1112
     optimized when drawing only the label.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1113
    "
2323
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
  1114
    |item x|
1569
447b0cafc1db drawing selected or unselected
ca
parents: 1564
diff changeset
  1115
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  1116
    editorView notNil ifTrue:[
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  1117
        "/ there is an open editor; do not redraw selected
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  1118
        ^ self
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  1119
    ].
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  1120
1569
447b0cafc1db drawing selected or unselected
ca
parents: 1564
diff changeset
  1121
    (shown and:[aLineNr notNil and:[highlightMode notNil]]) ifFalse:[
447b0cafc1db drawing selected or unselected
ca
parents: 1564
diff changeset
  1122
        ^ self
1557
e3feb8bc17b0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1554
diff changeset
  1123
    ].
e3feb8bc17b0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1554
diff changeset
  1124
2323
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
  1125
    highlightMode == #label ifTrue:[
2408
8b0d11537dc0 accessing list indirect
ca
parents: 2404
diff changeset
  1126
        item := self at:aLineNr ifAbsent:nil.
1569
447b0cafc1db drawing selected or unselected
ca
parents: 1564
diff changeset
  1127
2323
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
  1128
        item isNil ifTrue:[
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
  1129
            ^ self
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
  1130
        ].
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
  1131
        x := (self xVisibleOfItem:item) - (textStartLeft // 2)
1569
447b0cafc1db drawing selected or unselected
ca
parents: 1564
diff changeset
  1132
    ] ifFalse:[
2323
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
  1133
        x := 0.
1569
447b0cafc1db drawing selected or unselected
ca
parents: 1564
diff changeset
  1134
    ].
2323
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
  1135
    self invalidateLineAt:aLineNr fromX:x
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1136
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1137
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1138
!SelectionInListModelView methodsFor:'event handling'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1139
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1140
buttonControlPressAtLine:lineNr x:x y:y
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1141
    "handle a button control press
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1142
    "
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1143
    |isInSelection prvLine chgSet doAdd|
1747
f46c5941c028 better alghorithm for button motion in multipleSelection mode
ca
parents: 1745
diff changeset
  1144
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1145
    isInSelection := self isInSelection:lineNr.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1146
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1147
    multipleSelectOk ifFalse:[
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1148
        isInSelection ifTrue:[
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1149
            self deselect
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1150
        ]ifFalse:[
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1151
            (self canSelectIndex:lineNr forAdd:false) ifTrue:[
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1152
                self buttonPressOrReleaseAtLine:lineNr x:x y:y.
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1153
            ].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1154
        ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1155
        ^ self
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1156
    ].
2410
39ec0844e7d6 discard #toggleSelection:
ca
parents: 2409
diff changeset
  1157
    isInSelection ifTrue:[
39ec0844e7d6 discard #toggleSelection:
ca
parents: 2409
diff changeset
  1158
        self removeFromSelection:lineNr
39ec0844e7d6 discard #toggleSelection:
ca
parents: 2409
diff changeset
  1159
    ] ifFalse:[
39ec0844e7d6 discard #toggleSelection:
ca
parents: 2409
diff changeset
  1160
        self addToSelection:lineNr.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1161
2410
39ec0844e7d6 discard #toggleSelection:
ca
parents: 2409
diff changeset
  1162
        (self isInSelection:lineNr) ifFalse:[
39ec0844e7d6 discard #toggleSelection:
ca
parents: 2409
diff changeset
  1163
            "/ cannot add to selection
39ec0844e7d6 discard #toggleSelection:
ca
parents: 2409
diff changeset
  1164
            ^ self
39ec0844e7d6 discard #toggleSelection:
ca
parents: 2409
diff changeset
  1165
        ].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1166
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1167
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1168
    prvLine := lineNr.
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1169
    chgSet  := IdentitySet new.
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1170
    doAdd   := isInSelection not.
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1171
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1172
    buttonMotionAction := [:p| |rowNr mustRestore step f|
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1173
        rowNr := self yVisibleToLineNr:(p y).
1747
f46c5941c028 better alghorithm for button motion in multipleSelection mode
ca
parents: 1745
diff changeset
  1174
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1175
        (rowNr notNil and:[rowNr ~~ prvLine]) ifTrue:[
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1176
            rowNr == lineNr ifTrue:[
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1177
                mustRestore := true
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1178
            ] ifFalse:[
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1179
                rowNr > lineNr ifTrue:[ mustRestore := (rowNr < prvLine) ]
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1180
                              ifFalse:[ mustRestore := (rowNr > prvLine) ].
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1181
            ].
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1182
            prvLine > rowNr ifTrue:[ step := -1 ]
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1183
                          ifFalse:[ step :=  1 ].
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1184
            mustRestore ifTrue:[
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1185
                [ prvLine ~~ rowNr ] whileTrue:[
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1186
                    (chgSet removeIdentical:prvLine ifAbsent:nil) notNil ifTrue:[
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1187
                        doAdd ifFalse:[ self addToSelection:prvLine ]
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1188
                               ifTrue:[ self removeFromSelection:prvLine ].
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1189
                    ].
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1190
                    prvLine := prvLine + step.
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1191
                ].
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1192
            ] ifFalse:[
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1193
                [ prvLine ~~ rowNr ] whileTrue:[
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1194
                    prvLine := prvLine + step.
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1195
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1196
                    doAdd ~~ (self isInSelection:rowNr) ifTrue:[
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1197
                        chgSet add:prvLine.
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1198
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1199
                        doAdd ifTrue:[ self addToSelection:prvLine ]
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1200
                             ifFalse:[ self removeFromSelection:prvLine ].
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1201
                    ]
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1202
                ].
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1203
            ].
1748
0a2213a15e06 support of auto scrolling
ca
parents: 1747
diff changeset
  1204
        ].
0a2213a15e06 support of auto scrolling
ca
parents: 1747
diff changeset
  1205
    ].
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1206
!
1748
0a2213a15e06 support of auto scrolling
ca
parents: 1747
diff changeset
  1207
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1208
buttonMotion:buttonMask x:x y:y
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1209
    "mouse-move while button was pressed - handle selection changes
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1210
    "
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1211
    |lnNr item|
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1212
1748
0a2213a15e06 support of auto scrolling
ca
parents: 1747
diff changeset
  1213
    self stopAutoScroll.
0a2213a15e06 support of auto scrolling
ca
parents: 1747
diff changeset
  1214
2441
9ca40d634ff8 attention - do no motionAction, if no button is pressed
Claus Gittinger <cg@exept.de>
parents: 2418
diff changeset
  1215
    (buttonMask ~~ 0 and:[buttonMotionAction notNil]) ifTrue:[
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1216
        buttonMotionAction value:(x@y).
1747
f46c5941c028 better alghorithm for button motion in multipleSelection mode
ca
parents: 1745
diff changeset
  1217
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1218
        (autoScroll and:[buttonMotionAction notNil]) ifTrue:[
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1219
            "/ if moved outside of view, start autoscroll
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1220
            (y between:0 and:height) ifFalse:[
2670
27dacfff1d6d autoScroll: let timedBlock push an event which performs the scroll
Claus Gittinger <cg@exept.de>
parents: 2646
diff changeset
  1221
                y < 0 ifTrue:[ self startAutoScroll:#scrollUp distance:y ]
27dacfff1d6d autoScroll: let timedBlock push an event which performs the scroll
Claus Gittinger <cg@exept.de>
parents: 2646
diff changeset
  1222
                     ifFalse:[ self startAutoScroll:#scrollDown distance:(y - height) ].
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1223
            ].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1224
        ].
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1225
        ^ self
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1226
    ].
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1227
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1228
    (enabled and:[highlightEnterItem]) ifTrue:[
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1229
        self sensor anyButtonPressed ifFalse:[
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1230
            lnNr := self yVisibleToLineNr:y.
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1231
2408
8b0d11537dc0 accessing list indirect
ca
parents: 2404
diff changeset
  1232
            lnNr notNil ifTrue:[ item := self at:lnNr ifAbsent:nil ]
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1233
                       ifFalse:[ item := nil ].
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1234
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1235
            self pointerEntersItem:item.
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1236
        ]
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1237
    ].    
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1238
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1239
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1240
buttonMultiPress:button x:x y:y
2948
9b7b7b2e0dcd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2947
diff changeset
  1241
    "button was pressed multiple - handle a doubleClick action"
9b7b7b2e0dcd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2947
diff changeset
  1242
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1243
    buttonMotionAction := buttonReleaseAction := nil.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1244
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1245
    enabled ifFalse:[^ self].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1246
2948
9b7b7b2e0dcd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2947
diff changeset
  1247
    ((button == 1) or:[button == #select]) ifTrue:[
9b7b7b2e0dcd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2947
diff changeset
  1248
        doubleClickActionBlock notNil ifTrue:[
9b7b7b2e0dcd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2947
diff changeset
  1249
            self doubleClicked.
9b7b7b2e0dcd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2947
diff changeset
  1250
            ^ self.
9b7b7b2e0dcd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2947
diff changeset
  1251
        ].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1252
    ].
2947
caa98c08d3cf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2920
diff changeset
  1253
2948
9b7b7b2e0dcd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2947
diff changeset
  1254
    super buttonMultiPress:button x:x y:y
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1255
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1256
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1257
buttonPress:button x:x y:y
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1258
    "a button was pressed - handle selection here
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1259
    "
3146
b7294baadfb7 button press, move and release behaviour
ca
parents: 3137
diff changeset
  1260
    |sensor item menu appl isSelected lineNr startLine dragDistance|
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1261
3205
7ff2e20b37d4 *** empty log message ***
ca
parents: 3202
diff changeset
  1262
    modelChangedDuringButtonPress := buttonMotionAction := buttonReleaseAction := nil.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1263
2323
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
  1264
    self pointerEntersItem:nil.
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1265
    self cursorEntersItem:nil.
2361
c0e70e31ac28 close editor if button is pressed not in the editView
ca
parents: 2352
diff changeset
  1266
    self closeEditor.        
2323
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
  1267
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1268
    enabled ifFalse:[^ self].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1269
2228
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
  1270
    sensor := self sensor.
2399
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  1271
    lineNr := self yVisibleToLineNr:y.
2228
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
  1272
3385
e0f240ed0824 changed #buttonPress:x:y: selectOnButtonMenu behaviour
ca
parents: 3381
diff changeset
  1273
    ((button == 2) or:[button == #menu]) ifTrue:[
3438
a8ce9823cc1e english
Claus Gittinger <cg@exept.de>
parents: 3391
diff changeset
  1274
        (selectOnMenuButton and:[self numberOfSelections <= 1]) ifTrue:[
2228
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
  1275
            (     lineNr notNil
3380
d1290de3de27 selectOnButtonMenu - start menu also on already selected elements (until now only
ab
parents: 3370
diff changeset
  1276
             and:[self canSelectIndex:lineNr forAdd:false ]
2228
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
  1277
            ) ifTrue:[
3380
d1290de3de27 selectOnButtonMenu - start menu also on already selected elements (until now only
ab
parents: 3370
diff changeset
  1278
                (lineNr ~~ self selectedIndex) ifTrue: [
d1290de3de27 selectOnButtonMenu - start menu also on already selected elements (until now only
ab
parents: 3370
diff changeset
  1279
                    (self selectWithoutScroll:lineNr redraw:true) ifTrue:[
d1290de3de27 selectOnButtonMenu - start menu also on already selected elements (until now only
ab
parents: 3370
diff changeset
  1280
                        self selectionChanged
d1290de3de27 selectOnButtonMenu - start menu also on already selected elements (until now only
ab
parents: 3370
diff changeset
  1281
                    ].
2228
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
  1282
                ].
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
  1283
                item := self selectedElement.
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
  1284
            ] ifFalse:[
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
  1285
                item := nil
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
  1286
            ]
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
  1287
        ] ifFalse:[
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
  1288
            item := self selectedElement.
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
  1289
        ].
1578
cfa573485242 ask for middleButtonMenu if menuButton pressed
ca
parents: 1569
diff changeset
  1290
2308
c012b16422f0 replace ifNotNil: by notNil ifTrue:
ca
parents: 2302
diff changeset
  1291
        item notNil ifTrue:[
c012b16422f0 replace ifNotNil: by notNil ifTrue:
ca
parents: 2302
diff changeset
  1292
            self makeSelectionVisible.
2228
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
  1293
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
  1294
            menu := item perform:#middleButtonMenu ifNotUnderstood:nil.
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
  1295
2308
c012b16422f0 replace ifNotNil: by notNil ifTrue:
ca
parents: 2302
diff changeset
  1296
            menu notNil ifTrue:[
2228
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
  1297
                menu isCollection ifTrue:[
3221
af3fae427c7e use decodeFromLiteralArray
Claus Gittinger <cg@exept.de>
parents: 3205
diff changeset
  1298
                    menu := Menu decodeFromLiteralArray:menu.
2228
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
  1299
                    appl := self application.
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
  1300
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
  1301
                    appl notNil ifTrue:[
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
  1302
                        menu findGuiResourcesIn:appl.
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
  1303
                        "/ menu receiver:appl  -- now done in findGuiResources ...
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
  1304
                    ] ifFalse:[
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
  1305
                        menu receiver:item
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
  1306
                    ]
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
  1307
                ].
2333
eeff6439157e can now specify if menu action is to be performed by
ca
parents: 2330
diff changeset
  1308
                self startUpMenu:menu.
2361
c0e70e31ac28 close editor if button is pressed not in the editView
ca
parents: 2352
diff changeset
  1309
                ^ self
2228
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
  1310
            ]
1578
cfa573485242 ask for middleButtonMenu if menuButton pressed
ca
parents: 1569
diff changeset
  1311
        ].
2228
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
  1312
        super buttonPress:button x:x y:y.
2361
c0e70e31ac28 close editor if button is pressed not in the editView
ca
parents: 2352
diff changeset
  1313
        ^ self
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1314
    ].
2399
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  1315
    lineNr isNil ifTrue:[ ^ self ].
3205
7ff2e20b37d4 *** empty log message ***
ca
parents: 3202
diff changeset
  1316
    modelChangedDuringButtonPress := false.
1578
cfa573485242 ask for middleButtonMenu if menuButton pressed
ca
parents: 1569
diff changeset
  1317
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1318
    sensor ctrlDown ifTrue:[
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1319
        self buttonControlPressAtLine:lineNr x:x y:y.
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1320
        ^ self
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1321
    ].
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1322
2976
136d983423ab drag & drop activation if moving horizontal n pixels
ca
parents: 2964
diff changeset
  1323
    isSelected  := self isInSelection:lineNr.
136d983423ab drag & drop activation if moving horizontal n pixels
ca
parents: 2964
diff changeset
  1324
136d983423ab drag & drop activation if moving horizontal n pixels
ca
parents: 2964
diff changeset
  1325
    (self canDrag and:[sensor shiftDown not]) ifTrue:[
3146
b7294baadfb7 button press, move and release behaviour
ca
parents: 3137
diff changeset
  1326
        dragDistance := UserPreferences current motionDistanceToStartDrag.
2976
136d983423ab drag & drop activation if moving horizontal n pixels
ca
parents: 2964
diff changeset
  1327
136d983423ab drag & drop activation if moving horizontal n pixels
ca
parents: 2964
diff changeset
  1328
        isSelected ifTrue:[
3345
088090deaffb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3338
diff changeset
  1329
            buttonMotionAction := 
088090deaffb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3338
diff changeset
  1330
                [:p|
088090deaffb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3338
diff changeset
  1331
                    ((x@y) dist:p) > dragDistance ifTrue:[
088090deaffb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3338
diff changeset
  1332
                        self startDragAt:p.
088090deaffb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3338
diff changeset
  1333
                    ]
088090deaffb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3338
diff changeset
  1334
                ].
2976
136d983423ab drag & drop activation if moving horizontal n pixels
ca
parents: 2964
diff changeset
  1335
            buttonReleaseAction := [ self buttonPressOrReleaseAtLine:lineNr x:x y:y ].
3370
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
  1336
            ^ self.
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
  1337
        ].
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
  1338
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
  1339
        self selectOnButtonPress ifFalse: [
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
  1340
            |oldSelection|
3381
7451912f2aae fix selection problems for default drag handler
ab
parents: 3380
diff changeset
  1341
7451912f2aae fix selection problems for default drag handler
ab
parents: 3380
diff changeset
  1342
            "/ set selection to line;
7451912f2aae fix selection problems for default drag handler
ab
parents: 3380
diff changeset
  1343
            "/ set the model without change notification (objects to drag)
7451912f2aae fix selection problems for default drag handler
ab
parents: 3380
diff changeset
  1344
3370
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
  1345
            oldSelection := selection copy.
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
  1346
            self selectAndUpdateModelWithoutChangeNotification: lineNr.
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
  1347
            self windowGroup processExposeEvents.
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
  1348
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
  1349
            buttonMotionAction := 
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
  1350
                [:p|
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
  1351
                    ((x@y) dist:p) > dragDistance ifTrue:[
3381
7451912f2aae fix selection problems for default drag handler
ab
parents: 3380
diff changeset
  1352
                        |handler|
7451912f2aae fix selection problems for default drag handler
ab
parents: 3380
diff changeset
  1353
7451912f2aae fix selection problems for default drag handler
ab
parents: 3380
diff changeset
  1354
                        handler := self startDragAt:p.
7451912f2aae fix selection problems for default drag handler
ab
parents: 3380
diff changeset
  1355
                        handler contentsWillChange.
7451912f2aae fix selection problems for default drag handler
ab
parents: 3380
diff changeset
  1356
                        "/ restore old selection
3380
d1290de3de27 selectOnButtonMenu - start menu also on already selected elements (until now only
ab
parents: 3370
diff changeset
  1357
                        self selectAndUpdateModelWithoutChangeNotification: oldSelection.
3381
7451912f2aae fix selection problems for default drag handler
ab
parents: 3380
diff changeset
  1358
                        self windowGroup processExposeEvents.
3370
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
  1359
                    ].
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
  1360
                ].
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
  1361
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
  1362
            buttonReleaseAction := [
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
  1363
                (self canSelectIndex:lineNr forAdd:false) ifTrue:[
3381
7451912f2aae fix selection problems for default drag handler
ab
parents: 3380
diff changeset
  1364
                    "/ notify selection change
7451912f2aae fix selection problems for default drag handler
ab
parents: 3380
diff changeset
  1365
                    self selectionChanged.
7451912f2aae fix selection problems for default drag handler
ab
parents: 3380
diff changeset
  1366
                ] ifFalse:[
7451912f2aae fix selection problems for default drag handler
ab
parents: 3380
diff changeset
  1367
                    "/ restore old selection
7451912f2aae fix selection problems for default drag handler
ab
parents: 3380
diff changeset
  1368
                    self selectAndUpdateModelWithoutChangeNotification: oldSelection.
3370
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
  1369
                ].
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
  1370
            ].
2976
136d983423ab drag & drop activation if moving horizontal n pixels
ca
parents: 2964
diff changeset
  1371
            ^ self
3370
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
  1372
        ].
2976
136d983423ab drag & drop activation if moving horizontal n pixels
ca
parents: 2964
diff changeset
  1373
    ].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1374
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1375
    multipleSelectOk ifFalse:[
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1376
        (isSelected or:[self canSelectIndex:lineNr forAdd:false]) ifTrue:[
2399
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  1377
            self buttonPressOrReleaseAtLine:lineNr x:x y:y.
2976
136d983423ab drag & drop activation if moving horizontal n pixels
ca
parents: 2964
diff changeset
  1378
3146
b7294baadfb7 button press, move and release behaviour
ca
parents: 3137
diff changeset
  1379
            (dragDistance notNil and:[self isInSelection:lineNr]) ifTrue:[
3345
088090deaffb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3338
diff changeset
  1380
                buttonMotionAction := 
088090deaffb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3338
diff changeset
  1381
                    [:p|
088090deaffb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3338
diff changeset
  1382
                        ((x@y) dist:p) > dragDistance ifTrue:[
088090deaffb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3338
diff changeset
  1383
                            self startDragAt:p.
088090deaffb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3338
diff changeset
  1384
                        ].
2976
136d983423ab drag & drop activation if moving horizontal n pixels
ca
parents: 2964
diff changeset
  1385
                    ].
136d983423ab drag & drop activation if moving horizontal n pixels
ca
parents: 2964
diff changeset
  1386
            ].
2399
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  1387
        ].
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  1388
        ^ self
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  1389
    ].
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1390
    startLine := lineNr.
2399
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  1391
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1392
    sensor shiftDown ifTrue:[ |min max|
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1393
        (isSelected or:[self canSelectIndex:lineNr forAdd:true]) ifFalse:[
1644
d35b53c3d7d5 checkin from browser
ps
parents: 1641
diff changeset
  1394
            ^ self
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1395
        ].
1920
e3994a83fb16 selectConditionBlock can be a 2-arg block;
martin
parents: 1917
diff changeset
  1396
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1397
        multipleSelectOk ifTrue:[
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1398
            startLine := self firstInSelection.
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1399
            startLine isNil ifTrue:[ startLine := lineNr ].
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1400
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1401
            startLine <= lineNr ifTrue:[
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1402
                self selectFrom:startLine to:lineNr.
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1403
            ] ifFalse:[
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1404
                startLine := self lastInSelection.
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1405
                self selectFrom:lineNr to:startLine.
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1406
            ].
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1407
        ]
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1408
    ] ifFalse:[
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1409
        (isSelected or:[self canSelectIndex:lineNr forAdd:false]) ifFalse:[
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1410
            ^ self
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1411
        ].
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1412
        self buttonPressOrReleaseAtLine:lineNr x:x y:y.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1413
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1414
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1415
    multipleSelectOk ifTrue:[
3345
088090deaffb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3338
diff changeset
  1416
        buttonMotionAction := 
088090deaffb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3338
diff changeset
  1417
            [:p| |ln|
088090deaffb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3338
diff changeset
  1418
                (p y between:0 and:height) ifTrue:[ |ln|
088090deaffb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3338
diff changeset
  1419
                    ln := self yVisibleToLineNr:p y.
088090deaffb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3338
diff changeset
  1420
                    ln isNil ifTrue:[ln := self size].
088090deaffb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3338
diff changeset
  1421
088090deaffb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3338
diff changeset
  1422
                    (ln ~~ self lastInSelection and:[ln ~~ self firstInSelection]) ifTrue:[
088090deaffb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3338
diff changeset
  1423
                        self selectFrom:startLine to:ln.
088090deaffb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3338
diff changeset
  1424
                        dragDistance := nil.   "/ selection changed - no longer dragable
088090deaffb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3338
diff changeset
  1425
                    ]
088090deaffb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3338
diff changeset
  1426
                ].
088090deaffb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3338
diff changeset
  1427
088090deaffb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3338
diff changeset
  1428
                (dragDistance notNil and:[(x dist:p x) > dragDistance]) ifTrue:[
088090deaffb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3338
diff changeset
  1429
                    self startDragAt:p.
088090deaffb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3338
diff changeset
  1430
                ].
2964
619033c2fb7d distinguish between dragging vs. multi-selecting when the first move
ps
parents: 2959
diff changeset
  1431
            ].
1915
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
  1432
    ].
3221
af3fae427c7e use decodeFromLiteralArray
Claus Gittinger <cg@exept.de>
parents: 3205
diff changeset
  1433
af3fae427c7e use decodeFromLiteralArray
Claus Gittinger <cg@exept.de>
parents: 3205
diff changeset
  1434
    "Modified: / 27-03-2007 / 08:43:58 / cg"
1915
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
  1435
!
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
  1436
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
  1437
buttonPressOrReleaseAtLine:aLnNr x:x y:y
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
  1438
    "handle a button press or release at a line
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
  1439
    "
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
  1440
    aLnNr == self selectedIndex ifTrue:[
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
  1441
        editorView notNil ifTrue:[^ self].
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
  1442
2596
771e23c6d9cf access actions by call and not by reference
ca
parents: 2572
diff changeset
  1443
        self openEditorAction notNil ifTrue:[
1915
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
  1444
            self openEditorAtX:x y:y.
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
  1445
            editorView notNil ifTrue:[^ self].
1741
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
  1446
        ].
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
  1447
1915
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
  1448
        ignoreReselect ifFalse:[
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
  1449
            (toggleSelect and:[self sensor ctrlDown]) ifTrue:[
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
  1450
                self selection:nil
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
  1451
            ] ifFalse:[
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
  1452
                self selectionChanged
1741
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
  1453
            ].
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
  1454
        ].
1915
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
  1455
    ] ifFalse:[
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
  1456
        (self selectWithoutScroll:aLnNr redraw:true) ifTrue:[
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
  1457
            self selectionChanged
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
  1458
        ]
1741
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
  1459
    ].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1460
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1461
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1462
buttonRelease:button x:x y:y
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1463
    "a button was released
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1464
    "
3205
7ff2e20b37d4 *** empty log message ***
ca
parents: 3202
diff changeset
  1465
    |makeSelectionVisible|
7ff2e20b37d4 *** empty log message ***
ca
parents: 3202
diff changeset
  1466
7ff2e20b37d4 *** empty log message ***
ca
parents: 3202
diff changeset
  1467
    makeSelectionVisible := modelChangedDuringButtonPress.
7ff2e20b37d4 *** empty log message ***
ca
parents: 3202
diff changeset
  1468
    buttonMotionAction   := modelChangedDuringButtonPress := nil.
1915
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
  1469
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1470
    buttonReleaseAction notNil ifTrue:[
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1471
        buttonReleaseAction value.
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1472
        buttonReleaseAction := nil.
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  1473
    ].
1915
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
  1474
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1475
    self cursorEntersItem:nil.
1748
0a2213a15e06 support of auto scrolling
ca
parents: 1747
diff changeset
  1476
    self stopAutoScroll.
3205
7ff2e20b37d4 *** empty log message ***
ca
parents: 3202
diff changeset
  1477
7ff2e20b37d4 *** empty log message ***
ca
parents: 3202
diff changeset
  1478
    (makeSelectionVisible == true and:[self hasSelection]) ifTrue:[
7ff2e20b37d4 *** empty log message ***
ca
parents: 3202
diff changeset
  1479
        self makeSelectionVisible
7ff2e20b37d4 *** empty log message ***
ca
parents: 3202
diff changeset
  1480
    ].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1481
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1482
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1483
characterPress:aKey x:x y:y
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1484
    " a character is pressed - lookup and change selection
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1485
    "
2482
13acaaf02528 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2455
diff changeset
  1486
    |lnNr size idx stp to1 fr2|
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1487
2418
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1488
    size := self size.
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1489
    size > 1 ifFalse:[^ self].
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1490
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1491
    lnNr := self firstInSelection.
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1492
    lnNr isNil ifTrue:[lnNr := 0].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1493
2482
13acaaf02528 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2455
diff changeset
  1494
    self sensor shiftDown ifTrue:[
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1495
        stp := -1.              "/ search backward
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1496
        to1 :=  1.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1497
        fr2 := size.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1498
    ] ifFalse:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1499
        stp := 1.               "/ search forward
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1500
        to1 := size.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1501
        fr2 := 1.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1502
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1503
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1504
    idx := self findLineFrom:lnNr+stp to:to1 by:stp startingWithCharacter:aKey.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1505
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1506
    idx == 0 ifTrue:[
2418
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1507
        idx := self findLineFrom:fr2 to:lnNr-stp by:stp startingWithCharacter:aKey.
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1508
        idx == 0 ifTrue:[^ self].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1509
    ].
2418
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1510
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1511
    self selection:idx.
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1512
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1513
    keyActionStyle == #selectAndDoubleClick ifTrue:[
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1514
        self doubleClicked
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1515
    ].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1516
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1517
1768
04b330a75f75 allow for subclasses to redefine character search
Claus Gittinger <cg@exept.de>
parents: 1758
diff changeset
  1518
characterSearchItemStringAt:anIndex
2418
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1519
    "for first-character search:
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1520
     return a lines item-string.
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1521
     For multi-col items, this may be different from the actual string
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1522
    "
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1523
    |item s|
1768
04b330a75f75 allow for subclasses to redefine character search
Claus Gittinger <cg@exept.de>
parents: 1758
diff changeset
  1524
2408
8b0d11537dc0 accessing list indirect
ca
parents: 2404
diff changeset
  1525
    item := self at:anIndex ifAbsent:nil.
2418
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1526
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1527
    item isHierarchicalItem ifTrue:[
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1528
        item := item string
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1529
    ].
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1530
    item isNil ifTrue:[^ nil].
1768
04b330a75f75 allow for subclasses to redefine character search
Claus Gittinger <cg@exept.de>
parents: 1758
diff changeset
  1531
2455
44300555526c Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents: 2447
diff changeset
  1532
    (Error catch:[
2418
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1533
        s := item asString
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1534
    ]) ifTrue:[
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1535
        s := item displayString
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1536
    ].
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1537
    ^ s
1768
04b330a75f75 allow for subclasses to redefine character search
Claus Gittinger <cg@exept.de>
parents: 1758
diff changeset
  1538
!
04b330a75f75 allow for subclasses to redefine character search
Claus Gittinger <cg@exept.de>
parents: 1758
diff changeset
  1539
1917
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1540
containerChangedSize
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1541
    "/ 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
  1542
    "/ 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
  1543
    "/     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
  1544
2409
68095c891ceb reuse selection methods (prepared for common controller)
ca
parents: 2408
diff changeset
  1545
    self hasSelection ifTrue:[
1917
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1546
        (hilightFrameColor notNil 
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1547
        or:[hilightStyle == #motif
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1548
        or:[hilightLevel ~~ 0]]) ifTrue:[
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1549
           "/ invalidate the right-edge
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1550
            self invalidate:(((width-3) @ 0) corner:((width-1) @ (height-1))).
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1551
        ]
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1552
    ].
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1553
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1554
    super containerChangedSize.
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1555
!
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1556
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1557
cursorEntersItem:anItemOrNil
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1558
    "the cursor enters an item or nil
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1559
    "
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1560
    |lnNr x|
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1561
2408
8b0d11537dc0 accessing list indirect
ca
parents: 2404
diff changeset
  1562
    (shown and:[self size ~~ 0]) ifFalse:[
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1563
        cursorItem := nil.
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1564
        ^ self.  
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1565
    ].
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1566
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1567
    anItemOrNil == cursorItem ifTrue:[ ^ self ].
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1568
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1569
    2 timesRepeat:[
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1570
        cursorItem notNil ifTrue:[
2408
8b0d11537dc0 accessing list indirect
ca
parents: 2404
diff changeset
  1571
            lnNr := self identityIndexOf:cursorItem.
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1572
            lnNr notNil ifTrue:[
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1573
                x := self xVisibleOfItem:cursorItem.
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1574
                self invalidateLineAt:lnNr fromX:x
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1575
            ].
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1576
        ].
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1577
        "/ set the new item
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1578
        cursorItem := anItemOrNil.
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1579
    ].
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1580
    cursorItem notNil ifTrue:[
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1581
        self makeLineVisible:lnNr
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1582
    ].
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1583
!
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1584
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1585
doubleClicked
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1586
    "handle a double click
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1587
    "
2416
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
  1588
    |arg|
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
  1589
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
  1590
    doubleClickActionBlock notNil ifTrue:[
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
  1591
        arg := self selectedIndex.
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
  1592
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
  1593
        arg ~~ 0 ifTrue:[
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
  1594
            doubleClickActionBlock valueWithOptionalArgument:arg and:self.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1595
        ]
2416
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
  1596
    ].
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
findLineFrom:aStart to:aStop by:aStep startingWithCharacter:aCharacter
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1600
    "find a line starting with a character
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1601
    "
2408
8b0d11537dc0 accessing list indirect
ca
parents: 2404
diff changeset
  1602
    |char lbl cmp
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1603
     size     "{ Class:SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1604
     start    "{ Class:SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1605
     stop     "{ Class:SmallInteger }"
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1606
    |
2408
8b0d11537dc0 accessing list indirect
ca
parents: 2404
diff changeset
  1607
    (size := self size) ~~ 0 ifTrue:[
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1608
        aStep > 0 ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1609
            aStart > aStop ifTrue:[^ 0].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1610
        ] ifFalse:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1611
            (aStep == 0 or:[aStop > aStart]) ifTrue:[^ 0]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1612
        ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1613
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1614
        start := aStart < 0 ifTrue:[1] ifFalse:[aStart min:size].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1615
        stop  := aStop  < 0 ifTrue:[1] ifFalse:[aStop  min:size].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1616
        char  := aCharacter asUppercase.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1617
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1618
        start to:stop by:aStep do:[:anIndex|
3081
0af6dce8cbf0 first look for the next item then do a select check
fm
parents: 2976
diff changeset
  1619
            lbl := self characterSearchItemStringAt:anIndex.
0af6dce8cbf0 first look for the next item then do a select check
fm
parents: 2976
diff changeset
  1620
            lbl notNil ifTrue:[
0af6dce8cbf0 first look for the next item then do a select check
fm
parents: 2976
diff changeset
  1621
                cmp := lbl string at:1 ifAbsent:nil.
0af6dce8cbf0 first look for the next item then do a select check
fm
parents: 2976
diff changeset
  1622
0af6dce8cbf0 first look for the next item then do a select check
fm
parents: 2976
diff changeset
  1623
                cmp notNil ifTrue:[
0af6dce8cbf0 first look for the next item then do a select check
fm
parents: 2976
diff changeset
  1624
                    (char == cmp or:[char == cmp asUppercase]) ifTrue:[
0af6dce8cbf0 first look for the next item then do a select check
fm
parents: 2976
diff changeset
  1625
                        (self canSelectIndex:anIndex forAdd:false) ifTrue:[
1772
709e1ad163c0 checkin from browser
tm
parents: 1768
diff changeset
  1626
                            ^ anIndex
3081
0af6dce8cbf0 first look for the next item then do a select check
fm
parents: 2976
diff changeset
  1627
                        ].
0af6dce8cbf0 first look for the next item then do a select check
fm
parents: 2976
diff changeset
  1628
                        ^ 0
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1629
                    ]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1630
                ]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1631
            ]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1632
        ]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1633
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1634
    ^ 0
3081
0af6dce8cbf0 first look for the next item then do a select check
fm
parents: 2976
diff changeset
  1635
0af6dce8cbf0 first look for the next item then do a select check
fm
parents: 2976
diff changeset
  1636
    "Modified: / 15-09-2006 / 11:26:29 / User"
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1637
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1638
3338
01ad784543fc no underline-highlighting
Claus Gittinger <cg@exept.de>
parents: 3275
diff changeset
  1639
invalidateLineOfItem:anItem
01ad784543fc no underline-highlighting
Claus Gittinger <cg@exept.de>
parents: 3275
diff changeset
  1640
    |lnNr x|
01ad784543fc no underline-highlighting
Claus Gittinger <cg@exept.de>
parents: 3275
diff changeset
  1641
01ad784543fc no underline-highlighting
Claus Gittinger <cg@exept.de>
parents: 3275
diff changeset
  1642
    lnNr := self identityIndexOf:enterItem.
01ad784543fc no underline-highlighting
Claus Gittinger <cg@exept.de>
parents: 3275
diff changeset
  1643
    lnNr notNil ifTrue:[
01ad784543fc no underline-highlighting
Claus Gittinger <cg@exept.de>
parents: 3275
diff changeset
  1644
        x := self xVisibleOfItem:enterItem.
01ad784543fc no underline-highlighting
Claus Gittinger <cg@exept.de>
parents: 3275
diff changeset
  1645
        self invalidateLineAt:lnNr fromX:x
01ad784543fc no underline-highlighting
Claus Gittinger <cg@exept.de>
parents: 3275
diff changeset
  1646
    ].
01ad784543fc no underline-highlighting
Claus Gittinger <cg@exept.de>
parents: 3275
diff changeset
  1647
!
01ad784543fc no underline-highlighting
Claus Gittinger <cg@exept.de>
parents: 3275
diff changeset
  1648
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1649
keyPress:aKey x:x y:y
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1650
    "a key was pressed - handle page-keys here
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1651
    "
2365
bdf6954a0358 key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents: 2361
diff changeset
  1652
    <resource: #keyboard( #CursorUp #CursorDown #EndOfText #EndOfLine
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1653
                          #BeginOfText #BeginOfLine #Return
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1654
                          #CmdReturn #CmdCursorUp #CmdCursorDown )>
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1655
2413
49f5c28b1364 key handling
ca
parents: 2410
diff changeset
  1656
    |lineNr listSize shifted newSel step start|
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1657
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1658
    enabled ifFalse:[ ^ self ].
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1659
2408
8b0d11537dc0 accessing list indirect
ca
parents: 2404
diff changeset
  1660
    listSize := self size.
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1661
    listSize == 0 ifTrue:[^ self].
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1662
2365
bdf6954a0358 key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents: 2361
diff changeset
  1663
    aKey isCharacter ifTrue:[
2418
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1664
        keyActionStyle notNil ifTrue:[
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1665
            keyActionStyle == #pass ifTrue:[
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1666
                super keyPress:aKey x:x y:y
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1667
            ] ifFalse:[
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1668
                self characterPress:aKey x:x y:y.
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1669
            ].
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1670
        ].
2365
bdf6954a0358 key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents: 2361
diff changeset
  1671
        ^ self
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1672
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1673
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1674
    aKey == #Escape ifTrue:[
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1675
        cursorItem notNil ifTrue:[
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1676
            self cursorEntersItem:nil.
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1677
            self makeSelectionVisible.
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1678
        ].
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1679
        super keyPress:aKey x:x y:y.
2365
bdf6954a0358 key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents: 2361
diff changeset
  1680
        ^ self
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1681
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1682
2365
bdf6954a0358 key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents: 2361
diff changeset
  1683
    ((aKey == #BeginOfText) or:[aKey == #BeginOfLine]) ifTrue:[
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1684
        self cursorEntersItem:nil.
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1685
2368
8101aa8d50d2 cursor select behaviour in: #keyPress:x:y:
ca
parents: 2365
diff changeset
  1686
        1 to:listSize do:[:i|
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1687
            (self canSelectIndex:i forAdd:false) ifTrue:[
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1688
                self selection:i.
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1689
                ^ self
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1690
            ].
2368
8101aa8d50d2 cursor select behaviour in: #keyPress:x:y:
ca
parents: 2365
diff changeset
  1691
        ].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1692
        ^ self
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1693
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1694
2365
bdf6954a0358 key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents: 2361
diff changeset
  1695
    ((aKey == #EndOfText) or:[aKey == #EndOfLine]) ifTrue:[
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1696
        self cursorEntersItem:nil.
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1697
2368
8101aa8d50d2 cursor select behaviour in: #keyPress:x:y:
ca
parents: 2365
diff changeset
  1698
        listSize to:1 by:-1 do:[:i|
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1699
            (self canSelectIndex:i forAdd:false) ifTrue:[
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1700
                self selection:i.
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1701
                ^ self
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1702
            ].
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1703
        ].
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1704
        ^ self
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1705
    ].
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1706
    lineNr := self cursorLine.
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1707
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1708
    aKey == #Return ifTrue:[
2418
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1709
        returnKeyActionStyle == #pass ifTrue:[
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1710
            super keyPress:aKey x:x y:y
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1711
        ] ifFalse:[
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1712
            lineNr ~~ 0 ifTrue:[
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1713
                self cursorEntersItem:nil.
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1714
2418
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1715
                (self canSelectIndex:lineNr forAdd:false) ifTrue:[
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1716
                    self selection:lineNr
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1717
                ].
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1718
            ].
2418
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1719
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1720
            returnKeyActionStyle == #doubleClick ifTrue:[
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1721
                self doubleClicked
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1722
            ].
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1723
        ].
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1724
        ^ self
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1725
    ].
2413
49f5c28b1364 key handling
ca
parents: 2410
diff changeset
  1726
49f5c28b1364 key handling
ca
parents: 2410
diff changeset
  1727
    (lineNr == 0 and:[selection notNil]) ifTrue:[
49f5c28b1364 key handling
ca
parents: 2410
diff changeset
  1728
        multipleSelectOk ifFalse:[lineNr := selection]
49f5c28b1364 key handling
ca
parents: 2410
diff changeset
  1729
                          ifTrue:[lineNr := selection last].
49f5c28b1364 key handling
ca
parents: 2410
diff changeset
  1730
    ].
49f5c28b1364 key handling
ca
parents: 2410
diff changeset
  1731
49f5c28b1364 key handling
ca
parents: 2410
diff changeset
  1732
    aKey == #CmdReturn ifTrue:[
49f5c28b1364 key handling
ca
parents: 2410
diff changeset
  1733
        "/ toggle selection of the item
49f5c28b1364 key handling
ca
parents: 2410
diff changeset
  1734
        lineNr ~~ 0 ifTrue:[
49f5c28b1364 key handling
ca
parents: 2410
diff changeset
  1735
            (self isInSelection:lineNr) ifTrue:[ self removeFromSelection:lineNr ]
49f5c28b1364 key handling
ca
parents: 2410
diff changeset
  1736
                                       ifFalse:[ self addToSelection:lineNr ].
49f5c28b1364 key handling
ca
parents: 2410
diff changeset
  1737
49f5c28b1364 key handling
ca
parents: 2410
diff changeset
  1738
            self cursorEntersItem:(self at:lineNr).
49f5c28b1364 key handling
ca
parents: 2410
diff changeset
  1739
        ].
49f5c28b1364 key handling
ca
parents: 2410
diff changeset
  1740
        ^ self
49f5c28b1364 key handling
ca
parents: 2410
diff changeset
  1741
    ].
49f5c28b1364 key handling
ca
parents: 2410
diff changeset
  1742
49f5c28b1364 key handling
ca
parents: 2410
diff changeset
  1743
    (aKey == #CmdCursorDown or:[aKey == #CmdCursorUp]) ifTrue:[
49f5c28b1364 key handling
ca
parents: 2410
diff changeset
  1744
        aKey == #CmdCursorDown ifTrue:[
49f5c28b1364 key handling
ca
parents: 2410
diff changeset
  1745
            lineNr := lineNr + 1.
49f5c28b1364 key handling
ca
parents: 2410
diff changeset
  1746
            lineNr > listSize ifTrue:[lineNr := 1].
49f5c28b1364 key handling
ca
parents: 2410
diff changeset
  1747
        ] ifFalse:[
49f5c28b1364 key handling
ca
parents: 2410
diff changeset
  1748
            lineNr := lineNr - 1.
49f5c28b1364 key handling
ca
parents: 2410
diff changeset
  1749
            lineNr < 1 ifTrue:[lineNr := listSize].
49f5c28b1364 key handling
ca
parents: 2410
diff changeset
  1750
        ].
49f5c28b1364 key handling
ca
parents: 2410
diff changeset
  1751
        self cursorEntersItem:(self at:lineNr).
49f5c28b1364 key handling
ca
parents: 2410
diff changeset
  1752
        ^ self
49f5c28b1364 key handling
ca
parents: 2410
diff changeset
  1753
    ].
49f5c28b1364 key handling
ca
parents: 2410
diff changeset
  1754
49f5c28b1364 key handling
ca
parents: 2410
diff changeset
  1755
    (aKey == #CursorUp or:[aKey == #CursorDown]) ifFalse:[
2365
bdf6954a0358 key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents: 2361
diff changeset
  1756
        super keyPress:aKey x:x y:y.
bdf6954a0358 key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents: 2361
diff changeset
  1757
        ^ self
bdf6954a0358 key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents: 2361
diff changeset
  1758
    ].
2413
49f5c28b1364 key handling
ca
parents: 2410
diff changeset
  1759
    shifted := (multipleSelectOk and:[self sensor shiftDown]).
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1760
    self cursorEntersItem:nil.
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1761
2671
bba7717907bb compress keyEvents cursor Up and Down
ca
parents: 2670
diff changeset
  1762
    aKey == #CursorDown ifTrue:[ step :=  1.]
bba7717907bb compress keyEvents cursor Up and Down
ca
parents: 2670
diff changeset
  1763
                       ifFalse:[ step := -1.].
bba7717907bb compress keyEvents cursor Up and Down
ca
parents: 2670
diff changeset
  1764
bba7717907bb compress keyEvents cursor Up and Down
ca
parents: 2670
diff changeset
  1765
    shifted ifFalse:[ |compressed|
bba7717907bb compress keyEvents cursor Up and Down
ca
parents: 2670
diff changeset
  1766
        compressed := self sensor compressKeyPressEventsWithKey:aKey.
bba7717907bb compress keyEvents cursor Up and Down
ca
parents: 2670
diff changeset
  1767
bba7717907bb compress keyEvents cursor Up and Down
ca
parents: 2670
diff changeset
  1768
        compressed ~~ 0 ifTrue:[
bba7717907bb compress keyEvents cursor Up and Down
ca
parents: 2670
diff changeset
  1769
            aKey == #CursorDown ifTrue:[
bba7717907bb compress keyEvents cursor Up and Down
ca
parents: 2670
diff changeset
  1770
                lineNr := lineNr + compressed.
bba7717907bb compress keyEvents cursor Up and Down
ca
parents: 2670
diff changeset
  1771
                lineNr > listSize ifTrue:[lineNr := 1].
bba7717907bb compress keyEvents cursor Up and Down
ca
parents: 2670
diff changeset
  1772
            ] ifFalse:[
bba7717907bb compress keyEvents cursor Up and Down
ca
parents: 2670
diff changeset
  1773
                lineNr := lineNr - compressed.
bba7717907bb compress keyEvents cursor Up and Down
ca
parents: 2670
diff changeset
  1774
                lineNr < 1 ifTrue:[lineNr := listSize].
bba7717907bb compress keyEvents cursor Up and Down
ca
parents: 2670
diff changeset
  1775
            ].
bba7717907bb compress keyEvents cursor Up and Down
ca
parents: 2670
diff changeset
  1776
        ].
bba7717907bb compress keyEvents cursor Up and Down
ca
parents: 2670
diff changeset
  1777
    ].
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1778
    start  := lineNr.
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1779
    lineNr := lineNr + step.
2368
8101aa8d50d2 cursor select behaviour in: #keyPress:x:y:
ca
parents: 2365
diff changeset
  1780
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1781
    [ lineNr ~~ start ] whileTrue:[
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1782
        (lineNr between:1 and:listSize) ifFalse:[
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1783
            lineNr < 1 ifTrue:[ lineNr := listSize ]
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1784
                      ifFalse:[ lineNr := 1 ].
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1785
        ] ifTrue:[
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1786
            (self canSelectIndex:lineNr forAdd:shifted) ifTrue:[
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1787
                shifted ifFalse:[
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1788
                    self selection:lineNr.
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1789
                    ^ self
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1790
                ].
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1791
                (self isInSelection:lineNr) ifFalse:[
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1792
                    selection isNil ifTrue:[ newSel := Array with:lineNr ]
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1793
                                   ifFalse:[ newSel := selection copyWith:lineNr ].
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1794
                ] ifTrue:[
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1795
                    (start ~~ 0 and:[selection size > 1]) ifFalse:[
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1796
                        ^ self
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1797
                    ].
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1798
                    newSel := selection copyWithout:start.
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1799
                ].
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1800
                self selectWithoutScroll:newSel redraw:true.
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1801
                self makeLineVisible:lineNr.
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1802
                self selectionChanged.
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1803
                ^ self
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1804
            ].
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1805
            lineNr := lineNr + step.
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1806
        ]
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1807
    ].
1917
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1808
!
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1809
2323
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
  1810
pointerEntersItem:anItemOrNil
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
  1811
    "the pointer moves over an item or nil
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
  1812
    "
3338
01ad784543fc no underline-highlighting
Claus Gittinger <cg@exept.de>
parents: 3275
diff changeset
  1813
    |newItem|
2323
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
  1814
2408
8b0d11537dc0 accessing list indirect
ca
parents: 2404
diff changeset
  1815
    (shown and:[self size ~~ 0]) ifFalse:[
2323
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
  1816
        enterItem := nil.
2408
8b0d11537dc0 accessing list indirect
ca
parents: 2404
diff changeset
  1817
        ^ self.  
2323
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
  1818
    ].
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
  1819
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
  1820
    highlightEnterItem ifTrue:[ newItem := anItemOrNil ]
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
  1821
                      ifFalse:[ newItem := nil ].
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
  1822
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
  1823
    anItemOrNil == enterItem ifTrue:[ ^ self ].
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
  1824
3338
01ad784543fc no underline-highlighting
Claus Gittinger <cg@exept.de>
parents: 3275
diff changeset
  1825
    enterItem notNil ifTrue:[ self invalidateLineOfItem:enterItem ].
01ad784543fc no underline-highlighting
Claus Gittinger <cg@exept.de>
parents: 3275
diff changeset
  1826
    enterItem := anItemOrNil.
01ad784543fc no underline-highlighting
Claus Gittinger <cg@exept.de>
parents: 3275
diff changeset
  1827
    enterItem notNil ifTrue:[ self invalidateLineOfItem:enterItem ].
2323
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
  1828
!
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
  1829
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
  1830
pointerLeave:state
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
  1831
    self pointerEntersItem:nil.
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
  1832
    super pointerLeave:state.
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
  1833
!
8257059da044 support of highlighting items under mouse
ca
parents: 2309
diff changeset
  1834
1917
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1835
sizeChanged:how
2274
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  1836
    |selectionWasVisible|
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  1837
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  1838
    selectionWasVisible := false.
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  1839
1917
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1840
    "/ 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
  1841
    "/ 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
  1842
    "/     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
  1843
68095c891ceb reuse selection methods (prepared for common controller)
ca
parents: 2408
diff changeset
  1844
    self hasSelection ifTrue:[
2275
ca
parents: 2274
diff changeset
  1845
        selectionWasVisible := self isSelectionVisibleIn:(previousExtent ? self extent).
2274
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  1846
1917
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1847
        (hilightFrameColor notNil 
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1848
        or:[hilightStyle == #motif
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1849
        or:[hilightLevel ~~ 0]]) ifTrue:[
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1850
           "/ invalidate the right-edge
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1851
            self invalidate:(((width-3) @ 0) corner:((width-1) @ (height-1))).
2225
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
  1852
        ].
1917
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1853
    ].
21964f5b1cc1 fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents: 1915
diff changeset
  1854
    super sizeChanged:how.
2274
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  1855
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  1856
    selectionWasVisible ifTrue:[
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  1857
        self makeSelectionVisible
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  1858
    ].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1859
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1860
1421
95ac3092660a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1409
diff changeset
  1861
!SelectionInListModelView methodsFor:'focus handling'!
95ac3092660a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1409
diff changeset
  1862
3137
7e8fae56b94c highlight selection dependent on has focus
ca
parents: 3081
diff changeset
  1863
showFocus:explicit
7e8fae56b94c highlight selection dependent on has focus
ca
parents: 3081
diff changeset
  1864
    self invalidateSelection.
7e8fae56b94c highlight selection dependent on has focus
ca
parents: 3081
diff changeset
  1865
    super showFocus:explicit
7e8fae56b94c highlight selection dependent on has focus
ca
parents: 3081
diff changeset
  1866
!
7e8fae56b94c highlight selection dependent on has focus
ca
parents: 3081
diff changeset
  1867
7e8fae56b94c highlight selection dependent on has focus
ca
parents: 3081
diff changeset
  1868
showNoFocus:explicit
7e8fae56b94c highlight selection dependent on has focus
ca
parents: 3081
diff changeset
  1869
    self invalidateSelection.
7e8fae56b94c highlight selection dependent on has focus
ca
parents: 3081
diff changeset
  1870
    super showNoFocus:explicit
7e8fae56b94c highlight selection dependent on has focus
ca
parents: 3081
diff changeset
  1871
!
7e8fae56b94c highlight selection dependent on has focus
ca
parents: 3081
diff changeset
  1872
1421
95ac3092660a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1409
diff changeset
  1873
wantsFocusWithPointerEnter
95ac3092660a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1409
diff changeset
  1874
    "return true, if I want the focus when
95ac3092660a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1409
diff changeset
  1875
     the mouse pointer enters"
95ac3092660a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1409
diff changeset
  1876
2701
d95a0a764f4d do return false in #wantsFocusWithPointerEnter if an ecitor is open
ca
parents: 2671
diff changeset
  1877
    (editorView notNil and:[editorView realized]) ifTrue:[
d95a0a764f4d do return false in #wantsFocusWithPointerEnter if an ecitor is open
ca
parents: 2671
diff changeset
  1878
        ^ false
d95a0a764f4d do return false in #wantsFocusWithPointerEnter if an ecitor is open
ca
parents: 2671
diff changeset
  1879
    ].
d95a0a764f4d do return false in #wantsFocusWithPointerEnter if an ecitor is open
ca
parents: 2671
diff changeset
  1880
2959
afaf27dffcc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2948
diff changeset
  1881
    (UserPreferences current focusFollowsMouse ~~ false
1421
95ac3092660a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1409
diff changeset
  1882
    and:[(styleSheet at:#'selection.requestFocusOnPointerEnter' default:true)
95ac3092660a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1409
diff changeset
  1883
    ]) ifTrue:[
2408
8b0d11537dc0 accessing list indirect
ca
parents: 2404
diff changeset
  1884
        self size > 0 ifTrue:[
2055
964a2cac4e55 take focus on pointer enter only if the list is not empty.
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
  1885
            ^ true
964a2cac4e55 take focus on pointer enter only if the list is not empty.
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
  1886
        ]
1421
95ac3092660a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1409
diff changeset
  1887
    ].
95ac3092660a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1409
diff changeset
  1888
    ^ false
95ac3092660a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1409
diff changeset
  1889
! !
95ac3092660a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1409
diff changeset
  1890
2501
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2493
diff changeset
  1891
!SelectionInListModelView methodsFor:'initialization & release'!
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1892
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1893
fetchResources
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1894
    "fetch device colors and ..., to avoid reallocation at redraw time;
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1895
     *** called after a create or snapin to fetch all device resources
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1896
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1897
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1898
    super fetchResources.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1899
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1900
    hilightFgColor    := self colorOnDevice:hilightFgColor.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1901
    hilightBgColor    := self colorOnDevice:hilightBgColor.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1902
    hilightFrameColor := self colorOnDevice:hilightFrameColor.
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1903
    lineMask          := lineMask  onDevice:device.
3137
7e8fae56b94c highlight selection dependent on has focus
ca
parents: 3081
diff changeset
  1904
7e8fae56b94c highlight selection dependent on has focus
ca
parents: 3081
diff changeset
  1905
    hilightFgColorNoFocus := self colorOnDevice:hilightFgColorNoFocus.
7e8fae56b94c highlight selection dependent on has focus
ca
parents: 3081
diff changeset
  1906
    hilightBgColorNoFocus := self colorOnDevice:hilightBgColorNoFocus.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1907
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1908
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1909
initStyle
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1910
    "setup viewStyle specifics
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1911
    "
3438
a8ce9823cc1e english
Claus Gittinger <cg@exept.de>
parents: 3391
diff changeset
  1912
    <resource: #style (#'selection.selectOnMenuButton' 
2920
82161da6adef resource directive
Claus Gittinger <cg@exept.de>
parents: 2891
diff changeset
  1913
                       #'selection.font')>
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1914
    super initStyle.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1915
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1916
    lineMask isNil ifTrue:[
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1917
        lineMask := Form width:2 height:2 fromArray:#[16rAA 16r55].
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1918
    ].
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  1919
2228
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
  1920
    hilightFrameColor   := nil.
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
  1921
    hilightStyle        := DefaultHilightStyle.
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
  1922
    highlightMode       := #label.
5268b9c3be4a add behavior: selectOnButtonMenu; update documentation
ca
parents: 2225
diff changeset
  1923
    textStartLeft       := 4.
3438
a8ce9823cc1e english
Claus Gittinger <cg@exept.de>
parents: 3391
diff changeset
  1924
    selectOnMenuButton  := styleSheet at:#'selection.selectOnMenuButton' default:false.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1925
1741
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
  1926
    super font:(styleSheet fontAt:#'selection.font').
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
  1927
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1928
    device hasGrayscales ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1929
        "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1930
         must get rid of these hard codings
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1931
        "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1932
        (hilightStyle == #next) ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1933
            hilightFgColor := fgColor.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1934
            hilightBgColor := White.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1935
            hilightFrameColor := fgColor
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1936
        ] ifFalse:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1937
            (hilightStyle == #motif) ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1938
                fgColor := White.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1939
                bgColor := Grey.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1940
                viewBackground := bgColor.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1941
                hilightFgColor := bgColor.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1942
                hilightBgColor := fgColor.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1943
            ] ifFalse:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1944
                (hilightStyle == #openwin) ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1945
                    hilightFgColor := fgColor.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1946
                    hilightBgColor := Color grey.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1947
                ]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1948
            ]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1949
        ]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1950
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1951
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1952
    hilightFgColor isNil ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1953
        hilightFgColor := bgColor.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1954
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1955
    hilightBgColor isNil ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1956
        hilightBgColor := fgColor.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1957
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1958
    DefaultForegroundColor notNil ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1959
        fgColor := DefaultForegroundColor
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1960
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1961
    DefaultBackgroundColor notNil ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1962
        bgColor := viewBackground := DefaultBackgroundColor
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1963
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1964
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1965
    DefaultHilightForegroundColor notNil ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1966
        hilightFgColor := DefaultHilightForegroundColor
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1967
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1968
    DefaultHilightBackgroundColor notNil ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1969
        hilightBgColor := DefaultHilightBackgroundColor
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1970
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1971
    DefaultHilightFrameColor notNil ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1972
        hilightFrameColor := DefaultHilightFrameColor
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1973
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1974
1741
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
  1975
    hilightLevel := DefaultHilightLevel ? 0.
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
  1976
    lineSpacing  := (hilightLevel abs > 0) ifTrue:[3] ifFalse:[2].
d928cdc5f4e5 add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents: 1739
diff changeset
  1977
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1978
    hilightFgColor isNil ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1979
        hilightFgColor := bgColor.
3137
7e8fae56b94c highlight selection dependent on has focus
ca
parents: 3081
diff changeset
  1980
        hilightBgColor := fgColor.
7e8fae56b94c highlight selection dependent on has focus
ca
parents: 3081
diff changeset
  1981
    ].
7e8fae56b94c highlight selection dependent on has focus
ca
parents: 3081
diff changeset
  1982
7e8fae56b94c highlight selection dependent on has focus
ca
parents: 3081
diff changeset
  1983
    hilightFgColorNoFocus isNil ifTrue:[
7e8fae56b94c highlight selection dependent on has focus
ca
parents: 3081
diff changeset
  1984
        hilightFgColorNoFocus := hilightFgColor.
7e8fae56b94c highlight selection dependent on has focus
ca
parents: 3081
diff changeset
  1985
    ].
7e8fae56b94c highlight selection dependent on has focus
ca
parents: 3081
diff changeset
  1986
    hilightBgColorNoFocus isNil ifTrue:[
7e8fae56b94c highlight selection dependent on has focus
ca
parents: 3081
diff changeset
  1987
        hilightBgColorNoFocus := hilightBgColor lightened.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1988
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1989
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1990
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1991
initialize
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1992
    "setup default attributes/behavior
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1993
    "
2418
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1994
    multipleSelectOk     := false.
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1995
    useIndex             := true.
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1996
    ignoreReselect       := true.
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1997
    toggleSelect         := false.
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1998
    highlightEnterItem   := false.
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  1999
    strikeOut            := false.
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  2000
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  2001
    keyActionStyle       := #select.
14a9dbec8434 support of #keyActionStyle #returnKeyActionStyle #strikeOut
ca
parents: 2416
diff changeset
  2002
    returnKeyActionStyle := #doubleClick.
2324
ada66df6ac14 support of highlighting items under mouse
ca
parents: 2323
diff changeset
  2003
ada66df6ac14 support of highlighting items under mouse
ca
parents: 2323
diff changeset
  2004
    super initialize.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2005
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2006
1745
4eb3b6b12c99 make selection visible after mapped
ca
parents: 1741
diff changeset
  2007
mapped
4eb3b6b12c99 make selection visible after mapped
ca
parents: 1741
diff changeset
  2008
    "get selection from model; scroll to selection
4eb3b6b12c99 make selection visible after mapped
ca
parents: 1741
diff changeset
  2009
    "
4eb3b6b12c99 make selection visible after mapped
ca
parents: 1741
diff changeset
  2010
    super mapped.
4eb3b6b12c99 make selection visible after mapped
ca
parents: 1741
diff changeset
  2011
    self makeSelectionVisible.
4eb3b6b12c99 make selection visible after mapped
ca
parents: 1741
diff changeset
  2012
!
4eb3b6b12c99 make selection visible after mapped
ca
parents: 1741
diff changeset
  2013
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2014
realize
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2015
    "get selection from model; scroll to selection
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2016
    "
2302
5a2a1d5d09f8 remove asynchronous handling of changes; always disabled because doesn't work
ca
parents: 2275
diff changeset
  2017
    self updateFromModel.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2018
    super realize.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2019
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2020
2493
8b70a26f1694 method category rename
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  2021
!SelectionInListModelView methodsFor:'private-editor'!
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2022
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2023
computeEditorLayout
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2024
    "update the layout of the editor
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2025
    "
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2026
    |lnNr item y x h|
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2027
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2028
    editorView isNil ifTrue:[
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2029
        ^ self
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2030
    ].
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2031
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2032
    (    (lnNr := self selectedIndex) == 0
2408
8b0d11537dc0 accessing list indirect
ca
parents: 2404
diff changeset
  2033
     or:[(item := self at:lnNr ifAbsent:nil) isNil]
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2034
    ) ifTrue:[
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2035
        "/ there is no more single selection; thus close the editor
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2036
        ^ self closeEditor
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2037
    ].
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2038
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2039
    y := self yVisibleOfLine:lnNr.
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2040
    x := (self xVisibleOfItem:item) - (textStartLeft // 2).
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2041
    h := self yVisibleOfLine:(lnNr + 1).
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2042
2632
48a2b5f7d091 *** empty log message ***
martin
parents: 2613
diff changeset
  2043
    "/ Changed by cg:
48a2b5f7d091 *** empty log message ***
martin
parents: 2613
diff changeset
  2044
    "/ editorView layout:( Rectangle left:x top:y right:(width - 1 - margin) bottom:(h + 2 "- 1") ).
48a2b5f7d091 *** empty log message ***
martin
parents: 2613
diff changeset
  2045
    editorView layout:( Rectangle left:x top:y-2 right:(width - 1 - margin) bottom:(h "- 1") ).
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2046
!
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2047
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2048
openEditorAtX:x y:y
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2049
    "opens an editor on the current single selection
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2050
    "
2225
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
  2051
    |item lnNr x0 y0 editor|
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2052
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2053
    self closeEditor.
2308
c012b16422f0 replace ifNotNil: by notNil ifTrue:
ca
parents: 2302
diff changeset
  2054
    shown ifFalse:[^ self ].
2596
771e23c6d9cf access actions by call and not by reference
ca
parents: 2572
diff changeset
  2055
    self openEditorAction isNil ifTrue:[^ self].
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2056
2225
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
  2057
    lnNr := self selectedIndex.
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
  2058
    lnNr == 0 ifTrue:[^ self].
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
  2059
2408
8b0d11537dc0 accessing list indirect
ca
parents: 2404
diff changeset
  2060
    item := self at:lnNr ifAbsent:nil.
2308
c012b16422f0 replace ifNotNil: by notNil ifTrue:
ca
parents: 2302
diff changeset
  2061
    item isNil ifTrue:[^ self].
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2062
1915
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
  2063
    x < (self xVisibleOfItem:item) ifTrue:[
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
  2064
        "/ not part of the selection frame; ignorre
2f57720597d3 bug fix when opening editor on current selected line
ca
parents: 1909
diff changeset
  2065
        ^ self
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2066
    ].
2225
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
  2067
    editor := self openEditor.
2308
c012b16422f0 replace ifNotNil: by notNil ifTrue:
ca
parents: 2302
diff changeset
  2068
    editor isNil ifTrue:[^ self].
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2069
2225
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
  2070
    y0 := (y - editor origin y) max:0.
d785c9d86aa3 make selection visible if size changed
penk
parents: 2185
diff changeset
  2071
    x0 := (x - editor origin x) max:0.
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2072
2125
67e0f2c9ad4d event types are private to WindowEvent;
ca
parents: 2070
diff changeset
  2073
    "/ simulate clicking into the editor
2632
48a2b5f7d091 *** empty log message ***
martin
parents: 2613
diff changeset
  2074
48a2b5f7d091 *** empty log message ***
martin
parents: 2613
diff changeset
  2075
    "/ Changed by cg:
48a2b5f7d091 *** empty log message ***
martin
parents: 2613
diff changeset
  2076
    "/ but only if there was no initial selection
48a2b5f7d091 *** empty log message ***
martin
parents: 2613
diff changeset
  2077
    editor isInputField ifTrue:[
48a2b5f7d091 *** empty log message ***
martin
parents: 2613
diff changeset
  2078
        editor hasSelection ifFalse:[
3345
088090deaffb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3338
diff changeset
  2079
            self sensor 
088090deaffb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3338
diff changeset
  2080
                pushEvent:(WindowEvent buttonPress:#select x:x0 y:y0 view:editor);
088090deaffb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3338
diff changeset
  2081
                pushEvent:(WindowEvent buttonRelease:#select x:x0 y:y0 view:editor).
2632
48a2b5f7d091 *** empty log message ***
martin
parents: 2613
diff changeset
  2082
        ]
48a2b5f7d091 *** empty log message ***
martin
parents: 2613
diff changeset
  2083
    ].
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2084
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2085
    "/ to clear the selection
2245
546c6e5d0951 change #redrawSelectionAt: to #invalidateSelectionAt: (because is a invalidate)
ca
parents: 2228
diff changeset
  2086
    self invalidateLineAt:lnNr.
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2087
! !
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2088
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2089
!SelectionInListModelView methodsFor:'protocol'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2090
1458
02d7889dfb9a lostSynchronisation
Claus Gittinger <cg@exept.de>
parents: 1431
diff changeset
  2091
lostSynchronisation
02d7889dfb9a lostSynchronisation
Claus Gittinger <cg@exept.de>
parents: 1431
diff changeset
  2092
    "called when the changes derived from the model are faster than the handling
02d7889dfb9a lostSynchronisation
Claus Gittinger <cg@exept.de>
parents: 1431
diff changeset
  2093
    "
1547
f72d75aaec14 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
  2094
    self deselectWithoutRedraw.
1458
02d7889dfb9a lostSynchronisation
Claus Gittinger <cg@exept.de>
parents: 1431
diff changeset
  2095
    super lostSynchronisation.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2096
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2097
2330
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2098
!SelectionInListModelView methodsFor:'queries'!
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2099
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2100
isCursorKeyConsumer
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2101
    "return true, if the receiver can be controlled by cursor keys;
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2102
     i.e. it can handle some keyboard input,
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2103
     isCursorKeyConsumer are potential candidates for getting the keyboard
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2104
     focus initially within dialogBoxes, or when the focus-follows-pointer
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2105
     mode is off.
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2106
     Return false here, this is redefined in SelectionInListView."
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2107
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2108
    ^ true
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2109
! !
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2110
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2111
!SelectionInListModelView methodsFor:'selection'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2112
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  2113
addToSelection:lineNr
2410
39ec0844e7d6 discard #toggleSelection:
ca
parents: 2409
diff changeset
  2114
    "add line to selection without scrolling but raise a change notification
39ec0844e7d6 discard #toggleSelection:
ca
parents: 2409
diff changeset
  2115
    "
39ec0844e7d6 discard #toggleSelection:
ca
parents: 2409
diff changeset
  2116
    |oldSelect forAdd|
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  2117
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  2118
    (self isInSelection:lineNr) ifTrue:[
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  2119
        ^ self
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  2120
    ].
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  2121
2410
39ec0844e7d6 discard #toggleSelection:
ca
parents: 2409
diff changeset
  2122
    multipleSelectOk ifTrue:[ forAdd := selection notNil ]
39ec0844e7d6 discard #toggleSelection:
ca
parents: 2409
diff changeset
  2123
                    ifFalse:[ forAdd := false ].
39ec0844e7d6 discard #toggleSelection:
ca
parents: 2409
diff changeset
  2124
39ec0844e7d6 discard #toggleSelection:
ca
parents: 2409
diff changeset
  2125
    (self canSelectIndex:lineNr forAdd:forAdd) ifFalse:[
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  2126
        ^ self
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  2127
    ].
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  2128
2410
39ec0844e7d6 discard #toggleSelection:
ca
parents: 2409
diff changeset
  2129
    self closeEditor.
39ec0844e7d6 discard #toggleSelection:
ca
parents: 2409
diff changeset
  2130
    self cursorEntersItem:nil.
39ec0844e7d6 discard #toggleSelection:
ca
parents: 2409
diff changeset
  2131
39ec0844e7d6 discard #toggleSelection:
ca
parents: 2409
diff changeset
  2132
    multipleSelectOk ifFalse:[
39ec0844e7d6 discard #toggleSelection:
ca
parents: 2409
diff changeset
  2133
        oldSelect := selection.
39ec0844e7d6 discard #toggleSelection:
ca
parents: 2409
diff changeset
  2134
        selection := lineNr.
39ec0844e7d6 discard #toggleSelection:
ca
parents: 2409
diff changeset
  2135
        oldSelect notNil ifTrue:[ self invalidateSelectionAt:oldSelect ].
39ec0844e7d6 discard #toggleSelection:
ca
parents: 2409
diff changeset
  2136
    ] ifTrue:[
39ec0844e7d6 discard #toggleSelection:
ca
parents: 2409
diff changeset
  2137
        selection notNil ifTrue:[ selection := selection copyWith:lineNr ]
39ec0844e7d6 discard #toggleSelection:
ca
parents: 2409
diff changeset
  2138
                        ifFalse:[ selection := OrderedCollection with:lineNr ].
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  2139
    ].
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  2140
    self invalidateSelectionAt:lineNr.
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  2141
    self selectionChanged.
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  2142
!
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  2143
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2144
deselect
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2145
    "clear selection
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2146
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2147
    self selection:nil
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2148
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2149
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2150
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2151
firstInSelection
2399
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2152
    "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
  2153
    "
2409
68095c891ceb reuse selection methods (prepared for common controller)
ca
parents: 2408
diff changeset
  2154
    |min|
2365
bdf6954a0358 key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents: 2361
diff changeset
  2155
2409
68095c891ceb reuse selection methods (prepared for common controller)
ca
parents: 2408
diff changeset
  2156
    multipleSelectOk   ifFalse:[ ^ selection ].
68095c891ceb reuse selection methods (prepared for common controller)
ca
parents: 2408
diff changeset
  2157
    selection size == 0 ifTrue:[ ^ nil ].
2365
bdf6954a0358 key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents: 2361
diff changeset
  2158
bdf6954a0358 key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents: 2361
diff changeset
  2159
    min := selection at:1.
2409
68095c891ceb reuse selection methods (prepared for common controller)
ca
parents: 2408
diff changeset
  2160
    selection do:[:aNumber| min := min min:aNumber ].
2365
bdf6954a0358 key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents: 2361
diff changeset
  2161
    ^ min
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2162
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2163
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2164
hasSelection
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2165
    "returns true if a selection exists
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2166
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2167
    ^ selection notNil
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2168
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2169
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2170
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2171
isInSelection:aNumber
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2172
    "return true, if line, aNumber is in the selection
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2173
    "
1545
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  2174
    multipleSelectOk ifFalse:[
2409
68095c891ceb reuse selection methods (prepared for common controller)
ca
parents: 2408
diff changeset
  2175
        ^ (aNumber == selection)
1545
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  2176
    ].
2409
68095c891ceb reuse selection methods (prepared for common controller)
ca
parents: 2408
diff changeset
  2177
    selection notNil ifTrue:[
68095c891ceb reuse selection methods (prepared for common controller)
ca
parents: 2408
diff changeset
  2178
        ^ selection includesIdentical:aNumber
68095c891ceb reuse selection methods (prepared for common controller)
ca
parents: 2408
diff changeset
  2179
    ].
68095c891ceb reuse selection methods (prepared for common controller)
ca
parents: 2408
diff changeset
  2180
    ^ false
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2181
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2182
2274
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  2183
isSelectionVisible
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  2184
    "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
  2185
2409
68095c891ceb reuse selection methods (prepared for common controller)
ca
parents: 2408
diff changeset
  2186
    ^ self isSelectionVisibleIn:(self extent)
2274
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  2187
!
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  2188
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  2189
isSelectionVisibleIn:anExtentPoint
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  2190
    "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
  2191
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  2192
    self selectionDo:[:aLineNr|
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  2193
        (self isLineVisible:aLineNr in:anExtentPoint) ifTrue:[^ true].
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  2194
    ].
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  2195
    ^ false
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  2196
!
c973acbc021d only make selection visible after a resize, if it was visible before
ca
parents: 2250
diff changeset
  2197
2330
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2198
lastInSelection
2399
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2199
    "returns the maximum index of selected indices or nil if nothing is selected
2330
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2200
    "
2409
68095c891ceb reuse selection methods (prepared for common controller)
ca
parents: 2408
diff changeset
  2201
    |max|
2330
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2202
2409
68095c891ceb reuse selection methods (prepared for common controller)
ca
parents: 2408
diff changeset
  2203
    multipleSelectOk   ifFalse:[ ^ selection ].
68095c891ceb reuse selection methods (prepared for common controller)
ca
parents: 2408
diff changeset
  2204
    selection size == 0 ifTrue:[ ^ nil ].
2330
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2205
2365
bdf6954a0358 key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents: 2361
diff changeset
  2206
    max := 1.
bdf6954a0358 key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents: 2361
diff changeset
  2207
    selection do:[:aNumber| max := max max:aNumber ].
bdf6954a0358 key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents: 2361
diff changeset
  2208
    ^ max
2330
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2209
!
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2210
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2211
makeSelectionVisible
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2212
    "scroll to make the selection line visible
3202
11de451bc538 *** empty log message ***
ca
parents: 3146
diff changeset
  2213
     dont scroll, if any in the selection isVisible
2330
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2214
    "
3202
11de451bc538 *** empty log message ***
ca
parents: 3146
diff changeset
  2215
    |firstLine|
11de451bc538 *** empty log message ***
ca
parents: 3146
diff changeset
  2216
11de451bc538 *** empty log message ***
ca
parents: 3146
diff changeset
  2217
    shown ifFalse:[^ self].
11de451bc538 *** empty log message ***
ca
parents: 3146
diff changeset
  2218
3205
7ff2e20b37d4 *** empty log message ***
ca
parents: 3202
diff changeset
  2219
    modelChangedDuringButtonPress notNil ifTrue:[^ self].
7ff2e20b37d4 *** empty log message ***
ca
parents: 3202
diff changeset
  2220
3202
11de451bc538 *** empty log message ***
ca
parents: 3146
diff changeset
  2221
    firstLine := self firstInSelection.
11de451bc538 *** empty log message ***
ca
parents: 3146
diff changeset
  2222
    (firstLine isNil or:[firstLine == 0]) ifTrue:[^ self].
11de451bc538 *** empty log message ***
ca
parents: 3146
diff changeset
  2223
11de451bc538 *** empty log message ***
ca
parents: 3146
diff changeset
  2224
    self selectionDo:[:aLnNr|
11de451bc538 *** empty log message ***
ca
parents: 3146
diff changeset
  2225
        (self lineIsFullyVisible:aLnNr) ifTrue:[^ self].
11de451bc538 *** empty log message ***
ca
parents: 3146
diff changeset
  2226
    ].    
2368
8101aa8d50d2 cursor select behaviour in: #keyPress:x:y:
ca
parents: 2365
diff changeset
  2227
    self makeLineVisible:(self firstInSelection).
2365
bdf6954a0358 key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents: 2361
diff changeset
  2228
!
bdf6954a0358 key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents: 2361
diff changeset
  2229
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2230
numberOfSelections
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2231
    "return the number of selected items
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2232
    "
2330
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2233
    selection isNil   ifTrue:[ ^ 0 ].
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2234
    multipleSelectOk ifFalse:[ ^ 1 ].
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2235
  ^ selection size
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2236
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2237
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  2238
removeFromSelection:lineNr
2410
39ec0844e7d6 discard #toggleSelection:
ca
parents: 2409
diff changeset
  2239
    "remove line from selection without scrolling but raise a change notification
39ec0844e7d6 discard #toggleSelection:
ca
parents: 2409
diff changeset
  2240
    "
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  2241
    (self isInSelection:lineNr) ifFalse:[
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  2242
        ^ self
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  2243
    ].
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  2244
    self closeEditor.
2410
39ec0844e7d6 discard #toggleSelection:
ca
parents: 2409
diff changeset
  2245
    self cursorEntersItem:nil.
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  2246
2410
39ec0844e7d6 discard #toggleSelection:
ca
parents: 2409
diff changeset
  2247
    (multipleSelectOk and:[self numberOfSelections > 1]) ifTrue:[
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  2248
        selection := selection copyWithout:lineNr.
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  2249
    ] ifFalse:[
2410
39ec0844e7d6 discard #toggleSelection:
ca
parents: 2409
diff changeset
  2250
        selection := nil
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  2251
    ].
2410
39ec0844e7d6 discard #toggleSelection:
ca
parents: 2409
diff changeset
  2252
    self invalidateSelectionAt:lineNr.
39ec0844e7d6 discard #toggleSelection:
ca
parents: 2409
diff changeset
  2253
    self selectionChanged.
2401
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  2254
!
c0c3b44afb43 mouse handling
ca
parents: 2399
diff changeset
  2255
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2256
selectElement:anElement
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2257
    "select the element. Scroll to make the new selection visible.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2258
     Model and/or actionBlock notification IS done.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2259
    "
2178
f02ca1516c04 selectElement changed
penk
parents: 2148
diff changeset
  2260
    self selectElement:anElement ifAbsent:[self deselect]
f02ca1516c04 selectElement changed
penk
parents: 2148
diff changeset
  2261
!
f02ca1516c04 selectElement changed
penk
parents: 2148
diff changeset
  2262
f02ca1516c04 selectElement changed
penk
parents: 2148
diff changeset
  2263
selectElement:anElement ifAbsent:exceptionalValue
f02ca1516c04 selectElement changed
penk
parents: 2148
diff changeset
  2264
    |idx|
f02ca1516c04 selectElement changed
penk
parents: 2148
diff changeset
  2265
2408
8b0d11537dc0 accessing list indirect
ca
parents: 2404
diff changeset
  2266
    idx := self identityIndexOf:anElement.
2178
f02ca1516c04 selectElement changed
penk
parents: 2148
diff changeset
  2267
    idx == 0 ifTrue:[
f02ca1516c04 selectElement changed
penk
parents: 2148
diff changeset
  2268
        ^ exceptionalValue value
f02ca1516c04 selectElement changed
penk
parents: 2148
diff changeset
  2269
    ].
f02ca1516c04 selectElement changed
penk
parents: 2148
diff changeset
  2270
    self selection:idx
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2271
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2272
2399
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2273
selectFrom:aStart to:aStop
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2274
    "select lines between start and stop
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2275
    "
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2276
    |start stop step nsel|
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2277
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2278
    multipleSelectOk ifFalse:[^ self].
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2279
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2280
    start := aStart.
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2281
    stop  := aStop.
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2282
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2283
    aStart < aStop ifTrue:[
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2284
        start := aStart max:1.
2408
8b0d11537dc0 accessing list indirect
ca
parents: 2404
diff changeset
  2285
        stop  := aStop  min:(self size).
2399
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2286
        step  := 1.
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2287
        start > stop ifTrue:[^ self].
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2288
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2289
    ] ifFalse:[
2408
8b0d11537dc0 accessing list indirect
ca
parents: 2404
diff changeset
  2290
        start := aStart min:(self size).
2399
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2291
        stop  := aStop  max:1.
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2292
        step  := -1.
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2293
        start < stop ifTrue:[^ self].
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2294
    ].
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2295
    nsel := OrderedCollection new.
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2296
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2297
    start to:stop by:step do:[:i|
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2298
        (self canSelectIndex:i forAdd:true) ifTrue:[
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2299
            nsel add:i.
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2300
        ].
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2301
    ].
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2302
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2303
    (self selectWithoutScroll:nsel redraw:true) ifTrue:[
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2304
        self selectionChanged
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2305
    ].
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2306
!
949ec827ab3a button handle shift pressed
ca
parents: 2381
diff changeset
  2307
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2308
selectedElement
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2309
    "return the single selected item or nil
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2310
    "
1545
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  2311
    |index|
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2312
1545
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  2313
    (index := self selectedIndex) ~~ 0 ifTrue:[
2408
8b0d11537dc0 accessing list indirect
ca
parents: 2404
diff changeset
  2314
        ^ self at:index ifAbsent:nil
1545
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  2315
    ].
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  2316
    ^ nil
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2317
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2318
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2319
selectedIndex
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2320
    "returns the index of the selected line or 0. If more
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2321
     lines are selected, 0 is returned
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2322
    "
2365
bdf6954a0358 key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents: 2361
diff changeset
  2323
    selection notNil ifTrue:[
bdf6954a0358 key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents: 2361
diff changeset
  2324
        multipleSelectOk ifFalse:[ ^ selection ].
bdf6954a0358 key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents: 2361
diff changeset
  2325
bdf6954a0358 key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents: 2361
diff changeset
  2326
        selection size == 1 ifTrue:[
bdf6954a0358 key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents: 2361
diff changeset
  2327
            ^ selection at:1
bdf6954a0358 key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents: 2361
diff changeset
  2328
        ]
1545
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  2329
    ].
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  2330
    ^ 0
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2331
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2332
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2333
selection
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2334
    "return the selection index or collection of indices 
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2335
     in case of multiple selection enabled
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2336
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2337
    ^ selection
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2338
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2339
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2340
1545
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  2341
selection:something
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  2342
    "select something or deselect if the argument is nil;
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2343
     scroll to make the selected line visible.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2344
     The model and/or actionBlock IS notified.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2345
    "
1545
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  2346
    (self selectWithoutScroll:something redraw:true) ifTrue:[
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  2347
        self makeSelectionVisible.
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2348
        self selectionChanged
1545
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  2349
    ].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2350
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2351
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2352
2330
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2353
selectionAsCollection
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2354
    "return the selection as a collection of line numbers.
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2355
     This allows users of this class to enumerate independent of
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2356
     the multipleSelect style.
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2357
    "
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2358
    selection isNil  ifTrue:[ ^ #() ].
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2359
    multipleSelectOk ifTrue:[ ^ selection ].
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2360
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2361
  ^ OrderedCollection with:selection
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2362
!
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2363
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2364
selectionDo:aBlock
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2365
    "perform aBlock for each nr in the selection.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2366
     For single selection, it is called once for the items nr.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2367
     For multiple selections, it is called for each.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2368
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2369
    selection notNil ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2370
        multipleSelectOk ifTrue:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2371
            selection do:aBlock
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2372
        ] ifFalse:[
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2373
            aBlock value:selection
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2374
        ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2375
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2376
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2377
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2378
!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2379
2330
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2380
selectionValue
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2381
    "return the selection value i.e. the text in the selected line.
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2382
     For multiple selections a collection containing the entries is returned.
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2383
    "
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2384
    multipleSelectOk ifTrue:[
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2385
        selection isNil ifTrue:[^ #()].
2408
8b0d11537dc0 accessing list indirect
ca
parents: 2404
diff changeset
  2386
        ^ selection collect:[:nr| self at:nr ]
2330
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2387
    ].
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2388
    selection isNil ifTrue:[^ nil].
2408
8b0d11537dc0 accessing list indirect
ca
parents: 2404
diff changeset
  2389
    ^ self at:selection ifAbsent:nil.
2330
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2390
!
7d83a6a7728b *** empty log message ***
ca
parents: 2324
diff changeset
  2391
2346
b15af0e8dacc add #selectionValueAsCollection
ca
parents: 2333
diff changeset
  2392
selectionValueAsCollection
b15af0e8dacc add #selectionValueAsCollection
ca
parents: 2333
diff changeset
  2393
    "return the selection values as a collection - allows selectionValues to
b15af0e8dacc add #selectionValueAsCollection
ca
parents: 2333
diff changeset
  2394
     be enumerated independent of the multiSelect settings
b15af0e8dacc add #selectionValueAsCollection
ca
parents: 2333
diff changeset
  2395
    "
b15af0e8dacc add #selectionValueAsCollection
ca
parents: 2333
diff changeset
  2396
    |value|
b15af0e8dacc add #selectionValueAsCollection
ca
parents: 2333
diff changeset
  2397
b15af0e8dacc add #selectionValueAsCollection
ca
parents: 2333
diff changeset
  2398
    value := self selectionValue.
b15af0e8dacc add #selectionValueAsCollection
ca
parents: 2333
diff changeset
  2399
    multipleSelectOk ifTrue:[^ value].
b15af0e8dacc add #selectionValueAsCollection
ca
parents: 2333
diff changeset
  2400
b15af0e8dacc add #selectionValueAsCollection
ca
parents: 2333
diff changeset
  2401
    value notNil ifTrue:[^ Array with:value ].
b15af0e8dacc add #selectionValueAsCollection
ca
parents: 2333
diff changeset
  2402
  ^ #()
b15af0e8dacc add #selectionValueAsCollection
ca
parents: 2333
diff changeset
  2403
!
b15af0e8dacc add #selectionValueAsCollection
ca
parents: 2333
diff changeset
  2404
1542
8607d072c319 accessing selection through to selector
Claus Gittinger <cg@exept.de>
parents: 1537
diff changeset
  2405
setSelection:something
1545
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  2406
    "select something or deselect if the argument is nil;
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2407
     scroll to make the selected line visible.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2408
     *** No model and/or actionBlock notification is done here.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2409
    "
1545
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  2410
    (self selectWithoutScroll:something redraw:true) ifTrue:[
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2411
        self makeSelectionVisible
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2412
    ]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2413
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2414
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2415
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2416
!SelectionInListModelView methodsFor:'selection private'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2417
1641
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
  2418
canSelectIndex:anIndex
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
  2419
    "return true, if the object identified by its index is selectable
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
  2420
    "
1920
e3994a83fb16 selectConditionBlock can be a 2-arg block;
martin
parents: 1917
diff changeset
  2421
    ^ self canSelectIndex:anIndex forAdd:false
e3994a83fb16 selectConditionBlock can be a 2-arg block;
martin
parents: 1917
diff changeset
  2422
!
e3994a83fb16 selectConditionBlock can be a 2-arg block;
martin
parents: 1917
diff changeset
  2423
e3994a83fb16 selectConditionBlock can be a 2-arg block;
martin
parents: 1917
diff changeset
  2424
canSelectIndex:anIndex forAdd:isForAdd
e3994a83fb16 selectConditionBlock can be a 2-arg block;
martin
parents: 1917
diff changeset
  2425
    "return true, if the object identified by its index is selectable
e3994a83fb16 selectConditionBlock can be a 2-arg block;
martin
parents: 1917
diff changeset
  2426
    "
e3994a83fb16 selectConditionBlock can be a 2-arg block;
martin
parents: 1917
diff changeset
  2427
    |item isOk|
1649
60cf82a7d585 checkin from browser
ps
parents: 1644
diff changeset
  2428
60cf82a7d585 checkin from browser
ps
parents: 1644
diff changeset
  2429
    selectConditionBlock notNil ifTrue:[
2416
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
  2430
        isOk := selectConditionBlock valueWithOptionalArgument:anIndex and:isForAdd.
dd563121a967 instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents: 2413
diff changeset
  2431
1920
e3994a83fb16 selectConditionBlock can be a 2-arg block;
martin
parents: 1917
diff changeset
  2432
        isOk ifFalse:[
1649
60cf82a7d585 checkin from browser
ps
parents: 1644
diff changeset
  2433
            ^ false
60cf82a7d585 checkin from browser
ps
parents: 1644
diff changeset
  2434
        ]
1641
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
  2435
    ].
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
  2436
2408
8b0d11537dc0 accessing list indirect
ca
parents: 2404
diff changeset
  2437
    item := self at:anIndex ifAbsent:nil.
1752
1c11b6e4ab37 use isHierarchicalItem instead of hack variable
ca
parents: 1748
diff changeset
  2438
    item isNil ifTrue:[^ false].
2408
8b0d11537dc0 accessing list indirect
ca
parents: 2404
diff changeset
  2439
1752
1c11b6e4ab37 use isHierarchicalItem instead of hack variable
ca
parents: 1748
diff changeset
  2440
    item isHierarchicalItem ifTrue:[
2408
8b0d11537dc0 accessing list indirect
ca
parents: 2404
diff changeset
  2441
        ^ item isSelectable
1649
60cf82a7d585 checkin from browser
ps
parents: 1644
diff changeset
  2442
    ].
60cf82a7d585 checkin from browser
ps
parents: 1644
diff changeset
  2443
    ^ true
1641
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
  2444
!
22dc37288c14 add selectConditionBlock
ca
parents: 1599
diff changeset
  2445
1547
f72d75aaec14 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
  2446
deselectWithoutRedraw
f72d75aaec14 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
  2447
    "clear the selection without redraw and scrolling;
f72d75aaec14 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
  2448
     the model and/or actionBlock is notified
f72d75aaec14 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
  2449
    "
f72d75aaec14 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
  2450
    (self selectWithoutScroll:nil redraw:false) ifTrue:[
f72d75aaec14 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
  2451
        self selectionChanged
f72d75aaec14 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
  2452
    ]
f72d75aaec14 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
  2453
!
f72d75aaec14 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
  2454
3370
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
  2455
selectAndUpdateModelWithoutChangeNotification: aLineNo
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
  2456
    |arg|
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
  2457
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
  2458
    self selectWithoutScroll:aLineNo redraw:true.
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
  2459
    modelChangedDuringButtonPress := false.
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
  2460
    model isNil ifTrue:[ ^ self ].
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
  2461
    arg := self argForChangeMessage.
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
  2462
    self sendChangeMessage:#setValue: with:arg.
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
  2463
!
5199f62a817d Add posibility to configure the select behaviour (select on button press
ab
parents: 3367
diff changeset
  2464
1545
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  2465
selectWithoutScroll:something redraw:doRedraw
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  2466
    "change selection to something; returns true if selection changed
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2467
    "
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2468
    |oldSelect|
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2469
1554
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  2470
    selection = something ifTrue:[^ false].
c45cac3c4d31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
  2471
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2472
    oldSelect := selection.
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2473
1545
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  2474
    (something isNil or:[something == 0]) ifTrue:[
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  2475
        selection := nil
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  2476
    ] ifFalse:[
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  2477
        something isNumber ifTrue:[
1564
6c73d2b8c0e7 checkin from browser
ca
parents: 1563
diff changeset
  2478
            selection := multipleSelectOk ifTrue:[Array with:something]
6c73d2b8c0e7 checkin from browser
ca
parents: 1563
diff changeset
  2479
                                         ifFalse:[something]
1545
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  2480
        ] ifFalse:[
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  2481
            something size == 0 ifTrue:[
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  2482
                selection := nil
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  2483
            ] ifFalse:[
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  2484
                selection := multipleSelectOk ifTrue:[something]
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  2485
                                             ifFalse:[something at:1]
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  2486
            ]
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  2487
        ]
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  2488
    ].
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  2489
    selection = oldSelect ifTrue:[^ false].
3205
7ff2e20b37d4 *** empty log message ***
ca
parents: 3202
diff changeset
  2490
7ff2e20b37d4 *** empty log message ***
ca
parents: 3202
diff changeset
  2491
    modelChangedDuringButtonPress notNil ifTrue:[
7ff2e20b37d4 *** empty log message ***
ca
parents: 3202
diff changeset
  2492
        modelChangedDuringButtonPress := true.
7ff2e20b37d4 *** empty log message ***
ca
parents: 3202
diff changeset
  2493
    ].
7ff2e20b37d4 *** empty log message ***
ca
parents: 3202
diff changeset
  2494
1755
cbf87041448d add visible editor
ca
parents: 1752
diff changeset
  2495
    self closeEditor.
2377
6c368b8b0ec3 support cursor movements
ca
parents: 2368
diff changeset
  2496
    self cursorEntersItem:nil.
1545
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  2497
3205
7ff2e20b37d4 *** empty log message ***
ca
parents: 3202
diff changeset
  2498
    
1545
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  2499
    (doRedraw and:[shown]) ifFalse:[
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  2500
        ^ true
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2501
    ].
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2502
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2503
    multipleSelectOk ifFalse:[
2245
546c6e5d0951 change #redrawSelectionAt: to #invalidateSelectionAt: (because is a invalidate)
ca
parents: 2228
diff changeset
  2504
        oldSelect notNil ifTrue:[self invalidateSelectionAt:oldSelect].
546c6e5d0951 change #redrawSelectionAt: to #invalidateSelectionAt: (because is a invalidate)
ca
parents: 2228
diff changeset
  2505
        selection notNil ifTrue:[self invalidateSelectionAt:selection].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2506
    ] ifTrue:[
1545
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  2507
        (selection notNil and:[oldSelect notNil]) ifTrue:[
2245
546c6e5d0951 change #redrawSelectionAt: to #invalidateSelectionAt: (because is a invalidate)
ca
parents: 2228
diff changeset
  2508
            selection do:[:i|(oldSelect includesIdentical:i) ifFalse:[self invalidateSelectionAt:i]].
546c6e5d0951 change #redrawSelectionAt: to #invalidateSelectionAt: (because is a invalidate)
ca
parents: 2228
diff changeset
  2509
            oldSelect do:[:i|(selection includesIdentical:i) ifFalse:[self invalidateSelectionAt:i]].
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2510
        ] ifFalse:[
1545
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  2511
            oldSelect isNil ifTrue:[oldSelect := selection].
2245
546c6e5d0951 change #redrawSelectionAt: to #invalidateSelectionAt: (because is a invalidate)
ca
parents: 2228
diff changeset
  2512
            oldSelect do:[:i|self invalidateSelectionAt:i]
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2513
        ]
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2514
    ].
1545
65ae8d6b416e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
  2515
    ^ true
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2516
! !
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2517
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2518
!SelectionInListModelView class methodsFor:'documentation'!
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2519
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2520
version
3438
a8ce9823cc1e english
Claus Gittinger <cg@exept.de>
parents: 3391
diff changeset
  2521
    ^ '$Header: /cvs/stx/stx/libwidg2/SelectionInListModelView.st,v 1.133 2008-06-06 08:41:00 cg Exp $'
1390
62dc950b9140 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2522
! !