home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / intrvews / xgrab.lha / xgrab / include / ipaint.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-04-24  |  3.9 KB  |  207 lines

  1. /**
  2.    GRAB Graph Layout and Browser System
  3.  
  4.    Copyright (c) 1987, 1988, 1989 Stanford University
  5.    Copyright (c) 1989, Tera Computer Company
  6.  **/
  7.  
  8. #ifndef ipaint_h
  9. #define ipaint_h
  10.  
  11. #include <InterViews/Graphic/ppaint.h>
  12.  
  13. // An IBrush knows how to test for its noneness and get its line
  14. // pattern, width, arrows, and dash pattern.
  15.  
  16. class IBrush : public PBrush 
  17. {
  18. public:
  19.     IBrush();
  20.     IBrush(int, int, boolean, boolean);
  21.  
  22.     boolean None();
  23.     int GetLinePattern();
  24.     int Width();
  25.     boolean LeftArrow();
  26.     boolean RightArrow();
  27.     const int* GetDashPattern();
  28.     int GetDashPatternSize();
  29.     int GetDashOffset();
  30.     operator Brush*();
  31. protected:
  32.     void CalcDashPat(int);
  33.  
  34.     boolean leftarrow;        // stores true if line starts from an arrowhead
  35.     boolean rightarrow;        // stores true if line ends in an arrowhead
  36.     int dashpat[patternWidth];    // stores dash pattern
  37.     int dashpatsize;        // stores number of defined elements in dashpat
  38.     int dashoffset;        // stores dash pattern's offset
  39. };
  40.  
  41. // Define inline access functions to get members' values.
  42.  
  43. inline boolean IBrush::None () 
  44. {
  45.     return (value == nil);
  46. }
  47.  
  48. inline boolean IBrush::LeftArrow () 
  49. {
  50.     return leftarrow;
  51. }
  52.  
  53. inline boolean IBrush::RightArrow () 
  54. {
  55.     return rightarrow;
  56. }
  57.  
  58. inline int IBrush::GetLinePattern () 
  59. {
  60.     return p;
  61. }
  62.  
  63. inline const int* IBrush::GetDashPattern () 
  64. {
  65.     return dashpat;
  66. }
  67.  
  68. inline int IBrush::GetDashPatternSize () 
  69. {
  70.     return dashpatsize;
  71. }
  72.  
  73. inline int IBrush::GetDashOffset () 
  74. {
  75.     return dashoffset;
  76. }
  77.  
  78. inline IBrush::operator Brush* () 
  79. {
  80.     return value;
  81. }
  82.  
  83. // An IColor knows how to get its name.
  84.  
  85. class IColor : public PColor 
  86. {
  87. public:
  88.     IColor(const char*);
  89.     IColor(int, int, int, const char*);
  90.     IColor(Color*, const char*);
  91.     ~IColor();
  92.  
  93.     const char* GetName();
  94.     operator Color*();
  95. protected:
  96.     char* name;            // stores name passed into constructor
  97. };
  98.  
  99. // Define inline access functions to get members' values.
  100.  
  101. inline const char* IColor::GetName () 
  102. {
  103.     return name;
  104. }
  105.  
  106. inline IColor::operator Color* () 
  107. {
  108.     return value;
  109. }
  110.  
  111. // An IFont knows how to get its name, print font, and print size.
  112.  
  113. class IFont : public PFont 
  114. {
  115. public:
  116.     IFont(const char*, const char*, const char*);
  117.     ~IFont();
  118.  
  119.     const char* GetName();
  120.     const char* GetPrintFont();
  121.     const char* GetPrintSize();
  122.     const char* GetPrintFontAndSize();
  123.     operator Font*();
  124. protected:
  125.     const char* FilterName(const char*);
  126.  
  127.     char* printfont;        // stores name of font used by printer
  128.     char* printsize;        // stores scale of font used by printer
  129.     char* printfontandsize;    // stores name and size separated by a blank
  130. };
  131.  
  132. // Define inline access functions to get members' values.
  133.  
  134. inline const char* IFont::GetName () 
  135. {
  136.     return name ? name : "stdfont";
  137. }
  138.  
  139. inline const char* IFont::GetPrintFont () 
  140. {
  141.     return printfont;
  142. }
  143.  
  144. inline const char* IFont::GetPrintSize () 
  145. {
  146.     return printsize;
  147. }
  148.  
  149. inline const char* IFont::GetPrintFontAndSize () 
  150. {
  151.     return printfontandsize;
  152. }
  153.  
  154. inline IFont::operator Font* () 
  155. {
  156.     return value;
  157. }
  158.  
  159. // An IPattern knows how to test for its noneness or fullness and get
  160. // its dither, data, and gray level.
  161.  
  162. class IPattern : public PPattern 
  163. {
  164. public:
  165.     IPattern();
  166.     IPattern(int, float);
  167.     IPattern(int[patternHeight], int);
  168.  
  169.     boolean None();
  170.     float GetGrayLevel();
  171.     const int* GetData();
  172.     int GetSize();
  173.     operator Pattern*();
  174. protected:
  175.     float graylevel;        // stores gray level for grayscale patterns
  176.     int size;            // stores pat's orig size (4x4, 8x8, or 16x16)
  177. };
  178.  
  179. // Define inline access functions to get members' values.
  180.  
  181. inline boolean IPattern::None () 
  182. {
  183.     return (value == nil);
  184. }
  185.  
  186. inline float IPattern::GetGrayLevel () 
  187. {
  188.     return graylevel;
  189. }
  190.  
  191. inline const int* IPattern::GetData () 
  192. {
  193.     return data;
  194. }
  195.  
  196. inline int IPattern::GetSize () 
  197. {
  198.     return size;
  199. }
  200.  
  201. inline IPattern::operator Pattern* () 
  202. {
  203.     return value;
  204. }
  205.  
  206. #endif
  207.