eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'Cursor':

Home

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

Class: Cursor


Inheritance:

   Object
   |
   +--Cursor

Package:
stx:libview
Category:
Graphics-Support
Version:
rev: 1.121 date: 2019/05/27 13:09:48
user: cg
file: Cursor.st directory: libview
module: stx stc-classLibrary: libview
Author:
Claus Gittinger

Description:


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
                                    (don't 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
     ...


Related information:

    DeviceWorkstation
    DisplaySurface
    Font
    Color
    Image
    Form
    [introduction to view programming]

Class protocol:

default access
o  defaultBgColor
return the default bg color used for cursors

o  defaultFgColor
return the default fg color used for cursors

o  defaultFgColor: fgColor defaultBgColor: bgColor
set the default colors used for new cursors

usage example(s):

     Cursor defaultFgColor:(Color red) defaultBgColor:(Color white)

initialization
o  flushDeviceCursorsFor: aDevice
unassign all cursors from their device

usage example(s):

     self flushDeviceCursorsFor:Display

o  initialize
Cursor initialize

o  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

usage example(s):

     HandCursor := nil.   
     self initializeNewCursors.

     View new cursor:(Cursor eyeClosed); open
     View new cursor:(Cursor eye); open
     View new cursor:(Cursor bullet); open

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

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

o  fileCursorNamed: cursorName
return a cursor read from the file's 'cursorName_bits.bit' and
'cursorName_mask.bit' - return nil if either file does not exist.
This method is going to be obsoleted in the future.

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

o  fromImage: anImage
return a new cursor.
Source- and (optional) mask-Bits are taken from anImage;
The cursors hotSpot is the center of the image.

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

o  imageArray: imageBits maskArray: maskBits
ST-80 compatible cursor creation - the extent is fixed to 16@16

o  imageArray: imageBits maskArray: maskBits hotSpot: hot
ST-80 compatible cursor creation - the extent is fixed to 16@16

o  imageArray: imageBits maskArray: maskBits hotSpot: hot name: aString
ST-80 compatible cursor creation - the extent is fixed to 16@16

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

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

o  sourceForm: aForm
return a new cursor.
Source- and mask-Bits are taken from aForm; hotSpot is center

o  sourceForm: sourceForm maskForm: maskForm
return a new cursor. hotSpot is center

o  sourceForm: sourceForm maskForm: maskForm hotSpot: aPoint
return a new cursor

o  sourceForm: sourceForm maskForm: maskForm hotX: hotX hotY: hotY
return a new cursor

standard cursors
o  arrow
return an arrow (up-left-arrow) cursor

usage example(s):

     Cursor arrow
        showWhile:[ Delay waitForSeconds:3 ]

o  blank
Answer the instance of me that is an invisible cursor.

usage example(s):

     Cursor blank
	showWhile:[ Delay waitForSeconds:3 ]

o  bottomLeft
return a bottom-left corner cursor

usage example(s):

     Cursor bottomLeft
        showWhile:[ Delay waitForSeconds:3 ]

o  bottomRight
return a bottom-right corner cursor

usage example(s):

     Cursor bottomRight
	showWhile:[ Delay waitForSeconds:3 ]

o  bullet
return a bullet cursor

usage example(s):

     Cursor bullet showWhile:[ Delay waitForSeconds:3 ]

     View new cursor:(Cursor bullet); open

o  caret
return a caret cursor

usage example(s):

     Cursor caret
	showWhile:[ Delay waitForSeconds:3 ]

o  corner
return a corner (bottom-right) cursor

usage example(s):

     Cursor corner
        showWhile:[ Delay waitForSeconds:3 ]

o  cross
return a cross cursor

usage example(s):

     Cursor cross
        showWhile:[ Delay waitForSeconds:3 ]

o  crossHair
return a crossHair cursor

usage example(s):

     Cursor crossHair
        showWhile:[ Delay waitForSeconds:3 ]

o  document
return a document cursor (dragging a document)

usage example(s):

     Cursor document
	showWhile:[ Delay waitForSeconds:3 ]

o  down
Answer the instance of me that is the shape of a down-arrow.

usage example(s):

     Cursor down
	showWhile:[ Delay waitForSeconds:3 ]

o  downLimitArrow
return a down-arrow-to-limit cursor

usage example(s):

     Cursor downLimitArrow
        showWhile:[ Delay waitForSeconds:3 ]

o  execute
return a execute cursor - (the default here is a wait-cursor)

usage example(s):

     Cursor execute
        showWhile:[ Delay waitForSeconds:3 ]

o  eye
return an eye cursor

usage example(s):

     Cursor eye
	showWhile:[ Delay waitForSeconds:3 ]

o  eyeClosed
return an eye cursor

usage example(s):

     Cursor eyeClosed
        showWhile:[ Delay waitForSeconds:3 ]

o  folder
return a folder cursor (dragging a folder)

usage example(s):

     Cursor folder
	showWhile:[ Delay waitForSeconds:3 ]

o  fourWay
return a four-way arrow cursor

usage example(s):

     Cursor fourWay
        showWhile:[ Delay waitForSeconds:3 ]

o  hand
return a hand cursor

usage example(s):

     Cursor hand
        showWhile:[ Delay waitForSeconds:3 ]

o  left
Answer the instance of me that is the shape of an arrow facing to the left.

usage example(s):

     Cursor left
	showWhile:[ Delay waitForSeconds:3 ]

o  leftHand
return a left-hand cursor

usage example(s):

     Cursor leftHand
        showWhile:[ Delay waitForSeconds:3 ]

o  leftLimitArrow
return a left-arrow-to-limit cursor

usage example(s):

     Cursor leftLimitArrow
        showWhile:[ Delay waitForSeconds:3 ]

o  leftRightArrow
return a left-right-arrow cursor

usage example(s):

     Cursor leftRightArrow
        showWhile:[ Delay waitForSeconds:3 ]

o  marker
Answer the instance of me that is the shape of a horizontal arrow.

usage example(s):

     Cursor marker
	showWhile:[ Delay waitForSeconds:3 ]

o  normal
return the normal cursor; an arrow.
for ST-80 compatibility

usage example(s):

     Cursor normal
        showWhile:[ Delay waitForSeconds:3 ]

o  origin
return an origin cursor

usage example(s):

     Cursor origin
        showWhile:[ Delay waitForSeconds:3 ]

o  questionMark
return a question-mark cursor

usage example(s):

     Cursor questionMark
        showWhile:[ Delay waitForSeconds:3 ]

o  read
return a reading-file cursor (the default here is a wait-cursor)

usage example(s):

     Cursor read
        showWhile:[ Delay waitForSeconds:3 ]

o  right
Answer the instance of me that is the shape of an arrow facing to the right.

usage example(s):

     Cursor right
	showWhile:[ Delay waitForSeconds:3 ]

o  rightLimitArrow
return a right-arrow-to-limit cursor

usage example(s):

     Cursor rightLimitArrow
        showWhile:[ Delay waitForSeconds:3 ]

o  stop
return a stop cursor (the default here is a wait-cursor)

usage example(s):

     Cursor stop
        showWhile:[ Delay waitForSeconds:3 ]

o  text
return a text-cursor

usage example(s):

     Cursor text
        showWhile:[ Delay waitForSeconds:3 ]

o  thumbsDown
return a hand cursor - ST-80 compatibility

usage example(s):

     Cursor thumbsDown
        showWhile:[ Delay waitForSeconds:3 ]

o  thumbsUp
return a hand cursor - ST-80 compatibility

usage example(s):

     Cursor thumbsUp
        showWhile:[ Delay waitForSeconds:3 ]

o  topLeft
return a top-left corner cursor

usage example(s):

     Cursor topLeft
	showWhile:[ Delay waitForSeconds:3 ]

o  topRight
return a top-right corner cursor

usage example(s):

     Cursor topRight
        showWhile:[ Delay waitForSeconds:3 ]

o  up
Answer the instance of me that is the shape of an up-arrow.

usage example(s):

     Cursor up
	showWhile:[ Delay waitForSeconds:5 ]

o  upDownArrow
return an up-down-arrow cursor

usage example(s):

     Cursor upDownArrow
        showWhile:[ Delay waitForSeconds:3 ]

o  upLeftArrow
return an up-right-arrow cursor

usage example(s):

     Cursor upLeftArrow
        showWhile:[ Delay waitForSeconds:3 ]

o  upLimitArrow
return an up-arrow-to-limit cursor

usage example(s):

     Cursor upLimitArrow
        showWhile:[ Delay waitForSeconds:3 ]

o  upRightArrow
return an up-right-arrow cursor

usage example(s):

     Cursor upRightArrow
        showWhile:[ Delay waitForSeconds:3 ]

o  upRightHand
return an up-right-hand cursor

usage example(s):

     Cursor upRightHand
        showWhile:[ Delay waitForSeconds:3 ]

o  wait
return a wait cursor

usage example(s):

     Cursor wait
        showWhile:[ Delay waitForSeconds:3 ]

o  write
return a writing-file cursor (the default here is a wait-cursor)

usage example(s):

     Cursor write
        showWhile:[ Delay waitForSeconds:3 ]

o  xMarker
Answer the instance of me that is displayed when thumb-scrolling on the x-axis.

usage example(s):

     Cursor xMarker
	showWhile:[ Delay waitForSeconds:3 ]

styles
o  disableThumbsCursors
self initializeNewCursors.
self disableThumbsCursors.


Instance protocol:

ST-80 displaying
o  displayOn: aGC at: origin clippingBox: aRectangle rule: aRule mask: aMask
ST-80 compatibility;
limited functionality: can only display bitmap cursors (yet)

o  show
ST-80 mimicri: change cursors in active groups views to the receiver.

o  showIn: aView
ST-80 mimicri: install the receiver as aViews cursor

o  showIn: aView while: aBlock
ST-80 mimicri: change aView's cursors to the receiver, while evaluationg aBlock.
Return the value as returned by aBlock.

o  showWhile: aBlock
ST-80 mimicri: change all views cursors to the receiver.
Return the value as returned by aBlock.

accessing
o  device
return the device I am associated with

o  extent

o  foreground: fgColor background: bgColor
set the cursor colors

o  graphicsDevice
same as #device, for ST-80 compatibility naming.
Return the device I am associated with.

o  hotX
return the hotspots x-coordinate of the receiver

o  hotY
return the hotspots y-coordinate of the receiver

o  id
return the cursors deviceId

o  maskForm
return the mask-form of the receiver

o  maskForm: aForm
set the mask-form of the receiver

o  shape
return the shape

o  sourceForm
return the source-form of the receiver

o  sourceForm: aForm
set the source-form of the receiver

copying-private
o  postCopy

o  postDeepCopy

creating a device cursor
o  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) **

o  onDevice: aDevice
create a new Cursor representing the same cursor as
myself on aDevice; if one already exists, return the one

instance release
o  executor
redefined to return a lightweight copy
- all we need is the device handle

o  finalize
some Cursor has been collected - tell it to the display

o  releaseFromDevice
I am no longer available on the device

printing
o  printOn: aStream
append a printed representation to aStream

private
o  allocateOnDevice: aDevice
allocate a device-cursor-resource for me on aDevice

o  device: aDevice
set the cursors device

o  id: anId
set the cursors id

o  restored
set both device and id

private-accessing
o  setDevice: aDevice id: anId
set the device and deviceId of the receiver

o  setHotX: hx hotY: hy
set the hotspot

o  setShape: aShapeSymbol
set the shape

o  setSourceForm: sForm maskForm: mForm hotX: hx hotY: hy
set the forms and hotspot

queries
o  isAnimatedCursor


Examples:


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
          ]


ST/X 7.2.0.0; WebServer 1.670 at bd0aa1f87cdd.unknown:8081; Wed, 24 Apr 2024 17:59:07 GMT