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 |
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.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 -- |
64 |
: mWrapWidth(0), |
: mWrapWidth(0), |
65 |
mWrapHeight(0) |
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 |
} |
} |
152 |
req->height = mWrapHeight; |
req->height = mWrapHeight; |
153 |
} |
} |
154 |
|
|
|
// Gigedit addtion: gtk 3 compatibility |
|
|
void WrapLabel::get_preferred_width_vfunc(int& minimum_width, int& natural_width) const |
|
|
{ |
|
|
minimum_width = natural_width = 0; |
|
|
} |
|
|
|
|
|
// Gigedit addtion: gtk 3 compatibility |
|
|
void WrapLabel::get_preferred_height_vfunc(int& minimum_height, int& natural_height) const |
|
|
{ |
|
|
minimum_height = natural_height = mWrapHeight; |
|
|
} |
|
155 |
|
|
156 |
/* |
/* |
157 |
*----------------------------------------------------------------------------- |
*----------------------------------------------------------------------------- |
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. |
215 |
|
|
216 |
int unused; |
int unused; |
217 |
get_layout()->get_pixel_size(unused, mWrapHeight); |
get_layout()->get_pixel_size(unused, mWrapHeight); |
218 |
|
mWrapHeight += 2 * yPadding; |
219 |
|
|
220 |
if (mWrapWidth != width) { |
if (mWrapWidth != width) { |
221 |
mWrapWidth = width; |
mWrapWidth = width; |
225 |
|
|
226 |
|
|
227 |
}; /* namespace view */ |
}; /* namespace view */ |
228 |
|
|
229 |
|
#endif // GTKMM_MAJOR_VERSION < 3 |