1
//----------------------------------------------------------------------------
2
// Anti-Grain Geometry - Version 2.4
3
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
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.
10
//----------------------------------------------------------------------------
11
// Contact: mcseem@antigrain.com
12
// mcseemagg@yahoo.com
13
// http://www.antigrain.com
14
//----------------------------------------------------------------------------
16
// classes cbox_ctrl_impl, cbox_ctrl
18
//----------------------------------------------------------------------------
20
#ifndef AGG_CBOX_CTRL_INCLUDED
21
#define AGG_CBOX_CTRL_INCLUDED
23
#include "agg_basics.h"
24
#include "agg_conv_stroke.h"
25
#include "agg_gsv_text.h"
26
#include "agg_trans_affine.h"
27
#include "agg_color_rgba.h"
35
//----------------------------------------------------------cbox_ctrl_impl
36
class cbox_ctrl_impl : public ctrl
39
cbox_ctrl_impl(double x, double y, const char* label, bool flip_y=false);
41
void text_thickness(double t) { m_text_thickness = t; }
42
void text_size(double h, double w=0.0);
44
const char* label() { return m_label; }
45
void label(const char* l);
47
bool status() const { return m_status; }
48
void status(bool st) { m_status = st; }
50
virtual bool in_rect(double x, double y) const;
51
virtual bool on_mouse_button_down(double x, double y);
52
virtual bool on_mouse_button_up(double x, double y);
53
virtual bool on_mouse_move(double x, double y, bool button_flag);
54
virtual bool on_arrow_keys(bool left, bool right, bool down, bool up);
56
// Vertex soutce interface
57
unsigned num_paths() { return 3; };
58
void rewind(unsigned path_id);
59
unsigned vertex(double* x, double* y);
62
double m_text_thickness;
71
conv_stroke<gsv_text> m_text_poly;
78
//----------------------------------------------------------cbox_ctrl_impl
79
template<class ColorT> class cbox_ctrl : public cbox_ctrl_impl
82
cbox_ctrl(double x, double y, const char* label, bool flip_y=false) :
83
cbox_ctrl_impl(x, y, label, flip_y),
84
m_text_color(rgba(0.0, 0.0, 0.0)),
85
m_inactive_color(rgba(0.0, 0.0, 0.0)),
86
m_active_color(rgba(0.4, 0.0, 0.0))
88
m_colors[0] = &m_inactive_color;
89
m_colors[1] = &m_text_color;
90
m_colors[2] = &m_active_color;
93
void text_color(const ColorT& c) { m_text_color = c; }
94
void inactive_color(const ColorT& c) { m_inactive_color = c; }
95
void active_color(const ColorT& c) { m_active_color = c; }
97
const ColorT& color(unsigned i) const { return *m_colors[i]; }
100
cbox_ctrl(const cbox_ctrl<ColorT>&);
101
const cbox_ctrl<ColorT>& operator = (const cbox_ctrl<ColorT>&);
104
ColorT m_inactive_color;
105
ColorT m_active_color;