1 /* === S Y N F I G ========================================================= */
5 ** $Id: instance.h,v 1.2 2005/01/13 18:37:30 darco Exp $
8 ** Copyright (c) 2002 Robert B. Quattlebaum Jr.
10 ** This software and associated documentation
11 ** are CONFIDENTIAL and PROPRIETARY property of
12 ** the above-mentioned copyright holder.
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.
20 /* ========================================================================= */
22 /* === S T A R T =========================================================== */
24 #ifndef __SYNFIG_STUDIO_INSTANCE_H
25 #define __SYNFIG_STUDIO_INSTANCE_H
27 /* === H E A D E R S ======================================================= */
30 #include <gtkmm/treeview.h>
31 #include <gtkmm/treestore.h>
32 #include <synfigapp/instance.h>
33 #include <sigc++/object.h>
34 #include <synfigapp/value_desc.h>
35 #include "historytreestore.h"
36 #include <synfig/canvas.h>
38 /* === M A C R O S ========================================================= */
40 /* === T Y P E D E F S ===================================================== */
42 /* === C L A S S E S & S T R U C T S ======================================= */
44 namespace Gtk { class Menu; class ActionGroup; };
51 class Instance : public synfigapp::Instance
54 typedef std::list< etl::handle<CanvasView> > CanvasViewList;
56 class CanvasTreeModel : public Gtk::TreeModel::ColumnRecord
59 Gtk::TreeModelColumn<Glib::RefPtr<Gdk::Pixbuf> > icon;
60 Gtk::TreeModelColumn<Glib::ustring> label;
61 Gtk::TreeModelColumn<Glib::ustring> name;
62 Gtk::TreeModelColumn<Glib::ustring> id;
64 Gtk::TreeModelColumn<synfig::Canvas::Handle> canvas;
65 Gtk::TreeModelColumn<bool> is_canvas;
67 Gtk::TreeModelColumn<synfig::ValueNode::Handle> value_node;
68 Gtk::TreeModelColumn<bool> is_value_node;
69 Gtk::TreeModelColumn<synfig::ValueBase> value;
70 Gtk::TreeModelColumn<Glib::ustring> type;
71 Gtk::TreeModelColumn<int> link_id;
72 Gtk::TreeModelColumn<int> link_count;
74 Gtk::TreeModelColumn<bool> is_editable;
76 Gtk::TreeModelColumn<synfigapp::ValueDesc> value_desc;
100 sigc::signal<void,CanvasView*> signal_canvas_view_created_;
101 sigc::signal<void,CanvasView*> signal_canvas_view_deleted_;
103 sigc::signal<void> signal_undo_redo_status_changed_;
105 //! Tree containing the canvases -- used for the "canvas browser"
106 Glib::RefPtr<Gtk::TreeStore> canvas_tree_store_;
108 //! Tree containing the actions -- used for the "canvas browser"
109 Glib::RefPtr<HistoryTreeStore> history_tree_store_;
114 //! Used to calculate instance ID
115 static int instance_count_;
117 //! List of canvas view windows
118 CanvasViewList canvas_view_list_;
123 void set_undo_status(bool x);
124 void set_redo_status(bool x);
126 static void _revert(Instance *);
130 Instance(synfig::Canvas::Handle);
134 sigc::signal<void>& signal_undo_redo_status_changed() { return signal_undo_redo_status_changed_; }
138 sigc::signal<void,CanvasView*>& signal_canvas_view_created() { return signal_canvas_view_created_; }
139 sigc::signal<void,CanvasView*>& signal_canvas_view_deleted() { return signal_canvas_view_deleted_; }
141 bool get_undo_status()const { return undo_status_; }
143 bool get_redo_status()const { return redo_status_; }
145 int get_visible_canvases()const;
147 Glib::RefPtr<Gtk::TreeStore> canvas_tree_store() { return canvas_tree_store_; }
149 Glib::RefPtr<const Gtk::TreeStore> canvas_tree_store()const { return canvas_tree_store_; }
151 Glib::RefPtr<HistoryTreeStore> history_tree_store() { return history_tree_store_; }
153 Glib::RefPtr<const HistoryTreeStore> history_tree_store()const { return history_tree_store_; }
155 //! Returns the number of instances that are currently open in the program
156 static int get_count() { return instance_count_; }
158 //etl::handle<synfig::Canvas> get_canvas()const { return synfigapp::Instance::get_canvas(); }
160 etl::handle<CanvasView> find_canvas_view(etl::handle<synfig::Canvas> canvas);
162 //! Sets the focus to a specific canvas
163 void focus(etl::handle<synfig::Canvas> canvas);
165 CanvasViewList & canvas_view_list() { return canvas_view_list_; }
167 const CanvasViewList & canvas_view_list()const { return canvas_view_list_; }
169 bool save_as(const synfig::String &filename)const;
171 bool save_as(const synfig::String &filename);
173 //! Opens a "Save As" dialog, and then saves the composition to that file
174 void dialog_save_as();
178 void dialog_cvs_commit();
180 void dialog_cvs_add();
182 void dialog_cvs_update();
184 void dialog_cvs_revert();
186 //! Closes the instance of this composition
191 void update_all_titles();
193 void refresh_canvas_tree();
198 void add_actions_to_menu(Gtk::Menu *menu, const synfigapp::Action::ParamList ¶m_list, synfigapp::Action::Category category=synfigapp::Action::CATEGORY_ALL)const;
199 void add_actions_to_menu(Gtk::Menu *menu, const synfigapp::Action::ParamList ¶m_list1,const synfigapp::Action::ParamList ¶m_list2, synfigapp::Action::Category category=synfigapp::Action::CATEGORY_ALL)const;
201 void add_actions_to_group(const Glib::RefPtr<Gtk::ActionGroup>& action_group, synfig::String& ui_info, const synfigapp::Action::ParamList ¶m_list, synfigapp::Action::Category category=synfigapp::Action::CATEGORY_ALL)const;
203 void process_action(synfig::String name, synfigapp::Action::ParamList param_list);
205 void make_param_menu(Gtk::Menu *menu,synfig::Canvas::Handle canvas, synfigapp::ValueDesc value_desc, float location=0.5f);
207 void make_param_menu(Gtk::Menu *menu,synfig::Canvas::Handle canvas,const std::list<synfigapp::ValueDesc>& value_desc_list);
210 static void edit_waypoint(synfigapp::ValueDesc value_desc,synfig::Waypoint waypoint);
213 void insert_canvas(Gtk::TreeRow row,synfig::Canvas::Handle canvas);
216 static etl::handle<Instance> create(synfig::Canvas::Handle canvas);
217 }; // END class Instance
219 }; // END namespace studio
221 /* === E N D =============================================================== */