edelib 1.0

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List

Window.h
1 /*
2 * $Id: Window.h 2925 2009-11-10 11:06:08Z karijes $
3 *
4 * Window class
5 * Copyright (c) 2005-2007 edelib authors
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with this library. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 #ifndef __EDELIB_WINDOW_H__
22 #define __EDELIB_WINDOW_H__
23
24 #include "XSettingsClient.h"
25 #include <FL/Fl_Double_Window.H>
26
27 EDELIB_NS_BEGIN
28
34 enum WindowComponents {
35 WIN_INIT_NONE = (1 << 1),
36 WIN_INIT_ICON_THEME = (1 << 2),
37 WIN_INIT_IMAGES = (1 << 3),
38 WIN_INIT_ALL = (WIN_INIT_ICON_THEME | WIN_INIT_IMAGES)
39 };
40
41 #ifndef SKIP_DOCS
42 typedef bool (WindowXSettingsCallback)(const char* name, XSettingsAction action,
43 const XSettingsSetting* setting, void* data);
44 #endif
45
73 class EDELIB_API Window : public Fl_Double_Window {
74 private:
75 bool sbuffer;
76 int loaded_components;
77
78 XSettingsClient* xs;
79
80 WindowXSettingsCallback* xs_cb;
81 WindowXSettingsCallback* xs_cb_old;
82 void* xs_cb_data;
83
84 const char* const* icon_pixmap;
85
86 void init(int component);
87 public:
91 Window(int X, int Y, int W, int H, const char* l = 0, int component = WIN_INIT_ALL);
92
96 Window(int W, int H, const char* l = 0, int component = WIN_INIT_ALL);
97
101 virtual ~Window();
102
106 int component(void) { return loaded_components; }
107
114 void xsettings_callback(WindowXSettingsCallback cb, void* data = NULL) { xs_cb = cb; xs_cb_data = data; }
115
119 WindowXSettingsCallback* xsettings_callback(void) { return xs_cb; }
120
124 void* xsettings_callback_data(void) { return xs_cb_data; }
125
131 void pause_xsettings_callback(void) { xs_cb_old = xs_cb; xs_cb = NULL; }
132
138 void restore_xsettings_callback(void) { xs_cb = xs_cb_old; }
139
145 void window_icon(const char* const * pix) { icon_pixmap = pix; }
146
150 const char* const* window_icon(void) { return icon_pixmap; }
151
155 virtual void show(void);
156
160 virtual void show(int argc, char** argv) { Fl_Window::show(argc, argv); }
161
165 void single_buffer(bool s) { sbuffer = s; }
166
170 bool single_buffer(void) { return sbuffer; }
171
175 bool double_buffer(void) { return !single_buffer(); }
176
181 virtual void flush(void) {
182 if(!sbuffer)
183 Fl_Double_Window::flush();
184 else
185 Fl_Window::flush();
186 }
187
192 virtual void resize(int X, int Y, int W, int H) {
193 if(!sbuffer)
194 Fl_Double_Window::resize(X, Y, W, H);
195 else
196 Fl_Window::resize(X, Y, W, H);
197 }
198
203 virtual void hide(void) {
204 if(!sbuffer)
205 Fl_Double_Window::hide();
206 else
207 Fl_Window::hide();
208 }
209 };
210
211 EDELIB_NS_END
212 #endif