Added SILC Thread Queue API
[crypto.git] / apps / silcer / src / silcerbasewin.hh
1 /*
2
3   silcerbasewin.hh 
4
5   Author: Pekka Riikonen <priikone@silcnet.org>
6
7   Copyright (C) 2001 Pekka Riikonen
8
9   This program is free software; you can redistribute it and/or modify
10   it under the terms of the GNU General Public License as published by
11   the Free Software Foundation; version 2 of the License.
12
13   This program is distributed in the hope that it will be useful,
14   but WITHOUT ANY WARRANTY; without even the implied warranty of
15   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16   GNU General Public License for more details.
17
18 */
19
20 #ifndef SILCERBASEWIN_HH
21 #define SILCERBASEWIN_HH
22
23 #include "silcer_gladehelper.hh"
24
25 #include "silcincludes.h"
26 #include "silcclient.h"
27
28 #include <sigc++/signal_system.h>
29 #include <sigc++/object_slot.h>
30 #include <sigc++/marshal.h>
31 #include <glade/glade-xml.h>
32 #include <gtk--/box.h>
33 #include <gtk--/button.h>
34 #include <gtk--/checkbutton.h>
35 #include <gtk--/ctree.h>
36 #include <gtk--/entry.h>
37 #include <gtk--/eventbox.h>
38 #include <gtk--/frame.h>
39 #include <gtk--/label.h>
40 #include <gtk--/menuitem.h>
41 #include <gtk--/optionmenu.h>
42 #include <gtk--/text.h>
43 #include <gtk--/widget.h>
44 #include <gtk--/window.h>
45 #include <gnome--/dialog.h>
46 #include <gnome--/entry.h>
47 #include <gnome--/pixmap.h>
48 #include <gnome--/pixmapmenuitem.h>
49
50 using namespace SigC;
51
52 class SilcerBaseWindow : public SigC::Object
53 {
54 public:
55   SilcerBaseWindow(const char *widgetname);
56   virtual ~SilcerBaseWindow();
57
58   void show() { _thisWindow->show(); }
59   void hide() { _thisWindow->hide(); }
60   virtual void close(); 
61   // Object extender
62   virtual void set_dynamic();
63   // Destruction signal
64   Signal0<void, Marshal<void> > evtDestroy;
65
66 protected:
67   SilcerBaseWindow();
68   // FIXME: Should make this function properly copy
69   SilcerBaseWindow& operator=(const SilcerBaseWindow&) { return *this;}
70   SilcerBaseWindow(const SilcerBaseWindow&) {}
71   
72 public:
73   // Helper functions
74
75   Gtk::Button *getButton(const char *name)
76   { return SilcerGetWidget<Gtk::Button>(_thisGH, name); }
77
78   Gtk::CheckButton *getCheckButton(const char *name)
79   { return SilcerGetWidget<Gtk::CheckButton>(_thisGH, name); }
80
81   Gtk::CTree *getCTree(const char *name)
82   { return SilcerGetWidget<Gtk::CTree>(_thisGH, name); }
83
84   Gtk::Entry *getEntry(const char *name)
85   { return SilcerGetWidget<Gtk::Entry>(_thisGH, name); }
86
87   Gtk::EventBox *getEventBox(const char *name)
88   { return SilcerGetWidget<Gtk::EventBox>(_thisGH, name); }
89
90   Gtk::Frame *getFrame(const char *name)
91   { return SilcerGetWidget<Gtk::Frame>(_thisGH, name); }
92
93   Gtk::HBox *getHBox(const char *name)
94   { return SilcerGetWidget<Gtk::HBox>(_thisGH, name); }
95
96   Gnome::Entry *getGEntry(const char *name)
97   { return SilcerGetWidget<Gnome::Entry>(_thisGH, name); }
98
99   Gtk::Label *getLabel(const char *name)
100   { return SilcerGetWidget<Gtk::Label>(_thisGH, name); }
101
102   Gtk::MenuItem *getMenuItem(const char *name)
103   { return SilcerGetWidget<Gtk::MenuItem>(_thisGH, name); }
104
105   Gtk::OptionMenu *getOptionMenu(const char *name)
106   { return SilcerGetWidget<Gtk::OptionMenu>(_thisGH, name); }
107
108   Gnome::Pixmap *getPixmap(const char *name)
109   { return SilcerGetWidget<Gnome::Pixmap>(_thisGH, name); }
110
111   Gtk::PixmapMenuItem *getPixmapMenuItem(const char *name)
112   { return SilcerGetWidget<Gtk::PixmapMenuItem>(_thisGH, name); }
113
114   Gtk::Text *getText(const char *name)
115   { return SilcerGetWidget<Gtk::Text>(_thisGH, name); }
116
117   Gtk::VBox *getVBox(const char *name)
118   { return SilcerGetWidget<Gtk::VBox>(_thisGH, name); }
119
120   template <class T> T *getWidget(const char *name)
121   { return SilcerGetWidget<T>(_thisGH, name); }
122
123 protected:
124   Gtk::Window *_thisWindow;
125
126 private:
127   GladeXML *_thisGH;
128 };
129
130 class SilcerBaseDialog : public SilcerBaseWindow
131 {
132 public:
133   SilcerBaseDialog(const char *widgetname, gboolean close_hides = false);
134   virtual ~SilcerBaseDialog() {}
135
136 protected:
137   Gnome::Dialog *_thisDialog;
138   gboolean on_Dialog_close();
139 };
140
141 class SilcerBaseWidget : public SigC::Object
142 {
143 public:
144   SilcerBaseWidget(const char* widgetname, const char* filename);
145   virtual ~SilcerBaseWidget();
146   void show() { _thisWidget->show(); }
147   void hide() { _thisWidget->hide(); }
148   Gtk::Widget* get_this_widget() { return _thisWidget; }
149   virtual void close(); 
150   // Object extender
151   virtual void set_dynamic();
152   // Destruction signal
153   Signal0<void, Marshal<void> > evtDestroy;
154 protected:
155   SilcerBaseWidget();
156   // FIXME: Should make this function properly copy
157   SilcerBaseWidget& operator=(const SilcerBaseWidget&) { return *this;}
158   SilcerBaseWidget(const SilcerBaseWidget&) {}
159 public:
160   // Helper functions
161
162   Gtk::Button *getButton(const char *name)
163   { return SilcerGetWidget<Gtk::Button>(_thisGH, name); }
164
165   Gtk::CheckButton *getCheckButton(const char *name)
166   { return SilcerGetWidget<Gtk::CheckButton>(_thisGH, name); }
167
168   Gtk::Entry *getEntry(const char *name)
169   { return SilcerGetWidget<Gtk::Entry>(_thisGH, name); }
170
171   Gtk::Label *getLabel(const char *name)
172   { return SilcerGetWidget<Gtk::Label>(_thisGH, name); }
173
174   Gtk::MenuItem *getMenuItem(const char *name)
175   { return SilcerGetWidget<Gtk::MenuItem>(_thisGH, name); }
176
177   Gtk::OptionMenu *getOptionMenu(const char *name)
178   { return SilcerGetWidget<Gtk::OptionMenu>(_thisGH, name); }
179
180   Gtk::PixmapMenuItem *getPixmapMenuItem(const char *name)
181   { return SilcerGetWidget<Gtk::PixmapMenuItem>(_thisGH, name); }
182
183   Gtk::Text *getText(const char *name)
184   { return SilcerGetWidget<Gtk::Text>(_thisGH, name); }
185
186   template <class T> T *getWidget(const char *name)
187   { return SilcerGetWidget<T>(_thisGH, name); }
188
189 protected:
190   Gtk::Widget *_thisWidget;
191
192 private:
193   GladeXML *_thisGH;
194 };
195
196 #endif /* SILCERBASEWIN_HH */