Mention xterm mouse reporting in the section on copy and paste.
[u/mdw/putty] / mac / macctrls.c
CommitLineData
5537f572 1/* $Id: macctrls.c,v 1.6 2003/03/19 00:40:15 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>
fa4942e7 32#include <Resources.h>
8a7e67ec 33#include <Sound.h>
34#include <TextUtils.h>
35#include <Windows.h>
36
37#include "putty.h"
38#include "mac.h"
39#include "macresid.h"
40#include "dialog.h"
41#include "tree234.h"
42
43union macctrl {
44 struct macctrl_generic {
45 enum {
46 MACCTRL_TEXT,
47 MACCTRL_RADIO,
48 MACCTRL_CHECKBOX,
49 MACCTRL_BUTTON
50 } type;
51 /* Template from which this was generated */
52 union control *ctrl;
53 } generic;
54 struct {
55 struct macctrl_generic generic;
56 ControlRef tbctrl;
57 } text;
58 struct {
59 struct macctrl_generic generic;
60 ControlRef *tbctrls;
61 } radio;
62 struct {
63 struct macctrl_generic generic;
64 ControlRef tbctrl;
65 } checkbox;
66 struct {
67 struct macctrl_generic generic;
68 ControlRef tbctrl;
69 } button;
70};
71
72struct mac_layoutstate {
73 Point pos;
74 unsigned int width;
75};
76
77#define ctrlevent(mcs, mc, event) do { \
78 if ((mc)->generic.ctrl->generic.handler != NULL) \
79 (*(mc)->generic.ctrl->generic.handler)((mc)->generic.ctrl, (mc),\
80 (mcs)->data, (event)); \
81} while (0)
82
83static void macctrl_layoutset(struct mac_layoutstate *, struct controlset *,
84 WindowPtr, struct macctrls *);
85static void macctrl_text(struct macctrls *, WindowPtr,
86 struct mac_layoutstate *, union control *);
87static void macctrl_radio(struct macctrls *, WindowPtr,
88 struct mac_layoutstate *, union control *);
89static void macctrl_checkbox(struct macctrls *, WindowPtr,
90 struct mac_layoutstate *, union control *);
91static void macctrl_button(struct macctrls *, WindowPtr,
92 struct mac_layoutstate *, union control *);
fa4942e7 93#if !TARGET_API_MAC_CARBON
94static pascal SInt32 macctrl_sys7_text_cdef(SInt16, ControlRef,
95 ControlDefProcMessage, SInt32);
5537f572 96static pascal SInt32 macctrl_sys7_default_cdef(SInt16, ControlRef,
97 ControlDefProcMessage, SInt32);
fa4942e7 98#endif
99
100#if !TARGET_API_MAC_CARBON
101/*
102 * This trick enables us to keep all the CDEF code in the main
103 * application, which makes life easier. For details, see
104 * <http://developer.apple.com/technotes/tn/tn2003.html#custom_code_base>.
105 */
106
107#pragma options align=mac68k
108typedef struct {
109 short jmpabs; /* 4EF9 */
110 ControlDefUPP theUPP;
111} **PatchCDEF;
112#pragma options align=reset
113#endif
114
115static void macctrl_init()
116{
117#if !TARGET_API_MAC_CARBON
118 static int inited = 0;
119 PatchCDEF cdef;
120
121 if (inited) return;
122 cdef = (PatchCDEF)GetResource(kControlDefProcResourceType, CDEF_Text);
123 (*cdef)->theUPP = NewControlDefProc(macctrl_sys7_text_cdef);
5537f572 124 cdef = (PatchCDEF)GetResource(kControlDefProcResourceType, CDEF_Default);
125 (*cdef)->theUPP = NewControlDefProc(macctrl_sys7_default_cdef);
fa4942e7 126 inited = 1;
127#endif
128}
129
8a7e67ec 130
131static int macctrl_cmp_byctrl(void *av, void *bv)
132{
133 union macctrl *a = (union macctrl *)av;
134 union macctrl *b = (union macctrl *)bv;
135
136 if (a->generic.ctrl < b->generic.ctrl)
137 return -1;
138 else if (a->generic.ctrl > b->generic.ctrl)
139 return +1;
140 else
141 return 0;
142}
143
144void macctrl_layoutbox(struct controlbox *cb, WindowPtr window,
145 struct macctrls *mcs)
146{
147 int i;
148 struct mac_layoutstate curstate;
149 ControlRef root;
150 Rect rect;
fa4942e7 151
152 macctrl_init();
8a7e67ec 153#if TARGET_API_MAC_CARBON
154 GetPortBounds(GetWindowPort(window), &rect);
155#else
156 rect = window->portRect;
157#endif
158 curstate.pos.h = rect.left + 13;
159 curstate.pos.v = rect.top + 13;
160 curstate.width = rect.right - rect.left - (13 * 2);
161 if (mac_gestalts.apprvers >= 0x100)
162 CreateRootControl(window, &root);
163 mcs->byctrl = newtree234(macctrl_cmp_byctrl);
164 for (i = 0; i < cb->nctrlsets; i++)
165 macctrl_layoutset(&curstate, cb->ctrlsets[i], window, mcs);
166}
167
168static void macctrl_layoutset(struct mac_layoutstate *curstate,
169 struct controlset *s,
170 WindowPtr window, struct macctrls *mcs)
171{
172 unsigned int i;
173
174 fprintf(stderr, "--- begin set ---\n");
175 if (s->boxname && *s->boxname)
176 fprintf(stderr, "boxname = %s\n", s->boxname);
177 if (s->boxtitle)
178 fprintf(stderr, "boxtitle = %s\n", s->boxtitle);
179
180
181 for (i = 0; i < s->ncontrols; i++) {
182 union control *ctrl = s->ctrls[i];
183 char const *s;
184
185 switch (ctrl->generic.type) {
186 case CTRL_TEXT: s = "text"; break;
187 case CTRL_EDITBOX: s = "editbox"; break;
188 case CTRL_RADIO: s = "radio"; break;
189 case CTRL_CHECKBOX: s = "checkbox"; break;
190 case CTRL_BUTTON: s = "button"; break;
191 case CTRL_LISTBOX: s = "listbox"; break;
192 case CTRL_COLUMNS: s = "columns"; break;
193 case CTRL_FILESELECT: s = "fileselect"; break;
194 case CTRL_FONTSELECT: s = "fontselect"; break;
195 case CTRL_TABDELAY: s = "tabdelay"; break;
196 default: s = "unknown"; break;
197 }
198 fprintf(stderr, " control: %s\n", s);
199 switch (ctrl->generic.type) {
200 case CTRL_TEXT:
201 macctrl_text(mcs, window, curstate, ctrl);
202 break;
203 case CTRL_RADIO:
204 macctrl_radio(mcs, window, curstate, ctrl);
205 break;
206 case CTRL_CHECKBOX:
207 macctrl_checkbox(mcs, window, curstate, ctrl);
208 break;
209 case CTRL_BUTTON:
210 macctrl_button(mcs, window, curstate, ctrl);
211 break;
212
213 }
214 }
215}
216
217static void macctrl_text(struct macctrls *mcs, WindowPtr window,
218 struct mac_layoutstate *curstate,
219 union control *ctrl)
220{
221 union macctrl *mc = smalloc(sizeof *mc);
222 Rect bounds;
223
224 fprintf(stderr, " label = %s\n", ctrl->text.label);
225 mc->generic.type = MACCTRL_TEXT;
226 mc->generic.ctrl = ctrl;
227 bounds.left = curstate->pos.h;
228 bounds.right = bounds.left + curstate->width;
229 bounds.top = curstate->pos.v;
230 bounds.bottom = bounds.top + 16;
231 if (mac_gestalts.apprvers >= 0x100) {
232 SInt16 height;
233 Size olen;
234
235 mc->text.tbctrl = NewControl(window, &bounds, NULL, TRUE, 0, 0, 0,
236 kControlStaticTextProc, (long)mc);
237 SetControlData(mc->text.tbctrl, kControlEntireControl,
238 kControlStaticTextTextTag,
239 strlen(ctrl->text.label), ctrl->text.label);
240 GetControlData(mc->text.tbctrl, kControlEntireControl,
241 kControlStaticTextTextHeightTag,
242 sizeof(height), &height, &olen);
243 fprintf(stderr, " height = %d\n", height);
244 SizeControl(mc->text.tbctrl, curstate->width, height);
245 curstate->pos.v += height + 6;
246 } else {
fa4942e7 247 Str255 title;
248
249 c2pstrcpy(title, ctrl->text.label);
250 mc->text.tbctrl = NewControl(window, &bounds, title, TRUE, 0, 0, 0,
251 SYS7_TEXT_PROC, (long)mc);
8a7e67ec 252 }
253 add234(mcs->byctrl, mc);
254}
255
fa4942e7 256#if !TARGET_API_MAC_CARBON
257static pascal SInt32 macctrl_sys7_text_cdef(SInt16 variant, ControlRef control,
258 ControlDefProcMessage msg, SInt32 param)
259{
260 RgnHandle rgn;
261
262 switch (msg) {
263 case drawCntl:
264 if ((*control)->contrlVis)
265 TETextBox((*control)->contrlTitle + 1, (*control)->contrlTitle[0],
266 &(*control)->contrlRect, teFlushDefault);
267 return 0;
268 case calcCRgns:
269 if (param & (1 << 31)) {
270 param &= ~(1 << 31);
271 goto calcthumbrgn;
272 }
273 /* FALLTHROUGH */
274 case calcCntlRgn:
275 rgn = (RgnHandle)param;
276 RectRgn(rgn, &(*control)->contrlRect);
277 return 0;
278 case calcThumbRgn:
279 calcthumbrgn:
280 rgn = (RgnHandle)param;
281 SetEmptyRgn(rgn);
282 return 0;
283 }
284
285 return 0;
286}
287#endif
288
8a7e67ec 289static void macctrl_radio(struct macctrls *mcs, WindowPtr window,
290 struct mac_layoutstate *curstate,
291 union control *ctrl)
292{
293 union macctrl *mc = smalloc(sizeof *mc);
294 Rect bounds;
295 Str255 title;
296 unsigned int i, colwidth;
297
298 fprintf(stderr, " label = %s\n", ctrl->radio.label);
299 mc->generic.type = MACCTRL_RADIO;
300 mc->generic.ctrl = ctrl;
301 mc->radio.tbctrls =
302 smalloc(sizeof(*mc->radio.tbctrls) * ctrl->radio.nbuttons);
303 colwidth = (curstate->width + 13) / ctrl->radio.ncolumns;
304 for (i = 0; i < ctrl->radio.nbuttons; i++) {
305 fprintf(stderr, " button = %s\n", ctrl->radio.buttons[i]);
306 bounds.top = curstate->pos.v;
307 bounds.bottom = bounds.top + 16;
308 bounds.left = curstate->pos.h + colwidth * (i % ctrl->radio.ncolumns);
309 if (i == ctrl->radio.nbuttons - 1 ||
310 i % ctrl->radio.ncolumns == ctrl->radio.ncolumns - 1) {
311 bounds.right = curstate->pos.h + curstate->width;
312 curstate->pos.v += 22;
313 } else
314 bounds.right = bounds.left + colwidth - 13;
315 c2pstrcpy(title, ctrl->radio.buttons[i]);
316 mc->radio.tbctrls[i] = NewControl(window, &bounds, title, TRUE,
317 0, 0, 1, radioButProc, (long)mc);
318 }
319 add234(mcs->byctrl, mc);
320 ctrlevent(mcs, mc, EVENT_REFRESH);
321}
322
323static void macctrl_checkbox(struct macctrls *mcs, WindowPtr window,
324 struct mac_layoutstate *curstate,
325 union control *ctrl)
326{
327 union macctrl *mc = smalloc(sizeof *mc);
328 Rect bounds;
329 Str255 title;
330
331 fprintf(stderr, " label = %s\n", ctrl->checkbox.label);
332 mc->generic.type = MACCTRL_CHECKBOX;
333 mc->generic.ctrl = ctrl;
334 bounds.left = curstate->pos.h;
335 bounds.right = bounds.left + curstate->width;
336 bounds.top = curstate->pos.v;
337 bounds.bottom = bounds.top + 16;
338 c2pstrcpy(title, ctrl->checkbox.label);
339 mc->checkbox.tbctrl = NewControl(window, &bounds, title, TRUE, 0, 0, 1,
340 checkBoxProc, (long)mc);
341 add234(mcs->byctrl, mc);
342 curstate->pos.v += 22;
343 ctrlevent(mcs, mc, EVENT_REFRESH);
344}
345
346static void macctrl_button(struct macctrls *mcs, WindowPtr window,
347 struct mac_layoutstate *curstate,
348 union control *ctrl)
349{
350 union macctrl *mc = smalloc(sizeof *mc);
351 Rect bounds;
352 Str255 title;
353
354 fprintf(stderr, " label = %s\n", ctrl->button.label);
355 if (ctrl->button.isdefault)
356 fprintf(stderr, " is default\n");
357 mc->generic.type = MACCTRL_BUTTON;
358 mc->generic.ctrl = ctrl;
359 bounds.left = curstate->pos.h;
360 bounds.right = bounds.left + 100; /* XXX measure string */
361 bounds.top = curstate->pos.v;
362 bounds.bottom = bounds.top + 20;
363 c2pstrcpy(title, ctrl->button.label);
364 mc->button.tbctrl = NewControl(window, &bounds, title, TRUE, 0, 0, 1,
365 pushButProc, (long)mc);
366 if (mac_gestalts.apprvers >= 0x100) {
367 Boolean isdefault = ctrl->button.isdefault;
368
369 SetControlData(mc->button.tbctrl, kControlEntireControl,
370 kControlPushButtonDefaultTag,
371 sizeof(isdefault), &isdefault);
5537f572 372 } else if (ctrl->button.isdefault) {
373 InsetRect(&bounds, -4, -4);
374 NewControl(window, &bounds, title, TRUE, 0, 0, 1,
375 SYS7_DEFAULT_PROC, (long)mc);
8a7e67ec 376 }
855d05c4 377 if (mac_gestalts.apprvers >= 0x110) {
378 Boolean iscancel = ctrl->button.iscancel;
379
380 SetControlData(mc->button.tbctrl, kControlEntireControl,
381 kControlPushButtonCancelTag,
382 sizeof(iscancel), &iscancel);
383 }
8a7e67ec 384 add234(mcs->byctrl, mc);
385 curstate->pos.v += 26;
386}
387
5537f572 388#if !TARGET_API_MAC_CARBON
389static pascal SInt32 macctrl_sys7_default_cdef(SInt16 variant,
390 ControlRef control,
391 ControlDefProcMessage msg,
392 SInt32 param)
393{
394 RgnHandle rgn;
395 Rect rect;
396 int oval;
397
398 switch (msg) {
399 case drawCntl:
400 if ((*control)->contrlVis) {
401 rect = (*control)->contrlRect;
402 PenNormal();
403 PenSize(3, 3);
404 oval = (rect.bottom - rect.top) / 2 + 2;
405 FrameRoundRect(&rect, oval, oval);
406 }
407 return 0;
408 case calcCRgns:
409 if (param & (1 << 31)) {
410 param &= ~(1 << 31);
411 goto calcthumbrgn;
412 }
413 /* FALLTHROUGH */
414 case calcCntlRgn:
415 rgn = (RgnHandle)param;
416 RectRgn(rgn, &(*control)->contrlRect);
417 return 0;
418 case calcThumbRgn:
419 calcthumbrgn:
420 rgn = (RgnHandle)param;
421 SetEmptyRgn(rgn);
422 return 0;
423 }
424
425 return 0;
426}
427#endif
428
8a7e67ec 429
430void macctrl_activate(WindowPtr window, EventRecord *event)
431{
432 Boolean active = (event->modifiers & activeFlag) != 0;
433 GrafPtr saveport;
434 ControlRef root;
435
436 GetPort(&saveport);
437 SetPort((GrafPtr)GetWindowPort(window));
438 if (mac_gestalts.apprvers >= 0x100) {
439 SetThemeWindowBackground(window, active ?
440 kThemeBrushModelessDialogBackgroundActive :
441 kThemeBrushModelessDialogBackgroundInactive,
442 TRUE);
443 GetRootControl(window, &root);
444 if (active)
445 ActivateControl(root);
446 else
447 DeactivateControl(root);
448 } else {
449 /* (De)activate controls one at a time */
450 }
451 SetPort(saveport);
452}
453
454void macctrl_click(WindowPtr window, EventRecord *event)
455{
456 Point mouse;
457 ControlHandle control;
458 int part;
459 GrafPtr saveport;
460 union macctrl *mc;
461 struct macctrls *mcs = mac_winctrls(window);
462 int i;
463
464 GetPort(&saveport);
465 SetPort((GrafPtr)GetWindowPort(window));
466 mouse = event->where;
467 GlobalToLocal(&mouse);
468 part = FindControl(mouse, window, &control);
469 if (control != NULL)
470 if (TrackControl(control, mouse, NULL) != 0) {
471 mc = (union macctrl *)GetControlReference(control);
472 switch (mc->generic.type) {
473 case MACCTRL_RADIO:
474 for (i = 0; i < mc->generic.ctrl->radio.nbuttons; i++) {
475 if (mc->radio.tbctrls[i] == control)
476 SetControlValue(mc->radio.tbctrls[i],
477 kControlRadioButtonCheckedValue);
478 else
479 SetControlValue(mc->radio.tbctrls[i],
480 kControlRadioButtonUncheckedValue);
481 }
482 ctrlevent(mcs, mc, EVENT_VALCHANGE);
483 break;
484 case MACCTRL_CHECKBOX:
485 SetControlValue(control, !GetControlValue(control));
486 ctrlevent(mcs, mc, EVENT_VALCHANGE);
487 break;
488 case MACCTRL_BUTTON:
489 ctrlevent(mcs, mc, EVENT_ACTION);
490 break;
491 }
492 }
493 SetPort(saveport);
494}
495
496void macctrl_update(WindowPtr window)
497{
498#if TARGET_API_MAC_CARBON
499 RgnHandle visrgn;
500#endif
501 Rect rect;
502 GrafPtr saveport;
503
504 BeginUpdate(window);
505 GetPort(&saveport);
506 SetPort((GrafPtr)GetWindowPort(window));
507 if (mac_gestalts.apprvers >= 0x101) {
508#if TARGET_API_MAC_CARBON
509 GetPortBounds(GetWindowPort(window), &rect);
510#else
511 rect = window->portRect;
512#endif
513 InsetRect(&rect, -1, -1);
514 DrawThemeModelessDialogFrame(&rect, mac_frontwindow() == window ?
515 kThemeStateActive : kThemeStateInactive);
516 }
517#if TARGET_API_MAC_CARBON
518 visrgn = NewRgn();
519 GetPortVisibleRegion(GetWindowPort(window), visrgn);
520 UpdateControls(window, visrgn);
521 DisposeRgn(visrgn);
522#else
523 UpdateControls(window, window->visRgn);
524#endif
525 SetPort(saveport);
526 EndUpdate(window);
527}
528
529#if TARGET_API_MAC_CARBON
530#define EnableItem EnableMenuItem
531#define DisableItem DisableMenuItem
532#endif
533void macctrl_adjustmenus(WindowPtr window)
534{
535 MenuHandle menu;
536
537 menu = GetMenuHandle(mFile);
538 DisableItem(menu, iSave); /* XXX enable if modified */
539 EnableItem(menu, iSaveAs);
540 EnableItem(menu, iDuplicate);
541
542 menu = GetMenuHandle(mEdit);
543 DisableItem(menu, 0);
544}
545
546void macctrl_close(WindowPtr window)
547{
548 struct macctrls *mcs = mac_winctrls(window);
549 union macctrl *mc;
550
551 while ((mc = index234(mcs->byctrl, 0)) != NULL) {
552 del234(mcs->byctrl, mc);
553 sfree(mc);
554 }
555
556 freetree234(mcs->byctrl);
557 mcs->byctrl = NULL;
558
559/* XXX
560 DisposeWindow(window);
561 if (s->window == NULL)
562 sfree(s);
563*/
564}
565
566void dlg_update_start(union control *ctrl, void *dlg)
567{
568
569 /* No-op for now */
570}
571
572void dlg_update_done(union control *ctrl, void *dlg)
573{
574
575 /* No-op for now */
576}
577
578void dlg_set_focus(union control *ctrl, void *dlg)
579{
580
581 if (mac_gestalts.apprvers >= 0x100) {
582 /* Use SetKeyboardFocus() */
583 } else {
584 /* Do our own mucking around */
585 }
586}
587
0bd8d76d 588union control *dlg_last_focused(union control *ctrl, void *dlg)
8a7e67ec 589{
590
591 return NULL;
592}
593
594void dlg_beep(void *dlg)
595{
596
597 SysBeep(30);
598}
599
600void dlg_error_msg(void *dlg, char *msg)
601{
602 Str255 pmsg;
603
604 c2pstrcpy(pmsg, msg);
605 ParamText(pmsg, NULL, NULL, NULL);
606 StopAlert(128, NULL);
607}
608
609void dlg_end(void *dlg, int value)
610{
611
612};
613
614void dlg_refresh(union control *ctrl, void *dlg)
615{
616
617};
618
619void *dlg_get_privdata(union control *ctrl, void *dlg)
620{
621
622 return NULL;
623}
624
625void dlg_set_privdata(union control *ctrl, void *dlg, void *ptr)
626{
627
628 fatalbox("dlg_set_privdata");
629}
630
631void *dlg_alloc_privdata(union control *ctrl, void *dlg, size_t size)
632{
633
634 fatalbox("dlg_alloc_privdata");
635}
636
637
638/*
639 * Radio Button control
640 */
641
642void dlg_radiobutton_set(union control *ctrl, void *dlg, int whichbutton)
643{
644 union macctrl *mc = dlg;
645 int i;
646
647 for (i = 0; i < ctrl->radio.nbuttons; i++) {
648 if (i == whichbutton)
649 SetControlValue(mc->radio.tbctrls[i],
650 kControlRadioButtonCheckedValue);
651 else
652 SetControlValue(mc->radio.tbctrls[i],
653 kControlRadioButtonUncheckedValue);
654 }
655
656};
657
658int dlg_radiobutton_get(union control *ctrl, void *dlg)
659{
660 union macctrl *mc = dlg;
661 int i;
662
663 for (i = 0; i < ctrl->radio.nbuttons; i++) {
664 if (GetControlValue(mc->radio.tbctrls[i]) ==
665 kControlRadioButtonCheckedValue)
666 return i;
667 }
668 return -1;
669};
670
671
672/*
673 * Check Box control
674 */
675
676void dlg_checkbox_set(union control *ctrl, void *dlg, int checked)
677{
678 union macctrl *mc = dlg;
679
680 SetControlValue(mc->checkbox.tbctrl,
681 checked ? kControlCheckBoxCheckedValue :
682 kControlCheckBoxUncheckedValue);
683}
684
685int dlg_checkbox_get(union control *ctrl, void *dlg)
686{
687 union macctrl *mc = dlg;
688
689 return GetControlValue(mc->checkbox.tbctrl);
690}
691
692
693/*
694 * Edit Box control
695 */
696
697void dlg_editbox_set(union control *ctrl, void *dlg, char const *text)
698{
699
700};
701
702void dlg_editbox_get(union control *ctrl, void *dlg, char *buffer, int length)
703{
704
705};
706
707
708/*
709 * List Box control
710 */
711
712void dlg_listbox_clear(union control *ctrl, void *dlg)
713{
714
715};
716
717void dlg_listbox_del(union control *ctrl, void *dlg, int index)
718{
719
720};
721
722void dlg_listbox_add(union control *ctrl, void *dlg, char const *text)
723{
724
725};
726
727void dlg_listbox_addwithindex(union control *ctrl, void *dlg,
728 char const *text, int id)
729{
730
731};
732
733int dlg_listbox_getid(union control *ctrl, void *dlg, int index)
734{
735
736 return 0;
737};
738
739int dlg_listbox_index(union control *ctrl, void *dlg)
740{
741
742 return 0;
743};
744
745int dlg_listbox_issel(union control *ctrl, void *dlg, int index)
746{
747
748 return 0;
749};
750
751void dlg_listbox_select(union control *ctrl, void *dlg, int index)
752{
753
754};
755
756
757/*
758 * Text control
759 */
760
761void dlg_text_set(union control *ctrl, void *dlg, char const *text)
762{
763 union macctrl *mc = dlg;
f32ce408 764 Str255 title;
8a7e67ec 765
766 if (mac_gestalts.apprvers >= 0x100)
767 SetControlData(mc->text.tbctrl, kControlEntireControl,
768 kControlStaticTextTextTag,
769 strlen(ctrl->text.label), ctrl->text.label);
f32ce408 770 else {
771 c2pstrcpy(title, text);
772 SetControlTitle(mc->text.tbctrl, title);
773 }
8a7e67ec 774}
775
776
777/*
778 * File Selector control
779 */
780
781void dlg_filesel_set(union control *ctrl, void *dlg, Filename fn)
782{
783
784}
785
786void dlg_filesel_get(union control *ctrl, void *dlg, Filename *fn)
787{
788
789}
790
791
792/*
793 * Font Selector control
794 */
795
796void dlg_fontsel_set(union control *ctrl, void *dlg, FontSpec fn)
797{
798
799}
800
801void dlg_fontsel_get(union control *ctrl, void *dlg, FontSpec *fn)
802{
803
804}
805
806
807/*
808 * Printer enumeration
809 */
810
811printer_enum *printer_start_enum(int *nprinters)
812{
813
814 *nprinters = 0;
815 return NULL;
816}
817
818char *printer_get_name(printer_enum *pe, int thing)
819{
820
821 return "<none>";
822}
823
824void printer_finish_enum(printer_enum *pe)
825{
826
827}
828
829
830/*
831 * Colour selection stuff
832 */
833
834void dlg_coloursel_start(union control *ctrl, void *dlg,
835 int r, int g, int b)
836{
837
838}
839
840int dlg_coloursel_results(union control *ctrl, void *dlg,
841 int *r, int *g, int *b)
842{
843
844 return 0;
845}
846
847/*
848 * Local Variables:
849 * c-file-style: "simon"
850 * End:
851 */