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

  1. #ifndef _pen_h_
  2. #define _pen_h_
  3.  
  4.  
  5.  
  6.  
  7.  
  8. /*
  9.  *
  10.  *          Copyright (C) 1994, M. A. Sridhar
  11.  *  
  12.  *
  13.  *     This software is Copyright M. A. Sridhar, 1994. You are free
  14.  *     to copy, modify or distribute this software  as you see fit,
  15.  *     and to use  it  for  any  purpose, provided   this copyright
  16.  *     notice and the following   disclaimer are included  with all
  17.  *     copies.
  18.  *
  19.  *                        DISCLAIMER
  20.  *
  21.  *     The author makes no warranties, either expressed or implied,
  22.  *     with respect  to  this  software, its  quality, performance,
  23.  *     merchantability, or fitness for any particular purpose. This
  24.  *     software is distributed  AS IS.  The  user of this  software
  25.  *     assumes all risks  as to its quality  and performance. In no
  26.  *     event shall the author be liable for any direct, indirect or
  27.  *     consequential damages, even if the  author has been  advised
  28.  *     as to the possibility of such damages.
  29.  *
  30.  */
  31.  
  32.  
  33.  
  34. #if defined(__GNUC__)
  35. #pragma interface
  36. #endif
  37.  
  38.  
  39.  
  40. #include "ui/dsplrsrc.h"
  41. #include "ui/color.h"
  42. #include "ui/rectangl.h"
  43.  
  44.  
  45. // The properties of the Pen class  determine the color and style in which
  46. // lines are drawn on a DrawingSurface.
  47.  
  48.  
  49.  
  50. enum UI_PenPattern   {
  51.     UIPen_None, UIPen_Solid, UIPen_Dash, UIPen_Dot
  52. };
  53.  
  54. class CL_EXPORT UI_Pen : public UI_DisplayResource {
  55.  
  56. public:
  57.     UI_Pen (UI_DrawingSurface* ctxt, short pen_size = 1,
  58.             UI_Color pen_color = UI_Color (UIColor_Black),
  59.             UI_PenPattern patrn = UIPen_Solid);
  60.     
  61.     
  62.     ~UI_Pen ();
  63.  
  64.     // ------------------  Attribute querying methods ----------------
  65.  
  66.     short         Thickness ();
  67.     // Return the thickness of the pen, in pixels.
  68.  
  69.     UI_PenPattern Pattern ();
  70.     // Return the pattern of the pen.
  71.  
  72.     UI_Color      Color();
  73.     // Return the color of the pen.
  74.  
  75.     // ------------------ Attribute setting methods ------------------
  76.     
  77.     void Thickness (short size);
  78.     // Set the thickness of the pen. Under Microsoft Windows, Pens with
  79.     // thickness greater than one pixel will always have pattern {\tt
  80.     // UIPen_Solid}. This is a limitation imposed by Windows.
  81.     
  82.     void Pattern (UI_PenPattern );
  83.     // Set the pen's pattern.
  84.  
  85.     void Color (UI_Color newColor);
  86.     // Set the pen's color.
  87.  
  88.  
  89.     // ---------------------- Basic methods ---------------------------
  90.     
  91.     const char* ClassName () const { return "UI_Pen";};    
  92.  
  93.  
  94.     // ------------------- End public protocol ------------------------
  95.     
  96. protected:
  97.  
  98.     short          _size;
  99.     UI_Color       _color;
  100.     UI_PenPattern  _pattern;
  101.     UI_Point       _position;
  102.  
  103.     void           _Setup();
  104.  
  105. #if defined(__OS2__)
  106. public:
  107.     long OS2Pattern () const;
  108.     // [OS/2-specific, internal use only]
  109.  
  110. #endif
  111.     
  112. };
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119. inline short UI_Pen::Thickness()
  120. {
  121.     return _size;
  122. }
  123.  
  124.  
  125. inline UI_PenPattern UI_Pen::Pattern()
  126. {
  127.     return _pattern;
  128. }
  129.  
  130. inline UI_Color UI_Pen::Color()
  131. {
  132.     return _color;
  133. }
  134.  
  135.  
  136. // inline UI_Point UI_Pen::Position() const
  137. // {
  138. //     return _position;
  139. // }
  140.  
  141.  
  142.  
  143. #endif
  144.  
  145.