[comp.sys.mac.programmer] Changing the Font of Dialog Items

fordjm@byuvax.bitnet (10/15/88)

I need to design a rather "crowded" dialog box to allow editing of a
number of pieces of information which must all be present at the same
time.  Is there an easy way to change the font in which dialog items
(checkboxes, static and editable text) are displayed?  I would like to
get extra space by using geneva 9, but I would also like to use the
dialog item handling functions, etc.

Any help (or code fragments) would be greatly appreciated.  I am
programming on an old 512K Mac with the original ROMs.

Thanks,
John M. Ford             fordjm@byuvax.bitnet
Brigham Young University

bob@eecs.nwu.edu (Bob Hablutzel) (10/25/88)

> I need to design a rather "crowded" dialog box to allow editing of a
> number of pieces of information which must all be present at the same
> time.  Is there an easy way to change the font in which dialog items
> (checkboxes, static and editable text) are displayed?  I would like to
> get extra space by using geneva 9, but I would also like to use the
> dialog item handling functions, etc.

You can easily set the font and size for static text and editable text
items, but changing the font for controls takes more work, and usually
isn't worth it. (You'll find that the buttons don't look quite like
buttons, etc. Things the users will notice). After getting the dialogPtr,
set the font and size using quickdraw calls, treating the dialogPtr
as a grafPtr, which it is. Do this before the drawing takes place, i.e.
before the first update event.

Bob Hablutzel		BOB@NUACC.ACNS.NWU.EDU

alexis@ccnysci.UUCP (Alexis Rosen) (10/26/88)

I'm afraid you're SOL. You can change the font that dialogs will use in the
future by calling SetDAFont(fontNum), but this only affects editText and
statText items. Control Titles are always in the system font, and I don't think
there's any kosher way of changing the System Font with the old ROMs
(especially the size). I remember that you can do this fairly easily with the
new ROMs, but you'll have to look in IM IV for that...

I _strongly_ suggest that you re-think your interface. A screen design so
crowded is liable to make things slower for the user, not faster.

----
Alexis Rosen                       alexis@dasys1.UUCP  or  alexis@ccnysci.UUCP
Writing from                       {allegra,philabs,cmcl2}!phri\
The Big Electric Cat                                       uunet!dasys1!alexis
Public UNIX                           {portal,well,sun}!hoptoad/

clay@claris.com (Clay A. Maeckel) (10/26/88)

In article <10050037@eecs.nwu.edu> bob@eecs.nwu.edu (Bob Hablutzel) writes:
>You can easily set the font and size for static text and editable text
>items, but changing the font for controls takes more work, and usually
>isn't worth it.

But, if you still want to fight with the dialog manager and it's quirks
here is how I have set up a dialog to use another font. (The variable names
have been changed to protect the innocent :-).  Instead of creating CNTL
resources for all the controls to change the variant type (values > 8 tells
the control to use the windows font) you can do a slight of hand trick of
changing the variants directly after the dialog manager has created the
controls for the DITL list.

SetDAFont(dfNum);				{Set font for the dialog}
dBox := GetNewDialog(149, NIL, pointer(-1));	{Get the dialog box, invisible}
SetDAFont(0);					{Restore the normal dialog font}
dBox^.txSize := dfSize;				{Set font size}

FOR i := 4 TO 12 DO				{Loop through all the controls}
BEGIN
  GetDItem(dBox, i, j, h, r);			{Need the control handle}
  BSET(LongInt(ControlHandle(h)^^.contrlDefProc), 27);
						{Change the control variant}
END; {FOR}

ShowWindow(dBox);				{Now show the dialog}

WARNING -- This will not work with A/UX because they have moved the control's
variant to another location. There is a new call, GetCVariant, but there is
no SetCVariant that I know of. 

WARNING TWO -- This trick depends on the CDEFs not caring which variant it
is going to draw at initialization time. If Apple changes this, it will most
likely break.

Given these two problems, it works now, but the official and most likely not
to break way is to use a CNTL resource for each control in the dialog box
a setting the variant to use the window's font.

-- 
 Clay Maeckel         *   UUCP: {ames,apple,portal,sun,voder}!claris!clay
 (I know nothing!)    *   Internet:  clay@claris.com  *  GEnie: C.MAECKEL
 Claris Corporation   *   AppleLink: Maeckel1   *   CompuServe: 73057,255

mnkonar@pavo.SRC.Honeywell.COM (Murat N. Konar) (10/28/88)

> (stuff about changing the font of dialog items)

Using SetDAFont only affects static and editable text items.  To change the
font of other items you could write CDEFs that replace the statndard CDEFs
and behave identically except that they use a different font.  You could
also (HACK ALERT!) temporarily change the system font ( did I say that?)
before drawing the dialog.
______________________________________________________________________
Have a day. :^|
Murat N. Konar mnkonar@ely.UUCP
Honeywell Systems & Research Center, Camden, MN
g