1 // Copyright (c) 2011, Thomas Goyne <plorkyeran@aegisub.org>
2 //
3 // Permission to use, copy, modify, and distribute this software for any
4 // purpose with or without fee is hereby granted, provided that the above
5 // copyright notice and this permission notice appear in all copies.
6 //
7 // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8 // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9 // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
10 // ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11 // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
12 // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
13 // OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
14 //
15 // Aegisub Project http://www.aegisub.org/
16 
17 #include <wx/pen.h>
18 
19 #include <libaegisub/signal.h>
20 
21 namespace agi { class OptionValue; }
22 
23 /// @class Pen
24 /// @brief A simple wrapper around wxPen to bind the colour and width to the
25 /// value of an option
26 class Pen {
27 	wxPen impl;
28 	agi::signal::Connection colour_con;
29 	agi::signal::Connection width_con;
30 
31 	void OnColourChanged(agi::OptionValue const& opt);
32 	void OnWidthChanged(agi::OptionValue const& opt);
33 
34 public:
35 	/// Constructor
36 	/// @param colour_opt Option name to get the colour from
37 	/// @param width_opt Option name to get the width from
38 	/// @param style Pen style
39 	Pen(const char *colour_opt, const char *width_opt, wxPenStyle style = wxPENSTYLE_SOLID);
40 
41 	/// Constructor
42 	/// @param colour_opt Option name to get the colour from
43 	/// @param width Pen width
44 	/// @param style Pen style
45 	Pen(const char *colour_opt, int width = 1, wxPenStyle style = wxPENSTYLE_SOLID);
46 
47 	/// Implicit conversion to wxPen
48 	operator wxPen const&() const { return impl; }
49 };
50