home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-03-19 | 3.7 KB | 181 lines | [TEXT/CWIE] |
- // CGadgetsApp.cp -- application methods
- // Created 3/19/96 12:49 PM by AppMaker
-
- #include "CGadgetsApp.h"
-
- #include "CGadgetsDoc.h"
- #include "CGadgetsData.h"
- #include "CmdCodes.h"
-
- #include <UDesktop.h>
- #include <URegistrar.h>
- #include <UScreenPort.h>
- #include <PPobClasses.h>
- #include <PP_Messages.h>
-
- // ---------------------------------------------------------------------------
- // • CGadgetsApp
- // ---------------------------------------------------------------------------
- // Default constructor
-
- CGadgetsApp::CGadgetsApp()
- :LDocApplication()
- {
- UScreenPort::Initialize();
-
- RegisterClasses();
-
- SetUpMenus();
-
- // initialize app's data:
-
- }
-
-
- // ---------------------------------------------------------------------------
- // • ~CGadgetsApp
- // ---------------------------------------------------------------------------
- // Destructor
- //
-
- CGadgetsApp::~CGadgetsApp()
- {
- }
-
- // ---------------------------------------------------------------------------
- // • RegisterClasses
- // ---------------------------------------------------------------------------
- //
-
- void
- CGadgetsApp::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
- CGadgetsApp::SetUpMenus()
- {
-
- }
-
- // ---------------------------------------------------------------------------
- // • StartUp
- // ---------------------------------------------------------------------------
- // The application calls this member function automatically when the application
- // is opened
-
- void
- CGadgetsApp::StartUp()
- {
- ObeyCommand(cmd_New, nil);
- }
-
- //----------
- LModelObject*
- CGadgetsApp::MakeNewDocument()
- {
- CGadgetsDoc *theDoc = new CGadgetsDoc(this);
-
- theDoc->newFile();
-
- return theDoc;
- }
-
- //----------
- // called from SendAEOpenDoc in response to Open command
-
- void
- CGadgetsApp::OpenDocument(
- FSSpec *inMacFSSpec)
- {
- CGadgetsDoc *theDoc = new CGadgetsDoc(this);
-
- theDoc->openFile (inMacFSSpec);
- }
-
- //----------
- // called from LDocApplication in response to Open command
-
- void
- CGadgetsApp::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);
- }
- }
-
- // ---------------------------------------------------------------------------
- // • ObeyCommand
- // ---------------------------------------------------------------------------
- // Respond to commands
-
- Boolean
- CGadgetsApp::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
-
-
- default:
- cmdHandled = LDocApplication::ObeyCommand(inCommand, ioParam);
- break;
- }
-
- return cmdHandled;
- }
-
-
- // ---------------------------------------------------------------------------
- // • FindCommandStatus
- // ---------------------------------------------------------------------------
- // Pass back status of a (menu) command
-
- void
- CGadgetsApp::FindCommandStatus(
- CommandT inCommand,
- Boolean &outEnabled,
- Boolean &outUsesMark,
- Char16 &outMark,
- Str255 outName)
- {
- outUsesMark = false;
-
- switch (inCommand) {
-
- // +++ Add cases here for the commands you handle
-
-
- default:
- LDocApplication::FindCommandStatus(inCommand, outEnabled, outUsesMark,
- outMark, outName);
- break;
- }
- }
-