|
Class: ObjectView
Object
|
+--GraphicsMedium
|
+--DisplaySurface
|
+--SimpleView
|
+--View
|
+--ObjectView
|
+--BarChart3DWidget
- Package:
- stx:libwidg
- Category:
- Views-Basic
- Version:
- rev:
1.160
date: 2023/08/31 13:18:04
- user: cg
- file: ObjectView.st directory: libwidg
- module: stx stc-classLibrary: libwidg
a View which can hold DisplayObjects, can make selections, move them around etc.
ObjectView is an abstract class providing common mechanisms
(i.e. a whiteBox framework, to be used by concrete subclasses).
Actual instances are DrawView, DirectoryView, LogicView or DocumentView.
If you want to use this class, have a special look at the pluggable behavior, especially,
pressAction, releaseAction etc.:
[Instance variables:]
contents <Collection> the objects. The order in which
these are in that collection defines
their appearance in the z-plane:
an object located after another one
here will be drawn ABOVE the other.
sorted <Boolean> if set, redraw and picking methods
assume that the objects are sorted by
>= y-coordinates. These operations are
a bit faster then, since a binary search
can be done. (use with care).
lastButt <Point> last pointer press position
(internal)
pressAction <Block> action to perform when mouse pointer
is pressed. Can be set to something like
[self startCreate], [self startSelectOrMove]
etc.
releaseAction <Block> action to perform when mouse pointer is
released. Typically set in one of the
startXXX methods.
shiftPressAction <Block> like pressAction, if shift key is
pressed.
doublePressAction <Block> same for double-clicks
motionAction <Block> action to perform on mouse-pointer
motion.
keyPressAction <Block> action for keyboard events
selection <any> the current selection; either a single
object or a collection of objects.
gridShown <Boolean> internal
gridPixmap <Form> internal
scaleMetric <Symbol> either #mm or #inch; used to
decide how the grid is defined
dragObject internal
leftHandCursor cursor shown while dragging a rectangle
oldCursor saved original cursor while dragging a rectangle
movedObject internal
moveStartPoint internal
moveDelta internal
documentFormat <Symbol> defines the size and layout of the
document. Can be any of
#letter, #a4, #a3 etc.
canDragOutOfView <Boolean> if true, objects can be dragged out of the
view. If false, dragging is restricted to within
this view.
rootMotion internal
rootView internal
aligning <Boolean> if true, pointer positions are
aligned (snapped) to the point
specified in gridAlign
gridAlign <Point> if aligning is true, this point
defines the snapping. For example,
12@12 defines snap to the nearest
12-point grid.
written spring/summer 89 by claus
copyrightCOPYRIGHT (c) 1989 by Claus Gittinger
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
-
handleSize
-
size of blob drawn for handles
-
hitDelta
-
when clicking an object, allow for hitDelta pixels around object;
0 is exact; 1*pixelPerMillimeter is good for draw programs
-
mouseMotionDeltaForMove
-
-
mouseMotionTimeDeltaForMove
-
accessing
-
aligning
-
-
aligningMove
-
-
aligningMove: aBoolean
-
-
contents
-
-
gridShown
-
accessing-behavior
-
ctrlPressAction: aBlock
-
-
doublePressAction: aBlock
-
-
keyPressAction: aBlock
-
-
motionAction: aBlock
-
-
pressAction: aBlock
-
-
releaseAction: aBlock
-
-
setDefaultActions
-
setup actions for default behavior (do - nothing)
-
shiftPressAction: aBlock
-
adding & removing
-
add: something
-
add something, anObject or a collection of objects to the contents
with redraw
-
addObject: anObject
-
add the argument, anObject to the contents - with redraw
-
addObjectFirst: anObject
-
add the argument, anObject to the beginning of the contents - with redraw
-
addObjectFirstWithoutRedraw: anObject
-
add the argument, anObject to the start of the contents - no redraw
-
addObjectWithoutRedraw: anObject
-
add the argument, anObject to the contents - no redraw
-
addSelected: something
-
add something, anObject or a collection of objects to the contents
and select it
-
addWithoutRedraw: something
-
add something, anObject or a collection of objects to the contents
do not redraw
-
contents: aCollectionOfObjects
-
-
remove: something
-
remove something, anObject or a collection of objects from the contents
do redraw
-
removeAll
-
remove all - redraw
-
removeAllWithoutRedraw
-
remove all - no redraw
-
removeObject: anObject
-
remove the argument, anObject from the contents - no redraw
-
removeObjectWithoutRedraw: anObject
-
remove the argument, anObject from the contents - no redraw
-
removeWithoutRedraw: something
-
remove something, anObject or a collection of objects from the contents
do not redraw
cut & paste
-
convertForPaste: anObject
-
return a converted version of anObject to be pasted, or nil if
the object is not compatible with me.
Return nil here; concrete subclasses should try to convert.
Notice: anObject may be a collection of to-be-pasted objects.
-
copySelection
-
copy the selection into the cut&paste-buffer
-
cutSelection
-
cut the selection into the cut&paste buffer
-
deleteSelection
-
delete the selection
-
paste: something
-
add the objects in the cut&paste-buffer
-
pasteBuffer
-
add the objects in the paste-buffer
dragging-line
-
doLineDrag: aPoint
-
do drag a line
-
endLineDrag
-
cleanup after line drag; select them. Find the origin and destination
views and relative offsets, then dispatch to one of the endLineDrag methods.
These can be redefined in subclasses to allow connect between views.
-
invertDragLine
-
helper for line dragging - invert the dragged line.
Extracted for easier redefinition in subclasses
(different line width etc.)
-
lineDragFrom: startPoint to: endPoint
-
this is called after a line-drag. Nothing is done here.
- should be redefined in subclasses
-
lineDragFrom: startPoint to: endPoint in: destinationView
-
this is called after a line-drag crossing view boundaries.
- should be redefined in subclasses
-
lineDragFrom: startPoint to: endPoint inAlienViewId: destinationId
-
this is called after a line-drag with rootmotion set
to true, IFF the endpoint is in an alien view
- should be redefined in subclasses
-
setLineDragActions
-
setup to drag a line. Call this (for example) from your buttonPress
method, to make the view start to drag a line.
See startLineDrag and startRootLineDrag.
-
startLineDrag: startPoint
-
start a line drag within the view
-
startRootLineDrag: startPoint
-
start a line drag possibly crossing my view boundaries
dragging-object
-
doObjectMove: aPoint
-
do an object move - this is called for every motion
when moving objects.
-
endObjectMove
-
cleanup after object move - called when the object move ends.
Find the destination view and position and dispatch to
one of the moveObjectXXX-methods which should do the real move.
These can be redefined in subclasses.
-
invertDragObject: movedObject delta: moveDelta
-
draw inverting for an object move
-
setMoveActions
-
setup to drag an object. Call this (for example) from your buttonPress
method, to make the view start to drag some object.
See startObjectMove and startRootObjectMove.
-
startObjectMove: something at: aPoint
-
start an object move
-
startObjectMove: something at: aPoint inRoot: inRoot
-
start an object move; if inRoot is true, view
boundaries may be crossed.
-
startRootObjectMove: something at: aPoint
-
start an object move, possibly crossing view boundaries
dragging-rectangle
-
doRectangleDrag: aPoint
-
do drag a rectangle
-
endRectangleDrag
-
cleanup after rectangle drag; select them
-
invertDragRectangle
-
helper for rectangle drag - invert the dragRectangle.
Extracted into a separate method to allow easier redefinition
(different lineWidth etc)
-
setRectangleDragActions
-
setup to drag a rectangle. Call this (for example) from your buttonPress
method, to make the view start the drag.
See startRectangleDrag:.
-
startRectangleDrag: startPoint
-
start a rectangle drag
drawing
-
redraw
-
redraw complete View
-
redrawObjects
-
redraw all objects
-
redrawObjectsAbove: anObject in: aRectangle
-
redraw all objects which have part of themselfes in aRectangle
and are above (in front of) anObject.
draw only in (i.e. clip output to) aRectangle
-
redrawObjectsAbove: anObject inVisible: aRectangle
-
redraw all objects which have part of themselfes in a vis rectangle
and are above (in front of) anObject.
draw only in (i.e. clip output to) aRectangle
-
redrawObjectsAbove: anObject intersecting: aRectangle
-
redraw all objects which have part of themself in aRectangle
and are above (in front of) anObject
-
redrawObjectsAbove: anObject intersectingVisible: aRectangle
-
redraw all objects which have part of themself in a vis rectangle
and are above (in front of) anObject
-
redrawObjectsIn: aRectangle
-
redraw all objects which have part of themselfes in aRectangle
draw only in (i.e. clip output to) aRectangle
-
redrawObjectsInVisible: visRect
-
redraw all objects which have part of themselfes in a vis rectangle
draw only in (i.e. clip output to) aRectangle
-
redrawObjectsIntersecting: aRectangle
-
redraw all objects which have part of themself in aRectangle
-
redrawObjectsIntersectingVisible: aRectangle
-
redraw all objects which have part of themself in a vis rectangle
This is a leftOver from times when scrolling was not transparent.
Please use redrawObjectsIntersecting:, since this will vanish.
-
redrawObjectsOn: aGC
-
redraw all objects on a graphic context
-
redrawScale
-
redraw the scales
-
show: anObject
-
show the object, either selected or not
-
showDragging: something offset: anOffset
-
show an object while dragging
-
showSelected: anObject
-
show an object as selected
-
showUnselected: anObject
-
show an object as unselected
enumerating
-
contentsDo: aBlock
-
event handling
-
buttonCtrlPress: button x: x y: y
-
user pressed left button with ctrl
-
buttonMotion: buttonState x: buttX y: buttY
-
user moved mouse while button pressed
-
buttonMultiPress: button x: x y: y
-
user pressed left button twice (or more)
-
buttonPress: button x: x y: y
-
user pressed left button
-
buttonRelease: button x: x y: y
-
(comment from inherited method)
button was released - check my components for a hit.
-
buttonShiftPress: button x: x y: y
-
user pressed left button with shift
-
keyPress: key x: x y: y
-
(comment from inherited method)
a key has been pressed. If there are components,
pass it to the corresponding one.
Otherwise, forward it to the superview, if there is any.
-
redrawX: x y: y width: w height: h
-
self clearRectangle:redrawFrame.
focus control
-
wantsFocusWithPointerEnter
-
(comment from inherited method)
views which like to take the keyboard focus
when the pointer enters can do so by redefining this
to return true
grid manipulation
-
alignOff
-
do no align point to grid
-
alignOn
-
align points to grid
-
defineGrid
-
define the grid pattern - this creates the gridPixmap, which is
used as viewBackground when a grid is to be shown.
The grid is specified by the value returned from gridParameters,
which can be redefined in subclasses. See the comment there on how
the numbers are interpreted.
-
getAlignParameters
-
-
gridParameters
-
used by defineGrid, and in a separate method for
easier redefinition in subclasses.
Returns the grid parameters in an array of 7 elements,
which control the appearance of the grid-pattern.
the elements are:
bigStepH number of pixels horizontally between 2 major steps
bigStepV number of pixels vertically between 2 major steps
littleStepH number of pixels horizontally between 2 minor steps
littleStepV number of pixels vertically between 2 minor steps
gridAlignH number of pixels for horizontal grid align (pointer snap)
gridAlignV number of pixels for vertical grid align (pointer snap)
docBounds true, if document boundary should be shown
bgColor grid bg-color [optional]
fgColor grid fg-color [optional]
if littleStepH/V are nil, only bigSteps are drawn.
-
hideGrid
-
hide the grid
-
newGrid
-
define a new grid - this is a private helper which has to be
called after any change in the grid. It (re)creates the gridPixmap,
clears the view and redraws all visible objects.
-
showGrid
-
show the grid. The grid is defined by the return value of
gridParameters, which can be redefined in concrete subclasses.
initialization
-
initEvents
-
self backingStore:true.
-
initialize
-
(comment from inherited method)
must be called if redefined
-
setInitialDocumentFormat
-
layout manipulation
-
alignBottom: something
-
-
alignHorizontal: something
-
align selection along their center horizontally
-
alignLeft: something
-
-
alignRight: something
-
-
alignTop: something
-
-
alignVertical: something
-
align selection along their center vertically
-
move: something by: delta
-
change the position of something, an Object or Collection
by delta, aPoint
-
move: something to: aPoint in: aView
-
can only happen when dragOutOfView is true
- should be redefined in subclasses
-
move: something to: aPoint inAlienViewId: aViewId
-
can only happen when dragOutOfView is true
- should be redefined in subclasses
-
moveObject: anObject by: delta
-
change the position of anObject by delta, aPoint
-
moveObject: anObject to: newOrigin
-
move anObject to newOrigin, aPoint
-
objectToBack: anObject
-
bring the argument, anObject to back
-
objectToFront: anObject
-
bring the argument, anObject to front
-
selectionAlignBottom
-
align selected objects at bottom
-
selectionAlignHorizontal
-
align selected objects horizontally
-
selectionAlignLeft
-
align selected objects left
-
selectionAlignRight
-
align selected objects right
-
selectionAlignTop
-
align selected objects at top
-
selectionAlignVertical
-
align selected objects vertically
-
selectionToBack
-
bring the selection to back
-
selectionToFront
-
bring the selection to front
-
toBack: something
-
bring the argument, anObject or a collection of objects to back
-
toFront: something
-
bring the argument, anObject or a collection of objects to front
misc
-
documentFormat: aFormatString
-
set the document format (mostly used by scrollbars).
The argument should be a string such as 'a4', 'a5'
or 'letter'.
See the UnitConverter class for supported formats.
-
hitDelta
-
when clicking an object, allow for hitDelta pixels around object.
We compensate for any scaling here, to get a constant physical
hitDelta (i.e. the value returned here is inverse scaled).
-
numberOfObjectsIntersecting: aRectangle
-
answer the number of objects intersecting the argument, aRectangle
-
numberOfObjectsIntersectingVisible: aRectangle
-
answer the number of objects intersecting the argument, aRectangle.
This is a leftOver from times when scrolling was not transparent.
Please use numberOfObjectsIntersecting:, since this will vanish.
-
object: anObject isContainedIn: aRectangle
-
true, if anObject is completely inside aRectangle (for rectangle drag)
-
objectsAbove: objectToBeTested do: aBlock
-
do something to every object above objectToBeTested
(does not mean obscured - simply above in hierarchy)
-
objectsAbove: anObject intersecting: aRectangle do: aBlock
-
do something to every object above objectToBeTested
and intersecting aRectangle
-
objectsBelow: objectToBeTested do: aBlock
-
do something to every object below objectToBeTested
(does not mean obscured by - simply below in hierarchy)
-
objectsIn: aRectangle do: aBlock
-
do something to every object which is completely in a rectangle
-
objectsInVisible: aRectangle do: aBlock
-
do something to every object which is completely in a
visible rectangle.
This is a leftOver from times when scrolling was not transparent.
Please use objectsIn:do:, since this will vanish.
-
objectsIntersecting: aRectangle
-
answer a Collection of objects intersecting the argument, aRectangle
-
objectsIntersecting: aRectangle do: aBlock
-
do something to every object which intersects a rectangle
-
objectsIntersectingVisible: aRectangle
-
answer a Collection of objects intersecting a visible aRectangle.
This is a leftOver from times when scrolling was not transparent.
Please use objectsIntersecting:, since this will vanish.
-
objectsIntersectingVisible: aRectangle do: aBlock
-
do something to every object which intersects a visible rectangle.
This is a leftOver from times when scrolling was not transparent.
Please use objectsIntersecting:do:, since this will vanish.
-
rectangleForScroll
-
find the area occupied by visible objects
-
visibleObjectsDo: aBlock
-
do something to every visible object
queries
-
hasSolidBackground
-
return true, if I have a solid color background, which can be pixel-copied
for optimized redraw in moveObject.
-
heightOfContentsInMM
-
answer the height of the document in millimeters
-
widthOfContentsInMM
-
answer the width of the document in millimeters
queries-contents
-
heightOfContents
-
answer the height of the document in pixels
-
widthOfContents
-
answer the width of the document in pixels
saving & restoring
-
fileInContentsFrom: aStream
-
remove all objects, load new contents from aStream and redraw
-
fileInContentsFrom: aStream redraw: redraw
-
remove all objects, load new contents from aStream
and redraw if the redraw argument is true
-
fileInContentsFrom: aStream redraw: redraw new: new
-
remove all objects, load new contents from aStream
and redraw if the redraw argument is true
-
fileInContentsFrom: aStream redraw: redraw new: new binary: binary
-
if the new argument is true, remove all objects.
Then load objects from aStream. If redraw is false, no redraw
is done
(allows fileIn of multiple files doing a single redraw at the end).
-
initializeFileInObject: anObject
-
each object may be processed here after its being filed-in
- subclasses may do whatever they want here ...
(see LogicView for example)
-
storeBinaryContentsOn: aStream
-
store the contents in binary representation on aStream.
-
storeContentsOn: aStream
-
store the contents in textual representation on aStream.
Notice, that for huge objects (such as DrawImages) this ascii output
can become quite large, and the time to save and reload can become
long.
-
withoutRedrawFileInContentsFrom: aStream
-
remove all objects, load new contents from aStream without any redraw
scrolling
-
horizontalScrollStep
-
return the amount to scroll when stepping left/right.
Redefined to scroll by inches or centimeters.
-
verticalScrollStep
-
return the amount to scroll when stepping left/right.
Redefined to scroll by inches or centimeters.
selection & handles
-
drawHandle: aPoint
-
-
drawHandlesFor: anObject
-
-
findAllObjectsHandleAt: aPoint
-
-
findAllObjectsHandleAt: aPoint suchThat: aBlock
-
-
findLastObjectHandleAt: aPoint
-
-
findLastObjectHandleAt: aPoint suchThat: aBlock
-
-
findObjectHandleAt: aPoint
-
-
handle: handlePoint isHitBy: aPoint
-
-
handleFor: aPoint
-
return the handle-rectangle for a handle at aPoint
-
handleSize
-
return the size of the handles - since handles should be
the same size regardless of scaling, inverse-scale from
what the default is.
-
handlesOf: anObject do: aBlock
-
-
invertHandle: aHandle
-
-
invertHandlesOf: aSelection
-
-
object: anObject hasHandleAt: aPoint
-
-
selectionHandlesDo: aBlock
-
selections
-
addToSelection: anObject
-
add anObject to the selection; redraw it selected
-
hideSelection
-
hide the selection - undraw hilights - whatever that is
-
removeFromSelection: anObject
-
remove anObject from the selection
-
select: something
-
select something - hide previous selection, set to something and hilight
-
selectAll
-
select all objects
-
selectAllIn: aRectangle
-
select all objects which are fully contained in aRectangle
-
selectAllIntersecting: aRectangle
-
select all objects which are touched by aRectangle
-
selection
-
return the selection as a collection or nil
-
selectionDo: aBlock
-
apply block to every object in selection
-
showSelection
-
show the selection - draw hilights - whatever that is
-
unselect
-
unselect - hide selection; clear selection
-
withSelectionHiddenDo: aBlock
-
evaluate aBlock while selection is hidden
testing objects
-
allObjectsHitAt: aPoint do: aBlock
-
for all objects (by enumerating from back to front) which are hit by
the argument, aPoint, evaluate aBlock
-
allObjectsHitAt: aPoint withDelta: hDelta do: aBlock
-
for all objects (by enumerating from back to front) which are hit by
the argument, aPoint, evaluate aBlock
-
canMove: something
-
return true, if the argument, anObject or a collection can be moved
-
canSelect: something
-
return true, if the argument, anObject or a collection can be selected
-
findNearestObjectAt: aPoint
-
find the nearest object (by looking from back to front) which is hit by
the argument, aPoint - this is the topmost object hit
-
findObjectAt: aPoint
-
find the last object (by looking from back to front) which is hit by
the argument, aPoint - this is the topmost object hit
-
findObjectAt: aPoint forWhich: aBlock
-
find the last object (by looking from back to front) which is hit by
the argument, aPoint - this is the topmost object hit
-
findObjectAt: aPoint suchThat: aBlock
-
find the last object (back to front ) which is hit by
the argument, aPoint and for which the testBlock, aBlock evaluates to true.
This is a leftOver from times when scrolling was not transparent.
Please use findObjectAt:forWhich:, since this will vanish.
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
findObjectAtVisible: aPoint
-
find the last object (by looking from back to front) which is hit by
a visible point - this is the topmost object hit.
This is a leftOver from times when scrolling was not transparent.
Please use findObjectAt:, since this will vanish.
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
findObjectAtVisible: aPoint suchThat: aBlock
-
find the last object (back to front ) which is hit by
the argument, aPoint and for which the testBlock, aBlock evaluates to
true.
This is a leftOver from times when scrolling was not transparent.
Please use findObjectAt:forWhich:, since this will vanish.
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
findObjectForSelectAt: aPoint
-
find the object for a select
-
frameIncludesSelectionHandlesOn: anObject
-
return true, if anObjects frame includes any selection
handles, false if not or if we do not know.
This can be used to optimize the redraw, in removeObjectFromSelection.
Subclasses which know how selections are highlighted may redefine this.
-
frameOf: anObjectOrCollection
-
answer the maximum extent defined by the argument, anObject or a
collection of objects
-
isObscured: something
-
return true, if the argument something, anObject or a collection of
objects is obscured (partially or whole) by any other object
-
isSelected: anObject
-
return true, if the argument, anObject is in the selection
-
objectIsObscured: objectToBeTested
-
return true, if the argument, anObject is obscured (partially or whole)
by any other object
user interface
-
alignToGrid: aPoint
-
round aPoint to the next nearest point on the grid
-
selectMore: aPoint
-
add/remove an object from the selection
-
startSelectMoreOrMove: aPoint
-
add/remove object hit by aPoint, then start a rectangleDrag or move
- if aPoint hits an object, a move is started, otherwise a rectangleDrag.
This is typically the button shiftPressAction.
-
startSelectOrMove: aPoint
-
start a rectangleDrag or objectMove - if aPoint hits an object,
an object move is started, otherwise a rectangleDrag.
This is typically the button pressAction.
view manipulation
-
inchMetric
-
-
millimeterMetric
-
-
zoom: factor
-
set a zoom factor; smaller than 1 is shrink; larger than 1 is magnify.
I.e. 1 is identity; 2 is magnify by 2; 0.5 is shrink by 2
-
zoomIn
-
zoom in - multiply the zoom factor by 1.5
-
zoomIn: factor
-
zoom in by multiplying the zoom factor by the argument
-
zoomOut
-
zoom in - divide the zoom factor by 1.5
-
zoomOut: factor
-
zoom out by dividing the zoom factor by the argument
typically, ObjectViews are not used on their own, but instead
subclassed and thereby provide the common functionality for
views which show (possibly overlapping) objects.
The methods here provide all mechanisms to handle redraws, picking
(i.e. finding an object by position), gridding, moving objects with
minimum redraw etc.
Also, zooming and scrolling is handled.
All objects which respond to the DisplayObject protocol can be handled
by ObjectView - therefore, you can add almost any object and have it
displayed and handled here. (as an example, try to copy a LogicGate
from a LogicView and paste it into a DrawTool - it will work).
Reminder: ObjectViews are not to be used as below, but instead to be
subclassed. Therefore, the examples below are somewhat untypical.
simple example:
|v o|
v := ObjectView new.
v extent:200@200.
o := DrawRectangle new.
o origin:10@10 corner:100@100.
v add:o.
o := DrawText new.
o text:'hello there'; origin:50@50; foreground:Color red.
v add:o.
v open
|
add scrolling:
|v top o|
top := HVScrollableView for:ObjectView.
top extent:200@200.
v := top scrolledView.
o := DrawRectangle new.
o origin:10@10 corner:100@100.
v add:o.
o := DrawText new.
o text:'hello there'; origin:50@50; foreground:Color red.
v add:o.
top open
|
or, using miniscrollers:
|v top o|
top := HVScrollableView for:ObjectView
miniScrollerH:true miniScrollerV:true.
top extent:200@200.
v := top scrolledView.
o := DrawRectangle new.
o origin:10@10 corner:100@100.
v add:o.
o := DrawText new.
o text:'hello there'; origin:50@50; foreground:Color red.
v add:o.
top open
|
mix views and displayObjects:
|v top o|
top := HVScrollableView for:ObjectView.
top extent:200@200.
v := top scrolledView.
o := DrawLine new.
o origin:10@10 corner:50@50.
v add:o.
o := ClockView in:top.
o origin:50@50 corner:100@100.
v add:o.
top open
|
grid:
|v top o|
top := HVScrollableView for:ObjectView
miniScrollerH:true miniScrollerV:true.
top extent:200@200.
v := top scrolledView.
v showGrid.
o := DrawRectangle new.
o origin:10@10 corner:100@100.
v add:o.
o := DrawText new.
o text:'hello there'; origin:50@50; foreground:Color red.
v add:o.
top open
|
zoom:
|v top o|
top := HVScrollableView for:ObjectView
miniScrollerH:true miniScrollerV:true.
top extent:200@200.
v := top scrolledView.
v showGrid.
o := DrawRectangle new.
o origin:10@10 corner:100@100.
v add:o.
o := DrawText new.
o text:'hello there'; origin:50@50; foreground:Color red.
v add:o.
top open.
Delay waitForSeconds:5.
v zoom:2.
Delay waitForSeconds:5.
v zoom:0.35.
Delay waitForSeconds:5.
v zoom:1.
|
private benchmark: display 10000 objects ...
|v top o rnd|
top := HVScrollableView for:ObjectView
miniScrollerH:true miniScrollerV:true.
top extent:200@200.
v := top scrolledView.
rnd := Random new.
10000 timesRepeat:[
o := DrawLine new.
o origin:(rnd nextIntegerBetween:0 and:700) @ (rnd nextIntegerBetween:0 and:700)
corner:(rnd nextIntegerBetween:0 and:700) @ (rnd nextIntegerBetween:0 and:700).
v add:o.
].
top openAndWaitUntilVisible.
Transcript showCR:(
Time millisecondsToRun:[
v redraw
])
|
|