|
Class: SelectionInListModelView
Object
|
+--GraphicsMedium
|
+--DisplaySurface
|
+--SimpleView
|
+--View
|
+--ListModelView
|
+--SelectionInListModelView
|
+--HierarchicalListView
|
+--Tools::CodeCompletionMenu
|
+--Tools::TagsBrowser::TagView
- Package:
- stx:libwidg2
- Category:
- Views-Lists
- Version:
- rev:
1.234
date: 2023/11/11 15:24:33
- user: stefan
- file: SelectionInListModelView.st directory: libwidg2
- module: stx stc-classLibrary: libwidg2
SelectionInListModelView is mostly like SelectionInListView,
but derives from the ListModelView and thus the list is kept
in the list.
ATTENTION (warning by cg):
in contrast to its inappropriate name, this class COMPLETELY ignores the model
instance variable - all is through the list/listHolder.
[Instance variables:]
selection <misc> the current selection. nil, a number or collection of numbers
multipleSelectOk <Boolean> allow/disallow multiple selections( default:false )
selectMenuButton <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
ListModelView
HierarchicalListView
copyrightCOPYRIGHT (c) 1999 by eXept Software AG
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
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
defaults
-
updateStyleCache
-
extract values from the styleSheet and cache them in class variables
Usage example(s):
accessing
-
cursorLine
-
returns the index of the cursor line or 0
-
list: aList
-
(comment from inherited method)
set the list of items
-
textStartLeft
( an extension from the stx:libtool package )
-
-
textStartLeft: something
( an extension from the stx:libtool package )
-
accessing-actions
-
action
-
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
-
action: anUpToTwoArgBlock
-
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
-
doubleClickAction
-
get the action block to be performed on doubleclick.
The arguments to the block are:
- no argument
- 1 argument selectedIndex
- 2 argument selectedIndex, self
-
doubleClickAction: anUpToTwoArgBlock
-
set the action block to be performed on doubleclick.
The arguments to the block are:
- no argument
- 1 argument selectedIndex
- 2 argument selectedIndex, self
-
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
the default (set in #initialize) is #select
-
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
the default (set in #initialize) is #select
-
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
-
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
-
selectConditionBlock
-
set the conditionBlock; this block is evaluated before a selection
change is performed; the change will not be done, if the evaluation
returns false
The arguments to the block are:
- no argument
- 1 argument index
- 2 argument index, isForAdd
-
selectConditionBlock: anUpToTwoArgBlock
-
set the conditionBlock; this block is evaluated before a selection
change is performed; the change will not be done, if the evaluation
returns false.
The arguments to the block are:
- no argument
- 1 argument index
- 2 argument index, isForAdd
accessing-attributes
-
highlightEnterItem
-
enable or disable to highlight the item over which the mouse pointer is located
-
highlightEnterItem: aBool
-
enable or disable to highlight the item over which the mouse pointer is located
-
highlightMode
-
get the mode how to draw a selected line:
#line draw whole line selected
#label draw label selected
#dropMode set during drop
-
highlightMode: aMode
-
set the mode how to draw a selected line:
#line draw whole line selected
#label draw label selected
#dropMode set during drop
-
highlightWithUnderline
-
-
hilightBackgroundColor
-
returns the color used for the hilighted background
-
hilightForegroundColor
-
returns the color used for the hilighted foreground
-
strikeout
-
turn on/off strikeOut mode
-
strikeout: aBoolean
-
turn on/off strikeOut mode
accessing-behavior
-
ignoreReselect
-
controls if clicking on an already selected item should
be ignored or should perform the select action again.
By default, these are ignored
-
ignoreReselect: aBoolean
-
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.
(for example, in browser to update a method).
Setting ignoreReselect to false makes sense if data is shown
which may change by itself (i.e. without the user doing anything)
For example, the inspector uses this, and redisplays the value,
if the selection is the same.
The default is true, meaning that a click on an already selected
does not lead to a notification via the actionBlock/change mechanism.
-
multipleSelectOk
-
return true if multiple selections are allowed; the default is false
-
multipleSelectOk: aBoolean
-
allow/disallow multiple selections. If enabled, the
user may select multiple entries in the list, and the program
always gets a collection of selected items (indexes if useIndex is true,
values otherwise). The default is false, for single selections.
-
selectOnButtonMenu
-
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
selectOnButtonMenu: aBoolean
-
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
selectOnButtonPress
-
get the selectOnButtonPress flag - see method #selectOnButtonPress: for more details
-
selectOnButtonPress: aBoolean
-
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
a drag without changing the real selection. The selection is changed during the
drag and restored after the drop.
-
selectOnMenuButton
-
define the menu-button (middle button) press behavior;
if true, the line under the mouse
will be selected before the menu is opened (Windows behavior).
Otherwise the selection is unchanged and the menu is opened
for the current selection (Unix behavior).
-
selectOnMenuButton: aBoolean
-
define the menu-button (middle button) press behavior;
if true, the line under the mouse
will be selected before the menu is opened (Windows behavior).
Otherwise the selection is unchanged and the menu is opened
for the current selection (Unix behavior).
-
toggleSelect
-
get the toggleSelect flag - see method #toggleSelect: for more details
-
toggleSelect: aBoolean
-
turn on/off toggle select. If true, clicking on a selected entry
unselects it and vice versa. The default is false, which means
that clicking on an already selected entry does not change its
select status (see also ignoreReselect).
-
useIndex
-
return the useIndex flag.
if true, the selection written to the model are the indices into the list;
if false, its the elements selected.
-
useIndex: aBoolean
-
set/clear the useIndex flag.
if true, the selection written to the model are the indices into the list;
if false, its the elements selected.
accessing-editor
-
closeEditor
-
close the current editor
Usage example(s):
iff the closeEditorAction opens a dialog and the editor looses its focus
|
-
closeEditorAction
-
get the block which is evaluated before the editor is closed; the argument
to the action is the editor.
-
closeEditorAction: anOneArgAction
-
get the block which is evaluated before the editor is closed; the argument
to the action is the editor.
-
hasOpenEditor
-
-
minimumEditorHeight
-
answer the minumium height of the editor or nil.
If the height is nil the height of the line is used
-
minimumEditorHeight: aHeightOrNil
-
set the minumium height of the editor or nil.
If the height is nil the height of the line is used
-
openEditor
-
opens the editor on the current selection;
returns the editorView or nil if no openEditorAction is defined
or no single selection exists ...
-
openEditorAction
-
get the block which is evaluated to get the editor which is set for the
line; the arguments to the block is the line number and the widget itself
-
openEditorAction: aTwoArgAction
-
set the block which is evaluated to get the editor which is set for the
line; the arguments to the block is the line number and the widget itself
change & update
-
argForChangeMessage
-
return the argument for a selectionChange;
depending on the setting of useIndex, this is either the numeric
index of the selection or the value (i.e. the string)
-
contentsChanged
-
this one is sent, whenever my contents changes its size
-
lineChangedAt: aLnNr with: arg
-
(comment from inherited method)
line changed at position; check whether line height changed
-
listSizeChanged: aLnNr nLines: aDeltaLines
-
(comment from inherited method)
list size changed; information is stored to recompute the
width if required( preferredExtent, horizontal scroller ... ).
see: widthOfContents
*** if nLines is negative, lines are removed otherwise added.
-
originChanged: delta
-
setup the origin of the editing view
-
selectionChanged
-
selection has changed. Call actionblock and/or send changeMessage if defined
-
updateFromModel
-
update selection from the model
drag & drop
-
canDrag
-
returns true if dragging is enabled
-
dragAutoScroll: aDropContext
-
called by the DragAndDropManager to scroll during a drag/drop operation
if required (decided by the widget itself).
If a scroll was done, return true;
otherwise false (used to restore the background)
-
dropSource
-
returns the dropSource or nil
-
dropSource: aDropSourceOrNil
-
set the dropSource or nil
-
startDragAt: aPoint
-
start drag at a point
drawing
-
drawElementsFrom: start to: stop x: x y: y w: w
-
draw the items between start to stop without clearing the background
-
drawFrom: start to: stop x: x y: y w: w
-
draw the lines between start to stop without clearing the background
-
drawLabelAt: anIndex x: xI y: y h: h
-
draw the label at position x/y without clearing the background
-
drawSelectionFrameAt: lnNr x: x w: w
-
draw the background and foreground of the selection frame
at a lineNr.
-
drawSelectionFrameFrom: start to: stop x: x y: y w: w
-
draw the selection frame between start to stop without clearing the background
-
invalidateSelection
-
invalidate (force async redraw) the current selection
-
invalidateSelectionAt: aLineNr
-
redraw a line which changed its selection status.
optimized when drawing only the label.
event handling
-
activateMenu
-
menu receiver:appl -- now done in findGuiResources ...
-
buttonControlPressAtLine: lineNr x: x y: y
-
handle a button control press
-
buttonMotion: buttonMask x: x y: y
-
mouse-move while button was pressed - handle selection changes
-
buttonMultiPress: button x: x y: y
-
button was pressed multiple - handle a doubleClick action
-
buttonPress: button x: x y: y
-
a button was pressed - handle selection here
-
buttonPressOrReleaseAtLine: aLnNr x: x y: y
-
handle a button press or release at a line
-
buttonRelease: button x: x y: y
-
a button was released
-
characterPress: aKey x: x y: y
-
a character is pressed - lookup and change selection
-
characterSearchItemStringAt: anIndex
-
for first-character search:
return a lines item-string.
For multi-col items, this may be different from the actual string
-
containerChangedSize
-
stupid kludge for motif-style (which draws a frame at the right-edge)
-
cursorEntersItem: anItemOrNil
-
the cursor enters an item or nil
-
doubleClicked
-
handle a double click
-
findLineFrom: aStart to: aStop by: aStep startingWithCharacter: aCharacter
-
find a line starting with a character
-
invalidateLineOfItem: anItem
-
-
keyPress: aKey x: x y: y
-
a key was pressed - handle page-keys here
-
pointerEntersItem: anItemOrNil
-
the pointer moves over an item or nil
-
pointerLeave: state
-
(comment from inherited method)
mouse pointer left
-
sizeChanged: how from: oldExtentOrNil
-
my view has changed the size (not the contents)
focus handling
-
showFocus: explicit
-
(comment from inherited method)
highlight myself somehow to tell user that I have the focus.
If explicit is true, the focus came via focusStepping (i.e. tabbing);
if false, it came via the window manager (i.e. pointer entering).
Only change my border, if this is an explicit focusChange.
-
showNoFocus: explicit
-
(comment from inherited method)
undo the effect of showFocus.
Explicit tells if the focus came via focusStepping (i.e. tabbing)
or via the window manager (i.e. pointer entering).
Only change my border, if this is an explicit focusChange.
-
wantsFocusWithPointerEnter
-
return true, if I want the focus when
the mouse pointer enters
help
-
helpTextAt: aPoint
-
for lines which are clipped, provide the full line as a tooltip
(as in other listviews)
initialization & release
-
fetchResources
-
fetch device colors and ..., to avoid reallocation at redraw time;
*** called after a create or snapin to fetch all device resources
-
initStyle
-
setup viewStyle specifics
-
initialize
-
setup default attributes/behavior
-
mapped
-
get selection from model; scroll to selection
-
realize
-
get selection from model; scroll to selection
private-editor
-
computeEditorLayout
-
update the layout of the editor
-
openEditorAtX: x y: y
-
opens an editor on the current single selection
protocol
-
lostSynchronisation
-
called when the changes derived from the model are faster than the handling
queries
-
elementsForWhich: aBlock
-
-
hasToSkipButtonMultiPress: button x: x y: y
-
return true if a button multi press at x@y should be skipped
-
isCursorKeyConsumer
-
return true, if the receiver can be controlled by cursor keys;
i.e. it can handle some keyboard input,
isCursorKeyConsumer are potential candidates for getting the keyboard
focus initially within dialogBoxes, or when the focus-follows-pointer
mode is off.
queries-contents
-
heightOfContents
-
answer the height of the contents in pixels.
If the minimumEditorHeight and the openEditorAction is defined,
we have to involve the minimumEditorHeight in the computation,
to allow opening the editor fullyvisible at the last line.
selection
-
addToSelection: lineNr
-
add line to selection without scrolling but raise a change notification
-
deselect
-
clear selection
-
firstInSelection
-
returns the minimum index of selected indices or nil if nothing is selected
-
hasSelection
-
true if an item is selected
-
indexOfElementForWhich: aBlock
-
-
isInSelection: aNumber
-
return true, if line, aNumber is in the selection
-
isSelectionVisible
-
returns true if any selected element is visible
-
isSelectionVisibleIn: anExtentPoint
-
returns true if any selected element is visible
-
lastInSelection
-
returns the maximum index of selected indices or nil if nothing is selected
-
makeSelectionVisible
-
scroll to make the selection line visible
don't scroll, if any in the selection isVisible
-
nextAfterSelection
-
return the index of the next selectable entry after the selection.
Wrap at end.
-
nextSelectableAfter: indexOrIndexCollection
-
return the index of the next selectable entry after the indexOrIndexCollection.
Wrap at end.
-
numberOfSelections
-
return the number of selected items
-
previousBeforeSelection
-
return the index of the previous selectable entry before the selection.
Wrap at beginning.
-
previousSelectableBefore: indexOrIndexCollection
-
return the index of the previous selectable entry before the indexOrIndexCollection.
Wrap at beginning.
-
removeFromSelection: lineNr
-
remove line from selection without scrolling but raise a change notification
-
selectAll
-
select all entries.
Model and/or actionBlock notification IS done.
-
selectElement: anElement
-
select the element. Scroll to make the new selection visible.
Model and/or actionBlock notification IS done.
-
selectElement: anElement ifAbsent: exceptionalValue
-
-
selectElementForWhich: aBlock ifAbsent: exceptionalValue
-
-
selectElements: aCollectionOfElement
-
select the elements.
Scroll to make the new selection visible.
Model and/or actionBlock notification IS done.
-
selectElements: aCollectionOfElements ifAnyAbsent: exceptionalValue
-
Transcript show:'view index search time:'; showCR:(Time millisecondsToRun:[
-
selectFirst
-
select the first selectable element.
Model and/or actionBlock notification IS done.
-
selectFirstVisibleLine
-
select the first visible selectable element.
Model and/or actionBlock notification IS done.
-
selectFrom: aStart to: aStop
-
select lines between start and stop
-
selectLast
-
select the last selectable element.
Model and/or actionBlock notification IS done.
-
selectNext
-
select next line or first visible if there is currently no selection.
Wrap at end.
Model and/or actionBlock notification IS done.
-
selectPrevious
-
select previous line or previous visible if there is currently no selection.
Wrap at beginning.
Model and/or actionBlock notification IS done.
-
selectedElement
-
return the single selected item or nil
-
selectedIndex
-
returns the index of the selected line or 0.
If multiple lines are selected, 0 is returned
-
selection
-
return the selection index or collection of indices
in case of multiple selection enabled
-
selection: indexOrIndexCollection
-
select something or deselect if the argument is nil;
indexOrIndexCollection is either an individual index
or (if multiSelect is enabled) a collection of indices.
Scroll to make the selected line visible.
The model and/or actionBlock IS notified.
-
selectionAsCollection
-
return the selection as a collection of line numbers.
This allows users of this class to enumerate independent of
the multipleSelect style.
-
selectionDo: aBlock
-
perform aBlock for each nr in the selection.
For single selection, it is called once for the items nr.
For multiple selections, it is called for each.
-
selectionValue
-
return the selection value i.e. the text in the selected line.
For multiple selections a collection containing the entries is returned.
-
selectionValueAsCollection
-
return the selection values as a collection - allows selectionValues to
be enumerated independent of the multiSelect settings
-
setSelection: indexOrIndexCollection
-
select something or deselect if the argument is nil;
scroll to make the selected line visible.
*** No model and/or actionBlock notification is done here.
selection private
-
canSelectIndex: anIndex
-
return true, if the object identified by its index is selectable
-
canSelectIndex: anIndex forAdd: isForAdd
-
return true, if the object identified by its index is selectable
-
deselectWithoutRedraw
-
clear the selection without redraw and scrolling;
the model and/or actionBlock is notified
-
selectAndUpdateModelWithoutChangeNotification: aLineNo
-
-
selectWithoutScroll: newSelection redraw: doRedraw
-
change selection to something;
newSelection is either an individual index
or (if multiSelect is enabled) a collection of indices.
Returns true if selection changed
|top list view|
list := List new.
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.
view list:list.
top open.
|
|top list view|
list := List new.
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.
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
].
top open.
|
|top list view item|
list := HierarchicalList new.
item := HierarchicalItem::Example labeled:'Test'.
item expand.
list showRoot:false.
list root:item.
top := StandardSystemView new; extent:300@300.
view := ScrollableView for:SelectionInListModelView miniScroller:true
origin:0.0@0.0 corner:1.0@1.0 in:top.
view list:list.
view doubleClickAction:[:i| (list at:i) toggleExpand ].
top open.
|
ca
|top list view|
list := List new.
1 to:100 do:[:i| list add:('element: ', i printString) ].
top := StandardSystemView extent:300@300.
view := ScrollableView for:SelectionInListModelView miniScroller:true
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
].
view list:list.
top open.
|