diff --git a/src/dialogxml/dialogs/dialog.cpp b/src/dialogxml/dialogs/dialog.cpp index 57b5146fa..792de258b 100644 --- a/src/dialogxml/dialogs/dialog.cpp +++ b/src/dialogxml/dialogs/dialog.cpp @@ -245,6 +245,7 @@ void cDialog::loadFromFile(const DialogDefn& file){ } } prevCtrl = *inserted; + prevCtrl.second->setName(prevCtrl.first); // Needed to correctly resolve relative positioning inserted->second->recalcRect(); } @@ -464,6 +465,7 @@ bool cDialog::add(cControl* what, rectangle ctrl_frame, std::string key){ if(controls.find(key) != controls.end()) return false; what->setBounds(ctrl_frame); controls.insert(std::make_pair(key,what)); + what->setName(key); return true; } diff --git a/src/dialogxml/widgets/container.cpp b/src/dialogxml/widgets/container.cpp index 7483ec33f..29a601059 100644 --- a/src/dialogxml/widgets/container.cpp +++ b/src/dialogxml/widgets/container.cpp @@ -59,6 +59,7 @@ bool cContainer::parseChildControl(ticpp::Element& elem, std::mapsetName(prevCtrl.first); return true; } diff --git a/src/dialogxml/widgets/control.hpp b/src/dialogxml/widgets/control.hpp index f0a1983b0..9d9fc539a 100644 --- a/src/dialogxml/widgets/control.hpp +++ b/src/dialogxml/widgets/control.hpp @@ -149,6 +149,7 @@ protected: /// @throw xMissingAttr if a required attribute is missing /// @throw xMissingElem if a required attribute is either missing or present in insufficient quantity virtual void validatePostParse(ticpp::Element& who, std::string fname, const std::set& attrs, const std::multiset& nodes); + std::string name; public: /// Attach a keyboard shortcut to a control. Pressing the keyboard shortcut is equivalent to clicking the control. /// @param key The desired keyboard shortcut. @@ -181,6 +182,8 @@ public: if(old_handler.empty()) return nullptr; return boost::any_cast::type>(old_handler); } + inline std::string getName() { return name; } + inline void setName(std::string value) { name = value; } /// Attach a click handler to this control. /// @param f The click handler to attach. /// @throw xHandlerNotSupported if this control does not support click handlers. Most controls do support click handlers. diff --git a/src/dialogxml/widgets/scrollbar.cpp b/src/dialogxml/widgets/scrollbar.cpp index 7fe1998c3..a8f582cec 100644 --- a/src/dialogxml/widgets/scrollbar.cpp +++ b/src/dialogxml/widgets/scrollbar.cpp @@ -41,10 +41,6 @@ bool cScrollbar::isScrollable() const { return true; } -void cScrollbar::setName(std::string name) { - this->name = name; -} - void cScrollbar::setPosition(long newPos, bool record) { if(record && recording){ std::map info; diff --git a/src/dialogxml/widgets/scrollbar.hpp b/src/dialogxml/widgets/scrollbar.hpp index f479ee9a0..2ac925dcd 100644 --- a/src/dialogxml/widgets/scrollbar.hpp +++ b/src/dialogxml/widgets/scrollbar.hpp @@ -105,7 +105,6 @@ public: /// Get the scrollbar style. /// @return The style eScrollStyle getStyle() const; - void setName(std::string name); /// Set the scrollbar thumb's current position. /// @param to The new position. void setPosition(long to, bool record = false);