--- a/SelectionInListModelView.st Tue Aug 04 14:15:20 2009 +0200
+++ b/SelectionInListModelView.st Fri Aug 07 12:50:41 2009 +0200
@@ -1,6 +1,6 @@
"
COPYRIGHT (c) 1999 by eXept Software AG
- All Rights Reserved
+ All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
@@ -42,13 +42,13 @@
top := StandardSystemView new; extent:300@300.
view := ScrollableView for:SelectionInListModelView miniScroller:true
- origin:0.0@0.0 corner:1.0@1.0 in:top.
+ origin:0.0@0.0 corner:1.0@1.0 in:top.
view minimumEditorHeight:100.
view openEditorAction:[:ln :aGC| |f|
- f := SimpleView in:aGC.
- f viewBackground:(Color red).
- f
+ f := SimpleView in:aGC.
+ f viewBackground:(Color red).
+ f
].
view list:list.
top open.
@@ -57,7 +57,7 @@
copyright
"
COPYRIGHT (c) 1999 by eXept Software AG
- All Rights Reserved
+ All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
@@ -77,58 +77,58 @@
[Instance variables:]
- selection <misc> the current selection. nil, a number or collection of numbers
- multipleSelectOk <Boolean> allow/disallow multiple selections( default:false )
- selectOnButtonMenu <Boolean> enable/disable selection will change on menu pressed
-
- buttonReleaseAction <Action> called if the mouse button is released
- buttonMotionAction <Action> called during mouse motion with one argument the point
- under the mouse.
-
- actionBlock <Block> action evaluated on single click (0/1/2 arguments)
- doubleClickActionBlock <Block> action evaluated on double click (0/1/2 arguments)
- selectConditionBlock <Block> action evaluated before selection changed (0/1/2 arguments)
-
- keyActionStyle <Symbol> controls how to respond to keyboard selects
- returnKeyActionStyle <Symbol> controls how to respond to return key
-
- useIndex <Boolean> representation of the model selection
-
- ignoreReselect <Boolean> if set, a click on an already selected entry is ignored
- toggleSelect <Boolean> a click on an entry unselects it and vice versa
-
- highlightMode <Symbol> how to draw the selection
- hilightFgColor <Color> foregroundColor of highlighted items
- hilightBgColor <Color> backgroundColor of highlighted items
- hilightLevel <Integer> level to draw selections (i.e. for 3D effect)
- hilightFrameColor <Color> rectangle around highlighted items
- hilightStyle <Boolean> actions on widget are enabled/disabled
- strikeOut <Boolean> turn on/off strikeOut mode
-
- dropTarget <DropTarget> keeps information about the drop operation
- dropSource <DropSource> keeps information about the drag operation
-
- editorView <View> editor on current selected item
- openEditorAction <Action> action to get an editor on the current selection from user
- closeEditorAction <Action> action invoked before the editor is closed.
-
- enterItem <Item/nil> item over which the mouse pointer is located
- or nil
- highlightEnterItem <Boolean> enable or disable highlight of enterItem
+ selection <misc> the current selection. nil, a number or collection of numbers
+ multipleSelectOk <Boolean> allow/disallow multiple selections( default:false )
+ selectOnButtonMenu <Boolean> enable/disable selection will change on menu pressed
+
+ buttonReleaseAction <Action> called if the mouse button is released
+ buttonMotionAction <Action> called during mouse motion with one argument the point
+ under the mouse.
+
+ actionBlock <Block> action evaluated on single click (0/1/2 arguments)
+ doubleClickActionBlock <Block> action evaluated on double click (0/1/2 arguments)
+ selectConditionBlock <Block> action evaluated before selection changed (0/1/2 arguments)
+
+ keyActionStyle <Symbol> controls how to respond to keyboard selects
+ returnKeyActionStyle <Symbol> controls how to respond to return key
+
+ useIndex <Boolean> representation of the model selection
+
+ ignoreReselect <Boolean> if set, a click on an already selected entry is ignored
+ toggleSelect <Boolean> a click on an entry unselects it and vice versa
+
+ highlightMode <Symbol> how to draw the selection
+ hilightFgColor <Color> foregroundColor of highlighted items
+ hilightBgColor <Color> backgroundColor of highlighted items
+ hilightLevel <Integer> level to draw selections (i.e. for 3D effect)
+ hilightFrameColor <Color> rectangle around highlighted items
+ hilightStyle <Boolean> actions on widget are enabled/disabled
+ strikeOut <Boolean> turn on/off strikeOut mode
+
+ dropTarget <DropTarget> keeps information about the drop operation
+ dropSource <DropSource> keeps information about the drag operation
+
+ editorView <View> editor on current selected item
+ openEditorAction <Action> action to get an editor on the current selection from user
+ closeEditorAction <Action> action invoked before the editor is closed.
+
+ enterItem <Item/nil> item over which the mouse pointer is located
+ or nil
+ highlightEnterItem <Boolean> enable or disable highlight of enterItem
[author:]
- Claus Atzkern
+ Claus Atzkern
[see also:]
- ListModelView
- HierarchicalListView
+ ListModelView
+ HierarchicalListView
"
!
examples
"
- [exBegin]
+ [exBegin]
|top list view|
list := List new.
@@ -136,13 +136,13 @@
1 to:100 do:[:i| list add:('element: ', i printString) ].
top := StandardSystemView new; extent:300@300.
view := ScrollableView for:SelectionInListModelView miniScroller:true
- origin:0.0@0.0 corner:1.0@1.0 in:top.
+ origin:0.0@0.0 corner:1.0@1.0 in:top.
view list:list.
top open.
- [exEnd]
-
-
- [exBegin]
+ [exEnd]
+
+
+ [exBegin]
|top list view|
list := List new.
@@ -150,22 +150,22 @@
1 to:100 do:[:i| list add:('element: ', i printString) ].
top := StandardSystemView new; extent:300@300.
view := ScrollableView for:SelectionInListModelView miniScroller:true
- origin:0.0@0.0 corner:1.0@1.0 in:top.
+ origin:0.0@0.0 corner:1.0@1.0 in:top.
view list:list.
view openEditorAction:[:ln :aGC| |field|
- field := EditField new.
- field level:0.
- field acceptOnLostFocus:true.
- field acceptAction:[:x| list at:ln put:(field contents) ].
- field font:(aGC font).
- field contents:(list at:ln).
- field
+ field := EditField new.
+ field level:0.
+ field acceptOnLostFocus:true.
+ field acceptAction:[:x| list at:ln put:(field contents) ].
+ field font:(aGC font).
+ field contents:(list at:ln).
+ field
].
top open.
- [exEnd]
-
- [exBegin]
+ [exEnd]
+
+ [exBegin]
|top list view item|
list := HierarchicalList new.
@@ -176,12 +176,12 @@
top := StandardSystemView new; extent:300@300.
view := ScrollableView for:SelectionInListModelView miniScroller:true
- origin:0.0@0.0 corner:1.0@1.0 in:top.
+ origin:0.0@0.0 corner:1.0@1.0 in:top.
view list:list.
view doubleClickAction:[:i| (list at:i) toggleExpand ].
top open.
- [exEnd]
+ [exEnd]
"
! !
@@ -192,13 +192,13 @@
"extract values from the styleSheet and cache them in class variables"
<resource: #style (
- #'selection.hilightForegroundColor' #'selection.hilightBackgroundColor'
- #'selection.hilightFrameColor' #'selection.hilightLevel'
- #'selection.foregroundColor' #'selection.backgroundColor'
- #'selection.shadowColor' #'selection.lightColor'
- #'selection.font' #'selection.hilightStyle'
- #'text.foregroundColor'
- )>
+ #'selection.hilightForegroundColor' #'selection.hilightBackgroundColor'
+ #'selection.hilightFrameColor' #'selection.hilightLevel'
+ #'selection.foregroundColor' #'selection.backgroundColor'
+ #'selection.shadowColor' #'selection.lightColor'
+ #'selection.font' #'selection.hilightStyle'
+ #'text.foregroundColor'
+ )>
DefaultHilightForegroundColor := StyleSheet colorAt:'selection.hilightForegroundColor'.
DefaultHilightBackgroundColor := StyleSheet colorAt:'selection.hilightBackgroundColor'.
@@ -211,7 +211,7 @@
DefaultLightColor := StyleSheet colorAt:'selection.lightColor'.
DefaultForegroundColor isNil ifTrue:[
- DefaultForegroundColor := StyleSheet colorAt:'text.foregroundColor' default:Black
+ DefaultForegroundColor := StyleSheet colorAt:'text.foregroundColor' default:Black
].
"
self updateStyleCache
@@ -245,9 +245,9 @@
"get the action block to be performed on select
The arguments to the block are:
- - no argument
- - 1 argument index or item
- - 2 argument index or item, self
+ - no argument
+ - 1 argument index or item
+ - 2 argument index or item, self
"
^ actionBlock
!
@@ -256,9 +256,9 @@
"set the action block to be performed on select
The arguments to the block are:
- - no argument
- - 1 argument index or item
- - 2 argument index or item, self
+ - no argument
+ - 1 argument index or item
+ - 2 argument index or item, self
"
actionBlock := aOneArgAction
!
@@ -267,9 +267,9 @@
"get the action block to be performed on doubleclick.
The arguments to the block are:
- - no argument
- - 1 argument selectedIndex
- - 2 argument selectedIndex, self
+ - no argument
+ - 1 argument selectedIndex
+ - 2 argument selectedIndex, self
"
^ doubleClickActionBlock
!
@@ -278,9 +278,9 @@
"set the action block to be performed on doubleclick.
The arguments to the block are:
- - no argument
- - 1 argument selectedIndex
- - 2 argument selectedIndex, self
+ - no argument
+ - 1 argument selectedIndex
+ - 2 argument selectedIndex, self
"
doubleClickActionBlock := aOneArgAction
!
@@ -288,14 +288,14 @@
keyActionStyle
"defines how the view should respond to alpha-keys pressed.
Possible values are:
- #select -> will select next entry starting with that
- character and perform the click-action
-
- #selectAndDoubleclick -> will select next & perform double-click action
-
- #pass -> will pass key to superclass (i.e. no special treatment)
-
- nil -> will ignore key
+ #select -> will select next entry starting with that
+ character and perform the click-action
+
+ #selectAndDoubleclick -> will select next & perform double-click action
+
+ #pass -> will pass key to superclass (i.e. no special treatment)
+
+ nil -> will ignore key
the default (set in #initialize) is #select
"
@@ -305,14 +305,14 @@
keyActionStyle:aSymbol
"defines how the view should respond to alpha-keys pressed.
Possible values are:
- #select -> will select next entry starting with that
- character and perform the click-action
-
- #selectAndDoubleclick -> will select next & perform double-click action
-
- #pass -> will pass key to superclass (i.e. no special treatment)
-
- nil -> will ignore key
+ #select -> will select next entry starting with that
+ character and perform the click-action
+
+ #selectAndDoubleclick -> will select next & perform double-click action
+
+ #pass -> will pass key to superclass (i.e. no special treatment)
+
+ nil -> will ignore key
the default (set in #initialize) is #select
"
@@ -322,13 +322,13 @@
returnKeyActionStyle
"defines how the view should respond to a return key pressed.
Possible values are:
- #doubleClick -> perform double-click action
-
- #pass -> will pass key to superclass (i.e. no special treatment)
-
- nil -> will ignore key
-
- the default (set in #initialize) is #doubleClick
+ #doubleClick -> perform double-click action
+
+ #pass -> will pass key to superclass (i.e. no special treatment)
+
+ nil -> will ignore key
+
+ the default (set in #initialize) is #doubleClick
"
^ returnKeyActionStyle
!
@@ -336,13 +336,13 @@
returnKeyActionStyle:aSymbol
"defines how the view should respond to a return key pressed.
Possible values are:
- #doubleClick -> perform double-click action
-
- #pass -> will pass key to superclass (i.e. no special treatment)
-
- nil -> will ignore key
-
- the default (set in #initialize) is #doubleClick
+ #doubleClick -> perform double-click action
+
+ #pass -> will pass key to superclass (i.e. no special treatment)
+
+ nil -> will ignore key
+
+ the default (set in #initialize) is #doubleClick
"
returnKeyActionStyle := aSymbol
!
@@ -353,9 +353,9 @@
returns false
The arguments to the block are:
- - no argument
- - 1 argument index
- - 2 argument index, isForAdd
+ - no argument
+ - 1 argument index
+ - 2 argument index, isForAdd
"
^ selectConditionBlock
!
@@ -366,9 +366,9 @@
returns false.
The arguments to the block are:
- - no argument
- - 1 argument index
- - 2 argument index, isForAdd
+ - no argument
+ - 1 argument index
+ - 2 argument index, isForAdd
"
selectConditionBlock := aOneArgBlock.
! !
@@ -385,33 +385,33 @@
"enable or disable to highlight the item over which the mouse pointer is located
"
highlightEnterItem ~~ aBool ifTrue:[
- highlightEnterItem := aBool.
- self pointerEntersItem:nil.
-
- highlightEnterItem ifTrue:[
- self enableMotionEvents
- ].
+ highlightEnterItem := aBool.
+ self pointerEntersItem:nil.
+
+ highlightEnterItem ifTrue:[
+ self enableMotionEvents
+ ].
].
!
highlightMode
"get the mode how to draw a selected line:
- #line draw whole line selected
- #label draw label selected
- #dropMode set during drop
+ #line draw whole line selected
+ #label draw label selected
+ #dropMode set during drop
"
^ highlightMode
!
highlightMode:aMode
"set the mode how to draw a selected line:
- #line draw whole line selected
- #label draw label selected
- #dropMode set during drop
+ #line draw whole line selected
+ #label draw label selected
+ #dropMode set during drop
"
highlightMode ~~ aMode ifTrue:[
- highlightMode := aMode.
- self invalidateSelection.
+ highlightMode := aMode.
+ self invalidateSelection.
].
!
@@ -441,8 +441,8 @@
"turn on/off strikeOut mode
"
strikeOut ~~ aBoolean ifTrue:[
- strikeOut := aBoolean.
- self invalidateSelection.
+ strikeOut := aBoolean.
+ self invalidateSelection.
].
! !
@@ -455,7 +455,7 @@
!
ignoreReselect:aBoolean
- "set/clear the ignoreReselect flag -
+ "set/clear the ignoreReselect flag -
if set, a click on an already selected entry is ignored.
Otherwise the notification is done, even if no
change in the selection occurs.
@@ -492,20 +492,20 @@
multipleSelectOk == state ifTrue:[ ^ self ].
selection isNil ifTrue:[
- multipleSelectOk := state.
- ^ self.
+ multipleSelectOk := state.
+ ^ self.
].
multipleSelectOk ifFalse:[
- selection := Array with:selection.
- multipleSelectOk := true.
- ^ self
+ selection := Array with:selection.
+ multipleSelectOk := true.
+ ^ self
].
selection size == 1 ifTrue:[
- selection := selection first.
+ selection := selection first.
] ifFalse:[
- self selection:nil
+ self selection:nil
].
multipleSelectOk := false.
!
@@ -549,7 +549,7 @@
!
selectOnButtonPress:aBoolean
- "set/clear the selectOnButtonPress flag -
+ "set/clear the selectOnButtonPress flag -
if set (default), the selection changed on button press. This was the
behaviour until now.
if cleared, the selection is changed on button release. This new behaviour allows to start
@@ -565,7 +565,7 @@
on the current selection."
selectOnMenuButton isNil ifTrue:[
- ^ UserPreferences current selectOnRightClick
+ ^ UserPreferences current selectOnRightClick
].
^ selectOnMenuButton
!
@@ -624,10 +624,10 @@
(editor := editorView) notNil ifTrue:[
"/ editorView := nil.
- action := self closeEditorAction.
- action notNil ifTrue:[action value:editor.].
- editor destroy.
- editorView := nil.
+ action := self closeEditorAction.
+ action notNil ifTrue:[action value:editor.].
+ editor destroy.
+ editorView := nil.
].
!
@@ -686,7 +686,7 @@
editorView isNil ifTrue:[^ nil].
editorView superView isNil ifTrue:[
- self addSubView:editorView
+ self addSubView:editorView
].
self computeEditorLayout.
editorView realize.
@@ -734,7 +734,7 @@
super lineChangedAt:aLnNr with:arg.
(editorView notNil and:[aLnNr == self selectedIndex]) ifTrue:[
- self computeEditorLayout.
+ self computeEditorLayout.
]
!
@@ -746,57 +746,57 @@
selection isNil ifTrue:[^ self].
self size == 0 ifTrue:[
- selection := nil.
- ^ self selectionChanged
+ selection := nil.
+ ^ self selectionChanged
].
multipleSelectOk ifFalse:[
- selection < aLnNr ifTrue:[^ self].
-
- selection := selection + aDeltaLines.
-
- (aDeltaLines < 0 and:[selection < aLnNr]) ifTrue:[
- selection := nil.
- ^ self selectionChanged
- ]
+ selection < aLnNr ifTrue:[^ self].
+
+ selection := selection + aDeltaLines.
+
+ (aDeltaLines < 0 and:[selection < aLnNr]) ifTrue:[
+ selection := nil.
+ ^ self selectionChanged
+ ]
] ifTrue:[
- changed := false.
-
- aDeltaLines < 0 ifFalse:[
- selection keysAndValuesDo:[:i :ln|
- ln >= aLnNr ifTrue:[
- changed := true.
- selection at:i put:(ln + aDeltaLines)
- ]
- ]
- ] ifTrue:[
- cnts := 0.
-
- selection keysAndValuesDo:[:i :ln||new|
- ln >= aLnNr ifTrue:[
- changed := true.
-
- (new := ln + aDeltaLines) < aLnNr ifTrue:[
- cnts := cnts + 1.
- new := nil
- ].
- selection at:i put:new
- ]
- ].
- cnts ~~ 0 ifTrue:[
- cnts == selection size ifTrue:[
- selection := nil
- ] ifFalse:[
- selection := selection select:[:ln| ln notNil]
- ].
- ^ self selectionChanged.
- ].
- ].
- changed ifFalse:[^ self].
+ changed := false.
+
+ aDeltaLines < 0 ifFalse:[
+ selection keysAndValuesDo:[:i :ln|
+ ln >= aLnNr ifTrue:[
+ changed := true.
+ selection at:i put:(ln + aDeltaLines)
+ ]
+ ]
+ ] ifTrue:[
+ cnts := 0.
+
+ selection keysAndValuesDo:[:i :ln||new|
+ ln >= aLnNr ifTrue:[
+ changed := true.
+
+ (new := ln + aDeltaLines) < aLnNr ifTrue:[
+ cnts := cnts + 1.
+ new := nil
+ ].
+ selection at:i put:new
+ ]
+ ].
+ cnts ~~ 0 ifTrue:[
+ cnts == selection size ifTrue:[
+ selection := nil
+ ] ifFalse:[
+ selection := selection select:[:ln| ln notNil]
+ ].
+ ^ self selectionChanged.
+ ].
+ ].
+ changed ifFalse:[^ self].
].
(useIndex and:[model notNil]) ifTrue:[
- model setValue:(self argForChangeMessage)
+ model setValue:(self argForChangeMessage)
].
!
@@ -817,26 +817,26 @@
self closeEditor.
(model isNil and:[actionBlock isNil]) ifTrue:[
- ^ self
+ ^ self
].
arg := self argForChangeMessage.
model notNil ifTrue:[
- model removeDependent:self.
- "/ change models value to force a change notification: reselect mode
- arg = model value ifTrue:[
- model setValue:(arg isNil ifTrue:[0] ifFalse:[nil]).
- ].
- self sendChangeMessage:#value: with:arg.
- model notNil ifTrue:[ "/ argggh could be nilled
- model addDependent:self.
- self updateFromModel. "/ care for possibly lost change notification, due to #removeDependent
- ]
+ model removeDependent:self.
+ "/ change models value to force a change notification: reselect mode
+ arg = model value ifTrue:[
+ model setValue:(arg isNil ifTrue:[0] ifFalse:[nil]).
+ ].
+ self sendChangeMessage:#value: with:arg.
+ model notNil ifTrue:[ "/ argggh could be nilled
+ model addDependent:self.
+ self updateFromModel. "/ care for possibly lost change notification, due to #removeDependent
+ ]
].
actionBlock notNil ifTrue:[
- actionBlock valueWithOptionalArgument:arg and:self
+ actionBlock valueWithOptionalArgument:arg and:self
].
!
@@ -846,38 +846,38 @@
|value newSelection|
model isNil ifTrue:[
- ^ self
+ ^ self
].
buttonMotionAction notNil ifTrue:[
- "running in button motion; discard change notification
- "
- ^ self
+ "running in button motion; discard change notification
+ "
+ ^ self
].
value := model value.
(useIndex or:[value isNil or:[value isNumber]]) ifFalse:[
- multipleSelectOk ifFalse:[
- newSelection := self identityIndexOf:value
- ] ifTrue:[
- value size == 0 ifTrue:[
- newSelection := nil
- ] ifFalse:[
- newSelection := OrderedCollection new.
-
- value do:[:e||index|
- index := self identityIndexOf:e.
- index ~~ 0 ifTrue:[ newSelection add:index ].
- ].
-
- newSelection isEmpty ifTrue:[
- newSelection := nil
- ].
- ]
- ].
+ multipleSelectOk ifFalse:[
+ newSelection := self identityIndexOf:value
+ ] ifTrue:[
+ value size == 0 ifTrue:[
+ newSelection := nil
+ ] ifFalse:[
+ newSelection := OrderedCollection new.
+
+ value do:[:e||index|
+ index := self identityIndexOf:e.
+ index ~~ 0 ifTrue:[ newSelection add:index ].
+ ].
+
+ newSelection isEmpty ifTrue:[
+ newSelection := nil
+ ].
+ ]
+ ].
] ifTrue:[
- newSelection := value copy
+ newSelection := value copy
].
self setSelection:newSelection.
! !
@@ -903,29 +903,29 @@
inset := 15 + margin.
visibleY <= inset ifTrue:[
- self yOriginOfContents == 0 ifTrue:[ ^ false ].
+ self yOriginOfContents == 0 ifTrue:[ ^ false ].
] ifFalse:[
- visibleY < (self height - inset) ifTrue:[ ^ false ].
- self yOriginOfContents < self maxViewOriginY ifFalse:[ ^ false ].
+ visibleY < (self height - inset) ifTrue:[ ^ false ].
+ self yOriginOfContents < self maxViewOriginY ifFalse:[ ^ false ].
].
aContext contentsWillChange.
visibleY <= inset ifTrue:[ self scrollUp:inset ]
- ifFalse:[ self scrollDown:inset ].
+ ifFalse:[ self scrollDown:inset ].
^ true
!
dropSource
"returns the dropSource or nil"
-
+
^ dropSource
!
-dropSource:aDropSourceOrNil
+dropSource:aDropSourceOrNil
"set the dropSource or nil"
-
+
dropSource := aDropSourceOrNil.
!
@@ -935,12 +935,12 @@
buttonMotionAction := buttonReleaseAction := nil.
dropSource notNil ifTrue:[
- dropSource startDragSelector notNil ifTrue:[
- ^ dropSource startDragIn:self at:aPoint
- ] ifFalse:[
- ^ DragAndDropManager new
- startDragFrom:self dropSource:dropSource offset:#center
- ]
+ dropSource startDragSelector notNil ifTrue:[
+ ^ dropSource startDragIn:self at:aPoint
+ ] ifFalse:[
+ ^ DragAndDropManager new
+ startDragFrom:self dropSource:dropSource offset:#center
+ ]
].
^ nil
! !
@@ -958,9 +958,9 @@
y1 := y.
start to:stop do:[:i|
- y0 := y1.
- y1 := self yVisibleOfLine:(i + 1).
- self drawLabelAt:i x:x0 y:y0 h:(y1 - y0)
+ y0 := y1.
+ y1 := self yVisibleOfLine:(i + 1).
+ self drawLabelAt:i x:x0 y:y0 h:(y1 - y0)
].
@@ -970,11 +970,11 @@
"draw the lines between start to stop without clearing the background
"
highlightMode notNil ifTrue:[
- self selectionDo:[:lnNr|
- (lnNr between:start and:stop) ifTrue:[
- self drawSelectionFrameAt:lnNr x:x w:w
- ]
- ]
+ self selectionDo:[:lnNr|
+ (lnNr between:start and:stop) ifTrue:[
+ self drawSelectionFrameAt:lnNr x:x w:w
+ ]
+ ]
].
super drawFrom:start to:stop x:x y:y w:w.
!
@@ -986,8 +986,8 @@
x := xI + 1.
editorView notNil ifTrue:[
- "/ there is an open editor for the line; thus no redraw for the label (hidden by editor)
- self selectedIndex == anIndex ifTrue:[^ self].
+ "/ there is an open editor for the line; thus no redraw for the label (hidden by editor)
+ self selectedIndex == anIndex ifTrue:[^ self].
].
item := self at:anIndex ifAbsent:nil.
@@ -996,55 +996,55 @@
drawStrikeOut := false.
(highlightMode notNil and:[self isInSelection:anIndex]) ifTrue:[
- strikeOut ifTrue:[
- drawStrikeOut := true.
- self paint:fgColor on:bgColor
- ] ifFalse:[
- (highlightMode == #dropMode or:[self hasFocus not]) ifTrue:[
- self paint:hilightFgColorNoFocus on:hilightBgColorNoFocus.
- ] ifFalse:[
- self paint:hilightFgColor on:hilightBgColor
- ].
- ]
+ strikeOut ifTrue:[
+ drawStrikeOut := true.
+ self paint:fgColor on:bgColor
+ ] ifFalse:[
+ (highlightMode == #dropMode or:[self hasFocus not]) ifTrue:[
+ self paint:hilightFgColorNoFocus on:hilightBgColorNoFocus.
+ ] ifFalse:[
+ self paint:hilightFgColor on:hilightBgColor
+ ].
+ ]
] ifFalse:[
- enterItem == item ifTrue:[
- self paint:hilightBgColor on:bgColor.
- ] ifFalse:[
- self paint:fgColor on:bgColor.
- ].
+ enterItem == item ifTrue:[
+ self paint:hilightBgColor on:bgColor.
+ ] ifFalse:[
+ self paint:fgColor on:bgColor.
+ ].
].
- renderer display:item atX:x y:y lineHeight:h.
+ listRenderer display:item atX:x y:y lineHeight:h.
drawStrikeOut ifTrue:[
- xOut0 := self xVisibleOfItem:item.
- highlightMode == #label ifTrue:[
- xOut1 := xOut0 + (renderer widthFor:item).
- ] ifFalse:[
- xOut1 := width - margin.
- ].
- y0 := y + (h // 2).
- self displayLineFromX:xOut0 y:y0 toX:xOut1 y:y0.
- y0 := y0 - 1.
- self displayLineFromX:xOut0 y:y0 toX:xOut1 y:y0.
+ xOut0 := self xVisibleOfItem:item.
+ highlightMode == #label ifTrue:[
+ xOut1 := xOut0 + (listRenderer widthFor:item).
+ ] ifFalse:[
+ xOut1 := width - margin.
+ ].
+ y0 := y + (h // 2).
+ self displayLineFromX:xOut0 y:y0 toX:xOut1 y:y0.
+ y0 := y0 - 1.
+ self displayLineFromX:xOut0 y:y0 toX:xOut1 y:y0.
].
cursorItem == item ifTrue:[
- "/ textStartLeft
- self maskOrigin:((self viewOrigin + (0 @ 1)) \\ (lineMask extent)).
- self mask:lineMask.
- w := renderer widthFor:item.
- self displayRectangleX:x -1 y:(y+2) width:w+2 height:(h - 4).
- self mask:nil.
+ "/ textStartLeft
+ self maskOrigin:((self viewOrigin + (0 @ 1)) \\ (lineMask extent)).
+ self mask:lineMask.
+ w := listRenderer widthFor:item.
+ self displayRectangleX:x -1 y:(y+2) width:w+2 height:(h - 4).
+ self mask:nil.
] ifFalse:[
- enterItem == item ifTrue:[
- self highlightWithUnderline ifTrue:[
- "/ underline the hilite...
- y0 := y + h - 2.
- x1 := x + (renderer widthFor:item).
-
- self displayLineFromX:x y:y0 toX:x1 y:y0.
- ]
- ].
+ enterItem == item ifTrue:[
+ self highlightWithUnderline ifTrue:[
+ "/ underline the hilite...
+ y0 := y + h - 2.
+ x1 := x + (listRenderer widthFor:item).
+
+ self displayLineFromX:x y:y0 toX:x1 y:y0.
+ ]
+ ].
].
!
@@ -1055,23 +1055,23 @@
|item xMax xLftDmg xRgtDmg x0 x1 y0 y1 hL wL|
(strikeOut or:[highlightMode isNil]) ifTrue:[
- ^ self
+ ^ self
].
editorView notNil ifTrue:[
- "/ there is an open editor; do not redraw selected
- ^ self
+ "/ there is an open editor; do not redraw selected
+ ^ self
].
( highlightMode == #line
or:[highlightMode == #label
or:[highlightMode == #dropMode]]
) ifFalse:[
- "/ highlightMode not supported
- ^ self
+ "/ highlightMode not supported
+ ^ self
].
(item := self at:lnNr ifAbsent:nil) isNil ifTrue:[
- "/ list might change during drawing; item no longer visible
- ^ self
+ "/ list might change during drawing; item no longer visible
+ ^ self
].
xMax := x + w.
@@ -1082,23 +1082,23 @@
hL := y1 - y0.
highlightMode == #line ifTrue:[
- x0 := x.
- x1 := xMax.
+ x0 := x.
+ x1 := xMax.
] ifFalse:[ "/ is #label or #rectangle
- x0 := (self xVisibleOfItem:item) - (textStartLeft // 2).
- x0 >= xMax ifTrue:[ ^ self ].
-
- x1 := x0 + (renderer widthFor:item) + textStartLeft + 1.
- x1 < x ifTrue:[ ^ self ].
+ x0 := (self xVisibleOfItem:item) - (textStartLeft // 2).
+ x0 >= xMax ifTrue:[ ^ self ].
+
+ x1 := x0 + (listRenderer widthFor:item) + textStartLeft + 1.
+ x1 < x ifTrue:[ ^ self ].
].
xLftDmg := x0 max:x.
xRgtDmg := x1 min:xMax.
xRgtDmg > xLftDmg ifFalse:[^ self].
(highlightMode == #dropMode or:[self hasFocus not]) ifTrue:[
- self paint:hilightBgColorNoFocus.
+ self paint:hilightBgColorNoFocus.
] ifFalse:[
- self paint:hilightBgColor.
+ self paint:hilightBgColor.
].
self fillRectangleX:xLftDmg y:y0 width:(xRgtDmg - xLftDmg) height:hL.
wL := x1 - x0.
@@ -1106,37 +1106,37 @@
"/ DRAW THE FRAME
hilightFrameColor notNil ifTrue:[
- hilightLevel == 0 ifTrue:[
- self paint:hilightFrameColor.
-
- highlightMode == #line ifTrue:[
- self displayLineFromX:x0 y:y0 toX:x1 y:y0.
- y1 := y0 + hL - 1.
- self displayLineFromX:x0 y:y1 toX:x1 y:y1.
- ] ifFalse:[
- self displayRectangleX:x0 y:y0 width:wL height:hL
- ].
- ^ self.
- ]
+ hilightLevel == 0 ifTrue:[
+ self paint:hilightFrameColor.
+
+ highlightMode == #line ifTrue:[
+ self displayLineFromX:x0 y:y0 toX:x1 y:y0.
+ y1 := y0 + hL - 1.
+ self displayLineFromX:x0 y:y1 toX:x1 y:y1.
+ ] ifFalse:[
+ self displayRectangleX:x0 y:y0 width:wL height:hL
+ ].
+ ^ self.
+ ]
] ifFalse:[
- hilightStyle == #motif ifTrue:[
- self paint:bgColor.
- y1 := y0 + 1.
- highlightMode == #line ifTrue:[
- self displayLineFromX:x0 y:y1 toX:x1 y:y1.
- y1 := y0 + hL - 2.
- self displayLineFromX:x0 y:y1 toX:x1 y:y1.
- ] ifFalse:[
- self displayRectangleX:x0 + 1 y:y1 width:wL - 2 height:hL - 2
- ]
- ].
- hilightLevel == 0 ifTrue:[ ^ self ].
+ hilightStyle == #motif ifTrue:[
+ self paint:bgColor.
+ y1 := y0 + 1.
+ highlightMode == #line ifTrue:[
+ self displayLineFromX:x0 y:y1 toX:x1 y:y1.
+ y1 := y0 + hL - 2.
+ self displayLineFromX:x0 y:y1 toX:x1 y:y1.
+ ] ifFalse:[
+ self displayRectangleX:x0 + 1 y:y1 width:wL - 2 height:hL - 2
+ ]
+ ].
+ hilightLevel == 0 ifTrue:[ ^ self ].
].
"/ draw edge
highlightMode == #line ifTrue:[
- x0 := margin.
- wL := width - x0 - x0.
+ x0 := margin.
+ wL := width - x0 - x0.
].
self drawEdgesForX:x0 y:y0 width:wL height:hL level:hilightLevel.
!
@@ -1145,9 +1145,9 @@
"invalidate the current selection
"
shown ifTrue:[
- self selectionDo:[:aLnNr|
- self invalidateLineAt:aLnNr
- ].
+ self selectionDo:[:aLnNr|
+ self invalidateLineAt:aLnNr
+ ].
].
!
@@ -1158,23 +1158,23 @@
|item x|
editorView notNil ifTrue:[
- "/ there is an open editor; do not redraw selected
- ^ self
+ "/ there is an open editor; do not redraw selected
+ ^ self
].
(shown and:[aLineNr notNil and:[highlightMode notNil]]) ifFalse:[
- ^ self
+ ^ self
].
highlightMode == #label ifTrue:[
- item := self at:aLineNr ifAbsent:nil.
-
- item isNil ifTrue:[
- ^ self
- ].
- x := (self xVisibleOfItem:item) - (textStartLeft // 2)
+ item := self at:aLineNr ifAbsent:nil.
+
+ item isNil ifTrue:[
+ ^ self
+ ].
+ x := (self xVisibleOfItem:item) - (textStartLeft // 2)
] ifFalse:[
- x := 0.
+ x := 0.
].
self invalidateLineAt:aLineNr fromX:x
! !
@@ -1189,24 +1189,24 @@
isInSelection := self isInSelection:lineNr.
multipleSelectOk ifFalse:[
- isInSelection ifTrue:[
- self deselect
- ]ifFalse:[
- (self canSelectIndex:lineNr forAdd:false) ifTrue:[
- self buttonPressOrReleaseAtLine:lineNr x:x y:y.
- ].
- ].
- ^ self
+ isInSelection ifTrue:[
+ self deselect
+ ]ifFalse:[
+ (self canSelectIndex:lineNr forAdd:false) ifTrue:[
+ self buttonPressOrReleaseAtLine:lineNr x:x y:y.
+ ].
+ ].
+ ^ self
].
isInSelection ifTrue:[
- self removeFromSelection:lineNr
+ self removeFromSelection:lineNr
] ifFalse:[
- self addToSelection:lineNr.
-
- (self isInSelection:lineNr) ifFalse:[
- "/ cannot add to selection
- ^ self
- ].
+ self addToSelection:lineNr.
+
+ (self isInSelection:lineNr) ifFalse:[
+ "/ cannot add to selection
+ ^ self
+ ].
].
prvLine := lineNr.
@@ -1214,38 +1214,38 @@
doAdd := isInSelection not.
buttonMotionAction := [:p| |rowNr mustRestore step f|
- rowNr := self yVisibleToLineNr:(p y).
-
- (rowNr notNil and:[rowNr ~~ prvLine]) ifTrue:[
- rowNr == lineNr ifTrue:[
- mustRestore := true
- ] ifFalse:[
- rowNr > lineNr ifTrue:[ mustRestore := (rowNr < prvLine) ]
- ifFalse:[ mustRestore := (rowNr > prvLine) ].
- ].
- prvLine > rowNr ifTrue:[ step := -1 ]
- ifFalse:[ step := 1 ].
- mustRestore ifTrue:[
- [ prvLine ~~ rowNr ] whileTrue:[
- (chgSet removeIdentical:prvLine ifAbsent:nil) notNil ifTrue:[
- doAdd ifFalse:[ self addToSelection:prvLine ]
- ifTrue:[ self removeFromSelection:prvLine ].
- ].
- prvLine := prvLine + step.
- ].
- ] ifFalse:[
- [ prvLine ~~ rowNr ] whileTrue:[
- prvLine := prvLine + step.
-
- doAdd ~~ (self isInSelection:rowNr) ifTrue:[
- chgSet add:prvLine.
-
- doAdd ifTrue:[ self addToSelection:prvLine ]
- ifFalse:[ self removeFromSelection:prvLine ].
- ]
- ].
- ].
- ].
+ rowNr := self yVisibleToLineNr:(p y).
+
+ (rowNr notNil and:[rowNr ~~ prvLine]) ifTrue:[
+ rowNr == lineNr ifTrue:[
+ mustRestore := true
+ ] ifFalse:[
+ rowNr > lineNr ifTrue:[ mustRestore := (rowNr < prvLine) ]
+ ifFalse:[ mustRestore := (rowNr > prvLine) ].
+ ].
+ prvLine > rowNr ifTrue:[ step := -1 ]
+ ifFalse:[ step := 1 ].
+ mustRestore ifTrue:[
+ [ prvLine ~~ rowNr ] whileTrue:[
+ (chgSet removeIdentical:prvLine ifAbsent:nil) notNil ifTrue:[
+ doAdd ifFalse:[ self addToSelection:prvLine ]
+ ifTrue:[ self removeFromSelection:prvLine ].
+ ].
+ prvLine := prvLine + step.
+ ].
+ ] ifFalse:[
+ [ prvLine ~~ rowNr ] whileTrue:[
+ prvLine := prvLine + step.
+
+ doAdd ~~ (self isInSelection:rowNr) ifTrue:[
+ chgSet add:prvLine.
+
+ doAdd ifTrue:[ self addToSelection:prvLine ]
+ ifFalse:[ self removeFromSelection:prvLine ].
+ ]
+ ].
+ ].
+ ].
].
!
@@ -1257,28 +1257,28 @@
self stopAutoScroll.
(buttonMask ~~ 0 and:[buttonMotionAction notNil]) ifTrue:[
- buttonMotionAction value:(x@y).
-
- (autoScroll and:[buttonMotionAction notNil]) ifTrue:[
- "/ if moved outside of view, start autoscroll
- (y between:0 and:height) ifFalse:[
- y < 0 ifTrue:[ self startAutoScroll:#scrollUp distance:y ]
- ifFalse:[ self startAutoScroll:#scrollDown distance:(y - height) ].
- ].
- ].
- ^ self
+ buttonMotionAction value:(x@y).
+
+ (autoScroll and:[buttonMotionAction notNil]) ifTrue:[
+ "/ if moved outside of view, start autoscroll
+ (y between:0 and:height) ifFalse:[
+ y < 0 ifTrue:[ self startAutoScroll:#scrollUp distance:y ]
+ ifFalse:[ self startAutoScroll:#scrollDown distance:(y - height) ].
+ ].
+ ].
+ ^ self
].
(enabled and:[highlightEnterItem]) ifTrue:[
- self sensor anyButtonPressed ifFalse:[
- lnNr := self yVisibleToLineNr:y.
-
- lnNr notNil ifTrue:[ item := self at:lnNr ifAbsent:nil ]
- ifFalse:[ item := nil ].
-
- self pointerEntersItem:item.
- ]
- ].
+ self sensor anyButtonPressed ifFalse:[
+ lnNr := self yVisibleToLineNr:y.
+
+ lnNr notNil ifTrue:[ item := self at:lnNr ifAbsent:nil ]
+ ifFalse:[ item := nil ].
+
+ self pointerEntersItem:item.
+ ]
+ ].
!
buttonMultiPress:button x:x y:y
@@ -1291,14 +1291,14 @@
enabled ifFalse:[^ self].
((button == 1) or:[button == #select]) ifTrue:[
- doubleClickActionBlock notNil ifTrue:[
- ( (lnNr := self yVisibleToLineNr:y) notNil
- and:[(item := self at:lnNr ifAbsent:nil) notNil]
- ) ifTrue:[
- doubleClickActionBlock valueWithOptionalArgument:lnNr and:self.
- ].
- ].
- ^ self.
+ doubleClickActionBlock notNil ifTrue:[
+ ( (lnNr := self yVisibleToLineNr:y) notNil
+ and:[(item := self at:lnNr ifAbsent:nil) notNil]
+ ) ifTrue:[
+ doubleClickActionBlock valueWithOptionalArgument:lnNr and:self.
+ ].
+ ].
+ ^ self.
].
super buttonMultiPress:button x:x y:y
@@ -1313,7 +1313,7 @@
self pointerEntersItem:nil.
self cursorEntersItem:nil.
- self closeEditor.
+ self closeEditor.
enabled ifFalse:[^ self].
@@ -1321,165 +1321,165 @@
lineNr := self yVisibleToLineNr:y.
((button == 2) or:[button == #menu]) ifTrue:[
- (self selectOnMenuButton and:[self numberOfSelections <= 1]) ifTrue:[
- ( lineNr notNil
- and:[self canSelectIndex:lineNr forAdd:false ]
- ) ifTrue:[
- (lineNr ~~ self selectedIndex) ifTrue: [
- (self selectWithoutScroll:lineNr redraw:true) ifTrue:[
- self selectionChanged
- ].
- ].
- item := self selectedElement.
- ] ifFalse:[
- item := nil.
- item := self selectedElement.
+ (self selectOnMenuButton and:[self numberOfSelections <= 1]) ifTrue:[
+ ( lineNr notNil
+ and:[self canSelectIndex:lineNr forAdd:false ]
+ ) ifTrue:[
+ (lineNr ~~ self selectedIndex) ifTrue: [
+ (self selectWithoutScroll:lineNr redraw:true) ifTrue:[
+ self selectionChanged
+ ].
+ ].
+ item := self selectedElement.
+ ] ifFalse:[
+ item := nil.
+ item := self selectedElement.
"/ self deselect.
- ]
- ] ifFalse:[
- item := self selectedElement.
- ].
-
- item notNil ifTrue:[
- self makeSelectionVisible.
-
- menu := item perform:#middleButtonMenu ifNotUnderstood:nil.
- menu notNil ifTrue:[
- menu isCollection ifTrue:[
- menu := Menu decodeFromLiteralArray:menu.
- appl := self application.
-
- appl notNil ifTrue:[
- menu findGuiResourcesIn:appl.
- "/ menu receiver:appl -- now done in findGuiResources ...
- ] ifFalse:[
- menu receiver:item
- ]
- ].
- self startUpMenu:menu.
- ^ self
- ].
- ].
- super buttonPress:button x:x y:y.
- ^ self
+ ]
+ ] ifFalse:[
+ item := self selectedElement.
+ ].
+
+ item notNil ifTrue:[
+ self makeSelectionVisible.
+
+ menu := item perform:#middleButtonMenu ifNotUnderstood:nil.
+ menu notNil ifTrue:[
+ menu isCollection ifTrue:[
+ menu := Menu decodeFromLiteralArray:menu.
+ appl := self application.
+
+ appl notNil ifTrue:[
+ menu findGuiResourcesIn:appl.
+ "/ menu receiver:appl -- now done in findGuiResources ...
+ ] ifFalse:[
+ menu receiver:item
+ ]
+ ].
+ self startUpMenu:menu.
+ ^ self
+ ].
+ ].
+ super buttonPress:button x:x y:y.
+ ^ self
].
lineNr isNil ifTrue:[ ^ self ].
modelChangedDuringButtonPress := false.
sensor ctrlDown ifTrue:[
- self buttonControlPressAtLine:lineNr x:x y:y.
- ^ self
+ self buttonControlPressAtLine:lineNr x:x y:y.
+ ^ self
].
isSelected := self isInSelection:lineNr.
(self canDrag and:[sensor shiftDown not]) ifTrue:[
- dragDistance := UserPreferences current motionDistanceToStartDrag.
-
- isSelected ifTrue:[
- buttonMotionAction :=
- [:p|
- ((x@y) dist:p) > dragDistance ifTrue:[
- self startDragAt:p.
- ]
- ].
- buttonReleaseAction := [ self buttonPressOrReleaseAtLine:lineNr x:x y:y ].
- ^ self.
- ].
-
- self selectOnButtonPress ifFalse: [
- |oldSelection|
-
- "/ set selection to line;
- "/ set the model without change notification (objects to drag)
-
- oldSelection := selection copy.
- self selectAndUpdateModelWithoutChangeNotification: lineNr.
- self windowGroup processExposeEvents.
-
- buttonMotionAction :=
- [:p|
- ((x@y) dist:p) > dragDistance ifTrue:[
- |handler|
-
- handler := self startDragAt:p.
- handler contentsWillChange.
- "/ restore old selection
- self selectAndUpdateModelWithoutChangeNotification: oldSelection.
- self windowGroup processExposeEvents.
- ].
- ].
-
- buttonReleaseAction := [
- (self canSelectIndex:lineNr forAdd:false) ifTrue:[
- "/ notify selection change
- self selectionChanged.
- ] ifFalse:[
- "/ restore old selection
- self selectAndUpdateModelWithoutChangeNotification: oldSelection.
- ].
- ].
- ^ self
- ].
+ dragDistance := UserPreferences current motionDistanceToStartDrag.
+
+ isSelected ifTrue:[
+ buttonMotionAction :=
+ [:p|
+ ((x@y) dist:p) > dragDistance ifTrue:[
+ self startDragAt:p.
+ ]
+ ].
+ buttonReleaseAction := [ self buttonPressOrReleaseAtLine:lineNr x:x y:y ].
+ ^ self.
+ ].
+
+ self selectOnButtonPress ifFalse: [
+ |oldSelection|
+
+ "/ set selection to line;
+ "/ set the model without change notification (objects to drag)
+
+ oldSelection := selection copy.
+ self selectAndUpdateModelWithoutChangeNotification: lineNr.
+ self windowGroup processExposeEvents.
+
+ buttonMotionAction :=
+ [:p|
+ ((x@y) dist:p) > dragDistance ifTrue:[
+ |handler|
+
+ handler := self startDragAt:p.
+ handler contentsWillChange.
+ "/ restore old selection
+ self selectAndUpdateModelWithoutChangeNotification: oldSelection.
+ self windowGroup processExposeEvents.
+ ].
+ ].
+
+ buttonReleaseAction := [
+ (self canSelectIndex:lineNr forAdd:false) ifTrue:[
+ "/ notify selection change
+ self selectionChanged.
+ ] ifFalse:[
+ "/ restore old selection
+ self selectAndUpdateModelWithoutChangeNotification: oldSelection.
+ ].
+ ].
+ ^ self
+ ].
].
multipleSelectOk ifFalse:[
- (isSelected or:[self canSelectIndex:lineNr forAdd:false]) ifTrue:[
- self buttonPressOrReleaseAtLine:lineNr x:x y:y.
-
- (dragDistance notNil and:[self isInSelection:lineNr]) ifTrue:[
- buttonMotionAction :=
- [:p|
- ((x@y) dist:p) > dragDistance ifTrue:[
- self startDragAt:p.
- ].
- ].
- ].
- ].
- ^ self
+ (isSelected or:[self canSelectIndex:lineNr forAdd:false]) ifTrue:[
+ self buttonPressOrReleaseAtLine:lineNr x:x y:y.
+
+ (dragDistance notNil and:[self isInSelection:lineNr]) ifTrue:[
+ buttonMotionAction :=
+ [:p|
+ ((x@y) dist:p) > dragDistance ifTrue:[
+ self startDragAt:p.
+ ].
+ ].
+ ].
+ ].
+ ^ self
].
startLine := lineNr.
sensor shiftDown ifTrue:[ |min max|
- (isSelected or:[self canSelectIndex:lineNr forAdd:true]) ifFalse:[
- ^ self
- ].
-
- multipleSelectOk ifTrue:[
- startLine := self firstInSelection.
- startLine isNil ifTrue:[ startLine := lineNr ].
-
- startLine <= lineNr ifTrue:[
- self selectFrom:startLine to:lineNr.
- ] ifFalse:[
- startLine := self lastInSelection.
- self selectFrom:lineNr to:startLine.
- ].
- ]
+ (isSelected or:[self canSelectIndex:lineNr forAdd:true]) ifFalse:[
+ ^ self
+ ].
+
+ multipleSelectOk ifTrue:[
+ startLine := self firstInSelection.
+ startLine isNil ifTrue:[ startLine := lineNr ].
+
+ startLine <= lineNr ifTrue:[
+ self selectFrom:startLine to:lineNr.
+ ] ifFalse:[
+ startLine := self lastInSelection.
+ self selectFrom:lineNr to:startLine.
+ ].
+ ]
] ifFalse:[
- (isSelected or:[self canSelectIndex:lineNr forAdd:false]) ifFalse:[
- ^ self
- ].
- self buttonPressOrReleaseAtLine:lineNr x:x y:y.
+ (isSelected or:[self canSelectIndex:lineNr forAdd:false]) ifFalse:[
+ ^ self
+ ].
+ self buttonPressOrReleaseAtLine:lineNr x:x y:y.
].
multipleSelectOk ifTrue:[
- buttonMotionAction :=
- [:p| |ln|
- (p y between:0 and:height) ifTrue:[ |ln|
- ln := self yVisibleToLineNr:p y.
- ln isNil ifTrue:[ln := self size].
-
- (ln ~~ self lastInSelection and:[ln ~~ self firstInSelection]) ifTrue:[
- self selectFrom:startLine to:ln.
- dragDistance := nil. "/ selection changed - no longer dragable
- ]
- ].
-
- (dragDistance notNil and:[(x dist:p x) > dragDistance]) ifTrue:[
- self startDragAt:p.
- ].
- ].
+ buttonMotionAction :=
+ [:p| |ln|
+ (p y between:0 and:height) ifTrue:[ |ln|
+ ln := self yVisibleToLineNr:p y.
+ ln isNil ifTrue:[ln := self size].
+
+ (ln ~~ self lastInSelection and:[ln ~~ self firstInSelection]) ifTrue:[
+ self selectFrom:startLine to:ln.
+ dragDistance := nil. "/ selection changed - no longer dragable
+ ]
+ ].
+
+ (dragDistance notNil and:[(x dist:p x) > dragDistance]) ifTrue:[
+ self startDragAt:p.
+ ].
+ ].
].
"Modified: / 27-03-2007 / 08:43:58 / cg"
@@ -1489,24 +1489,24 @@
"handle a button press or release at a line
"
aLnNr == self selectedIndex ifTrue:[
- editorView notNil ifTrue:[^ self].
-
- self openEditorAction notNil ifTrue:[
- self openEditorAtX:x y:y.
- editorView notNil ifTrue:[^ self].
- ].
-
- ignoreReselect ifFalse:[
- (toggleSelect and:[self sensor ctrlDown]) ifTrue:[
- self selection:nil
- ] ifFalse:[
- self selectionChanged
- ].
- ].
+ editorView notNil ifTrue:[^ self].
+
+ self openEditorAction notNil ifTrue:[
+ self openEditorAtX:x y:y.
+ editorView notNil ifTrue:[^ self].
+ ].
+
+ ignoreReselect ifFalse:[
+ (toggleSelect and:[self sensor ctrlDown]) ifTrue:[
+ self selection:nil
+ ] ifFalse:[
+ self selectionChanged
+ ].
+ ].
] ifFalse:[
- (self selectWithoutScroll:aLnNr redraw:true) ifTrue:[
- self selectionChanged
- ]
+ (self selectWithoutScroll:aLnNr redraw:true) ifTrue:[
+ self selectionChanged
+ ]
].
!
@@ -1519,15 +1519,15 @@
buttonMotionAction := modelChangedDuringButtonPress := nil.
buttonReleaseAction notNil ifTrue:[
- buttonReleaseAction value.
- buttonReleaseAction := nil.
+ buttonReleaseAction value.
+ buttonReleaseAction := nil.
].
self cursorEntersItem:nil.
self stopAutoScroll.
(makeSelectionVisible == true and:[self hasSelection]) ifTrue:[
- self makeSelectionVisible
+ self makeSelectionVisible
].
!
@@ -1543,26 +1543,26 @@
lnNr isNil ifTrue:[lnNr := 0].
self sensor shiftDown ifTrue:[
- stp := -1. "/ search backward
- to1 := 1.
- fr2 := size.
+ stp := -1. "/ search backward
+ to1 := 1.
+ fr2 := size.
] ifFalse:[
- stp := 1. "/ search forward
- to1 := size.
- fr2 := 1.
+ stp := 1. "/ search forward
+ to1 := size.
+ fr2 := 1.
].
idx := self findLineFrom:lnNr+stp to:to1 by:stp startingWithCharacter:aKey.
idx == 0 ifTrue:[
- idx := self findLineFrom:fr2 to:lnNr-stp by:stp startingWithCharacter:aKey.
- idx == 0 ifTrue:[^ self].
+ idx := self findLineFrom:fr2 to:lnNr-stp by:stp startingWithCharacter:aKey.
+ idx == 0 ifTrue:[^ self].
].
self selection:idx.
keyActionStyle == #selectAndDoubleClick ifTrue:[
- self doubleClicked
+ self doubleClicked
].
!
@@ -1576,14 +1576,14 @@
item := self at:anIndex ifAbsent:nil.
item isHierarchicalItem ifTrue:[
- item := item string
+ item := item string
].
item isNil ifTrue:[^ nil].
(Error catch:[
- s := item asString
+ s := item asString
]) ifTrue:[
- s := item displayString
+ s := item displayString
].
^ s
!
@@ -1594,12 +1594,12 @@
"/ draw the frame at the top and bottom, but NOT at the left and right
self hasSelection ifTrue:[
- (hilightFrameColor notNil
- or:[hilightStyle == #motif
- or:[hilightLevel ~~ 0]]) ifTrue:[
- "/ invalidate the right-edge
- self invalidate:(((width-3) @ 0) corner:((width-1) @ (height-1))).
- ]
+ (hilightFrameColor notNil
+ or:[hilightStyle == #motif
+ or:[hilightLevel ~~ 0]]) ifTrue:[
+ "/ invalidate the right-edge
+ self invalidate:(((width-3) @ 0) corner:((width-1) @ (height-1))).
+ ]
].
super containerChangedSize.
@@ -1611,25 +1611,25 @@
|lnNr x|
(shown and:[self size ~~ 0]) ifFalse:[
- cursorItem := nil.
- ^ self.
+ cursorItem := nil.
+ ^ self.
].
anItemOrNil == cursorItem ifTrue:[ ^ self ].
2 timesRepeat:[
- cursorItem notNil ifTrue:[
- lnNr := self identityIndexOf:cursorItem.
- lnNr notNil ifTrue:[
- x := self xVisibleOfItem:cursorItem.
- self invalidateLineAt:lnNr fromX:x
- ].
- ].
- "/ set the new item
- cursorItem := anItemOrNil.
+ cursorItem notNil ifTrue:[
+ lnNr := self identityIndexOf:cursorItem.
+ lnNr notNil ifTrue:[
+ x := self xVisibleOfItem:cursorItem.
+ self invalidateLineAt:lnNr fromX:x
+ ].
+ ].
+ "/ set the new item
+ cursorItem := anItemOrNil.
].
cursorItem notNil ifTrue:[
- self makeLineVisible:lnNr
+ self makeLineVisible:lnNr
].
!
@@ -1639,11 +1639,11 @@
|arg|
doubleClickActionBlock notNil ifTrue:[
- arg := self selectedIndex.
-
- arg ~~ 0 ifTrue:[
- doubleClickActionBlock valueWithOptionalArgument:arg and:self.
- ]
+ arg := self selectedIndex.
+
+ arg ~~ 0 ifTrue:[
+ doubleClickActionBlock valueWithOptionalArgument:arg and:self.
+ ]
].
!
@@ -1656,31 +1656,31 @@
stop "{ Class:SmallInteger }"
|
(size := self size) ~~ 0 ifTrue:[
- aStep > 0 ifTrue:[
- aStart > aStop ifTrue:[^ 0].
- ] ifFalse:[
- (aStep == 0 or:[aStop > aStart]) ifTrue:[^ 0]
- ].
-
- start := aStart < 0 ifTrue:[1] ifFalse:[aStart min:size].
- stop := aStop < 0 ifTrue:[1] ifFalse:[aStop min:size].
- char := aCharacter asUppercase.
-
- start to:stop by:aStep do:[:anIndex|
- lbl := self characterSearchItemStringAt:anIndex.
- lbl notNil ifTrue:[
- cmp := lbl string at:1 ifAbsent:nil.
-
- cmp notNil ifTrue:[
- (char == cmp or:[char == cmp asUppercase]) ifTrue:[
- (self canSelectIndex:anIndex forAdd:false) ifTrue:[
- ^ anIndex
- ].
- ^ 0
- ]
- ]
- ]
- ]
+ aStep > 0 ifTrue:[
+ aStart > aStop ifTrue:[^ 0].
+ ] ifFalse:[
+ (aStep == 0 or:[aStop > aStart]) ifTrue:[^ 0]
+ ].
+
+ start := aStart < 0 ifTrue:[1] ifFalse:[aStart min:size].
+ stop := aStop < 0 ifTrue:[1] ifFalse:[aStop min:size].
+ char := aCharacter asUppercase.
+
+ start to:stop by:aStep do:[:anIndex|
+ lbl := self characterSearchItemStringAt:anIndex.
+ lbl notNil ifTrue:[
+ cmp := lbl string at:1 ifAbsent:nil.
+
+ cmp notNil ifTrue:[
+ (char == cmp or:[char == cmp asUppercase]) ifTrue:[
+ (self canSelectIndex:anIndex forAdd:false) ifTrue:[
+ ^ anIndex
+ ].
+ ^ 0
+ ]
+ ]
+ ]
+ ]
].
^ 0
@@ -1692,8 +1692,8 @@
lnNr := self identityIndexOf:enterItem.
lnNr notNil ifTrue:[
- x := self xVisibleOfItem:enterItem.
- self invalidateLineAt:lnNr fromX:x
+ x := self xVisibleOfItem:enterItem.
+ self invalidateLineAt:lnNr fromX:x
].
!
@@ -1701,8 +1701,8 @@
"a key was pressed - handle page-keys here
"
<resource: #keyboard( #CursorUp #CursorDown #EndOfText #EndOfLine
- #BeginOfText #BeginOfLine #Return
- #CmdReturn #CmdCursorUp #CmdCursorDown #SelectAll)>
+ #BeginOfText #BeginOfLine #Return
+ #CmdReturn #CmdCursorUp #CmdCursorDown #SelectAll)>
|lineNr listSize shifted newSel step start|
@@ -1712,154 +1712,154 @@
listSize == 0 ifTrue:[^ self].
aKey isCharacter ifTrue:[
- keyActionStyle notNil ifTrue:[
- keyActionStyle == #pass ifTrue:[
- super keyPress:aKey x:x y:y
- ] ifFalse:[
- self characterPress:aKey x:x y:y.
- ].
- ].
- ^ self
+ keyActionStyle notNil ifTrue:[
+ keyActionStyle == #pass ifTrue:[
+ super keyPress:aKey x:x y:y
+ ] ifFalse:[
+ self characterPress:aKey x:x y:y.
+ ].
+ ].
+ ^ self
].
aKey == #Escape ifTrue:[
- cursorItem notNil ifTrue:[
- self cursorEntersItem:nil.
- self makeSelectionVisible.
- ].
- super keyPress:aKey x:x y:y.
- ^ self
+ cursorItem notNil ifTrue:[
+ self cursorEntersItem:nil.
+ self makeSelectionVisible.
+ ].
+ super keyPress:aKey x:x y:y.
+ ^ self
].
((aKey == #BeginOfText) or:[aKey == #BeginOfLine]) ifTrue:[
- self cursorEntersItem:nil.
-
- 1 to:listSize do:[:i|
- (self canSelectIndex:i forAdd:false) ifTrue:[
- self selection:i.
- ^ self
- ].
- ].
- ^ self
+ self cursorEntersItem:nil.
+
+ 1 to:listSize do:[:i|
+ (self canSelectIndex:i forAdd:false) ifTrue:[
+ self selection:i.
+ ^ self
+ ].
+ ].
+ ^ self
].
((aKey == #EndOfText) or:[aKey == #EndOfLine]) ifTrue:[
- self cursorEntersItem:nil.
-
- listSize to:1 by:-1 do:[:i|
- (self canSelectIndex:i forAdd:false) ifTrue:[
- self selection:i.
- ^ self
- ].
- ].
- ^ self
+ self cursorEntersItem:nil.
+
+ listSize to:1 by:-1 do:[:i|
+ (self canSelectIndex:i forAdd:false) ifTrue:[
+ self selection:i.
+ ^ self
+ ].
+ ].
+ ^ self
].
lineNr := self cursorLine.
aKey == #Return ifTrue:[
- returnKeyActionStyle == #pass ifTrue:[
- super keyPress:aKey x:x y:y
- ] ifFalse:[
- lineNr ~~ 0 ifTrue:[
- self cursorEntersItem:nil.
-
- (self canSelectIndex:lineNr forAdd:false) ifTrue:[
- self selection:lineNr
- ].
- ].
-
- returnKeyActionStyle == #doubleClick ifTrue:[
- self doubleClicked
- ].
- ].
- ^ self
+ returnKeyActionStyle == #pass ifTrue:[
+ super keyPress:aKey x:x y:y
+ ] ifFalse:[
+ lineNr ~~ 0 ifTrue:[
+ self cursorEntersItem:nil.
+
+ (self canSelectIndex:lineNr forAdd:false) ifTrue:[
+ self selection:lineNr
+ ].
+ ].
+
+ returnKeyActionStyle == #doubleClick ifTrue:[
+ self doubleClicked
+ ].
+ ].
+ ^ self
].
aKey == #SelectAll ifTrue:[
- self selectAll.
- ^ self
+ self selectAll.
+ ^ self
].
(lineNr == 0 and:[selection notNil]) ifTrue:[
- multipleSelectOk ifFalse:[lineNr := selection]
- ifTrue:[lineNr := selection last].
+ multipleSelectOk ifFalse:[lineNr := selection]
+ ifTrue:[lineNr := selection last].
].
aKey == #CmdReturn ifTrue:[
- "/ toggle selection of the item
- lineNr ~~ 0 ifTrue:[
- (self isInSelection:lineNr) ifTrue:[ self removeFromSelection:lineNr ]
- ifFalse:[ self addToSelection:lineNr ].
-
- self cursorEntersItem:(self at:lineNr).
- ].
- ^ self
+ "/ toggle selection of the item
+ lineNr ~~ 0 ifTrue:[
+ (self isInSelection:lineNr) ifTrue:[ self removeFromSelection:lineNr ]
+ ifFalse:[ self addToSelection:lineNr ].
+
+ self cursorEntersItem:(self at:lineNr).
+ ].
+ ^ self
].
(aKey == #CmdCursorDown or:[aKey == #CmdCursorUp]) ifTrue:[
- aKey == #CmdCursorDown ifTrue:[
- lineNr := lineNr + 1.
- lineNr > listSize ifTrue:[lineNr := 1].
- ] ifFalse:[
- lineNr := lineNr - 1.
- lineNr < 1 ifTrue:[lineNr := listSize].
- ].
- self cursorEntersItem:(self at:lineNr).
- ^ self
+ aKey == #CmdCursorDown ifTrue:[
+ lineNr := lineNr + 1.
+ lineNr > listSize ifTrue:[lineNr := 1].
+ ] ifFalse:[
+ lineNr := lineNr - 1.
+ lineNr < 1 ifTrue:[lineNr := listSize].
+ ].
+ self cursorEntersItem:(self at:lineNr).
+ ^ self
].
(aKey == #CursorUp or:[aKey == #CursorDown]) ifFalse:[
- super keyPress:aKey x:x y:y.
- ^ self
+ super keyPress:aKey x:x y:y.
+ ^ self
].
shifted := (multipleSelectOk and:[self sensor shiftDown]).
self cursorEntersItem:nil.
aKey == #CursorDown ifTrue:[ step := 1.]
- ifFalse:[ step := -1.].
+ ifFalse:[ step := -1.].
shifted ifFalse:[ |compressed|
- compressed := self sensor compressKeyPressEventsWithKey:aKey.
-
- compressed ~~ 0 ifTrue:[
- aKey == #CursorDown ifTrue:[
- lineNr := lineNr + compressed.
- lineNr > listSize ifTrue:[lineNr := 1].
- ] ifFalse:[
- lineNr := lineNr - compressed.
- lineNr < 1 ifTrue:[lineNr := listSize].
- ].
- ].
+ compressed := self sensor compressKeyPressEventsWithKey:aKey.
+
+ compressed ~~ 0 ifTrue:[
+ aKey == #CursorDown ifTrue:[
+ lineNr := lineNr + compressed.
+ lineNr > listSize ifTrue:[lineNr := 1].
+ ] ifFalse:[
+ lineNr := lineNr - compressed.
+ lineNr < 1 ifTrue:[lineNr := listSize].
+ ].
+ ].
].
start := lineNr.
lineNr := lineNr + step.
[ lineNr ~~ start ] whileTrue:[
- (lineNr between:1 and:listSize) ifFalse:[
- lineNr < 1 ifTrue:[ lineNr := listSize ]
- ifFalse:[ lineNr := 1 ].
- ] ifTrue:[
- (self canSelectIndex:lineNr forAdd:shifted) ifTrue:[
- shifted ifFalse:[
- self selection:lineNr.
- ^ self
- ].
- (self isInSelection:lineNr) ifFalse:[
- selection isNil ifTrue:[ newSel := Array with:lineNr ]
- ifFalse:[ newSel := selection copyWith:lineNr ].
- ] ifTrue:[
- (start ~~ 0 and:[selection size > 1]) ifFalse:[
- ^ self
- ].
- newSel := selection copyWithout:start.
- ].
- self selectWithoutScroll:newSel redraw:true.
- self makeLineVisible:lineNr.
- self selectionChanged.
- ^ self
- ].
- lineNr := lineNr + step.
- ]
+ (lineNr between:1 and:listSize) ifFalse:[
+ lineNr < 1 ifTrue:[ lineNr := listSize ]
+ ifFalse:[ lineNr := 1 ].
+ ] ifTrue:[
+ (self canSelectIndex:lineNr forAdd:shifted) ifTrue:[
+ shifted ifFalse:[
+ self selection:lineNr.
+ ^ self
+ ].
+ (self isInSelection:lineNr) ifFalse:[
+ selection isNil ifTrue:[ newSel := Array with:lineNr ]
+ ifFalse:[ newSel := selection copyWith:lineNr ].
+ ] ifTrue:[
+ (start ~~ 0 and:[selection size > 1]) ifFalse:[
+ ^ self
+ ].
+ newSel := selection copyWithout:start.
+ ].
+ self selectWithoutScroll:newSel redraw:true.
+ self makeLineVisible:lineNr.
+ self selectionChanged.
+ ^ self
+ ].
+ lineNr := lineNr + step.
+ ]
].
!
@@ -1869,12 +1869,12 @@
|newItem|
(shown and:[self size ~~ 0]) ifFalse:[
- enterItem := nil.
- ^ self.
+ enterItem := nil.
+ ^ self.
].
highlightEnterItem ifTrue:[ newItem := anItemOrNil ]
- ifFalse:[ newItem := nil ].
+ ifFalse:[ newItem := nil ].
anItemOrNil == enterItem ifTrue:[ ^ self ].
@@ -1898,19 +1898,19 @@
"/ draw the frame at the top and bottom, but NOT at the left and right
self hasSelection ifTrue:[
- selectionWasVisible := self isSelectionVisibleIn:(previousExtent ? self extent).
-
- (hilightFrameColor notNil
- or:[hilightStyle == #motif
- or:[hilightLevel ~~ 0]]) ifTrue:[
- "/ invalidate the right-edge
- self invalidate:(((width-3) @ 0) corner:((width-1) @ (height-1))).
- ].
+ selectionWasVisible := self isSelectionVisibleIn:(previousExtent ? self extent).
+
+ (hilightFrameColor notNil
+ or:[hilightStyle == #motif
+ or:[hilightLevel ~~ 0]]) ifTrue:[
+ "/ invalidate the right-edge
+ self invalidate:(((width-3) @ 0) corner:((width-1) @ (height-1))).
+ ].
].
super sizeChanged:how.
selectionWasVisible ifTrue:[
- self makeSelectionVisible
+ self makeSelectionVisible
].
! !
@@ -1931,15 +1931,15 @@
the mouse pointer enters"
(editorView notNil and:[editorView realized]) ifTrue:[
- ^ false
+ ^ false
].
(UserPreferences current focusFollowsMouse ~~ false
and:[(styleSheet at:#'selection.requestFocusOnPointerEnter' default:true)
]) ifTrue:[
- self size > 0 ifTrue:[
- ^ true
- ]
+ self size > 0 ifTrue:[
+ ^ true
+ ]
].
^ false
! !
@@ -1965,12 +1965,12 @@
initStyle
"setup viewStyle specifics
"
- <resource: #style (#'selection.selectOnMenuButton'
- #'selection.font')>
+ <resource: #style (#'selection.selectOnMenuButton'
+ #'selection.font')>
super initStyle.
lineMask isNil ifTrue:[
- lineMask := Form width:2 height:2 fromArray:#[16rAA 16r55].
+ lineMask := Form width:2 height:2 fromArray:#[16rAA 16r55].
].
hilightFrameColor := nil.
@@ -1979,71 +1979,71 @@
textStartLeft := 4.
selectOnMenuButton := styleSheet at:#'selection.selectOnMenuButton' default:nil.
selectOnMenuButton isNil ifTrue:[
- selectOnMenuButton := UserPreferences current selectOnRightClick
+ selectOnMenuButton := UserPreferences current selectOnRightClick
].
super font:(styleSheet fontAt:#'selection.font').
device hasGrayscales ifTrue:[
- "
- must get rid of these hard codings
- "
- (hilightStyle == #next) ifTrue:[
- hilightFgColor := fgColor.
- hilightBgColor := White.
- hilightFrameColor := fgColor
- ] ifFalse:[
- (hilightStyle == #motif) ifTrue:[
- fgColor := White.
- bgColor := Grey.
- viewBackground := bgColor.
- hilightFgColor := bgColor.
- hilightBgColor := fgColor.
- ] ifFalse:[
- (hilightStyle == #openwin) ifTrue:[
- hilightFgColor := fgColor.
- hilightBgColor := Color grey.
- ]
- ]
- ]
+ "
+ must get rid of these hard codings
+ "
+ (hilightStyle == #next) ifTrue:[
+ hilightFgColor := fgColor.
+ hilightBgColor := White.
+ hilightFrameColor := fgColor
+ ] ifFalse:[
+ (hilightStyle == #motif) ifTrue:[
+ fgColor := White.
+ bgColor := Grey.
+ viewBackground := bgColor.
+ hilightFgColor := bgColor.
+ hilightBgColor := fgColor.
+ ] ifFalse:[
+ (hilightStyle == #openwin) ifTrue:[
+ hilightFgColor := fgColor.
+ hilightBgColor := Color grey.
+ ]
+ ]
+ ]
].
hilightFgColor isNil ifTrue:[
- hilightFgColor := bgColor.
+ hilightFgColor := bgColor.
].
hilightBgColor isNil ifTrue:[
- hilightBgColor := fgColor.
+ hilightBgColor := fgColor.
].
DefaultForegroundColor notNil ifTrue:[
- fgColor := DefaultForegroundColor
+ fgColor := DefaultForegroundColor
].
DefaultBackgroundColor notNil ifTrue:[
- bgColor := viewBackground := DefaultBackgroundColor
+ bgColor := viewBackground := DefaultBackgroundColor
].
DefaultHilightForegroundColor notNil ifTrue:[
- hilightFgColor := DefaultHilightForegroundColor
+ hilightFgColor := DefaultHilightForegroundColor
].
DefaultHilightBackgroundColor notNil ifTrue:[
- hilightBgColor := DefaultHilightBackgroundColor
+ hilightBgColor := DefaultHilightBackgroundColor
].
DefaultHilightFrameColor notNil ifTrue:[
- hilightFrameColor := DefaultHilightFrameColor
+ hilightFrameColor := DefaultHilightFrameColor
].
hilightLevel := DefaultHilightLevel ? 0.
lineSpacing := (hilightLevel abs > 0) ifTrue:[3] ifFalse:[2].
hilightFgColor isNil ifTrue:[
- hilightFgColor := bgColor.
- hilightBgColor := fgColor.
+ hilightFgColor := bgColor.
+ hilightBgColor := fgColor.
].
hilightFgColorNoFocus isNil ifTrue:[
- hilightFgColorNoFocus := hilightFgColor.
+ hilightFgColorNoFocus := hilightFgColor.
].
hilightBgColorNoFocus isNil ifTrue:[
- hilightBgColorNoFocus := hilightBgColor lightened.
+ hilightBgColorNoFocus := hilightBgColor lightened.
].
!
@@ -2085,14 +2085,14 @@
|lnNr item y0 x0 y1|
editorView isNil ifTrue:[
- ^ self
+ ^ self
].
( (lnNr := self selectedIndex) == 0
or:[(item := self at:lnNr ifAbsent:nil) isNil]
) ifTrue:[
- "/ there is no more single selection; thus close the editor
- ^ self closeEditor
+ "/ there is no more single selection; thus close the editor
+ ^ self closeEditor
].
x0 := (self xVisibleOfItem:item) - (textStartLeft // 2).
@@ -2100,7 +2100,7 @@
y1 := self yVisibleOfLine:(lnNr + 1).
minimumEditorHeight notNil ifTrue:[
- y1 := y0 + ((y1 - y0) max:minimumEditorHeight).
+ y1 := y0 + ((y1 - y0) max:minimumEditorHeight).
].
"/ Changed by cg:
"/ editorView layout:( Rectangle left:x top:y right:(width - 1 - margin) bottom:(h + 2 "- 1") ).
@@ -2123,8 +2123,8 @@
item isNil ifTrue:[^ self].
x < (self xVisibleOfItem:item) ifTrue:[
- "/ not part of the selection frame; ignorre
- ^ self
+ "/ not part of the selection frame; ignorre
+ ^ self
].
editor := self openEditor.
editor isNil ifTrue:[^ self].
@@ -2137,11 +2137,11 @@
"/ Changed by cg:
"/ but only if there was no initial selection
editor isInputField ifTrue:[
- editor hasSelection ifFalse:[
- self sensor
- pushEvent:(WindowEvent buttonPress:#select x:x0 y:y0 view:editor);
- pushEvent:(WindowEvent buttonRelease:#select x:x0 y:y0 view:editor).
- ]
+ editor hasSelection ifFalse:[
+ self sensor
+ pushEvent:(WindowEvent buttonPress:#select x:x0 y:y0 view:editor);
+ pushEvent:(WindowEvent buttonRelease:#select x:x0 y:y0 view:editor).
+ ]
].
"/ to clear the selection
@@ -2187,8 +2187,8 @@
y1 := cachedLinesY at:cachedMaxIdx.
(minimumEditorHeight notNil and:[openEditorAction notNil]) ifTrue:[
- y0 := cachedLinesY at:(cachedMaxIdx - 1) ifAbsent:0.
- y1 := y0 + ((y1 - y0) max:minimumEditorHeight).
+ y0 := cachedLinesY at:(cachedMaxIdx - 1) ifAbsent:0.
+ y1 := y0 + ((y1 - y0) max:minimumEditorHeight).
].
^ y1
! !
@@ -2201,26 +2201,26 @@
|oldSelect forAdd|
(self isInSelection:lineNr) ifTrue:[
- ^ self
+ ^ self
].
multipleSelectOk ifTrue:[ forAdd := selection notNil ]
- ifFalse:[ forAdd := false ].
+ ifFalse:[ forAdd := false ].
(self canSelectIndex:lineNr forAdd:forAdd) ifFalse:[
- ^ self
+ ^ self
].
self closeEditor.
self cursorEntersItem:nil.
multipleSelectOk ifFalse:[
- oldSelect := selection.
- selection := lineNr.
- oldSelect notNil ifTrue:[ self invalidateSelectionAt:oldSelect ].
+ oldSelect := selection.
+ selection := lineNr.
+ oldSelect notNil ifTrue:[ self invalidateSelectionAt:oldSelect ].
] ifTrue:[
- selection notNil ifTrue:[ selection := selection copyWith:lineNr ]
- ifFalse:[ selection := OrderedCollection with:lineNr ].
+ selection notNil ifTrue:[ selection := selection copyWith:lineNr ]
+ ifFalse:[ selection := OrderedCollection with:lineNr ].
].
self invalidateSelectionAt:lineNr.
self selectionChanged.
@@ -2257,10 +2257,10 @@
"return true, if line, aNumber is in the selection
"
multipleSelectOk ifFalse:[
- ^ (aNumber == selection)
+ ^ (aNumber == selection)
].
selection notNil ifTrue:[
- ^ selection includesIdentical:aNumber
+ ^ selection includesIdentical:aNumber
].
^ false
!
@@ -2275,7 +2275,7 @@
"returns true if any selected element is visible"
self selectionDo:[:aLineNr|
- (self isLineVisible:aLineNr in:anExtentPoint) ifTrue:[^ true].
+ (self isLineVisible:aLineNr in:anExtentPoint) ifTrue:[^ true].
].
^ false
!
@@ -2307,8 +2307,8 @@
(firstLine isNil or:[firstLine == 0]) ifTrue:[^ self].
self selectionDo:[:aLnNr|
- (self lineIsFullyVisible:aLnNr) ifTrue:[^ self].
- ].
+ (self lineIsFullyVisible:aLnNr) ifTrue:[^ self].
+ ].
self makeLineVisible:(self firstInSelection).
!
@@ -2324,22 +2324,22 @@
"remove line from selection without scrolling but raise a change notification
"
(self isInSelection:lineNr) ifFalse:[
- ^ self
+ ^ self
].
self closeEditor.
self cursorEntersItem:nil.
(multipleSelectOk and:[self numberOfSelections > 1]) ifTrue:[
- selection := selection copyWithout:lineNr.
+ selection := selection copyWithout:lineNr.
] ifFalse:[
- selection := nil
+ selection := nil
].
self invalidateSelectionAt:lineNr.
self selectionChanged.
!
selectAll
- "select all entries.
+ "select all entries.
Model and/or actionBlock notification IS done."
self selectFrom:1 to:self size.
@@ -2357,7 +2357,7 @@
idx := self identityIndexOf:anElement.
idx == 0 ifTrue:[
- ^ exceptionalValue value
+ ^ exceptionalValue value
].
self selection:idx
!
@@ -2373,27 +2373,27 @@
stop := aStop.
aStart < aStop ifTrue:[
- start := aStart max:1.
- stop := aStop min:(self size).
- step := 1.
- start > stop ifTrue:[^ self].
+ start := aStart max:1.
+ stop := aStop min:(self size).
+ step := 1.
+ start > stop ifTrue:[^ self].
] ifFalse:[
- start := aStart min:(self size).
- stop := aStop max:1.
- step := -1.
- start < stop ifTrue:[^ self].
+ start := aStart min:(self size).
+ stop := aStop max:1.
+ step := -1.
+ start < stop ifTrue:[^ self].
].
nsel := OrderedCollection new.
start to:stop by:step do:[:i|
- (self canSelectIndex:i forAdd:true) ifTrue:[
- nsel add:i.
- ].
+ (self canSelectIndex:i forAdd:true) ifTrue:[
+ nsel add:i.
+ ].
].
(self selectWithoutScroll:nsel redraw:true) ifTrue:[
- self selectionChanged
+ self selectionChanged
].
!
@@ -2403,7 +2403,7 @@
|index|
(index := self selectedIndex) ~~ 0 ifTrue:[
- ^ self at:index ifAbsent:nil
+ ^ self at:index ifAbsent:nil
].
^ nil
!
@@ -2413,17 +2413,17 @@
lines are selected, 0 is returned
"
selection notNil ifTrue:[
- multipleSelectOk ifFalse:[ ^ selection ].
-
- selection size == 1 ifTrue:[
- ^ selection at:1
- ]
+ multipleSelectOk ifFalse:[ ^ selection ].
+
+ selection size == 1 ifTrue:[
+ ^ selection at:1
+ ]
].
^ 0
!
selection
- "return the selection index or collection of indices
+ "return the selection index or collection of indices
in case of multiple selection enabled
"
^ selection
@@ -2436,8 +2436,8 @@
The model and/or actionBlock IS notified.
"
(self selectWithoutScroll:something redraw:true) ifTrue:[
- self makeSelectionVisible.
- self selectionChanged
+ self makeSelectionVisible.
+ self selectionChanged
].
!
@@ -2459,11 +2459,11 @@
For multiple selections, it is called for each.
"
selection notNil ifTrue:[
- multipleSelectOk ifTrue:[
- selection do:aBlock
- ] ifFalse:[
- aBlock value:selection
- ].
+ multipleSelectOk ifTrue:[
+ selection do:aBlock
+ ] ifFalse:[
+ aBlock value:selection
+ ].
].
@@ -2474,8 +2474,8 @@
For multiple selections a collection containing the entries is returned.
"
multipleSelectOk ifTrue:[
- selection isNil ifTrue:[^ #()].
- ^ selection collect:[:nr| self at:nr ]
+ selection isNil ifTrue:[^ #()].
+ ^ selection collect:[:nr| self at:nr ]
].
selection isNil ifTrue:[^ nil].
^ self at:selection ifAbsent:nil.
@@ -2500,7 +2500,7 @@
*** No model and/or actionBlock notification is done here.
"
(self selectWithoutScroll:something redraw:true) ifTrue:[
- self makeSelectionVisible
+ self makeSelectionVisible
]
! !
@@ -2519,18 +2519,18 @@
|item isOk|
selectConditionBlock notNil ifTrue:[
- isOk := selectConditionBlock valueWithOptionalArgument:anIndex and:isForAdd.
-
- isOk ifFalse:[
- ^ false
- ]
+ isOk := selectConditionBlock valueWithOptionalArgument:anIndex and:isForAdd.
+
+ isOk ifFalse:[
+ ^ false
+ ]
].
item := self at:anIndex ifAbsent:nil.
item isNil ifTrue:[^ false].
item isHierarchicalItem ifTrue:[
- ^ item isSelectable
+ ^ item isSelectable
].
^ true
!
@@ -2540,7 +2540,7 @@
the model and/or actionBlock is notified
"
(self selectWithoutScroll:nil redraw:false) ifTrue:[
- self selectionChanged
+ self selectionChanged
]
!
@@ -2564,45 +2564,45 @@
oldSelect := selection.
(something isNil or:[something == 0]) ifTrue:[
- selection := nil
+ selection := nil
] ifFalse:[
- something isNumber ifTrue:[
- selection := multipleSelectOk ifTrue:[Array with:something]
- ifFalse:[something]
- ] ifFalse:[
- something size == 0 ifTrue:[
- selection := nil
- ] ifFalse:[
- selection := multipleSelectOk ifTrue:[something]
- ifFalse:[something at:1]
- ]
- ]
+ something isNumber ifTrue:[
+ selection := multipleSelectOk ifTrue:[Array with:something]
+ ifFalse:[something]
+ ] ifFalse:[
+ something size == 0 ifTrue:[
+ selection := nil
+ ] ifFalse:[
+ selection := multipleSelectOk ifTrue:[something]
+ ifFalse:[something at:1]
+ ]
+ ]
].
selection = oldSelect ifTrue:[^ false].
modelChangedDuringButtonPress notNil ifTrue:[
- modelChangedDuringButtonPress := true.
+ modelChangedDuringButtonPress := true.
].
self closeEditor.
self cursorEntersItem:nil.
-
+
(doRedraw and:[shown]) ifFalse:[
- ^ true
+ ^ true
].
multipleSelectOk ifFalse:[
- oldSelect notNil ifTrue:[self invalidateSelectionAt:oldSelect].
- selection notNil ifTrue:[self invalidateSelectionAt:selection].
+ oldSelect notNil ifTrue:[self invalidateSelectionAt:oldSelect].
+ selection notNil ifTrue:[self invalidateSelectionAt:selection].
] ifTrue:[
- (selection notNil and:[oldSelect notNil]) ifTrue:[
- selection do:[:i|(oldSelect includesIdentical:i) ifFalse:[self invalidateSelectionAt:i]].
- oldSelect do:[:i|(selection includesIdentical:i) ifFalse:[self invalidateSelectionAt:i]].
- ] ifFalse:[
- oldSelect isNil ifTrue:[oldSelect := selection].
- oldSelect do:[:i|self invalidateSelectionAt:i]
- ]
+ (selection notNil and:[oldSelect notNil]) ifTrue:[
+ selection do:[:i|(oldSelect includesIdentical:i) ifFalse:[self invalidateSelectionAt:i]].
+ oldSelect do:[:i|(selection includesIdentical:i) ifFalse:[self invalidateSelectionAt:i]].
+ ] ifFalse:[
+ oldSelect isNil ifTrue:[oldSelect := selection].
+ oldSelect do:[:i|self invalidateSelectionAt:i]
+ ]
].
^ true
! !
@@ -2610,5 +2610,5 @@
!SelectionInListModelView class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libwidg2/SelectionInListModelView.st,v 1.143 2009-05-27 06:05:59 ca Exp $'
+ ^ '$Header: /cvs/stx/stx/libwidg2/SelectionInListModelView.st,v 1.144 2009-08-07 10:50:41 sr Exp $'
! !