home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / i / iv26_w_3.zip / EXAMPLES / IDRAW / IPAINT.H < prev    next >
C/C++ Source or Header  |  1980-01-05  |  5KB  |  223 lines

  1. /*
  2.  * Copyright (c) 1987, 1988, 1989 Stanford University
  3.  *
  4.  * Permission to use, copy, modify, distribute, and sell this software and its
  5.  * documentation for any purpose is hereby granted without fee, provided
  6.  * that the above copyright notice appear in all copies and that both that
  7.  * copyright notice and this permission notice appear in supporting
  8.  * documentation, and that the name of Stanford not be used in advertising or
  9.  * publicity pertaining to distribution of the software without specific,
  10.  * written prior permission.  Stanford makes no representations about
  11.  * the suitability of this software for any purpose.  It is provided "as is"
  12.  * without express or implied warranty.
  13.  *
  14.  * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  15.  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
  16.  * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  17.  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  18.  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  19.  * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
  20.  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  21.  */
  22.  
  23. // $Header: ipaint.h,v 1.10 89/10/09 14:48:20 linton Exp $
  24. // declares classes IBrush, IFont, and IPattern.
  25.  
  26. #ifndef ipaint_h
  27. #define ipaint_h
  28.  
  29. #include <InterViews/Graphic/ppaint.h>
  30.  
  31. // An IBrush knows how to test for its noneness and get its line
  32. // pattern, width, arrows, and dash pattern.
  33.  
  34. class IBrush : public PBrush {
  35. public:
  36.  
  37.     IBrush();
  38.     IBrush(int, int, boolean, boolean);
  39.  
  40.     boolean None();
  41.     int GetLinePattern();
  42.     int Width();
  43.     boolean LeftArrow();
  44.     boolean RightArrow();
  45.     const int* GetDashPattern();
  46.     int GetDashPatternSize();
  47.     int GetDashOffset();
  48.     operator Brush*();
  49.  
  50. protected:
  51.  
  52.     void CalcDashPat(int);
  53.  
  54.     boolean leftarrow;        // stores true if line starts from an arrowhead
  55.     boolean rightarrow;        // stores true if line ends in an arrowhead
  56.     int dashpat[patternWidth];    // stores dash pattern
  57.     int dashpatsize;        // stores number of defined elements in dashpat
  58.     int dashoffset;        // stores dash pattern's offset
  59.  
  60. };
  61.  
  62. // Define inline access functions to get members' values.
  63.  
  64. inline boolean IBrush::None () {
  65.     return (value == nil);
  66. }
  67.  
  68. inline boolean IBrush::LeftArrow () {
  69.     return leftarrow;
  70. }
  71.  
  72. inline boolean IBrush::RightArrow () {
  73.     return rightarrow;
  74. }
  75.  
  76. inline int IBrush::GetLinePattern () {
  77.     return p;
  78. }
  79.  
  80. inline const int* IBrush::GetDashPattern () {
  81.     return dashpat;
  82. }
  83.  
  84. inline int IBrush::GetDashPatternSize () {
  85.     return dashpatsize;
  86. }
  87.  
  88. inline int IBrush::GetDashOffset () {
  89.     return dashoffset;
  90. }
  91.  
  92. inline IBrush::operator Brush* () {
  93.     return value;
  94. }
  95.  
  96. // An IColor knows how to get its name.
  97.  
  98. class IColor : public PColor {
  99. public:
  100.  
  101.     IColor(const char*);
  102.     IColor(int, int, int, const char*);
  103.     IColor(Color*, const char*);
  104.     ~IColor();
  105.  
  106.     const char* GetName();
  107.     operator Color*();
  108.  
  109. protected:
  110.  
  111.     char* name;            // stores name passed into constructor
  112.  
  113. };
  114.  
  115. // Define inline access functions to get members' values.
  116.  
  117. inline const char* IColor::GetName () {
  118.     return name;
  119. }
  120.  
  121. inline IColor::operator Color* () {
  122.     return value;
  123. }
  124.  
  125. // An IFont knows how to get its name, print font, and print size.
  126.  
  127. class IFont : public PFont {
  128. public:
  129.  
  130.     IFont(const char*, const char*, const char*);
  131.     ~IFont();
  132.  
  133.     const char* GetName();
  134.     const char* GetPrintFont();
  135.     const char* GetPrintSize();
  136.     const char* GetPrintFontAndSize();
  137.     int GetLineHt();
  138.     operator Font*();
  139.  
  140. protected:
  141.  
  142.     const char* FilterName(const char*);
  143.  
  144.     char* printfont;        // stores name of font used by printer
  145.     char* printsize;        // stores scale of font used by printer
  146.     char* printfontandsize;    // stores name and size separated by a blank
  147.     int lineHt;            // stores printsize converted to int
  148.  
  149. };
  150.  
  151. // Define inline access functions to get members' values.
  152.  
  153. inline const char* IFont::GetName () {
  154.     return name ? name : "stdfont";
  155. }
  156.  
  157. inline const char* IFont::GetPrintFont () {
  158.     return printfont;
  159. }
  160.  
  161. inline const char* IFont::GetPrintSize () {
  162.     return printsize;
  163. }
  164.  
  165. inline const char* IFont::GetPrintFontAndSize () {
  166.     return printfontandsize;
  167. }
  168.  
  169. inline int IFont::GetLineHt () {
  170.     return lineHt;
  171. }
  172.  
  173. inline IFont::operator Font* () {
  174.     return value;
  175. }
  176.  
  177. // An IPattern knows how to test for its noneness or fullness and get
  178. // its dither, data, and gray level.
  179.  
  180. class IPattern : public PPattern {
  181. public:
  182.  
  183.     IPattern();
  184.     IPattern(int, float);
  185.     IPattern(int pattern[patternHeight], int);
  186.  
  187.     boolean None();
  188.     float GetGrayLevel();
  189.     const int* GetData();
  190.     int GetSize();
  191.     operator Pattern*();
  192.  
  193. protected:
  194.  
  195.     float graylevel;        // stores gray level for grayscale patterns
  196.     int size;            // stores pat's orig size (4x4, 8x8, or 16x16)
  197.  
  198. };
  199.  
  200. // Define inline access functions to get members' values.
  201.  
  202. inline boolean IPattern::None () {
  203.     return (value == nil);
  204. }
  205.  
  206. inline float IPattern::GetGrayLevel () {
  207.     return graylevel;
  208. }
  209.  
  210. inline const int* IPattern::GetData () {
  211.     return data;
  212. }
  213.  
  214. inline int IPattern::GetSize () {
  215.     return size;
  216. }
  217.  
  218. inline IPattern::operator Pattern* () {
  219.     return value;
  220. }
  221.  
  222. #endif
  223.