Debian Codegraph @

extern/agg24-svn/include/ctrl/agg_scale_ctrl.h

raw
1 //----------------------------------------------------------------------------
2 // Anti-Grain Geometry - Version 2.4
3 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
4 //
5 // Permission to copy, use, modify, sell and distribute this software
6 // is granted provided this copyright notice appears in all copies.
7 // This software is provided "as is" without express or implied
8 // warranty, and with no claim as to its suitability for any purpose.
9 //
10 //----------------------------------------------------------------------------
11 // Contact: [email protected]
12 // [email protected]
13 // http://www.antigrain.com
14 //----------------------------------------------------------------------------
15 //
16 // classes scale_ctrl_impl, scale_ctrl
17 //
18 //----------------------------------------------------------------------------
19
20 #ifndef AGG_SCALE_CTRL_INCLUDED
21 #define AGG_SCALE_CTRL_INCLUDED
22
23 #include "agg_basics.h"
24 #include "agg_math.h"
25 #include "agg_ellipse.h"
26 #include "agg_trans_affine.h"
27 #include "agg_color_rgba.h"
28 #include "agg_ctrl.h"
29
30
31 namespace agg
32 {
33
34 //------------------------------------------------------------------------
35 class scale_ctrl_impl : public ctrl
36 {
37 enum move_e
38 {
39 move_nothing,
40 move_value1,
41 move_value2,
42 move_slider
43 };
44
45 public:
46 scale_ctrl_impl(double x1, double y1, double x2, double y2, bool flip_y=false);
47
48 void border_thickness(double t, double extra=0.0);
49 void resize(double x1, double y1, double x2, double y2);
50
51 double min_delta() const { return m_min_d; }
52 void min_delta(double d) { m_min_d = d; }
53
54 double value1() const { return m_value1; }
55 void value1(double value);
56
57 double value2() const { return m_value2; }
58 void value2(double value);
59
60 void move(double d);
61
62 virtual bool in_rect(double x, double y) const;
63 virtual bool on_mouse_button_down(double x, double y);
64 virtual bool on_mouse_button_up(double x, double y);
65 virtual bool on_mouse_move(double x, double y, bool button_flag);
66 virtual bool on_arrow_keys(bool left, bool right, bool down, bool up);
67
68 // Vertex soutce interface
69 unsigned num_paths() { return 5; };
70 void rewind(unsigned path_id);
71 unsigned vertex(double* x, double* y);
72
73 private:
74 void calc_box();
75
76 double m_border_thickness;
77 double m_border_extra;
78 double m_value1;
79 double m_value2;
80 double m_min_d;
81 double m_xs1;
82 double m_ys1;
83 double m_xs2;
84 double m_ys2;
85 double m_pdx;
86 double m_pdy;
87 move_e m_move_what;
88 double m_vx[32];
89 double m_vy[32];
90
91 ellipse m_ellipse;
92
93 unsigned m_idx;
94 unsigned m_vertex;
95
96 };
97
98
99
100 //------------------------------------------------------------------------
101 template<class ColorT> class scale_ctrl : public scale_ctrl_impl
102 {
103 public:
104 scale_ctrl(double x1, double y1, double x2, double y2, bool flip_y=false) :
105 scale_ctrl_impl(x1, y1, x2, y2, flip_y),
106 m_background_color(rgba(1.0, 0.9, 0.8)),
107 m_border_color(rgba(0.0, 0.0, 0.0)),
108 m_pointers_color(rgba(0.8, 0.0, 0.0, 0.8)),
109 m_slider_color(rgba(0.2, 0.1, 0.0, 0.6))
110 {
111 m_colors[0] = &m_background_color;
112 m_colors[1] = &m_border_color;
113 m_colors[2] = &m_pointers_color;
114 m_colors[3] = &m_pointers_color;
115 m_colors[4] = &m_slider_color;
116 }
117
118
119 void background_color(const ColorT& c) { m_background_color = c; }
120 void border_color(const ColorT& c) { m_border_color = c; }
121 void pointers_color(const ColorT& c) { m_pointers_color = c; }
122 void slider_color(const ColorT& c) { m_slider_color = c; }
123
124 const ColorT& color(unsigned i) const { return *m_colors[i]; }
125
126 private:
127 scale_ctrl(const scale_ctrl<ColorT>&);
128 const scale_ctrl<ColorT>& operator = (const scale_ctrl<ColorT>&);
129
130 ColorT m_background_color;
131 ColorT m_border_color;
132 ColorT m_pointers_color;
133 ColorT m_slider_color;
134 ColorT* m_colors[5];
135 };
136
137
138
139
140
141 }
142
143
144
145 #endif
146