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

  1.  
  2.  
  3.  
  4.  
  5. #ifndef _stencil_h_ /* Sun Apr  2 13:02:04 1995 */
  6. #define _stencil_h_
  7.  
  8.  
  9.  
  10. #if defined(__GNUC__)
  11. #pragma interface
  12. #endif
  13.  
  14.  
  15. // A Stencil is a binary matrix used for masking when drawing on a
  16. // DisplaySurface. 
  17.  
  18. class UI_Stencil {
  19.  
  20. public:
  21.     UI_Stencil (short w = 1, short h = 1);
  22.     // Constructor.
  23.     
  24.     UI_Stencil (const char data[], short w, short h);
  25.     // Constructor: Build a Stencil from the given array of character
  26.     // data. The data is interpreted as an array of bytes, containing $w$
  27.     // rows and $h$ columns, with each cell being a single byte. The array
  28.     // is interpreted in row-major order.
  29.  
  30.     UI_Stencil (const UI_Stencil&);
  31.     // Copy constructor.
  32.     
  33.     ~UI_Stencil ();
  34.  
  35.     short Width () const {return _width;};
  36.     // Return the width of this Stencil in bytes.
  37.     
  38.     short Height () const {return _height;};
  39.     // Return the number of rows in the Stencil.
  40.     
  41.     char& Byte (short i, short j);
  42.     // Return a reference to the byte at the given position.
  43.  
  44.     short Bit  (short i, short j) const;
  45.     // Interpret the Stencil as an $m \times n$ array of bits, where $m$ is
  46.     // the number of rows and $n$ is eight times the number of
  47.     // columns. Return the bit in the $i$-th row and $j$-th column.
  48.     
  49.  
  50. private:
  51.     char* _data;
  52.     short _width;
  53.     short _height;
  54.  
  55. public:
  56.     char* AsPtr() const {return _data;};
  57.     // For internal use only.
  58.     
  59. };
  60.  
  61. #endif /* _stencil_h_ */
  62.