Initial revision
[ssr] / StraySrc / Libraries / Sapphire / sh / drag
1 ;
2 ; drag.sh
3 ;
4 ; Support code for dragging operations
5 ;
6 ; © 1995-1998 Straylight
7 ;
8
9 ;----- Licensing note -------------------------------------------------------
10 ;
11 ; This file is part of Straylight's Sapphire library.
12 ;
13 ; Sapphire is free software; you can redistribute it and/or modify
14 ; it under the terms of the GNU General Public License as published by
15 ; the Free Software Foundation; either version 2, or (at your option)
16 ; any later version.
17 ;
18 ; Sapphire is distributed in the hope that it will be useful,
19 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ; GNU General Public License for more details.
22 ;
23 ; You should have received a copy of the GNU General Public License
24 ; along with Sapphire. If not, write to the Free Software Foundation,
25 ; 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26
27 ;----- Overview -------------------------------------------------------------
28 ;
29 ; Functions provided:
30 ;
31 ; drag_start
32 ; drag_scroll
33 ; drag_setDash
34 ; drag_cancel
35 ; drag_redraw
36 ; drag_eorColour
37
38 [ :LNOT::DEF:drag__dfn
39 GBLL drag__dfn
40
41 ; --- drag_start ---
42 ;
43 ; On entry: R0 == window containing the drag
44 ; R1 == flags word (see flags below)
45 ; R2 == pointer to drag routine
46 ; R3 == magic number to pass in R9
47 ; R4 == value to pass to routine in R10
48 ; R5 == value to pass to routine in R12
49 ;
50 ; On exit: --
51 ;
52 ; Use: Starts a drag operation. Any outstanding drag operation
53 ; is cancelled on the assumption that someone stole our
54 ; UserDragBox event.
55
56 IMPORT drag_start
57
58 ; --- drag_scroll ---
59 ;
60 ; On entry: R1 == pointer to window state block
61 ;
62 ; On exit: R2,R3 == new scroll positions to set
63 ; R14 == R1+20 (pointer to scroll offsets)
64 ;
65 ; Use: Works out the scroll positions which should be set to auto-
66 ; scroll the window. The algorithm is simple: the window is
67 ; scrolled so that the point beneath the mouse pointer is
68 ; within the window's visible work area.
69
70 IMPORT drag_scroll
71
72 ; --- drag_setDash ---
73 ;
74 ; On entry: R0 == dash pattern byte
75 ;
76 ; On exit: --
77 ;
78 ; Use: Sets the dash pattern to be the given value.
79
80 IMPORT drag_setDash
81
82 ; --- drag_cancel ---
83 ;
84 ; On entry: --
85 ;
86 ; On exit: --
87 ;
88 ; Use: Cancels the current drag operation.
89
90 IMPORT drag_cancel
91
92 ; --- drag_redraw ---
93 ;
94 ; On entry: R1 == pointer to redraw block
95 ;
96 ; On exit: --
97 ;
98 ; Use: Redraws the drag box, if the redraw takes place in the
99 ; currently dragging window.
100
101 IMPORT drag_redraw
102
103 ; --- drag_eorColour ---
104 ;
105 ; On entry: R0 == colour A
106 ; R1 == colour B
107 ;
108 ; On exit: --
109 ;
110 ; Use: Sets the foreground colour to be an EOR colour such that
111 ; when painted over Wimp colour A, it appears as Wimp colour B.
112
113 IMPORT drag_eorColour
114
115 ;----- Flags ----------------------------------------------------------------
116
117 drFlag_noUpdate EQU (1<<0) ;Don't generate update events
118
119 ;----- Drag handler events --------------------------------------------------
120
121 ; --- Note ---
122 ;
123 ; The events which request that you draw something are called for each
124 ; rectangle of the draw operation -- i.e. do not call Wimp_GetRectangle
125 ; because this is done for you.
126
127 ^ 0
128 drEvent_draw # 1 ;Draw dragged object
129 ;R1 == pointer to redraw blk
130 ;R2,R3 == drag start posn
131 ;R4,R5 == drag current posn
132 ;R6,R7 == window origin
133 ;Dash pattern set up
134
135 drEvent_undraw # 1 ;Undraw dragged object
136 ;Regs as for drEvent_draw
137 ;Normally use the same code
138
139 drEvent_update # 1 ;Redraw dragged object in
140 ;place
141 ;Regs as for drEvent_draw
142 ;Dash pattern set up so that
143 ;single plot will rotate box,
144 ;so may share code with
145 ;drEvent_draw
146
147 drEvent_trans # 1 ;Translate coordinates
148 ;R1 == ptr to window state
149 ;R4,R5 == pointer position
150 ;R6,R7 == window origin
151 ;Translate pointer position
152 ;to internal coordinates if
153 ;this is useful to you.
154 ;Return new coords in R4,R5
155
156 drEvent_getPos # 1 ;Read pointer position
157 ;R1 == ptr to window state
158 ;R2,R3 == start position
159 ;R4,R5 == pointer position
160 ;R6,R7 == window origin
161 ;Used to read pointer posn.
162 ;Do any grid snapping here
163 ;and return with R4,R5 as
164 ;coords to use.
165
166 drEvent_done # 1 ;Drag operation completed
167 ;R1 == ptr to window state
168 ;R2,R3 == drag start posn
169 ;R4,R5 == drag current posn
170
171 drEvent_cancel # 1 ;Drag operation aborted
172 ;No other registers set up
173
174 ]
175
176 ;----- That's all, folks ----------------------------------------------------
177
178 END