1 /* $Id: macctrls.c,v 1.8 2003/03/21 00:24:17 ben Exp $ */
3 * Copyright (c) 2003 Ben Harris
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
15 * The above copyright notice and this permission notice shall be
16 * included in all copies or substantial portions of the Software.
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
29 #include <Appearance.h>
31 #include <ControlDefinitions.h>
32 #include <Resources.h>
34 #include <TextUtils.h>
47 struct macctrl_generic
{
54 /* Template from which this was generated */
56 /* Next control in this panel */
60 struct macctrl_generic generic
;
64 struct macctrl_generic generic
;
68 struct macctrl_generic generic
;
72 struct macctrl_generic generic
;
77 struct mac_layoutstate
{
80 unsigned int panelnum
;
83 #define ctrlevent(mcs, mc, event) do { \
84 if ((mc)->generic.ctrl->generic.handler != NULL) \
85 (*(mc)->generic.ctrl->generic.handler)((mc)->generic.ctrl, (mcs),\
86 (mcs)->data, (event)); \
89 #define findbyctrl(mcs, ctrl) \
90 find234((mcs)->byctrl, (ctrl), macctrl_cmp_byctrl_find)
92 static void macctrl_layoutset(struct mac_layoutstate
*, struct controlset
*,
93 WindowPtr
, struct macctrls
*);
94 static void macctrl_switchtopanel(struct macctrls
*, unsigned int);
95 static void macctrl_text(struct macctrls
*, WindowPtr
,
96 struct mac_layoutstate
*, union control
*);
97 static void macctrl_radio(struct macctrls
*, WindowPtr
,
98 struct mac_layoutstate
*, union control
*);
99 static void macctrl_checkbox(struct macctrls
*, WindowPtr
,
100 struct mac_layoutstate
*, union control
*);
101 static void macctrl_button(struct macctrls
*, WindowPtr
,
102 struct mac_layoutstate
*, union control
*);
103 #if !TARGET_API_MAC_CARBON
104 static pascal SInt32
macctrl_sys7_text_cdef(SInt16
, ControlRef
,
105 ControlDefProcMessage
, SInt32
);
106 static pascal SInt32
macctrl_sys7_default_cdef(SInt16
, ControlRef
,
107 ControlDefProcMessage
, SInt32
);
110 #if !TARGET_API_MAC_CARBON
112 * This trick enables us to keep all the CDEF code in the main
113 * application, which makes life easier. For details, see
114 * <http://developer.apple.com/technotes/tn/tn2003.html#custom_code_base>.
117 #pragma options align=mac68k
119 short jmpabs
; /* 4EF9 */
120 ControlDefUPP theUPP
;
122 #pragma options align=reset
125 static void macctrl_init()
127 #if !TARGET_API_MAC_CARBON
128 static int inited
= 0;
132 cdef
= (PatchCDEF
)GetResource(kControlDefProcResourceType
, CDEF_Text
);
133 (*cdef
)->theUPP
= NewControlDefProc(macctrl_sys7_text_cdef
);
134 cdef
= (PatchCDEF
)GetResource(kControlDefProcResourceType
, CDEF_Default
);
135 (*cdef
)->theUPP
= NewControlDefProc(macctrl_sys7_default_cdef
);
141 static int macctrl_cmp_byctrl(void *av
, void *bv
)
143 union macctrl
*a
= (union macctrl
*)av
;
144 union macctrl
*b
= (union macctrl
*)bv
;
146 if (a
->generic
.ctrl
< b
->generic
.ctrl
)
148 else if (a
->generic
.ctrl
> b
->generic
.ctrl
)
154 static int macctrl_cmp_byctrl_find(void *av
, void *bv
)
156 union control
*a
= (union control
*)av
;
157 union macctrl
*b
= (union macctrl
*)bv
;
159 if (a
< b
->generic
.ctrl
)
161 else if (a
> b
->generic
.ctrl
)
167 void macctrl_layoutbox(struct controlbox
*cb
, WindowPtr window
,
168 struct macctrls
*mcs
)
171 struct mac_layoutstate curstate
;
176 #if TARGET_API_MAC_CARBON
177 GetPortBounds(GetWindowPort(window
), &rect
);
179 rect
= window
->portRect
;
181 curstate
.pos
.h
= rect
.left
+ 13;
182 curstate
.pos
.v
= rect
.bottom
- 59;
183 curstate
.width
= rect
.right
- rect
.left
- (13 * 2);
184 if (mac_gestalts
.apprvers
>= 0x100)
185 CreateRootControl(window
, &root
);
186 mcs
->byctrl
= newtree234(macctrl_cmp_byctrl
);
187 /* Count the number of panels */
189 for (i
= 1; i
< cb
->nctrlsets
; i
++)
190 if (strcmp(cb
->ctrlsets
[i
]->pathname
, cb
->ctrlsets
[i
-1]->pathname
))
192 mcs
->panels
= smalloc(sizeof(*mcs
->panels
) * mcs
->npanels
);
193 memset(mcs
->panels
, 0, sizeof(*mcs
->panels
) * mcs
->npanels
);
194 curstate
.panelnum
= 0;
195 for (i
= 0; i
< cb
->nctrlsets
; i
++) {
196 if (i
> 0 && strcmp(cb
->ctrlsets
[i
]->pathname
,
197 cb
->ctrlsets
[i
-1]->pathname
)) {
198 curstate
.pos
.v
= rect
.top
+ 13;
200 assert(curstate
.panelnum
< mcs
->npanels
);
202 macctrl_layoutset(&curstate
, cb
->ctrlsets
[i
], window
, mcs
);
204 macctrl_switchtopanel(mcs
, 1);
207 static void macctrl_layoutset(struct mac_layoutstate
*curstate
,
208 struct controlset
*s
,
209 WindowPtr window
, struct macctrls
*mcs
)
213 fprintf(stderr
, "--- begin set ---\n");
214 fprintf(stderr
, "pathname = %s\n", s
->pathname
);
215 if (s
->boxname
&& *s
->boxname
)
216 fprintf(stderr
, "boxname = %s\n", s
->boxname
);
218 fprintf(stderr
, "boxtitle = %s\n", s
->boxtitle
);
221 for (i
= 0; i
< s
->ncontrols
; i
++) {
222 union control
*ctrl
= s
->ctrls
[i
];
225 switch (ctrl
->generic
.type
) {
226 case CTRL_TEXT
: s
= "text"; break;
227 case CTRL_EDITBOX
: s
= "editbox"; break;
228 case CTRL_RADIO
: s
= "radio"; break;
229 case CTRL_CHECKBOX
: s
= "checkbox"; break;
230 case CTRL_BUTTON
: s
= "button"; break;
231 case CTRL_LISTBOX
: s
= "listbox"; break;
232 case CTRL_COLUMNS
: s
= "columns"; break;
233 case CTRL_FILESELECT
: s
= "fileselect"; break;
234 case CTRL_FONTSELECT
: s
= "fontselect"; break;
235 case CTRL_TABDELAY
: s
= "tabdelay"; break;
236 default: s
= "unknown"; break;
238 fprintf(stderr
, " control: %s\n", s
);
239 switch (ctrl
->generic
.type
) {
241 macctrl_text(mcs
, window
, curstate
, ctrl
);
244 macctrl_radio(mcs
, window
, curstate
, ctrl
);
247 macctrl_checkbox(mcs
, window
, curstate
, ctrl
);
250 macctrl_button(mcs
, window
, curstate
, ctrl
);
257 static void macctrl_switchtopanel(struct macctrls
*mcs
, unsigned int which
)
262 /* Panel 0 is special and always visible. */
263 for (i
= 1; i
< mcs
->npanels
; i
++)
264 for (mc
= mcs
->panels
[i
]; mc
!= NULL
; mc
= mc
->generic
.next
)
265 switch (mc
->generic
.type
) {
268 ShowControl(mc
->text
.tbctrl
);
270 HideControl(mc
->text
.tbctrl
);
273 for (j
= 0; j
< mc
->generic
.ctrl
->radio
.nbuttons
; j
++)
275 ShowControl(mc
->radio
.tbctrls
[j
]);
277 HideControl(mc
->radio
.tbctrls
[j
]);
279 case MACCTRL_CHECKBOX
:
281 ShowControl(mc
->checkbox
.tbctrl
);
283 HideControl(mc
->checkbox
.tbctrl
);
287 ShowControl(mc
->button
.tbctrl
);
289 HideControl(mc
->button
.tbctrl
);
295 static void macctrl_text(struct macctrls
*mcs
, WindowPtr window
,
296 struct mac_layoutstate
*curstate
,
299 union macctrl
*mc
= smalloc(sizeof *mc
);
302 fprintf(stderr
, " label = %s\n", ctrl
->text
.label
);
303 mc
->generic
.type
= MACCTRL_TEXT
;
304 mc
->generic
.ctrl
= ctrl
;
305 bounds
.left
= curstate
->pos
.h
;
306 bounds
.right
= bounds
.left
+ curstate
->width
;
307 bounds
.top
= curstate
->pos
.v
;
308 bounds
.bottom
= bounds
.top
+ 16;
309 if (mac_gestalts
.apprvers
>= 0x100) {
313 mc
->text
.tbctrl
= NewControl(window
, &bounds
, NULL
, TRUE
, 0, 0, 0,
314 kControlStaticTextProc
, (long)mc
);
315 SetControlData(mc
->text
.tbctrl
, kControlEntireControl
,
316 kControlStaticTextTextTag
,
317 strlen(ctrl
->text
.label
), ctrl
->text
.label
);
318 GetControlData(mc
->text
.tbctrl
, kControlEntireControl
,
319 kControlStaticTextTextHeightTag
,
320 sizeof(height
), &height
, &olen
);
321 fprintf(stderr
, " height = %d\n", height
);
322 SizeControl(mc
->text
.tbctrl
, curstate
->width
, height
);
323 curstate
->pos
.v
+= height
+ 6;
327 c2pstrcpy(title
, ctrl
->text
.label
);
328 mc
->text
.tbctrl
= NewControl(window
, &bounds
, title
, TRUE
, 0, 0, 0,
329 SYS7_TEXT_PROC
, (long)mc
);
331 add234(mcs
->byctrl
, mc
);
332 mc
->generic
.next
= mcs
->panels
[curstate
->panelnum
];
333 mcs
->panels
[curstate
->panelnum
] = mc
;
336 #if !TARGET_API_MAC_CARBON
337 static pascal SInt32
macctrl_sys7_text_cdef(SInt16 variant
, ControlRef control
,
338 ControlDefProcMessage msg
, SInt32 param
)
344 if ((*control
)->contrlVis
)
345 TETextBox((*control
)->contrlTitle
+ 1, (*control
)->contrlTitle
[0],
346 &(*control
)->contrlRect
, teFlushDefault
);
349 if (param
& (1 << 31)) {
355 rgn
= (RgnHandle
)param
;
356 RectRgn(rgn
, &(*control
)->contrlRect
);
360 rgn
= (RgnHandle
)param
;
369 static void macctrl_radio(struct macctrls
*mcs
, WindowPtr window
,
370 struct mac_layoutstate
*curstate
,
373 union macctrl
*mc
= smalloc(sizeof *mc
);
376 unsigned int i
, colwidth
;
378 fprintf(stderr
, " label = %s\n", ctrl
->radio
.label
);
379 mc
->generic
.type
= MACCTRL_RADIO
;
380 mc
->generic
.ctrl
= ctrl
;
382 smalloc(sizeof(*mc
->radio
.tbctrls
) * ctrl
->radio
.nbuttons
);
383 colwidth
= (curstate
->width
+ 13) / ctrl
->radio
.ncolumns
;
384 for (i
= 0; i
< ctrl
->radio
.nbuttons
; i
++) {
385 fprintf(stderr
, " button = %s\n", ctrl
->radio
.buttons
[i
]);
386 bounds
.top
= curstate
->pos
.v
;
387 bounds
.bottom
= bounds
.top
+ 16;
388 bounds
.left
= curstate
->pos
.h
+ colwidth
* (i
% ctrl
->radio
.ncolumns
);
389 if (i
== ctrl
->radio
.nbuttons
- 1 ||
390 i
% ctrl
->radio
.ncolumns
== ctrl
->radio
.ncolumns
- 1) {
391 bounds
.right
= curstate
->pos
.h
+ curstate
->width
;
392 curstate
->pos
.v
+= 22;
394 bounds
.right
= bounds
.left
+ colwidth
- 13;
395 c2pstrcpy(title
, ctrl
->radio
.buttons
[i
]);
396 mc
->radio
.tbctrls
[i
] = NewControl(window
, &bounds
, title
, TRUE
,
397 0, 0, 1, radioButProc
, (long)mc
);
399 add234(mcs
->byctrl
, mc
);
400 mc
->generic
.next
= mcs
->panels
[curstate
->panelnum
];
401 mcs
->panels
[curstate
->panelnum
] = mc
;
402 ctrlevent(mcs
, mc
, EVENT_REFRESH
);
405 static void macctrl_checkbox(struct macctrls
*mcs
, WindowPtr window
,
406 struct mac_layoutstate
*curstate
,
409 union macctrl
*mc
= smalloc(sizeof *mc
);
413 fprintf(stderr
, " label = %s\n", ctrl
->checkbox
.label
);
414 mc
->generic
.type
= MACCTRL_CHECKBOX
;
415 mc
->generic
.ctrl
= ctrl
;
416 bounds
.left
= curstate
->pos
.h
;
417 bounds
.right
= bounds
.left
+ curstate
->width
;
418 bounds
.top
= curstate
->pos
.v
;
419 bounds
.bottom
= bounds
.top
+ 16;
420 c2pstrcpy(title
, ctrl
->checkbox
.label
);
421 mc
->checkbox
.tbctrl
= NewControl(window
, &bounds
, title
, TRUE
, 0, 0, 1,
422 checkBoxProc
, (long)mc
);
423 add234(mcs
->byctrl
, mc
);
424 curstate
->pos
.v
+= 22;
425 mc
->generic
.next
= mcs
->panels
[curstate
->panelnum
];
426 mcs
->panels
[curstate
->panelnum
] = mc
;
427 ctrlevent(mcs
, mc
, EVENT_REFRESH
);
430 static void macctrl_button(struct macctrls
*mcs
, WindowPtr window
,
431 struct mac_layoutstate
*curstate
,
434 union macctrl
*mc
= smalloc(sizeof *mc
);
438 fprintf(stderr
, " label = %s\n", ctrl
->button
.label
);
439 if (ctrl
->button
.isdefault
)
440 fprintf(stderr
, " is default\n");
441 mc
->generic
.type
= MACCTRL_BUTTON
;
442 mc
->generic
.ctrl
= ctrl
;
443 bounds
.left
= curstate
->pos
.h
;
444 bounds
.right
= bounds
.left
+ 100; /* XXX measure string */
445 bounds
.top
= curstate
->pos
.v
;
446 bounds
.bottom
= bounds
.top
+ 20;
447 c2pstrcpy(title
, ctrl
->button
.label
);
448 mc
->button
.tbctrl
= NewControl(window
, &bounds
, title
, TRUE
, 0, 0, 1,
449 pushButProc
, (long)mc
);
450 if (mac_gestalts
.apprvers
>= 0x100) {
451 Boolean isdefault
= ctrl
->button
.isdefault
;
453 SetControlData(mc
->button
.tbctrl
, kControlEntireControl
,
454 kControlPushButtonDefaultTag
,
455 sizeof(isdefault
), &isdefault
);
456 } else if (ctrl
->button
.isdefault
) {
457 InsetRect(&bounds
, -4, -4);
458 NewControl(window
, &bounds
, title
, TRUE
, 0, 0, 1,
459 SYS7_DEFAULT_PROC
, (long)mc
);
461 if (mac_gestalts
.apprvers
>= 0x110) {
462 Boolean iscancel
= ctrl
->button
.iscancel
;
464 SetControlData(mc
->button
.tbctrl
, kControlEntireControl
,
465 kControlPushButtonCancelTag
,
466 sizeof(iscancel
), &iscancel
);
468 add234(mcs
->byctrl
, mc
);
469 mc
->generic
.next
= mcs
->panels
[curstate
->panelnum
];
470 mcs
->panels
[curstate
->panelnum
] = mc
;
471 curstate
->pos
.v
+= 26;
474 #if !TARGET_API_MAC_CARBON
475 static pascal SInt32
macctrl_sys7_default_cdef(SInt16 variant
,
477 ControlDefProcMessage msg
,
486 if ((*control
)->contrlVis
) {
487 rect
= (*control
)->contrlRect
;
490 oval
= (rect
.bottom
- rect
.top
) / 2 + 2;
491 FrameRoundRect(&rect
, oval
, oval
);
495 if (param
& (1 << 31)) {
501 rgn
= (RgnHandle
)param
;
502 RectRgn(rgn
, &(*control
)->contrlRect
);
506 rgn
= (RgnHandle
)param
;
516 void macctrl_activate(WindowPtr window
, EventRecord
*event
)
518 Boolean active
= (event
->modifiers
& activeFlag
) != 0;
523 SetPort((GrafPtr
)GetWindowPort(window
));
524 if (mac_gestalts
.apprvers
>= 0x100) {
525 SetThemeWindowBackground(window
, active ?
526 kThemeBrushModelessDialogBackgroundActive
:
527 kThemeBrushModelessDialogBackgroundInactive
,
529 GetRootControl(window
, &root
);
531 ActivateControl(root
);
533 DeactivateControl(root
);
535 /* (De)activate controls one at a time */
540 void macctrl_click(WindowPtr window
, EventRecord
*event
)
543 ControlHandle control
;
547 struct macctrls
*mcs
= mac_winctrls(window
);
551 SetPort((GrafPtr
)GetWindowPort(window
));
552 mouse
= event
->where
;
553 GlobalToLocal(&mouse
);
554 part
= FindControl(mouse
, window
, &control
);
556 if (TrackControl(control
, mouse
, NULL
) != 0) {
557 mc
= (union macctrl
*)GetControlReference(control
);
558 switch (mc
->generic
.type
) {
560 for (i
= 0; i
< mc
->generic
.ctrl
->radio
.nbuttons
; i
++) {
561 if (mc
->radio
.tbctrls
[i
] == control
)
562 SetControlValue(mc
->radio
.tbctrls
[i
],
563 kControlRadioButtonCheckedValue
);
565 SetControlValue(mc
->radio
.tbctrls
[i
],
566 kControlRadioButtonUncheckedValue
);
568 ctrlevent(mcs
, mc
, EVENT_VALCHANGE
);
570 case MACCTRL_CHECKBOX
:
571 SetControlValue(control
, !GetControlValue(control
));
572 ctrlevent(mcs
, mc
, EVENT_VALCHANGE
);
575 ctrlevent(mcs
, mc
, EVENT_ACTION
);
582 void macctrl_update(WindowPtr window
)
584 #if TARGET_API_MAC_CARBON
592 SetPort((GrafPtr
)GetWindowPort(window
));
593 if (mac_gestalts
.apprvers
>= 0x101) {
594 #if TARGET_API_MAC_CARBON
595 GetPortBounds(GetWindowPort(window
), &rect
);
597 rect
= window
->portRect
;
599 InsetRect(&rect
, -1, -1);
600 DrawThemeModelessDialogFrame(&rect
, mac_frontwindow() == window ?
601 kThemeStateActive
: kThemeStateInactive
);
603 #if TARGET_API_MAC_CARBON
605 GetPortVisibleRegion(GetWindowPort(window
), visrgn
);
606 UpdateControls(window
, visrgn
);
609 UpdateControls(window
, window
->visRgn
);
615 #if TARGET_API_MAC_CARBON
616 #define EnableItem EnableMenuItem
617 #define DisableItem DisableMenuItem
619 void macctrl_adjustmenus(WindowPtr window
)
623 menu
= GetMenuHandle(mFile
);
624 DisableItem(menu
, iSave
); /* XXX enable if modified */
625 EnableItem(menu
, iSaveAs
);
626 EnableItem(menu
, iDuplicate
);
628 menu
= GetMenuHandle(mEdit
);
629 DisableItem(menu
, 0);
632 void macctrl_close(WindowPtr window
)
634 struct macctrls
*mcs
= mac_winctrls(window
);
637 while ((mc
= index234(mcs
->byctrl
, 0)) != NULL
) {
638 del234(mcs
->byctrl
, mc
);
642 freetree234(mcs
->byctrl
);
648 void dlg_update_start(union control
*ctrl
, void *dlg
)
654 void dlg_update_done(union control
*ctrl
, void *dlg
)
660 void dlg_set_focus(union control
*ctrl
, void *dlg
)
663 if (mac_gestalts
.apprvers
>= 0x100) {
664 /* Use SetKeyboardFocus() */
666 /* Do our own mucking around */
670 union control
*dlg_last_focused(union control
*ctrl
, void *dlg
)
676 void dlg_beep(void *dlg
)
682 void dlg_error_msg(void *dlg
, char *msg
)
686 c2pstrcpy(pmsg
, msg
);
687 ParamText(pmsg
, NULL
, NULL
, NULL
);
688 StopAlert(128, NULL
);
691 void dlg_end(void *dlg
, int value
)
696 void dlg_refresh(union control
*ctrl
, void *dlg
)
701 void *dlg_get_privdata(union control
*ctrl
, void *dlg
)
707 void dlg_set_privdata(union control
*ctrl
, void *dlg
, void *ptr
)
710 fatalbox("dlg_set_privdata");
713 void *dlg_alloc_privdata(union control
*ctrl
, void *dlg
, size_t size
)
716 fatalbox("dlg_alloc_privdata");
721 * Radio Button control
724 void dlg_radiobutton_set(union control
*ctrl
, void *dlg
, int whichbutton
)
726 struct macctrls
*mcs
= dlg
;
727 union macctrl
*mc
= findbyctrl(mcs
, ctrl
);
731 for (i
= 0; i
< ctrl
->radio
.nbuttons
; i
++) {
732 if (i
== whichbutton
)
733 SetControlValue(mc
->radio
.tbctrls
[i
],
734 kControlRadioButtonCheckedValue
);
736 SetControlValue(mc
->radio
.tbctrls
[i
],
737 kControlRadioButtonUncheckedValue
);
742 int dlg_radiobutton_get(union control
*ctrl
, void *dlg
)
744 struct macctrls
*mcs
= dlg
;
745 union macctrl
*mc
= findbyctrl(mcs
, ctrl
);
749 for (i
= 0; i
< ctrl
->radio
.nbuttons
; i
++) {
750 if (GetControlValue(mc
->radio
.tbctrls
[i
]) ==
751 kControlRadioButtonCheckedValue
)
762 void dlg_checkbox_set(union control
*ctrl
, void *dlg
, int checked
)
764 struct macctrls
*mcs
= dlg
;
765 union macctrl
*mc
= findbyctrl(mcs
, ctrl
);
768 SetControlValue(mc
->checkbox
.tbctrl
,
769 checked ? kControlCheckBoxCheckedValue
:
770 kControlCheckBoxUncheckedValue
);
773 int dlg_checkbox_get(union control
*ctrl
, void *dlg
)
775 struct macctrls
*mcs
= dlg
;
776 union macctrl
*mc
= findbyctrl(mcs
, ctrl
);
779 return GetControlValue(mc
->checkbox
.tbctrl
);
787 void dlg_editbox_set(union control
*ctrl
, void *dlg
, char const *text
)
792 void dlg_editbox_get(union control
*ctrl
, void *dlg
, char *buffer
, int length
)
802 void dlg_listbox_clear(union control
*ctrl
, void *dlg
)
807 void dlg_listbox_del(union control
*ctrl
, void *dlg
, int index
)
812 void dlg_listbox_add(union control
*ctrl
, void *dlg
, char const *text
)
817 void dlg_listbox_addwithindex(union control
*ctrl
, void *dlg
,
818 char const *text
, int id
)
823 int dlg_listbox_getid(union control
*ctrl
, void *dlg
, int index
)
829 int dlg_listbox_index(union control
*ctrl
, void *dlg
)
835 int dlg_listbox_issel(union control
*ctrl
, void *dlg
, int index
)
841 void dlg_listbox_select(union control
*ctrl
, void *dlg
, int index
)
851 void dlg_text_set(union control
*ctrl
, void *dlg
, char const *text
)
853 struct macctrls
*mcs
= dlg
;
854 union macctrl
*mc
= findbyctrl(mcs
, ctrl
);
858 if (mac_gestalts
.apprvers
>= 0x100)
859 SetControlData(mc
->text
.tbctrl
, kControlEntireControl
,
860 kControlStaticTextTextTag
,
861 strlen(ctrl
->text
.label
), ctrl
->text
.label
);
863 c2pstrcpy(title
, text
);
864 SetControlTitle(mc
->text
.tbctrl
, title
);
870 * File Selector control
873 void dlg_filesel_set(union control
*ctrl
, void *dlg
, Filename fn
)
878 void dlg_filesel_get(union control
*ctrl
, void *dlg
, Filename
*fn
)
885 * Font Selector control
888 void dlg_fontsel_set(union control
*ctrl
, void *dlg
, FontSpec fn
)
893 void dlg_fontsel_get(union control
*ctrl
, void *dlg
, FontSpec
*fn
)
900 * Printer enumeration
903 printer_enum
*printer_start_enum(int *nprinters
)
910 char *printer_get_name(printer_enum
*pe
, int thing
)
916 void printer_finish_enum(printer_enum
*pe
)
923 * Colour selection stuff
926 void dlg_coloursel_start(union control
*ctrl
, void *dlg
,
932 int dlg_coloursel_results(union control
*ctrl
, void *dlg
,
933 int *r
, int *g
, int *b
)
941 * c-file-style: "simon"