NEURON
rect.h
Go to the documentation of this file.
1 #ifndef rect_h
2 #define rect_h
3 
4 #undef Rect
5 #define Rect nrn_Rect
6 
7 class Requisition;
8 class Canvas;
9 class Allocation;
10 class Extension;
11 class Hit;
12 class Brush;
13 class Color;
14 
15 class Appear: public Glyph {
16  protected:
17  Appear(const Color* color = NULL, const Brush* brush = NULL);
18 
19  public:
20  virtual ~Appear();
21  const Color* color() const {
22  return color_;
23  }
24  void color(const Color*);
25  const Brush* brush() const {
26  return brush_;
27  }
28  void brush(const Brush*);
29  static const Color* default_color();
30  static const Brush* default_brush();
31 
32  private:
33  const Color* color_;
34  const Brush* brush_;
35  static const Color* dc_;
36  static const Brush* db_;
37 };
38 
39 #if defined(__MWERKS__)
40 #undef Rect
41 #define Rect ivoc_Rect
42 #endif
43 
44 class Rect: public Appear {
45  public:
47  Coord bottom,
48  Coord width,
49  Coord height,
50  const Color* c = NULL,
51  const Brush* b = NULL);
52  virtual void request(Requisition&) const;
53  virtual void allocate(Canvas*, const Allocation&, Extension&);
54  virtual void draw(Canvas*, const Allocation&) const;
55  virtual void pick(Canvas*, const Allocation&, int depth, Hit&);
56 
57  Coord left() const, right() const, top() const, bottom() const;
58  Coord width() const, height() const;
59  void left(Coord), bottom(Coord);
60  void width(Coord), height(Coord);
61 
62  private:
63  Coord l_, b_, w_, h_;
64 };
65 
66 #if defined(__MWERKS__)
67 #undef Line
68 #define Line ivoc_Line
69 #endif
70 
71 class Line: public Appear {
72  public:
73  Line(Coord dx, Coord dy, const Color* color = NULL, const Brush* brush = NULL);
74  Line(Coord dx,
75  Coord dy,
76  float x_align,
77  float y_align,
78  const Color* color = NULL,
79  const Brush* brush = NULL);
80  virtual ~Line();
81 
82  virtual void request(Requisition&) const;
83  virtual void allocate(Canvas*, const Allocation&, Extension&);
84  virtual void draw(Canvas*, const Allocation&) const;
85  virtual void pick(Canvas*, const Allocation&, int depth, Hit&);
86 
87  private:
88  Coord dx_, dy_;
89  float x_, y_;
90 };
91 
92 class Circle: public Appear {
93  public:
94  Circle(float radius, bool filled = false, const Color* color = NULL, const Brush* brush = NULL);
95  virtual ~Circle();
96 
97  virtual void request(Requisition&) const;
98  virtual void allocate(Canvas*, const Allocation&, Extension&);
99  virtual void draw(Canvas*, const Allocation&) const;
100 
101  private:
102  float radius_;
103  bool filled_;
104 };
105 
106 class Triangle: public Appear {
107  public:
108  Triangle(float side, bool filled = false, const Color* color = NULL, const Brush* brush = NULL);
109  virtual ~Triangle();
110 
111  virtual void request(Requisition&) const;
112  virtual void allocate(Canvas*, const Allocation&, Extension&);
113  virtual void draw(Canvas*, const Allocation&) const;
114 
115  private:
116  float side_;
117  bool filled_;
118 };
119 
120 #if defined(__MWERKS__)
121 #undef Rectangle
122 #define Rectangle ivoc_Rectangle
123 #endif
124 
125 class Rectangle: public Appear {
126  public:
128  float width,
129  bool filled = false,
130  const Color* color = NULL,
131  const Brush* brush = NULL);
132  virtual ~Rectangle();
133 
134  virtual void request(Requisition&) const;
135  virtual void allocate(Canvas*, const Allocation&, Extension&);
136  virtual void draw(Canvas*, const Allocation&) const;
137 
138  private:
139  float height_;
140  float width_;
141  bool filled_;
142 };
143 
144 inline Coord Rect::left() const {
145  return l_;
146 }
147 inline Coord Rect::right() const {
148  return l_ + w_;
149 }
150 inline Coord Rect::bottom() const {
151  return b_;
152 }
153 inline Coord Rect::top() const {
154  return b_ + h_;
155 }
156 inline Coord Rect::width() const {
157  return w_;
158 }
159 inline Coord Rect::height() const {
160  return h_;
161 }
162 
163 inline void Rect::left(Coord x) {
164  l_ = x;
165 }
166 inline void Rect::bottom(Coord x) {
167  b_ = x;
168 }
169 inline void Rect::width(Coord x) {
170  w_ = (x > 0) ? x : 1.;
171 }
172 inline void Rect::height(Coord x) {
173  h_ = (x > 0) ? x : 1.;
174 }
175 
176 #endif
#define Color
Definition: _defines.h:74
#define Canvas
Definition: _defines.h:65
#define Coord
Definition: _defines.h:19
#define Brush
Definition: _defines.h:59
#define Hit
Definition: _defines.h:147
#define Glyph
Definition: _defines.h:132
Definition: rect.h:15
const Color * color_
Definition: rect.h:33
virtual ~Appear()
const Color * color() const
Definition: rect.h:21
static const Color * default_color()
void color(const Color *)
void brush(const Brush *)
const Brush * brush_
Definition: rect.h:34
Appear(const Color *color=NULL, const Brush *brush=NULL)
static const Brush * db_
Definition: rect.h:36
static const Color * dc_
Definition: rect.h:35
static const Brush * default_brush()
const Brush * brush() const
Definition: rect.h:25
Definition: rect.h:92
Circle(float radius, bool filled=false, const Color *color=NULL, const Brush *brush=NULL)
virtual void draw(Canvas *, const Allocation &) const
virtual void request(Requisition &) const
virtual void allocate(Canvas *, const Allocation &, Extension &)
float radius_
Definition: rect.h:102
bool filled_
Definition: rect.h:103
virtual ~Circle()
Definition: rect.h:71
virtual void request(Requisition &) const
Line(Coord dx, Coord dy, float x_align, float y_align, const Color *color=NULL, const Brush *brush=NULL)
Coord dx_
Definition: rect.h:88
float x_
Definition: rect.h:89
virtual ~Line()
virtual void allocate(Canvas *, const Allocation &, Extension &)
Line(Coord dx, Coord dy, const Color *color=NULL, const Brush *brush=NULL)
virtual void draw(Canvas *, const Allocation &) const
virtual void pick(Canvas *, const Allocation &, int depth, Hit &)
Definition: rect.h:44
Coord bottom() const
Definition: rect.h:150
Rect(Coord left, Coord bottom, Coord width, Coord height, const Color *c=NULL, const Brush *b=NULL)
Coord right() const
Definition: rect.h:147
Coord l_
Definition: rect.h:63
Coord b_
Definition: rect.h:63
virtual void allocate(Canvas *, const Allocation &, Extension &)
Coord h_
Definition: rect.h:63
virtual void pick(Canvas *, const Allocation &, int depth, Hit &)
virtual void request(Requisition &) const
Coord height() const
Definition: rect.h:159
Coord width() const
Definition: rect.h:156
Coord top() const
Definition: rect.h:153
Coord left() const
Definition: rect.h:144
Coord w_
Definition: rect.h:63
virtual void draw(Canvas *, const Allocation &) const
virtual void request(Requisition &) const
bool filled_
Definition: rect.h:141
float height_
Definition: rect.h:139
virtual void draw(Canvas *, const Allocation &) const
Rectangle(float height, float width, bool filled=false, const Color *color=NULL, const Brush *brush=NULL)
virtual void allocate(Canvas *, const Allocation &, Extension &)
virtual ~Rectangle()
float width_
Definition: rect.h:140
Definition: rect.h:106
virtual ~Triangle()
virtual void allocate(Canvas *, const Allocation &, Extension &)
virtual void request(Requisition &) const
virtual void draw(Canvas *, const Allocation &) const
float side_
Definition: rect.h:116
bool filled_
Definition: rect.h:117
Triangle(float side, bool filled=false, const Color *color=NULL, const Brush *brush=NULL)
#define c
static N_Vector y_
#define NULL
Definition: sptree.h:16