home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-12-04 | 1.6 KB | 66 lines | [TEXT/CWIE] |
- // C3DMFViewerDoc.cp
- //
- // A PowerPlant application for viewing QuickDraw3D Metafiles
- //
- // by James Jennings
- // Started November 12, 1995
- //
-
- #include "C3DMFViewerDoc.h"
-
- const ResIDT WIND_ViewerDoc = 128;
-
- C3DMFViewerDoc::C3DMFViewerDoc(
- LCommander *inSuper, FSSpec *inFileSpec)
- : LSingleDoc(inSuper)
- {
- // Create window for our document
- mWindow = LWindow::CreateWindow(WIND_ViewerDoc, this);
-
- // Specify that the text view should
- // be the Target when the Window
- // is activated
- m3DMFPane = (C3DMFViewerPane*) mWindow->FindPaneByID(PaneID_Q3Viewer);
- mWindow->SetLatentSub(m3DMFPane);// assign sub-commander
-
- if (inFileSpec == nil) {
- // NameNewDoc(); // Set name of untitled window
-
- } else {
- OpenFile(*inFileSpec); // Display contents of file in window
- }
- }
-
- // ---------------------------------------------------------------------------
- // • OpenFile
- // ---------------------------------------------------------------------------
- // Open a new document for the specified File
-
- void
- C3DMFViewerDoc::OpenFile( FSSpec &inFileSpec)
- {
- // Create a new File object, read the entire File contents,
- // put the contents into the text view, and set the Window
- // title to the name of the File.
-
- try {
- mFile = new LFile(inFileSpec);
- mFile->OpenDataFork(fsRdPerm);
-
- C3DMFViewerPane *thePane = (C3DMFViewerPane *)
- mWindow->FindPaneByID(PaneID_Q3Viewer);
- ThrowIfNil_(thePane);
- thePane->UseFile(mFile->GetDataForkRefNum());
-
- mWindow->SetDescriptor(inFileSpec.name);
- mIsSpecified = true;
- }
-
- catch(ExceptionCode inErr) {
- delete this;
- Throw_(inErr);
-
- }
- }
-
-