1 /* === S Y N F I G ========================================================= */ 2 /*! \file dialogs/dialog_template.h 3 ** \brief Dialog design list and panel template Header 4 ** 5 ** $Id$ 6 ** 7 ** \legal 8 ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley 9 ** Copyright (c) 2016 Jerome Blanchi 10 ** 11 ** This package is free software; you can redistribute it and/or 12 ** modify it under the terms of the GNU General Public License as 13 ** published by the Free Software Foundation; either version 2 of 14 ** the License, or (at your option) any later version. 15 ** 16 ** This package is distributed in the hope that it will be useful, 17 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 18 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 ** General Public License for more details. 20 ** \endlegal 21 */ 22 /* ========================================================================= */ 23 24 /* === S T A R T =========================================================== */ 25 26 #ifndef __SYNFIG_STUDIO_DIALOG_TEMPLATE_H 27 #define __SYNFIG_STUDIO_DIALOG_TEMPLATE_H 28 29 /* === H E A D E R S ======================================================= */ 30 #include <synfig/general.h> 31 32 #include <gtkmm/dialog.h> 33 #include <gtkmm/grid.h> 34 #include <gtkmm/notebook.h> 35 #include <gtkmm/scrolledwindow.h> 36 #include <gtkmm/treestore.h> 37 #include <gtkmm/treeview.h> 38 39 /* === M A C R O S ========================================================= */ 40 41 /* === T Y P E D E F S ===================================================== */ 42 43 44 /* === C L A S S E S & S T R U C T S ======================================= */ 45 namespace studio { 46 47 /*! \class Dialog Template 48 \brief A dialog design template class. 49 50 Use this abstract class to build in a generic way the synfig studio 51 dialogs to keep design consistency. 52 */ 53 class Dialog_Template : public Gtk::Dialog 54 { 55 56 /* 57 -- ** -- P U B L I C T Y P E S --------------------------------------------- 58 */ 59 60 public: 61 62 /* 63 -- ** -- P R I V A T E D A T A --------------------------------------------- 64 */ 65 66 private: 67 68 //Child widgets: 69 Gtk::Notebook *notebook; 70 Gtk::Grid main_grid; 71 Gtk::ScrolledWindow categories_scrolledwindow; 72 Gtk::TreeView categories_treeview; 73 Glib::RefPtr<Gtk::TreeStore> categories_reftreemodel; 74 75 //Preferences Categories Tree model columns: 76 class Categories : public Gtk::TreeModel::ColumnRecord 77 { 78 public: 79 Categories()80 Categories() { add(category_id); add(category_name); } 81 82 Gtk::TreeModelColumn<int> category_id; 83 Gtk::TreeModelColumn<Glib::ustring> category_name; 84 }; 85 Categories categories; 86 87 int page_index; 88 89 /* 90 -- ** -- P R O T E C T E D D A T A ----------------------------------------------- 91 */ 92 protected: 93 // Style for title(s) 94 Pango::AttrList title_attrlist; 95 Pango::AttrList section_attrlist; 96 97 struct PageInfo 98 { 99 Gtk::Grid* grid; 100 Gtk::TreeRow row; 101 }; 102 103 /* 104 -- ** -- P U B L I C D A T A ----------------------------------------------- 105 */ 106 107 public: 108 109 /* 110 -- ** -- P R I V A T E M E T H O D S --------------------------------------- 111 */ 112 113 private: 114 115 void on_treeviewselection_changed (); 116 117 /* 118 -- ** -- P R O T E C T E D M E T H O D S --------------------------------------- 119 */ 120 121 protected: 122 123 //User Interface Design 124 //! \Brief Set the main title of the page 125 void attach_label_title(Gtk::Grid *grid, synfig::String str); 126 //! \Brief Add a new section (col 0) at specified row 127 void attach_label_section(Gtk::Grid *grid, synfig::String str, guint row); 128 //! \Brief Add a single label (col 0) at specified row 129 void attach_label(Gtk::Grid *grid, synfig::String str, guint row); 130 //! \Brief Add a single label at specified row and col 131 //! \return Gtk::Label* for further change 132 Gtk::Label* attach_label(Gtk::Grid *grid, synfig::String str, guint row, guint col, bool endstring=true); 133 134 //! \Brief Add a new page to the Notebook and Treeview collection 135 //! \return PageInfo used to fill with widget the new page 136 PageInfo add_page(synfig::String page_title); 137 //! \Brief Add a new child page to the Notebook and Treeview collection 138 //! \return PageInfo used to fill with widget the new page 139 PageInfo add_child_page(synfig::String page_title, Gtk::TreeRow parentrow); 140 141 /* 142 -- ** -- S I G N A L S ------------------------------------------------------- 143 */ 144 //Signal handlers dialog 145 virtual void on_ok_pressed() ; 146 virtual void on_apply_pressed() = 0; on_restore_pressed()147 virtual void on_restore_pressed() {} 148 149 /* 150 -- ** -- P U B L I C M E T H O D S --------------------------------------- 151 */ 152 153 public: 154 155 Dialog_Template(Gtk::Window& parent, synfig::String dialog_title); 156 ~Dialog_Template(); 157 158 }; // END of Dialog_Template 159 160 }; // END of namespace studio 161 162 /* === E N D =============================================================== */ 163 164 #endif 165