home *** CD-ROM | disk | FTP | other *** search
/ Dream 57 / Amiga_Dream_57.iso / Amiga / Programmation / c / Extensions / APPSource.lha / APlusPlus / libsource / ScreenC.cxx < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-29  |  3.3 KB  |  124 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:RCS/libsource/ScreenC.cxx,v $
  9.  **   $Revision: 1.6 $
  10.  **   $Date: 1994/07/27 11:51:51 $
  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. static const char rcs_id[] = "$Id: ScreenC.cxx,v 1.6 1994/07/27 11:51:51 Armin_Vogt Exp Armin_Vogt $";
  31.  
  32. //runtime type inquiry support
  33. intui_typeinfo(ScreenC, derived(from(GraphicObject)), rcs_id)
  34.  
  35.  
  36. BOOL ScreenC::fillInfo()
  37.    /* Gets the often used info data for the screen, DrawInfo and GadTools's VisualInfo.
  38.       Returns TRUE for success.
  39.    */
  40. {
  41.    drawInfo = GetScreenDrawInfo(screen());
  42.    _dprintf("got DrawInfo.\n");
  43.    visualInfo = GetVisualInfo(screen(),TAG_END);
  44.    _dprintf("got VisualInfo.\n");
  45.    return (drawInfo && visualInfo);
  46. }
  47.  
  48. ScreenC::ScreenC(OWNER,AttrList& attrs) : GraphicObject((GraphicObject*)owner,attrs)
  49. {
  50.    lockOnPublic = FALSE;
  51.    drawInfo = NULL;
  52.    visualInfo = NULL;
  53.    if (Ok())
  54.    if (NULL != (screen_ref() = OpenScreenTagList(NULL,intuiAttrs()) ) )
  55.    {
  56.       if (fillInfo())
  57.          setIOType(IOTYPE_SCREEN);
  58.       else
  59.          _ierror(SCREENC_NOINFO);
  60.    }
  61.    else _ierror(SCREENC_OPENSCREEN_FAILED);
  62. }
  63.  
  64. ScreenC::ScreenC(IntuiObject *owner, UBYTE *screenTitle)
  65.    : GraphicObject((GraphicObject*)owner,AttrList(NULL))
  66.    /* Tries to get a lock on the public screen with the given screenTitle. Use NULL as STRPTR to
  67.       get a lock on the default public screen.
  68.       The established lock will last for the lifetime of the ScreenC object. So, release
  69.       the lock in deleting the ScreenC object when you have no further use for it.
  70.    */
  71. {
  72.    if (Ok())
  73.    if ( NULL != (screen_ref() = LockPubScreen( (UBYTE*) screenTitle)) )
  74.    {
  75.       _dprintf("  screen locked.\n");
  76.       if (fillInfo())
  77.       {
  78.          lockOnPublic = TRUE;
  79.          _dprintf("  public screen locked. this = %lx\n",this);
  80.          setIOType(IOTYPE_SCREEN);
  81.          return;
  82.       }
  83.       else
  84.          _ierror(SCREENC_NOINFO);
  85.  
  86.       UnlockPubScreen(NULL,screen());
  87.    }
  88.    else _ierror(SCREENC_PUBLICSCREEN_NOT_FOUND);
  89.    drawInfo = NULL;
  90.    visualInfo = NULL;
  91.    lockOnPublic = FALSE;
  92. }
  93.  
  94. ScreenC::~ScreenC()
  95.    /* Unlock previously locked public screen, free DrawInfo and VisualInfo, and close screen.
  96.       Public screens will resist being closed as long as they have windows opened.
  97.    */
  98. {
  99.    if (drawInfo)  FreeScreenDrawInfo(screen(),drawInfo);
  100.    if (visualInfo)  FreeVisualInfo(visualInfo);
  101.    if (lockOnPublic)  UnlockPubScreen(NULL,screen());
  102.    else CloseScreen(screen());
  103. }
  104.  
  105. ULONG ScreenC::setAttributes(AttrList& attrs)
  106. {
  107.    return GraphicObject::setAttributes(attrs);
  108. }
  109.  
  110. ULONG ScreenC::getAttribute(Tag attr,ULONG& dataStore)
  111. {
  112.    return GraphicObject::getAttribute(attr,dataStore);
  113. }
  114. struct DrawInfo *ScreenC::getScreenDrawInfo()
  115. {
  116.    return drawInfo;
  117. }
  118.  
  119. APTR ScreenC::getVisualInfo()
  120. {
  121.    _dprintf("getVisualInfo from this=%lx\n",this);
  122.    return visualInfo;
  123. }
  124.