initial version
[synfig.git] / synfig-studio / trunk / src / gtkmm / keyframetreestore.h
1 /* === S I N F G =========================================================== */
2 /*!     \file keyframetreestore.h
3 **      \brief Template Header
4 **
5 **      $Id: keyframetreestore.h,v 1.1.1.1 2005/01/07 03:34:36 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 __SINFG_STUDIO_KEYFRAMETREESTORE_H
25 #define __SINFG_STUDIO_KEYFRAMETREESTORE_H
26
27 /* === H E A D E R S ======================================================= */
28
29 #include <gtkmm/liststore.h>
30 #include <sinfgapp/canvasinterface.h>
31 #include <gdkmm/pixbuf.h>
32 #include <sinfg/keyframe.h>
33 #include <map>
34
35 /* === M A C R O S ========================================================= */
36
37 /* === T Y P E D E F S ===================================================== */
38
39 /* === C L A S S E S & S T R U C T S ======================================= */
40
41 //class TreeRowReferenceHack;
42 //#define TreeRowReferenceHack Gtk::TreeRowReference
43
44 namespace studio {
45
46 class KeyframeTreeStore_Class;
47         
48 class KeyframeTreeStore :
49         public Glib::Object,
50         public Gtk::TreeModel,
51         public Gtk::TreeDragSource,
52         public Gtk::TreeDragDest
53 {
54         /*
55  -- ** -- P U B L I C   T Y P E S ---------------------------------------------
56         */
57
58 public:
59
60         class Model : public Gtk::TreeModel::ColumnRecord
61         {
62         public:
63                 Gtk::TreeModelColumn<sinfg::Time> time;
64                 Gtk::TreeModelColumn<Glib::ustring> description;
65                 Gtk::TreeModelColumn<sinfg::Keyframe> keyframe;
66                 Gtk::TreeModelColumn<sinfg::Time> time_delta;
67         
68                 Model()
69                 {
70                         add(time);
71                         add(description);
72                         add(keyframe);
73                         add(time_delta);
74                 }
75         };
76
77         /*
78  -- ** -- P U B L I C  D A T A ------------------------------------------------
79         */
80
81 public:
82         
83         const Model model;
84
85         /*
86  -- ** -- P R I V A T E   D A T A ---------------------------------------------
87         */
88
89 private:
90
91         etl::loose_handle<sinfgapp::CanvasInterface> canvas_interface_;
92
93         //! Unique stamp for this TreeModel.
94         int stamp_;
95         
96         static KeyframeTreeStore_Class keyframe_tree_store_class_;
97
98         //std::map<sinfg::Keyframe,TreeRowReferenceHack> path_table_;
99
100         sinfg::KeyframeList old_keyframe_list;
101
102         /*
103  -- ** -- P R I V A T E   M E T H O D S ---------------------------------------
104         */
105
106 private:
107
108         void add_keyframe(sinfg::Keyframe);
109
110         void remove_keyframe(sinfg::Keyframe);
111
112         void change_keyframe(sinfg::Keyframe);
113
114         static int sorter(const Gtk::TreeModel::iterator &,const Gtk::TreeModel::iterator &);
115
116         bool iterator_sane(const GtkTreeIter* iter)const;
117
118         bool iterator_sane(const Gtk::TreeModel::iterator& iter)const;
119
120         void dump_iterator(const GtkTreeIter* iter, const Glib::ustring &name)const;
121
122         void dump_iterator(const Gtk::TreeModel::iterator& iter, const Glib::ustring &name)const;
123
124         //! Resets the iterator stamp for this model.
125         /*!     This should be called whenever the class is
126         **      constructed     or when large numbers of
127         **      iterators become invalid. */
128         void reset_stamp();
129         
130         //void reset_path_table();
131
132         /*
133  -- ** -- V I R T U A L   F U N C T I O N S -----------------------------------
134         */
135
136 protected:
137         
138         virtual void set_value_impl (const Gtk::TreeModel::iterator& row, int column, const Glib::ValueBase& value);
139         virtual Gtk::TreeModelFlags  get_flags_vfunc ();
140         virtual int  get_n_columns_vfunc ();
141         virtual GType  get_column_type_vfunc (int index);
142         virtual bool iter_next_vfunc (const iterator& iter, iterator& iter_next) const;
143         virtual bool  get_iter_vfunc (const Gtk::TreeModel::Path& path, iterator& iter_next)const;
144         virtual bool  iter_nth_root_child_vfunc (int n, iterator& iter)const;
145         virtual Gtk::TreeModel::Path  get_path_vfunc (const iterator& iter)const;
146         virtual void  ref_node_vfunc (iterator& iter)const;
147         virtual void  unref_node_vfunc (iterator& iter)const;
148         virtual void  get_value_vfunc (const Gtk::TreeModel::iterator& iter, int column, Glib::ValueBase& value)const;
149         virtual bool    iter_is_valid (const iterator& iter) const;
150         virtual int     iter_n_root_children_vfunc () const;
151
152         //virtual bool  iter_nth_child_vfunc (GtkTreeIter* iter, const GtkTreeIter* parent, int n);
153         //virtual bool  iter_children_vfunc (GtkTreeIter* iter, const GtkTreeIter* parent);
154         //virtual bool  iter_has_child_vfunc (const GtkTreeIter* iter);
155         //virtual int  iter_n_children_vfunc (const GtkTreeIter* iter);
156         //virtual bool  iter_parent_vfunc (GtkTreeIter* iter, const GtkTreeIter* child);
157
158         /*
159         virtual bool  get_sort_column_id_vfunc (int* sort_column_id, Gtk::SortType* order);
160         virtual void  set_sort_column_id_vfunc (int sort_column_id, Gtk::SortType order);
161         virtual void  set_sort_func_vfunc (int sort_column_id, GtkTreeIterCompareFunc func, void* data, GtkDestroyNotify destroy);
162         virtual void  set_default_sort_func_vfunc (GtkTreeIterCompareFunc func, void* data, GtkDestroyNotify destroy);
163         virtual bool  has_default_sort_func_vfunc ();
164         */
165         
166         /*
167  -- ** -- S I G N A L   T E R M I N A L S -------------------------------------
168         */
169
170 private:
171
172         /*
173  -- ** -- P U B L I C   M E T H O D S -----------------------------------------
174         */
175
176 public:
177         
178         KeyframeTreeStore(etl::loose_handle<sinfgapp::CanvasInterface> canvas_interface_);
179         ~KeyframeTreeStore();
180
181         etl::loose_handle<sinfgapp::CanvasInterface> canvas_interface() { return canvas_interface_; }
182         etl::loose_handle<const sinfgapp::CanvasInterface> canvas_interface()const { return canvas_interface_; }
183         
184         sinfg::Canvas::Handle get_canvas() { return canvas_interface()->get_canvas(); }
185         sinfg::Canvas::Handle get_canvas()const { return canvas_interface()->get_canvas(); }
186
187         Gtk::TreeModel::Row find_row(const sinfg::Keyframe &keyframe);
188
189         /*
190  -- ** -- S T A T I C  M E T H O D S ------------------------------------------
191         */
192
193 public:
194
195         static Glib::RefPtr<KeyframeTreeStore> create(etl::loose_handle<sinfgapp::CanvasInterface> canvas_interface_);
196
197         static int time_sorter(const Gtk::TreeModel::iterator &rhs,const Gtk::TreeModel::iterator &lhs);
198
199 }; // END of class KeyframeTreeStore
200
201 //! \internal
202 class KeyframeTreeStore_Class : public Glib::Class
203 {
204 public:
205         struct KeyframeTreeStoreClass
206         {
207                 GObjectClass parent_class;
208         };
209         
210         friend class KeyframeTreeStore;
211         
212         const Glib::Class& init();
213         
214         static void class_init_function(gpointer g_blass, gpointer class_data);
215 }; // END of CustomTreeStore_Class
216
217 }; // END of namespace studio
218
219 /* === E N D =============================================================== */
220
221 #endif