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