MeshTex  3.0
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
GenericDialog.h
Go to the documentation of this file.
1 
7 /*
8  * Copyright 2012 Joel Baxter
9  *
10  * This file is part of MeshTex.
11  *
12  * MeshTex is free software: you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation, either version 3 of the License, or
15  * (at your option) any later version.
16  *
17  * MeshTex is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with MeshTex. If not, see <http://www.gnu.org/licenses/>.
24  */
25 
26 #if !defined(INCLUDED_GENERICDIALOG_H)
27 #define INCLUDED_GENERICDIALOG_H
28 
29 #include <string>
30 #include <gdk/gdk.h>
31 #include <glib.h>
32 
33 #include "RefCounted.h"
34 
35 #include "qerplugin.h"
36 
42 #define NamedWidget(widgetName) \
43  (gtk_object_get_data(GTK_OBJECT(_dialog), widgetName))
44 
50 #define NamedToggleWidgetActive(widgetName) \
51  (GTK_TOGGLE_BUTTON(NamedWidget(widgetName))->active)
52 
58 #define NamedEntryWidgetText(widgetName) \
59  (gtk_entry_get_text(GTK_ENTRY(NamedWidget(widgetName))))
60 
70 class GenericDialog : public RefCounted
71 {
72 protected: // protected methods
73 
75 
76  GenericDialog(const std::string& key);
77  virtual ~GenericDialog();
79 
80 private: // private methods
81 
83 
85  const GenericDialog& operator=(const GenericDialog&);
87 
88 public: // public methods
89 
91 
92  const std::string& GetKey() const;
94 
95 
96  virtual void SetWindow(GtkWidget *window);
97  virtual void Raise();
98  virtual void Show(const std::string& triggerCommand);
99  virtual void Hide();
101 
102 
103  virtual bool Apply();
104  virtual gint CloseEventCallback(GtkWidget *widget,
105  GdkEvent* event,
106  gpointer callbackID);
107  virtual void FinalizeCallback(GtkWidget *widget,
108  gpointer callbackID);
110 
111 
113  void CreateOkButtonCallback(GtkWidget *button);
114  void CreateApplyButtonCallback(GtkWidget *button);
115  void CreateCancelButtonCallback(GtkWidget *button);
117 
118 protected: // protected member vars
119 
123  GtkWidget *_dialog;
124 
128  GtkWidget *_window;
129 
133  const std::string _key;
134 
138  std::string _triggerCommand;
139 
143  gpointer _okCallbackID;
144 
149 
154 };
155 
156 #endif // #if !defined(INCLUDED_GENERICDIALOG_H)