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 |
55 |
# if PANGOMM_MAJOR_VERSION > 2 || (PANGOMM_MAJOR_VERSION == 2 && ((PANGOMM_MINOR_VERSION == 41 && PANGOMM_MICRO_VERSION >= 3) || PANGOMM_MINOR_VERSION > 41)) |
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 |
// the following backward compatibility workaround seems to be obsolete since |
194 |
// pangomm 2.42 (and could then cause compilation errors due to redecleration) |
195 |
# if PANGOMM_MAJOR_VERSION == 2 && PANGOMM_MINOR_VERSION < 42 |
196 |
namespace Pango { |
197 |
const Alignment ALIGN_LEFT = Alignment::LEFT; |
198 |
const Alignment ALIGN_CENTER = Alignment::CENTER; |
199 |
const Alignment ALIGN_RIGHT = Alignment::RIGHT; |
200 |
} |
201 |
# endif |
202 |
#endif // HAS_PANGOMM_CPP11_ENUMS |
203 |
|
204 |
#if HAS_GTKMM_CPP11_ENUMS |
205 |
# include <gdkmm/types.h> |
206 |
# include <gdkmm/cursor.h> |
207 |
# include <gdkmm/pixbuf.h> |
208 |
# include <gtkmm/enums.h> |
209 |
# include <gtkmm/box.h> |
210 |
# include <gtkmm/icontheme.h> |
211 |
# include <gtkmm/messagedialog.h> |
212 |
# include <gtkmm/dialog.h> |
213 |
# include <gtkmm/textview.h> |
214 |
# include <gtkmm/filechooser.h> |
215 |
namespace Gdk { |
216 |
const Cursor::Type SB_H_DOUBLE_ARROW = Cursor::Type::SB_H_DOUBLE_ARROW; |
217 |
const Cursor::Type FLEUR = Cursor::Type::FLEUR; |
218 |
const InterpType INTERP_NEAREST = InterpType::NEAREST; |
219 |
const InterpType INTERP_TILES = InterpType::TILES; |
220 |
const InterpType INTERP_BILINEAR = InterpType::BILINEAR; |
221 |
const InterpType INTERP_HYPER = InterpType::HYPER; |
222 |
const ModifierType SHIFT_MASK = ModifierType::SHIFT_MASK; |
223 |
const ModifierType LOCK_MASK = ModifierType::LOCK_MASK; |
224 |
const ModifierType CONTROL_MASK = ModifierType::CONTROL_MASK; |
225 |
const ModifierType MOD1_MASK = ModifierType::MOD1_MASK; |
226 |
const ModifierType MOD2_MASK = ModifierType::MOD2_MASK; |
227 |
const ModifierType MOD3_MASK = ModifierType::MOD3_MASK; |
228 |
const ModifierType MOD4_MASK = ModifierType::MOD4_MASK; |
229 |
const ModifierType MOD5_MASK = ModifierType::MOD5_MASK; |
230 |
const ModifierType BUTTON1_MASK = ModifierType::BUTTON1_MASK; |
231 |
const ModifierType BUTTON2_MASK = ModifierType::BUTTON2_MASK; |
232 |
const ModifierType BUTTON3_MASK = ModifierType::BUTTON3_MASK; |
233 |
const ModifierType BUTTON4_MASK = ModifierType::BUTTON4_MASK; |
234 |
const ModifierType BUTTON5_MASK = ModifierType::BUTTON5_MASK; |
235 |
const ModifierType SUPER_MASK = ModifierType::SUPER_MASK; |
236 |
const ModifierType HYPER_MASK = ModifierType::HYPER_MASK; |
237 |
const ModifierType META_MASK = ModifierType::META_MASK; |
238 |
const ModifierType RELEASE_MASK = ModifierType::RELEASE_MASK; |
239 |
const ModifierType MODIFIER_MASK = ModifierType::MODIFIER_MASK; |
240 |
} |
241 |
namespace Gtk { |
242 |
const PackOptions SHRINK = PackOptions::SHRINK; |
243 |
const PackOptions PACK_SHRINK = PackOptions::SHRINK; |
244 |
const PackOptions PACK_EXPAND_PADDING = PackOptions::EXPAND_PADDING; |
245 |
const PackOptions PACK_EXPAND_WIDGET = PackOptions::EXPAND_WIDGET; |
246 |
const ButtonBoxStyle BUTTONBOX_SPREAD = ButtonBoxStyle::SPREAD; |
247 |
const ButtonBoxStyle BUTTONBOX_EDGE = ButtonBoxStyle::EDGE; |
248 |
const ButtonBoxStyle BUTTONBOX_START = ButtonBoxStyle::START; |
249 |
const ButtonBoxStyle BUTTONBOX_END = ButtonBoxStyle::END; |
250 |
const ButtonBoxStyle BUTTONBOX_CENTER = ButtonBoxStyle::CENTER; |
251 |
const ButtonBoxStyle BUTTONBOX_EXPAND = ButtonBoxStyle::EXPAND; |
252 |
const MessageType MESSAGE_INFO = MessageType::INFO; |
253 |
const MessageType MESSAGE_WARNING = MessageType::WARNING; |
254 |
const MessageType MESSAGE_QUESTION = MessageType::QUESTION; |
255 |
const MessageType MESSAGE_ERROR = MessageType::ERROR; |
256 |
const MessageType MESSAGE_OTHER = MessageType::OTHER; |
257 |
const ButtonsType BUTTONS_NONE = ButtonsType::NONE; |
258 |
const ButtonsType BUTTONS_OK = ButtonsType::OK; |
259 |
const ButtonsType BUTTONS_CLOSE = ButtonsType::CLOSE; |
260 |
const ButtonsType BUTTONS_CANCEL = ButtonsType::CANCEL; |
261 |
const ButtonsType BUTTONS_YES_NO = ButtonsType::YES_NO; |
262 |
const ButtonsType BUTTONS_OK_CANCEL = ButtonsType::OK_CANCEL; |
263 |
const ResponseType RESPONSE_NONE = ResponseType::NONE; |
264 |
const ResponseType RESPONSE_REJECT = ResponseType::REJECT; |
265 |
const ResponseType RESPONSE_ACCEPT = ResponseType::ACCEPT; |
266 |
const ResponseType RESPONSE_DELETE_EVENT = ResponseType::DELETE_EVENT; |
267 |
const ResponseType RESPONSE_OK = ResponseType::OK; |
268 |
const ResponseType RESPONSE_CANCEL = ResponseType::CANCEL; |
269 |
const ResponseType RESPONSE_CLOSE = ResponseType::CLOSE; |
270 |
const ResponseType RESPONSE_YES = ResponseType::YES; |
271 |
const ResponseType RESPONSE_NO = ResponseType::NO; |
272 |
const ResponseType RESPONSE_APPLY = ResponseType::APPLY; |
273 |
const ResponseType RESPONSE_HELP = ResponseType::HELP; |
274 |
const ShadowType SHADOW_NONE = ShadowType::NONE; |
275 |
const ShadowType SHADOW_IN = ShadowType::IN; |
276 |
const ShadowType SHADOW_OUT = ShadowType::OUT; |
277 |
const ShadowType SHADOW_ETCHED_IN = ShadowType::ETCHED_IN; |
278 |
const ShadowType SHADOW_ETCHED_OUT = ShadowType::ETCHED_OUT; |
279 |
const Align ALIGN_FILL = Align::FILL; |
280 |
const Align ALIGN_START = Align::START; |
281 |
const Align ALIGN_END = Align::END; |
282 |
const Align ALIGN_CENTER = Align::CENTER; |
283 |
const Align ALIGN_BASELINE = Align::BASELINE; |
284 |
const WindowPosition WIN_POS_NONE = WindowPosition::NONE; |
285 |
const WindowPosition WIN_POS_CENTER = WindowPosition::CENTER; |
286 |
const WindowPosition WIN_POS_MOUSE = WindowPosition::MOUSE; |
287 |
const WindowPosition WIN_POS_CENTER_ALWAYS = WindowPosition::CENTER_ALWAYS; |
288 |
const WindowPosition WIN_POS_CENTER_ON_PARENT = WindowPosition::CENTER_ON_PARENT; |
289 |
const PolicyType POLICY_ALWAYS = PolicyType::ALWAYS; |
290 |
const PolicyType POLICY_AUTOMATIC = PolicyType::AUTOMATIC; |
291 |
const PolicyType POLICY_NEVER = PolicyType::NEVER; |
292 |
const PolicyType POLICY_EXTERNAL = PolicyType::EXTERNAL; |
293 |
const ToolbarStyle TOOLBAR_ICONS = ToolbarStyle::ICONS; |
294 |
const ToolbarStyle TOOLBAR_TEXT = ToolbarStyle::TEXT; |
295 |
const ToolbarStyle TOOLBAR_BOTH = ToolbarStyle::BOTH; |
296 |
const ToolbarStyle TOOLBAR_BOTH_HORIZ = ToolbarStyle::BOTH_HORIZ; |
297 |
const DirectionType DIR_TAB_FORWARD = DirectionType::TAB_FORWARD; |
298 |
const DirectionType DIR_TAB_BACKWARD = DirectionType::TAB_BACKWARD; |
299 |
const DirectionType DIR_UP = DirectionType::UP; |
300 |
const DirectionType DIR_DOWN = DirectionType::DOWN; |
301 |
const DirectionType DIR_LEFT = DirectionType::LEFT; |
302 |
const DirectionType DIR_RIGHT = DirectionType::RIGHT; |
303 |
const SelectionMode SELECTION_NONE = SelectionMode::NONE; |
304 |
const SelectionMode SELECTION_SINGLE = SelectionMode::SINGLE; |
305 |
const SelectionMode SELECTION_BROWSE = SelectionMode::BROWSE; |
306 |
const SelectionMode SELECTION_MULTIPLE = SelectionMode::MULTIPLE; |
307 |
const BuiltinIconSize ICON_SIZE_INVALID = BuiltinIconSize::INVALID; |
308 |
const BuiltinIconSize ICON_SIZE_MENU = BuiltinIconSize::MENU; |
309 |
const BuiltinIconSize ICON_SIZE_SMALL_TOOLBAR = BuiltinIconSize::SMALL_TOOLBAR; |
310 |
const BuiltinIconSize ICON_SIZE_LARGE_TOOLBAR = BuiltinIconSize::LARGE_TOOLBAR; |
311 |
const BuiltinIconSize ICON_SIZE_BUTTON = BuiltinIconSize::BUTTON; |
312 |
const BuiltinIconSize ICON_SIZE_DND = BuiltinIconSize::DND; |
313 |
const BuiltinIconSize ICON_SIZE_DIALOG = BuiltinIconSize::DIALOG; |
314 |
const IconLookupFlags ICON_LOOKUP_NO_SVG = IconLookupFlags::NO_SVG; |
315 |
const IconLookupFlags ICON_LOOKUP_FORCE_SVG = IconLookupFlags::FORCE_SVG; |
316 |
const IconLookupFlags ICON_LOOKUP_USE_BUILTIN = IconLookupFlags::USE_BUILTIN; |
317 |
const IconLookupFlags ICON_LOOKUP_GENERIC_FALLBACK = IconLookupFlags::GENERIC_FALLBACK; |
318 |
const IconLookupFlags ICON_LOOKUP_FORCE_SIZE = IconLookupFlags::FORCE_SIZE; |
319 |
const IconLookupFlags ICON_LOOKUP_FORCE_REGULAR = IconLookupFlags::FORCE_REGULAR; |
320 |
const IconLookupFlags ICON_LOOKUP_FORCE_SYMBOLIC = IconLookupFlags::FORCE_SYMBOLIC; |
321 |
const IconLookupFlags ICON_LOOKUP_DIR_LTR = IconLookupFlags::DIR_LTR; |
322 |
const IconLookupFlags ICON_LOOKUP_DIR_RTL = IconLookupFlags::DIR_RTL; |
323 |
const TextWindowType TEXT_WINDOW_PRIVATE = TextWindowType::PRIVATE; |
324 |
const TextWindowType TEXT_WINDOW_WIDGET = TextWindowType::WIDGET; |
325 |
const TextWindowType TEXT_WINDOW_TEXT = TextWindowType::TEXT; |
326 |
const TextWindowType TEXT_WINDOW_LEFT = TextWindowType::LEFT; |
327 |
const TextWindowType TEXT_WINDOW_RIGHT = TextWindowType::RIGHT; |
328 |
const TextWindowType TEXT_WINDOW_TOP = TextWindowType::TOP; |
329 |
const TextWindowType TEXT_WINDOW_BOTTOM = TextWindowType::BOTTOM; |
330 |
const FileChooser::Action FILE_CHOOSER_ACTION_OPEN = FileChooser::Action::OPEN; |
331 |
const FileChooser::Action FILE_CHOOSER_ACTION_SAVE = FileChooser::Action::SAVE; |
332 |
const FileChooser::Action FILE_CHOOSER_ACTION_SELECT_FOLDER = FileChooser::Action::SELECT_FOLDER; |
333 |
const FileChooser::Action FILE_CHOOSER_ACTION_CREATE_FOLDER = FileChooser::Action::CREATE_FOLDER; |
334 |
} |
335 |
#endif // HAS_GTKMM_CPP11_ENUMS |
336 |
|
337 |
// 2.10 |
338 |
|
339 |
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 10) || GTKMM_MAJOR_VERSION < 2 |
340 |
#define create_cairo_context() \ |
341 |
gobj() ? Cairo::RefPtr<Cairo::Context>( \ |
342 |
new Cairo::Context(gdk_cairo_create(get_window()->gobj()))) : \ |
343 |
Cairo::RefPtr<Cairo::Context>() |
344 |
#endif |
345 |
|
346 |
|
347 |
// 2.12 |
348 |
|
349 |
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 12) || GTKMM_MAJOR_VERSION < 2 |
350 |
#include <gtkmm/cellrenderertext.h> |
351 |
namespace Gtk { |
352 |
// this is not a real spin cell renderer, instead it's just text, |
353 |
// extended with a property for storing an adjustment |
354 |
class CellRendererSpin : public CellRendererText { |
355 |
private: |
356 |
Adjustment* adj; |
357 |
struct Proxy { |
358 |
Adjustment*& adj; |
359 |
Proxy(Adjustment*& adj) : adj(adj) { } |
360 |
const Adjustment* get_value() const { return adj; } |
361 |
void operator=(Adjustment* x) { adj = x; } |
362 |
}; |
363 |
public: |
364 |
Proxy property_adjustment() const { |
365 |
return const_cast<Adjustment*&>(adj); |
366 |
} |
367 |
}; |
368 |
} |
369 |
#endif |
370 |
|
371 |
|
372 |
// 2.18 |
373 |
|
374 |
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 18) || GTKMM_MAJOR_VERSION < 2 |
375 |
#define set_can_focus() set_flags(Gtk::CAN_FOCUS) |
376 |
#define set_can_default() set_flags(Gtk::CAN_DEFAULT) |
377 |
#endif |
378 |
|
379 |
|
380 |
// 2.21.9 |
381 |
|
382 |
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION == 21 && GTKMM_MICRO_VERSION < 9) || \ |
383 |
(GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 21) || GTKMM_MAJOR_VERSION < 2 |
384 |
#define ALIGN_START ALIGN_LEFT |
385 |
#define ALIGN_END ALIGN_RIGHT |
386 |
#endif |
387 |
|
388 |
|
389 |
// 2.24 |
390 |
|
391 |
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 24) || GTKMM_MAJOR_VERSION < 2 |
392 |
#define get_first_cell() get_first_cell_renderer() |
393 |
#endif |
394 |
|
395 |
|
396 |
// 3.0 |
397 |
|
398 |
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
399 |
#include <cairomm/context.h> |
400 |
#include <gdkmm/color.h> |
401 |
|
402 |
namespace Gdk { |
403 |
typedef Color RGBA; |
404 |
|
405 |
namespace Cairo { |
406 |
void set_source_rgba(const ::Cairo::RefPtr< ::Cairo::Context >& context, |
407 |
const Gdk::RGBA& color); |
408 |
} |
409 |
} |
410 |
#endif |
411 |
|
412 |
|
413 |
// glibmm 2.31.2 |
414 |
|
415 |
#if (GLIBMM_MAJOR_VERSION == 2 && GLIBMM_MINOR_VERSION == 31 && GLIBMM_MICRO_VERSION < 2) || \ |
416 |
(GLIBMM_MAJOR_VERSION == 2 && GLIBMM_MINOR_VERSION < 31) || GLIBMM_MAJOR_VERSION < 2 |
417 |
|
418 |
namespace Glib { |
419 |
namespace Threads { |
420 |
using Glib::Thread; |
421 |
using Glib::Mutex; |
422 |
using Glib::Cond; |
423 |
} |
424 |
} |
425 |
|
426 |
#define OLD_THREADS |
427 |
|
428 |
#endif // glibmm 2.31.2 |
429 |
|
430 |
|
431 |
// glibmm 2.47.3 |
432 |
|
433 |
#if (GLIBMM_MAJOR_VERSION == 2 && GLIBMM_MINOR_VERSION == 47 && GLIBMM_MICRO_VERSION < 3) || \ |
434 |
(GLIBMM_MAJOR_VERSION == 2 && GLIBMM_MINOR_VERSION < 47) || GLIBMM_MAJOR_VERSION < 2 |
435 |
|
436 |
#define GLIB_THREADS |
437 |
|
438 |
#endif |
439 |
|
440 |
#include <gtkmm/label.h> |
441 |
|
442 |
/** @brief Auto wrapped (multi-line) text, auto shrank to min. dimensions. |
443 |
* |
444 |
* This widgets is intended for large text blocks which are expected to require |
445 |
* the text to be automatically wrapped (i.e. auto inserted line breaks) such |
446 |
* that it would not exceed the label's maximum allowed width according to its |
447 |
* parent container. |
448 |
* |
449 |
* This class overrides get_preferred_height_for_width_vfunc() to fix the |
450 |
* default behaviour of Gtk::Label, which by default calculates a height under |
451 |
* the assumption that EVERY word of the text had a line break, which would |
452 |
* cause the label to claim much more vertical space than actually required for |
453 |
* the text. |
454 |
* |
455 |
* NOTE: This class only works with Gtk 3 and higher. For Gtk 2 and younger it |
456 |
* does nothing different than a normal Gtk::Label right now. See TODO comment |
457 |
* on get_preferred_height_for_width_vfunc() below for details. |
458 |
*/ |
459 |
class MultiLineLabel : public Gtk::Label { |
460 |
public: |
461 |
MultiLineLabel() : Gtk::Label() { |
462 |
#if GTKMM_MAJOR_VERSION >= 3 |
463 |
set_line_wrap(); |
464 |
#endif |
465 |
} |
466 |
|
467 |
void set_markup(const Glib::ustring& s) { |
468 |
Gtk::Label::set_markup(s); |
469 |
m_markup = s; |
470 |
} |
471 |
|
472 |
//TODO: get_preferred_height_for_width_vfunc() did not exist in Gtk 2, nor |
473 |
// did get_margin_top() and get_margin_bottom() and consequently I'm |
474 |
// unsure whether the issue MultiLineLabel addresses could actually be |
475 |
// fixed for Gtk 2 as well. For now this code is simply commented out |
476 |
// which means MultiLineLabel behaves as Gtk::Label on Gtk 2 & older. |
477 |
#if GTKMM_MAJOR_VERSION >= 3 |
478 |
void get_preferred_height_for_width_vfunc(int width, int& minimum_height, int& natural_height) const { |
479 |
Gtk::Label::get_preferred_height_for_width_vfunc(width, minimum_height, natural_height); |
480 |
//printf("super suggests minimum_height=%d natural_height=%d\n", minimum_height, natural_height); |
481 |
|
482 |
Pango::Layout* origLayout = const_cast<Pango::Layout*>(get_layout().operator->()); |
483 |
Glib::RefPtr<Pango::Layout> layout = origLayout->copy(); |
484 |
Glib::ustring s = (!m_markup.empty()) ? m_markup : get_text(); |
485 |
layout->set_markup(s); |
486 |
int w, h; |
487 |
layout->get_pixel_size(w, h); |
488 |
h += get_margin_top() + get_margin_bottom(); |
489 |
//printf("calculated w=%d h=%d\n", w, h); |
490 |
|
491 |
minimum_height = h; |
492 |
if (natural_height < h) |
493 |
natural_height = h; |
494 |
} |
495 |
#endif // GTKMM_MAJOR_VERSION >= 3 |
496 |
|
497 |
private: |
498 |
Glib::ustring m_markup; |
499 |
}; |
500 |
|
501 |
#endif // GIGEDIT_COMPAT_H |