home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.mac.programmer
- Path: sparky!uunet!cis.ohio-state.edu!zaphod.mps.ohio-state.edu!news.acns.nwu.edu!news.ils.nwu.edu!engber
- From: engber@ils.nwu.edu (Mike Engber)
- Subject: Re: popup menus in non-system font
- Message-ID: <1992Sep11.152531.29176@ils.nwu.edu>
- Summary: some source
- Sender: usenet@ils.nwu.edu (Mr. usenet)
- Nntp-Posting-Host: aristotle.ils.nwu.edu
- Organization: The Institute for the Learning Sciences
- References: <1992Sep10.214027.7936@dcs.qmw.ac.uk>
- Date: Fri, 11 Sep 1992 15:25:31 GMT
- Lines: 77
-
-
- Yes, it seems that certain applications change the window manager's
- font setting and don't restore them. Leonard Rosenthal told me
- about this. The workaround he suggested was to reset them myself.
- After playing around with it a while I discovered that you had
- to reset them in both the window manager port AND the color window
- manager port (if colorQD is avail) - or under some circumstances
- (which I can't recall) there are problems.
-
- Anyway, here is my version of PopUpMenuSelect (written in THINK C)
- which let's you specify that you want the menu popped up in the
- current port's font and size.
-
- -ME
-
- ---
-
- extern short SysFontFam : 0x0BA6;
- extern short SysFontSize : 0x0BA8;
- extern long LastSpExtra : 0x0B4C;
- extern Ptr CurFMInput : 0x0988;
-
- long PupSelect(MenuHandle theMenu,Point popPt,short popUpItem,Boolean useWFont){
- short item;
- short oldSysFont = SysFontFam;
- short oldSysSize = SysFontSize;
- GrafPtr curPort;
-
- GetPort(&curPort);
-
- /* no need to muck around if the current font is already the system font */
- if(curPort->txFont==SysFontFam && curPort->txSize==SysFontSize){
- useWFont = false;
- }
-
- if(useWFont){
-
- { /* this hack fixes bugs caused by programs that mess up
- the WindowMgr port (e.g. MacWrite & Word)
- */
- GrafPtr wPort;
- SysEnvRec theWorld;
- GetWMgrPort(&wPort);
- SetPort(wPort);
- TextSize(0);
- TextFont(0);
- if(SysEnvirons(1,&theWorld) == noErr && theWorld.hasColorQD){
- CGrafPtr wCPort;
- GetCWMgrPort(&wCPort);
- SetPort((GrafPtr)wCPort);
- TextSize(0);
- TextFont(0);
- }
- SetPort(curPort);
- }
-
- SysFontFam = curPort->txFont;
- SysFontSize = curPort->txSize;
- LastSpExtra = -1L;
- CurFMInput = (Ptr)(-1L);
- SetItemMark(theMenu,popUpItem,'%');
- }else{
- CheckItem(theMenu,popUpItem,true);
- }
-
- item = PopUpMenuSelect(theMenu,popPt.v,popPt.h,popUpItem);
- CheckItem(theMenu,popUpItem,false);
-
- if(useWFont){
- SysFontSize = oldSysSize;
- SysFontFam = oldSysFont;
- LastSpExtra = -1L;
- CurFMInput = (Ptr)-1L;
- }
-
- return item;
- }
-