2 Copyright (C) 2001-2006, William Joseph.
5 This file is part of GtkRadiant.
7 GtkRadiant is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 GtkRadiant 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
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GtkRadiant; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #if !defined( INCLUDED_GTKUTIL_WIDGET_H )
23 #define INCLUDED_GTKUTIL_WIDGET_H
26 #include <uilib/uilib.h>
28 #include "generic/callback.h"
30 #include "debugging/debugging.h"
33 #define GARUX_GTK_WORKAROUND
34 #ifndef GARUX_GTK_WORKAROUND
35 inline bool widget_is_visible( GtkWidget* widget ){
36 return GTK_WIDGET_VISIBLE( widget ) != FALSE;
39 inline void widget_set_visible( GtkWidget* widget, bool show ){
41 /* workaround for gtk 2.24 issue: not displayed glwidget after toggle */
42 GtkWidget* glwidget = GTK_WIDGET( g_object_get_data( G_OBJECT( widget ), "glwidget" ) );
44 //if ( widget_is_visible( glwidget ) )
45 //globalOutputStream() << "glwidget have been already visible :0\n"; /* is not hidden aswell, according to this */
46 gtk_widget_hide( glwidget );
47 gtk_widget_show( glwidget );
49 gtk_widget_show( widget );
53 gtk_widget_hide( widget );
59 Callback<void(const Callback<void(bool)> &)> m_exportCallback;
60 typedef std::list<Callback<void(bool)>> ImportCallbacks;
61 ImportCallbacks m_importCallbacks;
63 ToggleItem(const Callback<void(const Callback<void(bool)> &)> &exportCallback) : m_exportCallback(exportCallback)
69 for (ImportCallbacks::iterator i = m_importCallbacks.begin(); i != m_importCallbacks.end(); ++i) {
74 void addCallback(const Callback<void(bool)> &callback)
76 m_importCallbacks.push_back(callback);
77 m_exportCallback(callback);
80 typedef MemberCaller<ToggleItem, void(const Callback<void(bool)> &), &ToggleItem::addCallback> AddCallbackCaller;
86 ToggleShown(const ToggleShown &other); // NOT COPYABLE
87 ToggleShown &operator=(const ToggleShown &other); // NOT ASSIGNABLE
89 static gboolean notify_visible(ui::Widget widget, gpointer dummy, ToggleShown *self);
91 static gboolean destroy(ui::Widget widget, ToggleShown *self);
97 ToggleShown(bool shown)
98 : m_shownDeferred(shown), m_widget(ui::null), m_item(ActiveCaller(*this))
106 void exportActive(const Callback<void(bool)> &importCallback);
108 typedef MemberCaller<ToggleShown, void(const Callback<void(bool)> &), &ToggleShown::exportActive> ActiveCaller;
110 void set(bool shown);
114 typedef MemberCaller<ToggleShown, void(), &ToggleShown::toggle> ToggleCaller;
116 void connect(ui::Widget widget);
120 void widget_queue_draw(ui::Widget &widget);
122 typedef ReferenceCaller<ui::Widget, void(), widget_queue_draw> WidgetQueueDrawCaller;
125 void widget_make_default(ui::Widget widget);
127 class WidgetFocusPrinter {
130 static gboolean focus_in(ui::Widget widget, GdkEventFocus *event, WidgetFocusPrinter *self);
132 static gboolean focus_out(ui::Widget widget, GdkEventFocus *event, WidgetFocusPrinter *self);
135 WidgetFocusPrinter(const char *name) : m_name(name)
139 void connect(ui::Widget widget);