Author: mordante
Date: Thu Apr 30 14:14:41 2009
New Revision: 35340

URL: http://svn.gna.org/viewcvs/wesnoth?rev=35340&view=rev
Log:
Add NEW_request_reduce_width for tcontrol.

Modified:
    trunk/src/gui/widgets/control.cpp
    trunk/src/gui/widgets/control.hpp

Modified: trunk/src/gui/widgets/control.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/control.cpp?rev=35340&r1=35339&r2=35340&view=diff
==============================================================================
--- trunk/src/gui/widgets/control.cpp (original)
+++ trunk/src/gui/widgets/control.cpp Thu Apr 30 14:14:41 2009
@@ -142,6 +142,35 @@
 
        if(full_initialization) {
                shrunken_ = false;
+       }
+}
+
+void tcontrol::NEW_request_reduce_width(const unsigned maximum_width)
+{
+       // Inherited.
+       twidget::NEW_request_reduce_width(maximum_width);
+
+       assert(config_);
+
+       if(!label_.empty() && can_wrap()) {
+
+               tpoint size = get_best_text_size(
+                               tpoint(0,0),
+                               tpoint(maximum_width - 
config_->text_extra_width, 0));
+
+               size.x += config_->text_extra_width;
+               size.y += config_->text_extra_height;
+
+               set_layout_size(size);
+
+               DBG_GUI_L << "tcontrol(" + get_control_type() + ") " + __func__ 
+ ":"
+                               << " maximum_width " << maximum_width
+                               << " result " << size
+                               << ".\n";
+
+       } else {
+               DBG_GUI_L << "tcontrol(" + get_control_type() + ") " + __func__ 
+ ":"
+                               << " failed; either no label or wrapping not 
allowed.\n";
        }
 }
 

Modified: trunk/src/gui/widgets/control.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/control.hpp?rev=35340&r1=35339&r2=35340&view=diff
==============================================================================
--- trunk/src/gui/widgets/control.hpp (original)
+++ trunk/src/gui/widgets/control.hpp Thu Apr 30 14:14:41 2009
@@ -155,6 +155,9 @@
        void NEW_layout_init(const bool full_initialization);
 
        /** Inherited from twidget. */
+       void NEW_request_reduce_width(const unsigned maximum_width);
+
+       /** Inherited from twidget. */
        void layout_wrap(const unsigned maximum_width);
 
        /** Inherited from twidget. */


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

Reply via email to