00001 #ifndef rect_h 00002 #define rect_h 00003 00004 #undef Rect 00005 #define Rect nrn_Rect 00006 00007 class Requisition; 00008 class Canvas; 00009 class Allocation; 00010 class Extension; 00011 class Hit; 00012 class Brush; 00013 class Color; 00014 00015 class Appear: public Glyph { 00016 protected: 00017 Appear(const Color* color=nil, const Brush* brush=nil); 00018 public: 00019 virtual ~Appear(); 00020 const Color* color() const {return color_;} 00021 void color(const Color*); 00022 const Brush* brush() const {return brush_;} 00023 void brush(const Brush*); 00024 static const Color* default_color(); 00025 static const Brush* default_brush(); 00026 private: 00027 const Color* color_; 00028 const Brush* brush_; 00029 static const Color* dc_; 00030 static const Brush* db_; 00031 }; 00032 00033 #if defined(__MWERKS__) 00034 #undef Rect 00035 #define Rect ivoc_Rect 00036 #endif 00037 00038 class Rect : public Appear { 00039 public: 00040 Rect(Coord left, Coord bottom, Coord width, Coord height, 00041 const Color* c = nil, const Brush* b = nil); 00042 virtual void request(Requisition&) const; 00043 virtual void allocate(Canvas*, const Allocation&, Extension&); 00044 virtual void draw(Canvas*, const Allocation&) const; 00045 virtual void pick(Canvas*, const Allocation&, int depth, Hit&); 00046 00047 Coord left() const, right() const, top() const, bottom() const; 00048 Coord width() const, height() const; 00049 void left(Coord), bottom(Coord); 00050 void width(Coord), height(Coord); 00051 private: 00052 Coord l_, b_, w_, h_; 00053 }; 00054 00055 #if defined(__MWERKS__) 00056 #undef Line 00057 #define Line ivoc_Line 00058 #endif 00059 00060 class Line : public Appear { 00061 public: 00062 Line(Coord dx, Coord dy, const Color* color=nil, const Brush* brush=nil); 00063 Line(Coord dx, Coord dy, float x_align, float y_align, 00064 const Color* color=nil, const Brush* brush=nil); 00065 virtual ~Line(); 00066 00067 virtual void request(Requisition&) const; 00068 virtual void allocate(Canvas*, const Allocation&, Extension&); 00069 virtual void draw(Canvas*, const Allocation&) const; 00070 virtual void pick(Canvas*, const Allocation&, int depth, Hit&); 00071 private: 00072 Coord dx_, dy_; 00073 float x_, y_; 00074 }; 00075 00076 class Circle : public Appear { 00077 public: 00078 Circle(float radius, boolean filled=false, const Color* color=nil, const Brush* brush=nil); 00079 virtual ~Circle(); 00080 00081 virtual void request(Requisition&) const; 00082 virtual void allocate(Canvas*, const Allocation&, Extension&); 00083 virtual void draw(Canvas*, const Allocation&) const; 00084 private: 00085 float radius_; 00086 boolean filled_; 00087 }; 00088 00089 class Triangle : public Appear { 00090 public: 00091 Triangle(float side, boolean filled=false, const Color* color=nil, const Brush* brush=nil); 00092 virtual ~Triangle(); 00093 00094 virtual void request(Requisition&) const; 00095 virtual void allocate(Canvas*, const Allocation&, Extension&); 00096 virtual void draw(Canvas*, const Allocation&) const; 00097 private: 00098 float side_; 00099 boolean filled_; 00100 }; 00101 00102 #if defined(__MWERKS__) 00103 #undef Rectangle 00104 #define Rectangle ivoc_Rectangle 00105 #endif 00106 00107 class Rectangle : public Appear { 00108 public: 00109 Rectangle(float height, float width, boolean filled=false, const Color* color=nil, const Brush* brush=nil); 00110 virtual ~Rectangle(); 00111 00112 virtual void request(Requisition&) const; 00113 virtual void allocate(Canvas*, const Allocation&, Extension&); 00114 virtual void draw(Canvas*, const Allocation&) const; 00115 private: 00116 float height_; 00117 float width_; 00118 boolean filled_; 00119 }; 00120 00121 inline Coord Rect::left() const { return l_; } 00122 inline Coord Rect::right() const { return l_ + w_; } 00123 inline Coord Rect::bottom() const { return b_; } 00124 inline Coord Rect::top() const { return b_ + h_; } 00125 inline Coord Rect::width() const { return w_; } 00126 inline Coord Rect::height() const { return h_; } 00127 00128 inline void Rect::left(Coord x) { l_ = x; } 00129 inline void Rect::bottom(Coord x) { b_ = x;} 00130 inline void Rect::width(Coord x) { w_ = (x > 0) ? x : 1.;} 00131 inline void Rect::height(Coord x) { h_ = (x > 0) ? x : 1.;} 00132 00133 #endif