eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'Cursor':

Home

everywhere
www.exept.de
for:
[back]

Class: Cursor


Inheritance:

   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

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


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

initialization
o  flushDeviceCursorsFor: aDevice
unassign all cursors from their device

o  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

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

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

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

o  bottomLeft
return a bottom-left corner cursor

o  bottomRight
return a bottom-right corner cursor

o  caret
return a caret cursor

o  corner
return a corner (bottom-right) cursor

o  cross
return a cross cursor

o  crossHair
return a crossHair cursor

o  document
return a document cursor (dragging a document)

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

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

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

o  eye
return an eye cursor

o  eyeClosed
return an eye cursor

o  folder
return a folder cursor (dragging a folder)

o  fourWay
return a four-way arrow cursor

o  hand
return a hand cursor

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

o  leftHand
return a left-hand cursor

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

o  leftRightArrow
return a left-right-arrow cursor

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

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

o  origin
return an origin cursor

o  questionMark
return a question-mark cursor

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

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

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

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

o  text
return a text-cursor

o  thumbsDown
return a hand cursor - ST-80 compatibility

o  thumbsUp
return a hand cursor - ST-80 compatibility

o  topLeft
return a top-left corner cursor

o  topRight
return a top-right corner cursor

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

o  upDownArrow
return an up-down-arrow cursor

o  upLeftArrow
return an up-right-arrow cursor

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

o  upRightArrow
return an up-right-arrow cursor

o  upRightHand
return an up-right-hand cursor

o  wait
return a wait cursor

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

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

styles
o  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 aViews 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
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 6.1.1; WebServer 1.620 at exept:8081; Wed, 23 May 2012 08:44:33 GMT