mail[Wesnoth-commits] r33201 - in /trunk/src/gui/widgets: window_builder.cpp window_builder_private.hpp


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by koraq on March 01, 2009 - 09:23:
Author: mordante
Date: Sun Mar  1 09:23:23 2009
New Revision: 33201

URL: http://svn.gna.org/viewcvs/wesnoth?rev=33201&view=rev
Log:
Add a return_value_id config variable.

This variable should make it easier to define an known return value to a
button, which the need to give it the normal id.

Modified:
    trunk/src/gui/widgets/window_builder.cpp
    trunk/src/gui/widgets/window_builder_private.hpp

Modified: trunk/src/gui/widgets/window_builder.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/window_builder.cpp?rev=33201&r1=33200&r2=33201&view=diff
==============================================================================
--- trunk/src/gui/widgets/window_builder.cpp (original)
+++ trunk/src/gui/widgets/window_builder.cpp Sun Mar  1 09:23:23 2009
@@ -598,6 +598,7 @@
 
 tbuilder_button::tbuilder_button(const config& cfg) :
        tbuilder_control(cfg),
+       retval_id_(cfg["return_value_id"]),
        retval_(lexical_cast_default<int>(cfg["return_value"]))
 {
 /*WIKI
@@ -606,15 +607,20 @@
  *
  * == Button ==
  *
- * Definition of a button. When a button has a return value it sets the 
retour
- * value for the window. Normally this closes the window and returns this 
value
- * to the caller. The return value can either be defined by the user or
- * determined from the id of the button. The return value has a higher
- * precedence as the one defined by the id. (Of course it's weird to give a
- * button an id and then override it's return value.)
+ * Definition of a button. When a button has a return value it sets the
+ * retour value for the window. Normally this closes the window and returns
+ * this value to the caller. The return value can either be defined by the
+ * user or determined from the id of the button. The return value has a
+ * higher precedence as the one defined by the id. (Of course it's weird to
+ * give a button an id and then override it's return value.)
+ *
+ * When the button doesn't have a standard id, but you still want to use the
+ * return value of that id, use return_value_id instead. This has a higher
+ * precedence as return_value.
  *
  * List with the button specific variables:
  * @start_table = config
+ *     return_value_id (string = "")   The return value id.
  *     return_value (int = 0)          The return value.
  *
  * @end_table
@@ -628,7 +634,9 @@
 
        init_control(button);
 
-       if(retval_) {
+       if(!retval_id_.empty()) {
+               button->set_retval(twindow::get_retval_by_id(retval_id_));
+       } else if(retval_) {
                button->set_retval(retval_);
        } else {
                button->set_retval(twindow::get_retval_by_id(id));
@@ -1084,6 +1092,7 @@
 tbuilder_toggle_panel::tbuilder_toggle_panel(const config& cfg) :
        tbuilder_control(cfg),
        grid(0),
+       retval_id_(cfg["return_value_id"]),
        retval_(lexical_cast_default<int>(cfg["return_value"]))
 {
 /*WIKI
@@ -1099,6 +1108,8 @@
  * @start_table = config
  *     grid (section)                  Defines the grid with the widgets to
  *                                     place on the panel.
+ *     return_value_id (string = "")   The return value id, see
+ *                                     [[GUIToolkitWML#Button]] for more 
info.
  *     return_value (int = 0)          The return value, see
  *                                     [[GUIToolkitWML#Button]] for more 
info.
  * @end_table

Modified: trunk/src/gui/widgets/window_builder_private.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/window_builder_private.hpp?rev=33201&r1=33200&r2=33201&view=diff
==============================================================================
--- trunk/src/gui/widgets/window_builder_private.hpp (original)
+++ trunk/src/gui/widgets/window_builder_private.hpp Sun Mar  1 09:23:23 2009
@@ -59,6 +59,7 @@
        twidget* build () const;
 
 private:
+       std::string retval_id_;
        int retval_;
 };
 
@@ -398,6 +399,8 @@
  *
  * @start_table = config
  *     icon (f_string = "")            The name of the icon file to show.
+ *     return_value_id (string = "")   The return value id, see
+ *                                     [[GUIToolkitWML#Button]] for more 
info.
  *     return_value (int = 0)          The return value, see
  *                                     [[GUIToolkitWML#Button]] for more 
info.
  * @end_table
@@ -405,6 +408,7 @@
        tbuilder_toggle_button(const config& cfg) :
                tbuilder_control(cfg),
                icon_name_(cfg["icon"]),
+               retval_id_(cfg["return_value_id"]),
                retval_(lexical_cast_default<int>(cfg["return_value"]))
        {}
 
@@ -412,6 +416,7 @@
 
 private:
        std::string icon_name_;
+       std::string retval_id_;
        int retval_;
 };
 
@@ -428,6 +433,7 @@
        tbuilder_grid_ptr grid;
 
 private:
+       std::string retval_id_;
        int retval_;
 };
 




Related Messages


Powered by MHonArc, Updated Sun Mar 01 09:40:06 2009