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"
34 Callback<void(const Callback<void(bool)> &)> m_exportCallback;
35 typedef std::list<Callback<void(bool)>> ImportCallbacks;
36 ImportCallbacks m_importCallbacks;
38 ToggleItem(const Callback<void(const Callback<void(bool)> &)> &exportCallback) : m_exportCallback(exportCallback)
44 for (ImportCallbacks::iterator i = m_importCallbacks.begin(); i != m_importCallbacks.end(); ++i) {
49 void addCallback(const Callback<void(bool)> &callback)
51 m_importCallbacks.push_back(callback);
52 m_exportCallback(callback);
55 typedef MemberCaller<ToggleItem, void(const Callback<void(bool)> &), &ToggleItem::addCallback> AddCallbackCaller;
61 ToggleShown(const ToggleShown &other); // NOT COPYABLE
62 ToggleShown &operator=(const ToggleShown &other); // NOT ASSIGNABLE
64 static gboolean notify_visible(ui::Widget widget, gpointer dummy, ToggleShown *self);
66 static gboolean destroy(ui::Widget widget, ToggleShown *self);
72 ToggleShown(bool shown)
73 : m_shownDeferred(shown), m_widget(ui::null), m_item(ActiveCaller(*this))
81 void exportActive(const Callback<void(bool)> &importCallback);
83 typedef MemberCaller<ToggleShown, void(const Callback<void(bool)> &), &ToggleShown::exportActive> ActiveCaller;
89 typedef MemberCaller<ToggleShown, void(), &ToggleShown::toggle> ToggleCaller;
91 void connect(ui::Widget widget);
95 void widget_queue_draw(ui::Widget &widget);
97 typedef ReferenceCaller<ui::Widget, void(), widget_queue_draw> WidgetQueueDrawCaller;
100 void widget_make_default(ui::Widget widget);
102 class WidgetFocusPrinter {
105 static gboolean focus_in(ui::Widget widget, GdkEventFocus *event, WidgetFocusPrinter *self);
107 static gboolean focus_out(ui::Widget widget, GdkEventFocus *event, WidgetFocusPrinter *self);
110 WidgetFocusPrinter(const char *name) : m_name(name)
114 void connect(ui::Widget widget);