home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / yacl-012.zip / ui / bitmap.h < prev    next >
C/C++ Source or Header  |  1995-04-08  |  3KB  |  147 lines

  1.  
  2.  
  3. #ifndef _bitmap_h_ /* Wed Mar 23 12:51:01 1994 */
  4. #define _bitmap_h_
  5.  
  6.  
  7.  
  8.  
  9.  
  10. /*
  11.  *
  12.  *          Copyright (C) 1994, M. A. Sridhar
  13.  *  
  14.  *
  15.  *     This software is Copyright M. A. Sridhar, 1994. You are free
  16.  *     to copy, modify or distribute this software  as you see fit,
  17.  *     and to use  it  for  any  purpose, provided   this copyright
  18.  *     notice and the following   disclaimer are included  with all
  19.  *     copies.
  20.  *
  21.  *                        DISCLAIMER
  22.  *
  23.  *     The author makes no warranties, either expressed or implied,
  24.  *     with respect  to  this  software, its  quality, performance,
  25.  *     merchantability, or fitness for any particular purpose. This
  26.  *     software is distributed  AS IS.  The  user of this  software
  27.  *     assumes all risks  as to its quality  and performance. In no
  28.  *     event shall the author be liable for any direct, indirect or
  29.  *     consequential damages, even if the  author has been  advised
  30.  *     as to the possibility of such damages.
  31.  *
  32.  */
  33.  
  34.  
  35.  
  36. // Author: M. A. Sridhar
  37.  
  38.  
  39.  
  40. #if defined(__GNUC__)
  41. #pragma interface
  42. #endif
  43.  
  44.  
  45. #include "ui/rectangl.h"
  46.  
  47. #if defined (__MS_WINDOWS__)
  48. typedef ulong UI_BitmapHandle;
  49.  
  50. #elif defined (__OS2__)
  51. typedef ulong UI_BitmapHandle;
  52.  
  53. #elif defined (__X_MOTIF__)
  54. typedef struct _XImage* UI_BitmapHandle;
  55.  
  56. #endif
  57.  
  58.  
  59. // This class is just the beginning of an encapsulation of bitmaps. It is
  60. // nowhere near complete.
  61.  
  62. class CL_EXPORT UI_DrawingSurface;
  63. class CL_EXPORT UI_DisplaySurface;
  64.  
  65.  
  66. class CL_EXPORT UI_Bitmap: public UI_GraphicObject {
  67.     
  68. public:
  69.     
  70.     UI_Bitmap ();
  71.  
  72. #if defined(__MS_WINDOWS__)
  73.     UI_Bitmap (const char* name);
  74.     // MS-Windows-specific. Creates a Bitmap from the given resource name.
  75.     // If {\tt name} begins with a {\tt +}, the built-in bitmap with given
  76.     // name is constructed.
  77.  
  78. #endif
  79.     
  80.     ~UI_Bitmap ();
  81.  
  82.     UI_BitmapHandle Handle() const { return _handle;};
  83.     
  84.     long BitsPerPixel () const;
  85.     
  86.     long Height () const;
  87.     
  88.     long Width  () const;
  89.     
  90.     UI_Rectangle Shape () const;
  91.     // Return the shape of the bitmap as a rectangle. The origin of the
  92.     // returned rectangle will be (0,0).
  93.     
  94.     UI_Rectangle BoundingRectangle() const {return Shape();};
  95.     
  96.     bool OnBoundary (const UI_Point& p) const {return Shape().OnBoundary(p);};
  97.     
  98.     bool Includes (const UI_Point& p) const {return Shape().Includes (p);};
  99.     
  100.     // UI_Color& operator[] (short i, short j);
  101.     
  102.     bool DrawOn   (UI_DrawingSurface& s,
  103.                    const UI_Point& p = UI_Point (0, 0)) const;
  104.     
  105.     void CopyFrom (UI_DisplaySurface& s, const UI_Rectangle& r);
  106.     
  107.     
  108. protected:
  109.     
  110.     ulong           _width;
  111.     ulong           _height;
  112.     long            _bitsPerPixel;
  113.     UI_BitmapHandle _handle;
  114.     char*           _name;
  115. };
  116.  
  117.  
  118.  
  119.  
  120.  
  121. inline long UI_Bitmap::BitsPerPixel () const
  122. {
  123.     return _bitsPerPixel;
  124. }
  125.  
  126. inline long UI_Bitmap::Height () const
  127. {
  128.     return _height;
  129. }
  130.  
  131. inline long UI_Bitmap::Width  () const
  132. {
  133.     return _width;
  134. }
  135.  
  136.  
  137.  
  138. inline UI_Rectangle UI_Bitmap::Shape () const
  139. {
  140.     return UI_Rectangle (0, 0, _width, _height);
  141. }
  142.  
  143.  
  144.  
  145.  
  146. #endif /* _bitmap_h_ */
  147.