diff --git a/po/wesnoth-lib/POTFILES.in b/po/wesnoth-lib/POTFILES.in index 426e2382b24..6f77719c4d7 100644 --- a/po/wesnoth-lib/POTFILES.in +++ b/po/wesnoth-lib/POTFILES.in @@ -15,7 +15,6 @@ src/gui/auxiliary/widget_definition/horizontal_scrollbar.cpp src/gui/auxiliary/widget_definition/image.cpp src/gui/auxiliary/widget_definition/label.cpp src/gui/auxiliary/widget_definition/listbox.cpp -src/gui/auxiliary/widget_definition/menubar.cpp src/gui/auxiliary/widget_definition/minimap.cpp src/gui/auxiliary/widget_definition/multi_page.cpp src/gui/auxiliary/widget_definition/panel.cpp @@ -41,7 +40,6 @@ src/gui/auxiliary/window_builder/horizontal_scrollbar.cpp src/gui/auxiliary/window_builder/image.cpp src/gui/auxiliary/window_builder/label.cpp src/gui/auxiliary/window_builder/listbox.cpp -src/gui/auxiliary/window_builder/menubar.cpp src/gui/auxiliary/window_builder/minimap.cpp src/gui/auxiliary/window_builder/multi_page.cpp src/gui/auxiliary/window_builder/panel.cpp @@ -87,7 +85,6 @@ src/gui/widgets/horizontal_scrollbar.cpp src/gui/widgets/image.cpp src/gui/widgets/label.cpp src/gui/widgets/listbox.cpp -src/gui/widgets/menubar.cpp src/gui/widgets/minimap.cpp src/gui/widgets/multi_page.cpp src/gui/widgets/panel.cpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b87a37c5426..7bee41fceaa 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -233,7 +233,6 @@ set(wesnoth-main_SRC gui/auxiliary/widget_definition/image.cpp gui/auxiliary/widget_definition/label.cpp gui/auxiliary/widget_definition/listbox.cpp - gui/auxiliary/widget_definition/menubar.cpp gui/auxiliary/widget_definition/minimap.cpp gui/auxiliary/widget_definition/multi_page.cpp gui/auxiliary/widget_definition/panel.cpp @@ -259,7 +258,6 @@ set(wesnoth-main_SRC gui/auxiliary/window_builder/label.cpp gui/auxiliary/window_builder/listbox.cpp gui/auxiliary/window_builder/minimap.cpp - gui/auxiliary/window_builder/menubar.cpp gui/auxiliary/window_builder/multi_page.cpp gui/auxiliary/window_builder/repeating_button.cpp gui/auxiliary/window_builder/scroll_label.cpp @@ -309,7 +307,6 @@ set(wesnoth-main_SRC gui/widgets/image.cpp gui/widgets/label.cpp gui/widgets/listbox.cpp - gui/widgets/menubar.cpp gui/widgets/minimap.cpp gui/widgets/multi_page.cpp gui/widgets/panel.cpp diff --git a/src/Makefile.am b/src/Makefile.am index 8161b8b9178..a88c2f116bd 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -113,7 +113,6 @@ wesnoth_source = \ gui/auxiliary/widget_definition/image.cpp \ gui/auxiliary/widget_definition/label.cpp \ gui/auxiliary/widget_definition/listbox.cpp \ - gui/auxiliary/widget_definition/menubar.cpp \ gui/auxiliary/widget_definition/minimap.cpp \ gui/auxiliary/widget_definition/multi_page.cpp \ gui/auxiliary/widget_definition/panel.cpp \ @@ -139,7 +138,6 @@ wesnoth_source = \ gui/auxiliary/window_builder/label.cpp \ gui/auxiliary/window_builder/listbox.cpp \ gui/auxiliary/window_builder/minimap.cpp \ - gui/auxiliary/window_builder/menubar.cpp \ gui/auxiliary/window_builder/multi_page.cpp \ gui/auxiliary/window_builder/repeating_button.cpp \ gui/auxiliary/window_builder/scroll_label.cpp \ @@ -189,7 +187,6 @@ wesnoth_source = \ gui/widgets/image.cpp \ gui/widgets/label.cpp \ gui/widgets/listbox.cpp \ - gui/widgets/menubar.cpp \ gui/widgets/minimap.cpp \ gui/widgets/multi_page.cpp \ gui/widgets/panel.cpp \ diff --git a/src/SConscript b/src/SConscript index 23bf2d42a70..bc3f85e5546 100644 --- a/src/SConscript +++ b/src/SConscript @@ -272,7 +272,6 @@ wesnoth_sources = Split(""" gui/auxiliary/widget_definition/image.cpp gui/auxiliary/widget_definition/label.cpp gui/auxiliary/widget_definition/listbox.cpp - gui/auxiliary/widget_definition/menubar.cpp gui/auxiliary/widget_definition/minimap.cpp gui/auxiliary/widget_definition/multi_page.cpp gui/auxiliary/widget_definition/panel.cpp @@ -298,7 +297,6 @@ wesnoth_sources = Split(""" gui/auxiliary/window_builder/label.cpp gui/auxiliary/window_builder/listbox.cpp gui/auxiliary/window_builder/minimap.cpp - gui/auxiliary/window_builder/menubar.cpp gui/auxiliary/window_builder/multi_page.cpp gui/auxiliary/window_builder/repeating_button.cpp gui/auxiliary/window_builder/scroll_label.cpp @@ -348,7 +346,6 @@ wesnoth_sources = Split(""" gui/widgets/image.cpp gui/widgets/label.cpp gui/widgets/listbox.cpp - gui/widgets/menubar.cpp gui/widgets/minimap.cpp gui/widgets/multi_page.cpp gui/widgets/panel.cpp diff --git a/src/gui/auxiliary/widget_definition/menubar.cpp b/src/gui/auxiliary/widget_definition/menubar.cpp deleted file mode 100644 index 24dbea61bfc..00000000000 --- a/src/gui/auxiliary/widget_definition/menubar.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/* $Id$ */ -/* - Copyright (C) 2007 - 2010 by Mark de Wever - Part of the Battle for Wesnoth Project http://www.wesnoth.org/ - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License version 2 - or at your option any later version. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY. - - See the COPYING file for more details. -*/ - -#define GETTEXT_DOMAIN "wesnoth-lib" - -#include "gui/auxiliary/widget_definition/menubar.hpp" - -#include "gui/auxiliary/log.hpp" - -namespace gui2 { - -tmenubar_definition::tmenubar_definition(const config& cfg) : - tcontrol_definition(cfg) -{ - DBG_GUI_P << "Parsing menubar " << id << '\n'; - - load_resolutions(cfg); -} - -tmenubar_definition::tresolution::tresolution(const config& cfg) : - tresolution_definition_(cfg) -{ -/*WIKI - * @page = GUIWidgetDefinitionWML - * @order = 1_menubar - * - * == Menubar == - * - * The definition of a normal menubar. - * - * The following states exist: - * * state_enabled, the menubar is enabled. - * * state_disabled, the menubar is disabled. - * - */ - // Note the order should be the same as the enum tstate is menubar.hpp. - state.push_back(tstate_definition(cfg.child("state_enabled"))); - state.push_back(tstate_definition(cfg.child("state_disabled"))); -} - -} // namespace gui2 - diff --git a/src/gui/auxiliary/widget_definition/menubar.hpp b/src/gui/auxiliary/widget_definition/menubar.hpp deleted file mode 100644 index f676482b939..00000000000 --- a/src/gui/auxiliary/widget_definition/menubar.hpp +++ /dev/null @@ -1,38 +0,0 @@ -/* $Id$ */ -/* - Copyright (C) 2007 - 2010 by Mark de Wever - Part of the Battle for Wesnoth Project http://www.wesnoth.org/ - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License version 2 - or at your option any later version. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY. - - See the COPYING file for more details. -*/ - -#ifndef GUI_AUXILIARY_WIDGET_DEFINITION_MENUBAR_HPP_INCLUDED -#define GUI_AUXILIARY_WIDGET_DEFINITION_MENUBAR_HPP_INCLUDED - -#include "gui/auxiliary/widget_definition.hpp" - -namespace gui2 { - -struct tmenubar_definition - : public tcontrol_definition -{ - - explicit tmenubar_definition(const config& cfg); - - struct tresolution - : public tresolution_definition_ - { - explicit tresolution(const config& cfg); - }; -}; - -} // namespace gui2 - -#endif - diff --git a/src/gui/auxiliary/window_builder.cpp b/src/gui/auxiliary/window_builder.cpp index e6339c00817..81a0984e768 100644 --- a/src/gui/auxiliary/window_builder.cpp +++ b/src/gui/auxiliary/window_builder.cpp @@ -28,7 +28,6 @@ #include "gui/auxiliary/window_builder/label.hpp" #include "gui/auxiliary/window_builder/listbox.hpp" #include "gui/auxiliary/window_builder/minimap.hpp" -#include "gui/auxiliary/window_builder/menubar.hpp" #include "gui/auxiliary/window_builder/multi_page.hpp" #include "gui/auxiliary/window_builder/repeating_button.hpp" #include "gui/auxiliary/window_builder/scroll_label.hpp" @@ -76,7 +75,6 @@ tbuilder_widget_ptr create_builder_widget(const config& cfg) TRY(image); TRY(label); TRY(listbox); - TRY(menubar); TRY(minimap); TRY(multi_page); TRY(panel); diff --git a/src/gui/auxiliary/window_builder/menubar.cpp b/src/gui/auxiliary/window_builder/menubar.cpp deleted file mode 100644 index 7c3f331d475..00000000000 --- a/src/gui/auxiliary/window_builder/menubar.cpp +++ /dev/null @@ -1,117 +0,0 @@ -/* $Id$ */ -/* - Copyright (C) 2008 - 2010 by Mark de Wever - Part of the Battle for Wesnoth Project http://www.wesnoth.org/ - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License version 2 - or at your option any later version. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY. - - See the COPYING file for more details. -*/ - -#define GETTEXT_DOMAIN "wesnoth-lib" - -#include "gui/auxiliary/window_builder/menubar.hpp" - -#include "config.hpp" -#include "foreach.hpp" -#include "gui/auxiliary/log.hpp" - -namespace gui2 { - -namespace implementation { - -static tmenubar::tdirection read_direction(const std::string& direction) -{ - if(direction == "vertical") { - return tmenubar::VERTICAL; - } else if(direction == "horizontal") { - return tmenubar::HORIZONTAL; - } else { - ERR_GUI_E << "Invalid direction " - << direction << "' falling back to 'horizontal'.\n"; - return tmenubar::HORIZONTAL; - } -} - -tbuilder_menubar::tbuilder_menubar(const config& cfg) - : tbuilder_control(cfg) - , must_have_one_item_selected_( - utils::string_bool(cfg["must_have_one_item_selected"])) - , direction_(read_direction(cfg["direction"])) - , selected_item_(lexical_cast_default( - cfg["selected_item"], must_have_one_item_selected_ ? 0 : -1)) - , cells_() -{ - const config &data = cfg.child("data"); - if (!data) return; - - foreach (const config &cell, data.child_range("cell")) { - cells_.push_back(tbuilder_gridcell(cell)); - } -} - -twidget* tbuilder_menubar::build() const -{ - tmenubar* widget = new tmenubar(direction_); - - init_control(widget); - - DBG_GUI_G << "Window builder: placed menubar '" - << id << "' with defintion '" - << definition << "'.\n"; - - if(direction_ == tmenubar::HORIZONTAL) { - widget->set_rows_cols(1, cells_.size()); - - for(size_t i = 0; i < cells_.size(); ++i) { - widget->set_child(cells_[i].widget->build(), - 0, i, cells_[i].flags, cells_[i].border_size); - } - } else { - // vertical growth - widget->set_rows_cols(cells_.size(), 1); - - for(size_t i = 0; i < cells_.size(); ++i) { - widget->set_child(cells_[i].widget->build(), - i, 0, cells_[i].flags, cells_[i].border_size); - } - } - - widget->set_selected_item(selected_item_); - widget->set_must_select(must_have_one_item_selected_); - widget->finalize_setup(); - - return widget; -} - -} // namespace implementation - -} // namespace gui2 - -/*WIKI - * @page = GUIWidgetInstanceWML - * @order = 2_menubar - * - * == Menubar == - * - * A menu bar used for menus and tab controls. - * - * List with the listbox specific variables: - * @start_table = config - * must_have_one_item_selected (bool = false) - * Does the menu always have one item - * selected. This makes sense for - * tabsheets - * but not for menus. - * direction (direction = "") The direction of the menubar. - * selected_item(int = -1) The item to select upon creation, when - * 'must_have_one_item_selected' is true - * the default value is 0 instead of -1. - * -1 means no item selected. - * @end_table - */ - diff --git a/src/gui/auxiliary/window_builder/menubar.hpp b/src/gui/auxiliary/window_builder/menubar.hpp deleted file mode 100644 index 7f0e1e254a2..00000000000 --- a/src/gui/auxiliary/window_builder/menubar.hpp +++ /dev/null @@ -1,50 +0,0 @@ -/* $Id$ */ -/* - Copyright (C) 2008 - 2010 by Mark de Wever - Part of the Battle for Wesnoth Project http://www.wesnoth.org/ - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License version 2 - or at your option any later version. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY. - - See the COPYING file for more details. -*/ - -#ifndef GUI_AUXILIARY_WINDOW_BUILDER_MENUBAR_HPP_INCLUDED -#define GUI_AUXILIARY_WINDOW_BUILDER_MENUBAR_HPP_INCLUDED - -#include "gui/auxiliary/window_builder/control.hpp" - -#include "gui/auxiliary/window_builder_private.hpp" -#include "gui/widgets/menubar.hpp" - -namespace gui2 { - -namespace implementation { - -struct tbuilder_menubar - : public tbuilder_control -{ - tbuilder_menubar(const config& cfg); - - twidget* build () const; - -private: - bool must_have_one_item_selected_; - - tmenubar::tdirection direction_; - - int selected_item_; - - std::vector cells_; -}; - -} // namespace implementation - -} // namespace gui2 - -#endif - - diff --git a/src/gui/widgets/menubar.cpp b/src/gui/widgets/menubar.cpp deleted file mode 100644 index df8b0450336..00000000000 --- a/src/gui/widgets/menubar.cpp +++ /dev/null @@ -1,157 +0,0 @@ -/* $Id$ */ -/* - Copyright (C) 2008 - 2010 by Mark de Wever - Part of the Battle for Wesnoth Project http://www.wesnoth.org/ - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License version 2 - or at your option any later version. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY. - - See the COPYING file for more details. -*/ - -#define GETTEXT_DOMAIN "wesnoth-lib" - -#include "gui/widgets/menubar.hpp" - -#include "gui/widgets/selectable.hpp" - -namespace gui2 { - -static void callback_select_item(twidget* caller) -{ - get_parent(caller)->item_selected(caller); -} - -size_t tmenubar::get_item_count() const -{ - if(direction_ == VERTICAL) { - return grid().get_rows(); - } else { - return grid().get_cols(); - } -} - -void tmenubar::set_must_select(const bool must_select) -{ - assert(!must_select || selected_item_ != -1); - - must_select_ = must_select; -} - -void tmenubar::set_selected_item(const int item) -{ - assert(!must_select_ || item != -1); - - if(item == selected_item_) { - return; - } - - if(selected_item_ != -1) { - (*(*this)[selected_item_]).set_value(false); - } - - selected_item_ = item; - if(selected_item_ != -1) { - (*(*this)[selected_item_]).set_value(true); - } -} - -void tmenubar::set_state(const tstate state) -{ - if(state != state_) { - state_ = state; - set_dirty(true); - } -} - -void tmenubar::item_selected(twidget* widget) -{ - //std::cerr << "click.\n"; - - tselectable_* item = dynamic_cast(widget); - assert(item); - - // Find the widget clicked upon. - size_t index = 0; - for(; index < get_item_count(); ++index) { - - if((*this)[index] == item) { - break; - } - } - assert(index < get_item_count()); - - // Set the selection. - if(!item->get_value()) { - // Deselected an item, allowed? - if(must_select_) { - item->set_value(true); - } else { - selected_item_ = -1; - } - } else { - set_selected_item(index); - } -} - -const tselectable_* tmenubar::operator[](const size_t index) const -{ - assert(index < get_item_count()); - - const tselectable_* widget = NULL; - if(direction_ == VERTICAL) { - widget = dynamic_cast(grid().widget(index, 0)); - } else { - widget = dynamic_cast(grid().widget(0, index)); - } - - assert(widget); - - return widget; -} - -tselectable_* tmenubar::operator[](const size_t index) -{ - assert(index < get_item_count()); - - tselectable_* widget = NULL; - if(direction_ == VERTICAL) { - widget = dynamic_cast(grid().widget(index, 0)); - } else { - widget = dynamic_cast(grid().widget(0, index)); - } - - assert(widget); - - return widget; -} - -void tmenubar::finalize_setup() -{ - for(unsigned row = 0; row < grid().get_rows(); ++row) { - for(unsigned col = 0; col < grid().get_cols(); ++col) { - twidget* widget = grid().widget(row, col); - assert(widget); - - tselectable_* btn = dynamic_cast(widget); - - if(btn) { - btn->set_callback_state_change(callback_select_item); - } else { - //std::cerr << "Widget type " << typeid(*widget).name() << ".\n"; - assert(false); - } - } - } -} - -const std::string& tmenubar::get_control_type() const -{ - static const std::string type = "menubar"; - return type; -} -} // namespace gui2 - diff --git a/src/gui/widgets/menubar.hpp b/src/gui/widgets/menubar.hpp deleted file mode 100644 index ec5f0e1fe02..00000000000 --- a/src/gui/widgets/menubar.hpp +++ /dev/null @@ -1,126 +0,0 @@ -/* $Id$ */ -/* - Copyright (C) 2008 - 2010 by Mark de Wever - Part of the Battle for Wesnoth Project http://www.wesnoth.org/ - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License version 2 - or at your option any later version. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY. - - See the COPYING file for more details. -*/ - -#ifndef GUI_WIDGETS_MENUBAR_HPP_INCLUDED -#define GUI_WIDGETS_MENUBAR_HPP_INCLUDED - -#include "gui/widgets/container.hpp" - -namespace gui2 { - -class tselectable_; -namespace implementation { - struct tbuilder_menubar; -} -/** - * A menu bar. - * - * A menu bar is a generic component which can hold mutiple toggle items of which - * zero or one are selected. Whether zero is allowed depends on the selection mode. - * The elements can be order horizontally or vertically which is set in WML. - */ -class tmenubar : public tcontainer_ -{ - friend struct implementation::tbuilder_menubar; -public: - /** The direction is which the items are next to eachother. */ - enum tdirection { HORIZONTAL, VERTICAL }; - - tmenubar(const tdirection direction) : - tcontainer_(COUNT), - state_(ENABLED), - callback_selection_change_(0), - must_select_(false), - selected_item_(-1), - direction_(direction) - { - } - - /** Returns the number of items in the menu. */ - size_t get_item_count() const; - - /***** ***** ***** ***** Inherited ***** ***** ***** *****/ - - /** Inherited from tcontrol. */ - bool get_active() const { return state_ != DISABLED; } - - /** Inherited from tcontrol. */ - unsigned get_state() const { return state_; } - - /** - * Update our state when a widget selected or deselected an item. - * - * @param widget The widget that changed its state by a user - * action. - */ - void item_selected(twidget* widget) ; - - /***** ***** ***** setters / getters for members ***** ****** *****/ - void set_callback_selection_change(void (*callback) (twidget*)) - { callback_selection_change_ = callback; } - - void set_must_select(const bool must_select); - - void set_selected_item(const int item); - int get_selected_item() const { return selected_item_; } - -private: - /** - * Possible states of the widget. - * - * Note the order of the states must be the same as defined in settings.hpp. - */ - enum tstate { ENABLED, DISABLED, COUNT }; - - void set_state(const tstate state); - - /** - * Current state of the widget. - * - * The state of the widget determines what to render and how the widget - * reacts to certain 'events'. - */ - tstate state_; - - /** This callback is used when the selection is changed by the user. */ - void (*callback_selection_change_) (twidget*); - - /** Do we always need to select an item? */ - bool must_select_; - - /** The selected item -1 for none. */ - int selected_item_; - - /** The direction of the menu bar. */ - tdirection direction_; - - /** Returns an item. */ - const tselectable_* operator[](const size_t index) const; - tselectable_* operator[](const size_t index); - - /** The builder needs to call us so we can wire in the proper callbacks. */ - void finalize_setup(); - - /** Inherited from tcontainer_. */ - void set_self_active(const bool active) - { state_ = active ? ENABLED : DISABLED; } - - /** Inherited from tcontrol. */ - const std::string& get_control_type() const; -}; - -} // namespace gui2 - -#endif - diff --git a/src/gui/widgets/settings.cpp b/src/gui/widgets/settings.cpp index 48a4b01c115..3f8ada42886 100644 --- a/src/gui/widgets/settings.cpp +++ b/src/gui/widgets/settings.cpp @@ -32,7 +32,6 @@ #include "gui/auxiliary/widget_definition/image.hpp" #include "gui/auxiliary/widget_definition/label.hpp" #include "gui/auxiliary/widget_definition/listbox.hpp" -#include "gui/auxiliary/widget_definition/menubar.hpp" #include "gui/auxiliary/widget_definition/minimap.hpp" #include "gui/auxiliary/widget_definition/multi_page.hpp" #include "gui/auxiliary/widget_definition/panel.hpp" @@ -193,9 +192,6 @@ const std::string& tgui_definition::read(const config& cfg) * Horizontal_scrollbar @macro = horizontal_scrollbar_description * Label @macro = label_description * Listbox @macro = listbox_description - * Menubar A menubar which is used in menus and the - * tabbar in a tabcontrol. (NOTE this widget - * is still under heavy development.) * Minimap @macro = minimap_description * Multi_page @macro = multi_page_description * Panel @macro = panel_description @@ -271,7 +267,6 @@ const std::string& tgui_definition::read(const config& cfg) load_definitions("image", cfg); load_definitions("label", cfg); load_definitions("listbox", cfg); - load_definitions("menubar", cfg); load_definitions("minimap", cfg); load_definitions("multi_page", cfg); load_definitions("stacked_widget", cfg);