home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / C++ / Applications / Lookup 1.0d2 / Sources / CLookupApplication.cp < prev    next >
Encoding:
Text File  |  1995-09-12  |  3.0 KB  |  142 lines  |  [TEXT/CWIE]

  1. /*
  2.     CLookupApplication.cp
  3.     
  4.     Copyright © 1995 Alastair Rankine.
  5.     All Rights Reserved.
  6. */
  7.  
  8. #include <StandardFile.h>
  9.  
  10. #include <LApplication.h>
  11. #include <LGrowZone.h>
  12. #include <LWindow.h>
  13. #include <LScroller.h>
  14. #include <LPrintout.h>
  15. #include <LPlaceHolder.h>
  16.  
  17. #include <UMemoryMgr.h>
  18. #include <UDrawingState.h>
  19. #include <URegistrar.h>
  20. #include <UDesktop.h>
  21.  
  22. #include "CLookupApplication.h"
  23. #include "CLookupDocument.h"
  24. #include "CLookupWindow.h"
  25. #include "CEntryList.h"
  26.  
  27. void main(void)
  28. {
  29.                                     // Set Debugging options
  30.     SetDebugThrow_(debugAction_SourceDebugger);
  31.     SetDebugSignal_(debugAction_SourceDebugger);
  32.  
  33.     InitializeHeap(3);                // Initialize Memory Manager
  34.                                     // Parameter is number of Master Pointer
  35.                                     //   blocks to allocate
  36.     
  37.                                     // Initialize standard Toolbox managers
  38.     UQDGlobals::InitializeToolbox(&qd);    
  39.     
  40.     new LGrowZone(20000);            // Install a GrowZone function to catch
  41.                                     //    low memory situations.
  42.                                     //    Parameter is size of reserve memory
  43.                                     //    block to allocated. The first time
  44.                                     //    the GrowZone function is called,
  45.                                     //    there will be at least this much
  46.                                     //    memory left (so you'll have enough
  47.                                     //    memory to alert the user or finish
  48.                                     //    what you are doing).
  49.     
  50.     CLookupApplication    theApp;                // Create instance of your Application
  51.     theApp.Run();                    //   class and run it
  52. }
  53.  
  54.  
  55. CLookupApplication::CLookupApplication()
  56. {
  57.     // This is easier for the time being...
  58.     RegisterAllPPClasses();
  59.     
  60.     CLookupWindow::Register();
  61.     CEntryList::Register();
  62.     
  63.     AddAttachment(new LUndoer);
  64. }
  65.  
  66.  
  67. CLookupApplication::~CLookupApplication()
  68. {
  69.         // +++ Add code here to cleanup (if necessary) before quitting
  70. }
  71.  
  72.  
  73. Boolean CLookupApplication::ObeyCommand(
  74.     CommandT    inCommand,
  75.     void        *ioParam)
  76. {
  77.     Boolean    cmdHandled = true;
  78.     
  79.     switch (inCommand) {
  80.     
  81.         // +++ Add cases here for the commands you handle
  82.         //        Remember to add same cases to FindCommandStatus below
  83.         //        to enable/disable the menu items for the commands
  84.     
  85.         default:
  86.             cmdHandled = LDocApplication::ObeyCommand(inCommand, ioParam);
  87.             break;
  88.     }
  89.     
  90.     return cmdHandled;
  91. }
  92.  
  93.  
  94. void
  95. CLookupApplication::FindCommandStatus(
  96.     CommandT    inCommand,
  97.     Boolean        &outEnabled,
  98.     Boolean        &outUsesMark,
  99.     Char16        &outMark,
  100.     Str255        outName)
  101. {
  102.     outUsesMark = false;
  103.     
  104.     switch (inCommand) {
  105.     
  106.         // +++ Add cases here for the commands you handle
  107.     
  108.         default:
  109.             LDocApplication::FindCommandStatus(inCommand, outEnabled, outUsesMark,
  110.                                 outMark, outName);
  111.             break;
  112.     }
  113. }
  114.  
  115. void CLookupApplication::OpenDocument(FSSpec * inMacFSSpec)
  116. {
  117.     CLookupDocument * theDoc = new CLookupDocument(this, inMacFSSpec);
  118. }
  119.  
  120.  
  121. LModelObject * CLookupApplication::MakeNewDocument()
  122. {
  123.     CLookupDocument * theDoc = new CLookupDocument(this, nil);
  124.     return theDoc;
  125. }
  126.  
  127.  
  128. void
  129. CLookupApplication::ChooseDocument()
  130. {
  131.     StandardFileReply    macFileReply;
  132.     SFTypeList            typeList;
  133.     
  134.     UDesktop::Deactivate();
  135.     typeList[0] = CLookupDocument::kFileType;
  136.     ::StandardGetFile(nil, 1, typeList, &macFileReply);
  137.     UDesktop::Activate();
  138.     if (macFileReply.sfGood) {
  139.         OpenDocument(&macFileReply.sfFile);
  140.     }
  141. }
  142.