Fix bugs in previous commit that caused FTBFS in synfig and ETL FTBFS with older...
[synfig.git] / synfig-studio / tags / synfigstudio_0_61_07_rc1 / src / gtkmm / workarearenderer.h
1 /* === S Y N F I G ========================================================= */
2 /*!     \file workarearenderer.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_WORKAREARENDERER_H
26 #define __SYNFIG_WORKAREARENDERER_H
27
28 /* === H E A D E R S ======================================================= */
29
30 #include <ETL/handle>
31 #include <sigc++/signal.h>
32 #include <sigc++/object.h>
33 #include <synfig/vector.h>
34 #include <gdkmm/drawable.h>
35 #include <gdkmm/rectangle.h>
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 namespace studio {
44 class WorkArea;
45
46 class WorkAreaRenderer : public etl::shared_object, public sigc::trackable
47 {
48 public:
49         typedef etl::handle<WorkAreaRenderer> Handle;
50         typedef etl::loose_handle<WorkAreaRenderer> LooseHandle;
51
52 private:
53         bool enabled_;
54         int priority_;
55
56         sigc::signal<void> signal_changed_;
57
58         WorkArea* work_area_;
59
60 public:
61
62         sigc::signal<void>& signal_changed() { return signal_changed_; }
63
64 public:
65         int get_w()const;
66         int get_h()const;
67
68         float get_pw()const;
69         float get_ph()const;
70
71         //! Converts screen coords (ie: pixels) to composition coordinates
72         synfig::Point screen_to_comp_coords(synfig::Point pos)const;
73
74         //! Converts composition coordinates to screen coords (ie: pixels)
75         synfig::Point comp_to_screen_coords(synfig::Point pos)const;
76
77         WorkAreaRenderer();
78         virtual ~WorkAreaRenderer();
79
80         bool get_enabled()const { return get_enabled_vfunc(); }
81         int get_priority()const { return priority_; }
82         WorkArea* get_work_area()const { return work_area_; }
83
84         void set_enabled(bool x);
85         void set_priority(int x);
86         void set_work_area(WorkArea* work_area_);
87
88         virtual void render_vfunc(
89                 const Glib::RefPtr<Gdk::Drawable>& window,
90                 const Gdk::Rectangle& expose_area
91         );
92
93         virtual bool event_vfunc(
94                 GdkEvent* event
95         );
96
97 protected:
98
99         virtual bool get_enabled_vfunc()const;
100
101 public:
102         bool operator<(const WorkAreaRenderer &rhs)
103                 { return priority_<rhs.priority_; }
104 };
105
106 inline bool operator<(const WorkAreaRenderer::Handle &lhs,const WorkAreaRenderer::Handle &rhs)
107         { return lhs->get_priority() < rhs->get_priority(); }
108
109 inline bool operator<(const WorkAreaRenderer::LooseHandle &lhs,const WorkAreaRenderer::LooseHandle &rhs)
110         { return lhs->get_priority() < rhs->get_priority(); }
111
112 }; // END of namespace studio
113
114 /* === E N D =============================================================== */
115
116 #endif