home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-10-05 | 5.9 KB | 264 lines | [TEXT/MMCC] |
- // CAMReminderApp.cp -- application methods
- // Created 10/5/95 8:02 PM by AppMaker
-
- #include "CAMReminderApp.h"
-
- #include "CAMReminderDoc.h"
- #include "CAMReminderData.h"
- #include "CmdCodes.h"
-
- #include <UDesktop.h>
- #include <URegistrar.h>
- #include <UScreenPort.h>
- #include <PPobClasses.h>
- #include <PP_Messages.h>
-
- // ---------------------------------------------------------------------------
- // • CAMReminderApp
- // ---------------------------------------------------------------------------
- // Default constructor
-
- CAMReminderApp::CAMReminderApp()
- :CNeoAppNative (kSignature, kFileType)
- {
- UScreenPort::Initialize();
-
- RegisterClasses();
-
- SetUpMenus();
-
- // initialize app's data:
- CAMReminderData::InitAppData();
-
- }
-
-
- // ---------------------------------------------------------------------------
- // • ~CAMReminderApp
- // ---------------------------------------------------------------------------
- // Destructor
- //
-
- CAMReminderApp::~CAMReminderApp()
- {
- }
-
- // ---------------------------------------------------------------------------
- // • RegisterClasses
- // ---------------------------------------------------------------------------
- //
-
- void
- CAMReminderApp::RegisterClasses()
- {
- RegisterAllPPClasses();
- // replace to register only classes that we use.
- // windows know what classes they use
- // so call static functions in each window/dialog,
- }
-
- // ---------------------------------------------------------------------------
- // • SetUpMenus
- // ---------------------------------------------------------------------------
- //
-
- void
- CAMReminderApp::SetUpMenus()
- {
-
- }
-
- // ---------------------------------------------------------------------------
- // • StartUp
- // ---------------------------------------------------------------------------
- // The application calls this member function automatically when the application
- // is opened
-
- void
- CAMReminderApp::StartUp()
- {
- ObeyCommand(cmd_Open, nil);
- }
-
- //----------
- // called from CNeoAppPP in response to New command
-
- CNeoDoc*
- CAMReminderApp::createDocument()
- {
- CAMReminderDoc * document = nil;
-
- VOLATILE(document);
-
- NEOTRY {
- /*
- * Create your document.
- *
- * The arguments indicate whether the document is...
- * printable (true),
- * a new file (true),
- * remote (false).
- */
- document = new CAMReminderDoc (true, true, false);
- NeoFailNil (document);
- document->SetSuperCommander (this);
-
- // Call the document’s newDatabase method.
- document->newDatabase();
- }
- NEOCATCH {
- /*
- * This exception handler gets executed if a failure occurred
- * anywhere within the scope of the above NEOTRY block. Since
- * this indicates that a new doc could not be created, we
- * check if an object had been allocated and if it has, delete
- * it. The exception will propagate up to the next exception
- * handler, which displays an error alert.
- */
- if (document != nil) {
- delete document;
- document = nil;
- }
- }
- NEOENDTRY;
-
- return document;
- }
-
- //----------
- // called from SendAEOpenDoc in response to Open command
-
- void
- CAMReminderApp::OpenDocument(
- FSSpec *inMacFSSpec)
- {
- CAMReminderDoc * document = nil;
-
- VOLATILE(document);
-
- NEOTRY {
- // Our parent will check to see if this is a document we have
- // already opened. If we find the file already open by the app,
- // then fDocument will refer to it. If the file is opened but
- // not by this app, then the parent will signal a failure.
- inherited::OpenDocument (inMacFSSpec);
- if (fDocument != nil)
- return;
-
- // Create your document.
- document = new CAMReminderDoc (true, false, false);
- NeoFailNil (document);
- document->SetSuperCommander (this);
-
- // Call the document's openDatabase method. The document will open
- // a window, open the file specified in the file specification
- // record, and display it in its window.
- document->openFile (inMacFSSpec);
- }
- NEOCATCH {
- /*
- * This exception handler gets executed if a failure occurred
- * anywhere within the scope of the NEOTRY block above. Since
- * this indicates that the document could not be opened, we
- * send it a unrefer message. The exception will propagate up to
- * the event loop's exception handler, which handles displaying
- * an error alert.
- */
- if (document != nil) {
- delete document;
- document = nil;
- }
- }
- NEOENDTRY;
- }
-
- //----------
- // called from LDocApplication in response to Open command
-
- void
- CAMReminderApp::ChooseDocument()
- {
- SFTypeList typeList;
- short numTypes;
- StandardFileReply macFileReply;
-
- typeList[0] = kFileType;
- numTypes = 1;
-
- UDesktop::Deactivate();
- ::StandardGetFile(nil, numTypes, typeList, &macFileReply);
- UDesktop::Activate();
-
- if (macFileReply.sfGood) {
- SendAEOpenDoc(macFileReply.sfFile);
- }
- }
-
- //----------
- void
- CAMReminderApp::DoDeleteReminder ()
- {
- }
-
- // ---------------------------------------------------------------------------
- // • ObeyCommand
- // ---------------------------------------------------------------------------
- // Respond to commands
-
- Boolean
- CAMReminderApp::ObeyCommand(
- CommandT inCommand,
- void *ioParam)
- {
- Boolean cmdHandled = true;
-
- switch (inCommand) {
-
- // +++ Add cases here for the commands you handle
- // Remember to add same cases to FindCommandStatus below
- // to enable/disable the menu items for the commands
-
-
- case cmdDeleteReminder:
- DoDeleteReminder ();
- break;
-
- default:
- cmdHandled = CNeoAppNative::ObeyCommand(inCommand, ioParam);
- break;
- }
-
- return cmdHandled;
- }
-
-
- // ---------------------------------------------------------------------------
- // • FindCommandStatus
- // ---------------------------------------------------------------------------
- // Pass back status of a (menu) command
-
- void
- CAMReminderApp::FindCommandStatus(
- CommandT inCommand,
- Boolean &outEnabled,
- Boolean &outUsesMark,
- Char16 &outMark,
- Str255 outName)
- {
- outUsesMark = false;
-
- switch (inCommand) {
-
- // +++ Add cases here for the commands you handle
-
- case cmdDeleteReminder:
- outEnabled = true;
- break;
-
- default:
- CNeoAppNative::FindCommandStatus(inCommand, outEnabled, outUsesMark,
- outMark, outName);
- break;
- }
- }
-