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 >
Wrap
Text File
|
1997-01-05
|
5KB
|
156 lines
{ ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊
// MiscellanyPascal.p
// ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊
//
// Miscellany source code is contained in three files, namely, UMain.p, UDemos.p and
// MiscellanyPascal.p Within the CodeWarrior project, MiscellanyPascal.p and UMain.p
// are in Segment 1, while UDemos.p is in Segment 2.
// (Note that this small program does not really require such segmentation; the
// code is segmented only to facilitate demonstration of the Segment Loader aspects.
//
// This program demonstrates:
//
// • The use of stubs in code segments, together with a function which uses those stubs
// to unlock code segments and make them purgeable.
//
// • The use of a status bar to graphically indicate the current status of a time-
// consuming operation.
//
// • The use of the Command-period key combination to terminate a time-consuming
// operation before it concludes.
//
// • The use of the Notification Manager to allow an application running in the
// background to communicate with the foreground application.
//
// • The determination of whether a particular application is currently the foreground
// application.
//
// • The use of the Color Picker to solicit a choice of colour from the user.
//
// • The determination of whether a particular trap is available.
//
// • Image drawing optimisation and window zooming in a multi-monitors environment.
//
// The program utilises the following resources:
//
// • An 'MBAR' resource, and 'MENU' resources for Apple, File, Edit and Demonstration
// menus (preload, non-purgeable).
//
// • A 'WIND' resource (purgeable) (initially visible) for a window in which graphics
// and information relevant to the demonstrations is displayed.
//
// • An 'ALRT' resource (purgeable), and associated 'DITL' resource (purgeable), for
// displaying a message to the user from within the Notification Manager demonstration.
//
// • A 'DLOG' resource (purgeable), and associated 'DITL' and 'dctb' resources
// (purgeable), for a dialog box in which the status bar is displayed.
//
// • 'icn#', 'ics4', and 'ics8' resources (non-purgeable) which contain the Miscellany
// application icon displayed in the Application menu during the Notification Manager
// demonstration.
//
// • A 'snd ' resource (non-purgeable) used in the Notification Manager demonstration.
//
// • A 'STR ' resource (non-purgeable) containing the text displayed in the alert box
// invoked by the Notification Manager.
//
// • A 'SIZE' resource with the acceptSuspendResumeEvents doesActivateOnFGSwitch,
// canBackgound, and is32BitCompatible flags set.
//
// ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ }
program MiscellanyPascal(input, output);
{ ………………………………………………………………………………………………………………… include the following Universal Interfaces }
uses
Windows, Fonts, Menus, TextEdit, Quickdraw, Dialogs, QuickdrawText, Processes, Types,
Memory, Events, TextUtils, ToolUtils, OSUtils, Devices,
{ ……………………………………………………………………………………………………………………… include the following user-defined units }
UMain, UDemos;
{ ……………………………………………………………………………………………………………………………………………………………………………………… global variables }
var
gColorQuickDraw : boolean; external;
gDone : boolean; external;
gWindowPtr : WindowPtr; external;
gProcessSerNum : ProcessSerialNumber; external;
gMultiMonitorsDrawDemo : boolean; external;
theErr : OSErr;
response : longint;
menubarHdl : Handle;
menuHdl : MenuHandle;
theEvent : EventRecord;
{ ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ start of main program }
begin
gMultiMonitorsDrawDemo := false;
{ …………………………………………………………………………………………………………………………………………………………………… initialise managers }
DoInitManagers;
{ …………………………………………………………………………………………………………………………………………………… check for Color QuickDraw }
gColorQuickDraw := true;
theErr := Gestalt(gestaltQuickdrawVersion, response);
if (response < gestalt8BitQD) then
gColorQuickDraw := false;
{ …………………………………………………………………………………………………………………………………………………… set up menu bar and menus }
menubarHdl := GetNewMBar(rMenubar);
if (menubarHdl = nil) then
ExitToShell;
SetMenuBar(menubarHdl);
DrawMenuBar;
menuHdl := GetMenuHandle(mApple);
if (menuHdl = nil) then
ExitToShell
else
AppendResMenu(menuHdl,'DRVR');
{ ………………………………………………………………………………………………………………………………………………………………………………………… open window }
if (gColorQuickDraw) then
gWindowPtr := GetNewCWindow(rWindow, nil, WindowPtr(-1))
else
gWindowPtr := GetNewWindow(rWindow, nil, WindowPtr(-1));
if (gWindowPtr = nil) then
ExitToShell;
SetPort(gWindowPtr);
TextSize(10);
{ ………………………………………………………………………………………………………… get process serial number of this process }
theErr := GetCurrentProcess(gProcessSerNum);
{ ……………………………………………………………………………………………………………………………………………………………………………… enter EventLoop }
gDone := false;
while not (gDone) do
begin
if (WaitNextEvent(everyEvent, theEvent, 30, nil)) then
DoEvents(theEvent)
else
DoNullEvent;
UnloadSegments;
end;
end.
{ ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ }