|
|
Class: Cursor
Object
|
+--Cursor
- Package:
- stx:libview
- Category:
- Graphics-Support
- Version:
- rev:
1.111
date: 2009/10/02 08:27:27
- user: cg
- file: Cursor.st directory: libview
- module: stx stc-classLibrary: libview
- Author:
- Claus Gittinger
I represents cursors in a device independent manner.
Normally, cursors are defined at view creation time,
via
'aView cursor:aCursor'.
[Instance variables:]
shape <Symbol> a shape (i.e. #arrow, #hand, ...) or nil
sourceForm <Form> if shape is nil, the source bits
maskForm <Form> if shape is nil, the mask bits
hotX <SmallInteger> if shape is nil, the hotSpot x of the cursor
hotY <SmallInteger> if shape is nil, the hotSpot y of the cursor
device <aDevice> the device, if associated to one
cursorId <anObject> the device-specific id if device is nonNil
[class variables:]
Lobby <Registry> keeps track of known device cursors
(dont use it: this will be moved to the device)
DefaultFgColor <Color> default foreground color for cursors (usually black)
DefaultBgColor <Color> default background color for cursors (usually white)
NormalCursor <Cursor> cached instance of normal (arrow) cursor
...
DeviceWorkstation
DisplaySurface
Font
Color
Image
Form
[introduction to view programming]
default access
-
defaultBgColor
-
return the default bg color used for cursors
-
defaultFgColor
-
return the default fg color used for cursors
-
defaultFgColor: fgColor defaultBgColor: bgColor
-
set the default colors used for new cursors
initialization
-
flushDeviceCursorsFor: aDevice
-
unassign all cursors from their device
-
initialize
-
-
initializeNewCursors
-
Create additional cursors as bitmap cursors,
if not available as native cursors on the device.
This is invoked via the startup script (display.rc)
(This is rubbish - we should keep that info on a per-device basis ...)
Cursor blank
Cursor down
Cursor execute
Cursor left
Cursor marker
Cursor normal
Cursor read
Cursor right
Cursor square
Cursor up
Cursor wait
Cursor write
Cursor thumbsUp
Cursor thumbsDown
Cursor xMarker
Cursor caret
Cursor stop
Cursor eye
Cursor eyeClosed
instance creation
-
extent: extent fromArray: array offset: offset
-
ST-80 compatibility
create a new bitmap cursor from bits in the array argument.
Here, the offset argument defines the hotSpot, but is given
as the negative of the hotSpot coordinate within the cursor (sigh - ST80 compatibility).
-
extent: extent sourceArray: sourceArray maskArray: maskArray offset: offset
-
create a new bitmap cursor with mask from bits in sourceArray and
maskArray.
The offset argument defines the hotSpot, but is given as the negative
of the hotSpots coordinate within the cursor (sigh - ST80 compatibility)
-
fileCursorNamed: cursorName
-
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
fromImage: anImage
-
return a new cursor.
Source- and (optional) mask-Bits are taken from anImage;
The cursors hotSpot is the center of the image.
-
fromImage: anImage hotSpot: aPoint
-
return a new cursor.
Source- and (optional) mask-Bits are taken from anImage;
The cursors hotSpot is given as an offset from the top-left.
-
imageArray: imageBits maskArray: maskBits
-
ST-80 compatible cursor creation - the extent is fixed to 16@16
-
imageArray: imageBits maskArray: maskBits hotSpot: hot
-
ST-80 compatible cursor creation - the extent is fixed to 16@16
-
imageArray: imageBits maskArray: maskBits hotSpot: hot name: aString
-
ST-80 compatible cursor creation - the extent is fixed to 16@16
-
shape: aShape
-
return one of the standard cursors.
Each display may offer different shapes - see for example XWorkstation
for details (however a basic minimum set should be supported by all)
-
shape: aShape on: aDevice
-
return one of the standard cursors already associated to aDevice.
This is the same as '(Cursor shape:aShape) on:aDevice' but somwehat faster.
-
sourceForm: aForm
-
return a new cursor.
Source- and mask-Bits are taken from aForm; hotSpot is center
-
sourceForm: sourceForm maskForm: maskForm
-
return a new cursor. hotSpot is center
-
sourceForm: sourceForm maskForm: maskForm hotSpot: aPoint
-
return a new cursor
-
sourceForm: sourceForm maskForm: maskForm hotX: hotX hotY: hotY
-
return a new cursor
standard cursors
-
arrow
-
return an arrow (up-left-arrow) cursor
-
blank
-
Answer the instance of me that is an invisible cursor.
-
bottomLeft
-
return a bottom-left corner cursor
-
bottomRight
-
return a bottom-right corner cursor
-
caret
-
return a caret cursor
-
corner
-
return a corner (bottom-right) cursor
-
cross
-
return a cross cursor
-
crossHair
-
return a crossHair cursor
-
document
-
return a document cursor (dragging a document)
-
down
-
Answer the instance of me that is the shape of a down-arrow.
-
downLimitArrow
-
return a down-arrow-to-limit cursor
-
execute
-
return a execute cursor - (the default here is a wait-cursor)
-
eye
-
return an eye cursor
-
eyeClosed
-
return an eye cursor
-
folder
-
return a folder cursor (dragging a folder)
-
fourWay
-
return a four-way arrow cursor
-
hand
-
return a hand cursor
-
left
-
Answer the instance of me that is the shape of an arrow facing to the left.
-
leftHand
-
return a left-hand cursor
-
leftLimitArrow
-
return a left-arrow-to-limit cursor
-
leftRightArrow
-
return a left-right-arrow cursor
-
marker
-
Answer the instance of me that is the shape of a horizontal arrow.
-
normal
-
return the normal cursor; an arrow.
for ST-80 compatibility
-
origin
-
return an origin cursor
-
questionMark
-
return a question-mark cursor
-
read
-
return a reading-file cursor (the default here is a wait-cursor)
-
right
-
Answer the instance of me that is the shape of an arrow facing to the right.
-
rightLimitArrow
-
return a right-arrow-to-limit cursor
-
stop
-
return a stop cursor (the default here is a wait-cursor)
-
text
-
return a text-cursor
-
thumbsDown
-
return a hand cursor - ST-80 compatibility
-
thumbsUp
-
return a hand cursor - ST-80 compatibility
-
topLeft
-
return a top-left corner cursor
-
topRight
-
return a top-right corner cursor
-
up
-
Answer the instance of me that is the shape of an up-arrow.
-
upDownArrow
-
return an up-down-arrow cursor
-
upLeftArrow
-
return an up-right-arrow cursor
-
upLimitArrow
-
return an up-arrow-to-limit cursor
-
upRightArrow
-
return an up-right-arrow cursor
-
upRightHand
-
return an up-right-hand cursor
-
wait
-
return a wait cursor
-
write
-
return a writing-file cursor (the default here is a wait-cursor)
-
xMarker
-
Answer the instance of me that is displayed when thumb-scrolling on the x-axis.
styles
-
disableThumbsCursors
-
ST-80 displaying
-
displayOn: aGC at: origin clippingBox: aRectangle rule: aRule mask: aMask
-
ST-80 compatibility;
limited functionality: can only display bitmap cursors (yet)
-
show
-
ST-80 mimicri: change cursors in active groups views to the receiver.
-
showIn: aView
-
ST-80 mimicri: install the receiver as aViews cursor
-
showIn: aView while: aBlock
-
ST-80 mimicri: change aViews cursors to the receiver, while evaluationg aBlock.
Return the value as returned by aBlock.
-
showWhile: aBlock
-
ST-80 mimicri: change all views cursors to the receiver.
Return the value as returned by aBlock.
accessing
-
device
-
return the device I am associated with
-
extent
-
-
foreground: fgColor background: bgColor
-
set the cursor colors
-
graphicsDevice
-
same as #device, for ST-80 compatibility naming.
Return the device I am associated with.
-
hotX
-
return the hotspots x-coordinate of the receiver
-
hotY
-
return the hotspots y-coordinate of the receiver
-
id
-
return the cursors deviceId
-
maskForm
-
return the mask-form of the receiver
-
maskForm: aForm
-
set the mask-form of the receiver
-
shape
-
return the shape
-
sourceForm
-
return the source-form of the receiver
-
sourceForm: aForm
-
set the source-form of the receiver
copying
-
postCopy
-
-
postDeepCopy
-
creating a device cursor
-
on: aDevice
-
create a new Cursor representing the same cursor as
myself on aDevice; if one already exists, return the one
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
onDevice: aDevice
-
create a new Cursor representing the same cursor as
myself on aDevice; if one already exists, return the one
instance release
-
executor
-
redefined to return a lightweight copy
- all we need is the device handle
-
finalize
-
some Cursor has been collected - tell it to the display
-
releaseFromDevice
-
I am no longer available on the device
printing
-
printOn: aStream
-
append a printed representation to aStream
private
-
allocateOnDevice: aDevice
-
allocate a device-cursor-resource for me on aDevice
-
device: aDevice
-
set the cursors device
-
id: anId
-
set the cursors id
-
restored
-
set both device and id
private-accessing
-
setDevice: aDevice id: anId
-
set the device and deviceId of the receiver
-
setHotX: hx hotY: hy
-
set the hotspot
-
setShape: aShapeSymbol
-
set the shape
-
setSourceForm: sForm maskForm: mForm hotX: hx hotY: hy
-
set the forms and hotspot
queries
-
isAnimatedCursor
-
get a standard cursors:
Cursor wait.
Cursor stop.
Cursor normal.
|
create a custom cursor:
Cursor extent:16@16
fromArray:#[ 2r00000000 2r00000000
2r00000000 2r00000000
2r00000000 2r00000000
2r11111111 2r11111111
2r11111111 2r11111111
2r00000000 2r00000000
2r00000000 2r00000000
2r11111111 2r11111111
2r11111111 2r11111111
2r00000000 2r00000000
2r00000000 2r00000000
2r11111111 2r11111111
2r11111111 2r11111111
2r00000000 2r00000000
2r00000000 2r00000000
2r00000000 2r00000000]
offset:-8 @ -8
|
some common cursors ...
|v b cursors nextCursorAction|
cursors := OrderedCollection new.
cursors add:#arrow.
cursors add:#blank.
cursors add:#bottomLeft.
cursors add:#bottomRight.
cursors add:#caret.
cursors add:#corner.
cursors add:#cross.
cursors add:#crossHair.
cursors add:#document.
cursors add:#down.
cursors add:#downLimitArrow.
cursors add:#execute.
cursors add:#eye.
cursors add:#folder.
cursors add:#fourWay.
cursors add:#hand.
cursors add:#left.
cursors add:#leftHand.
cursors add:#leftLimitArrow.
cursors add:#leftRightArrow.
cursors add:#marker.
cursors add:#normal.
cursors add:#origin.
cursors add:#questionMark.
cursors add:#read.
cursors add:#right.
cursors add:#rightLimitArrow.
cursors add:#stop.
cursors add:#text.
cursors add:#thumbsDown.
cursors add:#thumbsUp.
cursors add:#topLeft.
cursors add:#topRight.
cursors add:#up.
cursors add:#upDownArrow.
cursors add:#upLeftArrow.
cursors add:#upLimitArrow.
cursors add:#upRightArrow.
cursors add:#upRightHand.
cursors add:#wait.
cursors add:#write.
cursors add:#xMarker.
nextCursorAction := [
|sel c|
cursors isEmpty ifTrue:[
v close.
] ifFalse:[
sel := cursors removeFirst.
c := Cursor perform:sel.
b label:sel.
b cursor:c.
]
].
v := StandardSystemView extent:100@100.
b := Button origin:0.0@0.0 corner:1.0@1.0 in:v.
b label:'default'.
b action:nextCursorAction.
v openAndWait.
|
define a cursor for a view:
|v|
v := StandardSystemView extent:100@100.
v cursor:Cursor stop.
v open.
|
with above custom cursor:
|v|
v := StandardSystemView extent:100@100.
v cursor:(
Cursor extent:16@16
fromArray:#[ 2r00000000 2r00000000
2r00000000 2r00000000
2r00000000 2r00000000
2r11111111 2r11111111
2r11111111 2r11111111
2r00000000 2r00000000
2r00000000 2r00000000
2r11111111 2r11111111
2r11111111 2r11111111
2r00000000 2r00000000
2r00000000 2r00000000
2r11111111 2r11111111
2r11111111 2r11111111
2r00000000 2r00000000
2r00000000 2r00000000
2r00000000 2r00000000]
offset:-8 @ -8).
v open.
|
a custom cursor with mask:
|v|
v := StandardSystemView extent:100@100.
v cursor:(
Cursor
extent:16@16
sourceArray:#[
2r00000000 2r00000000
2r00000000 2r00000000
2r00000000 2r00000000
2r11111111 2r11111111
2r11111111 2r11111111
2r00000000 2r00000000
2r00000000 2r00000000
2r00000000 2r00000000
2r00000000 2r00000000
2r00000000 2r00000000
2r00000000 2r00000000
2r11111111 2r11111111
2r11111111 2r11111111
2r00000000 2r00000000
2r00000000 2r00000000
2r00000000 2r00000000]
maskArray:#[
2r00000000 2r00000000
2r00000000 2r00000000
2r11111111 2r11111111
2r11111111 2r11111111
2r11111111 2r11111111
2r11111111 2r11111111
2r00000000 2r00000000
2r00000000 2r00000000
2r00000000 2r00000000
2r00000000 2r00000000
2r11111111 2r11111111
2r11111111 2r11111111
2r11111111 2r11111111
2r11111111 2r11111111
2r00000000 2r00000000
2r00000000 2r00000000]
offset:-8 @ -8).
v open.
|
a cursor from an image read from a file:
|v img|
v := StandardSystemView extent:100@100.
img := Image fromFile:'bitmaps/xpmBitmaps/cursors/mouse.xpm'.
v cursor:(Cursor fromImage:img).
v open.
|
with multiple views:
|v1 v2 top|
top := StandardSystemView new.
top extent:300@300.
v1 := View origin:0.0@0.0 corner:1.0@0.5 in:top.
v1 viewBackground:(Color grey:75).
v1 cursor:Cursor thumbsUp.
v2 := View origin:0.0@0.5 corner:1.0@1.0 in:top.
v2 viewBackground:(Color white).
v2 cursor:Cursor wait.
top open.
|
show a cursor (in the active ST/X view) for a while:
Cursor wait
showWhile:[
Delay waitForSeconds:5
]
|
show a cursor in all views belonging to a windowGroup:
(have to wait until top is visible to access windowGroup)
|v1 v2 top|
top := StandardSystemView new.
top extent:300@300.
v1 := View origin:0.0@0.0 corner:1.0@0.5 in:top.
v1 viewBackground:(Color grey:75).
v1 cursor:(Cursor normal).
v2 := View origin:0.0@0.5 corner:1.0@1.0 in:top.
v2 viewBackground:(Color white).
v2 cursor:(Cursor crossHair).
top openAndWait.
Delay waitForSeconds:3.
top windowGroup
withCursor:Cursor wait
do:[
Delay waitForSeconds:5
]
|
show a cursor in a single view for a while:
|v1 v2 top|
top := StandardSystemView new.
top extent:300@300.
v1 := View origin:0.0@0.0 corner:1.0@0.5 in:top.
v1 viewBackground:(Color grey:75).
v1 cursor:(Cursor normal).
v2 := View origin:0.0@0.5 corner:1.0@1.0 in:top.
v2 viewBackground:(Color white).
v2 cursor:(Cursor crossHair).
top openAndWait.
Delay waitForSeconds:3.
v1 withCursor:Cursor wait
do:[
Delay waitForSeconds:5
]
|
|