|
Class: ListModelView
Object
|
+--GraphicsMedium
|
+--DisplaySurface
|
+--SimpleView
|
+--View
|
+--ListModelView
|
+--SelectionInListModelView
- Package:
- stx:libwidg2
- Category:
- Views-Lists
- Version:
- rev:
1.216
date: 2024/03/01 11:45:21
- user: stefan
- file: ListModelView.st directory: libwidg2
- module: stx stc-classLibrary: libwidg2
This widget is a new improved revision of the good-old ListView.
In contrast to ListView, this one reacts on changes of the
underlying list and performs optimized redraws.
It requires a List (or alike) as list.
This class can only passively display collections of elements.
The class doesn't keep its own list, it works directly on
the list ( List or HierarchicalList ).
ATTENTION (warning by cg):
in contrast to its inappropriate name, this class COMPLETELY ignores the model
instance variable - all is through the list/listHolder.
Each list item is obligated to provide 3 services:
- heightOn:aGC
- widthOn:aGC
- displayOn:aGC x:x y:y
[Instance variables:]
list <List-Model> List or HierarchicalList ...
listHolder <Model> Model, which keeps a List
textStartLeft <Number> left inset of text
viewOrigin <Point> the current origin
enabled <Boolean> widget is enabled/disabeled
fgColor <Color> color to draw characters
bgColor <Color> the background
lineSpacing <Number> pixels between lines
widthOfContents <Number> cached width of widest line
computeWidthInRange <Point> used for recompute width of contents
startOfLinesY <Collection> keeps all the absolute Y-start positions
for each line in the list. The first
entry into the list is the top Y inset.
supportsDisplayInRange <Boolean> set to true if the list elements
supports the service:
#displayOn:x:y:h:
hasConstantHeight <Boolean> true, than each line has the same height
constantHeight <SmallInteger> hasConstantHeight is turned on, this
is the used line height
SelectionInListModelView
HierarchicalListView
List
HierarchicalList
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.
bug1shown contents is not updated, until scrolled slightly
or resized
bug2shown contents is not updated, until scrolled slightly
or resized
Signal constants
-
stopRedrawSignal
-
defaults
-
defaultRenderer
-
-
updateStyleCache
-
extract values from the styleSheet and cache them in class variables
Usage example(s):
initialization
-
initialize
-
setup the signals
accessing
-
list
-
get the list of items
-
list: aList
-
set the list of items
-
listRenderer
-
returns the used listrenderer
-
listRenderer: aRendererOrRendererClass
-
change the used listRenderer
-
renderer
-
(comment from inherited method)
warning: this is experimental and not yet implemented
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
renderer: aTableRenderer
-
(comment from inherited method)
warning: this is experimental and not yet implemented
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
setupTableRenderer
-
creates a renderer with columns based on a DataSetColumnSpec
answer the new renderer
accessing-behavior
-
autoScroll
-
returns true if auto scrolling is enabled
-
autoScroll: aBool
-
returns true if auto scrolling is enabled
-
enabled
-
returns the enabled state
-
enabled: aBoolean
-
set the enabled state
-
hasConstantHeight
-
user configured; true if each line has the same lineHeight.
Optimizes scroll and redraw operations
-
hasConstantHeight: aBool
-
user configured; true if each line has the same lineHeight.
Optimizes scrolling and redraw.
-
scrollWhenUpdating
-
return how to scroll, when I get a new text
(via the model or the #contents/#list)
Possible return values are:
#keep / nil -> no change
#endOfText -> scroll to the end
#beginOfText -> scroll to the top
The default is #beginOfText.
This may be useful for fields which get new values assigned from
the program (i.e. not from the user)
-
scrollWhenUpdating: aSymbolOrNil
-
define how to scroll, when I get a new text
(via the model or the #contents/#list)
Allowed arguments are:
#keep / nil -> no change
#endOfText -> scroll to the end
#beginOfText -> scroll to the top
The default is #beginOfText.
This may be useful for fields which get new values assigned from
the program (i.e. not from the user)
accessing-items
-
at: anIndex
-
return the list element at an index
-
at: anIndex ifAbsent: exceptionBlock
-
return the list element at an index if valid.
If the index is invalid, return the result of evaluating
the exceptionblock.
-
findLast: aOneArgBlock
-
find the last list entry, for which evaluation of the argument, aOneArgBlock
returns true; return its index or 0 if none detected.
-
identityIndexOf: anElement
-
returns the index of an element or nil
-
last
-
returns the last list entry
-
listAt: anIndex
-
for protocol compatibility with SelectionInListView
accessing-look
-
backgroundColor
-
get the background color
-
font: aFont
-
set a new font
-
foregroundColor
-
get the foreground color
-
foregroundColor: aColor
-
set the foreground color
-
lineSpacing
-
get the lineSpacing - that's an additional number of pixels,
by which lines are vertically separated.
-
lineSpacing: aNumber
-
set the lineSpacing - that's an additional number of pixels,
by which lines are vertically separated.
-
viewBackground: aColor
-
set the background color
accessing-mvc
-
listHolder
-
returns the listHolder or nil
-
listHolder: aListHolder
-
set a new listHolder
change & update
-
lineChangedAt: aLnNr with: arg
-
line changed at position; check whether line height changed
-
listChangedInsert: start nItems: nLines
-
list changed; items are added
-
listChangedRemove: aStart toIndex: aStop
-
list changed; items were removed from indices aStart to aStop
-
update: what with: aPara from: chgObj
-
catch and handle any notification raised from the list model
or list holder
-
updateFromList: what with: aParameter
-
called if the list changed
drawing
-
drawElementsFrom: start to: stop x: x y: y w: w
-
draw lines from start to stop.
clipping and clearing the background is already done
-
drawFrom: start to: stop x: xLft y: yTop w: aWidth
-
draw lines from start to stop. Test whether a new clip
must be setup.
-
drawSelectionFrameFrom: start to: stop x: x y: y w: w
-
What to do here?
-
invalidateLineAt: aLineNr
-
add a damage to redraw a line specified by its line number to the
input event queue.
-
invalidateLineAt: aLineNr fromX: x
-
add a damage to redraw a line specified by its line number to the
input event queue.
-
redraw
-
redraw complete view
-
redrawX: x y: y width: w height: h
-
redraw part of myself immediately, given logical coordinates
enumerating
-
visibleLinesAndItemsDo: aTwoArgBlock
-
enumerate over each visible item
event handling
-
keyPress: aKey x: x y: y
-
a key was pressed - handle page-keys here
Usage example(s):
super keyPress:aKey x:x y:y
|
-
keyboardZoom: largerBoolean
-
ALT+/- (was: CTRL+/-) zoom action
-
mouseWheelZoom: amount
-
(comment from inherited method)
CTRL-wheel action.
ignored here - redefined in views which can zoom
-
sizeChanged: how from: oldExtentOrNil
-
my view has changed the size (not the contents)
event simulation
-
syncronizeEvents
-
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
syncronizeEvents: aBoolean
-
** This is an obsolete interface - do not use it (it may vanish in future versions) **
fetch resources
-
colorOnDevice: aColor
-
fetch a device colors
-
imageOnMyDevice: anImage
-
associate image to device and returns the new image.
focus handling
-
wantsFocusWithButtonPress
-
catch the keyboard focus on button click
-
wantsFocusWithPointerEnter
-
views which like to take the keyboard focus
when the pointer enters can do so by redefining this
to return true
initialization & release
-
create
-
fetch device dependent resources
-
initStyle
-
setup viewStyle specifics
-
initialize
-
setup default attributes
-
mapped
-
recompute list
-
recreate
-
sent after a snapin or a migration, reinit for new device
-
reinitialize
-
reinit after snapIn (font geometry might be different)
-
release
-
remove dependencies
private
-
hasDamage
-
return true, if any damage events (i.e. expose or resize) are pending
-
startOfLinesY
-
returns a collection of absolute Y-positions per line.
The first entry is the top Y inset.
The size of the list is one more than the lists size,
providing the Y-position of the line below the contents as its last entry.
-
xAbsoluteOfItem: anItem
-
returns the absolute x of the labeled text
-
xVisibleOfItem: anItem
-
returns the visible x of the labeled text
-
yAbsoluteOfLine: aLineNr
-
given a lineNr, return its y-coordinate
this returns the coordinate in absolute coordinates.
(i.e. subtract the scrollOffset in viewOrigin to get the position within the window,
and subtract the scrollOffset and add the view's screenorigin, to get the position on the screen)
-
yAbsoluteToLineNr: yAbsolute
-
returns the line number for a given physical y coordinate
or nil if beyond of list.
-
yAbsoluteToRowNr: yVisible
-
for protocol compatibility with DSVColumnView
-
yVisibleOfLine: aLineNr
-
given a lineNr, return the y-coordinate within the view
-
yVisibleToLineNr: yVisible
-
returns the line number for a given physical y coordinate
or nil if beyond of list.
-
yVisibleToRowNr: yVisible
-
for protocol compatibility with DSVColumnView
protocol
-
fetchResources
-
fetch device colors and ..., to avoid reallocation at redraw time;
*** called after a create or snapin to fetch all device resources
-
heightForLines: numberOfLines
-
-
lineHeightFor: anItem
-
returns the computed line height for an item
-
listSizeChanged: anIndex nLines: noLines
-
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.
-
lostSynchronisation
-
called when the changes derived from the model are faster than the handling
-
newDefaultList
-
creates and returns a new default list; by default, an instance of List
-
widthOfWidestLineBetween: firstLine and: lastLine
-
return the width in pixels of the widest line in a range
- used to optimize scrolling, by limiting the scrolled area;
not for scrollbar or other width related stuff which should be exact.
queries
-
isLineFullyVisible: aLineNr
-
returns true if the line is fully visible
-
isLineVisible: aLineNr
-
returns true if the line is visible
-
isLineVisible: aLineNr in: anExtentPoint
-
returns true if the line is visible inside the top margin and the y given by the point
-
lineIsFullyVisible: aLineNr
-
returns true if the line is fully visible
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
numberOfLines
-
return the number of lines the text has
(protocol compat. with SelectionInListView)
-
size
-
returns the number of list entries
queries-contents
-
heightOfContents
-
return the height of the contents in pixels
-
widthOfContents
-
return the width of the contents in pixels
recomputation
-
computePreferredExtent
-
returns the preferred extent
-
recomputeHeightOfContents
-
recompute all the (cached) y positions
scroller interface
-
getWidthOfContents
-
-
heightOfAnyNonNilItem
-
returns the height of a line at an index (including lineSpacing...)
-
heightOfLineAt: aLineNr
-
returns the height of a line at an index (including lineSpacing...)
-
innerHeight
-
returns the inner height of the contents shown
-
innerWidth
-
returns the inner width of the contents shown
-
maxViewOriginY
-
returns the maximum possible y of the view origin
-
realHeightOfLineAt: aLineNr
-
returns the real (uncached) height of a line at an index
-
setWidthOfContents: aWidth
-
-
verticalScrollStep
-
return the amount to scroll when stepping up/down (also used for mouseWheel).
-
viewOrigin
-
return the viewOrigin; that's the coordinate of the contents
which is shown topLeft in the view.
-
xOriginOfContents
-
return the horizontal origin of the contents in pixels
-
yOriginOfContents
-
return the vertical origin of the contents in pixels
scrolling
-
basicScrollTo: anOrigin redraw: doRedraw
-
change origin to have newOrigin be visible at the top-left.
-
halfPageDown
-
scroll down half a page
-
halfPageUp
-
scroll up half a page
-
makeLineVisible: aLnNr
-
make the line visible
-
scrollTo: anOrigin redraw: doRedraw
-
change origin to have newOrigin be visible at the top-left.
-
scrollToEndOfText
-
-
scrollToLine: aLineNumber
-
make line visible
scrolling auto
-
startAutoScroll: aSelectorOrBlock distance: aDistance
-
setup for auto-scroll (when button-press-moving below/above view);
- timeDelta for scroll is computed from distance
-
stopAutoScroll
-
stop any autoScroll
selection
-
hasSelection
-
by default, false is returned here (redefined in SelectionInListModelView)
Renderer
TableRenderer
|top list view up index|
list := List new.
top := StandardSystemView new; extent:300@300.
view := ScrollableView for:ListModelView miniScroller:true
origin:0.0@0.0 corner:1.0@1.0 in:top.
view list:list.
top openAndWaitUntilVisible.
up := true.
[top shown] whileTrue:[
Delay waitForSeconds:0.2.
up ifTrue:[
index := 1 + (list size).
list add:('element: ', index printString).
up := index < 20
] ifFalse:[
list removeIndex:1.
up := list isEmpty.
]
].
|
|