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"
32 void widget_set_visible(ui::Widget widget, bool shown);
34 bool widget_is_visible(ui::Widget widget);
36 inline void widget_toggle_visible(ui::Widget widget)
38 widget_set_visible(widget, !widget_is_visible(widget));
42 BoolExportCallback m_exportCallback;
43 typedef std::list<BoolImportCallback> ImportCallbacks;
44 ImportCallbacks m_importCallbacks;
46 ToggleItem(const BoolExportCallback &exportCallback) : m_exportCallback(exportCallback)
52 for (ImportCallbacks::iterator i = m_importCallbacks.begin(); i != m_importCallbacks.end(); ++i) {
57 void addCallback(const BoolImportCallback &callback)
59 m_importCallbacks.push_back(callback);
60 m_exportCallback(callback);
63 typedef MemberCaller1<ToggleItem, const BoolImportCallback &, &ToggleItem::addCallback> AddCallbackCaller;
69 ToggleShown(const ToggleShown &other); // NOT COPYABLE
70 ToggleShown &operator=(const ToggleShown &other); // NOT ASSIGNABLE
72 static gboolean notify_visible(ui::Widget widget, gpointer dummy, ToggleShown *self);
74 static gboolean destroy(ui::Widget widget, ToggleShown *self);
80 ToggleShown(bool shown)
81 : m_shownDeferred(shown), m_widget(0), m_item(ActiveCaller(*this))
89 void exportActive(const BoolImportCallback &importCallback);
91 typedef MemberCaller1<ToggleShown, const BoolImportCallback &, &ToggleShown::exportActive> ActiveCaller;
97 typedef MemberCaller<ToggleShown, &ToggleShown::toggle> ToggleCaller;
99 void connect(ui::Widget widget);
103 void widget_queue_draw(ui::Widget &widget);
105 typedef ReferenceCaller<ui::Widget, widget_queue_draw> WidgetQueueDrawCaller;
108 void widget_make_default(ui::Widget widget);
110 class WidgetFocusPrinter {
113 static gboolean focus_in(ui::Widget widget, GdkEventFocus *event, WidgetFocusPrinter *self);
115 static gboolean focus_out(ui::Widget widget, GdkEventFocus *event, WidgetFocusPrinter *self);
118 WidgetFocusPrinter(const char *name) : m_name(name)
122 void connect(ui::Widget widget);