home *** CD-ROM | disk | FTP | other *** search
- #include "AboutDialog.h"
- #include "main.h" // For AppInBackground()
- #include "PICSDialogs.h"
- #include "DialogUtils.h"
- #include "MovableModalDialogs.h"
-
- #include "SoundUtils.h"
- #include "Monitors.h" // For Place()
- #include "KeyUtils.h" // To handle key-down events
-
- // ---------------------------------------------------------------------------
-
- static void DisposeAboutDialog(DialogPtr aboutDlog);
- static void AboutDialogHandleHit(DialogPtr aboutDlog, EventRecord *theEvt, short itemHit);
- static Boolean AboutDialogHandleKey(DialogPtr aboutDlog, EventRecord *theEvt);
- static void AboutDialogHandleUpdate(DialogPtr aboutDlog, EventRecord *theEvt, Boolean frontMost);
- static void AboutDialogHandleActivate(DialogPtr aboutDlog, Boolean activate);
- static void AboutDialogHandleIdle(DialogPtr aboutDlog);
-
- // ---------------------------------------------------------------------------
-
- enum {
- kAboutSndChannel = 1,
-
- kAboutDialogID = 1972,
-
- kAboutSndID = kAboutDialogID,
-
- kAboutDialog_AboutText = 1,
- kAboutDialog_WitchBrew,
- kAboutDialog_Filmstrip,
- kAboutDialog_PICSeeDust
- };
-
- static Handle sAboutSnd = NULL;
-
- // ---------------------------------------------------------------------------
-
- void DoAbout() {
- DialogPtr aboutDlog = GetNewDialog(kAboutDialogID, NULL, (WindowPtr)-1);
- SetPort(aboutDlog);
- TextMode(srcCopy);
- ForeColor(whiteColor);
- BackColor(blackColor);
- TextFont(geneva);
- TextSize(9);
-
- RegisterMovableModalDialog(aboutDlog,
- AboutDialogHandleHit,
- AboutDialogHandleKey,
- AboutDialogHandleUpdate,
- AboutDialogHandleActivate,
- AboutDialogHandleIdle);
-
- sAboutSnd = GetResource('SND!', kAboutSndID);
- Place(aboutDlog, kCenterOnDeepDevice);
-
- if (sAboutSnd != NULL && CreateSndChannel(kAboutSndChannel) == noErr) {
- PlayAsynch(sAboutSnd, kAboutSndChannel);
- }
- else {
- ReleaseResource(sAboutSnd);
- sAboutSnd = NULL;
- }
- } // END DoAbout
-
- // ---------------------------------------------------------------------------
-
- void DisposeAboutDialog(DialogPtr aboutDlog) {
- if (sAboutSnd != NULL) {
- SndStopSoftly(kAboutSndChannel);
- HUnlock(sAboutSnd);
- ReleaseResource(sAboutSnd);
- DisposeSndChannel(kAboutSndChannel);
- }
-
- DisposeDialog(aboutDlog);
- UnregisterMovableModalDialog(aboutDlog);
- } // END DisposeAboutDialog
-
- // ---------------------------------------------------------------------------
-
- void AboutDialogHandleHit(DialogPtr aboutDlog, EventRecord *theEvt, short itemHit) {
- switch(itemHit) {
- case kAboutDialog_WitchBrew:
- if (SndDone(kAboutSndChannel))
- PlayAsynch(sAboutSnd, kAboutSndChannel);
- break;
-
- default:
- DisposeAboutDialog(aboutDlog);
- break;
- }
- } // END AboutDialogHandleHit
-
- // ---------------------------------------------------------------------------
-
- Boolean AboutDialogHandleKey(DialogPtr aboutDlog, EventRecord *theEvt) {
- return(false);
- } // END AboutDialogHandleKey
-
- // ---------------------------------------------------------------------------
-
- void AboutDialogHandleUpdate(DialogPtr aboutDlog, EventRecord *theEvt, Boolean frontMost) {
- if (!frontMost) {
- }
- RGBColor saveFore;
- RGBColor textColor = { kDarkGrayRGB, kDarkGrayRGB, kDarkGrayRGB };
- Rect itemR;
-
- GetForeColor(&saveFore);
- RGBForeColor(&textColor);
- GetDItemRect(aboutDlog, 1, &itemR);
- MoveTo(itemR.left, itemR.top);
- DrawString("\pPICSee Dust (c)1995 by ");
- TextFace(bold);
- DrawString("\pHiep Dam");
- TextFace(0);
- MoveTo(itemR.left, itemR.bottom);
- DrawString("\pAll Rights Reserved");
- RGBForeColor(&saveFore);
- } // END AboutDialogHandleUpdate
-
- // ---------------------------------------------------------------------------
-
- void AboutDialogHandleActivate(DialogPtr aboutDlog, Boolean activate) {
- if (!activate) {
- }
- } // END AboutDialogHandleActivate
-
- // ---------------------------------------------------------------------------
-
- void AboutDialogHandleIdle(DialogPtr aboutDlog) {
- } // END AboutDialogHandleIdle