home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-03-13 | 3.5 KB | 154 lines | [TEXT/MPS ] |
- // Copyright ©1994 Apple Computer, Inc.
- // Author: John Powers
- // Date: 04-Aug-93
-
- // UDoc.cp
- // This file contains the documents and the objects that go
- // into the document window.
-
- #ifndef __UDOC__
- #include "UDoc.h"
- #endif
-
- // Segment
-
- #pragma segment MoG1
-
- // =========================================================================
- // TDoc : TDocument
- // ------------------------------------------------------------------------
- // TDoc::TDoc
- // Document object constructor.
- // The base class creates the Window Manager window pointer.
- // The resID is used by the base class constructor.
- TDoc::TDoc(short resID) : TDocument(resID)
- {
- // The TDocument constructor makes a NewWindow,
- // but we need a NewCWindow. Replace it with
- // our own NewCWindow. This lets us leave the
- // DTS TDocument class unmodified.
- DisposeWindow(this->fDocWindow);
- this->fDocWindow = GetNewCWindow( resID, nil, (WindowPtr) -1 );
- SetPort(this->fDocWindow);
- }
-
- // ------------------------------------------------------------------------
- // TDoc::~TDoc
- // Document window destructor.
- // The window pointer is disposed in the document destructor.
- TDoc::~TDoc()
- {
- }
-
- // ------------------------------------------------------------------------
- // TDoc::DoUpdate
- // Document object.
- // Entry for update event action.
- void
- TDoc::DoUpdate()
- {
- BeginUpdate(this->fDocWindow);
- this->Draw();
- EndUpdate(this->fDocWindow);
- }
-
- // ------------------------------------------------------------------------
- // TDoc::Erase
- // Erase the window.
- void
- TDoc::Erase()
- {
- SetPort(this->fDocWindow);
- EraseRect(&this->fDocWindow->portRect);
- };
-
- // ------------------------------------------------------------------------
- // TDoc::Hide
- // Hide the window.
- void
- TDoc::Hide()
- {
- HideWindow(this->fDocWindow);
- };
-
- // ------------------------------------------------------------------------
- // TDoc::Invalidate
- // Invalidate the window.
- void
- TDoc::Invalidate()
- {
- SetPort(this->fDocWindow);
- InvalRect(&this->fDocWindow->portRect);
- }
-
- //--------------------------------------------------------------------------
- // TDoc::IsThisKeyDown
- // Return true if theKey is down.
- // Adapted from MacApp 3.0.1, UMacAppUtilities.cp.
- Boolean
- TDoc::IsThisKeyDown(const short theKey)
- {
- union
- {
- KeyMap asMap;
- Byte asBytes[16];
- };
-
- GetKeys(asMap);
- return asBytes[theKey >> 3] & (1 << (theKey & 0x07)) ? true : false;
- }
-
- // ------------------------------------------------------------------------
- // TDoc::IsWindowVisible
- // Return true if the window is visible.
- Boolean
- TDoc::IsWindowVisible()
- {
- if(this->fDocWindow)
- return ((WindowPeek)this->fDocWindow)->visible;
- else
- return false;
- }
-
- // ------------------------------------------------------------------------
- // TDoc::Show
- // Show the window and bring it to the front.
- void
- TDoc::Show()
- {
- ShowWindow(this->fDocWindow);
- SelectWindow(this->fDocWindow);
- SetPort(this->fDocWindow);
- };
-
- // ------------------------------------------------------------------------
- // TDoc::Toggle
- // Show/Hide the window.
- void
- TDoc::Toggle()
- {
- if(this->IsWindowVisible())
- this->Hide();
- else
- this->Show();
- };
-
- // =========================================================================
- // TDocClip : TDoc : TDocument
- // ------------------------------------------------------------------------
- // TDocClip::TDocClip
- // Document window constructor.
- TDocClip::TDocClip(short resID) : TDoc(resID)
- {
- this->fScrap = nil;
- }
-
- // ------------------------------------------------------------------------
- void
- TDocClip::Draw()
- {
- if(this->fScrap)
- this->fScrap->Draw(this->fDocWindow);
- }
-
-