home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 5 / FreshFish_July-August1994.bin / bbs / gnu / aplusplus-1.01-src.lha / src / amiga / aplusplus-1.01 / libsource / ScreenC.cxx < prev    next >
C/C++ Source or Header  |  1994-04-23  |  3KB  |  120 lines

  1. /******************************************************************************
  2.  **
  3.  **    C++ Class Library for the Amiga© system software.
  4.  **
  5.  **    Copyright (C) 1994 by Armin Vogt  **  EMail: armin@uni-paderborn.de
  6.  **    All Rights Reserved.
  7.  **
  8.  **    $Source: apphome:APlusPlus/RCS/libsource/ScreenC.cxx,v $
  9.  **    $Revision: 1.3 $
  10.  **    $Date: 1994/04/23 21:02:25 $
  11.  **    $Author: Armin_Vogt $
  12.  **
  13.  ******************************************************************************/
  14.  
  15.  
  16. extern "C" {
  17. #ifdef __GNUG__
  18. #include <inline/intuition.h>
  19. #include <inline/gadtools.h>
  20. #endif
  21.  
  22. #ifdef __SASC
  23. #include <proto/intuition.h>
  24. #include <proto/gadtools.h>
  25. #endif
  26. }
  27. #include <APlusPlus/intuition/ScreenC.h>
  28.  
  29.  
  30. volatile static char rcs_id[] = "$Id: ScreenC.cxx,v 1.3 1994/04/23 21:02:25 Armin_Vogt Exp Armin_Vogt $";
  31.  
  32.  
  33. BOOL ScreenC::fillInfo()
  34.    /* Gets the often used info data for the screen, DrawInfo and GadTools's VisualInfo.
  35.       Returns TRUE for success.
  36.    */
  37. {
  38.    drawInfo = GetScreenDrawInfo(screenPtr());
  39.    _dout("got DrawInfo.\n");
  40.    visualInfo = GetVisualInfoA(screenPtr(),TAG_END);
  41.    _dout("got VisualInfo.\n");
  42.    return (drawInfo && visualInfo);
  43. }
  44.  
  45. ScreenC::ScreenC(OWNER,AttrList& attrs) : GraphicObject((GraphicObject*)owner,attrs)
  46. {
  47.     lockOnPublic = FALSE;
  48.     drawInfo = NULL;
  49.     visualInfo = NULL;
  50.     if (Ok())
  51.    if (NULL != (screen() = OpenScreenTagList(NULL,intuiAttrs()) ) )
  52.    {
  53.       if (fillInfo())
  54.          setIOType(IOTYPE_SCREEN);
  55.       else
  56.          _ierror(SCREENC_NOINFO);
  57.    }
  58.    else _ierror(SCREENC_OPENSCREEN_FAILED);
  59. }
  60.  
  61. ScreenC::ScreenC(IntuiObject *owner, UBYTE *screenTitle) 
  62.     : GraphicObject((GraphicObject*)owner,AttrList(NULL))
  63.    /* Tries to get a lock on the public screen with the given screenTitle. Use NULL as STRPTR to
  64.       get a lock on the default public screen.
  65.       The established lock will last for the lifetime of the ScreenC object. So, release
  66.       the lock in deleting the ScreenC object when you have no further use for it.
  67.    */
  68. {
  69.     if (Ok())
  70.    if ( NULL != (screen() = LockPubScreen( (UBYTE*) screenTitle)) )
  71.    {
  72.       _dout("  screen locked.\n");
  73.       if (fillInfo())
  74.       {
  75.          lockOnPublic = TRUE;
  76.          _dout("  public screen locked. this = "<<this<<"\n");
  77.          setIOType(IOTYPE_SCREEN);
  78.          return;
  79.       }
  80.       else
  81.          _ierror(SCREENC_NOINFO);
  82.  
  83.       UnlockPubScreen(NULL,screenPtr());
  84.    }
  85.    else _ierror(SCREENC_PUBLICSCREEN_NOT_FOUND);
  86.     drawInfo = NULL;
  87.     visualInfo = NULL;
  88.    lockOnPublic = FALSE;
  89. }
  90.  
  91. ScreenC::~ScreenC()
  92.    /* Unlock previously locked public screen, free DrawInfo and VisualInfo, and close screen.
  93.       Public screens will resist being closed as long as they have windows opened.
  94.    */
  95. {
  96.    if (drawInfo)  FreeScreenDrawInfo(screen(),drawInfo);
  97.    if (visualInfo)  FreeVisualInfo(visualInfo);
  98.     if (lockOnPublic)  UnlockPubScreen(NULL,screen());
  99.     else CloseScreen(screen());
  100. }
  101.  
  102. ULONG ScreenC::setAttributes(AttrList& attrs)
  103. {
  104.    return GraphicObject::setAttributes(attrs);
  105. }
  106.  
  107. ULONG ScreenC::getAttribute(Tag attr,ULONG& dataStore)
  108. {
  109.    return GraphicObject::getAttribute(attr,dataStore);
  110. }
  111. struct DrawInfo *ScreenC::getScreenDrawInfo()
  112. {
  113.    return drawInfo;
  114. }
  115.  
  116. APTR ScreenC::getVisualInfo()
  117. {
  118.    _dout("getVisualInfo from this="<<this<<endl);
  119.    return visualInfo;
  120. }