home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / sys / mac / programm / 15348 < prev    next >
Encoding:
Text File  |  1992-09-11  |  3.0 KB  |  91 lines

  1. Newsgroups: comp.sys.mac.programmer
  2. Path: sparky!uunet!cis.ohio-state.edu!zaphod.mps.ohio-state.edu!news.acns.nwu.edu!news.ils.nwu.edu!engber
  3. From: engber@ils.nwu.edu (Mike Engber)
  4. Subject: Re: popup menus in non-system font
  5. Message-ID: <1992Sep11.152531.29176@ils.nwu.edu>
  6. Summary: some source
  7. Sender: usenet@ils.nwu.edu (Mr. usenet)
  8. Nntp-Posting-Host: aristotle.ils.nwu.edu
  9. Organization: The Institute for the Learning Sciences
  10. References: <1992Sep10.214027.7936@dcs.qmw.ac.uk>
  11. Date: Fri, 11 Sep 1992 15:25:31 GMT
  12. Lines: 77
  13.  
  14.  
  15. Yes, it seems that certain applications change the window manager's
  16. font setting and don't restore them. Leonard Rosenthal told me
  17. about this. The workaround he suggested was to reset them myself.
  18. After playing around with it a while I discovered that you had
  19. to reset them in both the window manager port AND the color window
  20. manager port (if colorQD is avail) - or under some circumstances
  21. (which I can't recall) there are problems.
  22.  
  23. Anyway, here is my version of PopUpMenuSelect (written in THINK C)
  24. which let's you specify that you want the menu popped up in the
  25. current port's font and size.
  26.  
  27. -ME
  28.  
  29. ---
  30.  
  31. extern  short   SysFontFam  : 0x0BA6;
  32. extern  short   SysFontSize : 0x0BA8;
  33. extern  long    LastSpExtra : 0x0B4C;
  34. extern  Ptr     CurFMInput  : 0x0988;
  35.  
  36. long PupSelect(MenuHandle theMenu,Point popPt,short popUpItem,Boolean useWFont){
  37.         short   item;
  38.         short   oldSysFont = SysFontFam;
  39.         short   oldSysSize = SysFontSize;
  40.         GrafPtr curPort;
  41.         
  42.         GetPort(&curPort);
  43.         
  44.         /* no need to muck around if the current font is already the system font */
  45.         if(curPort->txFont==SysFontFam && curPort->txSize==SysFontSize){
  46.             useWFont = false;
  47.         }
  48.         
  49.         if(useWFont){
  50.  
  51.             {   /* this hack fixes bugs caused by programs that mess up
  52.                     the WindowMgr port (e.g. MacWrite & Word)
  53.                  */
  54.                 GrafPtr     wPort;
  55.                 SysEnvRec   theWorld;
  56.                 GetWMgrPort(&wPort);
  57.                 SetPort(wPort);
  58.                 TextSize(0);
  59.                 TextFont(0);
  60.                 if(SysEnvirons(1,&theWorld) == noErr && theWorld.hasColorQD){
  61.                     CGrafPtr    wCPort;
  62.                     GetCWMgrPort(&wCPort);
  63.                     SetPort((GrafPtr)wCPort);
  64.                     TextSize(0);
  65.                     TextFont(0);
  66.                 }
  67.                 SetPort(curPort);
  68.             }
  69.  
  70.             SysFontFam  = curPort->txFont;
  71.             SysFontSize = curPort->txSize;
  72.             LastSpExtra = -1L;
  73.             CurFMInput  = (Ptr)(-1L);
  74.             SetItemMark(theMenu,popUpItem,'%');
  75.         }else{
  76.             CheckItem(theMenu,popUpItem,true);
  77.         }
  78.         
  79.         item = PopUpMenuSelect(theMenu,popPt.v,popPt.h,popUpItem);
  80.         CheckItem(theMenu,popUpItem,false);
  81.  
  82.         if(useWFont){
  83.             SysFontSize = oldSysSize;
  84.             SysFontFam  = oldSysFont;
  85.             LastSpExtra = -1L;
  86.             CurFMInput  = (Ptr)-1L;
  87.         }
  88.  
  89.     return item;
  90. }
  91.