Author: mordante
Date: Sun Mar 13 08:49:38 2011
New Revision: 48878

URL: http://svn.gna.org/viewcvs/wesnoth?rev=48878&view=rev
Log:
Add a register_text2 function.

The original version has an optional flag the new version a
mandatory flag. The latter feels better. At some point all register
functions need to be changed.

Modified:
    trunk/src/gui/dialogs/dialog.cpp
    trunk/src/gui/dialogs/dialog.hpp

Modified: trunk/src/gui/dialogs/dialog.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/dialogs/dialog.cpp?rev=48878&r1=48877&r2=48878&view=diff
==============================================================================
--- trunk/src/gui/dialogs/dialog.cpp (original)
+++ trunk/src/gui/dialogs/dialog.cpp Sun Mar 13 08:49:38 2011
@@ -185,6 +185,24 @@
        return tdialog::register_text(id, !mandatory, linked_variable);
 }
 
+tfield_text* tdialog::register_text2(const std::string& id
+               , const bool mandatory
+               , std::string (*callback_load_value) ()
+               , void (*callback_save_value) (const std::string& value)
+               , const bool capture_focus)
+{
+       assert(!capture_focus || focus_.empty());
+
+       if(capture_focus) {
+               focus_ = id;
+       }
+
+       return tdialog::register_text(id
+                       , !mandatory
+                       , callback_load_value
+                       , callback_save_value);
+}
+
 tfield_label* tdialog::register_label2(const std::string& id
                , const bool mandatory
                , const std::string& text

Modified: trunk/src/gui/dialogs/dialog.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/dialogs/dialog.hpp?rev=48878&r1=48877&r2=48878&view=diff
==============================================================================
--- trunk/src/gui/dialogs/dialog.hpp (original)
+++ trunk/src/gui/dialogs/dialog.hpp Sun Mar 13 08:49:38 2011
@@ -298,6 +298,12 @@
                        , std::string& linked_variable
                        , const bool capture_focus = false);
 
+       tfield_text* register_text2(const std::string& id
+                       , const bool mandatory
+                       , std::string (*callback_load_value) () = NULL
+                       , void (*callback_save_value) (const std::string& 
value) = NULL
+                       , const bool capture_focus = false);
+
        /**
         * Registers a new control as a label.
         *


_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits

Reply via email to