home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 December / macformat-031.iso / mac / Shareware City / Developers / CopyBits Demo 3.1 / System Utilities.c < prev    next >
Encoding:
Text File  |  1995-06-02  |  1.1 KB  |  72 lines  |  [TEXT/MMCC]

  1. // System Utilities.c v1.0
  2. //
  3. // by Kenneth Worley
  4. // Public Domain
  5. //
  6. // Contact me at: America Online: KNEworley
  7. //        internet: KNEworley@aol.com or kworley@fascination.com
  8. //
  9.  
  10. #include "System Utilities.h"
  11.  
  12. #define MTopLeft(r)                (* (Point*) &(r.top) )
  13.  
  14. void InitToolbox( void )
  15. {
  16.     /* Initialize the Mac Toolbox Managers */
  17.     
  18.     InitGraf((Ptr) &qd.thePort);
  19.     InitFonts();
  20.     InitWindows();
  21.     InitMenus();
  22.     FlushEvents(everyEvent,0);
  23.     TEInit();
  24.     InitDialogs(0L);
  25.     InitCursor();
  26. }
  27.  
  28. short    GetSysVersion( void )
  29. {
  30.     SysEnvRec        env;
  31.     
  32.     SysEnvirons( 2, &env );
  33.     
  34.     if ( env.systemVersion >= 0x0700 )
  35.         return 7;
  36.     else if ( env.systemVersion >= 0x0600 )
  37.         return 6;
  38.     else
  39.         return 0;
  40. }
  41.  
  42. Boolean HasColorQuickDraw( void )
  43. {
  44.     SysEnvRec        env;
  45.     
  46.     SysEnvirons( 2, &env );
  47.     
  48.     return env.hasColorQD;
  49. }
  50.  
  51. GDHandle WindowDevice( WindowPtr winPtr )
  52. {
  53.     GDHandle        theDevice;
  54.     Point            targetPt;
  55.     
  56.     targetPt = MTopLeft( ((WindowPeek)winPtr)->port.portRect );
  57.     
  58.     theDevice = GetDeviceList();
  59.     while ( !PtInRect( targetPt, &((**theDevice).gdRect) ) )
  60.     {
  61.         theDevice = GetNextDevice( theDevice );
  62.         if ( theDevice == NULL )
  63.         {
  64.             theDevice = GetMainDevice();
  65.             break;
  66.         }
  67.     }
  68.     
  69.     return theDevice;
  70. }
  71.  
  72.