Cursor.st
changeset 2 b35336ab0de3
parent 0 48194c26a46c
child 3 c0aaded4ef28
--- a/Cursor.st	Wed Oct 13 01:30:35 1993 +0100
+++ b/Cursor.st	Wed Oct 13 01:32:53 1993 +0100
@@ -20,7 +20,8 @@
                               ReadCursor WriteCursor WaitCursor
                               XeqCursor CrossHairCursor OriginCursor
                               CornerCursor SquareCursor FourWayCursor
-                              UpDownArrowCursor LeftRightArrowCursor'
+                              UpDownArrowCursor LeftRightArrowCursor
+                              Wait2Cursor Wait3Cursor Wait4Cursor'
        poolDictionaries:''
        category:'Graphics-Support'
 !
@@ -55,7 +56,7 @@
 
 class variables:
 
-lobby           <Registry>      keeps track of known cursors
+lobby           <Registry>      keeps track of known device cursors
 
 DefaultFgColor  <Color>         default foreground color for cursors (usually black)
 DefaultBgColor  <Color>         default background color for cursors (usually white)
@@ -81,7 +82,7 @@
     "unassign all cursors from their device"
 
     lobby contentsDo:[:aCursor |
-        aCursor resetDevice.
+        aCursor restored.
         lobby changed:aCursor
     ]
 !
@@ -171,8 +172,10 @@
             ]
         ]
     ].
-    newCursor := self basicNew sourceForm:sourceForm maskForm:maskForm
-                                     hotX:hotX hotY:hotY on:nil.
+    newCursor := self basicNew setSourceForm:sourceForm 
+                                    maskForm:maskForm
+                                        hotX:hotX
+                                        hotY:hotY.
     lobby register:newCursor.
     ^ newCursor
 !
@@ -190,7 +193,7 @@
             ^ aCursor
         ]
     ].
-    newCursor := self basicNew shape:aShape on:nil.
+    newCursor := self basicNew setShape:aShape.
     lobby register:newCursor.
     ^ newCursor
 !
@@ -367,6 +370,150 @@
     ^ WaitCursor
 !
 
+wait2
+    "return a wait cursor showing 3 o'clock"
+
+    Wait2Cursor isNil ifTrue:[
+        Wait2Cursor := (self
+                        extent: 16@16
+                        sourceArray: #(
+                            2r0001111111100000
+                            2r0001111111100000
+                            2r0001111111100000
+                            2r0011111111110000
+                            2r0110000000011000
+                            2r1100000000001100
+                            2r1000000000000111
+                            2r1000001110000111
+                            2r1000001111111111
+                            2r1000010000000111
+                            2r1100100000001100
+                            2r0110000000011000
+                            2r0011111111110000
+                            2r0001111111100000
+                            2r0001111111100000
+                            2r0001111111100000
+                            )
+                        maskArray: #(
+                            2r0011111111110000
+                            2r0011111111110000
+                            2r0011111111110000
+                            2r0111111111111000
+                            2r1111111111111100
+                            2r1111111111111111
+                            2r1111111111111111
+                            2r1111111111111111
+                            2r1111111111111111
+                            2r1111111111111111
+                            2r1111111111111111
+                            2r1111111111111100
+                            2r0111111111111000
+                            2r0011111111110000
+                            2r0011111111110000
+                            2r0011111111110000
+                           )
+                        offset: -15 @ -9).
+        Wait2Cursor := Wait2Cursor on:Display.
+    ].
+    ^ Wait2Cursor
+!
+
+wait3
+    "return a wait cursor showing 6 o'clock"
+
+    Wait3Cursor isNil ifTrue:[
+        Wait3Cursor := (Cursor
+                        extent: 16@16
+                        sourceArray: #(
+                            2r0001111111100000
+                            2r0001111111100000
+                            2r0001111111100000
+                            2r0011111111110000
+                            2r0110000000011000
+                            2r1100000000001100
+                            2r1000000000000111
+                            2r1000001110000111
+                            2r1000001110000111
+                            2r1000010100000111
+                            2r1100100100001100
+                            2r0110000100011000
+                            2r0011111111110000
+                            2r0001111111100000
+                            2r0001111111100000
+                            2r0001111111100000
+                            )
+                        maskArray: #(
+                            2r0011111111110000
+                            2r0011111111110000
+                            2r0011111111110000
+                            2r0111111111111000
+                            2r1111111111111100
+                            2r1111111111111111
+                            2r1111111111111111
+                            2r1111111111111111
+                            2r1111111111111111
+                            2r1111111111111111
+                            2r1111111111111111
+                            2r1111111111111100
+                            2r0111111111111000
+                            2r0011111111110000
+                            2r0011111111110000
+                            2r0011111111110000
+                           )
+                        offset: -15 @ -9).
+        Wait3Cursor := Wait3Cursor on:Display.
+    ].
+    ^ Wait3Cursor
+!
+
+wait4
+    "return a wait cursor showing 9 o'clock"
+
+    Wait4Cursor isNil ifTrue:[
+        Wait4Cursor := (Cursor
+                        extent: 16@16
+                        sourceArray: #(
+                            2r0001111111100000
+                            2r0001111111100000
+                            2r0001111111100000
+                            2r0011111111110000
+                            2r0110000000011000
+                            2r1100000000001100
+                            2r1000000000000111
+                            2r1111111110000111
+                            2r1000001110000111
+                            2r1000010000000111
+                            2r1100100000001100
+                            2r0110000000011000
+                            2r0011111111110000
+                            2r0001111111100000
+                            2r0001111111100000
+                            2r0001111111100000
+                            )
+                        maskArray: #(
+                            2r0011111111110000
+                            2r0011111111110000
+                            2r0011111111110000
+                            2r0111111111111000
+                            2r1111111111111100
+                            2r1111111111111111
+                            2r1111111111111111
+                            2r1111111111111111
+                            2r1111111111111111
+                            2r1111111111111111
+                            2r1111111111111111
+                            2r1111111111111100
+                            2r0111111111111000
+                            2r0011111111110000
+                            2r0011111111110000
+                            2r0011111111110000
+                           )
+                        offset: -15 @ -9).
+        Wait4Cursor := Wait4Cursor on:Display.
+    ].
+    ^ Wait4Cursor
+!
+
 read
     "return a reading-file cursor"
 
@@ -404,6 +551,30 @@
     ]
 ! !
 
+!Cursor methodsFor:'private accessing'!
+
+setShape:aShapeSymbol
+    "set the shape"
+
+    shape := aShapeSymbol.
+!
+
+setSourceForm:sForm maskForm:mForm hotX:hx hotY:hy
+    "set the forms and hotspot"
+
+    sourceForm := sForm.
+    maskForm := mForm.
+    hotX := hx.
+    hotY := hy.
+!
+
+setDevice:aDevice id:anId
+    "set the device and deviceId of the receiver"
+
+    device := aDevice.
+    cursorId := anId
+! !
+
 !Cursor methodsFor:'accessing'!
 
 id
@@ -424,23 +595,6 @@
     ^ shape
 !
 
-shape:aShapeSymbol on:aDevice
-    "set the shape and device of the receiver"
-
-    shape := aShapeSymbol.
-    device := aDevice
-!
-
-sourceForm:sForm maskForm:mForm hotX:hx hotY:hy on:aDevice
-    "set the forms, hotspot and device of the receiver"
-
-    sourceForm := sForm.
-    maskForm := mForm.
-    hotX := hx.
-    hotY := hy.
-    device := aDevice
-!
-
 sourceForm
     "return the source-form of the receiver"
 
@@ -471,24 +625,12 @@
     ^ hotX
 !
 
-hotX:aNumber
-    "set the hotspots x-coordinate of the receiver"
-
-    hotX := aNumber
-!
-
 hotY
     "return the hotspots y-coordinate of the receiver"
 
     ^ hotY
 !
 
-hotY:aNumber
-    "set the hotspots y-coordinate of the receiver"
-
-    hotY := aNumber
-!
-
 foreground:fgColor background:bgColor
     "set the cursor colors"
 
@@ -534,17 +676,20 @@
 
     "ask that device for the cursor"
     shape notNil ifTrue:[
-        id := aDevice createCursorShape:shape
+        id := aDevice createCursorShape:shape.
+        id isNil ifTrue:[
+            'no cursor with shape:' print. shape printNewline.
+            ^ nil
+        ].
     ] ifFalse:[
         id := aDevice createCursorSourceForm:sourceForm
                                     maskForm:maskForm
                                         hotX:hotX
-                                        hotY:hotY
-    ].
-    id isNil ifTrue:[
-        "no such cursor on this device"
-        'no cursor with shape:' print. shape printNewline.
-        ^ nil
+                                        hotY:hotY.
+        id isNil ifTrue:[
+            'cannot create cursor' printNewline.
+            ^ nil
+        ].
     ].
 
     "goody for IRIXs red cursor"
@@ -564,16 +709,16 @@
     ].
 
     "receiver was already associated to another device - need a new cursor"
+    newCursor := self class basicNew.
     shape notNil ifTrue:[
-        newCursor := (self class basicNew) shape:shape on:aDevice
+        newCursor setShape:shape.
     ] ifFalse:[
-        newCursor := (self class basicNew) sourceForm:sourceForm
-                                             maskForm:maskForm
-                                                 hotX:hotX
-                                                 hotY:hotY
-                                                   on:aDevice
+        newCursor setSourceForm:sourceForm
+                       maskForm:maskForm
+                           hotX:hotX
+                           hotY:hotY
     ].
-    newCursor id:id.
+    newCursor setDevice:aDevice id:id.
     lobby register:newCursor.
     ^ newCursor
 ! !
@@ -590,7 +735,7 @@
     cursorId := anId
 !
 
-resetDevice
+restored
     "set both device and id"
 
     device := nil.