[comp.sys.mac.programmer] How do I change Dialog font size?

wolf@mel.cipl.uiowa.edu (10/10/90)

How does one change the size of editable and static text items in dialogs?

I can use SetDAFont to change it to the font I wish, but it is always stuck at
12 point size from the systems default.  I have IM I but it doesn't speak about
changing the font size in dialogs.

I only want to change it for STAT and EDIT text items, not the other controls.

All help much appreciated...thanks!

MJ Wolf

smoke@well.sf.ca.us (Nicholas Jackiw) (10/18/90)

In article <1990Oct9.125203.1@mel.cipl.uiowa.edu> wolf@mel.cipl.uiowa.edu writes:
>How does one change the size of editable and static text items in dialogs?
>
>I only want to change it for STAT and EDIT text items, not the other controls.
>MJ Wolf

Mark the DLOG as invisible in ResEdit, if you use GetNewDialog, or in
the call to NewDialog, if you use that.  Then, as soon as you have the
dialogPtr, use quickdraw to change the font.  e. g. 


   theDLOG:=GetNewDialog(129,nil,pointer(-1));
   if theDLOG<>nil then
     begin {Successfully allocated}
	SetPort(theDLOG);	{Switch to the invisible dialog window}
	TextFont(1);		{Switch to application font}
	TextSize(9);		{Size 9}
	ShowWindow(theDLOG);
	...
     end;

This will affect only the statText and editTxt font--buttons, etc, will
still use the system font.  Alternately, if you're willing to limit
yourself to color machines, check out the ictb resource description
in Inside Mac V.  It's convoluted, but will allow any combination of
fonts and sizes (and colors and styles) within a single dialog.



-- 
                              --- * ---
Nicholas Jackiw                Smoke@well.sf.ca.us | Jackiw@cs.swarthmore.edu
Key Curriculum Press, Inc.     Applelink: D3970    | (415) 548-2304
                              --- * ---

leonardr@svc.portal.com (Leonard Rosenthol) (10/19/90)

In article <21229@well.sf.ca.us>, smoke@well.sf.ca.us (Nicholas Jackiw) writes:
> In article <1990Oct9.125203.1@mel.cipl.uiowa.edu> wolf@mel.cipl.uiowa.edu writes:
> >How does one change the size of editable and static text items in dialogs?
> 
>    theDLOG:=GetNewDialog(129,nil,pointer(-1));
>    if theDLOG<>nil then
>      begin {Successfully allocated}
> 	SetPort(theDLOG);	{Switch to the invisible dialog window}
> 	TextFont(1);		{Switch to application font}
> 	TextSize(9);		{Size 9}
> 	ShowWindow(theDLOG);
> 	...
>      end;
> 
	Although this SHOULD work, it does not handle all appropriate situations.
In addition to doing this, you will also have to personally munge the dialog's
TERec, in order to set it up correctly.  Here is the routine that I use:

PROCEDURE SetDialogFontInfo(theDialog:DialogPtr: theFont, theSize:integer);
VAR
	myFInfo: FontInfo;
	myTEH: TEHandle;
BEGIN
	TextFont(theFont);  {name to num conversion done externally}
	TextSize(theSize);
	GetFontInfo(myFInfo);
	myTEH := DialogPeek(theDialog)^.textH;
	myTEH^^.txFont := GetAppFont;
	myTEH^^.txSize := 9;
	myTEH^^.lineHeight := myFInfo.ascent + myFInfo.descent + myFInfo.leading;
	myTEH^^.fontAscent := myFInfo.ascent;
	TECalText(myTEH);
END;

> This will affect only the statText and editTxt font--buttons, etc, will
> still use the system font.  Alternately, if you're willing to limit
> yourself to color machines, check out the ictb resource description
> in Inside Mac V.  It's convoluted, but will allow any combination of
> fonts and sizes (and colors and styles) within a single dialog.
> 
	Don't bother using ictb's.  As of System 6.0.5, Apple still does
not have them working correctly - especially for edit fields.
--
Leonard Rosenthol
Software Ventures Corp.
MicroPhone II Development Team