Author: mordante
Date: Mon Aug 25 18:39:47 2008
New Revision: 28978

URL: http://svn.gna.org/viewcvs/wesnoth?rev=28978&view=rev
Log:
Let the user determine the ellipse mode default to end.

Modified:
    trunk/src/text.cpp
    trunk/src/text.hpp

Modified: trunk/src/text.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/text.cpp?rev=28978&r1=28977&r2=28978&view=diff
==============================================================================
--- trunk/src/text.cpp (original)
+++ trunk/src/text.cpp Mon Aug 25 18:39:47 2008
@@ -45,12 +45,15 @@
        foreground_colour_(0xFFFFFFFF), // solid white
        maximum_width_(-1),
        maximum_height_(-1),
+       ellipse_mode_(PANGO_ELLIPSIZE_END),
        calculation_dirty_(true),
        surface_dirty_(true),
        surface_buffer_(NULL)
 {      
        // With 72 dpi the sizes are the same as with SDL_TTF so hardcoded.
        pango_cairo_context_set_resolution(context_, 72.0);
+
+       pango_layout_set_ellipsize(layout_, ellipse_mode_);
 }
 
 ttext::~ttext()
@@ -172,6 +175,18 @@
                pango_layout_set_height(layout_, height == -1 ? -1 : height * 
PANGO_SCALE);
 #endif
                maximum_height_ = height;
+               calculation_dirty_ = true;
+               surface_dirty_ = true;
+       }
+
+       return *this;
+}
+
+ttext& ttext::set_ellipse_mode(const PangoEllipsizeMode ellipse_mode)
+{
+       if(ellipse_mode != ellipse_mode_) {
+               pango_layout_set_ellipsize(layout_, ellipse_mode);
+               ellipse_mode_ = ellipse_mode_;
                calculation_dirty_ = true;
                surface_dirty_ = true;
        }
@@ -225,13 +240,6 @@
                tfont font(get_fonts(), font_size_, font_style_);
                pango_layout_set_font_description(layout_, font.get());
 
-               // NOTE for now the setting of the ellipse is undocumented and
-               // implicitly done, this will change later. We'll need it for 
the
-               // textboxes.
-               pango_layout_set_ellipsize(layout_, 
-                       maximum_width_ == -1 && maximum_height_ == -1 
-                       ? PANGO_ELLIPSIZE_NONE : PANGO_ELLIPSIZE_END);
-
                pango_layout_get_pixel_extents(layout_, NULL, &rect_);
        }
 }

Modified: trunk/src/text.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/text.hpp?rev=28978&r1=28977&r2=28978&view=diff
==============================================================================
--- trunk/src/text.hpp (original)
+++ trunk/src/text.hpp Mon Aug 25 18:39:47 2008
@@ -91,6 +91,8 @@
 
        ttext& set_maximum_height(const int height);
 
+       ttext& set_ellipse_mode(const PangoEllipsizeMode ellipse_mode);
+
 private:
 
        /***** ***** ***** *****  Pango variables ***** ***** ***** *****/
@@ -123,6 +125,9 @@
 
        /** The maximum height of the text, -1 means no maximum . */
        int maximum_height_;
+
+       /** The way too long text is shown depends on this mode. */
+       PangoEllipsizeMode ellipse_mode_;
 
        /** 
         * The text has two dirty states:


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

Reply via email to