initial version
[synfig.git] / synfig-studio / trunk / src / gtkmm / instance.h
diff --git a/synfig-studio/trunk/src/gtkmm/instance.h b/synfig-studio/trunk/src/gtkmm/instance.h
new file mode 100644 (file)
index 0000000..bd68918
--- /dev/null
@@ -0,0 +1,223 @@
+/* === S I N F G =========================================================== */
+/*!    \file instance.h
+**     \brief writeme
+**
+**     $Id: instance.h,v 1.2 2005/01/13 18:37:30 darco Exp $
+**
+**     \legal
+**     Copyright (c) 2002 Robert B. Quattlebaum Jr.
+**
+**     This software and associated documentation
+**     are CONFIDENTIAL and PROPRIETARY property of
+**     the above-mentioned copyright holder.
+**
+**     You may not copy, print, publish, or in any
+**     other way distribute this software without
+**     a prior written agreement with
+**     the copyright holder.
+**     \endlegal
+*/
+/* ========================================================================= */
+
+/* === S T A R T =========================================================== */
+
+#ifndef __SINFG_STUDIO_INSTANCE_H
+#define __SINFG_STUDIO_INSTANCE_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <ETL/handle>
+#include <gtkmm/treeview.h>
+#include <gtkmm/treestore.h>
+#include <sinfgapp/instance.h>
+#include <sigc++/object.h>
+#include <sinfgapp/value_desc.h>
+#include "historytreestore.h"
+#include <sinfg/canvas.h>
+
+/* === M A C R O S ========================================================= */
+
+/* === T Y P E D E F S ===================================================== */
+
+/* === C L A S S E S & S T R U C T S ======================================= */
+
+namespace Gtk { class Menu; class ActionGroup; };
+
+namespace studio {
+
+class CanvasView;
+       
+
+class Instance : public sinfgapp::Instance
+{
+public:
+       typedef std::list< etl::handle<CanvasView> > CanvasViewList;
+
+       class CanvasTreeModel : public Gtk::TreeModel::ColumnRecord
+       {
+       public:
+               Gtk::TreeModelColumn<Glib::RefPtr<Gdk::Pixbuf> > icon;
+               Gtk::TreeModelColumn<Glib::ustring> label;
+               Gtk::TreeModelColumn<Glib::ustring> name;
+               Gtk::TreeModelColumn<Glib::ustring> id;
+
+               Gtk::TreeModelColumn<sinfg::Canvas::Handle> canvas;
+               Gtk::TreeModelColumn<bool> is_canvas;
+
+               Gtk::TreeModelColumn<sinfg::ValueNode::Handle> value_node;
+               Gtk::TreeModelColumn<bool> is_value_node;
+               Gtk::TreeModelColumn<sinfg::ValueBase> value;
+               Gtk::TreeModelColumn<Glib::ustring> type;
+               Gtk::TreeModelColumn<int> link_id;
+               Gtk::TreeModelColumn<int> link_count;
+
+               Gtk::TreeModelColumn<bool> is_editable;
+
+               Gtk::TreeModelColumn<sinfgapp::ValueDesc> value_desc;
+       
+               CanvasTreeModel()
+               {
+                       add(value);
+                       add(name);
+                       add(label);
+                       add(icon);
+                       add(type);
+                       add(id);
+                       add(canvas);
+                       add(value_node);
+                       add(is_canvas);
+                       add(is_value_node);
+
+                       add(is_editable);
+                       add(value_desc);
+                       add(link_count);
+                       add(link_id);
+               }
+       } canvas_tree_model;
+       
+private:
+
+       sigc::signal<void,CanvasView*> signal_canvas_view_created_;
+       sigc::signal<void,CanvasView*> signal_canvas_view_deleted_;
+       
+       sigc::signal<void> signal_undo_redo_status_changed_;
+
+       //! Tree containing the canvases -- used for the "canvas browser"
+       Glib::RefPtr<Gtk::TreeStore> canvas_tree_store_;
+
+       //! Tree containing the actions -- used for the "canvas browser"
+       Glib::RefPtr<HistoryTreeStore> history_tree_store_;
+
+       //! Instance number
+       int     id_;
+
+       //! Used to calculate instance ID
+       static int instance_count_;
+
+       //! List of canvas view windows
+       CanvasViewList canvas_view_list_;
+       
+       bool undo_status_;
+       bool redo_status_;
+
+       void set_undo_status(bool x);
+       void set_redo_status(bool x);
+
+       static void _revert(Instance *);
+
+protected:
+
+       Instance(sinfg::Canvas::Handle);
+
+public:
+
+       sigc::signal<void>& signal_undo_redo_status_changed() { return signal_undo_redo_status_changed_; }
+
+       ~Instance();
+
+       sigc::signal<void,CanvasView*>& signal_canvas_view_created() { return signal_canvas_view_created_; }
+       sigc::signal<void,CanvasView*>& signal_canvas_view_deleted() { return signal_canvas_view_deleted_; }
+
+       bool get_undo_status()const { return undo_status_; }
+
+       bool get_redo_status()const { return redo_status_; }
+
+       int get_visible_canvases()const;
+       
+       Glib::RefPtr<Gtk::TreeStore> canvas_tree_store() { return canvas_tree_store_; }
+
+       Glib::RefPtr<const Gtk::TreeStore> canvas_tree_store()const { return canvas_tree_store_; }
+
+       Glib::RefPtr<HistoryTreeStore> history_tree_store() { return history_tree_store_; }
+
+       Glib::RefPtr<const HistoryTreeStore> history_tree_store()const { return history_tree_store_; }
+
+       //! Returns the number of instances that are currently open in the program
+       static int get_count() { return instance_count_; }
+
+       //etl::handle<sinfg::Canvas> get_canvas()const { return sinfgapp::Instance::get_canvas(); }
+       
+       etl::handle<CanvasView> find_canvas_view(etl::handle<sinfg::Canvas> canvas);
+
+       //! Sets the focus to a specific canvas
+       void focus(etl::handle<sinfg::Canvas> canvas);
+
+       CanvasViewList & canvas_view_list() { return canvas_view_list_; }
+       
+       const CanvasViewList & canvas_view_list()const { return canvas_view_list_; }
+
+       bool save_as(const sinfg::String &filename)const;
+
+       bool save_as(const sinfg::String &filename);
+
+       //! Opens a "Save As" dialog, and then saves the composition to that file
+       void dialog_save_as();
+
+       bool save();
+
+       void dialog_cvs_commit();
+
+       void dialog_cvs_add();
+
+       void dialog_cvs_update();
+
+       void dialog_cvs_revert();
+       
+       //! Closes the instance of this composition
+       void close();
+       
+       void revert();
+       
+       void update_all_titles();
+
+       void refresh_canvas_tree();
+       
+       bool safe_revert();
+       bool safe_close();
+
+       void add_actions_to_menu(Gtk::Menu *menu,   const sinfgapp::Action::ParamList &param_list, sinfgapp::Action::Category category=sinfgapp::Action::CATEGORY_ALL)const;
+       void add_actions_to_menu(Gtk::Menu *menu, const sinfgapp::Action::ParamList &param_list1,const sinfgapp::Action::ParamList &param_list2, sinfgapp::Action::Category category=sinfgapp::Action::CATEGORY_ALL)const;
+
+       void add_actions_to_group(const Glib::RefPtr<Gtk::ActionGroup>& action_group, sinfg::String& ui_info,   const sinfgapp::Action::ParamList &param_list, sinfgapp::Action::Category category=sinfgapp::Action::CATEGORY_ALL)const;
+
+       void process_action(sinfg::String name, sinfgapp::Action::ParamList param_list);
+
+       void make_param_menu(Gtk::Menu *menu,sinfg::Canvas::Handle canvas, sinfgapp::ValueDesc value_desc, float location=0.5f);
+
+       void make_param_menu(Gtk::Menu *menu,sinfg::Canvas::Handle canvas,const std::list<sinfgapp::ValueDesc>& value_desc_list);
+
+
+       static void edit_waypoint(sinfgapp::ValueDesc value_desc,sinfg::Waypoint waypoint);
+
+private:
+       void insert_canvas(Gtk::TreeRow row,sinfg::Canvas::Handle canvas);
+
+public:
+       static etl::handle<Instance> create(sinfg::Canvas::Handle canvas);
+}; // END class Instance
+
+}; // END namespace studio
+
+/* === E N D =============================================================== */
+
+#endif