home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / C++ / Applications / PICSee Dust 1.01 / Primary Source / AboutDialog.cpp next >
Encoding:
C/C++ Source or Header  |  1995-11-13  |  3.8 KB  |  134 lines  |  [TEXT/CWIE]

  1. #include "AboutDialog.h"
  2. #include "main.h"                    // For AppInBackground()
  3. #include "PICSDialogs.h"
  4. #include "DialogUtils.h"
  5. #include "MovableModalDialogs.h"
  6.  
  7. #include "SoundUtils.h"
  8. #include "Monitors.h"                // For Place()
  9. #include "KeyUtils.h"                // To handle key-down events
  10.  
  11. // ---------------------------------------------------------------------------
  12.  
  13. static void DisposeAboutDialog(DialogPtr aboutDlog);
  14. static void AboutDialogHandleHit(DialogPtr aboutDlog, EventRecord *theEvt, short itemHit);
  15. static Boolean AboutDialogHandleKey(DialogPtr aboutDlog, EventRecord *theEvt);
  16. static void AboutDialogHandleUpdate(DialogPtr aboutDlog, EventRecord *theEvt, Boolean frontMost);
  17. static void AboutDialogHandleActivate(DialogPtr aboutDlog, Boolean activate);
  18. static void AboutDialogHandleIdle(DialogPtr aboutDlog);
  19.  
  20. // ---------------------------------------------------------------------------
  21.  
  22. enum {
  23.     kAboutSndChannel = 1,
  24.  
  25.     kAboutDialogID = 1972,
  26.     
  27.     kAboutSndID = kAboutDialogID,
  28.     
  29.     kAboutDialog_AboutText = 1,
  30.     kAboutDialog_WitchBrew,
  31.     kAboutDialog_Filmstrip,
  32.     kAboutDialog_PICSeeDust
  33. };
  34.  
  35. static Handle sAboutSnd = NULL;
  36.  
  37. // ---------------------------------------------------------------------------
  38.  
  39. void DoAbout() {
  40.     DialogPtr aboutDlog = GetNewDialog(kAboutDialogID, NULL, (WindowPtr)-1);
  41.     SetPort(aboutDlog);
  42.     TextMode(srcCopy);
  43.     ForeColor(whiteColor);
  44.     BackColor(blackColor);
  45.     TextFont(geneva);
  46.     TextSize(9);
  47.     
  48.     RegisterMovableModalDialog(aboutDlog,
  49.         AboutDialogHandleHit,
  50.         AboutDialogHandleKey,
  51.         AboutDialogHandleUpdate,
  52.         AboutDialogHandleActivate,
  53.         AboutDialogHandleIdle);
  54.  
  55.     sAboutSnd = GetResource('SND!', kAboutSndID);
  56.     Place(aboutDlog, kCenterOnDeepDevice);
  57.  
  58.     if (sAboutSnd != NULL && CreateSndChannel(kAboutSndChannel) == noErr) {
  59.         PlayAsynch(sAboutSnd, kAboutSndChannel);
  60.     }
  61.     else {
  62.         ReleaseResource(sAboutSnd);
  63.         sAboutSnd = NULL;
  64.     }
  65. } // END DoAbout
  66.  
  67. // ---------------------------------------------------------------------------
  68.  
  69. void DisposeAboutDialog(DialogPtr aboutDlog) {
  70.     if (sAboutSnd != NULL) {
  71.         SndStopSoftly(kAboutSndChannel);
  72.         HUnlock(sAboutSnd);
  73.         ReleaseResource(sAboutSnd);
  74.         DisposeSndChannel(kAboutSndChannel);
  75.     }
  76.  
  77.     DisposeDialog(aboutDlog);
  78.     UnregisterMovableModalDialog(aboutDlog);
  79. } // END DisposeAboutDialog
  80.  
  81. // ---------------------------------------------------------------------------
  82.  
  83. void AboutDialogHandleHit(DialogPtr aboutDlog, EventRecord *theEvt, short itemHit) {
  84.     switch(itemHit) {
  85.         case kAboutDialog_WitchBrew:
  86.             if (SndDone(kAboutSndChannel))
  87.                 PlayAsynch(sAboutSnd, kAboutSndChannel);
  88.         break;
  89.     
  90.         default:
  91.             DisposeAboutDialog(aboutDlog);
  92.         break;
  93.     }
  94. } // END AboutDialogHandleHit
  95.  
  96. // ---------------------------------------------------------------------------
  97.  
  98. Boolean AboutDialogHandleKey(DialogPtr aboutDlog, EventRecord *theEvt) {
  99.     return(false);
  100. } // END AboutDialogHandleKey
  101.  
  102. // ---------------------------------------------------------------------------
  103.  
  104. void AboutDialogHandleUpdate(DialogPtr aboutDlog, EventRecord *theEvt, Boolean frontMost) {
  105.     if (!frontMost) {
  106.     }
  107.     RGBColor saveFore;
  108.     RGBColor textColor = { kDarkGrayRGB, kDarkGrayRGB, kDarkGrayRGB };
  109.     Rect itemR;
  110.  
  111.     GetForeColor(&saveFore);
  112.     RGBForeColor(&textColor);
  113.     GetDItemRect(aboutDlog, 1, &itemR);
  114.     MoveTo(itemR.left, itemR.top);
  115.     DrawString("\pPICSee Dust (c)1995 by ");
  116.     TextFace(bold);
  117.     DrawString("\pHiep Dam");
  118.     TextFace(0);
  119.     MoveTo(itemR.left, itemR.bottom);
  120.     DrawString("\pAll Rights Reserved");
  121.     RGBForeColor(&saveFore);
  122. } // END AboutDialogHandleUpdate
  123.  
  124. // ---------------------------------------------------------------------------
  125.  
  126. void AboutDialogHandleActivate(DialogPtr aboutDlog, Boolean activate) {
  127.     if (!activate) {
  128.     }
  129. } // END AboutDialogHandleActivate
  130.  
  131. // ---------------------------------------------------------------------------
  132.  
  133. void AboutDialogHandleIdle(DialogPtr aboutDlog) {
  134. } // END AboutDialogHandleIdle