home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-09-30 | 3.7 KB | 175 lines | [TEXT/MMCC] |
- // CFileAndFindDoc.cp -- Document methods
- // Created 01/01/95 12:01 PM by AppMaker
-
- #include "CFileAndFindDoc.h"
-
- #include "CListArticles.h"
-
- #include <LFile.h>
- #include <LPlaceHolder.h>
- #include <LPrintout.h>
- #include <LWindow.h>
- #include <UWindows.h>
- #include <String_Utils.h>
-
- #include "FileAndFind_OOFILE.h"
- #include "CEditArticle.h"
- #include "CEditArticle.h"
-
- const ResIDT prto_PrintView = 201;
- const ResIDT STRx_Untitled = 128;
-
- // ---------------------------------------------------------------------------
- // • CFileAndFindDoc
- // ---------------------------------------------------------------------------
-
- CFileAndFindDoc::CFileAndFindDoc(
- LCommander *inSuper)
- : LSingleDoc(inSuper)
- , mData(0)
- , mArticles(0)
- {
- }
-
- // ---------------------------------------------------------------------------
- // • ~CFileAndFindDoc
- // ---------------------------------------------------------------------------
- // Destructor
- //
-
- CFileAndFindDoc::~CFileAndFindDoc()
- {
- delete mData;
- delete mArticles;
- }
-
- //----------
- void
- CFileAndFindDoc::newFile()
- {
- FSSpec fileSpec;
- if (AskSaveAs(fileSpec, true)) {
- MakeDatabaseObjects();
- mData->newConnection(OOF_MacString(fileSpec.name));
- CompleteOpenFile(&fileSpec);
- }
- }
-
- //----------
- void
- CFileAndFindDoc::openFile(
- FSSpec *inFileSpec)
- {
- MakeDatabaseObjects();
- mData->openConnection(OOF_MacString(inFileSpec->name));
- CompleteOpenFile(inFileSpec);
- }
-
-
-
- // ---------------------------------------------------------------------------
- // • DoPrint
- // ---------------------------------------------------------------------------
- // Print the contents of the Document
-
- void
- CFileAndFindDoc::DoPrint()
- {
- LPrintout *thePrintout = LPrintout::CreatePrintout(prto_PrintView);
- LPlaceHolder *textPlace = (LPlaceHolder *)
- thePrintout->FindPaneByID('TBox');
- //! textPlace->InstallOccupant(mTextView, atNone);
-
-
- thePrintout->DoPrintJob();
- delete thePrintout;
- }
-
- //----------
- Boolean
- CFileAndFindDoc::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 = LSingleDoc::ObeyCommand(inCommand, ioParam);
- break;
- }
-
- return cmdHandled;
- }
-
- //----------
- void
- CFileAndFindDoc::FindCommandStatus(
- CommandT inCommand,
- Boolean &outEnabled,
- Boolean &outUsesMark,
- Char16 &outMark,
- Str255 outName)
- {
- outUsesMark = false;
-
- switch (inCommand) {
-
- // +++ Add cases here for the commands you handle
-
- default:
- LSingleDoc::FindCommandStatus(inCommand, outEnabled,
- outUsesMark, outMark, outName);
- break;
- }
- }
-
-
- //----------
- void
- CFileAndFindDoc::MakeDatabaseObjects()
- {
-
- // MUST TAKE PLACE BEFORE newConnection or openConnection
- // you can't define dbTables after opening the connection
-
- // Note if these were defined as part of CFIleAndFindDoc, instead of being
- // 'newed' heap-based objects, this method would not be necessary
-
- mData = new dbConnect_ctree;
- // create all database tables
- mArticles = new CdbArticles;
-
- // change types of files created by c-tree (given modification to ctclib.c)
- ctMacCreator = kSignature;
- ctMacType = kFileType;
- }
-
-
- //----------
- void
- CFileAndFindDoc::CompleteOpenFile(
- FSSpec *inFileSpec)
- {
-
- // can now make the factories for our database editing windows and dialogs
- // which require us to have constructed the database objects
-
- AdoptAddDialogFactory(new CEditArticleFactory(this, mArticles));
- AdoptEditDialogFactory(new CEditArticleFactory(this, mArticles));
- AdoptBrowseWindowFactory(new CListArticlesFactory(this, mArticles));
-
- mWindow = MakeBrowser();
- if (mWindow != nil) {
- mWindow->SetDescriptor (inFileSpec->name);
- }
- mIsSpecified = true;
-
- }
-
-