home *** CD-ROM | disk | FTP | other *** search
/ ftp.mactech.com 2010 / ftp.mactech.com.tar / ftp.mactech.com / macintosh-pascal / macintoshp-1.2-demos.sit.hqx / chap22pascal_demo / MiscellanyPascal.p < prev    next >
Text File  |  1997-01-05  |  5KB  |  156 lines

  1. { ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊
  2. // MiscellanyPascal.p
  3. // ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊
  4. // 
  5. // Miscellany source code is contained in three files, namely, UMain.p, UDemos.p and
  6. // MiscellanyPascal.p  Within the CodeWarrior project, MiscellanyPascal.p and UMain.p
  7. // are in Segment 1, while UDemos.p is in Segment 2.  
  8. // (Note that this small program does not really require such segmentation; the 
  9. // code is segmented only to facilitate demonstration of the Segment Loader aspects.
  10. //
  11. // This program demonstrates:
  12. //
  13. // •    The use of stubs in code segments, together with a function which uses those stubs
  14. //        to unlock code segments and make them purgeable. 
  15. //
  16. // •    The use of a status bar to graphically indicate the current status of a time-
  17. //        consuming operation.
  18. //
  19. // •    The use of the Command-period key combination to terminate a time-consuming
  20. //        operation before it concludes.
  21. //
  22. // •    The use of the Notification Manager to allow an application running in the 
  23. //        background to communicate with the foreground application.
  24. //
  25. // •    The determination of whether a particular application is currently the foreground
  26. //        application.
  27. //
  28. // •    The use of the Color Picker to solicit a choice of colour from the user.
  29. //
  30. // •    The determination of whether a particular trap is available.
  31. //
  32. // •    Image drawing optimisation and window zooming in a multi-monitors environment. 
  33. //
  34. // The program utilises the following resources:
  35. //
  36. // •    An 'MBAR' resource, and 'MENU' resources for Apple, File, Edit and Demonstration
  37. //        menus (preload, non-purgeable).
  38. //
  39. // •    A 'WIND' resource (purgeable) (initially visible) for a window in which graphics
  40. //        and information relevant to the demonstrations is displayed.
  41. //
  42. // •    An 'ALRT' resource (purgeable), and associated 'DITL' resource (purgeable), for
  43. //        displaying a message to the user from within the Notification Manager demonstration.
  44. //
  45. // •    A 'DLOG' resource (purgeable), and associated 'DITL' and 'dctb' resources
  46. //        (purgeable), for a dialog box in which the status bar is displayed.
  47. //
  48. // •    'icn#', 'ics4', and 'ics8' resources (non-purgeable) which contain the Miscellany
  49. //        application icon displayed in the Application menu during the Notification Manager
  50. //        demonstration.
  51. //
  52. // •    A 'snd ' resource (non-purgeable) used in the Notification Manager demonstration.
  53. //
  54. // •    A 'STR ' resource (non-purgeable) containing the text displayed in the alert box
  55. //        invoked by the Notification Manager.
  56. //
  57. // •    A 'SIZE' resource with the acceptSuspendResumeEvents doesActivateOnFGSwitch,
  58. //        canBackgound, and is32BitCompatible flags set.
  59. //
  60. // ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ }
  61.  
  62. program MiscellanyPascal(input, output);
  63.  
  64. { ………………………………………………………………………………………………………………… include the following Universal Interfaces }
  65.  
  66. uses
  67.  
  68.     Windows, Fonts, Menus, TextEdit, Quickdraw, Dialogs, QuickdrawText, Processes, Types,
  69.     Memory, Events, TextUtils, ToolUtils, OSUtils, Devices,
  70.  
  71. { ……………………………………………………………………………………………………………………… include the following user-defined units }
  72.  
  73.     UMain, UDemos;
  74.  
  75. { ……………………………………………………………………………………………………………………………………………………………………………………… global variables }
  76.  
  77. var
  78.  
  79. gColorQuickDraw : boolean; external;
  80. gDone : boolean; external;
  81. gWindowPtr : WindowPtr; external;
  82. gProcessSerNum : ProcessSerialNumber; external;
  83. gMultiMonitorsDrawDemo : boolean; external;
  84.  
  85. theErr : OSErr;
  86. response : longint;
  87. menubarHdl : Handle;
  88. menuHdl : MenuHandle;
  89. theEvent : EventRecord;
  90.  
  91. { ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ start of main program }
  92.  
  93. begin
  94.  
  95.     gMultiMonitorsDrawDemo := false;
  96.  
  97.     { …………………………………………………………………………………………………………………………………………………………………… initialise managers }
  98.  
  99.     DoInitManagers;
  100.  
  101.     { …………………………………………………………………………………………………………………………………………………… check for Color QuickDraw }
  102.  
  103.     gColorQuickDraw := true;
  104.  
  105.     theErr := Gestalt(gestaltQuickdrawVersion, response);
  106.     if (response < gestalt8BitQD) then
  107.         gColorQuickDraw := false;
  108.  
  109.     { …………………………………………………………………………………………………………………………………………………… set up menu bar and menus }
  110.     
  111.     menubarHdl := GetNewMBar(rMenubar);
  112.     if (menubarHdl = nil) then
  113.         ExitToShell;
  114.     SetMenuBar(menubarHdl);
  115.     DrawMenuBar;
  116.  
  117.     menuHdl := GetMenuHandle(mApple);
  118.     if (menuHdl = nil) then
  119.         ExitToShell
  120.     else
  121.         AppendResMenu(menuHdl,'DRVR');
  122.  
  123.     { ………………………………………………………………………………………………………………………………………………………………………………………… open window } 
  124.  
  125.     if (gColorQuickDraw) then
  126.         gWindowPtr := GetNewCWindow(rWindow, nil, WindowPtr(-1))
  127.     else
  128.         gWindowPtr := GetNewWindow(rWindow, nil, WindowPtr(-1));
  129.  
  130.     if (gWindowPtr = nil) then
  131.             ExitToShell;
  132.  
  133.     SetPort(gWindowPtr);
  134.     TextSize(10);
  135.  
  136.     { ………………………………………………………………………………………………………… get process serial number of this process }
  137.  
  138.     theErr := GetCurrentProcess(gProcessSerNum);    
  139.  
  140.     { ……………………………………………………………………………………………………………………………………………………………………………… enter EventLoop }
  141.  
  142.     gDone := false;
  143.  
  144.     while not (gDone) do
  145.         begin
  146.         if (WaitNextEvent(everyEvent, theEvent, 30, nil)) then
  147.             DoEvents(theEvent)
  148.         else
  149.             DoNullEvent;
  150.  
  151.         UnloadSegments;
  152.         end;
  153.         
  154. end.
  155.     
  156. { ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ }