home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C ++ / Applications / ScriptExplorer / LG_main.cp < prev    next >
Encoding:
Text File  |  1997-07-24  |  4.1 KB  |  159 lines  |  [TEXT/CWIE]

  1. // ===========================================================================
  2. //    <PP Starter Source>.cp         ©1994-1995 Metrowerks Inc. All rights reserved.
  3. // ===========================================================================
  4. //
  5. //    This file contains the starter code for a PowerPlant application
  6.  
  7. #include "LG_main.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 "CLGCommander.h"
  20. #include "CLG_CharsGrid.h"
  21. #include "CLG_CharInfo.h"
  22. #include "CLG_AnimBanner.h"
  23.  
  24.  
  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.     LGApp    theApp;            // replace this with your App type
  48.     theApp.Run();
  49. }
  50.  
  51.  
  52. // ---------------------------------------------------------------------------
  53. //        • LGApp             // replace this with your App type
  54. // ---------------------------------------------------------------------------
  55. //    Constructor
  56.  
  57. LGApp::LGApp()
  58. {
  59.     // Register functions to create core PowerPlant classes
  60.     
  61.     RegisterAllPPClasses();
  62.  
  63.     URegistrar::RegisterClass(CLG_CharsGrid::class_ID,        (ClassCreatorFunc)CLG_CharsGrid::CreateDisplayStream);
  64.     URegistrar::RegisterClass(CLG_CharInfo::class_ID,        (ClassCreatorFunc)CLG_CharInfo::CreateDisplayStream);
  65.     URegistrar::RegisterClass(CLG_AnimBanner::class_ID,        (ClassCreatorFunc)CLG_AnimBanner::CreateDisplayStream);
  66.  
  67. }
  68.  
  69.  
  70. // ---------------------------------------------------------------------------
  71. //        • ~LGApp            // replace this with your App type
  72. // ---------------------------------------------------------------------------
  73. //    Destructor
  74. //
  75.  
  76. LGApp::~LGApp()
  77. {
  78. }
  79.  
  80. // ---------------------------------------------------------------------------
  81. //        • StartUp
  82. // ---------------------------------------------------------------------------
  83. //    This function lets you do something when the application starts up. 
  84. //    For example, you could issue your own new command, or respond to a system
  85. //  oDoc (open document) event.
  86.  
  87. void
  88. LGApp::StartUp()
  89. {
  90.     // set FontForce false and leave it false
  91.     SetScriptManagerVariable( smFontForce, false);
  92.     
  93.     //ObeyCommand(cmd_New, nil);        // EXAMPLE, create a new window
  94.     mCmdr = new CLGCommander( this);
  95.     mCmdr->CreateWindow();
  96.     
  97. }
  98.  
  99. // ---------------------------------------------------------------------------
  100. //        • ObeyCommand
  101. // ---------------------------------------------------------------------------
  102. //    Respond to commands
  103.  
  104. Boolean
  105. LGApp::ObeyCommand(
  106.     CommandT    inCommand,
  107.     void        *ioParam)
  108. {
  109.     Boolean        cmdHandled = true;
  110.  
  111.     switch (inCommand) {
  112.     
  113.         // Deal with command messages (defined in PP_Messages.h).
  114.         // Any that you don't handle will be passed to LApplication
  115.              
  116.         case cmd_New:
  117.             break;
  118.  
  119.         default:
  120.             cmdHandled = LApplication::ObeyCommand(inCommand, ioParam);
  121.             break;
  122.     }
  123.     
  124.     return cmdHandled;
  125. }
  126.  
  127. // ---------------------------------------------------------------------------
  128. //        • FindCommandStatus
  129. // ---------------------------------------------------------------------------
  130. //    This function enables menu commands.
  131. //
  132.  
  133. void
  134. LGApp::FindCommandStatus(
  135.     CommandT    inCommand,
  136.     Boolean        &outEnabled,
  137.     Boolean        &outUsesMark,
  138.     Char16        &outMark,
  139.     Str255        outName)
  140. {
  141.  
  142.     switch (inCommand) {
  143.     
  144.         // Return menu item status according to command messages.
  145.         // Any that you don't handle will be passed to LApplication
  146.  
  147.         case cmd_Close:                    // EXAMPLE
  148.         case cmd_New:                    // EXAMPLE
  149.             outEnabled = false;            // enable the New command
  150.             break;
  151.  
  152.  
  153.         default:
  154.             LApplication::FindCommandStatus(inCommand, outEnabled,
  155.                                                 outUsesMark, outMark, outName);
  156.             break;
  157.     }
  158. }
  159.