diff --git a/projectfiles/CodeBlocks-SCons/wesnoth.cbp b/projectfiles/CodeBlocks-SCons/wesnoth.cbp index 5921e39e2ff..ace9b6ff4a5 100644 --- a/projectfiles/CodeBlocks-SCons/wesnoth.cbp +++ b/projectfiles/CodeBlocks-SCons/wesnoth.cbp @@ -431,7 +431,6 @@ - diff --git a/projectfiles/CodeBlocks/tests.cbp b/projectfiles/CodeBlocks/tests.cbp index 512fc93b093..643dbd3ff54 100644 --- a/projectfiles/CodeBlocks/tests.cbp +++ b/projectfiles/CodeBlocks/tests.cbp @@ -509,7 +509,6 @@ - diff --git a/projectfiles/CodeBlocks/wesnoth.cbp b/projectfiles/CodeBlocks/wesnoth.cbp index f03c86e4cf0..25180dbfb31 100644 --- a/projectfiles/CodeBlocks/wesnoth.cbp +++ b/projectfiles/CodeBlocks/wesnoth.cbp @@ -504,7 +504,6 @@ - diff --git a/projectfiles/Xcode/The Battle for Wesnoth.xcodeproj/project.pbxproj b/projectfiles/Xcode/The Battle for Wesnoth.xcodeproj/project.pbxproj index 93cc1a008a4..b053803b6b2 100644 --- a/projectfiles/Xcode/The Battle for Wesnoth.xcodeproj/project.pbxproj +++ b/projectfiles/Xcode/The Battle for Wesnoth.xcodeproj/project.pbxproj @@ -1997,7 +1997,6 @@ 46F92D0A2174F6A300602C1C /* iterator.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = iterator.hpp; sourceTree = ""; }; 46F92D0B2174F6A300602C1C /* exception.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = exception.hpp; sourceTree = ""; }; 46F92D0C2174F6A300602C1C /* walker_grid.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = walker_grid.hpp; sourceTree = ""; }; - 46F92D0D2174F6A300602C1C /* find_widget.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = find_widget.hpp; sourceTree = ""; }; 46F92D0E2174F6A300602C1C /* tips.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = tips.hpp; sourceTree = ""; }; 46F92D102174F6A300602C1C /* field-fwd.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = "field-fwd.hpp"; sourceTree = ""; }; 46F92D122174F6A300602C1C /* generator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = generator.cpp; sourceTree = ""; }; @@ -4012,7 +4011,6 @@ children = ( 46F92D102174F6A300602C1C /* field-fwd.hpp */, 46F92CFD2174F6A300602C1C /* field.hpp */, - 46F92D0D2174F6A300602C1C /* find_widget.hpp */, 46F92D002174F6A300602C1C /* iterator */, 46F92CFC2174F6A300602C1C /* tips.cpp */, 46F92D0E2174F6A300602C1C /* tips.hpp */, diff --git a/src/gui/auxiliary/field.hpp b/src/gui/auxiliary/field.hpp index 42283eb1296..d551e2b5166 100644 --- a/src/gui/auxiliary/field.hpp +++ b/src/gui/auxiliary/field.hpp @@ -23,7 +23,6 @@ #pragma once -#include "gui/auxiliary/find_widget.hpp" #include "gui/auxiliary/field-fwd.hpp" #include "gui/widgets/styled_widget.hpp" #include "gui/widgets/selectable_item.hpp" @@ -75,7 +74,7 @@ public: void attach_to_window(window& window) { assert(!widget_); - widget_ = find_widget(&window, id(), false, mandatory_); + widget_ = window.find_widget(id(), false, mandatory_); } /** diff --git a/src/gui/auxiliary/find_widget.hpp b/src/gui/auxiliary/find_widget.hpp deleted file mode 100644 index b6f14b3edb7..00000000000 --- a/src/gui/auxiliary/find_widget.hpp +++ /dev/null @@ -1,111 +0,0 @@ -/* - Copyright (C) 2007 - 2024 - by Mark de Wever - Part of the Battle for Wesnoth Project https://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 as published by - the Free Software Foundation; either version 2 of the License, 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. -*/ - -#pragma once - -#include "global.hpp" -#include "gui/widgets/helper.hpp" -#include "gui/widgets/widget.hpp" -#include "utils/const_clone.hpp" -#include "wml_exception.hpp" - -namespace gui2 -{ - -/** - * Returns the first parent of a widget with a certain type. - * - * @param child The widget to get the parent from, - * @tparam T The class of the widget to return. - * - * @returns The parent widget. - */ -template -T& get_parent(widget& child) -{ - T* result; - widget* w = &child; - do { - w = w->parent(); - result = dynamic_cast(w); - - } while(w && !result); - - assert(result); - return *result; -} - -/** - * Gets a widget with the wanted id. - * - * This template function doesn't return a pointer to a generic widget but - * returns the wanted type and tests for its existence if required. - * - * @param widget The widget test or find a child with the wanted - * id. - * @param id The id of the widget to find. - * @param must_be_active The widget should be active, not all widgets - * have an active flag, those who don't ignore - * flag. - * @param must_exist The widget should be exist, the function will - * fail if the widget doesn't exist or is - * inactive and must be active. Upon failure a - * wml_error is thrown. - * - * @returns The widget with the id. - */ -template -NOT_DANGLING T* find_widget(utils::const_clone_ptr widget, - const std::string& id, - const bool must_be_active, - const bool must_exist) -{ - T* result = dynamic_cast(widget->find(id, must_be_active)); - VALIDATE(!must_exist || result, missing_widget(id)); - - return result; -} - -/** - * Gets a widget with the wanted id. - * - * This template function doesn't return a reference to a generic widget but - * returns a reference to the wanted type - * - * @param widget The widget test or find a child with the wanted - * id. - * @param id The id of the widget to find. - * @param must_be_active The widget should be active, not all widgets - * have an active flag, those who don't ignore - * flag. - * - * @returns The widget with the id. - */ -template -NOT_DANGLING T& find_widget(utils::const_clone_ptr widget, - const std::string& id, - const bool must_be_active) -{ - return *find_widget(widget, id, must_be_active, true); -} - -template -void on_widget(utils::const_clone_ptr parent, const std::string& id, std::function func) -{ - if(auto widget = find_widget(parent, id, false, false)) { - func(*widget); - } -} -} // namespace gui2 diff --git a/src/gui/dialogs/help_browser.cpp b/src/gui/dialogs/help_browser.cpp index 297a573e56e..17c47b4b075 100644 --- a/src/gui/dialogs/help_browser.cpp +++ b/src/gui/dialogs/help_browser.cpp @@ -18,7 +18,6 @@ #include "gui/dialogs/help_browser.hpp" #include "game_config_manager.hpp" -#include "gui/auxiliary/find_widget.hpp" #include "gui/widgets/button.hpp" #include "gui/widgets/image.hpp" #include "gui/widgets/label.hpp"