home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-10-05 | 4.6 KB | 222 lines | [TEXT/MMCC] |
- // CAMReminderDoc.cp -- Document methods
- // Created 10/5/95 8:02 PM by AppMaker
-
- #include "CAMReminderDoc.h"
-
- #include "CAMReminderData.h"
- #include "CMainWindow.h"
- #include "CmdCodes.h"
- #include "CAdd.h"
-
- #include <LFile.h>
- #include <LPlaceHolder.h>
- #include <LPrintout.h>
- #include <LWindow.h>
- #include <UWindows.h>
- #include <String_Utils.h>
-
- const ResIDT prto_PrintView = 201;
- const ResIDT STRx_Untitled = 128;
-
- // ---------------------------------------------------------------------------
- // • CAMReminderDoc
- // ---------------------------------------------------------------------------
-
- CAMReminderDoc::CAMReminderDoc (const Boolean inPrintable,
- const Boolean inNewDatabase,
- const Boolean inRemote)
- : CNeoDocRoot (kSignature, kFileType, inPrintable, inNewDatabase)
- {
- mData = new CAMReminderData (this, (CNeoDatabasePP *)mFile);
- }
-
- // ---------------------------------------------------------------------------
- // • ~CAMReminderDoc
- // ---------------------------------------------------------------------------
- // Destructor
- //
-
- CAMReminderDoc::~CAMReminderDoc()
- {
- delete mData;
- }
-
- //----------
- void
- CAMReminderDoc::newDatabase ()
- {
- FSSpec spec;
-
- inherited::newDatabase();
-
- // Set the default name which appears in the get file dialog.
- spec.vRefNum = 0;
- spec.parID = 0;
- NeoStringCopy ("\pAMReminder", spec.name);
- ((CNeoDatabasePP *)mFile)->setFileSpec (spec);
-
- NameNewDoc(); // Set name of untitled window
- }
-
- //----------
- void
- CAMReminderDoc::buildWindow()
- {
- mMainWindow = CMainWindow::CreateMainWindow(this, mData);
-
- mWindow = mMainWindow;
- }
-
- // ---------------------------------------------------------------------------
- // • NameNewDoc
- // ---------------------------------------------------------------------------
- // Name a new, untitled document window
- //
- // Untitled windows start with "untitled", then "untitled 1",
- // "untitled 2", etc. Old numbers are reused, so there won't be
- // gaps in the numbering.
- //
- // This routine uses a STR# resource to store the "untitled" string,
- // which can be localized to different languages. The first string
- // is "untitled" and the second is "untitled " (trailing space),
- // which is used when appending a number to the name.
-
- void
- CAMReminderDoc::NameNewDoc()
- {
- // Start with the default name("untitled")
- Str255 name;
- ::GetIndString(name, STRx_Untitled, 1);
-
- long num = 0;
- while (UWindows::FindNamedWindow(name) != nil) {
-
- // An existing window has the current name
- // Increment counter and try again
-
- ::GetIndString(name, STRx_Untitled, 2);
- num++;
- Str15 numStr;
- ::NumToString(num, numStr);
- ConcatPStr(name, numStr);
- }
-
- mWindow->SetDescriptor(name); // Finally, set window title
- }
-
-
- // ---------------------------------------------------------------------------
- // • DoPrint
- // ---------------------------------------------------------------------------
- // Print the contents of the Document
-
- void
- CAMReminderDoc::DoPrint()
- {
- LPrintout *thePrintout = LPrintout::CreatePrintout(prto_PrintView);
- LPlaceHolder *textPlace = (LPlaceHolder *)
- thePrintout->FindPaneByID('TBox');
- //! textPlace->InstallOccupant(mTextView, atNone);
-
-
- thePrintout->DoPrintJob();
- delete thePrintout;
- }
-
- //----------
- void
- CAMReminderDoc::DoAddReminder ()
- {
- CAdd* dialog = CAdd::CreateAdd(this);
- }
-
- //----------
- void
- CAMReminderDoc::DoEditReminder ()
- {
- CAdd* dialog = CAdd::CreateAdd(this);
- }
-
- //----------
- void
- CAMReminderDoc::DoDeleteReminder ()
- {
- }
-
- //----------
- void
- CAMReminderDoc::ObeyAdd (void* ioParam)
- {
- }
-
- //----------
- Boolean
- CAMReminderDoc::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 cmdAddReminder:
- DoAddReminder ();
- break;
-
- case cmdEditReminder:
- DoEditReminder ();
- break;
-
- case cmdDeleteReminder:
- DoDeleteReminder ();
- break;
-
- case cmd_Add:
- ObeyAdd (ioParam);
- break;
-
- default:
- cmdHandled = CNeoDocNative::ObeyCommand(inCommand, ioParam);
- break;
- }
-
- return cmdHandled;
- }
-
- //----------
- void
- CAMReminderDoc::FindCommandStatus(
- CommandT inCommand,
- Boolean &outEnabled,
- Boolean &outUsesMark,
- Char16 &outMark,
- Str255 outName)
- {
- outUsesMark = false;
-
- switch (inCommand) {
-
- // +++ Add cases here for the commands you handle
-
- case cmdAddReminder:
- outEnabled = true;
- break;
- case cmdEditReminder:
- outEnabled = true;
- break;
- case cmdDeleteReminder:
- outEnabled = true;
- break;
-
- default:
- CNeoDocNative::FindCommandStatus(inCommand, outEnabled,
- outUsesMark, outMark, outName);
- break;
- }
- }
-