home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-10-29 | 933 b | 45 lines | [TEXT/CWIE] |
- // GWorldSetter.h, GWorld setter and restorer using the "resource acquisition
- // is initialization" technique, see 9.4 of Stroustrup.
-
- // copyright © 1995, Macneil Shonle. All rights reserved.
-
- #ifndef __GWORLDSETTER__
- #define __GWORLDSETTER__
-
- #ifndef __QDOFFSCREEN__
- #include <QDOffscreen.h>
- #endif
-
- // class GWorldSetter
- class GWorldSetter {
- public:
- GWorldSetter(CGrafPtr, GDHandle =nil);
- GWorldSetter(WindowRef);
- ~GWorldSetter();
-
- private:
- CGrafPtr origPort;
- GDHandle origDev;
- };
-
- // sets the port to parameters
- inline GWorldSetter::GWorldSetter(CGrafPtr port, GDHandle gdh)
- {
- ::GetGWorld(&origPort, &origDev);
- ::SetGWorld(port, gdh);
- }
-
- // sets the port to parameter
- inline GWorldSetter::GWorldSetter(WindowRef port)
- {
- ::GetGWorld(&origPort, &origDev);
- ::SetGWorld(CGrafPtr(port), GetMainDevice());
- }
-
- // sets the port back to original
- inline GWorldSetter::~GWorldSetter()
- {
- ::SetGWorld(origPort, origDev);
- }
-
- #endif