home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-08-06 | 3.4 KB | 144 lines | [TEXT/MMCC] |
- /****
- * CNeoBenchDoc.cp
- *
- * Document methods for a typical application.
- *
- * Copyright © 1990 Symantec Corporation. All rights reserved.
- *
- ****/
-
- #include "NeoTypes.h"
- #include "PP_Messages.h"
- #include "UDesktop.h"
- #include CNeoDatabaseNativeH
- #include "NeoBench.h"
- #include "CNeoBenchApp.h"
- #include "CNeoBenchDoc.h"
- #include "CNeoWindow.h"
-
- #define WINDNeoBench 500 /* Resource ID for WIND template */
-
- /***
- * CNeoBenchDoc
- *
- * This is your document's initialization method.
- * If your document has its own instance variables, initialize
- * them here.
- *
- * The least you need to do is invoke the default method.
- *
- ***/
- CNeoBenchDoc::CNeoBenchDoc(const Boolean aPrintable, const Boolean aNewDatabase, const Boolean aRemote)
- : CNeoDocRoot(kNeoBenchSig, kNeoBenchFileType, aPrintable, aNewDatabase)
- {
- }
-
- /***
- * buildWindow
- *
- * This is the auxiliary window-building method that the
- * newFile() and openFile() methods use to create a window.
- *
- * In this implementation, the argument is the data to display.
- *
- ***/
-
- void CNeoBenchDoc::buildWindow(void)
- {
- /**
- ** Create the window and initialize it.
- **/
- mWindow = new CNeoWindow(WINDNeoBench, this);
- }
-
- void CNeoBenchDoc::ListenToMessage(MessageT aMessage, void *aParam)
- {
- short phase;
- CNeoDatabasePP * file;
-
- switch (aMessage) {
- case msg_GrowZone:
- file = (CNeoDatabasePP *)mFile;
- if (file &&
- file->isOpen() &&
- *(NeoSize *)aParam) {
-
- if (isDirty()) {
- file->commit(FALSE);
- setDirty(FALSE);
- }
-
- phase = ((CNeoWindow *)mWindow)->getPhase();
- if (phase == kRandomly) {
- CNeoDatabase::FPurgeLevel = CNeoPersist::FPurgeDesperation +1;
- CNeoDatabase::FPurgeMin = ((CNeoWindow *)mWindow)->getPhaseTarget(kInsert) / 16;
- CNeoDatabase::FPurgeDelta = CNeoDatabase::FPurgeMin / 2;
- }
- else {
- if (phase == kInsert)
- CNeoDatabase::FPurgeMin = 2000;
- else
- CNeoDatabase::FPurgeMin = 200;
- CNeoDatabase::FPurgeDelta = CNeoDatabase::FPurgeMin / 4;
- CNeoDatabase::FPurgeLevel = CNeoPersist::FPurgeDesperation +3;
- }
- if (!file->purge(*(NeoSize *)aParam))
- *(NeoSize *)aParam = 0;
- }
- break;
-
- default:
- inherited::ListenToMessage(aMessage, aParam);
- break;
- }
- }
-
- /***
- * newFile
- *
- * When the user chooses New from the File menu, the CreateDocument()
- * method in your Application class will send a newly created document
- * this message. This method needs to create a new window, ready to
- * work on a new document.
- *
- * Since this method and the openFile() method share the code for creating
- * the window, you should use an auxiliary window-building method.
- *
- ***/
- void CNeoBenchDoc::newDatabase(void)
- {
- FSSpec spec;
-
- inherited::newDatabase();
-
- ((CNeoWindow *)mWindow)->setDocument(this);
-
- spec.vRefNum = 0;
- spec.parID = 0;
- BlockMove("\pNeoBench Results", spec.name, 18);
- ((CNeoDatabasePP *)mFile)->setFileSpec(spec);
- DoSave();
- setDirty(FALSE);
- }
-
- /***
- * openFile
- *
- * When the user chooses Open… from the File menu, the OpenDocument()
- * method in your Application class will let the user choose a file
- * and then send a newly created document this message. The information
- * about the file is in the SFReply record.
- *
- * In this method, you need to open the file and display its contents
- * in a window. This method uses the auxiliary window-building method.
- *
- ***/
-
- void CNeoBenchDoc::openFile(FSSpec *aSpec)
- {
- fOpenMode = fsRdWrPerm;
- inherited::openFile(aSpec);
-
- ((CNeoWindow *)mWindow)->setDocument(this);
- }
-