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 public:
19  virtual ~Appear();
20  const Color* color() const {return color_;}
21  void color(const Color*);
22  const Brush* brush() const {return brush_;}
23  void brush(const Brush*);
24  static const Color* default_color();
25  static const Brush* default_brush();
26 private:
27  const Color* color_;
28  const Brush* brush_;
29  static const Color* dc_;
30  static const Brush* db_;
31 };
32 
33 #if defined(__MWERKS__)
34 #undef Rect
35 #define Rect ivoc_Rect
36 #endif
37 
38 class Rect : public Appear {
39 public:
40  Rect(Coord left, Coord bottom, Coord width, Coord height,
41  const Color* c = NULL, const Brush* b = NULL);
42  virtual void request(Requisition&) const;
43  virtual void allocate(Canvas*, const Allocation&, Extension&);
44  virtual void draw(Canvas*, const Allocation&) const;
45  virtual void pick(Canvas*, const Allocation&, int depth, Hit&);
46 
47  Coord left() const, right() const, top() const, bottom() const;
48  Coord width() const, height() const;
49  void left(Coord), bottom(Coord);
50  void width(Coord), height(Coord);
51 private:
52  Coord l_, b_, w_, h_;
53 };
54 
55 #if defined(__MWERKS__)
56 #undef Line
57 #define Line ivoc_Line
58 #endif
59 
60 class Line : public Appear {
61 public:
62  Line(Coord dx, Coord dy, const Color* color=NULL, const Brush* brush=NULL);
63  Line(Coord dx, Coord dy, float x_align, float y_align,
64  const Color* color=NULL, const Brush* brush=NULL);
65  virtual ~Line();
66 
67  virtual void request(Requisition&) const;
68  virtual void allocate(Canvas*, const Allocation&, Extension&);
69  virtual void draw(Canvas*, const Allocation&) const;
70  virtual void pick(Canvas*, const Allocation&, int depth, Hit&);
71 private:
72  Coord dx_, dy_;
73  float x_, y_;
74 };
75 
76 class Circle : public Appear {
77 public:
78  Circle(float radius, bool filled=false, const Color* color=NULL, const Brush* brush=NULL);
79  virtual ~Circle();
80 
81  virtual void request(Requisition&) const;
82  virtual void allocate(Canvas*, const Allocation&, Extension&);
83  virtual void draw(Canvas*, const Allocation&) const;
84 private:
85  float radius_;
86  bool filled_;
87 };
88 
89 class Triangle : public Appear {
90 public:
91  Triangle(float side, bool filled=false, const Color* color=NULL, const Brush* brush=NULL);
92  virtual ~Triangle();
93 
94  virtual void request(Requisition&) const;
95  virtual void allocate(Canvas*, const Allocation&, Extension&);
96  virtual void draw(Canvas*, const Allocation&) const;
97 private:
98  float side_;
99  bool filled_;
100 };
101 
102 #if defined(__MWERKS__)
103 #undef Rectangle
104 #define Rectangle ivoc_Rectangle
105 #endif
106 
107 class Rectangle : public Appear {
108 public:
109  Rectangle(float height, float width, bool filled=false, const Color* color=NULL, const Brush* brush=NULL);
110  virtual ~Rectangle();
111 
112  virtual void request(Requisition&) const;
113  virtual void allocate(Canvas*, const Allocation&, Extension&);
114  virtual void draw(Canvas*, const Allocation&) const;
115  private:
116  float height_;
117  float width_;
118  bool filled_;
119 };
120 
121 inline Coord Rect::left() const { return l_; }
122 inline Coord Rect::right() const { return l_ + w_; }
123 inline Coord Rect::bottom() const { return b_; }
124 inline Coord Rect::top() const { return b_ + h_; }
125 inline Coord Rect::width() const { return w_; }
126 inline Coord Rect::height() const { return h_; }
127 
128 inline void Rect::left(Coord x) { l_ = x; }
129 inline void Rect::bottom(Coord x) { b_ = x;}
130 inline void Rect::width(Coord x) { w_ = (x > 0) ? x : 1.;}
131 inline void Rect::height(Coord x) { h_ = (x > 0) ? x : 1.;}
132 
133 #endif
Definition: rect.h:76
Coord top() const
Definition: rect.h:124
Coord right() const
Definition: rect.h:122
const Color * color_
Definition: rect.h:27
#define Glyph
Definition: _defines.h:132
#define Coord
Definition: _defines.h:19
Definition: rect.h:89
#define Brush
Definition: _defines.h:59
static const Color * dc_
Definition: rect.h:29
float height_
Definition: rect.h:116
#define Color
Definition: _defines.h:74
static const Color * default_color()
const Brush * brush() const
Definition: rect.h:22
Definition: rect.h:38
Coord width() const
Definition: rect.h:125
Coord bottom() const
Definition: rect.h:123
float side_
Definition: rect.h:98
const Color * color() const
Definition: rect.h:20
float width_
Definition: rect.h:117
static const Brush * default_brush()
const Brush * brush_
Definition: rect.h:28
static N_Vector w_
float radius_
Definition: rect.h:85
static N_Vector x_
Coord height() const
Definition: rect.h:126
#define Canvas
Definition: _defines.h:65
Definition: rect.h:15
Definition: rect.h:60
bool filled_
Definition: rect.h:99
bool filled_
Definition: rect.h:118
#define left
Definition: rbtqueue.cpp:45
#define Line
Definition: _defines.h:11
#define right
Definition: rbtqueue.cpp:46
Coord dy_
Definition: rect.h:72
#define Rect
Definition: rect.h:5
Coord left() const
Definition: rect.h:121
#define c
virtual ~Appear()
bool filled_
Definition: rect.h:86
float y_
Definition: rect.h:73
Coord w_
Definition: rect.h:52
return NULL
Definition: cabcode.cpp:461
Appear(const Color *color=NULL, const Brush *brush=NULL)
static realtype b_
#define Hit
Definition: _defines.h:147
static const Brush * db_
Definition: rect.h:30