/[svn]/gigedit/trunk/src/gigedit/MacroEditor.h
ViewVC logotype

Contents of /gigedit/trunk/src/gigedit/MacroEditor.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3364 - (show annotations) (download) (as text)
Tue Nov 14 18:07:25 2017 UTC (6 years, 5 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 5803 byte(s)
* Added experimental support for upcoming GTK(MM)4
  (for now up to GTKMM 3.91.2 while still preserving backward compatibility
  down to GTKMM 2).
* Re-merged r2845 to compile now with and without Gtk "Stock ID" API
  (see also r3158).

1 /*
2 Copyright (c) MMXVII Christian Schoenebeck
3
4 This file is part of "gigedit" and released under the terms of the
5 GNU General Public License version 2.
6 */
7
8 #ifndef GIGEDIT_MACROEDITOR_H
9 #define GIGEDIT_MACROEDITOR_H
10
11 #ifdef LIBGIG_HEADER_FILE
12 # include LIBGIG_HEADER_FILE(gig.h)
13 # include LIBGIG_HEADER_FILE(Serialization.h)
14 #else
15 # include <gig.h>
16 # include <Serialization.h>
17 #endif
18
19 #ifdef GTKMM_HEADER_FILE
20 # include GTKMM_HEADER_FILE(gtkmm.h)
21 #else
22 # include <gtkmm.h>
23 #endif
24
25 #if HAVE_CONFIG_H
26 # include <config.h>
27 #endif
28 #include "compat.h"
29 #if USE_GTKMM_BUILDER
30 # include <gtkmm/builder.h>
31 #else
32 # include <gtkmm/uimanager.h> // deprecated in gtkmm >= 3.21.4
33 #endif
34 #include "wrapLabel.hh"
35 #include "ManagedWindow.h"
36
37 /** @brief Editor for gigedit macros.
38 *
39 * Implements a window which allows to edit the abstract tree of one macro
40 * that may be applied with gigedit.
41 */
42 class MacroEditor : public ManagedWindow {
43 public:
44 MacroEditor();
45 ~MacroEditor();
46 void setMacro(Serialization::Archive* macro, bool isClipboard);
47
48 sigc::signal<void>& signal_changes_applied();
49
50 // implementation for abstract methods of interface class "ManagedWindow"
51 virtual Settings::Property<int>* windowSettingX() { return &Settings::singleton()->macroEditorWindowX; }
52 virtual Settings::Property<int>* windowSettingY() { return &Settings::singleton()->macroEditorWindowY; }
53 virtual Settings::Property<int>* windowSettingWidth() { return &Settings::singleton()->macroEditorWindowW; }
54 virtual Settings::Property<int>* windowSettingHeight() { return &Settings::singleton()->macroEditorWindowH; }
55
56 protected:
57 Serialization::Archive* m_macroOriginal;
58 Serialization::Archive m_macro;
59
60 sigc::signal<void> m_changes_applied;
61
62 VBox m_vbox;
63 HBox m_footerHBox;
64 HBox m_statusHBox;
65 HButtonBox m_buttonBoxL;
66 HButtonBox m_buttonBox;
67 Gtk::ScrolledWindow m_scrolledWindow;
68 #if GTKMM_MAJOR_VERSION < 3
69 view::WrapLabel m_labelIntro;
70 #else
71 Gtk::Label m_labelIntro;
72 #endif
73
74 class ComboOptionsModel : public Gtk::TreeModel::ColumnRecord {
75 public:
76 ComboOptionsModel() {
77 add(m_col_choice);
78 }
79
80 Gtk::TreeModelColumn<Glib::ustring> m_col_choice;
81 } m_comboOptionsModel;
82
83 class MacroModel : public Gtk::TreeModel::ColumnRecord {
84 public:
85 MacroModel() {
86 add(m_col_name);
87 add(m_col_type);
88 add(m_col_value);
89 add(m_col_uid);
90 add(m_col_allowTextEntry);
91 add(m_col_editable);
92 add(m_col_options);
93 }
94
95 Gtk::TreeModelColumn<Glib::ustring> m_col_name;
96 Gtk::TreeModelColumn<Glib::ustring> m_col_type;
97 Gtk::TreeModelColumn<Glib::ustring> m_col_value;
98 Gtk::TreeModelColumn<Serialization::UID> m_col_uid;
99 Gtk::TreeModelColumn<bool> m_col_allowTextEntry;
100 Gtk::TreeModelColumn<bool> m_col_editable;
101 Gtk::TreeModelColumn<Glib::RefPtr<Gtk::ListStore> > m_col_options;
102 } m_treeModelMacro;
103
104 class MacroTreeStore : public Gtk::TreeStore {
105 public:
106 static Glib::RefPtr<MacroTreeStore> create(const MacroModel& columns) {
107 return Glib::RefPtr<MacroTreeStore>( new MacroTreeStore(columns) );
108 }
109 protected:
110 MacroTreeStore(const MacroModel& columns) : Gtk::TreeStore(columns) {}
111 };
112
113 Gtk::TreeView m_treeViewMacro;
114 Glib::RefPtr<MacroTreeStore> m_treeStoreMacro;
115 Gtk::CellRendererCombo m_valueCellRenderer;
116 Glib::RefPtr<Gtk::ListStore> m_comboBoxModel;
117 bool m_ignoreTreeViewValueChange;
118
119 Gtk::Label m_statusLabel;
120 Gtk::Button m_deleteButton;
121 Gtk::Button m_inverseDeleteButton;
122 Gtk::Button m_applyButton;
123 Gtk::Button m_cancelButton;
124
125 bool m_altKeyDown;
126 bool m_primaryKeyDown; // on Mac: Cmd key, on all other OSs: Ctrl key
127
128 bool isModified() const;
129 void onButtonCancel();
130 void onButtonApply();
131 void onWindowHide();
132 #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && (GTKMM_MINOR_VERSION > 91 || (GTKMM_MINOR_VERSION == 91 && GTKMM_MICRO_VERSION >= 2))) // GTKMM >= 3.91.2
133 bool onWindowDelete(Gdk::Event& e);
134 #endif
135 bool onWindowDeleteP(GdkEventAny* e);
136 void updateStatus();
137 void updateStatusBar();
138 void reloadTreeView();
139 void buildTreeView(const Gtk::TreeModel::Row& parentRow, const Serialization::Object& parentObject);
140 void onTreeViewSelectionChanged();
141
142 #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && (GTKMM_MINOR_VERSION > 91 || (GTKMM_MINOR_VERSION == 91 && GTKMM_MICRO_VERSION >= 2))) // GTKMM >= 3.91.2
143 bool onMacroTreeViewKeyRelease(Gdk::EventKey& key);
144 #else
145 void onMacroTreeViewKeyRelease(GdkEventKey* button);
146 #endif
147 void onMacroTreeViewRowValueChanged(const Gtk::TreeModel::Path& path,
148 const Gtk::TreeModel::iterator& iter);
149 void onMacroTreeViewRowValueChangedImpl(const Gtk::TreeModel::Path& path,
150 const Gtk::TreeModel::iterator& iter,
151 const Glib::ustring& value);
152 void onValueCellEdited(const Glib::ustring& sPath, const Glib::ustring& text);
153 void deleteSelectedRows();
154 void inverseDeleteSelectedRows();
155 void deleteRows(const std::vector<Gtk::TreeModel::Path>& rows);
156 #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && (GTKMM_MINOR_VERSION > 91 || (GTKMM_MINOR_VERSION == 91 && GTKMM_MICRO_VERSION >= 2))) // GTKMM >= 3.91.2
157 bool onKeyPressed(Gdk::EventKey& key);
158 bool onKeyReleased(Gdk::EventKey& key);
159 #else
160 bool onKeyPressed(GdkEventKey* key);
161 bool onKeyReleased(GdkEventKey* key);
162 #endif
163 Glib::RefPtr<Gtk::ListStore> createComboOptions(const char** options);
164 };
165
166 #endif // GIGEDIT_MACROEDITOR_H

  ViewVC Help
Powered by ViewVC