MeshTex  3.0
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
GenericPluginUI.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_GENERICPLUGINUI_H)
27 #define INCLUDED_GENERICPLUGINUI_H
28 
29 #include <vector>
30 #include <gdk/gdk.h>
31 #include <glib.h>
32 
33 #include "GenericMainMenu.h"
34 #include "GenericDialog.h"
35 
36 #include "qerplugin.h"
37 #include "generic/referencecounted.h"
38 
55 {
56 protected: // protected methods
57 
59 
61  virtual ~GenericPluginUI();
63 
64 private: // private methods
65 
67 
69  const GenericPluginUI& operator=(const GenericPluginUI&);
71 
72 public: // public types
73 
80  typedef Callback3<GtkWidget *, GdkEvent *, gpointer, gint> DialogEventCallback;
81 
87  typedef Callback2<GtkWidget *, gpointer, void> DialogSignalCallback;
88 
98  template<typename ObjectClass, gint (ObjectClass::*member)(GtkWidget *, GdkEvent*, gpointer)>
99  class DialogEventCallbackMethod : public BindFirstOpaque3<Member3<ObjectClass, GtkWidget *, GdkEvent*, gpointer, gint, member> >
100  {
101  public:
107  DialogEventCallbackMethod(ObjectClass& object) :
108  BindFirstOpaque3<Member3<ObjectClass, GtkWidget *, GdkEvent *, gpointer, gint, member> >(object) {}
109  };
110 
120  template<typename ObjectClass, void (ObjectClass::*member)(GtkWidget *, gpointer)>
121  class DialogSignalCallbackMethod : public BindFirstOpaque2<Member2<ObjectClass, GtkWidget *, gpointer, void, member> >
122  {
123  public:
129  DialogSignalCallbackMethod(ObjectClass& object) :
130  BindFirstOpaque2<Member2<ObjectClass, GtkWidget *, gpointer, void, member> >(object) {}
131  };
132 
133 public: // public methods
134 
136 
137  void RegisterMainMenu(SmartPointer<GenericMainMenu>& mainMenu);
138  void RegisterDialog(SmartPointer<GenericDialog>& dialog);
139  void SetWindow(GtkWidget *window);
141 
142 
144  GenericDialog *Dialog(const std::string& key);
146 
147 
148  static gint DialogEventCallbackDispatch(GtkWidget *widget,
149  GdkEvent* event,
150  gpointer data);
151  static void DialogSignalCallbackDispatch(GtkWidget *widget,
152  gpointer data);
153  gpointer RegisterDialogEventCallback(GtkWidget *widget,
154  const gchar *name,
155  const DialogEventCallback& callback);
156  gpointer RegisterDialogSignalCallback(GtkWidget *widget,
157  const gchar *name,
158  const DialogSignalCallback& callback);
160 
161 
162  void RegisterWidgetDependence(GtkWidget *controller,
163  GtkWidget *controllee);
164  void RegisterWidgetAntiDependence(GtkWidget *controller,
165  GtkWidget *controllee);
166  void WidgetControlCallback(GtkWidget *widget,
167  gpointer callbackID);
169 
170 
171  static void ErrorReportDialog(const char *title,
172  const char *message);
173  static void WarningReportDialog(const char *title,
174  const char *message);
175  static void InfoReportDialog(const char *title,
176  const char *message);
178 
179 private: // private types
180 
184  typedef std::map<std::string, SmartPointer<GenericDialog> > DialogMap;
185 
189  typedef std::map<gpointer, DialogEventCallback> DialogEventCallbackMap;
190 
194  typedef std::map<gpointer, DialogSignalCallback> DialogSignalCallbackMap;
195 
199  typedef std::map<GtkWidget *, std::vector<GtkWidget *> > WidgetDependenceMap;
200 
201 private: // private member vars
202 
206  GtkWidget *_window;
207 
211  SmartPointer<GenericMainMenu> *_mainMenu;
212 
217  unsigned _callbackID;
218 
224 
229 
234 
239 
245 
251 
257 };
258 
259 
275 
276 #endif // #if !defined(INCLUDED_GENERICPLUGINUI_H)