home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / PowerPlant / C3DMFViewer / Sources / C3DMFViewerApp.cp < prev    next >
Encoding:
Text File  |  1995-12-04  |  5.7 KB  |  213 lines  |  [TEXT/CWIE]

  1. //
  2. //    C3DMFViewerApp.cp
  3. //
  4. //    A PowerPlant application for viewing QuickDraw3D Metafiles
  5. //
  6. //    by James Jennings
  7. //    Started November 12, 1995
  8. //
  9.  
  10. #include "C3DMFViewerApp.h"
  11. #include "C3DMFViewerDoc.h"
  12. #include "C3DMFViewerPane.h"
  13.  
  14. #include "StQD3DInitializer.h"
  15.  
  16. /*#include <StandardFile.h>
  17.  
  18. #include <LApplication.h>
  19. #include <LGrowZone.h>
  20. #include <LWindow.h>
  21. #include <LScroller.h>
  22. #include <LPrintout.h>
  23. #include <LPlaceHolder.h>
  24.  
  25. #include <UMemoryMgr.h>
  26. #include <UDrawingState.h>
  27. #include <URegistrar.h>
  28. #include <UDesktop.h>
  29.  
  30. #include "CDocDemoApp.h"
  31. #include "CTextDoc.h"
  32. #include "CDirtyText.h"*/
  33.  
  34. // ===========================================================================
  35. //        • Main Program
  36. // ===========================================================================
  37.  
  38. void main(void)
  39. {
  40.                                     // Set Debugging options
  41.     SetDebugThrow_(debugAction_Alert);
  42.     SetDebugSignal_(debugAction_Alert);
  43.  
  44.     InitializeHeap(3);                // Initialize Memory Manager
  45.                                     // Parameter is number of Master Pointer
  46.                                     //   blocks to allocate
  47.     
  48.                                     // Initialize standard Toolbox managers
  49.     UQDGlobals::InitializeToolbox(&qd);    
  50.     
  51.     new LGrowZone(20000);            // Install a GrowZone function to catch
  52.                                     //    low memory situations.
  53.                                     //    Parameter is size of reserve memory
  54.                                     //    block to allocated. The first time
  55.                                     //    the GrowZone function is called,
  56.                                     //    there will be at least this much
  57.                                     //    memory left (so you'll have enough
  58.                                     //    memory to alert the user or finish
  59.                                     //    what you are doing).
  60.     
  61.     StQD3DInitializer qd3dState;    // initialize QuickDraw 3D
  62.     if (qd3dState.GetStatus()==kQ3Success) {
  63.         C3DMFViewerApp    theApp;            // Create instance of your Application
  64.         theApp.Run();                    //   class and run it
  65.     }
  66. }
  67.  
  68.  
  69. // ===========================================================================
  70. //        • C3DMFViewerApp Class
  71. // ===========================================================================
  72.  
  73. // ---------------------------------------------------------------------------
  74. //        • C3DMFViewerApp
  75. // ---------------------------------------------------------------------------
  76. //    Constructor
  77.  
  78. C3DMFViewerApp::C3DMFViewerApp(void)
  79. {
  80.         // Register classes for objects created from 'PPob' resources
  81.     URegistrar::RegisterClass(LWindow::class_ID,        LWindow::CreateWindowStream);
  82. //    URegistrar::RegisterClass(LActiveScroller::class_ID,
  83. //                                        LActiveScroller::CreateActiveScrollerStream);
  84. //    URegistrar::RegisterClass(LPlaceHolder::class_ID,    LPlaceHolder::CreatePlaceHolderStream);
  85. //    URegistrar::RegisterClass(LPrintout::class_ID,        LPrintout::CreatePrintoutStream);
  86.     URegistrar::RegisterClass(LView::class_ID,            LView::CreateViewStream);
  87.     
  88.     // dBug: Tell the Registar about our new QD3D Viewer Pane class
  89.     URegistrar::RegisterClass(C3DMFViewerPane::class_ID, 
  90.                                         C3DMFViewerPane::CreateQ3ViewerPaneStream);
  91. }
  92.  
  93.  
  94. // ---------------------------------------------------------------------------
  95. //        • ~C3DMFViewerApp
  96. // ---------------------------------------------------------------------------
  97. //    Destructor
  98.  
  99. C3DMFViewerApp::~C3DMFViewerApp(void)
  100. {
  101.         // +++ Add code here to cleanup (if necessary) before quitting
  102. }
  103.  
  104. // ---------------------------------------------------------------------------
  105. //        • StartUp
  106. // ---------------------------------------------------------------------------
  107. //    Open a file the first thing.
  108.  
  109. void C3DMFViewerApp::StartUp(void)
  110. {
  111.     ObeyCommand(cmd_Open, nil);
  112. }
  113.  
  114. // ---------------------------------------------------------------------------
  115. //        • ObeyCommand
  116. // ---------------------------------------------------------------------------
  117. //    Respond to commands
  118.  
  119. Boolean
  120. C3DMFViewerApp::ObeyCommand(
  121.     CommandT    inCommand,
  122.     void        *ioParam)
  123. {
  124.     Boolean    cmdHandled = true;
  125.     
  126.     switch (inCommand) {
  127.     
  128.         // +++ Add cases here for the commands you handle
  129.         //        Remember to add same cases to FindCommandStatus below
  130.         //        to enable/disable the menu items for the commands
  131.     
  132.         default:
  133.             cmdHandled = LDocApplication::ObeyCommand(inCommand, ioParam);
  134.             break;
  135.     }
  136.     
  137.     return cmdHandled;
  138. }
  139.  
  140.  
  141. // ---------------------------------------------------------------------------
  142. //        • FindCommandStatus
  143. // ---------------------------------------------------------------------------
  144. //    Pass back status of a (menu) command
  145.  
  146. void
  147. C3DMFViewerApp::FindCommandStatus(
  148.     CommandT    inCommand,
  149.     Boolean        &outEnabled,
  150.     Boolean        &outUsesMark,
  151.     Char16        &outMark,
  152.     Str255        outName)
  153. {
  154.     outUsesMark = false;
  155.     
  156.     switch (inCommand) {
  157.     
  158.         // +++ Add cases here for the commands you handle
  159.     
  160.         default:
  161.             LDocApplication::FindCommandStatus(inCommand, outEnabled, outUsesMark,
  162.                                 outMark, outName);
  163.             break;
  164.     }
  165. }
  166.  
  167.  
  168. // ---------------------------------------------------------------------------
  169. //        • OpenDocument
  170. // ---------------------------------------------------------------------------
  171. //    Open a Document file
  172.  
  173. void
  174. C3DMFViewerApp::OpenDocument(
  175.     FSSpec    *inMacFSSpec)
  176. {
  177.     C3DMFViewerDoc    *theDoc = new C3DMFViewerDoc(this, inMacFSSpec);
  178. }
  179.  
  180.  
  181. // ---------------------------------------------------------------------------
  182. //        • MakeNewDocument
  183. // ---------------------------------------------------------------------------
  184. //    Create a new Document
  185.  
  186. /*LModelObject*
  187. C3DMFViewerApp::MakeNewDocument()
  188. {
  189.     CTextDoc    *theDoc = new CTextDoc(this, nil);
  190.     return theDoc;
  191. }*/
  192.  
  193.  
  194. // ---------------------------------------------------------------------------
  195. //        • ChooseDocument
  196. // ---------------------------------------------------------------------------
  197. //    Prompt the user to select a document to open
  198.  
  199. void
  200. C3DMFViewerApp::ChooseDocument()
  201. {
  202.     StandardFileReply    macFileReply;
  203.     SFTypeList            typeList;
  204.     
  205.     UDesktop::Deactivate();
  206.     typeList[0] = '3DMF';
  207.     ::StandardGetFile(nil, 1, typeList, &macFileReply);
  208.     UDesktop::Activate();
  209.     if (macFileReply.sfGood) {
  210.         OpenDocument(&macFileReply.sfFile);
  211.     }
  212. }
  213.