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 |
#include <gtkmm.h> |
20 |
#if HAVE_CONFIG_H |
21 |
# include <config.h> |
22 |
#endif |
23 |
#include "compat.h" |
24 |
#include <gtkmm/uimanager.h> |
25 |
#include <gtkmm/actiongroup.h> |
26 |
#include "ManagedWindow.h" |
27 |
|
28 |
class MacroEditor : public ManagedWindow { |
29 |
public: |
30 |
MacroEditor(); |
31 |
~MacroEditor(); |
32 |
void setMacro(Serialization::Archive* macro); |
33 |
|
34 |
// implementation for abstract methods of interface class "ManagedWindow" |
35 |
virtual Settings::Property<int>* windowSettingX() { return &Settings::singleton()->macroEditorWindowX; } |
36 |
virtual Settings::Property<int>* windowSettingY() { return &Settings::singleton()->macroEditorWindowY; } |
37 |
virtual Settings::Property<int>* windowSettingWidth() { return &Settings::singleton()->macroEditorWindowW; } |
38 |
virtual Settings::Property<int>* windowSettingHeight() { return &Settings::singleton()->macroEditorWindowH; } |
39 |
|
40 |
protected: |
41 |
Serialization::Archive* m_macroOriginal; |
42 |
Serialization::Archive m_macro; |
43 |
|
44 |
Gtk::VBox m_vbox; |
45 |
Gtk::HBox m_footerHBox; |
46 |
Gtk::HBox m_statusHBox; |
47 |
Gtk::HButtonBox m_buttonBoxL; |
48 |
Gtk::HButtonBox m_buttonBox; |
49 |
Gtk::ScrolledWindow m_scrolledWindow; |
50 |
|
51 |
class MacroModel : public Gtk::TreeModel::ColumnRecord { |
52 |
public: |
53 |
MacroModel() { |
54 |
add(m_col_name); |
55 |
add(m_col_type); |
56 |
add(m_col_value); |
57 |
add(m_col_uid); |
58 |
} |
59 |
|
60 |
Gtk::TreeModelColumn<Glib::ustring> m_col_name; |
61 |
Gtk::TreeModelColumn<Glib::ustring> m_col_type; |
62 |
Gtk::TreeModelColumn<Glib::ustring> m_col_value; |
63 |
Gtk::TreeModelColumn<Serialization::UID> m_col_uid; |
64 |
} m_treeModelMacro; |
65 |
|
66 |
class MacroTreeStore : public Gtk::TreeStore { |
67 |
public: |
68 |
static Glib::RefPtr<MacroTreeStore> create(const MacroModel& columns) { |
69 |
return Glib::RefPtr<MacroTreeStore>( new MacroTreeStore(columns) ); |
70 |
} |
71 |
protected: |
72 |
MacroTreeStore(const MacroModel& columns) : Gtk::TreeStore(columns) {} |
73 |
}; |
74 |
|
75 |
Gtk::TreeView m_treeViewMacro; |
76 |
Glib::RefPtr<MacroTreeStore> m_treeStoreMacro; |
77 |
bool m_ignoreTreeViewValueChange; |
78 |
|
79 |
Gtk::Label m_statusLabel; |
80 |
Gtk::Button m_deleteButton; |
81 |
Gtk::Button m_inverseDeleteButton; |
82 |
Gtk::Button m_applyButton; |
83 |
Gtk::Button m_cancelButton; |
84 |
|
85 |
bool isModified() const; |
86 |
void onButtonCancel(); |
87 |
void onButtonApply(); |
88 |
void onWindowHide(); |
89 |
bool onWindowDelete(GdkEventAny* e); |
90 |
void updateStatus(); |
91 |
void updateStatusBar(); |
92 |
void reloadTreeView(); |
93 |
void buildTreeView(const Gtk::TreeModel::Row& parentRow, const Serialization::Object& parentObject); |
94 |
void onTreeViewSelectionChanged(); |
95 |
void onMacroTreeViewKeyRelease(GdkEventKey* button); |
96 |
void onMacroTreeViewRowValueChanged(const Gtk::TreeModel::Path& path, |
97 |
const Gtk::TreeModel::iterator& iter); |
98 |
void deleteSelectedRows(); |
99 |
void inverseDeleteSelectedRows(); |
100 |
}; |
101 |
|
102 |
#endif // GIGEDIT_MACROEDITOR_H |