1 /* === S Y N F I G ========================================================= */
2 /*!	\file inputdevice.h
3 **	\brief Template Header
4 **
5 **	$Id$
6 **
7 **	\legal
8 **	Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
9 **
10 **	This package is free software; you can redistribute it and/or
11 **	modify it under the terms of the GNU General Public License as
12 **	published by the Free Software Foundation; either version 2 of
13 **	the License, or (at your option) any later version.
14 **
15 **	This package is distributed in the hope that it will be useful,
16 **	but WITHOUT ANY WARRANTY; without even the implied warranty of
17 **	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 **	General Public License for more details.
19 **	\endlegal
20 */
21 /* ========================================================================= */
22 
23 /* === S T A R T =========================================================== */
24 
25 #ifndef __SYNFIG_INPUTDEVICE_H
26 #define __SYNFIG_INPUTDEVICE_H
27 
28 /* === H E A D E R S ======================================================= */
29 
30 #include <vector>
31 #include <synfig/color.h>
32 #include <synfig/vector.h>
33 #include <synfig/distance.h>
34 #include <synfig/string.h>
35 #include <ETL/handle>
36 
37 /* === M A C R O S ========================================================= */
38 
39 /* === T Y P E D E F S ===================================================== */
40 
41 /* === C L A S S E S & S T R U C T S ======================================= */
42 
43 class DeviceSettings;
44 
45 namespace synfigapp {
46 class Settings;
47 
48 
49 /*!	\class  InputDevice  inputdevice.h  "synfigapp/inputdevice.h"
50 **	\brief  This class provides a device independent representation the state
51 **	        of an input device.
52 **  \see  studio::DeviceTracker
53 **  \see  synfigapp::Settings
54 **
55 **   The represenation includes both the GDK state (e.g., mode) and synfigstudio
56 **   state (e.g., outline color). An object of this class can be saved and
57 **   restored using its Settings object, provided by the settings method.
58 */
59 class InputDevice : public etl::shared_object
60 {
61 public:
62 	enum Type
63 	{
64 		TYPE_MOUSE,
65 		TYPE_PEN,
66 		TYPE_ERASER,
67 		TYPE_CURSOR
68 	};
69 
70 	enum Mode
71 	{
72 		MODE_DISABLED,
73 		MODE_SCREEN,
74 		MODE_WINDOW
75 	};
76 
77 	enum AxisUse
78 	{
79 	  AXIS_IGNORE,
80 	  AXIS_X,
81 	  AXIS_Y,
82 	  AXIS_PRESSURE,
83 	  AXIS_XTILT,
84 	  AXIS_YTILT,
85 	  AXIS_WHEEL,
86 	  AXIS_LAST
87 	};
88 
89 	struct DeviceKey
90 	{
91 	  unsigned int keyval;
92 	  unsigned int modifiers;
93 	};
94 
95 	typedef etl::handle<InputDevice> Handle;
96 
97 private:
98 	synfig::String id_;
99 	Type type_;
100 	synfig::String state_;
101 	synfig::Color outline_color_;
102 	synfig::Color fill_color_;
103 	synfig::Distance	bline_width_;
104 	synfig::Real opacity_;
105 	synfig::Color::BlendMethod blend_method_;
106 	Mode mode_;
107 	std::vector<AxisUse> axes_;
108 	std::vector<DeviceKey> keys_;
109 
110 	DeviceSettings* device_settings;
111 
112 public:
113 	InputDevice(const synfig::String id_, Type type_=TYPE_MOUSE);
114 	~InputDevice();
115 
get_id()116 	const synfig::String& get_id()const { return id_; }
get_state()117 	const synfig::String& get_state()const { return state_; }
get_outline_color()118 	const synfig::Color& get_outline_color()const { return outline_color_; }
get_fill_color()119 	const synfig::Color& get_fill_color()const { return fill_color_; }
get_bline_width()120 	const synfig::Distance& get_bline_width()const { return bline_width_; }
get_opacity()121 	const synfig::Real& get_opacity()const { return opacity_; }
get_blend_method()122 	const synfig::Color::BlendMethod& get_blend_method()const { return blend_method_; }
get_type()123 	Type get_type()const { return type_; }
get_mode()124 	Mode get_mode()const { return mode_; }
get_axes()125 	const std::vector<AxisUse> & get_axes()const { return axes_; }
get_keys()126 	const std::vector<DeviceKey> & get_keys()const { return keys_; }
127 
set_state(const synfig::String & x)128 	void set_state(const synfig::String& x) { state_=x; }
set_outline_color(const synfig::Color & x)129 	void set_outline_color(const synfig::Color& x) { outline_color_=x; }
set_fill_color(const synfig::Color & x)130 	void set_fill_color(const synfig::Color& x) { fill_color_=x; }
set_bline_width(const synfig::Distance & x)131 	void set_bline_width(const synfig::Distance& x) { bline_width_=x; }
set_blend_method(const synfig::Color::BlendMethod & x)132 	void set_blend_method(const synfig::Color::BlendMethod& x) { blend_method_=x; }
set_opacity(const synfig::Real & x)133 	void set_opacity(const synfig::Real& x) { opacity_=x; }
set_type(Type x)134 	void set_type(Type x) { type_=x; }
set_mode(Mode x)135 	void set_mode(Mode x) { mode_=x; }
set_axes(const std::vector<AxisUse> & x)136 	void set_axes(const std::vector<AxisUse>& x) { axes_=x; }
set_keys(const std::vector<DeviceKey> & x)137 	void set_keys(const std::vector<DeviceKey>& x) { keys_=x; }
138 
139 	Settings& settings();
140 	const Settings& settings()const;
141 }; // END of class InputDevice
142 
143 }; // END of namespace synfigapp
144 
145 /* === E N D =============================================================== */
146 
147 #endif
148