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 inline bool widget_is_visible( GtkWidget* widget ){
34 return GTK_WIDGET_VISIBLE( widget ) != FALSE;
37 inline void widget_set_visible( GtkWidget* widget, bool show ){
39 /* workaround for gtk 2.24 issue: not displayed glwidget after toggle */
40 GtkWidget* glwidget = GTK_WIDGET( g_object_get_data( G_OBJECT( widget ), "glwidget" ) );
42 //if ( widget_is_visible( glwidget ) )
43 //globalOutputStream() << "glwidget have been already visible :0\n"; /* is not hidden aswell, according to this */
44 gtk_widget_hide( glwidget );
45 gtk_widget_show( glwidget );
47 gtk_widget_show( widget );
51 gtk_widget_hide( widget );
56 Callback<void(const Callback<void(bool)> &)> m_exportCallback;
57 typedef std::list<Callback<void(bool)>> ImportCallbacks;
58 ImportCallbacks m_importCallbacks;
60 ToggleItem(const Callback<void(const Callback<void(bool)> &)> &exportCallback) : m_exportCallback(exportCallback)
66 for (ImportCallbacks::iterator i = m_importCallbacks.begin(); i != m_importCallbacks.end(); ++i) {
71 void addCallback(const Callback<void(bool)> &callback)
73 m_importCallbacks.push_back(callback);
74 m_exportCallback(callback);
77 typedef MemberCaller<ToggleItem, void(const Callback<void(bool)> &), &ToggleItem::addCallback> AddCallbackCaller;
83 ToggleShown(const ToggleShown &other); // NOT COPYABLE
84 ToggleShown &operator=(const ToggleShown &other); // NOT ASSIGNABLE
86 static gboolean notify_visible(ui::Widget widget, gpointer dummy, ToggleShown *self);
88 static gboolean destroy(ui::Widget widget, ToggleShown *self);
94 ToggleShown(bool shown)
95 : m_shownDeferred(shown), m_widget(ui::null), m_item(ActiveCaller(*this))
103 void exportActive(const Callback<void(bool)> &importCallback);
105 typedef MemberCaller<ToggleShown, void(const Callback<void(bool)> &), &ToggleShown::exportActive> ActiveCaller;
107 void set(bool shown);
111 typedef MemberCaller<ToggleShown, void(), &ToggleShown::toggle> ToggleCaller;
113 void connect(ui::Widget widget);
117 void widget_queue_draw(ui::Widget &widget);
119 typedef ReferenceCaller<ui::Widget, void(), widget_queue_draw> WidgetQueueDrawCaller;
122 void widget_make_default(ui::Widget widget);
124 class WidgetFocusPrinter {
127 static gboolean focus_in(ui::Widget widget, GdkEventFocus *event, WidgetFocusPrinter *self);
129 static gboolean focus_out(ui::Widget widget, GdkEventFocus *event, WidgetFocusPrinter *self);
132 WidgetFocusPrinter(const char *name) : m_name(name)
136 void connect(ui::Widget widget);