home *** CD-ROM | disk | FTP | other *** search
- /******************************************************************************
- **
- ** C++ Class Library for the Amiga© system software.
- **
- ** Copyright (C) 1994 by Armin Vogt ** EMail: armin@uni-paderborn.de
- ** All Rights Reserved.
- **
- ** $Source: apphome:APlusPlus/RCS/libsource/ScreenC.cxx,v $
- ** $Revision: 1.3 $
- ** $Date: 1994/04/23 21:02:25 $
- ** $Author: Armin_Vogt $
- **
- ******************************************************************************/
-
-
- extern "C" {
- #ifdef __GNUG__
- #include <inline/intuition.h>
- #include <inline/gadtools.h>
- #endif
-
- #ifdef __SASC
- #include <proto/intuition.h>
- #include <proto/gadtools.h>
- #endif
- }
- #include <APlusPlus/intuition/ScreenC.h>
-
-
- volatile static char rcs_id[] = "$Id: ScreenC.cxx,v 1.3 1994/04/23 21:02:25 Armin_Vogt Exp Armin_Vogt $";
-
-
- BOOL ScreenC::fillInfo()
- /* Gets the often used info data for the screen, DrawInfo and GadTools's VisualInfo.
- Returns TRUE for success.
- */
- {
- drawInfo = GetScreenDrawInfo(screenPtr());
- _dout("got DrawInfo.\n");
- visualInfo = GetVisualInfoA(screenPtr(),TAG_END);
- _dout("got VisualInfo.\n");
- return (drawInfo && visualInfo);
- }
-
- ScreenC::ScreenC(OWNER,AttrList& attrs) : GraphicObject((GraphicObject*)owner,attrs)
- {
- lockOnPublic = FALSE;
- drawInfo = NULL;
- visualInfo = NULL;
- if (Ok())
- if (NULL != (screen() = OpenScreenTagList(NULL,intuiAttrs()) ) )
- {
- if (fillInfo())
- setIOType(IOTYPE_SCREEN);
- else
- _ierror(SCREENC_NOINFO);
- }
- else _ierror(SCREENC_OPENSCREEN_FAILED);
- }
-
- ScreenC::ScreenC(IntuiObject *owner, UBYTE *screenTitle)
- : GraphicObject((GraphicObject*)owner,AttrList(NULL))
- /* Tries to get a lock on the public screen with the given screenTitle. Use NULL as STRPTR to
- get a lock on the default public screen.
- The established lock will last for the lifetime of the ScreenC object. So, release
- the lock in deleting the ScreenC object when you have no further use for it.
- */
- {
- if (Ok())
- if ( NULL != (screen() = LockPubScreen( (UBYTE*) screenTitle)) )
- {
- _dout(" screen locked.\n");
- if (fillInfo())
- {
- lockOnPublic = TRUE;
- _dout(" public screen locked. this = "<<this<<"\n");
- setIOType(IOTYPE_SCREEN);
- return;
- }
- else
- _ierror(SCREENC_NOINFO);
-
- UnlockPubScreen(NULL,screenPtr());
- }
- else _ierror(SCREENC_PUBLICSCREEN_NOT_FOUND);
- drawInfo = NULL;
- visualInfo = NULL;
- lockOnPublic = FALSE;
- }
-
- ScreenC::~ScreenC()
- /* Unlock previously locked public screen, free DrawInfo and VisualInfo, and close screen.
- Public screens will resist being closed as long as they have windows opened.
- */
- {
- if (drawInfo) FreeScreenDrawInfo(screen(),drawInfo);
- if (visualInfo) FreeVisualInfo(visualInfo);
- if (lockOnPublic) UnlockPubScreen(NULL,screen());
- else CloseScreen(screen());
- }
-
- ULONG ScreenC::setAttributes(AttrList& attrs)
- {
- return GraphicObject::setAttributes(attrs);
- }
-
- ULONG ScreenC::getAttribute(Tag attr,ULONG& dataStore)
- {
- return GraphicObject::getAttribute(attr,dataStore);
- }
- struct DrawInfo *ScreenC::getScreenDrawInfo()
- {
- return drawInfo;
- }
-
- APTR ScreenC::getVisualInfo()
- {
- _dout("getVisualInfo from this="<<this<<endl);
- return visualInfo;
- }