Initial revision
[ssr] / StraySrc / Libraries / Sapphire / sh / dbx / dbx
1 ;
2 ; dbx.dbx.sh
3 ;
4 ; Managing dialogue box control types
5 ;
6 ; © 1994-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 ; dbx_declare
32 ; dbx_sendEvent
33 ; dbx_findData
34 ; dbx_controlBBox
35 ; dbx_update
36 ; dbx_qUpdate
37 ;
38 ; Macros provided:
39 ;
40 ; CONTROL
41 ; ECTRL
42 ; DBXEND
43
44 [ :LNOT::DEF:dbx__dfn
45 GBLL dbx__dfn
46
47 ;+ LIB sapphire:^.bsh.dbx
48
49 ; --- dbx_declare ---
50 ;
51 ; On entry: R0 == dialogue box handle from dbox
52 ; R1 == pointer to dialogue box definition block
53 ;
54 ; On exit: --
55 ;
56 ; Use: Declares a dialogue box to be dbx-managed, and declares the
57 ; control types of all its controls.
58
59 IMPORT dbx_declare
60
61 ; --- dbx_sendEvent ---
62 ;
63 ; On entry: R0 == event code to send
64 ; R1-R7 == depend on the event code
65 ; R10 == dialogue box handle
66 ;
67 ; On exit: C flag as set by event handler
68 ;
69 ; Use: Sends an event to the specified dialogue box. This is
70 ; intended to be used by control handlers, hence the unusual
71 ; placing of the dialogue handle in R10.
72
73 IMPORT dbx_sendEvent
74
75 ; --- dbx_findData ---
76 ;
77 ; On entry: R0 == icon handle
78 ; R10 == dialogue box handle
79 ;
80 ; On exit: If found, CS and
81 ; R8 == pointer to writable control data
82 ; R9 == pointer to static control data
83 ; else CC and
84 ; R8, R9 corrupted
85 ;
86 ; Use: Allows a control to find its data when called by client
87 ; code.
88
89 IMPORT dbx_findData
90
91 ; --- dbx_controlBBox ---
92 ;
93 ; On entry: R0 == dialogue box handle
94 ; R1 == control icon number
95 ;
96 ; On exit: R0,R1 preserved
97 ; R2-R5 == inclusive screen coordinates of icon bounding box
98 ;
99 ; Use: Calculates the position *on the screen* of the given control
100 ; icon, and returns it to you as a set of four inclusive
101 ; coordinates (*not* inclusive-exclusve as the WIMP tends to
102 ; return to you)
103
104 IMPORT dbx_controlBBox
105
106 ; --- dbx_update ---
107 ;
108 ; On entry: R0 == dialogue box handle
109 ; R1 == icon number of control to update
110 ;
111 ; On exit: --
112 ;
113 ; Use: Redraws the specified control immediately. If the control
114 ; does not redraw itself, this call does nothing.
115
116 IMPORT dbx_update
117
118 ; --- dbx_qUpdate ---
119 ;
120 ; On entry: R0 == dialogue box handle
121 ; R1 == icon number of control to update
122 ;
123 ; On exit: --
124 ;
125 ; Use: Makes a control quickly update itself in whichever way it
126 ; needs to in order to be perfect again. It is anticipated
127 ; that this is used to update EORed areas of the control.
128
129 IMPORT dbx_qUpdate
130
131 ;----- Creating dialogue definitions ----------------------------------------
132
133 ; --- Some internal definitions ---
134
135 GBLA dbx__c
136 dbx__c SETA 0
137
138 ; --- Macro: CONTROL ---
139 ;
140 ; Arguments: icon == icon number for control
141 ; control == pointer to control definition
142 ; baseReg == base register for data
143 ; flags == other flags for this control
144 ; data == offset within data area
145 ;
146 ; Use: Creates a control header block. Intended to be used by
147 ; specifiec control defining macros.
148
149 MACRO
150 $label CONTROL $icon,$control,$baseReg,$flags,$data
151
152 dbx__c SETA dbx__c+1
153
154 ALIGN
155 $label
156 dbx__s$dbx__c
157
158 LCLA ctf
159 ctf SETA $flags
160
161 DCD $icon
162 DCD $control
163
164 [ "$baseReg" = "R10"
165 ctf SETA ctf :OR: dbxFlag_dataR10
166 ]
167
168 [ "$baseReg" = "R12"
169 ctf SETA ctf :OR: dbxFlag_dataR12
170 ]
171
172 DCD ctf
173 DCD dbx__sz$dbx__c
174
175 [ ctf :AND: 3 <> 0
176 DCD $data
177 ]
178
179 MEND
180
181 ; --- Macro: ECTRL ---
182 ;
183 ; Arguments: --
184 ;
185 ; Use: Ends a control definition
186
187 MACRO
188 ECTRL
189
190 ALIGN
191 dbx__sz$dbx__c EQU {PC}-dbx__s$dbx__c
192
193 MEND
194
195 ; --- Macro: DBXEND ---
196 ;
197 ; Arguments: --
198 ;
199 ; Use: Terminates a list of control entries for a dialogue box.
200
201 MACRO
202 DBXEND
203 DCD -1
204 MEND
205
206 ;----- Standard dbx flags ---------------------------------------------------
207 ;
208 ; Individual controls may have their own flags starting at bit 8.
209
210 dbxFlag_dataR10 EQU (1<<0) ;Has R10-relative data
211 dbxFlag_dataR12 EQU (1<<1) ;Has R12-relative data
212
213 ;----- dbx event codes ------------------------------------------------------
214 ;
215 ; All events have:
216 ;
217 ; R0 == event code
218 ; R1 == icon handle of control
219 ; R8 == pointer to control workspace
220 ; R9 == pointer to control definition body
221 ; R10 == dialogue box handle
222 ; R12 == control handler workspace
223
224 ^ 0
225 dbxEvent_click # 1 ;Mouse click on the control
226 ;R2 == button status
227
228 dbxEvent_redraw # 1 ;Redraw or update the control
229 ;R2-R5 == coords of control
230 ;R6 == ptr to graphics window
231
232 dbxEvent_key # 1 ;Key pressed
233 ;R2 == key code
234
235 dbxEvent_drop # 1 ;File dropped on control
236 ;R2 == filetype
237 ;R3 == pointer to filename
238 ;R4 == estimated file size
239 ;R5 == subreason code
240
241 dbxEvent_help # 1 ;Help request for control
242
243 dbxEvent_update # 1 ;Quick update request
244 ;R2-R5 == coords of control
245 ;R6 == ptr to graphics window
246
247 dbxEvent_lifeCycle # 1 ;Dialogue state change
248 ;R1 == dblc lifecycle code
249
250 ; --- dbxEvent_drop subreason codes ---
251
252 ^ 0
253 dbxDrop_load # 1
254 dbxDrop_save # 1
255
256 ; --- dbx event masks ---
257
258 dbxMask_click EQU (1<<dbxEvent_click)
259 dbxMask_redraw EQU (1<<dbxEvent_redraw)
260 dbxMask_key EQU (1<<dbxEvent_key)
261 dbxMask_drop EQU (1<<dbxEvent_drop)
262 dbxMask_help EQU (1<<dbxEvent_help)
263 dbxMask_update EQU (1<<dbxEvent_update)
264 dbxMask_lifeCycle EQU (1<<dbxEvent_lifeCycle)
265
266 ]
267
268 ;----- That's all, folks ----------------------------------------------------
269
270 END