home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / macfe / gui / CDrawable.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  4.5 KB  |  171 lines

  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19. //   drawable.h - Classes used for maintaining the notion of 
  20. //                offscreen and onscreen drawables, so that 
  21. //                document contents can be drawn to either
  22. //                location. Currently used for LAYERS.
  23.  
  24. #include <QDOffscreen.h>
  25. #include "ntypes.h"
  26. #include "structs.h"
  27.  
  28. #include "layers.h"
  29. #include "cl_types.h"
  30.  
  31. #ifndef _DRAWABLE_H_
  32. #define _DRAWABLE_H_
  33.  
  34.  
  35. #ifdef LAYERS 
  36.  
  37. extern CL_DrawableVTable mfe_drawable_vtable;
  38.  
  39. class CDrawable
  40. {
  41.     public:
  42.     // Constructor and destructor
  43.                                 CDrawable();
  44.                                 ~CDrawable();
  45.  
  46.     // Lock the drawable for use, based on the state passed in.
  47.     // Does nothing in the super class.
  48.         virtual PRBool            LockDrawable(
  49.                                     CL_Drawable*            /*pCLDrawable*/, 
  50.                                     CL_DrawableState        /*newState*/) { return PR_TRUE; }
  51.  
  52.     // Calls to indicate a new client or the relinquishing of the drawable
  53.     // by a client.
  54.         virtual void            InitDrawable(
  55.                                     CL_Drawable*            pCLDrawable);
  56.                                     
  57.         virtual void            RelinquishDrawable(
  58.                                     CL_Drawable*            pCLDrawable);
  59.  
  60.     // Get and set the origin of the drawable
  61.         virtual void            SetLayerOrigin(
  62.                                     int32                    inX,
  63.                                     int32                    inY);
  64.         virtual void            GetLayerOrigin(
  65.                                     int32*                    outX,
  66.                                     int32*                    outY);
  67.  
  68.     // Set the drawable's clip. A value of NULL indicates that the
  69.     // clip should be restored to its initial value.
  70.         virtual void            SetLayerClip(
  71.                                     FE_Region                inClipRgn);
  72.  
  73.         virtual FE_Region        GetLayerClip() { return mClipRgn; }
  74.         
  75.         virtual Boolean            HasClipChanged();
  76.         
  77.     // Call to copy pixels from the given drawable
  78.         virtual void            CopyPixels(
  79.                                     CDrawable *                inSrcDrawable,
  80.                                     FE_Region                hCopyRgn);
  81.  
  82.     // Call to set the width and height of a drawable;
  83.         virtual void            SetDimensions(
  84.                                     int32                    /*inWidth*/,
  85.                                     int32                    /*inHeight*/) {}
  86.         
  87.         virtual GWorldPtr        GetDrawableOffscreen() { return mGWorld; }
  88.  
  89.     // Set the parent drawable
  90.         virtual void            SetParent(
  91.                                     CDrawable*                parent );
  92.                                     
  93.           CDrawable*                mParent;
  94.         GWorldPtr                mGWorld;
  95.         Uint32                    mRefCnt;
  96.         int32                    mOriginX;
  97.         int32                    mOriginY;
  98.         RgnHandle                mClipRgn;
  99.         Boolean                    mClipChanged;
  100. };
  101.  
  102. class COnscreenDrawable :
  103.         public CDrawable
  104. {
  105.     public:
  106.         COnscreenDrawable();
  107.         ~COnscreenDrawable() {}
  108. };
  109.  
  110. class CRouterDrawable :
  111.         public CDrawable
  112. {
  113.     public:
  114.         CRouterDrawable();
  115.         ~CRouterDrawable() {}
  116.  
  117.         virtual void            SetLayerOrigin(
  118.                                     int32                    inX,
  119.                                     int32                    inY);
  120.         virtual void            GetLayerOrigin(
  121.                                     int32*                    outX,
  122.                                     int32*                    outY);
  123.  
  124.         virtual void            SetLayerClip(
  125.                                     FE_Region                inClipRgn);
  126.         virtual FE_Region        GetLayerClip();
  127.         
  128.         virtual Boolean            HasClipChanged();
  129.         
  130.         virtual void            CopyPixels(
  131.                                     CDrawable *                inSrcDrawable,
  132.                                     FE_Region                hCopyRgn);
  133. };
  134.  
  135. class COffscreenDrawable :
  136.         public CDrawable
  137. {
  138.  
  139.     public:
  140.                                 COffscreenDrawable();
  141.                                 ~COffscreenDrawable();
  142.     
  143.     // Factory for creating offscreen drawables
  144.         static COffscreenDrawable* AllocateOffscreen();
  145.  
  146.         virtual void            RelinquishDrawable(
  147.                                     CL_Drawable*            pCLDrawable);
  148.  
  149.         virtual PRBool            LockDrawable(
  150.                                     CL_Drawable*            pCLDrawable, 
  151.                                     CL_DrawableState        newState);
  152.  
  153.         virtual void            SetDimensions(
  154.                                     int32                    inWidth,
  155.                                     int32                    inHeight);
  156.     
  157.   private:
  158.         void                    delete_offscreen();
  159.  
  160.     protected:
  161.         CL_Drawable*            mOwner;
  162.         int32                    mWidth;
  163.         int32                    mHeight;
  164.         
  165.     // In this implementation, we only have a single offscreen drawable
  166.         static COffscreenDrawable *    mOffscreenDrawable;
  167. };
  168.  
  169. #endif // LAYERS 
  170. #endif // _DRAWABLE_H_ 
  171.