home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / C++ / Frameworks / Sprocket Framework DR2 / Sprocket Starter / SprocketStarter Code / PreferencesDialogWindow.cp < prev    next >
Encoding:
Text File  |  1996-06-15  |  3.2 KB  |  142 lines  |  [TEXT/CWIE]

  1. /*
  2.  
  3.     File:        PreferencesDialogWindow.cp
  4.     Project:    Sample code for Sprocket Framework 1.1 (DR2), released 6/15/96
  5.     Contains:    A simple dialog window recipe
  6.     To Do:        Whatever your heart desires
  7.  
  8.     Sprocket Major Contributors:
  9.     ----------------------------
  10.     Dave Falkenburg, producer of Sprocket 1.0
  11.     Bill Hayden,     producer of Sprocket 1.1
  12.     Steve Sisak,     producer of the upcoming Sprocket 2.0
  13.     
  14.     Pete Alexander        Steve Falkenburg    Randy Thelen
  15.     Eric Berdahl        Nitin Ganatra        Chris K. Thomas
  16.     Marshall Clow        Dave Hershey        Leonard Rosenthal
  17.     Tim Craycroft        Dave Mark            Dean Yu
  18.     David denBoer        Gary Powell
  19.     Cameron Esfahani    Jon Summers            Apple Computer, Inc.
  20.         
  21.     Comments, Additions, or Corrections:
  22.     ------------------------------------
  23.     Bill Hayden, Nikol Software <nikol@codewell.com>
  24.  
  25. */
  26.  
  27.  
  28. #include "Sprocket.h" // for gHasAppleGuide
  29. #include "PreferencesDialogWindow.h"
  30. #include "UGuide.h"
  31. #include "UDialog.h"
  32.  
  33.  
  34. #if GENERATINGPOWERPC
  35.  
  36. #include "SpokenCommandHandler.h"
  37.  
  38. extern TSpokenCommandHandler*    SCH;
  39.  
  40. #endif
  41.  
  42.  
  43.  
  44. TPreferencesDialogWindow::TPreferencesDialogWindow() : TDialogWindow(kPreferencesDialogTemplateID)
  45. {
  46.     //    Because TDialogWindow::TDialogWindow has already created the dialog,
  47.     //    this is a great place to grab settings & setup the contents of the
  48.     //    dialog.
  49.     //
  50.     //    Of course, if you do this you probably want to mark the DLOG
  51.     //    as not initially visible, then call ShowWindow just before returning.
  52.     //
  53.     //    You should also setup UPPs for any user items in here, too. 
  54.  
  55.     //    Set up the default buttons
  56.     //    Isn’t it neat that these also work for modeless dialogs?
  57.     
  58.     this->CreateWindow(kModalWindow);
  59.     
  60.     if (fWindow)
  61.         {
  62.         SetDialogDefaultItem(this->GetDialogRef(), 1);
  63.         SetDialogCancelItem(this->GetDialogRef(), 2);
  64.         SetDialogTracksCursor(this->GetDialogRef(), true);
  65.         }
  66.         
  67.     if (!gHasAppleGuide)
  68.         {
  69.         SetControlActive(this->GetDialogRef(), 3, false);    // disable guide item
  70.         }
  71.  
  72. #if GENERATINGPOWERPC        
  73.     if (!SCH)
  74.         {
  75.         SetControlActive(this->GetDialogRef(), 4, false);    // disable SR item
  76.         }
  77.     else
  78.         {
  79.         if (SCH->IsListening())
  80.             ToggleCheckBox(this->GetDialogRef(), 4);
  81.         }
  82. #else
  83.     SetControlActive(this->GetDialogRef(), 4, false);    // disable SR item
  84. #endif
  85. }
  86.  
  87.  
  88.  
  89. void TPreferencesDialogWindow::ItemHit(short theItem)
  90. {
  91.     OSErr    err;
  92.     
  93.     
  94.     switch (theItem)
  95.         {
  96.         case    ok:
  97. #if GENERATINGPOWERPC
  98.             if (SCH)
  99.                 {
  100.                 short state = GetControlSetting(this->GetDialogRef(), 4);
  101.                 
  102.                 if (state && !SCH->IsListening())
  103.                     SCH->StartListening();
  104.                 else if (!state && SCH->IsListening())
  105.                     SCH->StopListening();
  106.                     
  107.                 }
  108. #endif
  109.         case    cancel:
  110.             this->Close();
  111.             delete this;
  112.             break;
  113.             
  114.         case    3:    // our Guide item
  115.             err = OpenGuideFile();
  116.             if (err == kAGErrDatabaseNotAvailable)
  117.                 ErrorAlert(131, 1, false);
  118.             else if (err)
  119.                 ErrorReporter(err, __FILE__, __LINE__);
  120.             break;
  121.  
  122. #if GENERATINGPOWERPC
  123.         case    4:    // Enable speech recognition
  124.             ToggleCheckBox(this->GetDialogRef(), 4);
  125.             break;
  126. #endif
  127.  
  128.         default:
  129.             break;
  130.         }
  131. }
  132.  
  133.  
  134.  
  135. void TPreferencesDialogWindow::AdjustMenusBeforeMenuSelection(void)
  136. {
  137.     gMenuBar->EnableCommand ( cCut,            true );
  138.     gMenuBar->EnableCommand ( cCopy,        true );
  139.     gMenuBar->EnableCommand ( cPaste,        true );
  140.     gMenuBar->EnableCommand ( cClear,        true );
  141.     gMenuBar->EnableCommand ( cSelectAll,    true );
  142. }