eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'SelectionInListModelView':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: SelectionInListModelView


Inheritance:

   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

Description:


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

copyright

COPYRIGHT (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.

Class protocol:

defaults
o  updateStyleCache
extract values from the styleSheet and cache them in class variables

Usage example(s):

     self updateStyleCache


Instance protocol:

accessing
o  cursorLine
returns the index of the cursor line or 0

o  list: aList
(comment from inherited method)
set the list of items

o  textStartLeft
( an extension from the stx:libtool package )

o  textStartLeft: something
( an extension from the stx:libtool package )

accessing-actions
o  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

o  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

o  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

o  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

o  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

o  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

o  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

o  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

o  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

o  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
o  highlightEnterItem
enable or disable to highlight the item over which the mouse pointer is located

o  highlightEnterItem: aBool
enable or disable to highlight the item over which the mouse pointer is located

o  highlightMode
get the mode how to draw a selected line:
#line draw whole line selected
#label draw label selected
#dropMode set during drop

o  highlightMode: aMode
set the mode how to draw a selected line:
#line draw whole line selected
#label draw label selected
#dropMode set during drop

o  highlightWithUnderline

o  hilightBackgroundColor
returns the color used for the hilighted background

o  hilightForegroundColor
returns the color used for the hilighted foreground

o  strikeout
turn on/off strikeOut mode

o  strikeout: aBoolean
turn on/off strikeOut mode

accessing-behavior
o  ignoreReselect
controls if clicking on an already selected item should
be ignored or should perform the select action again.
By default, these are ignored

o  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.

o  multipleSelectOk
return true if multiple selections are allowed; the default is false

o  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.

o  selectOnButtonMenu

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  selectOnButtonMenu: aBoolean

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  selectOnButtonPress
get the selectOnButtonPress flag - see method #selectOnButtonPress: for more details

o  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.

o  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).

o  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).

o  toggleSelect
get the toggleSelect flag - see method #toggleSelect: for more details

o  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).

o  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.

o  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
o  closeEditor
close the current editor

Usage example(s):

iff the closeEditorAction opens a dialog and the editor looses its focus

o  closeEditorAction
get the block which is evaluated before the editor is closed; the argument
to the action is the editor.

o  closeEditorAction: anOneArgAction
get the block which is evaluated before the editor is closed; the argument
to the action is the editor.

o  hasOpenEditor

o  minimumEditorHeight
answer the minumium height of the editor or nil.
If the height is nil the height of the line is used

o  minimumEditorHeight: aHeightOrNil
set the minumium height of the editor or nil.
If the height is nil the height of the line is used

o  openEditor
opens the editor on the current selection;
returns the editorView or nil if no openEditorAction is defined
or no single selection exists ...

o  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

o  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
o  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)

o  contentsChanged
this one is sent, whenever my contents changes its size

o  lineChangedAt: aLnNr with: arg
(comment from inherited method)
line changed at position; check whether line height changed

o  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.

o  originChanged: delta
setup the origin of the editing view

o  selectionChanged
selection has changed. Call actionblock and/or send changeMessage if defined

o  updateFromModel
update selection from the model

drag & drop
o  canDrag
returns true if dragging is enabled

o  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)

o  dropSource
returns the dropSource or nil

o  dropSource: aDropSourceOrNil
set the dropSource or nil

o  startDragAt: aPoint
start drag at a point

drawing
o  drawElementsFrom: start to: stop x: x y: y w: w
draw the items between start to stop without clearing the background

o  drawFrom: start to: stop x: x y: y w: w
draw the lines between start to stop without clearing the background

o  drawLabelAt: anIndex x: xI y: y h: h
draw the label at position x/y without clearing the background

o  drawSelectionFrameAt: lnNr x: x w: w
draw the background and foreground of the selection frame
at a lineNr.

o  drawSelectionFrameFrom: start to: stop x: x y: y w: w
draw the selection frame between start to stop without clearing the background

o  invalidateSelection
invalidate (force async redraw) the current selection

o  invalidateSelectionAt: aLineNr
redraw a line which changed its selection status.
optimized when drawing only the label.

event handling
o  activateMenu
menu receiver:appl -- now done in findGuiResources ...

o  buttonControlPressAtLine: lineNr x: x y: y
handle a button control press

o  buttonMotion: buttonMask x: x y: y
mouse-move while button was pressed - handle selection changes

o  buttonMultiPress: button x: x y: y
button was pressed multiple - handle a doubleClick action

o  buttonPress: button x: x y: y
a button was pressed - handle selection here

o  buttonPressOrReleaseAtLine: aLnNr x: x y: y
handle a button press or release at a line

o  buttonRelease: button x: x y: y
a button was released

o  characterPress: aKey x: x y: y
a character is pressed - lookup and change selection

o  characterSearchItemStringAt: anIndex
for first-character search:
return a lines item-string.
For multi-col items, this may be different from the actual string

o  containerChangedSize
stupid kludge for motif-style (which draws a frame at the right-edge)

o  cursorEntersItem: anItemOrNil
the cursor enters an item or nil

o  doubleClicked
handle a double click

o  findLineFrom: aStart to: aStop by: aStep startingWithCharacter: aCharacter
find a line starting with a character

o  invalidateLineOfItem: anItem

o  keyPress: aKey x: x y: y
a key was pressed - handle page-keys here

o  pointerEntersItem: anItemOrNil
the pointer moves over an item or nil

o  pointerLeave: state
(comment from inherited method)
mouse pointer left

o  sizeChanged: how from: oldExtentOrNil
my view has changed the size (not the contents)

focus handling
o  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.

o  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.

o  wantsFocusWithPointerEnter
return true, if I want the focus when
the mouse pointer enters

help
o  helpTextAt: aPoint
for lines which are clipped, provide the full line as a tooltip
(as in other listviews)

initialization & release
o  fetchResources
fetch device colors and ..., to avoid reallocation at redraw time;
*** called after a create or snapin to fetch all device resources

o  initStyle
setup viewStyle specifics

o  initialize
setup default attributes/behavior

o  mapped
get selection from model; scroll to selection

o  realize
get selection from model; scroll to selection

private-editor
o  computeEditorLayout
update the layout of the editor

o  openEditorAtX: x y: y
opens an editor on the current single selection

protocol
o  lostSynchronisation
called when the changes derived from the model are faster than the handling

queries
o  elementsForWhich: aBlock

o  hasToSkipButtonMultiPress: button x: x y: y
return true if a button multi press at x@y should be skipped

o  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
o  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
o  addToSelection: lineNr
add line to selection without scrolling but raise a change notification

o  deselect
clear selection

o  firstInSelection
returns the minimum index of selected indices or nil if nothing is selected

o  hasSelection
true if an item is selected

o  indexOfElementForWhich: aBlock

o  isInSelection: aNumber
return true, if line, aNumber is in the selection

o  isSelectionVisible
returns true if any selected element is visible

o  isSelectionVisibleIn: anExtentPoint
returns true if any selected element is visible

o  lastInSelection
returns the maximum index of selected indices or nil if nothing is selected

o  makeSelectionVisible
scroll to make the selection line visible
don't scroll, if any in the selection isVisible

o  nextAfterSelection
return the index of the next selectable entry after the selection.
Wrap at end.

o  nextSelectableAfter: indexOrIndexCollection
return the index of the next selectable entry after the indexOrIndexCollection.
Wrap at end.

o  numberOfSelections
return the number of selected items

o  previousBeforeSelection
return the index of the previous selectable entry before the selection.
Wrap at beginning.

o  previousSelectableBefore: indexOrIndexCollection
return the index of the previous selectable entry before the indexOrIndexCollection.
Wrap at beginning.

o  removeFromSelection: lineNr
remove line from selection without scrolling but raise a change notification

o  selectAll
select all entries.
Model and/or actionBlock notification IS done.

o  selectElement: anElement
select the element. Scroll to make the new selection visible.
Model and/or actionBlock notification IS done.

o  selectElement: anElement ifAbsent: exceptionalValue

o  selectElementForWhich: aBlock ifAbsent: exceptionalValue

o  selectElements: aCollectionOfElement
select the elements.
Scroll to make the new selection visible.
Model and/or actionBlock notification IS done.

o  selectElements: aCollectionOfElements ifAnyAbsent: exceptionalValue
Transcript show:'view index search time:'; showCR:(Time millisecondsToRun:[

o  selectFirst
select the first selectable element.
Model and/or actionBlock notification IS done.

o  selectFirstVisibleLine
select the first visible selectable element.
Model and/or actionBlock notification IS done.

o  selectFrom: aStart to: aStop
select lines between start and stop

o  selectLast
select the last selectable element.
Model and/or actionBlock notification IS done.

o  selectNext
select next line or first visible if there is currently no selection.
Wrap at end.
Model and/or actionBlock notification IS done.

o  selectPrevious
select previous line or previous visible if there is currently no selection.
Wrap at beginning.
Model and/or actionBlock notification IS done.

o  selectedElement
return the single selected item or nil

o  selectedIndex
returns the index of the selected line or 0.
If multiple lines are selected, 0 is returned

o  selection
return the selection index or collection of indices
in case of multiple selection enabled

o  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.

o  selectionAsCollection
return the selection as a collection of line numbers.
This allows users of this class to enumerate independent of
the multipleSelect style.

o  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.

o  selectionValue
return the selection value i.e. the text in the selected line.
For multiple selections a collection containing the entries is returned.

o  selectionValueAsCollection
return the selection values as a collection - allows selectionValues to
be enumerated independent of the multiSelect settings

o  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
o  canSelectIndex: anIndex
return true, if the object identified by its index is selectable

o  canSelectIndex: anIndex forAdd: isForAdd
return true, if the object identified by its index is selectable

o  deselectWithoutRedraw
clear the selection without redraw and scrolling;
the model and/or actionBlock is notified

o  selectAndUpdateModelWithoutChangeNotification: aLineNo

o  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


Examples:


    |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.

ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Thu, 21 Nov 2024 17:05:55 GMT