home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / mac / developm / source / glview.sit / glview.src / macinit.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-10-16  |  3.9 KB  |  165 lines

  1. /*
  2.   macmain.c
  3.     -- Macintosh initializations, then call real main
  4.  
  5. //Note: compile this segment as Main for generic 68000 processor, so it won't
  6. // fail on generic mac
  7.  
  8. */
  9.  
  10.  
  11. #pragma segment Main
  12.  
  13. #include <Types.h>
  14. #include <stdio.h>
  15. #include <ctype.h>
  16. #include <string.h>
  17.  
  18. #include <Quickdraw.h>
  19. #include <Memory.h>
  20. #include <OSUtils.h>
  21. #include <ToolUtils.h>
  22. #include <Windows.h>
  23. #include <Palettes.h>
  24. #include    <dialogs.h>
  25. #include    <StandardFile.h>
  26. #include    <Events.h>
  27. //#include <Menus.h>
  28. //#include <Fonts.h>
  29.  
  30. extern _DataInit();
  31.  
  32. //#define    VERSION            curSysEnvVers
  33. #define    nocolorID        130
  34. #define    no68020            133
  35. #define    no68881            132
  36. #define    no256              134
  37. #define    nosys6            135
  38.  
  39. void MacInit()
  40. {
  41. SysEnvRec        theWorld;
  42. OSErr                OSys;
  43. DialogPtr        crashDia;
  44. long                tick;
  45.  
  46.         UnloadSeg(_DataInit);
  47.     
  48.     InitGraf((Ptr)&qd.thePort);
  49.     //InitFonts();
  50.     InitWindows();
  51.     //InitMenus();
  52.     //TEInit();
  53.     InitDialogs(nil);
  54.     InitCursor();
  55.     
  56. /*______________________________________________________*/
  57. /*            If not right Machine then stop            */
  58. /*______________________________________________________*/
  59.     OSys = SysEnvirons( curSysEnvVers,&theWorld);
  60.     if(!theWorld.hasColorQD) {
  61.         crashDia = GetNewDialog (nocolorID, nil, (WindowPtr) -1);
  62.         DrawDialog (crashDia);
  63.         Delay (300, &tick);
  64.         ExitToShell();
  65.         }
  66.     if(theWorld.processor < env68020) {
  67.         crashDia = GetNewDialog (no68020, nil, (WindowPtr) -1);
  68.         DrawDialog (crashDia);
  69.         Delay (300, &tick);
  70.         ExitToShell();
  71.         }
  72.     /*if(!theWorld.hasFPU) {
  73.         crashDia = GetNewDialog (no68881, nil, (WindowPtr) -1);
  74.         DrawDialog (crashDia);
  75.         Delay (300, &tick);
  76.         ExitToShell();
  77.         }
  78.     if(theWorld.systemVersion < 0x0600) {
  79.         crashDia = GetNewDialog (nosys6, nil, (WindowPtr) -1);
  80.         DrawDialog (crashDia);
  81.         Delay (300, &tick);
  82.         ExitToShell();
  83.         }*/
  84.         
  85. #ifdef UnDeFineD
  86. /*______________________________________________________*/
  87. /*                     Set Rects                        */
  88. /*______________________________________________________*/
  89.     screenRect = qd.screenBits.bounds;
  90.     offLeft = 0;
  91.     offTop = 0;
  92.     offRight = screenRect.right;
  93.     offBottom = screenRect.bottom;
  94.     SetRect(&BaseRect, 40, 60, 472, 282);
  95.     tempRgn = GetGrayRgn();
  96.     HLock ((Handle) tempRgn);
  97.     TotalRect = (**tempRgn).rgnBBox;
  98.     SetRect(&minRect, 80, 80, (**tempRgn).rgnBBox.right - 40, 
  99.                 (**tempRgn).rgnBBox.bottom - 40);
  100.     HUnlock ((Handle) tempRgn);
  101.  
  102. /*______________________________________________________*/
  103. /*        Open Window & set Palette & Picture           */
  104. /*______________________________________________________*/
  105.     theGDevice = GetMainDevice();
  106.     HLock ((Handle) theGDevice);
  107.     mycolors = (**(**theGDevice).gdPMap).pmTable;
  108.     numcolor = (**(**theGDevice).gdPMap).pixelSize;
  109.     HUnlock((Handle) theGDevice);
  110.     switch (numcolor) {
  111.         case 1:
  112.             numcolor = 2;
  113.             break;
  114.         case 2:
  115.             numcolor = 4;
  116.             break;
  117.         case 4:
  118.             numcolor = 16;
  119.             break;
  120.         case 8:
  121.             numcolor = 256;
  122.             break;
  123.         }
  124.     
  125.     myWindow = NewCWindow(nil, &BaseRect, "", TRUE, zoomDocProc, 
  126.                             (WindowPtr) -1, TRUE, 150);
  127.     SetPort((WindowPtr) myWindow);
  128.     DrawGrowIcon (myWindow);
  129.  
  130.     srcPalette = NewPalette (numcolor, mycolors, pmCourteous, 0);
  131.     SetPalette ((WindowPtr) myWindow, srcPalette, TRUE);
  132.     
  133. /*______________________________________________________*/
  134. /*                    Set menus                         */
  135. /*______________________________________________________*/
  136.     mymenu0 = GetMenu(appleID);
  137.     AddResMenu(mymenu0, 'DRVR');
  138.     InsertMenu(mymenu0,0);
  139.     mymenu1 = newmenu(129,"File");
  140.     appendmenu(mymenu1,"Start;Quit");
  141.     InsertMenu(mymenu1,0);
  142.     mymenu2 = newmenu(130,"Edit");
  143.     InsertMenu(mymenu2,0);
  144.     DrawMenuBar();
  145.  
  146. /*______________________________________________________*/
  147. /*                  Init variables                      */
  148. /*______________________________________________________*/
  149.     DoneFlag = FALSE;
  150.     yieldTime = 0;
  151.     return;
  152. #endif
  153.  
  154. }
  155.  
  156.  
  157. real_main(int argc, char  *argv[]);
  158.  
  159. main(int argc, char  *argv[])
  160. {
  161.     MacInit();
  162.     real_main(argc, argv);
  163. }
  164.  
  165.