csparr@cybaswan.UUCP (Jason Parr) (04/06/90)
I have been trying to set the font of an editText item in a dialog box by getting the handle to the item and setting its txFont field. The problem is the dialog seems to just ignore this and carry on using the system font. Is it possible to change the font in a dialog, if so how do you do it? Thanks in advance for any help received. -- _____ ___ ____ Jason Parr Janet: csparr@uk.ac.swan.pyr / /__/ /___ U.C. of Swansea ARPA: csparr@pyr.swan.ac.uk __/ / / ___/ Wales. U.K.
amanda@mermaid.intercon.com (Amanda Walker) (04/09/90)
In article <1739@cybaswan.UUCP>, csparr@cybaswan.UUCP (Jason Parr) writes: > Is it possible to change the font in a dialog, if so how do you do it? The easiest way to change the font of a particular item is to make it a user item and maintain your own TEHandle for it. If it's the only editText item in the dialog, it's pretty easy, but if you have other fields that are handled by the Dialog Manager, you have to go through some hoops to avoid getting two blinking insertion points... It's too bad ictb's don't work on the Plus or SE... -- Amanda Walker, InterCon Systems Corporation -- "Y'know, you can't have, like, a light, without a dark to stick it in... You know what I'm sayin'?" --Arlo Guthrie
mxmora@unix.SRI.COM (Matt Mora) (04/10/90)
In article <1990Apr9.045703.6950@intercon.com> amanda@mermaid.intercon.com (Amanda Walker) writes: >In article <1739@cybaswan.UUCP>, csparr@cybaswan.UUCP (Jason Parr) writes: >> Is it possible to change the font in a dialog, if so how do you do it? > >The easiest way to change the font of a particular item is to make it >a user item and maintain your own TEHandle for it. If it's the only >editText item in the dialog, it's pretty easy, but if you have other >fields that are handled by the Dialog Manager, you have to go through some >hoops to avoid getting two blinking insertion points... > >It's too bad ictb's don't work on the Plus or SE... > >-- >Amanda Walker, InterCon Systems Corporation >-- Am I missing something? SetDAFont(fontNum); Inside Mac Page 412. Won't this call set the font for you? I've done his before and it worked. Now if you want to change the font and the size then it get a little trickier. Below is some code from a fkey that I wrote: setdafont(1); mydlg := GetNewDialog(128, nil, pointer(-1)); {bunch o' error checking. deleted for clarity} dpeek := DialogPeek(mydlg); dpeek^.textH^^.txsize := 9; This works for me. If you want only one thing in a dialog to be a certain font then you have to go the Dialog filter route. -- ___________________________________________________________ Matthew Mora SRI International mxmora@unix.sri.com ___________________________________________________________
nf0i+@andrew.cmu.edu (Norman William Franke, III) (04/10/90)
>SetDAFont(fontNum); Inside Mac Page 412.
This is what I usually do, as well as, what seemed the easiest to me: I
make a PICT resource, and put that in the dialog. I haven't had any
problems with this method. Plus you can make them really complex! And if
you use something like MacDraw, it will (I think) store the QD commands,
and not the bitmaps, saving space.
-Norman Franke
nf0i+@andrew.cmu.edu
aries@rhi.hi.is (Reynir Hugason) (04/11/90)
>>I have been trying to set the font of an editText item in a dialog box by >>getting the handle to the item and setting its txFont field. The problem is >>the dialog seems to just ignore this and carry on using the system font. >>Is it possible to change the font in a dialog, if so how do you do it? Of course it is possible but how you do it really depends on what requirements you have. Here are three possible solutions. 1. If you have many editText items and just want to change one of them you can use the ictb or the method Amanda suggested with the userItems. Perhaps its better, if you have many editTexts, to throw them away altogether and use userItems instead; but then again perhaps its even better to throw the dialog manager away in such a case and simply do-it-yourself, because it isn't a user-interface (at least not a very good one :-)). 2. If you want to change all of the editText items its best to do the following: myDialog:=GetNewDialog(whatEver,NIL,Pointer(-1)); TextFont(myNewFont); TextSize(myNewSize); TextFace(myNewFace); GetFontInfo(fInfo); WITH DialogPeek(myDialog)^.textH, fInfo DO BEGIN txFont:=myNewFont; txSize:=myNewSize; txFace:=myNewFace; { you can skip this lineHeight calculation but we } { european users will hate you for it! } fontAscent:=ascent; lineHeight:=ascent+descent+leading; END; ShowWindow(myDialog); If you want the editText to be in say GENEVA 9pt and the static to be in CHICAGO 12pt you could make all the static text into PICTs and use the method described above. 3. You can call SetDAFont; BUT NOTE WHAT IM HAS TO SAY ABOUT IT! For subsequently created dialogs and alerts, SetDAFont causes the font of the dialog or alert window's grafPort to be set to the font having the specified font number. THIS ALTERNATIVE IS NOT A VERY GOOD ONE, at least I don't think it is! For example if you have to do some data validation: When the user enters something invalid into your editText items and clicks on OK you will want to display a friendly alert box in order to inform the poor fellow of his/her mistakes. This means you will have to call SetDAFont twice!! I hope this answers your question. ============================================================================== Mimir R. (aries@rhi.hi.is) | Taeknigardur, Dunhaga 5 | Programmers get overlaid (ehem, that is to say..) IS-105, Reykjavik | ICELAND | DISCLAIMER: Who me?! ==============================================================================