/[svn]/gigedit/trunk/src/gigedit/compat.h
ViewVC logotype

Contents of /gigedit/trunk/src/gigedit/compat.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3735 - (show annotations) (download) (as text)
Sat Feb 1 19:28:43 2020 UTC (4 years, 1 month ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 18682 byte(s)
- Added widget class 'MultiLineLabel' to fix size issues with stock
  Gtk::Label on large text blocks.

1 /* -*- c++ -*-
2 * Copyright (C) 2011-2019 Andreas Persson
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2, or (at
7 * your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with program; see the file COPYING. If not, write to the Free
16 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
17 * 02110-1301 USA.
18 */
19
20 #ifndef GIGEDIT_COMPAT_H
21 #define GIGEDIT_COMPAT_H
22
23 #ifdef GTK_HEADER_FILE
24 # include GTK_HEADER_FILE(gtk.h)
25 #else
26 # include <gtk/gtk.h>
27 #endif
28
29 #ifdef GLIBMM_HEADER_FILE
30 # include GLIBMM_HEADER_FILE(glibmmconfig.h)
31 #else
32 # include <glibmmconfig.h>
33 #endif
34
35 #ifdef PANGOMM_HEADER_FILE
36 # include PANGOMM_HEADER_FILE(pangommconfig.h)
37 #else
38 # include <pangommconfig.h>
39 #endif
40
41 #ifdef CAIROMM_HEADER_FILE
42 # include CAIROMM_HEADER_FILE(cairommconfig.h)
43 #elif HAVE_CAIROMMCONFIG_H
44 # include <cairommconfig.h>
45 #endif
46
47 #ifdef GTKMM_HEADER_FILE
48 # include GTKMM_HEADER_FILE(gtkmmconfig.h)
49 #else
50 # include <gtkmmconfig.h>
51 #endif
52
53 #ifndef HAS_PANGOMM_CPP11_ENUMS
54 // new enums introduced in unstable pangomm 2.41.3, but not in stable 2.42
55 # if PANGOMM_MAJOR_VERSION > 2 || (PANGOMM_MAJOR_VERSION == 2 && ((PANGOMM_MINOR_VERSION == 41 && PANGOMM_MICRO_VERSION >= 3) || PANGOMM_MINOR_VERSION > 42))
56 # define HAS_PANGOMM_CPP11_ENUMS 1
57 # else
58 # define HAS_PANGOMM_CPP11_ENUMS 0
59 # endif
60 #endif
61
62 // Gtk::UIManager had been replaced by Gtk::Builder in GTKMM 3 and removed in GTKMM 4
63 // Gtk::ActionGroup had been replaced by Gio::ActionGroup in GTKMM 3 and removed in GTKMM 4
64 #if !defined(USE_GTKMM_BUILDER) || !defined(USE_GLIB_ACTION) // gtkmm > 3.22 :
65 # if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 24)
66 # define USE_GTKMM_BUILDER 1
67 # define USE_GLIB_ACTION 1
68 # else
69 # define USE_GTKMM_BUILDER 0
70 # define USE_GLIB_ACTION 0
71 # endif
72 #endif
73
74 #ifndef HAS_GDKMM_SEAT
75 # if GTKMM_MAJOR_VERSION > 2 || (GTKMM_MAJOR_VERSION == 2 && (GTKMM_MINOR_VERSION > 99 || (GTKMM_MINOR_VERSION == 99 && GTKMM_MICRO_VERSION >= 1))) // GTKM >= 2.99.1
76 # define HAS_GDKMM_SEAT 1
77 # else
78 # define HAS_GDKMM_SEAT 0
79 # endif
80 #endif
81
82 #ifndef HAS_GTKMM_CPP11_ENUMS // gtkmm > 3.22
83 # if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 24)
84 # define HAS_GTKMM_CPP11_ENUMS 1
85 # else
86 # define HAS_GTKMM_CPP11_ENUMS 0
87 # endif
88 #endif
89
90 // alignment.h had been removed in GTKMM 4
91 #ifndef HAS_GTKMM_ALIGNMENT // gtkmm > 3.22 :
92 # if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 24)
93 # define HAS_GTKMM_ALIGNMENT 0
94 # else
95 # define HAS_GTKMM_ALIGNMENT 1
96 # endif
97 #endif
98
99 // Gtk::Table had been replaced by Gtk::Grid in GTKMM 3 and removed in GTKMM 4
100 // stock.h had been removed in GTKMM 4
101 // Gtk::VBox, Gtk::HBox and Gtk::HButtonBox had been replaced by Gtk::Box in GTKMM 3 and removed in GTKMM 4
102 #if !defined(USE_GTKMM_GRID) || !defined(HAS_GTKMM_STOCK) || !defined(USE_GTKMM_BOX) || !defined(USE_GTKMM_PANED) // gtkmm > 3.22 :
103 # if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 24)
104 # define USE_GTKMM_GRID 1
105 # define HAS_GTKMM_STOCK 0
106 # define USE_GTKMM_BOX 1
107 # define USE_GTKMM_PANED 1
108 # else
109 # define USE_GTKMM_GRID 0
110 # define HAS_GTKMM_STOCK 1
111 # define USE_GTKMM_BOX 0
112 # define USE_GTKMM_PANED 0
113 # endif
114 #endif
115
116 // Gtk::Widget::show_all_children() had been removed in GTKMM 3.89.4
117 #ifndef HAS_GTKMM_SHOW_ALL_CHILDREN
118 # if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && (GTKMM_MINOR_VERSION > 89 || (GTKMM_MINOR_VERSION == 89 && GTKMM_MICRO_VERSION >= 4)))
119 # define HAS_GTKMM_SHOW_ALL_CHILDREN 0
120 # else
121 # define HAS_GTKMM_SHOW_ALL_CHILDREN 1
122 # endif
123 #endif
124
125 // enums have been renamed in cairomm 1.15.4
126 #ifndef HAS_CAIROMM_CPP11_ENUMS // cairomm >= 1.15.4 :
127 # if CAIROMM_MAJOR_VERSION > 1 || (CAIROMM_MAJOR_VERSION == 1 && (CAIROMM_MINOR_VERSION > 15 || (CAIROMM_MINOR_VERSION == 15 && CAIROMM_MICRO_VERSION >= 4)))
128 # define HAS_CAIROMM_CPP11_ENUMS 1
129 # else
130 # define HAS_CAIROMM_CPP11_ENUMS 0
131 # endif
132 #endif
133
134 #include <gtkmm/buttonbox.h>
135 #include <gtkmm/scale.h>
136
137 #if USE_GTKMM_BOX
138 # include <gtkmm/box.h>
139 class HBox : public Gtk::Box {
140 public:
141 HBox() : Gtk::Box(Gtk::Orientation::HORIZONTAL) {}
142 };
143
144 class VBox : public Gtk::Box {
145 public:
146 VBox() : Gtk::Box(Gtk::Orientation::VERTICAL) {}
147 };
148
149 class HButtonBox : public Gtk::ButtonBox {
150 public:
151 HButtonBox() : Gtk::ButtonBox(Gtk::Orientation::HORIZONTAL) {}
152 };
153
154 class HScale : public Gtk::Scale {
155 public:
156 HScale() : Gtk::Scale(Gtk::Orientation::HORIZONTAL) {}
157 HScale(const Glib::RefPtr<Gtk::Adjustment>& adjustment) : Gtk::Scale(adjustment, Gtk::Orientation::HORIZONTAL) {}
158 };
159 #else
160 # if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && (GTKMM_MINOR_VERSION > 1 || (GTKMM_MINOR_VERSION == 1 && GTKMM_MICRO_VERSION >= 6))) // GTKMM >= 3.1.6
161 # include <gtkmm/hvbox.h>
162 #endif
163 typedef Gtk::HBox HBox;
164 typedef Gtk::VBox VBox;
165 typedef Gtk::HButtonBox HButtonBox;
166 typedef Gtk::HScale HScale;
167 #endif // USE_GTKMM_BOX
168
169 #if USE_GTKMM_PANED
170 # include <gtkmm/paned.h>
171 namespace Gtk {
172 class HPaned : public Paned {
173 public:
174 HPaned() : Paned(Orientation::HORIZONTAL) {}
175 };
176 }
177 #endif // USE_GTKMM_PANED
178
179 #if USE_GLIB_ACTION
180 # include <giomm/simpleactiongroup.h>
181 # include <giomm/simpleaction.h>
182 typedef Gio::SimpleActionGroup ActionGroup;
183 typedef Gio::SimpleAction Action;
184 #else
185 # include <gtkmm/actiongroup.h>
186 # include <gtkmm/action.h>
187 typedef Gtk::ActionGroup ActionGroup;
188 typedef Gtk::Action Action;
189 #endif // USE_GLIB_ACTION
190
191 #if HAS_PANGOMM_CPP11_ENUMS
192 # include <pangomm/layout.h>
193 namespace Pango {
194 const Alignment ALIGN_LEFT = Alignment::LEFT;
195 const Alignment ALIGN_CENTER = Alignment::CENTER;
196 const Alignment ALIGN_RIGHT = Alignment::RIGHT;
197 }
198 #endif // HAS_PANGOMM_CPP11_ENUMS
199
200 #if HAS_GTKMM_CPP11_ENUMS
201 # include <gdkmm/types.h>
202 # include <gdkmm/cursor.h>
203 # include <gdkmm/pixbuf.h>
204 # include <gtkmm/enums.h>
205 # include <gtkmm/box.h>
206 # include <gtkmm/icontheme.h>
207 # include <gtkmm/messagedialog.h>
208 # include <gtkmm/dialog.h>
209 # include <gtkmm/textview.h>
210 # include <gtkmm/filechooser.h>
211 namespace Gdk {
212 const Cursor::Type SB_H_DOUBLE_ARROW = Cursor::Type::SB_H_DOUBLE_ARROW;
213 const Cursor::Type FLEUR = Cursor::Type::FLEUR;
214 const InterpType INTERP_NEAREST = InterpType::NEAREST;
215 const InterpType INTERP_TILES = InterpType::TILES;
216 const InterpType INTERP_BILINEAR = InterpType::BILINEAR;
217 const InterpType INTERP_HYPER = InterpType::HYPER;
218 const ModifierType SHIFT_MASK = ModifierType::SHIFT_MASK;
219 const ModifierType LOCK_MASK = ModifierType::LOCK_MASK;
220 const ModifierType CONTROL_MASK = ModifierType::CONTROL_MASK;
221 const ModifierType MOD1_MASK = ModifierType::MOD1_MASK;
222 const ModifierType MOD2_MASK = ModifierType::MOD2_MASK;
223 const ModifierType MOD3_MASK = ModifierType::MOD3_MASK;
224 const ModifierType MOD4_MASK = ModifierType::MOD4_MASK;
225 const ModifierType MOD5_MASK = ModifierType::MOD5_MASK;
226 const ModifierType BUTTON1_MASK = ModifierType::BUTTON1_MASK;
227 const ModifierType BUTTON2_MASK = ModifierType::BUTTON2_MASK;
228 const ModifierType BUTTON3_MASK = ModifierType::BUTTON3_MASK;
229 const ModifierType BUTTON4_MASK = ModifierType::BUTTON4_MASK;
230 const ModifierType BUTTON5_MASK = ModifierType::BUTTON5_MASK;
231 const ModifierType SUPER_MASK = ModifierType::SUPER_MASK;
232 const ModifierType HYPER_MASK = ModifierType::HYPER_MASK;
233 const ModifierType META_MASK = ModifierType::META_MASK;
234 const ModifierType RELEASE_MASK = ModifierType::RELEASE_MASK;
235 const ModifierType MODIFIER_MASK = ModifierType::MODIFIER_MASK;
236 }
237 namespace Gtk {
238 const PackOptions SHRINK = PackOptions::SHRINK;
239 const PackOptions PACK_SHRINK = PackOptions::SHRINK;
240 const PackOptions PACK_EXPAND_PADDING = PackOptions::EXPAND_PADDING;
241 const PackOptions PACK_EXPAND_WIDGET = PackOptions::EXPAND_WIDGET;
242 const ButtonBoxStyle BUTTONBOX_SPREAD = ButtonBoxStyle::SPREAD;
243 const ButtonBoxStyle BUTTONBOX_EDGE = ButtonBoxStyle::EDGE;
244 const ButtonBoxStyle BUTTONBOX_START = ButtonBoxStyle::START;
245 const ButtonBoxStyle BUTTONBOX_END = ButtonBoxStyle::END;
246 const ButtonBoxStyle BUTTONBOX_CENTER = ButtonBoxStyle::CENTER;
247 const ButtonBoxStyle BUTTONBOX_EXPAND = ButtonBoxStyle::EXPAND;
248 const MessageType MESSAGE_INFO = MessageType::INFO;
249 const MessageType MESSAGE_WARNING = MessageType::WARNING;
250 const MessageType MESSAGE_QUESTION = MessageType::QUESTION;
251 const MessageType MESSAGE_ERROR = MessageType::ERROR;
252 const MessageType MESSAGE_OTHER = MessageType::OTHER;
253 const ButtonsType BUTTONS_NONE = ButtonsType::NONE;
254 const ButtonsType BUTTONS_OK = ButtonsType::OK;
255 const ButtonsType BUTTONS_CLOSE = ButtonsType::CLOSE;
256 const ButtonsType BUTTONS_CANCEL = ButtonsType::CANCEL;
257 const ButtonsType BUTTONS_YES_NO = ButtonsType::YES_NO;
258 const ButtonsType BUTTONS_OK_CANCEL = ButtonsType::OK_CANCEL;
259 const ResponseType RESPONSE_NONE = ResponseType::NONE;
260 const ResponseType RESPONSE_REJECT = ResponseType::REJECT;
261 const ResponseType RESPONSE_ACCEPT = ResponseType::ACCEPT;
262 const ResponseType RESPONSE_DELETE_EVENT = ResponseType::DELETE_EVENT;
263 const ResponseType RESPONSE_OK = ResponseType::OK;
264 const ResponseType RESPONSE_CANCEL = ResponseType::CANCEL;
265 const ResponseType RESPONSE_CLOSE = ResponseType::CLOSE;
266 const ResponseType RESPONSE_YES = ResponseType::YES;
267 const ResponseType RESPONSE_NO = ResponseType::NO;
268 const ResponseType RESPONSE_APPLY = ResponseType::APPLY;
269 const ResponseType RESPONSE_HELP = ResponseType::HELP;
270 const ShadowType SHADOW_NONE = ShadowType::NONE;
271 const ShadowType SHADOW_IN = ShadowType::IN;
272 const ShadowType SHADOW_OUT = ShadowType::OUT;
273 const ShadowType SHADOW_ETCHED_IN = ShadowType::ETCHED_IN;
274 const ShadowType SHADOW_ETCHED_OUT = ShadowType::ETCHED_OUT;
275 const Align ALIGN_FILL = Align::FILL;
276 const Align ALIGN_START = Align::START;
277 const Align ALIGN_END = Align::END;
278 const Align ALIGN_CENTER = Align::CENTER;
279 const Align ALIGN_BASELINE = Align::BASELINE;
280 const WindowPosition WIN_POS_NONE = WindowPosition::NONE;
281 const WindowPosition WIN_POS_CENTER = WindowPosition::CENTER;
282 const WindowPosition WIN_POS_MOUSE = WindowPosition::MOUSE;
283 const WindowPosition WIN_POS_CENTER_ALWAYS = WindowPosition::CENTER_ALWAYS;
284 const WindowPosition WIN_POS_CENTER_ON_PARENT = WindowPosition::CENTER_ON_PARENT;
285 const PolicyType POLICY_ALWAYS = PolicyType::ALWAYS;
286 const PolicyType POLICY_AUTOMATIC = PolicyType::AUTOMATIC;
287 const PolicyType POLICY_NEVER = PolicyType::NEVER;
288 const PolicyType POLICY_EXTERNAL = PolicyType::EXTERNAL;
289 const ToolbarStyle TOOLBAR_ICONS = ToolbarStyle::ICONS;
290 const ToolbarStyle TOOLBAR_TEXT = ToolbarStyle::TEXT;
291 const ToolbarStyle TOOLBAR_BOTH = ToolbarStyle::BOTH;
292 const ToolbarStyle TOOLBAR_BOTH_HORIZ = ToolbarStyle::BOTH_HORIZ;
293 const DirectionType DIR_TAB_FORWARD = DirectionType::TAB_FORWARD;
294 const DirectionType DIR_TAB_BACKWARD = DirectionType::TAB_BACKWARD;
295 const DirectionType DIR_UP = DirectionType::UP;
296 const DirectionType DIR_DOWN = DirectionType::DOWN;
297 const DirectionType DIR_LEFT = DirectionType::LEFT;
298 const DirectionType DIR_RIGHT = DirectionType::RIGHT;
299 const SelectionMode SELECTION_NONE = SelectionMode::NONE;
300 const SelectionMode SELECTION_SINGLE = SelectionMode::SINGLE;
301 const SelectionMode SELECTION_BROWSE = SelectionMode::BROWSE;
302 const SelectionMode SELECTION_MULTIPLE = SelectionMode::MULTIPLE;
303 const BuiltinIconSize ICON_SIZE_INVALID = BuiltinIconSize::INVALID;
304 const BuiltinIconSize ICON_SIZE_MENU = BuiltinIconSize::MENU;
305 const BuiltinIconSize ICON_SIZE_SMALL_TOOLBAR = BuiltinIconSize::SMALL_TOOLBAR;
306 const BuiltinIconSize ICON_SIZE_LARGE_TOOLBAR = BuiltinIconSize::LARGE_TOOLBAR;
307 const BuiltinIconSize ICON_SIZE_BUTTON = BuiltinIconSize::BUTTON;
308 const BuiltinIconSize ICON_SIZE_DND = BuiltinIconSize::DND;
309 const BuiltinIconSize ICON_SIZE_DIALOG = BuiltinIconSize::DIALOG;
310 const IconLookupFlags ICON_LOOKUP_NO_SVG = IconLookupFlags::NO_SVG;
311 const IconLookupFlags ICON_LOOKUP_FORCE_SVG = IconLookupFlags::FORCE_SVG;
312 const IconLookupFlags ICON_LOOKUP_USE_BUILTIN = IconLookupFlags::USE_BUILTIN;
313 const IconLookupFlags ICON_LOOKUP_GENERIC_FALLBACK = IconLookupFlags::GENERIC_FALLBACK;
314 const IconLookupFlags ICON_LOOKUP_FORCE_SIZE = IconLookupFlags::FORCE_SIZE;
315 const IconLookupFlags ICON_LOOKUP_FORCE_REGULAR = IconLookupFlags::FORCE_REGULAR;
316 const IconLookupFlags ICON_LOOKUP_FORCE_SYMBOLIC = IconLookupFlags::FORCE_SYMBOLIC;
317 const IconLookupFlags ICON_LOOKUP_DIR_LTR = IconLookupFlags::DIR_LTR;
318 const IconLookupFlags ICON_LOOKUP_DIR_RTL = IconLookupFlags::DIR_RTL;
319 const TextWindowType TEXT_WINDOW_PRIVATE = TextWindowType::PRIVATE;
320 const TextWindowType TEXT_WINDOW_WIDGET = TextWindowType::WIDGET;
321 const TextWindowType TEXT_WINDOW_TEXT = TextWindowType::TEXT;
322 const TextWindowType TEXT_WINDOW_LEFT = TextWindowType::LEFT;
323 const TextWindowType TEXT_WINDOW_RIGHT = TextWindowType::RIGHT;
324 const TextWindowType TEXT_WINDOW_TOP = TextWindowType::TOP;
325 const TextWindowType TEXT_WINDOW_BOTTOM = TextWindowType::BOTTOM;
326 const FileChooser::Action FILE_CHOOSER_ACTION_OPEN = FileChooser::Action::OPEN;
327 const FileChooser::Action FILE_CHOOSER_ACTION_SAVE = FileChooser::Action::SAVE;
328 const FileChooser::Action FILE_CHOOSER_ACTION_SELECT_FOLDER = FileChooser::Action::SELECT_FOLDER;
329 const FileChooser::Action FILE_CHOOSER_ACTION_CREATE_FOLDER = FileChooser::Action::CREATE_FOLDER;
330 }
331 #endif // HAS_GTKMM_CPP11_ENUMS
332
333 // 2.10
334
335 #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 10) || GTKMM_MAJOR_VERSION < 2
336 #define create_cairo_context() \
337 gobj() ? Cairo::RefPtr<Cairo::Context>( \
338 new Cairo::Context(gdk_cairo_create(get_window()->gobj()))) : \
339 Cairo::RefPtr<Cairo::Context>()
340 #endif
341
342
343 // 2.12
344
345 #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 12) || GTKMM_MAJOR_VERSION < 2
346 #include <gtkmm/cellrenderertext.h>
347 namespace Gtk {
348 // this is not a real spin cell renderer, instead it's just text,
349 // extended with a property for storing an adjustment
350 class CellRendererSpin : public CellRendererText {
351 private:
352 Adjustment* adj;
353 struct Proxy {
354 Adjustment*& adj;
355 Proxy(Adjustment*& adj) : adj(adj) { }
356 const Adjustment* get_value() const { return adj; }
357 void operator=(Adjustment* x) { adj = x; }
358 };
359 public:
360 Proxy property_adjustment() const {
361 return const_cast<Adjustment*&>(adj);
362 }
363 };
364 }
365 #endif
366
367
368 // 2.18
369
370 #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 18) || GTKMM_MAJOR_VERSION < 2
371 #define set_can_focus() set_flags(Gtk::CAN_FOCUS)
372 #define set_can_default() set_flags(Gtk::CAN_DEFAULT)
373 #endif
374
375
376 // 2.21.9
377
378 #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION == 21 && GTKMM_MICRO_VERSION < 9) || \
379 (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 21) || GTKMM_MAJOR_VERSION < 2
380 #define ALIGN_START ALIGN_LEFT
381 #define ALIGN_END ALIGN_RIGHT
382 #endif
383
384
385 // 2.24
386
387 #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 24) || GTKMM_MAJOR_VERSION < 2
388 #define get_first_cell() get_first_cell_renderer()
389 #endif
390
391
392 // 3.0
393
394 #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2
395 #include <cairomm/context.h>
396 #include <gdkmm/color.h>
397
398 namespace Gdk {
399 typedef Color RGBA;
400
401 namespace Cairo {
402 void set_source_rgba(const ::Cairo::RefPtr< ::Cairo::Context >& context,
403 const Gdk::RGBA& color);
404 }
405 }
406 #endif
407
408
409 // glibmm 2.31.2
410
411 #if (GLIBMM_MAJOR_VERSION == 2 && GLIBMM_MINOR_VERSION == 31 && GLIBMM_MICRO_VERSION < 2) || \
412 (GLIBMM_MAJOR_VERSION == 2 && GLIBMM_MINOR_VERSION < 31) || GLIBMM_MAJOR_VERSION < 2
413
414 namespace Glib {
415 namespace Threads {
416 using Glib::Thread;
417 using Glib::Mutex;
418 using Glib::Cond;
419 }
420 }
421
422 #define OLD_THREADS
423
424 #endif // glibmm 2.31.2
425
426
427 // glibmm 2.47.3
428
429 #if (GLIBMM_MAJOR_VERSION == 2 && GLIBMM_MINOR_VERSION == 47 && GLIBMM_MICRO_VERSION < 3) || \
430 (GLIBMM_MAJOR_VERSION == 2 && GLIBMM_MINOR_VERSION < 47) || GLIBMM_MAJOR_VERSION < 2
431
432 #define GLIB_THREADS
433
434 #endif
435
436 #include <gtkmm/label.h>
437
438 /** @brief Auto wrapped (multi-line) text, auto shrank to min. dimensions.
439 *
440 * This widgets is intended for large text blocks which are expected to require
441 * the text to be automatically wrapped (i.e. auto inserted line breaks) such
442 * that it would not exceed the label's maximum allowed width according to its
443 * parent container.
444 *
445 * This class overrides get_preferred_height_for_width_vfunc() to fix the
446 * default behaviour of Gtk::Label, which by default calculates a height under
447 * the assumption that EVERY word of the text had a line break, which would
448 * cause the label to claim much more vertical space than actually required for
449 * the text.
450 */
451 class MultiLineLabel : public Gtk::Label {
452 public:
453 MultiLineLabel() : Gtk::Label() {
454 #if GTKMM_MAJOR_VERSION >= 3
455 set_line_wrap();
456 #endif
457 }
458
459 void set_markup(const Glib::ustring& s) {
460 Gtk::Label::set_markup(s);
461 m_markup = s;
462 }
463
464 void get_preferred_height_for_width_vfunc(int width, int& minimum_height, int& natural_height) const {
465 Gtk::Label::get_preferred_height_for_width_vfunc(width, minimum_height, natural_height);
466 //printf("super suggests minimum_height=%d natural_height=%d\n", minimum_height, natural_height);
467
468 Pango::Layout* origLayout = const_cast<Pango::Layout*>(get_layout().operator->());
469 Glib::RefPtr<Pango::Layout> layout = origLayout->copy();
470 Glib::ustring s = (!m_markup.empty()) ? m_markup : get_text();
471 layout->set_markup(s);
472 int w, h;
473 layout->get_pixel_size(w, h);
474 h += get_margin_top() + get_margin_bottom();
475 //printf("calculated w=%d h=%d\n", w, h);
476
477 minimum_height = h;
478 if (natural_height < h)
479 natural_height = h;
480 }
481
482 private:
483 Glib::ustring m_markup;
484 };
485
486 #endif // GIGEDIT_COMPAT_H

  ViewVC Help
Powered by ViewVC