Author: mordante
Date: Sun Mar 13 08:49:27 2011
New Revision: 48874

URL: http://svn.gna.org/viewcvs/wesnoth?rev=48874&view=rev
Log:
Add register functions to the dialog.

The functions added allow to register images and labels.

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=48874&r1=48873&r2=48874&view=diff
==============================================================================
--- trunk/src/gui/dialogs/dialog.cpp (original)
+++ trunk/src/gui/dialogs/dialog.cpp Sun Mar 13 08:49:27 2011
@@ -177,6 +177,21 @@
        return tdialog::register_text(id, !mandatory, linked_variable);
 }
 
+tfield_label* tdialog::register_label2(const std::string& id
+               , const bool mandatory
+               , const std::string& text
+               , const bool use_markup)
+{
+       tfield_label* field =  new tfield_label(
+                         id
+                       , mandatory
+                       , text
+                       , use_markup);
+
+       fields_.push_back(field);
+       return field;
+}
+
 twindow* tdialog::build_window(CVideo& video) const
 {
        return build(video, window_id());

Modified: trunk/src/gui/dialogs/dialog.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/dialogs/dialog.hpp?rev=48874&r1=48873&r2=48874&view=diff
==============================================================================
--- trunk/src/gui/dialogs/dialog.hpp (original)
+++ trunk/src/gui/dialogs/dialog.hpp Sun Mar 13 08:49:27 2011
@@ -275,6 +275,37 @@
                        , const bool mandatory
                        , std::string& linked_variable
                        , const bool capture_focus = false);
+
+       /**
+        * Registers a new control as a label.
+        *
+        * The label is used for a control to set the 'label' since it calls the
+        * @ref tcontrol::set_label it can also be used for the @ref timage 
since
+        * there this sets the filename. (The @p use_markup makes no sense in an
+        * image but that's a detail.)
+        *
+        * @note In general it's prefered a widget sets its markup flag in WML, 
but
+        * some generice windows (like messages) may need different versions
+        * depending on where used.
+        *
+        * @param id                  Id of the widget, same value as in WML.
+        * @param mandatory           Is the widget mandatory or optional.
+        * @param text                The text for the label.
+        * @param use_markup          Whether or not use markup for the label.
+        */
+       tfield_label* register_label2(const std::string& id
+                       , const bool mandatory
+                       , const std::string& text
+                       , const bool use_markup = false);
+
+       /** Registers a new control as image. */
+       tfield_label* register_image2(const std::string& id
+                       , const bool mandatory
+                       , const std::string& filename)
+       {
+               return register_label2(id, mandatory, filename);
+       }
+
 private:
        /** Returns the window exit status, 0 means not shown. */
        int retval_;


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

Reply via email to