457f0b8f |
1 | /* $Id: macctrls.c,v 1.29 2003/04/05 18:00:46 ben Exp $ */ |
8a7e67ec |
2 | /* |
3 | * Copyright (c) 2003 Ben Harris |
4 | * All rights reserved. |
5 | * |
6 | * Permission is hereby granted, free of charge, to any person |
7 | * obtaining a copy of this software and associated documentation |
8 | * files (the "Software"), to deal in the Software without |
9 | * restriction, including without limitation the rights to use, |
10 | * copy, modify, merge, publish, distribute, sublicense, and/or |
11 | * sell copies of the Software, and to permit persons to whom the |
12 | * Software is furnished to do so, subject to the following |
13 | * conditions: |
14 | * |
15 | * The above copyright notice and this permission notice shall be |
16 | * included in all copies or substantial portions of the Software. |
17 | * |
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
20 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
21 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR |
22 | * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF |
23 | * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
24 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
25 | * SOFTWARE. |
26 | */ |
27 | |
28 | #include <MacTypes.h> |
29 | #include <Appearance.h> |
30 | #include <Controls.h> |
31 | #include <ControlDefinitions.h> |
135c0f1a |
32 | #include <Events.h> |
56c01970 |
33 | #include <Menus.h> |
fa4942e7 |
34 | #include <Resources.h> |
0e9ce565 |
35 | #include <Script.h> |
8a7e67ec |
36 | #include <Sound.h> |
0e9ce565 |
37 | #include <TextEdit.h> |
8a7e67ec |
38 | #include <TextUtils.h> |
0e9ce565 |
39 | #include <ToolUtils.h> |
8a7e67ec |
40 | #include <Windows.h> |
41 | |
93ba25f8 |
42 | #include <assert.h> |
ee10bc56 |
43 | #include <string.h> |
93ba25f8 |
44 | |
8a7e67ec |
45 | #include "putty.h" |
46 | #include "mac.h" |
47 | #include "macresid.h" |
48 | #include "dialog.h" |
49 | #include "tree234.h" |
50 | |
56c01970 |
51 | /* Range of menu IDs for popup menus */ |
52 | #define MENU_MIN 1024 |
53 | #define MENU_MAX 2048 |
54 | |
55 | |
8a7e67ec |
56 | union macctrl { |
57 | struct macctrl_generic { |
58 | enum { |
59 | MACCTRL_TEXT, |
1f1ec0e5 |
60 | MACCTRL_EDITBOX, |
8a7e67ec |
61 | MACCTRL_RADIO, |
62 | MACCTRL_CHECKBOX, |
56c01970 |
63 | MACCTRL_BUTTON, |
64 | MACCTRL_POPUP |
8a7e67ec |
65 | } type; |
66 | /* Template from which this was generated */ |
67 | union control *ctrl; |
ee10bc56 |
68 | /* Next control in this panel */ |
69 | union macctrl *next; |
1f1ec0e5 |
70 | void *privdata; |
71 | int freeprivdata; |
8a7e67ec |
72 | } generic; |
73 | struct { |
74 | struct macctrl_generic generic; |
75 | ControlRef tbctrl; |
76 | } text; |
77 | struct { |
78 | struct macctrl_generic generic; |
1f1ec0e5 |
79 | ControlRef tbctrl; |
cd3e71e8 |
80 | ControlRef tblabel; |
1f1ec0e5 |
81 | } editbox; |
82 | struct { |
83 | struct macctrl_generic generic; |
8a7e67ec |
84 | ControlRef *tbctrls; |
cd3e71e8 |
85 | ControlRef tblabel; |
8a7e67ec |
86 | } radio; |
87 | struct { |
88 | struct macctrl_generic generic; |
89 | ControlRef tbctrl; |
90 | } checkbox; |
91 | struct { |
92 | struct macctrl_generic generic; |
93 | ControlRef tbctrl; |
457f0b8f |
94 | ControlRef tbring; |
8a7e67ec |
95 | } button; |
56c01970 |
96 | struct { |
97 | struct macctrl_generic generic; |
98 | ControlRef tbctrl; |
99 | MenuRef menu; |
100 | int menuid; |
101 | unsigned int nids; |
102 | int *ids; |
103 | } popup; |
8a7e67ec |
104 | }; |
105 | |
106 | struct mac_layoutstate { |
107 | Point pos; |
108 | unsigned int width; |
ee10bc56 |
109 | unsigned int panelnum; |
8a7e67ec |
110 | }; |
111 | |
112 | #define ctrlevent(mcs, mc, event) do { \ |
113 | if ((mc)->generic.ctrl->generic.handler != NULL) \ |
93ba25f8 |
114 | (*(mc)->generic.ctrl->generic.handler)((mc)->generic.ctrl, (mcs),\ |
8a7e67ec |
115 | (mcs)->data, (event)); \ |
116 | } while (0) |
117 | |
93ba25f8 |
118 | #define findbyctrl(mcs, ctrl) \ |
119 | find234((mcs)->byctrl, (ctrl), macctrl_cmp_byctrl_find) |
120 | |
8a7e67ec |
121 | static void macctrl_layoutset(struct mac_layoutstate *, struct controlset *, |
122 | WindowPtr, struct macctrls *); |
ee10bc56 |
123 | static void macctrl_switchtopanel(struct macctrls *, unsigned int); |
a460b361 |
124 | static void macctrl_setfocus(struct macctrls *, union macctrl *); |
8a7e67ec |
125 | static void macctrl_text(struct macctrls *, WindowPtr, |
126 | struct mac_layoutstate *, union control *); |
1f1ec0e5 |
127 | static void macctrl_editbox(struct macctrls *, WindowPtr, |
128 | struct mac_layoutstate *, union control *); |
8a7e67ec |
129 | static void macctrl_radio(struct macctrls *, WindowPtr, |
130 | struct mac_layoutstate *, union control *); |
131 | static void macctrl_checkbox(struct macctrls *, WindowPtr, |
132 | struct mac_layoutstate *, union control *); |
133 | static void macctrl_button(struct macctrls *, WindowPtr, |
134 | struct mac_layoutstate *, union control *); |
56c01970 |
135 | static void macctrl_popup(struct macctrls *, WindowPtr, |
136 | struct mac_layoutstate *, union control *); |
fa4942e7 |
137 | #if !TARGET_API_MAC_CARBON |
0e9ce565 |
138 | static pascal SInt32 macctrl_sys7_editbox_cdef(SInt16, ControlRef, |
139 | ControlDefProcMessage, SInt32); |
5537f572 |
140 | static pascal SInt32 macctrl_sys7_default_cdef(SInt16, ControlRef, |
141 | ControlDefProcMessage, SInt32); |
fa4942e7 |
142 | #endif |
143 | |
144 | #if !TARGET_API_MAC_CARBON |
145 | /* |
146 | * This trick enables us to keep all the CDEF code in the main |
147 | * application, which makes life easier. For details, see |
148 | * <http://developer.apple.com/technotes/tn/tn2003.html#custom_code_base>. |
149 | */ |
150 | |
151 | #pragma options align=mac68k |
152 | typedef struct { |
153 | short jmpabs; /* 4EF9 */ |
154 | ControlDefUPP theUPP; |
155 | } **PatchCDEF; |
156 | #pragma options align=reset |
157 | #endif |
158 | |
159 | static void macctrl_init() |
160 | { |
161 | #if !TARGET_API_MAC_CARBON |
162 | static int inited = 0; |
163 | PatchCDEF cdef; |
164 | |
165 | if (inited) return; |
0e9ce565 |
166 | cdef = (PatchCDEF)GetResource(kControlDefProcResourceType, CDEF_EditBox); |
167 | (*cdef)->theUPP = NewControlDefProc(macctrl_sys7_editbox_cdef); |
5537f572 |
168 | cdef = (PatchCDEF)GetResource(kControlDefProcResourceType, CDEF_Default); |
169 | (*cdef)->theUPP = NewControlDefProc(macctrl_sys7_default_cdef); |
fa4942e7 |
170 | inited = 1; |
171 | #endif |
172 | } |
173 | |
8a7e67ec |
174 | |
175 | static int macctrl_cmp_byctrl(void *av, void *bv) |
176 | { |
177 | union macctrl *a = (union macctrl *)av; |
178 | union macctrl *b = (union macctrl *)bv; |
179 | |
180 | if (a->generic.ctrl < b->generic.ctrl) |
181 | return -1; |
182 | else if (a->generic.ctrl > b->generic.ctrl) |
183 | return +1; |
184 | else |
185 | return 0; |
186 | } |
187 | |
93ba25f8 |
188 | static int macctrl_cmp_byctrl_find(void *av, void *bv) |
189 | { |
190 | union control *a = (union control *)av; |
191 | union macctrl *b = (union macctrl *)bv; |
192 | |
193 | if (a < b->generic.ctrl) |
194 | return -1; |
195 | else if (a > b->generic.ctrl) |
196 | return +1; |
197 | else |
198 | return 0; |
199 | } |
200 | |
8a7e67ec |
201 | void macctrl_layoutbox(struct controlbox *cb, WindowPtr window, |
202 | struct macctrls *mcs) |
203 | { |
204 | int i; |
205 | struct mac_layoutstate curstate; |
206 | ControlRef root; |
207 | Rect rect; |
fa4942e7 |
208 | |
209 | macctrl_init(); |
8a7e67ec |
210 | #if TARGET_API_MAC_CARBON |
211 | GetPortBounds(GetWindowPort(window), &rect); |
212 | #else |
213 | rect = window->portRect; |
214 | #endif |
215 | curstate.pos.h = rect.left + 13; |
47c65db4 |
216 | curstate.pos.v = rect.bottom - 33; |
8a7e67ec |
217 | curstate.width = rect.right - rect.left - (13 * 2); |
218 | if (mac_gestalts.apprvers >= 0x100) |
219 | CreateRootControl(window, &root); |
1f1ec0e5 |
220 | mcs->window = window; |
8a7e67ec |
221 | mcs->byctrl = newtree234(macctrl_cmp_byctrl); |
a460b361 |
222 | mcs->focus = NULL; |
135c0f1a |
223 | mcs->defbutton = NULL; |
224 | mcs->canbutton = NULL; |
ee10bc56 |
225 | /* Count the number of panels */ |
226 | mcs->npanels = 1; |
227 | for (i = 1; i < cb->nctrlsets; i++) |
228 | if (strcmp(cb->ctrlsets[i]->pathname, cb->ctrlsets[i-1]->pathname)) |
229 | mcs->npanels++; |
34773273 |
230 | mcs->panels = snewn(mcs->npanels, union macctrl *); |
ee10bc56 |
231 | memset(mcs->panels, 0, sizeof(*mcs->panels) * mcs->npanels); |
232 | curstate.panelnum = 0; |
233 | for (i = 0; i < cb->nctrlsets; i++) { |
234 | if (i > 0 && strcmp(cb->ctrlsets[i]->pathname, |
235 | cb->ctrlsets[i-1]->pathname)) { |
236 | curstate.pos.v = rect.top + 13; |
237 | curstate.panelnum++; |
238 | assert(curstate.panelnum < mcs->npanels); |
239 | } |
8a7e67ec |
240 | macctrl_layoutset(&curstate, cb->ctrlsets[i], window, mcs); |
ee10bc56 |
241 | } |
47c65db4 |
242 | macctrl_switchtopanel(mcs, 1); |
f28d33e8 |
243 | /* 14 = proxies, 20 = SSH bugs */ |
8a7e67ec |
244 | } |
245 | |
47c65db4 |
246 | #define MAXCOLS 16 |
247 | |
8a7e67ec |
248 | static void macctrl_layoutset(struct mac_layoutstate *curstate, |
249 | struct controlset *s, |
250 | WindowPtr window, struct macctrls *mcs) |
251 | { |
47c65db4 |
252 | unsigned int i, j, ncols, colstart; |
253 | struct mac_layoutstate cols[MAXCOLS]; |
8a7e67ec |
254 | |
255 | fprintf(stderr, "--- begin set ---\n"); |
93ba25f8 |
256 | fprintf(stderr, "pathname = %s\n", s->pathname); |
8a7e67ec |
257 | if (s->boxname && *s->boxname) |
258 | fprintf(stderr, "boxname = %s\n", s->boxname); |
259 | if (s->boxtitle) |
260 | fprintf(stderr, "boxtitle = %s\n", s->boxtitle); |
261 | |
47c65db4 |
262 | cols[0] = *curstate; |
263 | ncols = 1; |
8a7e67ec |
264 | |
265 | for (i = 0; i < s->ncontrols; i++) { |
266 | union control *ctrl = s->ctrls[i]; |
267 | char const *s; |
268 | |
47c65db4 |
269 | colstart = COLUMN_START(ctrl->generic.column); |
8a7e67ec |
270 | switch (ctrl->generic.type) { |
271 | case CTRL_TEXT: s = "text"; break; |
272 | case CTRL_EDITBOX: s = "editbox"; break; |
273 | case CTRL_RADIO: s = "radio"; break; |
274 | case CTRL_CHECKBOX: s = "checkbox"; break; |
275 | case CTRL_BUTTON: s = "button"; break; |
276 | case CTRL_LISTBOX: s = "listbox"; break; |
277 | case CTRL_COLUMNS: s = "columns"; break; |
278 | case CTRL_FILESELECT: s = "fileselect"; break; |
279 | case CTRL_FONTSELECT: s = "fontselect"; break; |
280 | case CTRL_TABDELAY: s = "tabdelay"; break; |
281 | default: s = "unknown"; break; |
282 | } |
283 | fprintf(stderr, " control: %s\n", s); |
284 | switch (ctrl->generic.type) { |
47c65db4 |
285 | case CTRL_COLUMNS: |
286 | if (ctrl->columns.ncols != 1) { |
287 | ncols = ctrl->columns.ncols; |
288 | fprintf(stderr, " split to %d\n", ncols); |
289 | assert(ncols <= MAXCOLS); |
290 | for (j = 0; j < ncols; j++) { |
291 | cols[j] = cols[0]; |
292 | if (j > 0) |
293 | cols[j].pos.h = cols[j-1].pos.h + cols[j-1].width + 6; |
294 | if (j == ncols - 1) |
295 | cols[j].width = curstate->width - |
296 | (cols[j].pos.h - curstate->pos.h); |
297 | else |
298 | cols[j].width = (curstate->width + 6) * |
299 | ctrl->columns.percentages[j] / 100 - 6; |
300 | } |
301 | } else { |
302 | fprintf(stderr, " join\n"); |
303 | for (j = 0; j < ncols; j++) |
304 | if (cols[j].pos.v > cols[0].pos.v) |
305 | cols[0].pos.v = cols[j].pos.v; |
306 | cols[0].width = curstate->width; |
307 | ncols = 1; |
308 | } |
309 | break; |
8a7e67ec |
310 | case CTRL_TEXT: |
47c65db4 |
311 | macctrl_text(mcs, window, &cols[colstart], ctrl); |
8a7e67ec |
312 | break; |
1f1ec0e5 |
313 | case CTRL_EDITBOX: |
47c65db4 |
314 | macctrl_editbox(mcs, window, &cols[colstart], ctrl); |
1f1ec0e5 |
315 | break; |
8a7e67ec |
316 | case CTRL_RADIO: |
47c65db4 |
317 | macctrl_radio(mcs, window, &cols[colstart], ctrl); |
8a7e67ec |
318 | break; |
319 | case CTRL_CHECKBOX: |
47c65db4 |
320 | macctrl_checkbox(mcs, window, &cols[colstart], ctrl); |
8a7e67ec |
321 | break; |
322 | case CTRL_BUTTON: |
47c65db4 |
323 | macctrl_button(mcs, window, &cols[colstart], ctrl); |
8a7e67ec |
324 | break; |
56c01970 |
325 | case CTRL_LISTBOX: |
326 | if (ctrl->listbox.height == 0) |
47c65db4 |
327 | macctrl_popup(mcs, window, &cols[colstart], ctrl); |
56c01970 |
328 | break; |
8a7e67ec |
329 | } |
330 | } |
47c65db4 |
331 | for (j = 0; j < ncols; j++) |
332 | if (cols[j].pos.v > curstate->pos.v) |
333 | curstate->pos.v = cols[j].pos.v; |
8a7e67ec |
334 | } |
335 | |
ee10bc56 |
336 | static void macctrl_switchtopanel(struct macctrls *mcs, unsigned int which) |
337 | { |
338 | unsigned int i, j; |
339 | union macctrl *mc; |
340 | |
0a33efe1 |
341 | #define hideshow(c) do { \ |
342 | if (i == which) ShowControl(c); else HideControl(c); \ |
343 | } while (0) |
344 | |
345 | mcs->curpanel = which; |
ee10bc56 |
346 | /* Panel 0 is special and always visible. */ |
347 | for (i = 1; i < mcs->npanels; i++) |
a460b361 |
348 | for (mc = mcs->panels[i]; mc != NULL; mc = mc->generic.next) { |
349 | #if !TARGET_API_MAC_CARBON |
350 | if (mcs->focus == mc) |
351 | macctrl_setfocus(mcs, NULL); |
352 | #endif |
ee10bc56 |
353 | switch (mc->generic.type) { |
354 | case MACCTRL_TEXT: |
0a33efe1 |
355 | hideshow(mc->text.tbctrl); |
ee10bc56 |
356 | break; |
1f1ec0e5 |
357 | case MACCTRL_EDITBOX: |
358 | hideshow(mc->editbox.tbctrl); |
0b89e7b2 |
359 | if (mc->editbox.tblabel != NULL) |
360 | hideshow(mc->editbox.tblabel); |
1f1ec0e5 |
361 | break; |
ee10bc56 |
362 | case MACCTRL_RADIO: |
363 | for (j = 0; j < mc->generic.ctrl->radio.nbuttons; j++) |
0a33efe1 |
364 | hideshow(mc->radio.tbctrls[j]); |
0b89e7b2 |
365 | if (mc->radio.tblabel != NULL) |
366 | hideshow(mc->radio.tblabel); |
ee10bc56 |
367 | break; |
368 | case MACCTRL_CHECKBOX: |
0a33efe1 |
369 | hideshow(mc->checkbox.tbctrl); |
ee10bc56 |
370 | break; |
371 | case MACCTRL_BUTTON: |
0a33efe1 |
372 | hideshow(mc->button.tbctrl); |
373 | break; |
374 | case MACCTRL_POPUP: |
375 | hideshow(mc->popup.tbctrl); |
ee10bc56 |
376 | break; |
ee10bc56 |
377 | } |
a460b361 |
378 | } |
379 | } |
380 | |
381 | #if !TARGET_API_MAC_CARBON |
382 | /* |
383 | * System 7 focus manipulation |
384 | */ |
385 | static void macctrl_defocus(union macctrl *mc) |
386 | { |
387 | |
388 | assert(mac_gestalts.apprvers < 0x100); |
389 | switch (mc->generic.type) { |
390 | case MACCTRL_EDITBOX: |
391 | TEDeactivate((TEHandle)(*mc->editbox.tbctrl)->contrlData); |
392 | break; |
393 | } |
394 | } |
395 | |
396 | static void macctrl_enfocus(union macctrl *mc) |
397 | { |
398 | |
399 | assert(mac_gestalts.apprvers < 0x100); |
400 | switch (mc->generic.type) { |
401 | case MACCTRL_EDITBOX: |
402 | TEActivate((TEHandle)(*mc->editbox.tbctrl)->contrlData); |
403 | break; |
404 | } |
ee10bc56 |
405 | } |
406 | |
a460b361 |
407 | static void macctrl_setfocus(struct macctrls *mcs, union macctrl *mc) |
408 | { |
409 | |
410 | if (mcs->focus != NULL) |
411 | macctrl_defocus(mcs->focus); |
412 | mcs->focus = mc; |
413 | if (mc != NULL) |
414 | macctrl_enfocus(mc); |
415 | } |
416 | #endif |
417 | |
8a7e67ec |
418 | static void macctrl_text(struct macctrls *mcs, WindowPtr window, |
419 | struct mac_layoutstate *curstate, |
420 | union control *ctrl) |
421 | { |
34773273 |
422 | union macctrl *mc = snew(union macctrl); |
8a7e67ec |
423 | Rect bounds; |
f28d33e8 |
424 | SInt16 height; |
8a7e67ec |
425 | |
0b89e7b2 |
426 | assert(ctrl->text.label != NULL); |
8a7e67ec |
427 | fprintf(stderr, " label = %s\n", ctrl->text.label); |
428 | mc->generic.type = MACCTRL_TEXT; |
429 | mc->generic.ctrl = ctrl; |
1f1ec0e5 |
430 | mc->generic.privdata = NULL; |
8a7e67ec |
431 | bounds.left = curstate->pos.h; |
432 | bounds.right = bounds.left + curstate->width; |
433 | bounds.top = curstate->pos.v; |
434 | bounds.bottom = bounds.top + 16; |
435 | if (mac_gestalts.apprvers >= 0x100) { |
8a7e67ec |
436 | Size olen; |
437 | |
438 | mc->text.tbctrl = NewControl(window, &bounds, NULL, TRUE, 0, 0, 0, |
439 | kControlStaticTextProc, (long)mc); |
440 | SetControlData(mc->text.tbctrl, kControlEntireControl, |
441 | kControlStaticTextTextTag, |
442 | strlen(ctrl->text.label), ctrl->text.label); |
443 | GetControlData(mc->text.tbctrl, kControlEntireControl, |
444 | kControlStaticTextTextHeightTag, |
445 | sizeof(height), &height, &olen); |
f28d33e8 |
446 | } |
447 | #if !TARGET_API_MAC_CARBON |
448 | else { |
449 | TEHandle te; |
fa4942e7 |
450 | |
f28d33e8 |
451 | mc->text.tbctrl = NewControl(window, &bounds, NULL, TRUE, 0, 0, 0, |
fa4942e7 |
452 | SYS7_TEXT_PROC, (long)mc); |
f28d33e8 |
453 | te = (TEHandle)(*mc->text.tbctrl)->contrlData; |
454 | TESetText(ctrl->text.label, strlen(ctrl->text.label), te); |
455 | height = TEGetHeight(1, (*te)->nLines, te); |
8a7e67ec |
456 | } |
f28d33e8 |
457 | #endif |
458 | fprintf(stderr, " height = %d\n", height); |
459 | SizeControl(mc->text.tbctrl, curstate->width, height); |
460 | curstate->pos.v += height + 6; |
8a7e67ec |
461 | add234(mcs->byctrl, mc); |
ee10bc56 |
462 | mc->generic.next = mcs->panels[curstate->panelnum]; |
463 | mcs->panels[curstate->panelnum] = mc; |
8a7e67ec |
464 | } |
465 | |
1f1ec0e5 |
466 | static void macctrl_editbox(struct macctrls *mcs, WindowPtr window, |
467 | struct mac_layoutstate *curstate, |
468 | union control *ctrl) |
469 | { |
34773273 |
470 | union macctrl *mc = snew(union macctrl); |
cd3e71e8 |
471 | Rect lbounds, bounds; |
1f1ec0e5 |
472 | |
0b89e7b2 |
473 | if (ctrl->editbox.label != NULL) |
474 | fprintf(stderr, " label = %s\n", ctrl->editbox.label); |
1f1ec0e5 |
475 | fprintf(stderr, " percentwidth = %d\n", ctrl->editbox.percentwidth); |
476 | if (ctrl->editbox.password) fprintf(stderr, " password\n"); |
477 | if (ctrl->editbox.has_list) fprintf(stderr, " has list\n"); |
478 | mc->generic.type = MACCTRL_EDITBOX; |
479 | mc->generic.ctrl = ctrl; |
480 | mc->generic.privdata = NULL; |
cd3e71e8 |
481 | lbounds.left = curstate->pos.h; |
482 | lbounds.top = curstate->pos.v; |
483 | if (ctrl->editbox.percentwidth == 100) { |
0b89e7b2 |
484 | if (ctrl->editbox.label != NULL) { |
485 | lbounds.right = lbounds.left + curstate->width; |
486 | lbounds.bottom = lbounds.top + 16; |
487 | curstate->pos.v += 18; |
488 | } |
cd3e71e8 |
489 | bounds.left = curstate->pos.h; |
490 | bounds.right = bounds.left + curstate->width; |
cd3e71e8 |
491 | } else { |
492 | lbounds.right = lbounds.left + |
493 | curstate->width * (100 - ctrl->editbox.percentwidth) / 100; |
494 | lbounds.bottom = lbounds.top + 22; |
495 | bounds.left = lbounds.right; |
496 | bounds.right = lbounds.left + curstate->width; |
497 | } |
0e9ce565 |
498 | bounds.top = curstate->pos.v; |
499 | bounds.bottom = bounds.top + 22; |
1f1ec0e5 |
500 | if (mac_gestalts.apprvers >= 0x100) { |
0b89e7b2 |
501 | if (ctrl->editbox.label == NULL) |
502 | mc->editbox.tblabel = NULL; |
503 | else { |
504 | mc->editbox.tblabel = NewControl(window, &lbounds, NULL, TRUE, |
505 | 0, 0, 0, kControlStaticTextProc, |
506 | (long)mc); |
507 | SetControlData(mc->editbox.tblabel, kControlEntireControl, |
508 | kControlStaticTextTextTag, |
509 | strlen(ctrl->editbox.label), ctrl->editbox.label); |
510 | } |
95b1a3e4 |
511 | InsetRect(&bounds, 3, 3); |
cd3e71e8 |
512 | mc->editbox.tbctrl = NewControl(window, &bounds, NULL, TRUE, 0, 0, 0, |
513 | ctrl->editbox.password ? |
514 | kControlEditTextPasswordProc : |
515 | kControlEditTextProc, (long)mc); |
f28d33e8 |
516 | } |
517 | #if !TARGET_API_MAC_CARBON |
518 | else { |
0b89e7b2 |
519 | if (ctrl->editbox.label == NULL) |
520 | mc->editbox.tblabel = NULL; |
521 | else { |
522 | mc->editbox.tblabel = NewControl(window, &lbounds, NULL, TRUE, |
523 | 0, 0, 0, SYS7_TEXT_PROC, |
524 | (long)mc); |
525 | TESetText(ctrl->editbox.label, strlen(ctrl->editbox.label), |
526 | (TEHandle)(*mc->editbox.tblabel)->contrlData); |
527 | } |
cd3e71e8 |
528 | mc->editbox.tbctrl = NewControl(window, &bounds, NULL, TRUE, 0, 0, 0, |
529 | SYS7_EDITBOX_PROC, (long)mc); |
1f1ec0e5 |
530 | } |
f28d33e8 |
531 | #endif |
0e9ce565 |
532 | curstate->pos.v += 28; |
533 | add234(mcs->byctrl, mc); |
534 | mc->generic.next = mcs->panels[curstate->panelnum]; |
535 | mcs->panels[curstate->panelnum] = mc; |
536 | ctrlevent(mcs, mc, EVENT_REFRESH); |
1f1ec0e5 |
537 | } |
538 | |
0e9ce565 |
539 | #if !TARGET_API_MAC_CARBON |
540 | static pascal SInt32 macctrl_sys7_editbox_cdef(SInt16 variant, |
541 | ControlRef control, |
542 | ControlDefProcMessage msg, |
543 | SInt32 param) |
544 | { |
545 | RgnHandle rgn; |
546 | Rect rect; |
547 | TEHandle te; |
548 | long ssfs; |
a460b361 |
549 | Point mouse; |
0e9ce565 |
550 | |
551 | switch (msg) { |
552 | case initCntl: |
553 | rect = (*control)->contrlRect; |
f28d33e8 |
554 | if (variant == SYS7_EDITBOX_VARIANT) |
555 | InsetRect(&rect, 3, 3); /* 2 if it's 20 pixels high */ |
0e9ce565 |
556 | te = TENew(&rect, &rect); |
557 | ssfs = GetScriptVariable(smSystemScript, smScriptSysFondSize); |
558 | (*te)->txSize = LoWord(ssfs); |
559 | (*te)->txFont = HiWord(ssfs); |
560 | (*control)->contrlData = (Handle)te; |
561 | return noErr; |
562 | case dispCntl: |
563 | TEDispose((TEHandle)(*control)->contrlData); |
564 | return 0; |
565 | case drawCntl: |
566 | if ((*control)->contrlVis) { |
567 | rect = (*control)->contrlRect; |
f28d33e8 |
568 | if (variant == SYS7_EDITBOX_VARIANT) { |
569 | PenNormal(); |
570 | FrameRect(&rect); |
571 | InsetRect(&rect, 3, 3); |
572 | } |
573 | (*(TEHandle)(*control)->contrlData)->viewRect = rect; |
0e9ce565 |
574 | TEUpdate(&rect, (TEHandle)(*control)->contrlData); |
575 | } |
576 | return 0; |
a460b361 |
577 | case testCntl: |
f28d33e8 |
578 | if (variant == SYS7_TEXT_VARIANT) |
579 | return kControlNoPart; |
a460b361 |
580 | mouse.h = LoWord(param); |
581 | mouse.v = HiWord(param); |
f28d33e8 |
582 | rect = (*control)->contrlRect; |
583 | InsetRect(&rect, 3, 3); |
584 | return PtInRect(mouse, &rect) ? kControlEditTextPart : kControlNoPart; |
0e9ce565 |
585 | case calcCRgns: |
586 | if (param & (1 << 31)) { |
587 | param &= ~(1 << 31); |
588 | goto calcthumbrgn; |
589 | } |
590 | /* FALLTHROUGH */ |
591 | case calcCntlRgn: |
592 | rgn = (RgnHandle)param; |
593 | RectRgn(rgn, &(*control)->contrlRect); |
594 | return 0; |
595 | case calcThumbRgn: |
596 | calcthumbrgn: |
597 | rgn = (RgnHandle)param; |
598 | SetEmptyRgn(rgn); |
599 | return 0; |
600 | } |
601 | |
602 | return 0; |
603 | } |
604 | #endif |
605 | |
8a7e67ec |
606 | static void macctrl_radio(struct macctrls *mcs, WindowPtr window, |
607 | struct mac_layoutstate *curstate, |
608 | union control *ctrl) |
609 | { |
34773273 |
610 | union macctrl *mc = snew(union macctrl); |
8a7e67ec |
611 | Rect bounds; |
612 | Str255 title; |
613 | unsigned int i, colwidth; |
614 | |
0b89e7b2 |
615 | if (ctrl->radio.label != NULL) |
616 | fprintf(stderr, " label = %s\n", ctrl->radio.label); |
8a7e67ec |
617 | mc->generic.type = MACCTRL_RADIO; |
618 | mc->generic.ctrl = ctrl; |
1f1ec0e5 |
619 | mc->generic.privdata = NULL; |
34773273 |
620 | mc->radio.tbctrls = snewn(ctrl->radio.nbuttons, ControlRef); |
8a7e67ec |
621 | colwidth = (curstate->width + 13) / ctrl->radio.ncolumns; |
cd3e71e8 |
622 | bounds.top = curstate->pos.v; |
623 | bounds.bottom = bounds.top + 16; |
624 | bounds.left = curstate->pos.h; |
625 | bounds.right = bounds.left + curstate->width; |
0b89e7b2 |
626 | if (ctrl->radio.label == NULL) |
627 | mc->radio.tblabel = NULL; |
f28d33e8 |
628 | else { |
0b89e7b2 |
629 | if (mac_gestalts.apprvers >= 0x100) { |
630 | mc->radio.tblabel = NewControl(window, &bounds, NULL, TRUE, |
631 | 0, 0, 0, kControlStaticTextProc, |
632 | (long)mc); |
633 | SetControlData(mc->radio.tblabel, kControlEntireControl, |
634 | kControlStaticTextTextTag, |
635 | strlen(ctrl->radio.label), ctrl->radio.label); |
636 | } |
637 | #if !TARGET_API_MAC_CARBON |
638 | else { |
639 | mc->radio.tblabel = NewControl(window, &bounds, NULL, TRUE, |
640 | 0, 0, 0, SYS7_TEXT_PROC, (long)mc); |
641 | TESetText(ctrl->radio.label, strlen(ctrl->radio.label), |
642 | (TEHandle)(*mc->radio.tblabel)->contrlData); |
643 | } |
f28d33e8 |
644 | #endif |
0b89e7b2 |
645 | curstate->pos.v += 18; |
646 | } |
8a7e67ec |
647 | for (i = 0; i < ctrl->radio.nbuttons; i++) { |
648 | fprintf(stderr, " button = %s\n", ctrl->radio.buttons[i]); |
35790008 |
649 | bounds.top = curstate->pos.v - 2; |
650 | bounds.bottom = bounds.top + 18; |
8a7e67ec |
651 | bounds.left = curstate->pos.h + colwidth * (i % ctrl->radio.ncolumns); |
652 | if (i == ctrl->radio.nbuttons - 1 || |
653 | i % ctrl->radio.ncolumns == ctrl->radio.ncolumns - 1) { |
654 | bounds.right = curstate->pos.h + curstate->width; |
35790008 |
655 | curstate->pos.v += 18; |
8a7e67ec |
656 | } else |
657 | bounds.right = bounds.left + colwidth - 13; |
658 | c2pstrcpy(title, ctrl->radio.buttons[i]); |
659 | mc->radio.tbctrls[i] = NewControl(window, &bounds, title, TRUE, |
660 | 0, 0, 1, radioButProc, (long)mc); |
661 | } |
35790008 |
662 | curstate->pos.v += 4; |
8a7e67ec |
663 | add234(mcs->byctrl, mc); |
ee10bc56 |
664 | mc->generic.next = mcs->panels[curstate->panelnum]; |
665 | mcs->panels[curstate->panelnum] = mc; |
8a7e67ec |
666 | ctrlevent(mcs, mc, EVENT_REFRESH); |
667 | } |
668 | |
669 | static void macctrl_checkbox(struct macctrls *mcs, WindowPtr window, |
670 | struct mac_layoutstate *curstate, |
671 | union control *ctrl) |
672 | { |
34773273 |
673 | union macctrl *mc = snew(union macctrl); |
8a7e67ec |
674 | Rect bounds; |
675 | Str255 title; |
676 | |
0b89e7b2 |
677 | assert(ctrl->checkbox.label != NULL); |
8a7e67ec |
678 | fprintf(stderr, " label = %s\n", ctrl->checkbox.label); |
679 | mc->generic.type = MACCTRL_CHECKBOX; |
680 | mc->generic.ctrl = ctrl; |
1f1ec0e5 |
681 | mc->generic.privdata = NULL; |
8a7e67ec |
682 | bounds.left = curstate->pos.h; |
683 | bounds.right = bounds.left + curstate->width; |
684 | bounds.top = curstate->pos.v; |
685 | bounds.bottom = bounds.top + 16; |
686 | c2pstrcpy(title, ctrl->checkbox.label); |
687 | mc->checkbox.tbctrl = NewControl(window, &bounds, title, TRUE, 0, 0, 1, |
688 | checkBoxProc, (long)mc); |
689 | add234(mcs->byctrl, mc); |
690 | curstate->pos.v += 22; |
ee10bc56 |
691 | mc->generic.next = mcs->panels[curstate->panelnum]; |
692 | mcs->panels[curstate->panelnum] = mc; |
8a7e67ec |
693 | ctrlevent(mcs, mc, EVENT_REFRESH); |
694 | } |
695 | |
696 | static void macctrl_button(struct macctrls *mcs, WindowPtr window, |
697 | struct mac_layoutstate *curstate, |
698 | union control *ctrl) |
699 | { |
34773273 |
700 | union macctrl *mc = snew(union macctrl); |
8a7e67ec |
701 | Rect bounds; |
702 | Str255 title; |
703 | |
0b89e7b2 |
704 | assert(ctrl->button.label != NULL); |
8a7e67ec |
705 | fprintf(stderr, " label = %s\n", ctrl->button.label); |
706 | if (ctrl->button.isdefault) |
707 | fprintf(stderr, " is default\n"); |
708 | mc->generic.type = MACCTRL_BUTTON; |
709 | mc->generic.ctrl = ctrl; |
1f1ec0e5 |
710 | mc->generic.privdata = NULL; |
8a7e67ec |
711 | bounds.left = curstate->pos.h; |
47c65db4 |
712 | bounds.right = bounds.left + curstate->width; |
8a7e67ec |
713 | bounds.top = curstate->pos.v; |
714 | bounds.bottom = bounds.top + 20; |
715 | c2pstrcpy(title, ctrl->button.label); |
716 | mc->button.tbctrl = NewControl(window, &bounds, title, TRUE, 0, 0, 1, |
717 | pushButProc, (long)mc); |
457f0b8f |
718 | mc->button.tbring = NULL; |
8a7e67ec |
719 | if (mac_gestalts.apprvers >= 0x100) { |
720 | Boolean isdefault = ctrl->button.isdefault; |
721 | |
722 | SetControlData(mc->button.tbctrl, kControlEntireControl, |
723 | kControlPushButtonDefaultTag, |
724 | sizeof(isdefault), &isdefault); |
5537f572 |
725 | } else if (ctrl->button.isdefault) { |
726 | InsetRect(&bounds, -4, -4); |
457f0b8f |
727 | mc->button.tbring = NewControl(window, &bounds, title, TRUE, 0, 0, 1, |
728 | SYS7_DEFAULT_PROC, (long)mc); |
8a7e67ec |
729 | } |
855d05c4 |
730 | if (mac_gestalts.apprvers >= 0x110) { |
731 | Boolean iscancel = ctrl->button.iscancel; |
732 | |
733 | SetControlData(mc->button.tbctrl, kControlEntireControl, |
734 | kControlPushButtonCancelTag, |
735 | sizeof(iscancel), &iscancel); |
736 | } |
135c0f1a |
737 | if (ctrl->button.isdefault) |
738 | mcs->defbutton = mc; |
739 | if (ctrl->button.iscancel) |
740 | mcs->canbutton = mc; |
8a7e67ec |
741 | add234(mcs->byctrl, mc); |
ee10bc56 |
742 | mc->generic.next = mcs->panels[curstate->panelnum]; |
743 | mcs->panels[curstate->panelnum] = mc; |
8a7e67ec |
744 | curstate->pos.v += 26; |
745 | } |
746 | |
5537f572 |
747 | #if !TARGET_API_MAC_CARBON |
748 | static pascal SInt32 macctrl_sys7_default_cdef(SInt16 variant, |
749 | ControlRef control, |
750 | ControlDefProcMessage msg, |
751 | SInt32 param) |
752 | { |
753 | RgnHandle rgn; |
754 | Rect rect; |
755 | int oval; |
457f0b8f |
756 | PenState savestate; |
5537f572 |
757 | |
758 | switch (msg) { |
759 | case drawCntl: |
760 | if ((*control)->contrlVis) { |
761 | rect = (*control)->contrlRect; |
457f0b8f |
762 | GetPenState(&savestate); |
5537f572 |
763 | PenNormal(); |
764 | PenSize(3, 3); |
457f0b8f |
765 | if ((*control)->contrlHilite == kControlInactivePart) |
766 | PenPat(&qd.gray); |
5537f572 |
767 | oval = (rect.bottom - rect.top) / 2 + 2; |
768 | FrameRoundRect(&rect, oval, oval); |
457f0b8f |
769 | SetPenState(&savestate); |
5537f572 |
770 | } |
771 | return 0; |
772 | case calcCRgns: |
773 | if (param & (1 << 31)) { |
774 | param &= ~(1 << 31); |
775 | goto calcthumbrgn; |
776 | } |
777 | /* FALLTHROUGH */ |
778 | case calcCntlRgn: |
779 | rgn = (RgnHandle)param; |
780 | RectRgn(rgn, &(*control)->contrlRect); |
781 | return 0; |
782 | case calcThumbRgn: |
783 | calcthumbrgn: |
784 | rgn = (RgnHandle)param; |
785 | SetEmptyRgn(rgn); |
786 | return 0; |
787 | } |
788 | |
789 | return 0; |
790 | } |
791 | #endif |
792 | |
56c01970 |
793 | static void macctrl_popup(struct macctrls *mcs, WindowPtr window, |
794 | struct mac_layoutstate *curstate, |
795 | union control *ctrl) |
796 | { |
34773273 |
797 | union macctrl *mc = snew(union macctrl); |
56c01970 |
798 | Rect bounds; |
799 | Str255 title; |
800 | unsigned int labelwidth; |
0a33efe1 |
801 | static int nextmenuid = MENU_MIN; |
56c01970 |
802 | int menuid; |
803 | MenuRef menu; |
804 | |
805 | /* |
806 | * <http://developer.apple.com/qa/tb/tb42.html> explains how to |
807 | * create a popup menu with dynamic content. |
808 | */ |
809 | assert(ctrl->listbox.height == 0); |
810 | assert(!ctrl->listbox.draglist); |
811 | assert(!ctrl->listbox.multisel); |
812 | |
0b89e7b2 |
813 | if (ctrl->listbox.label != NULL) |
814 | fprintf(stderr, " label = %s\n", ctrl->listbox.label); |
56c01970 |
815 | fprintf(stderr, " percentwidth = %d\n", ctrl->listbox.percentwidth); |
816 | |
817 | mc->generic.type = MACCTRL_POPUP; |
818 | mc->generic.ctrl = ctrl; |
1f1ec0e5 |
819 | mc->generic.privdata = NULL; |
0b89e7b2 |
820 | c2pstrcpy(title, ctrl->button.label == NULL ? "" : ctrl->button.label); |
56c01970 |
821 | |
822 | /* Find a spare menu ID and create the menu */ |
823 | while (GetMenuHandle(nextmenuid) != NULL) |
824 | if (++nextmenuid >= MENU_MAX) nextmenuid = MENU_MIN; |
825 | menuid = nextmenuid++; |
826 | menu = NewMenu(menuid, "\pdummy"); |
827 | if (menu == NULL) return; |
828 | mc->popup.menu = menu; |
829 | mc->popup.menuid = menuid; |
830 | InsertMenu(menu, kInsertHierarchicalMenu); |
831 | |
832 | /* The menu starts off empty */ |
833 | mc->popup.nids = 0; |
834 | mc->popup.ids = NULL; |
835 | |
836 | bounds.left = curstate->pos.h; |
837 | bounds.right = bounds.left + curstate->width; |
838 | bounds.top = curstate->pos.v; |
839 | bounds.bottom = bounds.top + 20; |
840 | /* XXX handle percentwidth == 100 */ |
841 | labelwidth = curstate->width * (100 - ctrl->listbox.percentwidth) / 100; |
842 | mc->popup.tbctrl = NewControl(window, &bounds, title, TRUE, |
843 | popupTitleLeftJust, menuid, labelwidth, |
844 | popupMenuProc + popupFixedWidth, (long)mc); |
845 | add234(mcs->byctrl, mc); |
846 | curstate->pos.v += 26; |
847 | mc->generic.next = mcs->panels[curstate->panelnum]; |
848 | mcs->panels[curstate->panelnum] = mc; |
849 | ctrlevent(mcs, mc, EVENT_REFRESH); |
850 | } |
851 | |
8a7e67ec |
852 | |
853 | void macctrl_activate(WindowPtr window, EventRecord *event) |
854 | { |
0a33efe1 |
855 | struct macctrls *mcs = mac_winctrls(window); |
8a7e67ec |
856 | Boolean active = (event->modifiers & activeFlag) != 0; |
857 | GrafPtr saveport; |
0a33efe1 |
858 | int i, j; |
859 | ControlPartCode state; |
860 | union macctrl *mc; |
8a7e67ec |
861 | |
862 | GetPort(&saveport); |
863 | SetPort((GrafPtr)GetWindowPort(window)); |
78f015b8 |
864 | if (mac_gestalts.apprvers >= 0x100) |
8a7e67ec |
865 | SetThemeWindowBackground(window, active ? |
866 | kThemeBrushModelessDialogBackgroundActive : |
867 | kThemeBrushModelessDialogBackgroundInactive, |
868 | TRUE); |
0a33efe1 |
869 | state = active ? kControlNoPart : kControlInactivePart; |
870 | for (i = 0; i <= mcs->curpanel; i += mcs->curpanel) |
f28d33e8 |
871 | for (mc = mcs->panels[i]; mc != NULL; mc = mc->generic.next) { |
0a33efe1 |
872 | switch (mc->generic.type) { |
873 | case MACCTRL_TEXT: |
874 | HiliteControl(mc->text.tbctrl, state); |
875 | break; |
1f1ec0e5 |
876 | case MACCTRL_EDITBOX: |
877 | HiliteControl(mc->editbox.tbctrl, state); |
0b89e7b2 |
878 | if (mc->editbox.tblabel != NULL) |
879 | HiliteControl(mc->editbox.tblabel, state); |
1f1ec0e5 |
880 | break; |
0a33efe1 |
881 | case MACCTRL_RADIO: |
882 | for (j = 0; j < mc->generic.ctrl->radio.nbuttons; j++) |
883 | HiliteControl(mc->radio.tbctrls[j], state); |
0b89e7b2 |
884 | if (mc->radio.tblabel != NULL) |
885 | HiliteControl(mc->radio.tblabel, state); |
0a33efe1 |
886 | break; |
887 | case MACCTRL_CHECKBOX: |
888 | HiliteControl(mc->checkbox.tbctrl, state); |
889 | break; |
890 | case MACCTRL_BUTTON: |
891 | HiliteControl(mc->button.tbctrl, state); |
457f0b8f |
892 | if (mc->button.tbring != NULL) |
893 | HiliteControl(mc->button.tbring, state); |
0a33efe1 |
894 | break; |
895 | case MACCTRL_POPUP: |
896 | HiliteControl(mc->popup.tbctrl, state); |
897 | break; |
898 | } |
f28d33e8 |
899 | #if !TARGET_API_MAC_CARBON |
900 | if (mcs->focus == mc) { |
901 | if (active) |
902 | macctrl_enfocus(mc); |
903 | else |
904 | macctrl_defocus(mc); |
905 | } |
906 | #endif |
907 | } |
8a7e67ec |
908 | SetPort(saveport); |
909 | } |
910 | |
911 | void macctrl_click(WindowPtr window, EventRecord *event) |
912 | { |
913 | Point mouse; |
914 | ControlHandle control; |
1f1ec0e5 |
915 | int part, trackresult; |
8a7e67ec |
916 | GrafPtr saveport; |
917 | union macctrl *mc; |
918 | struct macctrls *mcs = mac_winctrls(window); |
919 | int i; |
1f1ec0e5 |
920 | UInt32 features; |
8a7e67ec |
921 | |
922 | GetPort(&saveport); |
923 | SetPort((GrafPtr)GetWindowPort(window)); |
924 | mouse = event->where; |
925 | GlobalToLocal(&mouse); |
926 | part = FindControl(mouse, window, &control); |
56c01970 |
927 | if (control != NULL) { |
a460b361 |
928 | mc = (union macctrl *)GetControlReference(control); |
1f1ec0e5 |
929 | if (mac_gestalts.apprvers >= 0x100) { |
930 | if (GetControlFeatures(control, &features) == noErr && |
931 | (features & kControlSupportsFocus) && |
932 | (features & kControlGetsFocusOnClick)) |
933 | SetKeyboardFocus(window, control, part); |
934 | trackresult = HandleControlClick(control, mouse, event->modifiers, |
935 | (ControlActionUPP)-1); |
a460b361 |
936 | } else { |
937 | #if !TARGET_API_MAC_CARBON |
938 | if (mc->generic.type == MACCTRL_EDITBOX && |
939 | control == mc->editbox.tbctrl) { |
940 | TEHandle te = (TEHandle)(*control)->contrlData; |
941 | |
942 | macctrl_setfocus(mcs, mc); |
943 | TEClick(mouse, !!(event->modifiers & shiftKey), te); |
944 | goto done; |
945 | } |
946 | #endif |
1f1ec0e5 |
947 | trackresult = TrackControl(control, mouse, (ControlActionUPP)-1); |
a460b361 |
948 | } |
56c01970 |
949 | switch (mc->generic.type) { |
56c01970 |
950 | case MACCTRL_RADIO: |
1f1ec0e5 |
951 | if (trackresult != 0) { |
56c01970 |
952 | for (i = 0; i < mc->generic.ctrl->radio.nbuttons; i++) |
8a7e67ec |
953 | if (mc->radio.tbctrls[i] == control) |
954 | SetControlValue(mc->radio.tbctrls[i], |
955 | kControlRadioButtonCheckedValue); |
956 | else |
957 | SetControlValue(mc->radio.tbctrls[i], |
958 | kControlRadioButtonUncheckedValue); |
8a7e67ec |
959 | ctrlevent(mcs, mc, EVENT_VALCHANGE); |
56c01970 |
960 | } |
961 | break; |
962 | case MACCTRL_CHECKBOX: |
1f1ec0e5 |
963 | if (trackresult != 0) { |
8a7e67ec |
964 | SetControlValue(control, !GetControlValue(control)); |
965 | ctrlevent(mcs, mc, EVENT_VALCHANGE); |
8a7e67ec |
966 | } |
56c01970 |
967 | break; |
968 | case MACCTRL_BUTTON: |
1f1ec0e5 |
969 | if (trackresult != 0) |
56c01970 |
970 | ctrlevent(mcs, mc, EVENT_ACTION); |
971 | break; |
1f1ec0e5 |
972 | case MACCTRL_POPUP: |
973 | ctrlevent(mcs, mc, EVENT_SELCHANGE); |
974 | break; |
8a7e67ec |
975 | } |
56c01970 |
976 | } |
a460b361 |
977 | done: |
8a7e67ec |
978 | SetPort(saveport); |
979 | } |
980 | |
1f1ec0e5 |
981 | void macctrl_key(WindowPtr window, EventRecord *event) |
982 | { |
983 | ControlRef control; |
984 | struct macctrls *mcs = mac_winctrls(window); |
985 | union macctrl *mc; |
135c0f1a |
986 | unsigned long dummy; |
987 | |
988 | switch (event->message & charCodeMask) { |
989 | case kEnterCharCode: |
990 | case kReturnCharCode: |
991 | if (mcs->defbutton != NULL) { |
992 | assert(mcs->defbutton->generic.type == MACCTRL_BUTTON); |
993 | HiliteControl(mcs->defbutton->button.tbctrl, kControlButtonPart); |
994 | /* |
995 | * I'd like to delay unhilighting the button until after |
996 | * the event has been processed, but by them the entire |
997 | * dialgue box might have been destroyed. |
998 | */ |
999 | Delay(6, &dummy); |
1000 | HiliteControl(mcs->defbutton->button.tbctrl, kControlNoPart); |
1001 | ctrlevent(mcs, mcs->defbutton, EVENT_ACTION); |
1002 | } |
1003 | return; |
1004 | case kEscapeCharCode: |
1005 | if (mcs->canbutton != NULL) { |
1006 | assert(mcs->canbutton->generic.type == MACCTRL_BUTTON); |
1007 | HiliteControl(mcs->canbutton->button.tbctrl, kControlButtonPart); |
1008 | Delay(6, &dummy); |
1009 | HiliteControl(mcs->defbutton->button.tbctrl, kControlNoPart); |
1010 | ctrlevent(mcs, mcs->canbutton, EVENT_ACTION); |
1011 | } |
1012 | return; |
1013 | } |
2dfd068b |
1014 | if (mac_gestalts.apprvers >= 0x100) { |
1015 | if (GetKeyboardFocus(window, &control) == noErr && control != NULL) { |
1016 | HandleControlKey(control, (event->message & keyCodeMask) >> 8, |
1017 | event->message & charCodeMask, event->modifiers); |
1018 | mc = (union macctrl *)GetControlReference(control); |
1019 | ctrlevent(mcs, mc, EVENT_VALCHANGE); |
1020 | } |
47c65db4 |
1021 | } |
1022 | #if !TARGET_API_MAC_CARBON |
1023 | else { |
1024 | TEHandle te; |
1025 | |
2dfd068b |
1026 | if (mcs->focus != NULL) { |
91156e95 |
1027 | mc = mcs->focus; |
1028 | switch (mc->generic.type) { |
2dfd068b |
1029 | case MACCTRL_EDITBOX: |
91156e95 |
1030 | te = (TEHandle)(*mc->editbox.tbctrl)->contrlData; |
2dfd068b |
1031 | TEKey(event->message & charCodeMask, te); |
91156e95 |
1032 | ctrlevent(mcs, mc, EVENT_VALCHANGE); |
2dfd068b |
1033 | break; |
1034 | } |
1035 | } |
1f1ec0e5 |
1036 | } |
47c65db4 |
1037 | #endif |
1f1ec0e5 |
1038 | } |
1039 | |
8a7e67ec |
1040 | void macctrl_update(WindowPtr window) |
1041 | { |
1042 | #if TARGET_API_MAC_CARBON |
1043 | RgnHandle visrgn; |
1044 | #endif |
1045 | Rect rect; |
1046 | GrafPtr saveport; |
1047 | |
1048 | BeginUpdate(window); |
1049 | GetPort(&saveport); |
1050 | SetPort((GrafPtr)GetWindowPort(window)); |
1051 | if (mac_gestalts.apprvers >= 0x101) { |
1052 | #if TARGET_API_MAC_CARBON |
1053 | GetPortBounds(GetWindowPort(window), &rect); |
1054 | #else |
1055 | rect = window->portRect; |
1056 | #endif |
1057 | InsetRect(&rect, -1, -1); |
1058 | DrawThemeModelessDialogFrame(&rect, mac_frontwindow() == window ? |
1059 | kThemeStateActive : kThemeStateInactive); |
1060 | } |
1061 | #if TARGET_API_MAC_CARBON |
1062 | visrgn = NewRgn(); |
1063 | GetPortVisibleRegion(GetWindowPort(window), visrgn); |
1064 | UpdateControls(window, visrgn); |
1065 | DisposeRgn(visrgn); |
1066 | #else |
1067 | UpdateControls(window, window->visRgn); |
1068 | #endif |
1069 | SetPort(saveport); |
1070 | EndUpdate(window); |
1071 | } |
1072 | |
1073 | #if TARGET_API_MAC_CARBON |
1074 | #define EnableItem EnableMenuItem |
1075 | #define DisableItem DisableMenuItem |
1076 | #endif |
1077 | void macctrl_adjustmenus(WindowPtr window) |
1078 | { |
1079 | MenuHandle menu; |
1080 | |
1081 | menu = GetMenuHandle(mFile); |
1082 | DisableItem(menu, iSave); /* XXX enable if modified */ |
1083 | EnableItem(menu, iSaveAs); |
1084 | EnableItem(menu, iDuplicate); |
1085 | |
1086 | menu = GetMenuHandle(mEdit); |
1087 | DisableItem(menu, 0); |
1088 | } |
1089 | |
1090 | void macctrl_close(WindowPtr window) |
1091 | { |
1092 | struct macctrls *mcs = mac_winctrls(window); |
1093 | union macctrl *mc; |
1094 | |
56c01970 |
1095 | /* |
1096 | * Mostly, we don't bother disposing of the Toolbox controls, |
1097 | * since that will happen automatically when the window is |
1098 | * disposed of. Popup menus are an exception, because we have to |
1099 | * dispose of the menu ourselves, and doing that while the control |
1100 | * still holds a reference to it seems rude. |
1101 | */ |
8a7e67ec |
1102 | while ((mc = index234(mcs->byctrl, 0)) != NULL) { |
1f1ec0e5 |
1103 | if (mc->generic.privdata != NULL && mc->generic.freeprivdata) |
1104 | sfree(mc->generic.privdata); |
56c01970 |
1105 | switch (mc->generic.type) { |
1106 | case MACCTRL_POPUP: |
1107 | DisposeControl(mc->popup.tbctrl); |
1108 | DeleteMenu(mc->popup.menuid); |
1109 | DisposeMenu(mc->popup.menu); |
1110 | break; |
1111 | } |
8a7e67ec |
1112 | del234(mcs->byctrl, mc); |
1113 | sfree(mc); |
1114 | } |
1115 | |
1116 | freetree234(mcs->byctrl); |
1117 | mcs->byctrl = NULL; |
ee10bc56 |
1118 | sfree(mcs->panels); |
1119 | mcs->panels = NULL; |
8a7e67ec |
1120 | } |
1121 | |
1122 | void dlg_update_start(union control *ctrl, void *dlg) |
1123 | { |
1124 | |
1125 | /* No-op for now */ |
1126 | } |
1127 | |
1128 | void dlg_update_done(union control *ctrl, void *dlg) |
1129 | { |
1130 | |
1131 | /* No-op for now */ |
1132 | } |
1133 | |
1134 | void dlg_set_focus(union control *ctrl, void *dlg) |
1135 | { |
1136 | |
1137 | if (mac_gestalts.apprvers >= 0x100) { |
1138 | /* Use SetKeyboardFocus() */ |
1139 | } else { |
1140 | /* Do our own mucking around */ |
1141 | } |
1142 | } |
1143 | |
0bd8d76d |
1144 | union control *dlg_last_focused(union control *ctrl, void *dlg) |
8a7e67ec |
1145 | { |
1146 | |
1147 | return NULL; |
1148 | } |
1149 | |
1150 | void dlg_beep(void *dlg) |
1151 | { |
1152 | |
1153 | SysBeep(30); |
1154 | } |
1155 | |
1156 | void dlg_error_msg(void *dlg, char *msg) |
1157 | { |
1158 | Str255 pmsg; |
1159 | |
1160 | c2pstrcpy(pmsg, msg); |
1161 | ParamText(pmsg, NULL, NULL, NULL); |
1162 | StopAlert(128, NULL); |
1163 | } |
1164 | |
1165 | void dlg_end(void *dlg, int value) |
1166 | { |
f73f2f31 |
1167 | struct macctrls *mcs = dlg; |
8a7e67ec |
1168 | |
f73f2f31 |
1169 | if (mcs->end != NULL) |
1170 | (*mcs->end)(mcs->window, value); |
8a7e67ec |
1171 | }; |
1172 | |
1173 | void dlg_refresh(union control *ctrl, void *dlg) |
1174 | { |
1f1ec0e5 |
1175 | struct macctrls *mcs = dlg; |
1176 | union macctrl *mc; |
8a7e67ec |
1177 | |
1f1ec0e5 |
1178 | if (ctrl == NULL) |
1179 | return; /* FIXME */ |
1180 | mc = findbyctrl(mcs, ctrl); |
1181 | assert(mc != NULL); |
1182 | ctrlevent(mcs, mc, EVENT_REFRESH); |
8a7e67ec |
1183 | }; |
1184 | |
1185 | void *dlg_get_privdata(union control *ctrl, void *dlg) |
1186 | { |
1f1ec0e5 |
1187 | struct macctrls *mcs = dlg; |
1188 | union macctrl *mc = findbyctrl(mcs, ctrl); |
8a7e67ec |
1189 | |
1f1ec0e5 |
1190 | assert(mc != NULL); |
1191 | return mc->generic.privdata; |
8a7e67ec |
1192 | } |
1193 | |
1194 | void dlg_set_privdata(union control *ctrl, void *dlg, void *ptr) |
1195 | { |
1f1ec0e5 |
1196 | struct macctrls *mcs = dlg; |
1197 | union macctrl *mc = findbyctrl(mcs, ctrl); |
8a7e67ec |
1198 | |
1f1ec0e5 |
1199 | assert(mc != NULL); |
1200 | mc->generic.privdata = ptr; |
1201 | mc->generic.freeprivdata = FALSE; |
8a7e67ec |
1202 | } |
1203 | |
1204 | void *dlg_alloc_privdata(union control *ctrl, void *dlg, size_t size) |
1205 | { |
1f1ec0e5 |
1206 | struct macctrls *mcs = dlg; |
1207 | union macctrl *mc = findbyctrl(mcs, ctrl); |
8a7e67ec |
1208 | |
1f1ec0e5 |
1209 | assert(mc != NULL); |
1210 | mc->generic.privdata = smalloc(size); |
1211 | mc->generic.freeprivdata = TRUE; |
1212 | return mc->generic.privdata; |
8a7e67ec |
1213 | } |
1214 | |
1215 | |
1216 | /* |
1217 | * Radio Button control |
1218 | */ |
1219 | |
1220 | void dlg_radiobutton_set(union control *ctrl, void *dlg, int whichbutton) |
1221 | { |
93ba25f8 |
1222 | struct macctrls *mcs = dlg; |
1223 | union macctrl *mc = findbyctrl(mcs, ctrl); |
8a7e67ec |
1224 | int i; |
1225 | |
93ba25f8 |
1226 | assert(mc != NULL); |
8a7e67ec |
1227 | for (i = 0; i < ctrl->radio.nbuttons; i++) { |
1228 | if (i == whichbutton) |
1229 | SetControlValue(mc->radio.tbctrls[i], |
1230 | kControlRadioButtonCheckedValue); |
1231 | else |
1232 | SetControlValue(mc->radio.tbctrls[i], |
1233 | kControlRadioButtonUncheckedValue); |
1234 | } |
1235 | |
1236 | }; |
1237 | |
1238 | int dlg_radiobutton_get(union control *ctrl, void *dlg) |
1239 | { |
93ba25f8 |
1240 | struct macctrls *mcs = dlg; |
1241 | union macctrl *mc = findbyctrl(mcs, ctrl); |
8a7e67ec |
1242 | int i; |
1243 | |
93ba25f8 |
1244 | assert(mc != NULL); |
8a7e67ec |
1245 | for (i = 0; i < ctrl->radio.nbuttons; i++) { |
1246 | if (GetControlValue(mc->radio.tbctrls[i]) == |
1247 | kControlRadioButtonCheckedValue) |
1248 | return i; |
1249 | } |
1250 | return -1; |
1251 | }; |
1252 | |
1253 | |
1254 | /* |
1255 | * Check Box control |
1256 | */ |
1257 | |
1258 | void dlg_checkbox_set(union control *ctrl, void *dlg, int checked) |
1259 | { |
93ba25f8 |
1260 | struct macctrls *mcs = dlg; |
1261 | union macctrl *mc = findbyctrl(mcs, ctrl); |
8a7e67ec |
1262 | |
93ba25f8 |
1263 | assert(mc != NULL); |
8a7e67ec |
1264 | SetControlValue(mc->checkbox.tbctrl, |
1265 | checked ? kControlCheckBoxCheckedValue : |
1266 | kControlCheckBoxUncheckedValue); |
1267 | } |
1268 | |
1269 | int dlg_checkbox_get(union control *ctrl, void *dlg) |
1270 | { |
93ba25f8 |
1271 | struct macctrls *mcs = dlg; |
1272 | union macctrl *mc = findbyctrl(mcs, ctrl); |
8a7e67ec |
1273 | |
93ba25f8 |
1274 | assert(mc != NULL); |
8a7e67ec |
1275 | return GetControlValue(mc->checkbox.tbctrl); |
1276 | } |
1277 | |
1278 | |
1279 | /* |
1280 | * Edit Box control |
1281 | */ |
1282 | |
1283 | void dlg_editbox_set(union control *ctrl, void *dlg, char const *text) |
1284 | { |
1f1ec0e5 |
1285 | struct macctrls *mcs = dlg; |
1286 | union macctrl *mc = findbyctrl(mcs, ctrl); |
1287 | GrafPtr saveport; |
8a7e67ec |
1288 | |
1f1ec0e5 |
1289 | assert(mc != NULL); |
1290 | assert(mc->generic.type == MACCTRL_EDITBOX); |
0e9ce565 |
1291 | GetPort(&saveport); |
1292 | SetPort((GrafPtr)(GetWindowPort(mcs->window))); |
d9158b5e |
1293 | if (mac_gestalts.apprvers >= 0x100) |
1f1ec0e5 |
1294 | SetControlData(mc->editbox.tbctrl, kControlEntireControl, |
1295 | ctrl->editbox.password ? |
1296 | kControlEditTextPasswordTag : |
1297 | kControlEditTextTextTag, |
1298 | strlen(text), text); |
a460b361 |
1299 | #if !TARGET_API_MAC_CARBON |
d9158b5e |
1300 | else |
0e9ce565 |
1301 | TESetText(text, strlen(text), |
1302 | (TEHandle)(*mc->editbox.tbctrl)->contrlData); |
a460b361 |
1303 | #endif |
d9158b5e |
1304 | DrawOneControl(mc->editbox.tbctrl); |
0e9ce565 |
1305 | SetPort(saveport); |
1306 | } |
8a7e67ec |
1307 | |
1308 | void dlg_editbox_get(union control *ctrl, void *dlg, char *buffer, int length) |
1309 | { |
1f1ec0e5 |
1310 | struct macctrls *mcs = dlg; |
1311 | union macctrl *mc = findbyctrl(mcs, ctrl); |
1312 | Size olen; |
8a7e67ec |
1313 | |
1f1ec0e5 |
1314 | assert(mc != NULL); |
1315 | assert(mc->generic.type == MACCTRL_EDITBOX); |
1316 | if (mac_gestalts.apprvers >= 0x100) { |
1317 | if (GetControlData(mc->editbox.tbctrl, kControlEntireControl, |
1318 | ctrl->editbox.password ? |
1319 | kControlEditTextPasswordTag : |
1320 | kControlEditTextTextTag, |
1321 | length - 1, buffer, &olen) != noErr) |
1322 | olen = 0; |
1323 | if (olen > length - 1) |
d9158b5e |
1324 | olen = length - 1; |
a460b361 |
1325 | } |
1326 | #if !TARGET_API_MAC_CARBON |
1327 | else { |
1328 | TEHandle te = (TEHandle)(*mc->editbox.tbctrl)->contrlData; |
1329 | |
d9158b5e |
1330 | olen = (*te)->teLength; |
1331 | if (olen > length - 1) |
1332 | olen = length - 1; |
1333 | memcpy(buffer, *(*te)->hText, olen); |
1334 | } |
a460b361 |
1335 | #endif |
d9158b5e |
1336 | buffer[olen] = '\0'; |
1f1ec0e5 |
1337 | fprintf(stderr, "dlg_editbox_get: %s\n", buffer); |
d9158b5e |
1338 | } |
8a7e67ec |
1339 | |
1340 | |
1341 | /* |
1342 | * List Box control |
1343 | */ |
1344 | |
56c01970 |
1345 | static void dlg_macpopup_clear(union control *ctrl, void *dlg) |
1346 | { |
1347 | struct macctrls *mcs = dlg; |
1348 | union macctrl *mc = findbyctrl(mcs, ctrl); |
1349 | MenuRef menu = mc->popup.menu; |
1350 | unsigned int i, n; |
1351 | |
1352 | fprintf(stderr, " popup_clear\n"); |
fd703c0a |
1353 | n = CountMenuItems(menu); |
56c01970 |
1354 | for (i = 0; i < n; i++) |
1355 | DeleteMenuItem(menu, n - i); |
1356 | mc->popup.nids = 0; |
1357 | sfree(mc->popup.ids); |
1358 | mc->popup.ids = NULL; |
fd703c0a |
1359 | SetControlMaximum(mc->popup.tbctrl, CountMenuItems(menu)); |
56c01970 |
1360 | } |
1361 | |
8a7e67ec |
1362 | void dlg_listbox_clear(union control *ctrl, void *dlg) |
1363 | { |
1364 | |
56c01970 |
1365 | if (ctrl->listbox.height == 0) |
1366 | dlg_macpopup_clear(ctrl, dlg); |
1367 | } |
1368 | |
1369 | static void dlg_macpopup_del(union control *ctrl, void *dlg, int index) |
1370 | { |
1371 | struct macctrls *mcs = dlg; |
1372 | union macctrl *mc = findbyctrl(mcs, ctrl); |
1373 | MenuRef menu = mc->popup.menu; |
1374 | |
1375 | fprintf(stderr, " popup_del %d\n", index); |
1376 | DeleteMenuItem(menu, index + 1); |
1377 | if (mc->popup.ids != NULL) |
1378 | memcpy(mc->popup.ids + index, mc->popup.ids + index + 1, |
1379 | (mc->popup.nids - index - 1) * sizeof(*mc->popup.ids)); |
fd703c0a |
1380 | SetControlMaximum(mc->popup.tbctrl, CountMenuItems(menu)); |
56c01970 |
1381 | } |
8a7e67ec |
1382 | |
1383 | void dlg_listbox_del(union control *ctrl, void *dlg, int index) |
1384 | { |
1385 | |
56c01970 |
1386 | if (ctrl->listbox.height == 0) |
1387 | dlg_macpopup_del(ctrl, dlg, index); |
1388 | } |
1389 | |
1390 | static void dlg_macpopup_add(union control *ctrl, void *dlg, char const *text) |
1391 | { |
1392 | struct macctrls *mcs = dlg; |
1393 | union macctrl *mc = findbyctrl(mcs, ctrl); |
1394 | MenuRef menu = mc->popup.menu; |
1395 | Str255 itemstring; |
1396 | |
1397 | fprintf(stderr, " popup_add %s\n", text); |
1398 | assert(text[0] != '\0'); |
1399 | c2pstrcpy(itemstring, text); |
1400 | AppendMenu(menu, "\pdummy"); |
fd703c0a |
1401 | SetMenuItemText(menu, CountMenuItems(menu), itemstring); |
1402 | SetControlMaximum(mc->popup.tbctrl, CountMenuItems(menu)); |
56c01970 |
1403 | } |
8a7e67ec |
1404 | |
1405 | void dlg_listbox_add(union control *ctrl, void *dlg, char const *text) |
1406 | { |
1407 | |
56c01970 |
1408 | if (ctrl->listbox.height == 0) |
1409 | dlg_macpopup_add(ctrl, dlg, text); |
1410 | } |
1411 | |
4eaff8d4 |
1412 | static void dlg_macpopup_addwithid(union control *ctrl, void *dlg, |
1413 | char const *text, int id) |
56c01970 |
1414 | { |
1415 | struct macctrls *mcs = dlg; |
1416 | union macctrl *mc = findbyctrl(mcs, ctrl); |
1417 | MenuRef menu = mc->popup.menu; |
1418 | unsigned int index; |
1419 | |
1420 | fprintf(stderr, " popup_addwthindex %s, %d\n", text, id); |
1421 | dlg_macpopup_add(ctrl, dlg, text); |
fd703c0a |
1422 | index = CountMenuItems(menu) - 1; |
56c01970 |
1423 | if (mc->popup.nids <= index) { |
1424 | mc->popup.nids = index + 1; |
34773273 |
1425 | mc->popup.ids = sresize(mc->popup.ids, mc->popup.nids, int); |
56c01970 |
1426 | } |
1427 | mc->popup.ids[index] = id; |
1428 | } |
8a7e67ec |
1429 | |
4eaff8d4 |
1430 | void dlg_listbox_addwithid(union control *ctrl, void *dlg, |
1431 | char const *text, int id) |
8a7e67ec |
1432 | { |
1433 | |
56c01970 |
1434 | if (ctrl->listbox.height == 0) |
4eaff8d4 |
1435 | dlg_macpopup_addwithid(ctrl, dlg, text, id); |
56c01970 |
1436 | } |
8a7e67ec |
1437 | |
1438 | int dlg_listbox_getid(union control *ctrl, void *dlg, int index) |
1439 | { |
56c01970 |
1440 | struct macctrls *mcs = dlg; |
1441 | union macctrl *mc = findbyctrl(mcs, ctrl); |
8a7e67ec |
1442 | |
56c01970 |
1443 | if (ctrl->listbox.height == 0) { |
1444 | assert(mc->popup.ids != NULL && mc->popup.nids > index); |
1445 | return mc->popup.ids[index]; |
1446 | } |
8a7e67ec |
1447 | return 0; |
56c01970 |
1448 | } |
8a7e67ec |
1449 | |
1450 | int dlg_listbox_index(union control *ctrl, void *dlg) |
1451 | { |
56c01970 |
1452 | struct macctrls *mcs = dlg; |
1453 | union macctrl *mc = findbyctrl(mcs, ctrl); |
8a7e67ec |
1454 | |
56c01970 |
1455 | if (ctrl->listbox.height == 0) |
1456 | return GetControlValue(mc->popup.tbctrl) - 1; |
8a7e67ec |
1457 | return 0; |
1458 | }; |
1459 | |
1460 | int dlg_listbox_issel(union control *ctrl, void *dlg, int index) |
1461 | { |
56c01970 |
1462 | struct macctrls *mcs = dlg; |
1463 | union macctrl *mc = findbyctrl(mcs, ctrl); |
8a7e67ec |
1464 | |
56c01970 |
1465 | if (ctrl->listbox.height == 0) |
1466 | return GetControlValue(mc->popup.tbctrl) - 1 == index; |
8a7e67ec |
1467 | return 0; |
1468 | }; |
1469 | |
1470 | void dlg_listbox_select(union control *ctrl, void *dlg, int index) |
1471 | { |
56c01970 |
1472 | struct macctrls *mcs = dlg; |
1473 | union macctrl *mc = findbyctrl(mcs, ctrl); |
8a7e67ec |
1474 | |
56c01970 |
1475 | if (ctrl->listbox.height == 0) |
1476 | SetControlValue(mc->popup.tbctrl, index + 1); |
8a7e67ec |
1477 | }; |
1478 | |
1479 | |
1480 | /* |
1481 | * Text control |
1482 | */ |
1483 | |
1484 | void dlg_text_set(union control *ctrl, void *dlg, char const *text) |
1485 | { |
93ba25f8 |
1486 | struct macctrls *mcs = dlg; |
1487 | union macctrl *mc = findbyctrl(mcs, ctrl); |
8a7e67ec |
1488 | |
93ba25f8 |
1489 | assert(mc != NULL); |
8a7e67ec |
1490 | if (mac_gestalts.apprvers >= 0x100) |
1491 | SetControlData(mc->text.tbctrl, kControlEntireControl, |
1f1ec0e5 |
1492 | kControlStaticTextTextTag, strlen(text), text); |
f28d33e8 |
1493 | #if !TARGET_API_MAC_CARBON |
1494 | else |
1495 | TESetText(text, strlen(text), |
1496 | (TEHandle)(*mc->text.tbctrl)->contrlData); |
1497 | #endif |
8a7e67ec |
1498 | } |
1499 | |
1500 | |
1501 | /* |
1502 | * File Selector control |
1503 | */ |
1504 | |
1505 | void dlg_filesel_set(union control *ctrl, void *dlg, Filename fn) |
1506 | { |
1507 | |
1508 | } |
1509 | |
1510 | void dlg_filesel_get(union control *ctrl, void *dlg, Filename *fn) |
1511 | { |
1512 | |
1513 | } |
1514 | |
1515 | |
1516 | /* |
1517 | * Font Selector control |
1518 | */ |
1519 | |
1520 | void dlg_fontsel_set(union control *ctrl, void *dlg, FontSpec fn) |
1521 | { |
1522 | |
1523 | } |
1524 | |
1525 | void dlg_fontsel_get(union control *ctrl, void *dlg, FontSpec *fn) |
1526 | { |
1527 | |
1528 | } |
1529 | |
1530 | |
1531 | /* |
1532 | * Printer enumeration |
1533 | */ |
1534 | |
1535 | printer_enum *printer_start_enum(int *nprinters) |
1536 | { |
1537 | |
1538 | *nprinters = 0; |
1539 | return NULL; |
1540 | } |
1541 | |
1542 | char *printer_get_name(printer_enum *pe, int thing) |
1543 | { |
1544 | |
1545 | return "<none>"; |
1546 | } |
1547 | |
1548 | void printer_finish_enum(printer_enum *pe) |
1549 | { |
1550 | |
1551 | } |
1552 | |
1553 | |
1554 | /* |
1555 | * Colour selection stuff |
1556 | */ |
1557 | |
1558 | void dlg_coloursel_start(union control *ctrl, void *dlg, |
1559 | int r, int g, int b) |
1560 | { |
1561 | |
1562 | } |
1563 | |
1564 | int dlg_coloursel_results(union control *ctrl, void *dlg, |
1565 | int *r, int *g, int *b) |
1566 | { |
1567 | |
1568 | return 0; |
1569 | } |
1570 | |
1571 | /* |
1572 | * Local Variables: |
1573 | * c-file-style: "simon" |
1574 | * End: |
1575 | */ |