/[svn]/gigedit/trunk/src/gigedit/wrapLabel.cc
ViewVC logotype

Diff of /gigedit/trunk/src/gigedit/wrapLabel.cc

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1799 by persson, Sat Dec 6 13:49:26 2008 UTC revision 3364 by schoenebeck, Tue Nov 14 18:07:25 2017 UTC
# Line 1  Line 1 
1  /* *************************************************************************  /* *************************************************************************
2   * Copyright (c) 2005 VMware, Inc.   * Copyright (c) 2005 VMware, Inc.
3     * Copyright (c) 2011 - 2017 Andreas Persson
4   *   *
5   * Permission is hereby granted, free of charge, to any person obtaining   * Permission is hereby granted, free of charge, to any person obtaining
6   * a copy of this software and associated documentation files (the   * a copy of this software and associated documentation files (the
# Line 21  Line 22 
22   * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.   * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23   * *************************************************************************/   * *************************************************************************/
24    
25  #include <wrapLabel.hh>  #include "wrapLabel.hh"
26    #ifdef PANGOMM_HEADER_FILE
27    # include PANGOMM_HEADER_FILE(pangomm.h)
28    # include PANGOMM_HEADER_FILE(pangommconfig.h)
29    #else
30    # include <pangomm/pangomm.h>
31    # include <pangommconfig.h>
32    #endif
33    
34    // we don't need this WrapLabel helper class on GTKMM 3 and higher
35    #if GTKMM_MAJOR_VERSION < 3
36    
37  /*  /*
38   * wrapLabel.cc --   * wrapLabel.cc --
# Line 51  namespace view { Line 61  namespace view {
61   */   */
62    
63  WrapLabel::WrapLabel(const Glib::ustring &text) // IN: The label text  WrapLabel::WrapLabel(const Glib::ustring &text) // IN: The label text
64     : mWrapWidth(0)     : mWrapWidth(0),
65         mWrapHeight(0)
66  {  {
67       // pangomm >= 2.35.1
68    #if PANGOMM_MAJOR_VERSION > 2 || (PANGOMM_MAJOR_VERSION == 2 && (PANGOMM_MINOR_VERSION > 35 || (PANGOMM_MINOR_VERSION == 35 && PANGOMM_MICRO_VERSION >= 1)))
69       get_layout()->set_wrap(Pango::WrapMode::WORD_CHAR);
70    #else
71     get_layout()->set_wrap(Pango::WRAP_WORD_CHAR);     get_layout()->set_wrap(Pango::WRAP_WORD_CHAR);
72    #endif
73     set_alignment(0.0, 0.0);     set_alignment(0.0, 0.0);
74     set_text(text);     set_text(text);
75  }  }
# Line 132  WrapLabel::set_markup(const Glib::ustrin Line 148  WrapLabel::set_markup(const Glib::ustrin
148  void  void
149  WrapLabel::on_size_request(Gtk::Requisition *req) // OUT: Our requested size  WrapLabel::on_size_request(Gtk::Requisition *req) // OUT: Our requested size
150  {  {
    int width;  
    int height;  
   
    get_layout()->get_pixel_size(width, height);  
   
151     req->width  = 0;     req->width  = 0;
152     req->height = height;     req->height = mWrapHeight;
153  }  }
154    
155    
# Line 185  WrapLabel::on_size_allocate(Gtk::Allocat Line 196  WrapLabel::on_size_allocate(Gtk::Allocat
196   */   */
197    
198  void  void
199  WrapLabel::SetWrapWidth(size_t width) // IN: The wrap width  WrapLabel::SetWrapWidth(int width) // IN: The wrap width
200  {  {
201     if (width == 0) {     if (width == 0) {
202        return;        return;
203     }     }
204    
205       int xPadding, yPadding;
206       get_padding(xPadding, yPadding);
207    
208       width -= 2 * xPadding;
209    
210     /*     /*
211      * We may need to reset the wrap width, so do this regardless of whether      * We may need to reset the wrap width, so do this regardless of whether
212      * or not we've changed the width.      * or not we've changed the width.
213      */      */
214     get_layout()->set_width(width * Pango::SCALE);     get_layout()->set_width(width * Pango::SCALE);
215    
216       int unused;
217       get_layout()->get_pixel_size(unused, mWrapHeight);
218       mWrapHeight += 2 * yPadding;
219    
220     if (mWrapWidth != width) {     if (mWrapWidth != width) {
221        mWrapWidth = width;        mWrapWidth = width;
222        queue_resize();        queue_resize();
# Line 205  WrapLabel::SetWrapWidth(size_t width) // Line 225  WrapLabel::SetWrapWidth(size_t width) //
225    
226    
227  }; /* namespace view */  }; /* namespace view */
228    
229    #endif // GTKMM_MAJOR_VERSION < 3

Legend:
Removed from v.1799  
changed lines
  Added in v.3364

  ViewVC Help
Powered by ViewVC