my log
[synfig.git] / synfig-studio / trunk / src / gtkmm / workarearenderer.h
1 /* === S Y N F I G ========================================================= */
2 /*!     \file template.h
3 **      \brief Template Header
4 **
5 **      $Id: workarearenderer.h,v 1.1.1.1 2005/01/07 03:34:37 darco Exp $
6 **
7 **      \legal
8 **      Copyright (c) 2002 Robert B. Quattlebaum Jr.
9 **
10 **      This software and associated documentation
11 **      are CONFIDENTIAL and PROPRIETARY property of
12 **      the above-mentioned copyright holder.
13 **
14 **      You may not copy, print, publish, or in any
15 **      other way distribute this software without
16 **      a prior written agreement with
17 **      the copyright holder.
18 **      \endlegal
19 */
20 /* ========================================================================= */
21
22 /* === S T A R T =========================================================== */
23
24 #ifndef __SYNFIG_WORKAREARENDERER_H
25 #define __SYNFIG_WORKAREARENDERER_H
26
27 /* === H E A D E R S ======================================================= */
28
29 #include <ETL/handle>
30 #include <sigc++/signal.h>
31 #include <sigc++/object.h>
32 #include <synfig/vector.h>
33 #include <gdkmm/drawable.h>
34 #include <gdkmm/rectangle.h>
35
36 /* === M A C R O S ========================================================= */
37
38 /* === T Y P E D E F S ===================================================== */
39
40 /* === C L A S S E S & S T R U C T S ======================================= */
41
42 namespace studio {
43 class WorkArea;
44         
45 class WorkAreaRenderer : public etl::shared_object, public sigc::trackable
46 {
47 public:
48         typedef etl::handle<WorkAreaRenderer> Handle;
49         typedef etl::loose_handle<WorkAreaRenderer> LooseHandle;
50
51 private:
52         bool enabled_;
53         int priority_;
54         
55         sigc::signal<void> signal_changed_;
56         
57         WorkArea* work_area_;
58         
59 public:
60
61         sigc::signal<void>& signal_changed() { return signal_changed_; }
62                 
63 public:
64         int get_w()const;
65         int get_h()const;
66         
67         float get_pw()const;
68         float get_ph()const;
69
70         //! Converts screen coords (ie: pixels) to composition coordinates
71         synfig::Point screen_to_comp_coords(synfig::Point pos)const;
72
73         //! Converts composition coordinates to screen coords (ie: pixels)
74         synfig::Point comp_to_screen_coords(synfig::Point pos)const;
75
76         WorkAreaRenderer();
77         virtual ~WorkAreaRenderer();
78
79         bool get_enabled()const { return get_enabled_vfunc(); }
80         int get_priority()const { return priority_; }
81         WorkArea* get_work_area()const { return work_area_; }
82         
83         void set_enabled(bool x);
84         void set_priority(int x);
85         void set_work_area(WorkArea* work_area_);
86         
87         virtual void render_vfunc(
88                 const Glib::RefPtr<Gdk::Drawable>& window,
89                 const Gdk::Rectangle& expose_area
90         );
91
92         virtual bool event_vfunc(
93                 GdkEvent* event
94         );
95
96 protected:
97
98         virtual bool get_enabled_vfunc()const;
99
100 public:
101         bool operator<(const WorkAreaRenderer &rhs)
102                 { return priority_<rhs.priority_; }
103 };
104
105 inline bool operator<(const WorkAreaRenderer::Handle &lhs,const WorkAreaRenderer::Handle &rhs)
106         { return lhs->get_priority() < rhs->get_priority(); }
107
108 inline bool operator<(const WorkAreaRenderer::LooseHandle &lhs,const WorkAreaRenderer::LooseHandle &rhs)
109         { return lhs->get_priority() < rhs->get_priority(); }
110
111 }; // END of namespace studio
112
113 /* === E N D =============================================================== */
114
115 #endif