my log
[synfig.git] / synfig-studio / trunk / src / synfigapp / instance.h
1 /* === S Y N F I G ========================================================= */
2 /*!     \file instance.h
3 **      \brief writeme
4 **
5 **      $Id: instance.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_APP_INSTANCE_H
25 #define __SYNFIG_APP_INSTANCE_H
26
27 /* === H E A D E R S ======================================================= */
28
29 #include "action.h"
30 #include <ETL/handle>
31 #include <synfig/canvas.h>
32 #include <synfig/string.h>
33 #include <list>
34 #include <sigc++/signal.h>
35 #include <sigc++/object.h>
36 #include "action_system.h"
37 #include "selectionmanager.h"
38 #include "cvs.h"
39
40 /* === M A C R O S ========================================================= */
41
42 /* === T Y P E D E F S ===================================================== */
43
44 /* === C L A S S E S & S T R U C T S ======================================= */
45
46 namespace synfigapp {
47
48 class CanvasInterface;
49
50
51 class Instance : public Action::System , public CVSInfo
52 {
53         friend class PassiveGrouper;
54         /*
55  -- ** -- P U B L I C   T Y P E S ---------------------------------------------
56         */
57
58 public:
59
60         typedef std::list< etl::handle<CanvasInterface> > CanvasInterfaceList;
61
62         using etl::shared_object::ref;
63         using etl::shared_object::unref;
64
65         /*
66  -- ** -- P U B L I C  D A T A ------------------------------------------------
67         */
68
69 public:
70         
71         /*
72  -- ** -- P R I V A T E   D A T A ---------------------------------------------
73         */
74
75 private:
76         //! Handle for root canvas
77         synfig::Canvas::Handle canvas_;
78
79
80         CanvasInterfaceList canvas_interface_list_;
81
82         sigc::signal<void> signal_filename_changed_;
83         sigc::signal<void> signal_saved_;
84         etl::handle<SelectionManager> selection_manager_;
85         
86 protected:
87         Instance(etl::handle<synfig::Canvas>);
88
89         /*
90  -- ** -- P U B L I C   M E T H O D S -----------------------------------------
91         */
92
93 public:
94
95         ~Instance();
96
97         void set_selection_manager(const etl::handle<SelectionManager> &sm) { assert(sm); selection_manager_=sm; }
98         void unset_selection_manager() { selection_manager_=new NullSelectionManager(); }
99         const etl::handle<SelectionManager> &get_selection_manager() { return selection_manager_; }     
100
101
102
103         etl::handle<CanvasInterface> find_canvas_interface(synfig::Canvas::Handle canvas);
104
105         synfig::Canvas::Handle get_canvas()const { return canvas_; }
106
107         //! Saves the instance to filename_
108         bool save()const;
109
110         bool save_as(const synfig::String &filename)const;
111
112         bool save_as(const synfig::String &filename);
113
114 public: // Interfaces to internal information
115         sigc::signal<void>& signal_filename_changed() { return signal_filename_changed_; }
116         sigc::signal<void>& signal_saved() { return signal_saved_; }
117
118         CanvasInterfaceList & canvas_interface_list() { return canvas_interface_list_; }
119         const CanvasInterfaceList & canvas_interface_list()const { return canvas_interface_list_; }
120
121         synfig::String get_file_name()const;
122
123         void set_file_name(const synfig::String &name);
124
125 public:
126         
127
128 public: // Constructor interfaces
129         static etl::handle<Instance> create(etl::handle<synfig::Canvas> canvas);
130 }; // END class Instance
131
132 etl::handle<Instance> find_instance(etl::handle<synfig::Canvas> canvas);
133
134 bool is_editable(synfig::ValueNode::Handle value_node);
135
136 }; // END namespace studio
137
138 /* === E N D =============================================================== */
139
140 #endif