home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / PowerPlant / AGA Slider 1.0 / Sources / AGASliderApp.cp < prev    next >
Encoding:
Text File  |  1996-06-20  |  4.0 KB  |  156 lines  |  [TEXT/CWIE]

  1. // ===========================================================================
  2. //    <PP Starter Source>.cp         ©1994-1996 Metrowerks Inc. All rights reserved.
  3. // ===========================================================================
  4. //
  5. //    This file contains the starter code for a PowerPlant application
  6.  
  7. #include "AGASliderApp.h"
  8.  
  9. #include <LGrowZone.h>
  10. #include <LWindow.h>
  11. #include <PP_Messages.h>
  12. #include <PP_Resources.h>
  13. #include <PPobClasses.h>
  14. #include <UDrawingState.h>
  15. #include <UMemoryMgr.h>
  16. #include <URegistrar.h>
  17. #include <LEditField.h>
  18.  
  19. #include "CAGASlider.h"
  20. #include "CSliderDemoWindow.h"
  21.  
  22. // put declarations for resource ids (ResIDTs) here
  23.  
  24. const ResIDT    window_Sample        = 1;    // EXAMPLE
  25.  
  26.  
  27. // ===========================================================================
  28. //        • Main Program
  29. // ===========================================================================
  30.  
  31. void main(void)
  32. {
  33.                                     // Set Debugging options
  34.     SetDebugThrow_(debugAction_Alert);
  35.     SetDebugSignal_(debugAction_Alert);
  36.  
  37.     InitializeHeap(3);                // Initialize Memory Manager
  38.                                     // Parameter is number of Master Pointer
  39.                                     //   blocks to allocate
  40.     
  41.                                     // Initialize standard Toolbox managers
  42.     UQDGlobals::InitializeToolbox(&qd);
  43.     
  44.     new LGrowZone(20000);            // Install a GrowZone function to catch
  45.                                     //    low memory situations.
  46.  
  47.     GASliderApp    theApp;            // replace this with your App type
  48.     theApp.Run();
  49. }
  50.  
  51.  
  52. // ---------------------------------------------------------------------------
  53. //        • GASliderApp             // replace this with your App type
  54. // ---------------------------------------------------------------------------
  55. //    Constructor
  56.  
  57. GASliderApp::GASliderApp()
  58. {
  59.     // Register functions to create core PowerPlant classes
  60.     
  61.     RegisterAllPPClasses();
  62.     CAGASlider::Register();
  63.     CSliderDemoWindow::Register();
  64. }
  65.  
  66.  
  67. // ---------------------------------------------------------------------------
  68. //        • ~GASliderApp            // replace this with your App type
  69. // ---------------------------------------------------------------------------
  70. //    Destructor
  71. //
  72.  
  73. GASliderApp::~GASliderApp()
  74. {
  75. }
  76.  
  77. // ---------------------------------------------------------------------------
  78. //        • StartUp
  79. // ---------------------------------------------------------------------------
  80. //    This function lets you do something when the application starts up
  81. //    without a document. For example, you could issue your own new command.
  82.  
  83. void
  84. GASliderApp::StartUp()
  85. {
  86.     ObeyCommand(cmd_New, nil);        // EXAMPLE, create a new window
  87. }
  88.  
  89. // ---------------------------------------------------------------------------
  90. //        • ObeyCommand
  91. // ---------------------------------------------------------------------------
  92. //    Respond to commands
  93.  
  94. Boolean
  95. GASliderApp::ObeyCommand(
  96.     CommandT    inCommand,
  97.     void        *ioParam)
  98. {
  99.     Boolean        cmdHandled = true;
  100.  
  101.     switch (inCommand) {
  102.     
  103.         // Deal with command messages (defined in PP_Messages.h).
  104.         // Any that you don't handle will be passed to LApplication
  105.              
  106.         case cmd_New:
  107.                                         // EXAMPLE, create a new window
  108.             CSliderDemoWindow        *theWindow;
  109.             theWindow = (CSliderDemoWindow*)LWindow::CreateWindow(window_Sample, this);
  110.                 // Link the window to the controls.
  111.             UReanimator::LinkListenerToControls( theWindow, theWindow, window_Sample );
  112.     
  113.             theWindow->Show();
  114.             break;
  115.  
  116.  
  117.  
  118.         default:
  119.             cmdHandled = LApplication::ObeyCommand(inCommand, ioParam);
  120.             break;
  121.     }
  122.     
  123.     return cmdHandled;
  124. }
  125.  
  126. // ---------------------------------------------------------------------------
  127. //        • FindCommandStatus
  128. // ---------------------------------------------------------------------------
  129. //    This function enables menu commands.
  130. //
  131.  
  132. void
  133. GASliderApp::FindCommandStatus(
  134.     CommandT    inCommand,
  135.     Boolean        &outEnabled,
  136.     Boolean        &outUsesMark,
  137.     Char16        &outMark,
  138.     Str255        outName)
  139. {
  140.  
  141.     switch (inCommand) {
  142.     
  143.         // Return menu item status according to command messages.
  144.         // Any that you don't handle will be passed to LApplication
  145.  
  146.         case cmd_New:                    // EXAMPLE
  147.             outEnabled = true;            // enable the New command
  148.             break;
  149.  
  150.         default:
  151.             LApplication::FindCommandStatus(inCommand, outEnabled,
  152.                                                 outUsesMark, outMark, outName);
  153.             break;
  154.     }
  155. }
  156.