edelib  2.0.0
edelib/Window.h
00001 /*
00002  * $Id: Window.h 2925 2009-11-10 11:06:08Z karijes $
00003  *
00004  * Window class
00005  * Copyright (c) 2005-2007 edelib authors
00006  *
00007  * This library is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2 of the License, or (at your option) any later version.
00011  *
00012  * This library is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00015  * Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public License
00018  * along with this library. If not, see <http://www.gnu.org/licenses/>.
00019  */
00020 
00021 #ifndef __EDELIB_WINDOW_H__
00022 #define __EDELIB_WINDOW_H__
00023 
00024 #include "XSettingsClient.h"
00025 #include <FL/Fl_Double_Window.H>
00026 
00027 EDELIB_NS_BEGIN
00028 
00034 enum WindowComponents {
00035         WIN_INIT_NONE       = (1 << 1),                               
00036         WIN_INIT_ICON_THEME = (1 << 2),                               
00037         WIN_INIT_IMAGES     = (1 << 3),                               
00038         WIN_INIT_ALL        = (WIN_INIT_ICON_THEME | WIN_INIT_IMAGES) 
00039 };
00040 
00041 #ifndef SKIP_DOCS
00042 typedef bool (WindowXSettingsCallback)(const char* name, XSettingsAction action, 
00043                 const XSettingsSetting* setting, void* data);
00044 #endif
00045 
00073 class EDELIB_API Window : public Fl_Double_Window {
00074 private:
00075         bool sbuffer;
00076         int  loaded_components;
00077 
00078         XSettingsClient*         xs;
00079 
00080         WindowXSettingsCallback* xs_cb;
00081         WindowXSettingsCallback* xs_cb_old;
00082         void*                    xs_cb_data;
00083 
00084         const char* const*       icon_pixmap;
00085 
00086         void init(int component);
00087 public:
00091         Window(int X, int Y, int W, int H, const char* l = 0, int component = WIN_INIT_ALL);
00092 
00096         Window(int W, int H, const char* l = 0, int component = WIN_INIT_ALL);
00097 
00101         virtual ~Window();
00102 
00106         int component(void) { return loaded_components; }
00107 
00114         void xsettings_callback(WindowXSettingsCallback cb, void* data = NULL) { xs_cb = cb; xs_cb_data = data; }
00115 
00119         WindowXSettingsCallback* xsettings_callback(void) { return xs_cb; }
00120 
00124         void* xsettings_callback_data(void) { return xs_cb_data; }
00125 
00131         void pause_xsettings_callback(void) { xs_cb_old = xs_cb; xs_cb = NULL; }
00132 
00138         void restore_xsettings_callback(void) { xs_cb = xs_cb_old; }
00139 
00145         void window_icon(const char* const * pix) { icon_pixmap = pix; }
00146 
00150         const char* const* window_icon(void) { return icon_pixmap; }
00151 
00155         virtual void show(void);
00156 
00160         virtual void show(int argc, char** argv) { Fl_Window::show(argc, argv); }
00161 
00165         void single_buffer(bool s) { sbuffer = s; }
00166 
00170         bool single_buffer(void) { return sbuffer; }
00171 
00175         bool double_buffer(void) { return !single_buffer(); }
00176 
00181         virtual void flush(void) { 
00182                 if(!sbuffer) 
00183                         Fl_Double_Window::flush();
00184                 else 
00185                         Fl_Window::flush(); 
00186         }
00187 
00192         virtual void resize(int X, int Y, int W, int H) {
00193                 if(!sbuffer)
00194                         Fl_Double_Window::resize(X, Y, W, H);
00195                 else
00196                         Fl_Window::resize(X, Y, W, H);
00197         }
00198 
00203         virtual void hide(void) {
00204                 if(!sbuffer)
00205                         Fl_Double_Window::hide();
00206                 else
00207                         Fl_Window::hide();
00208         }
00209 };
00210 
00211 EDELIB_NS_END
00212 #endif