src/gui.h

changeset 237
ec77f6e9a19f
parent 230
43d722c255d3
child 251
c4b96bc41298
equal deleted inserted replaced
236:b58d35dc5d52 237:ec77f6e9a19f
42 connect (bbx_buttons, SIGNAL (rejected ()), this, SLOT (reject ())); \ 42 connect (bbx_buttons, SIGNAL (rejected ()), this, SLOT (reject ())); \
43 43
44 // ============================================================================= 44 // =============================================================================
45 // Metadata for actions 45 // Metadata for actions
46 typedef struct { 46 typedef struct {
47 QAction** const qAct; 47 QAction** qAct;
48 keyseqconfig* const conf; 48 keyseqconfig* conf;
49 const char* const name, *sDisplayName, *sIconName, *sDescription; 49 const char* name, *sDisplayName, *sIconName, *sDescription;
50 void (*const handler) (); 50 void (*handler) ();
51 } actionmeta; 51 } actionmeta;
52 52
53 extern vector<actionmeta> g_ActionMeta; 53 #define MAX_ACTIONS 256
54 extern actionmeta g_actionMeta[256];
54 55
55 // ============================================================================= 56 // =============================================================================
56 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 57 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
57 // ============================================================================= 58 // =============================================================================
58 #define MAKE_ACTION(NAME, DISPLAYNAME, ICONNAME, DESCR, DEFSHORTCUT) \ 59 #define MAKE_ACTION(NAME, DISPLAYNAME, ICONNAME, DESCR, DEFSHORTCUT) \
76 typedef struct { 77 typedef struct {
77 color* col; 78 color* col;
78 QToolButton* btn; 79 QToolButton* btn;
79 bool bSeparator; 80 bool bSeparator;
80 } quickColorMetaEntry; 81 } quickColorMetaEntry;
81
82 // =============================================================================
83 // ActionAdder
84 //
85 // The ACTION macro expands into - among other stuff - into an instance of this.
86 // This class' constructor creates meta for the newly defined action and stores
87 // it in g_ActionMeta. It is not supposed to be used directly!
88 // =============================================================================
89 class ActionAdder {
90 public:
91 ActionAdder (QAction** qAct, const char* sDisplayName, const char* sIconName,
92 const char* sDescription, keyseqconfig* conf, void (*const handler) (),
93 const char* name)
94 {
95 actionmeta meta = {qAct, conf, name, sDisplayName, sIconName, sDescription, handler};
96 g_ActionMeta.push_back (meta);
97 }
98 };
99 82
100 // ============================================================================= 83 // =============================================================================
101 // ObjectList 84 // ObjectList
102 // 85 //
103 // Object list class for ForgeWindow 86 // Object list class for ForgeWindow
144 std::vector<LDObject*>& sel () { return m_sel; } 127 std::vector<LDObject*>& sel () { return m_sel; }
145 void setQuickColorMeta (std::vector<quickColorMetaEntry>& quickColorMeta) { 128 void setQuickColorMeta (std::vector<quickColorMetaEntry>& quickColorMeta) {
146 m_colorMeta = quickColorMeta; 129 m_colorMeta = quickColorMeta;
147 } 130 }
148 void setStatusBarText (str text); 131 void setStatusBarText (str text);
132 void addActionMeta (actionmeta& meta);
149 133
150 protected: 134 protected:
151 void closeEvent (QCloseEvent* ev); 135 void closeEvent (QCloseEvent* ev);
152 void logVA (LogType eType, const char* fmtstr, va_list va); 136 void logVA (LogType eType, const char* fmtstr, va_list va);
153 137
199 183
200 // ----------------------------------------------------------------------------- 184 // -----------------------------------------------------------------------------
201 // Pointer to the instance of ForgeWindow. 185 // Pointer to the instance of ForgeWindow.
202 extern ForgeWindow* g_win; 186 extern ForgeWindow* g_win;
203 187
188 // =============================================================================
189 // ActionAdder
190 //
191 // The MAKE_ACTION macro expands into - among other stuff - into an instance
192 // of this. This class' constructor creates meta for the newly defined action
193 // and stores it in g_actionMeta. Don't use this directly!
194 // =============================================================================
195 class ActionAdder {
196 public:
197 ActionAdder (QAction** act, const char* displayName, const char* iconName,
198 const char* description, keyseqconfig* conf, void (*const handler) (),
199 const char* name)
200 {
201 actionmeta meta = {act, conf, name, displayName, iconName, description, handler};
202 g_win->addActionMeta (meta);
203 }
204 };
205
204 #endif // GUI_H 206 #endif // GUI_H

mercurial