updates.
[silc.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 extern "C" {
26 #include "silcincludes.h"
27 #include "clientlibincludes.h"
28 }
29
30 #include <sigc++/signal_system.h>
31 #include <sigc++/object_slot.h>
32 #include <sigc++/marshal.h>
33 #include <glade/glade-xml.h>
34 #include <gtk--/box.h>
35 #include <gtk--/button.h>
36 #include <gtk--/checkbutton.h>
37 #include <gtk--/ctree.h>
38 #include <gtk--/entry.h>
39 #include <gtk--/eventbox.h>
40 #include <gtk--/frame.h>
41 #include <gtk--/label.h>
42 #include <gtk--/menuitem.h>
43 #include <gtk--/optionmenu.h>
44 #include <gtk--/text.h>
45 #include <gtk--/widget.h>
46 #include <gtk--/window.h>
47 #include <gnome--/dialog.h>
48 #include <gnome--/entry.h>
49 #include <gnome--/pixmap.h>
50 #include <gnome--/pixmapmenuitem.h>
51
52 using namespace SigC;
53
54 class SilcerBaseWindow : public SigC::Object
55 {
56 public:
57   SilcerBaseWindow(const char *widgetname);
58   virtual ~SilcerBaseWindow();
59
60   void show() { _thisWindow->show(); }
61   void hide() { _thisWindow->hide(); }
62   virtual void close(); 
63   // Object extender
64   virtual void set_dynamic();
65   // Destruction signal
66   Signal0<void, Marshal<void> > evtDestroy;
67
68 protected:
69   SilcerBaseWindow();
70   // FIXME: Should make this function properly copy
71   SilcerBaseWindow& operator=(const SilcerBaseWindow&) { return *this;}
72   SilcerBaseWindow(const SilcerBaseWindow&) {}
73   
74 public:
75   // Helper functions
76
77   Gtk::Button *getButton(const char *name)
78   { return SilcerGetWidget<Gtk::Button>(_thisGH, name); }
79
80   Gtk::CheckButton *getCheckButton(const char *name)
81   { return SilcerGetWidget<Gtk::CheckButton>(_thisGH, name); }
82
83   Gtk::CTree *getCTree(const char *name)
84   { return SilcerGetWidget<Gtk::CTree>(_thisGH, name); }
85
86   Gtk::Entry *getEntry(const char *name)
87   { return SilcerGetWidget<Gtk::Entry>(_thisGH, name); }
88
89   Gtk::EventBox *getEventBox(const char *name)
90   { return SilcerGetWidget<Gtk::EventBox>(_thisGH, name); }
91
92   Gtk::Frame *getFrame(const char *name)
93   { return SilcerGetWidget<Gtk::Frame>(_thisGH, name); }
94
95   Gtk::HBox *getHBox(const char *name)
96   { return SilcerGetWidget<Gtk::HBox>(_thisGH, name); }
97
98   Gnome::Entry *getGEntry(const char *name)
99   { return SilcerGetWidget<Gnome::Entry>(_thisGH, name); }
100
101   Gtk::Label *getLabel(const char *name)
102   { return SilcerGetWidget<Gtk::Label>(_thisGH, name); }
103
104   Gtk::MenuItem *getMenuItem(const char *name)
105   { return SilcerGetWidget<Gtk::MenuItem>(_thisGH, name); }
106
107   Gtk::OptionMenu *getOptionMenu(const char *name)
108   { return SilcerGetWidget<Gtk::OptionMenu>(_thisGH, name); }
109
110   Gnome::Pixmap *getPixmap(const char *name)
111   { return SilcerGetWidget<Gnome::Pixmap>(_thisGH, name); }
112
113   Gtk::PixmapMenuItem *getPixmapMenuItem(const char *name)
114   { return SilcerGetWidget<Gtk::PixmapMenuItem>(_thisGH, name); }
115
116   Gtk::Text *getText(const char *name)
117   { return SilcerGetWidget<Gtk::Text>(_thisGH, name); }
118
119   Gtk::VBox *getVBox(const char *name)
120   { return SilcerGetWidget<Gtk::VBox>(_thisGH, name); }
121
122   template <class T> T *getWidget(const char *name)
123   { return SilcerGetWidget<T>(_thisGH, name); }
124
125 protected:
126   Gtk::Window *_thisWindow;
127
128 private:
129   GladeXML *_thisGH;
130 };
131
132 class SilcerBaseDialog : public SilcerBaseWindow
133 {
134 public:
135   SilcerBaseDialog(const char *widgetname, gboolean close_hides = false);
136   virtual ~SilcerBaseDialog() {}
137
138 protected:
139   Gnome::Dialog *_thisDialog;
140   gboolean on_Dialog_close();
141 };
142
143 class SilcerBaseWidget : public SigC::Object
144 {
145 public:
146   SilcerBaseWidget(const char* widgetname, const char* filename);
147   virtual ~SilcerBaseWidget();
148   void show() { _thisWidget->show(); }
149   void hide() { _thisWidget->hide(); }
150   Gtk::Widget* get_this_widget() { return _thisWidget; }
151   virtual void close(); 
152   // Object extender
153   virtual void set_dynamic();
154   // Destruction signal
155   Signal0<void, Marshal<void> > evtDestroy;
156 protected:
157   SilcerBaseWidget();
158   // FIXME: Should make this function properly copy
159   SilcerBaseWidget& operator=(const SilcerBaseWidget&) { return *this;}
160   SilcerBaseWidget(const SilcerBaseWidget&) {}
161 public:
162   // Helper functions
163
164   Gtk::Button *getButton(const char *name)
165   { return SilcerGetWidget<Gtk::Button>(_thisGH, name); }
166
167   Gtk::CheckButton *getCheckButton(const char *name)
168   { return SilcerGetWidget<Gtk::CheckButton>(_thisGH, name); }
169
170   Gtk::Entry *getEntry(const char *name)
171   { return SilcerGetWidget<Gtk::Entry>(_thisGH, name); }
172
173   Gtk::Label *getLabel(const char *name)
174   { return SilcerGetWidget<Gtk::Label>(_thisGH, name); }
175
176   Gtk::MenuItem *getMenuItem(const char *name)
177   { return SilcerGetWidget<Gtk::MenuItem>(_thisGH, name); }
178
179   Gtk::OptionMenu *getOptionMenu(const char *name)
180   { return SilcerGetWidget<Gtk::OptionMenu>(_thisGH, name); }
181
182   Gtk::PixmapMenuItem *getPixmapMenuItem(const char *name)
183   { return SilcerGetWidget<Gtk::PixmapMenuItem>(_thisGH, name); }
184
185   Gtk::Text *getText(const char *name)
186   { return SilcerGetWidget<Gtk::Text>(_thisGH, name); }
187
188   template <class T> T *getWidget(const char *name)
189   { return SilcerGetWidget<T>(_thisGH, name); }
190
191 protected:
192   Gtk::Widget *_thisWidget;
193
194 private:
195   GladeXML *_thisGH;
196 };
197
198 #endif /* SILCERBASEWIN_HH */