home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ctcoll95.zip / PARALLEL / DROPS.P next >
Text File  |  1995-03-22  |  5KB  |  224 lines

  1. { MacPrint Spooler, ⌐ c╒t und C.Meyer 3/95.  Adaptierte DropShell von Leonard Rosenthol }
  2.  
  3. program DropShell;
  4.  
  5. {$IFC THINK_Pascal}
  6.     uses
  7.         AppleTalk, Processes, PPCToolbox, EPPC, Notification, AppleEvents, Script,
  8. { und die DropShell-Files }
  9.         DSGlobals, DSUtils, DSUserProcs, DSAppleEvents;
  10. {$ELSEC}
  11.     uses
  12.         MemTypes, QuickDraw, OSIntf, ToolIntf, Packages, GestaltEqu, Files, Aliases, AppleEvents,
  13. { und die DropShell-Files }
  14.         DSGlobals, DSUtils, DSUserProcs, DSAppleEvents;
  15. {$ENDC THINK_Pascal}
  16.  
  17. {$IFC THINK_Pascal}
  18. {$ELSEC}
  19. { Zwecks Segment-Entladung von %A5Init fƒr MPW }
  20.     procedure _DataInit;
  21.     EXTERNAL;
  22. {$ENDC THINK_Pascal}
  23.  
  24. { Von InitDialogs fƒr den "Retten"-Knopf in Absturzmeldung installiert }
  25.     procedure Panic;
  26.     begin
  27.         ExitToShell;
  28.     end;
  29.  
  30. {$S Initialize}
  31. { Initialisierung der Toolboxen }
  32.     procedure InitToolbox;
  33.     begin
  34. {$IFC THINK_Pascal}
  35. {$I-}
  36. {$ELSEC }
  37.         UnloadSeg(@_DataInit);        { speziell fƒr MPW }
  38. {$ENDC THINK_Pascal}
  39.  
  40.         InitGraf(@thePort);
  41.         InitFonts;
  42.         InitWindows;
  43.         InitMenus;
  44.         TEInit;
  45.         InitDialogs(@Panic);
  46.         InitCursor;
  47.         FlushEvents(everyEvent, 0);
  48.  
  49. { Die ƒblichen Masterpointer }
  50.         MoreMasters;
  51.         MoreMasters;
  52.     end;
  53.  
  54. { Der Name sagt½s auch hier...    }
  55.     procedure InitGlobals;
  56.         var
  57.             aLong: LongInt;
  58.     begin
  59.         gDone := FALSE;
  60.         gOApped := FALSE;
  61.         gHasAppleEvents := (Gestalt(gestaltAppleEventsAttr, aLong) = noErr);
  62.         gSplashScreen := nil;
  63.         gDocNo := 0;
  64.     end;
  65.  
  66. { Menƒs installieren }
  67.     procedure SetUpMenus;
  68.     begin
  69.         gAppleMenu := GetMenu(kAppleNum);
  70.         AddResMenu(gAppleMenu, 'DRVR');
  71.         InsertMenu(gAppleMenu, 0);
  72.         gFileMenu := GetMenu(kFileNum);
  73.         InsertMenu(gFileMenu, 0);
  74.         gOptionsMenu := GetMenu(kOptionsNum);
  75.         InsertMenu(gOptionsMenu, 0);
  76.         DrawMenuBar;
  77.     end;
  78.  
  79.  
  80. { Fenster und nichtmodale Dialoge installieren. Hier nur Status }
  81. { mit verankertem Bild anzeigen }
  82.     procedure InstallWindows;
  83.         var
  84.             picH: PicHandle;
  85.     begin
  86.         if (gSplashScreen = nil) then
  87.             begin
  88.                 picH := GetPicture(kPicID);
  89.                 if picH <> nil then
  90.                     begin
  91.                         gSplashScreen := GetNewWindow(kWindowID, nil, Pointer(-1));
  92.                         if gSplashScreen <> nil then
  93.                             begin
  94.                                 SetWindowPic(gSplashScreen, picH);
  95. { kommt sowieso irgendwann bei 'oapp': }
  96. { ShowWindow(gSplashScreen); }
  97.                             end;
  98.                     end;
  99.             end;
  100.     end;
  101.  
  102. {$S Main}
  103.  
  104. { Die ƒblichen Event-gesteuerten Routinen }
  105.     procedure ShowAbout;
  106.         var
  107.             itemHit: integer;
  108.     begin
  109.         itemHit := Alert(128, nil);
  110.     end;
  111.  
  112.     procedure DoMenu (retVal: longint);
  113.         var
  114.             menuID, itemID: integer;
  115.             itemStr: Str255;
  116.             refNum: integer;
  117.     begin
  118.         menuID := HiWord(retVal);
  119.         itemID := LoWord(retVal);
  120.  
  121.         case menuID of
  122.             kAppleNum: 
  123.                 if itemID = 1 then    {handle the about box}
  124.                     ShowAbout
  125.                 else                {get the DA's}
  126.                     begin
  127.                         GetItem(GetMHandle(kAppleNum), itemID, itemStr);
  128.                         refNum := OpenDeskAcc(itemStr);
  129.                     end;
  130.             kFileNum: 
  131.                 if itemID = 1 then    {Select File╔}
  132.                     SelectFile
  133.                 else
  134.                     SendQuitToSelf;    {send me a quit event}
  135.             kOptionsNum: 
  136.                 case itemID of
  137.                     kDOSItem: 
  138.                         begin
  139.                             gPrefs.PCkonv := not gPrefs.PCKonv;
  140.                             CheckItem(GetMenu(kOptionsNum), itemID, gPrefs.PCKonv);
  141.                         end;
  142.                     kPrintPortItem: 
  143.                         begin
  144.                             gPrefs.Port := itemID;
  145.                             CheckItem(GetMenu(kOptionsNum), kModemPortItem, false);
  146.                             SetItemMark(GetMenu(kOptionsNum), itemID, '');    { Raute }
  147.                         end;
  148.                     kModemPortItem: 
  149.                         begin
  150.                             gPrefs.Port := itemID;
  151.                             CheckItem(GetMenu(kOptionsNum), kPrintPortItem, false);
  152.                             SetItemMark(GetMenu(kOptionsNum), itemID, '');    { Raute }
  153.                         end;
  154.                 end;
  155.             otherwise
  156. { Hier nichts zu tun }
  157.         end;
  158.         HiliteMenu(0);
  159.     end;
  160.  
  161.     procedure DoMouseDown (curEvent: EventRecord);
  162.         var
  163.             whichWindow: WindowPtr;
  164.             whichPart: integer;
  165.     begin
  166.         whichPart := FindWindow(curEvent.where, whichWindow);
  167.         case whichPart of
  168.             inMenuBar: 
  169.                 DoMenu(MenuSelect(curEvent.where));
  170.             inSysWindow: 
  171.                 SystemClick(curEvent, whichWindow);
  172.             inDrag: 
  173.                 DragWindow(whichWindow, curEvent.where, screenBits.bounds);
  174.             inDesk, inContent, inGrow, inGoAway, inZoomIn, inZoomOut: 
  175.                 ;
  176. { Hier nichts zu tun }
  177.             otherwise
  178. { Hier auch nicht }
  179.         end;
  180.     end;
  181.  
  182.     procedure DoKeyDown (curEvent: EventRecord);
  183.         var
  184.             ch: char;
  185.     begin
  186.         ch := CHR(BitAnd(curEvent.message, charCodeMask));
  187.         if BitAnd(curEvent.modifiers, cmdKey) <> 0 then
  188.             DoMenu(MenuKey(ch));
  189.     end;
  190.  
  191. { Klassische Hauptschleife }
  192. begin
  193.     InitToolbox;
  194.     InitGlobals;
  195.     InstallWindows;
  196. { Anwendungsspezifische Datenstrukturen erstellen }
  197.     InitUserGlobals;
  198.     if gHasAppleEvents then
  199.         begin
  200.             InitAEVTStuff;
  201.             SetupMenus;
  202.             while not gDone do
  203.                 begin
  204.                     gWasEvent := WaitNextEvent(everyEvent, gEvent, 0, nil);
  205.                     if gWasEvent then
  206.                         begin
  207.                             case gEvent.what of
  208.                                 kHighLevelEvent: 
  209.                                     DoHighLevelEvent(gEvent);
  210.                                 mouseDown: 
  211.                                     DoMouseDown(gEvent);
  212.                                 keyDown, autoKey: 
  213.                                     DoKeyDown(gEvent);
  214.                                 otherwise
  215. { Nichts zu tun }
  216.                             end; { case }
  217.                         end;
  218.                 end; { while }
  219.         end
  220.     else
  221.         ErrorAlert(kErrStringID, kCantRunErr, 0);
  222. { Anwendungsspezifische Datenstrukturen entfernen }
  223.     DisposeUserGlobals;
  224. end.