X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=libs%2Fgtkutil%2Fwidget.cpp;h=9d9c1a8d33e2e4f87e7c5182b813d36267269790;hb=a333eaee1c5b8b20ec59411f4878f8fc5bdfa584;hp=e212fdf644350e3d53be45dbb328041e8e7b9676;hpb=b7e36c120eb1546a6c6f97f30e42ab7f9a559c61;p=xonotic%2Fnetradiant.git diff --git a/libs/gtkutil/widget.cpp b/libs/gtkutil/widget.cpp index e212fdf6..9d9c1a8d 100644 --- a/libs/gtkutil/widget.cpp +++ b/libs/gtkutil/widget.cpp @@ -1,22 +1,86 @@ -/* - Copyright (C) 2001-2006, William Joseph. - All Rights Reserved. +#include "widget.h" +#include - This file is part of GtkRadiant. +void widget_queue_draw(ui::Widget &widget) +{ + gtk_widget_queue_draw(widget); +} - GtkRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. +void widget_make_default(ui::Widget widget) +{ + gtk_widget_set_can_default(widget, true); + gtk_widget_grab_default(widget); +} - GtkRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. +gboolean ToggleShown::notify_visible(ui::Widget widget, gpointer dummy, ToggleShown *self) +{ + self->update(); + return FALSE; +} - You should have received a copy of the GNU General Public License - along with GtkRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ +gboolean ToggleShown::destroy(ui::Widget widget, ToggleShown *self) +{ + self->m_shownDeferred = gtk_widget_get_visible(self->m_widget) != FALSE; + self->m_widget = ui::Widget(ui::null); + return FALSE; +} -#include "widget.h" +void ToggleShown::update() +{ + m_item.update(); +} + +bool ToggleShown::active() const +{ + if (!m_widget) { + return m_shownDeferred; + } else { + return gtk_widget_get_visible(m_widget) != FALSE; + } +} + +void ToggleShown::exportActive(const Callback &importCallback) +{ + importCallback(active()); +} + +void ToggleShown::set(bool shown) +{ + if (!m_widget) { + m_shownDeferred = shown; + } else { + m_widget.visible(shown); + } +} + +void ToggleShown::toggle() +{ + m_widget.visible(!m_widget.visible()); +} + +void ToggleShown::connect(ui::Widget widget) +{ + m_widget = widget; + m_widget.visible(m_shownDeferred); + m_widget.connect("notify::visible", G_CALLBACK(notify_visible), this); + m_widget.connect("destroy", G_CALLBACK(destroy), this); + update(); +} + +gboolean WidgetFocusPrinter::focus_in(ui::Widget widget, GdkEventFocus *event, WidgetFocusPrinter *self) +{ + globalOutputStream() << self->m_name << " takes focus\n"; + return FALSE; +} + +gboolean WidgetFocusPrinter::focus_out(ui::Widget widget, GdkEventFocus *event, WidgetFocusPrinter *self) +{ + globalOutputStream() << self->m_name << " loses focus\n"; + return FALSE; +} + +void WidgetFocusPrinter::connect(ui::Widget widget) +{ + widget.connect("focus_in_event", G_CALLBACK(focus_in), this); + widget.connect("focus_out_event", G_CALLBACK(focus_out), this); +}