Initial revision
[ssr] / StraySrc / Libraries / Sapphire / sh / listbox
1 ;
2 ; listbox.sh
3 ;
4 ; Nice listbox handling routines
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 ; lb_create
32 ; lb_destroy
33 ; lb_eventHandler
34 ; lb_plotString
35 ; lb_update
36 ; lb_updateItem
37 ; lb_select
38 ; lb_isSelected
39 ; lb_clearSelection
40 ; lb_clickS
41 ; lb_clickM
42 ; lb_drag
43 ; lb_inserted
44 ; lb_removed
45 ; lb_init
46
47 [ :LNOT::DEF:listbox__dfn
48 GBLL listbox__dfn
49
50 ; --- lb_create ---
51 ;
52 ; On entry: R0 == pointer to list manager description block
53 ; R1 == pointer to the list
54 ; R2 == pointer to a width function
55 ; R3 == The height of each item
56 ; R4 == parent window handle or
57 ; pointer to window block if R5 == -1
58 ; R5 == parent icon handle or -1 if not a pane
59 ;
60 ; On exit: R0 == listbox handle
61 ; R1 == window handle of list box
62 ; May return an error (R1 corrupted)
63
64 IMPORT lb_create
65
66 ; --- lb_destroy ---
67 ;
68 ; On entry: R0 == listbox handle
69 ;
70 ; On exit: --
71 ;
72 ; Use: Destroys the given listbox.
73
74 IMPORT lb_destroy
75
76 ; --- lb_eventHandler ---
77 ;
78 ; On entry: R0 == listbox handle
79 ; R1 == handler function
80 ; R2 == R10 value to pass
81 ; R3 == R12 value to pass
82 ;
83 ; On exit: --
84 ;
85 ; Use: Registers an event handler for the given listbox.
86
87 IMPORT lb_eventHandler
88
89 ; --- lb_plotString ---
90 ;
91 ; On entry: R0 == pointer to a string
92 ; R1 == pointer to the list item
93 ; R2-R5 == window coordinates to plot it
94 ; R10 == pointer to the listbox
95 ;
96 ; On exit: --
97 ;
98 ; Use: Plots a list item consisting of a single string. It assumes
99 ; the default selection model.
100
101 IMPORT lb_plotString
102
103 ; --- lb_update ---
104 ;
105 ; On entry: R0 == listbox handle
106 ;
107 ; On exit: May return an error
108 ;
109 ; Use: Updates the entire listbox prettily
110
111 IMPORT lb_update
112
113 ; --- lb_updateItem ---
114 ;
115 ; On entry: R0 == list box handle
116 ; R1 == list item handle
117 ;
118 ; On exit: --
119 ;
120 ; Use: Redraws a list item to reflect a change in its state.
121
122 IMPORT lb_updateItem
123
124 ; --- lb_select ---
125 ;
126 ; On entry: R0 == listbox handle
127 ; R1 == item handle
128 ; R2 == 0 to unselect, 1 to select, or 2 to toggle
129 ;
130 ; On exit: --
131 ;
132 ; Use: Selects or deselects a listbox item, nicely and without
133 ; flickering it.
134
135 IMPORT lb_select
136
137 ; --- lb_isSelected ---
138 ;
139 ; On entry: R0 == listbox handle
140 ; R1 == item handle
141 ;
142 ; On exit: CS if item is selected, else CC
143 ;
144 ; Use: Informs you whether an item is selected.
145
146 IMPORT lb_isSelected
147
148 ; --- lb_clearSelection ---
149 ;
150 ; On entry: R0 == listbox handle
151 ; R1 == item handle of item to ignore (or 0 for none)
152 ;
153 ; On exit: --
154 ;
155 ; Use: Deselects all items in the listbox.
156
157 IMPORT lb_clearSelection
158
159 ; --- lb_clickS ---
160 ;
161 ; On entry: R0 == listbox handle
162 ; R1 == pointer to list item
163 ; R3 == mouse button status
164 ;
165 ; On exit: --
166 ;
167 ; Use: Provides a default action for clicking on an item in a
168 ; list box.
169 ;
170 ; Only one selection is possible at any one time.
171
172 IMPORT lb_clickS
173
174 ; --- lb_clickM ---
175 ;
176 ; On entry: R0 == listbox handle
177 ; R1 == pointer to list item
178 ; R3 == mouse button status
179 ;
180 ; On exit: --
181 ;
182 ; Use: Provides a default action for clicking on an item in a
183 ; list box.
184 ;
185 ; The multiple selection model is used.
186
187 IMPORT lb_clickM
188
189 ; --- lb_drag ---
190 ;
191 ; On entry: R1 == pointer to list item
192 ; R2 == window relative y position
193 ; R3 == mouse button status
194 ; R10 == listbox handle
195 ;
196 ; On exit: --
197 ;
198 ; Use: Starts a drag operation to allow for easy multiple
199 ; selection.
200
201 IMPORT lb_drag
202
203 ; --- lb_inserted ---
204 ;
205 ; On entry: R0 == pointer to the listbox
206 ; R1 == pointer to the new item
207 ;
208 ; On exit: --
209 ;
210 ; Use: Informs the listbox that an item has been inserted,
211 ; and causes a flicker free insert to occur if possible.
212
213 IMPORT lb_inserted
214
215 ; --- lb_removed ---
216 ;
217 ; On entry: R0 == pointer to the listbox
218 ; R1 == index of item removed
219 ;
220 ; On exit: --
221 ;
222 ; Use: Informs the listbox that an item has been removed, and
223 ; causes a flicker free remove to occur, if possible.
224
225 IMPORT lb_removed
226
227 ; --- lb_window ---
228 ;
229 ; On entry: R0 == listbox handle
230 ;
231 ; On exit: R0 == window handle
232 ;
233 ; Use: Returns the window handle of the listbox
234
235 IMPORT lb_window
236
237 ; --- lb_init ---
238 ;
239 ; On entry: --
240 ;
241 ; On exit: --
242 ;
243 ; Use: Initialises the listbox unit.
244
245 IMPORT lb_init
246
247 ;----- List events ----------------------------------------------------------
248
249 ^ 0
250 lbEvent_close # 1 ;Listbox has been closed
251
252 lbEvent_redraw # 1 ;Redraw a list item
253 ;R1 == pointer to list item
254 ;R2-R5 == window coords
255 lbEvent_click # 1 ;Click/Double on listbox
256 ;R1 == pointer to list item
257 ;R2 == window relative y pos
258 ;R3 == button type (10)
259 lbEvent_menu # 1 ;Menu click
260 ;R1 == pointer to list item
261 ;R2 == window relative y pos
262 ;R3 == button type (10)
263 lbEvent_drag # 1 ;Drag on listbox
264 ;R1 == pointer to list item
265 ;R2 == window relative y pos
266 ;R3 == button type (10)
267 lbEvent_help # 1 ;R1 == pointer to list item
268 lbEvent_drop # 1 ;R1 == pointer to list item
269 ;R2 == filetype
270 ;R3 == pointer to filename
271 ;R4 == estimated file size
272 ;R5 == subreason cde
273
274 ^ 0
275 lbDrop_load # 1
276 lbDrop_save # 1
277
278
279 ]
280
281 ;----- That's all, folks ----------------------------------------------------
282
283 END