Debian Codegraph @

gtk/src/widget.hg

raw
1 /* Copyright (C) 2002, 2003 The gtkmm Development Team
2 *
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; either
6 * version 2.1 of the License, or (at your option) any later version.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, see <https://www.gnu.org/licenses/>.
15 */
16
17 _CONFIGINCLUDE(gtkmmconfig.h)
18
19 #include <vector>
20
21 #include <pangomm/context.h>
22 #include <pangomm/layout.h>
23
24 #ifdef GTKMM_ATKMM_ENABLED
25 #include <atkmm/object.h>
26 #include <atkmm/implementor.h>
27 #endif //GTKMM_ATKMM_ENABLED
28
29 #include <gtkmm/object.h>
30 #include <gtkmm/buildable.h>
31 #include <gdkmm/event.h>
32 #include <gdkmm/types.h>
33 #include <gdkmm/window.h>
34 #include <gdkmm/dragcontext.h>
35 #include <gdkmm/pixbuf.h>
36 #include <gdkmm/screen.h>
37 #include <gtkmm/enums.h>
38 #include <gdkmm/display.h>
39 #include <gtkmm/targetlist.h>
40 #include <gtkmm/clipboard.h>
41 #include <gtkmm/requisition.h>
42 #include <gtkmm/stylecontext.h>
43 #include <gtkmm/widgetpath.h>
44 #include <giomm/actiongroup.h>
45
46 _DEFS(gtkmm,gtk)
47 _PINCLUDE(gtkmm/private/object_p.h)
48
49
50 #ifndef DOXYGEN_SHOULD_SKIP_THIS
51 extern "C"
52 {
53 typedef struct _GtkTargetEntry GtkTargetEntry;
54 }
55 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
56
57 namespace Gdk
58 {
59 class GTKMM_API FrameClock;
60 }
61
62 namespace Gtk
63 {
64
65 _CC_INCLUDE(gtk/gtk.h)
66 _WRAP_ENUM(DestDefaults, GtkDestDefaults, decl_prefix GTKMM_API)
67 _WRAP_ENUM(WidgetHelpType, GtkWidgetHelpType, decl_prefix GTKMM_API)
68 _WRAP_ENUM(DragResult, GtkDragResult, decl_prefix GTKMM_API)
69
70 class GTKMM_API Action;
71 class GTKMM_API Style;
72 class GTKMM_API AccelGroup;
73 class GTKMM_API Adjustment;
74 class GTKMM_API Window;
75 class GTKMM_API Container;
76 class GTKMM_API Settings;
77 class GTKMM_API Tooltip;
78 class GTKMM_API StockID; //deprecated.
79
80 // Gtk::Allocation is a typedef of Gdk::Rectangle because GtkAllocation is
81 // a typedef of GdkRectangle.
82 typedef Gdk::Rectangle Allocation;
83
84 /** @defgroup Widgets Widgets
85 */
86
87 //TODO: Deal with the GtkObject->GObject change:
88 /** Abstract %Widget (Base class for all widgets)
89 *
90 * As the base class of all widgets this contains all of the properties
91 * and methods common to all widgets. It is an abstract class that
92 * can not be instantiated.
93 *
94 * Important part of widgets are the *_event signals and virtual methods
95 * that every widget have. Those are events coming directly from gdk and
96 * thus also from XLib. By overriding those virtual methods you can
97 * trap everything a widget can ever do.
98 * In order to capture events from a widget, the event mask must
99 * first be set with set_events() or add_events().
100 *
101 * Only widgets with a Gdk::Window on the server side are allowed to
102 * capture events. Widgets in the Gtk::Misc group for example lack
103 * a Gdk::Window.
104 *
105 * Key values are the codes which are sent whenever a key is pressed or released.
106 * The complete list of key values can be found in the
107 * <a href="https://gitlab.gnome.org/GNOME/gtk/tree/gtk-3-24/gdk/gdkkeysyms.h">gdk/gdkkeysyms.h</a>
108 * header file. They are prefixed with <tt>GDK_KEY_</tt>.
109 */
110 class GTKMM_API Widget
111 : public Object,
112 public Buildable
113 #ifdef GTKMM_ATKMM_ENABLED
114 ,public Atk::Implementor
115 #endif //GTKMM_ATKMM_ENABLED
116 {
117 _CLASS_GTKOBJECT(Widget,GtkWidget,GTK_WIDGET,Object,GObject, , , GTKMM_API)
118 _IMPLEMENTS_INTERFACE(Buildable)
119 _IMPLEMENTS_INTERFACE(Atk::Implementor, ifdef GTKMM_ATKMM_ENABLED)
120 _IGNORE(gtk_widget_set_visual, gtk_widget_destroy, gtk_widget_destroyed, gtk_widget_hide_on_delete,
121 gtk_widget_style_get_valist, gtk_widget_list_accel_closures, gtk_widget_style_get)
122 public:
123 friend class GTKMM_API Main;
124 _CUSTOM_DTOR
125 _DOCUMENT_DTOR(Destroys the widget. The widget will be automatically removed from the parent container.)
126
127 _WRAP_METHOD(void show(), gtk_widget_show)
128 _WRAP_METHOD(void show_now(), gtk_widget_show_now)
129 _WRAP_METHOD(void hide(), gtk_widget_hide)
130
131 _WRAP_METHOD(void show_all(), gtk_widget_show_all)
132
133 /* QUEUE DRAWS */
134
135 _WRAP_METHOD(void queue_draw(), gtk_widget_queue_draw)
136 _WRAP_METHOD(void queue_draw_area(int x, int y, int width, int height), gtk_widget_queue_draw_area)
137 _WRAP_METHOD(void queue_draw_region(const ::Cairo::RefPtr<const ::Cairo::Region>& region), gtk_widget_queue_draw_region)
138 _WRAP_METHOD(void queue_resize(), gtk_widget_queue_resize)
139 _WRAP_METHOD(void queue_allocate(), gtk_widget_queue_allocate)
140
141 _WRAP_METHOD(void size_allocate(const Allocation& allocation), gtk_widget_size_allocate)
142
143 _WRAP_METHOD(void size_allocate(const Allocation& allocation, int baseline), gtk_widget_size_allocate_with_baseline)
144
145 _IGNORE(gtk_widget_size_request) //deprecated
146
147 _WRAP_METHOD(SizeRequestMode get_request_mode() const, gtk_widget_get_request_mode)
148 _WRAP_METHOD(void get_preferred_width(int& minimum_width, int& natural_width) const, gtk_widget_get_preferred_width)
149 _WRAP_METHOD(void get_preferred_height_for_width(int width, int& minimum_height, int& natural_height) const, gtk_widget_get_preferred_height_for_width)
150 _WRAP_METHOD(void get_preferred_height_for_width(int width, int& minimum_height, int& natural_height, int& minimum_baseline, int& natural_baseline) const, gtk_widget_get_preferred_height_and_baseline_for_width)
151 _WRAP_METHOD(void get_preferred_height(int& minimum_height, int& natural_height) const, gtk_widget_get_preferred_height)
152 _WRAP_METHOD(void get_preferred_width_for_height(int height, int& minimum_width, int& natural_width) const, gtk_widget_get_preferred_width_for_height)
153 _WRAP_METHOD(void get_preferred_size(Requisition& minimum_size, Requisition& natural_size) const, gtk_widget_get_preferred_size)
154
155
156 _WRAP_METHOD(void add_accelerator(const Glib::ustring& accel_signal, const Glib::RefPtr<AccelGroup>& accel_group,
157 guint accel_key, Gdk::ModifierType accel_mods, AccelFlags accel_flags), gtk_widget_add_accelerator)
158
159 _WRAP_METHOD(bool remove_accelerator(const Glib::RefPtr<AccelGroup>& accel_group,
160 guint accel_key, Gdk::ModifierType accel_mods), gtk_widget_remove_accelerator)
161 _WRAP_METHOD(void set_accel_path(const Glib::ustring& accel_path,
162 const Glib::RefPtr<AccelGroup>& accel_group),
163 gtk_widget_set_accel_path)
164
165 //GList* gtk_widget_list_accel_closures();
166
167 _WRAP_METHOD(bool mnemonic_activate(bool group_cycling), gtk_widget_mnemonic_activate)
168
169 _IGNORE(gtk_widget_can_activate_accel)
170 //Probably not useful. Too C-specific: _WRAP_METHOD(bool can_activate_accel(guint signal_id) const, gtk_widget_can_activate_accel)
171
172 //TODO: Use C++ type
173 _WRAP_METHOD(bool event(GdkEvent* gdk_event), gtk_widget_event)
174 _WRAP_METHOD(int send_expose(GdkEvent* gdk_event), gtk_widget_send_expose,
175 deprecated "%Application and widget code should not handle expose events directly; invalidation should use the Gtk::Widget API, and drawing should only happen inside signal_draw() implementations.")
176 _WRAP_METHOD(bool send_focus_change(GdkEvent* gdk_event), gtk_widget_send_focus_change)
177 _WRAP_METHOD(bool activate(), gtk_widget_activate)
178
179 //TODO: When we can break ABI/API, change to void reparent(Container& new_parent).
180 // gtk_widget_reparent() is deprecated, but we want to keep Gtk::Widget::reparent().
181 /** Moves a widget from one Gtk::Container to another, handling reference
182 * count issues to avoid destroying the widget.
183 *
184 * @param new_parent A Gtk::Container to move the widget into.
185 */
186 void reparent(Widget& new_parent);
187 _IGNORE(gtk_widget_reparent)
188
189 bool intersect(const Gdk::Rectangle& area) const;
190 _WRAP_METHOD(bool intersect(const Gdk::Rectangle& area, Gdk::Rectangle& intersection) const, gtk_widget_intersect)
191
192 #m4 _CONVERSION(`cairo_region_t*',`::Cairo::RefPtr< ::Cairo::Region>',`::Cairo::RefPtr< ::Cairo::Region>(new ::Cairo::Region($3, true /* do not take ref */))')
193
194 _WRAP_METHOD(::Cairo::RefPtr< ::Cairo::Region> region_intersect(const ::Cairo::RefPtr< ::Cairo::Region>& region) const, gtk_widget_region_intersect,
195 deprecated "Use get_allocation() and Cairo::Region::intersect(const Cairo::RectangleInt&) to get the same behavior.")
196
197 _WRAP_METHOD(void freeze_child_notify(), gtk_widget_freeze_child_notify)
198 _WRAP_METHOD(void child_notify(const Glib::ustring& child_property), gtk_widget_child_notify)
199 _WRAP_METHOD(void thaw_child_notify(), gtk_widget_thaw_child_notify)
200
201 _WRAP_METHOD(void set_can_focus(bool can_focus = true), gtk_widget_set_can_focus)
202 _WRAP_METHOD(bool get_can_focus() const, gtk_widget_get_can_focus)
203 _WRAP_METHOD(bool has_focus() const, gtk_widget_has_focus)
204
205 _WRAP_METHOD(bool is_focus() const, gtk_widget_is_focus)
206 _WRAP_METHOD(bool has_visible_focus() const, gtk_widget_has_visible_focus)
207 _WRAP_METHOD(void grab_focus(), gtk_widget_grab_focus)
208 _WRAP_METHOD(void set_focus_on_click(bool focus_on_click = true), gtk_widget_set_focus_on_click)
209 _WRAP_METHOD(bool get_focus_on_click() const, gtk_widget_get_focus_on_click)
210 _WRAP_METHOD(void set_can_default(bool can_default = true), gtk_widget_set_can_default)
211 _WRAP_METHOD(bool get_can_default() const, gtk_widget_get_can_default)
212 _WRAP_METHOD(bool has_default() const, gtk_widget_has_default)
213 _WRAP_METHOD(void grab_default(), gtk_widget_grab_default)
214 _WRAP_METHOD(void set_receives_default(bool receives_default = true), gtk_widget_set_receives_default)
215 _WRAP_METHOD(bool get_receives_default() const, gtk_widget_get_receives_default)
216 _WRAP_METHOD(bool has_grab() const, gtk_widget_has_grab)
217 _WRAP_METHOD(bool device_is_shadowed(const Glib::RefPtr<const Gdk::Device>& device), gtk_widget_device_is_shadowed)
218
219
220 /** Block events to everything else than this widget and its children. This
221 * way you can get modal behaviour (usually not recommended). One practical
222 * example could be when implementing a key-binding widget that needs
223 * exclusive access to the key combination that the user presses next.
224 *
225 * Calls to add_modal_grab should be paired with calls to remove_modal_grab.
226 */
227 void add_modal_grab();
228
229 /** Remove the modal grab of the widget in case it was previously grabbed.
230 */
231 void remove_modal_grab();
232
233 /** Retrieve the widget which is currently grabbing all events.
234 */
235 static Widget* get_current_modal_grab();
236
237 _WRAP_METHOD(void set_name(const Glib::ustring& name), gtk_widget_set_name)
238 void unset_name();
239 _WRAP_METHOD(Glib::ustring get_name() const, gtk_widget_get_name)
240
241 _WRAP_METHOD(void set_state(StateType state), gtk_widget_set_state, deprecated "Use set_state_flags() instead.")
242 _WRAP_METHOD(StateType get_state() const, gtk_widget_get_state, deprecated "Use get_state_flags() instead.")
243
244 _WRAP_METHOD(void set_state_flags(StateFlags flags, bool clear = true), gtk_widget_set_state_flags)
245 _WRAP_METHOD(void unset_state_flags(StateFlags flags), gtk_widget_unset_state_flags)
246 _WRAP_METHOD(StateFlags get_state_flags() const, gtk_widget_get_state_flags)
247
248 _WRAP_METHOD(void set_sensitive(bool sensitive = true), gtk_widget_set_sensitive)
249 _WRAP_METHOD(bool get_sensitive() const, gtk_widget_get_sensitive)
250 _WRAP_METHOD(bool is_sensitive() const, gtk_widget_is_sensitive)
251 _WRAP_METHOD(void set_visible(bool visible = true), gtk_widget_set_visible)
252 _WRAP_METHOD(bool get_visible() const, gtk_widget_get_visible)
253 _WRAP_METHOD(bool is_visible() const, gtk_widget_is_visible)
254 _WRAP_METHOD(bool get_has_window() const, gtk_widget_get_has_window)
255 _WRAP_METHOD(bool get_is_toplevel() const, gtk_widget_is_toplevel)
256 _WRAP_METHOD(bool get_is_drawable() const, gtk_widget_is_drawable)
257 _WRAP_METHOD(bool get_realized() const, gtk_widget_get_realized)
258 _WRAP_METHOD(bool get_mapped() const, gtk_widget_get_mapped)
259 _WRAP_METHOD(void set_app_paintable(bool app_paintable = true), gtk_widget_set_app_paintable)
260 _WRAP_METHOD(bool get_app_paintable() const, gtk_widget_get_app_paintable)
261 _WRAP_METHOD(void set_double_buffered(bool double_buffered = true), gtk_widget_set_double_buffered,
262 deprecated "This does not work under non-X11 backends, and it should not be used in newly written code.")
263 _WRAP_METHOD(bool get_double_buffered() const, gtk_widget_get_double_buffered,
264 deprecated "This should not be used in newly written code.")
265
266 _WRAP_METHOD(void set_redraw_on_allocate(bool redraw_on_allocate = true),
267 gtk_widget_set_redraw_on_allocate)
268
269 _WRAP_METHOD(void set_child_visible(bool visible = true), gtk_widget_set_child_visible)
270 _WRAP_METHOD(bool get_child_visible() const, gtk_widget_get_child_visible)
271
272 _WRAP_METHOD(Glib::RefPtr<Gdk::Window> get_window(), gtk_widget_get_window, refreturn)
273 _WRAP_METHOD(Glib::RefPtr<const Gdk::Window> get_window() const, gtk_widget_get_window, refreturn, constversion)
274
275 _WRAP_METHOD(void register_window(const Glib::RefPtr<Gdk::Window>& window), gtk_widget_register_window)
276 _WRAP_METHOD(void unregister_window(const Glib::RefPtr<Gdk::Window>& window), gtk_widget_unregister_window)
277
278 _WRAP_METHOD(int get_allocated_width() const, gtk_widget_get_allocated_width)
279 _WRAP_METHOD(int get_allocated_height() const, gtk_widget_get_allocated_height)
280 _WRAP_METHOD(int get_allocated_baseline() const, gtk_widget_get_allocated_baseline)
281 _WRAP_METHOD(void get_allocated_size(Allocation& allocation, int& baseline) const, gtk_widget_get_allocated_size)
282
283 /** Retrieves the widget's location.
284 * Note, when implementing a Container: a widget's allocation will be its "adjusted" allocation,
285 * that is, the widget's parent container typically calls size_allocate() with an allocation,
286 * and that allocation is then adjusted (to handle margin and alignment for example) before
287 * assignment to the widget. get_allocation() returns the adjusted allocation that was actually
288 * assigned to the widget. The adjusted allocation is guaranteed to be completely contained
289 * within the size_allocate() allocation, however. So a Container is guaranteed that its
290 * children stay inside the assigned bounds, but not that they have exactly the bounds the
291 * container assigned. There is no way to get the original allocation assigned by
292 * size_allocate(), since it isn't stored. If a container implementation needs that information
293 * it will have to track it itself.
294 *
295 * @return The widget's allocated area.
296 */
297 Allocation get_allocation() const;
298 _IGNORE(gtk_widget_get_allocation)
299
300 #m4 _CONVERSION(`const Allocation&',`const GtkAllocation*',`($3).gobj()')
301 #m4 _CONVERSION(`const Allocation&',`const GdkRectangle*',`($3).gobj()')
302 _WRAP_METHOD(void set_allocation(const Allocation& allocation), gtk_widget_set_allocation)
303
304 _WRAP_METHOD(void set_clip(const Allocation& clip), gtk_widget_set_clip)
305
306 /** Retrieves the widget’s clip area.
307 *
308 * The clip area is the area in which all of the widget's drawing will
309 * happen. Other toolkits call it the bounding box.
310 *
311 * Historically, in GTK+ the clip area has been equal to the allocation
312 * retrieved via get_allocation().
313 *
314 * @newin{3,14}
315 */
316 Allocation get_clip() const;
317 _IGNORE(gtk_widget_get_clip)
318
319 _WRAP_METHOD(Container* get_parent(), gtk_widget_get_parent)
320 _WRAP_METHOD(const Container* get_parent() const, gtk_widget_get_parent, constversion)
321
322 _WRAP_METHOD(Glib::RefPtr<Gdk::Window> get_parent_window(), gtk_widget_get_parent_window, refreturn)
323 _WRAP_METHOD(Glib::RefPtr<const Gdk::Window> get_parent_window() const, gtk_widget_get_parent_window, refreturn, constversion)
324 _WRAP_METHOD(void set_parent_window(const Glib::RefPtr<const Gdk::Window>& parent_window), gtk_widget_set_parent_window)
325
326 _WRAP_METHOD(bool child_focus(DirectionType direction), gtk_widget_child_focus)
327
328 _WRAP_METHOD(bool keynav_failed(DirectionType direction), gtk_widget_keynav_failed)
329 _WRAP_METHOD(void error_bell(), gtk_widget_error_bell)
330
331 _WRAP_METHOD(void set_size_request(int width = -1, int height = -1), gtk_widget_set_size_request)
332 _WRAP_METHOD(void get_size_request(int& width, int& height) const, gtk_widget_get_size_request)
333
334 _WRAP_METHOD(void set_events(Gdk::EventMask events), gtk_widget_set_events)
335 _WRAP_METHOD(void add_events(Gdk::EventMask events), gtk_widget_add_events)
336
337 _WRAP_METHOD(void set_device_events(const Glib::RefPtr<const Gdk::Device>& device, Gdk::EventMask events), gtk_widget_set_device_events)
338 _WRAP_METHOD(void add_device_events(const Glib::RefPtr<const Gdk::Device>& device, Gdk::EventMask events), gtk_widget_add_device_events)
339
340 _WRAP_METHOD(void set_opacity(double opacity), gtk_widget_set_opacity)
341 _WRAP_METHOD(double get_opacity() const, gtk_widget_get_opacity)
342
343 _WRAP_METHOD(void set_device_enabled(const Glib::RefPtr<Gdk::Device>& device, bool enabled = true), gtk_widget_set_device_enabled)
344 _WRAP_METHOD(bool get_device_enabled(const Glib::RefPtr<const Gdk::Device>& device) const, gtk_widget_get_device_enabled)
345
346 _WRAP_METHOD(Container* get_toplevel(), gtk_widget_get_toplevel)
347 _WRAP_METHOD(const Container* get_toplevel() const, gtk_widget_get_toplevel, constversion)
348
349 _WRAP_METHOD(Widget* get_ancestor(GType widget_type), gtk_widget_get_ancestor)
350 _WRAP_METHOD(const Widget* get_ancestor(GType widget_type) const, gtk_widget_get_ancestor, constversion)
351
352
353 _WRAP_METHOD(Glib::RefPtr<Gdk::Visual> get_visual(), gtk_widget_get_visual, refreturn)
354
355 _WRAP_METHOD(Glib::RefPtr<Gdk::Screen> get_screen(), gtk_widget_get_screen, refreturn)
356 _WRAP_METHOD(Glib::RefPtr<const Gdk::Screen> get_screen() const, gtk_widget_get_screen, refreturn, constversion)
357
358 _WRAP_METHOD(bool has_screen() const, gtk_widget_has_screen)
359
360 _WRAP_METHOD(int get_scale_factor() const, gtk_widget_get_scale_factor)
361
362 _WRAP_METHOD(Glib::RefPtr<Gdk::Display> get_display(), gtk_widget_get_display, refreturn)
363 _WRAP_METHOD(Glib::RefPtr<const Gdk::Display> get_display() const, gtk_widget_get_display, refreturn, constversion)
364
365 _WRAP_METHOD(Glib::RefPtr<Gdk::Window> get_root_window(), gtk_widget_get_root_window, refreturn, deprecated "Use Gdk::Screen::get_root_window() instead.")
366 _WRAP_METHOD(Glib::RefPtr<const Gdk::Window> get_root_window() const, gtk_widget_get_root_window, refreturn, constversion, deprecated "Use Gdk::Screen::get_root_window() instead.")
367
368 _WRAP_METHOD(Glib::RefPtr<Settings> get_settings(), gtk_widget_get_settings, refreturn)
369
370 _WRAP_METHOD(Glib::RefPtr<Clipboard> get_clipboard(const Glib::ustring& selection), gtk_widget_get_clipboard, refreturn)
371 _WRAP_METHOD(Glib::RefPtr<const Clipboard> get_clipboard(const Glib::ustring& selection) const, gtk_widget_get_clipboard, refreturn, constversion)
372
373 _WRAP_METHOD(bool get_hexpand() const, gtk_widget_get_hexpand)
374 _WRAP_METHOD(void set_hexpand(bool expand = true), gtk_widget_set_hexpand)
375 _WRAP_METHOD(bool get_hexpand_set() const, gtk_widget_get_hexpand_set)
376 _WRAP_METHOD(void set_hexpand_set(bool set = true), gtk_widget_set_hexpand_set)
377 _WRAP_METHOD(bool get_vexpand() const, gtk_widget_get_vexpand)
378 _WRAP_METHOD(void set_vexpand(bool expand = true), gtk_widget_set_vexpand)
379 _WRAP_METHOD(bool get_vexpand_set() const, gtk_widget_get_vexpand_set)
380 _WRAP_METHOD(void set_vexpand_set(bool set = true), gtk_widget_set_vexpand_set)
381 _WRAP_METHOD(void queue_compute_expand(), gtk_widget_queue_compute_expand)
382 _WRAP_METHOD(bool compute_expand(Orientation orientation), gtk_widget_compute_expand)
383
384 _WRAP_METHOD(bool get_support_multidevice() const, gtk_widget_get_support_multidevice)
385 _WRAP_METHOD(void set_support_multidevice(bool support_multidevice = true), gtk_widget_set_support_multidevice)
386
387 _WRAP_METHOD(Glib::RefPtr<Atk::Object> get_accessible(), gtk_widget_get_accessible, refreturn, ifdef GTKMM_ATKMM_ENABLED)
388 _WRAP_METHOD(Glib::RefPtr<const Atk::Object> get_accessible() const, gtk_widget_get_accessible, refreturn, constversion, ifdef GTKMM_ATKMM_ENABLED)
389
390 _WRAP_METHOD(Align get_halign() const, gtk_widget_get_halign)
391 _WRAP_METHOD(void set_halign(Align align), gtk_widget_set_halign)
392 _WRAP_METHOD(Align get_valign() const, gtk_widget_get_valign)
393 _WRAP_METHOD(Align get_valign_with_baseline() const, gtk_widget_get_valign_with_baseline)
394 _WRAP_METHOD(void set_valign(Align align), gtk_widget_set_valign)
395 _WRAP_METHOD(int get_margin_left() const, gtk_widget_get_margin_left, deprecated "Use get_margin_start() instead.")
396 _WRAP_METHOD(void set_margin_left(int margin), gtk_widget_set_margin_left, deprecated "Use set_margin_start() instead.")
397 _WRAP_METHOD(int get_margin_right() const, gtk_widget_get_margin_right, deprecated "Use get_margin_end() instead.")
398 _WRAP_METHOD(void set_margin_right(int margin), gtk_widget_set_margin_right, deprecated "Use set_margin_end() instead.")
399 _WRAP_METHOD(int get_margin_start() const, gtk_widget_get_margin_start)
400 _WRAP_METHOD(void set_margin_start(int margin), gtk_widget_set_margin_start)
401 _WRAP_METHOD(int get_margin_end() const, gtk_widget_get_margin_end)
402 _WRAP_METHOD(void set_margin_end(int margin), gtk_widget_set_margin_end)
403 _WRAP_METHOD(int get_margin_top() const, gtk_widget_get_margin_top)
404 _WRAP_METHOD(void set_margin_top(int margin), gtk_widget_set_margin_top)
405 _WRAP_METHOD(int get_margin_bottom() const, gtk_widget_get_margin_bottom)
406 _WRAP_METHOD(void set_margin_bottom(int margin), gtk_widget_set_margin_bottom)
407
408 _WRAP_METHOD(Gdk::EventMask get_events() const, gtk_widget_get_events)
409 _WRAP_METHOD(Gdk::EventMask get_device_events(const Glib::RefPtr<const Gdk::Device>& device) const, gtk_widget_get_device_events)
410 _WRAP_METHOD(void get_pointer(int &x, int &y) const, gtk_widget_get_pointer, deprecated "Use Gdk::Window::get_device_position instead.")
411 _WRAP_METHOD(bool is_ancestor(Widget &ancestor) const, gtk_widget_is_ancestor)
412
413 _WRAP_METHOD(bool translate_coordinates(Widget& dest_widget,
414 int src_x, int src_y,
415 int& dest_x, int& dest_y), gtk_widget_translate_coordinates)
416
417 _IGNORE(gtk_widget_set_style, gtk_widget_get_style, gtk_widget_has_rc_style, gtk_widget_ensure_style,
418 gtk_widget_modify_style, gtk_widget_get_modifier_style,
419 gtk_widget_reset_rc_styles) //deprecated broadly in favour of StyleContext.;
420
421 _WRAP_METHOD(void override_color(const Gdk::RGBA& color{.}, StateFlags state{.} = STATE_FLAG_NORMAL), gtk_widget_override_color,
422 deprecated "Use a custom style provider and style classes instead.")
423
424 _DEPRECATE_IFDEF_START
425 /** Undoes the effect of previous calls to override_color().
426 *
427 * @newin{3,0}
428 * @deprecated Use a custom style provider and style classes instead.
429 *
430 * @param state The state for which to use the color of the user's theme.
431 */
432 void unset_color(StateFlags state = STATE_FLAG_NORMAL);
433 _DEPRECATE_IFDEF_END
434
435 _WRAP_METHOD(void override_background_color(const Gdk::RGBA& color{.}, StateFlags state{.} = STATE_FLAG_NORMAL), gtk_widget_override_background_color,
436 deprecated "Use a custom style provider and style classes instead.")
437
438 _DEPRECATE_IFDEF_START
439 /** Undoes the effect of previous calls to override_background_color().
440 *
441 * @newin{3,0}
442 * @deprecated Use a custom style provider and style classes instead.
443 *
444 * @param state The state for which to use the background color of the user's theme.
445 */
446 void unset_background_color(StateFlags state = STATE_FLAG_NORMAL);
447 _DEPRECATE_IFDEF_END
448
449 _WRAP_METHOD(void override_font(const Pango::FontDescription& font_desc), gtk_widget_override_font,
450 deprecated "Use a custom style provider and style classes instead.")
451
452 _DEPRECATE_IFDEF_START
453 /** Undoes the effect of previous calls to override_font().
454 *
455 * @newin{3,0}
456 * @deprecated Use a custom style provider and style classes instead.
457 */
458 void unset_font();
459 _DEPRECATE_IFDEF_END
460
461 _WRAP_METHOD(void override_symbolic_color(const Glib::ustring& name, const Gdk::RGBA& color), gtk_widget_override_symbolic_color,
462 deprecated "Use a custom style provider and style classes instead.")
463
464 _DEPRECATE_IFDEF_START
465 /** Undoes the effect of previous calls to override_symbolic_color().
466 *
467 * @newin{3,0}
468 * @deprecated Use a custom style provider and style classes instead.
469 *
470 * @param name The name of the symbolic color to fetch from the user's theme.
471 */
472 void unset_symbolic_color(const Glib::ustring& name);
473 _DEPRECATE_IFDEF_END
474
475 _WRAP_METHOD(void override_cursor(const Gdk::RGBA& cursor, const Gdk::RGBA& secondary_cursor), gtk_widget_override_cursor,
476 deprecated "Use a custom style provider and style classes instead.")
477
478 _DEPRECATE_IFDEF_START
479 /** Undoes the effect of previous calls to override_cursor().
480 *
481 * @newin{3,0}
482 * @deprecated Use a custom style provider and style classes instead.
483 */
484 void unset_cursor();
485 _DEPRECATE_IFDEF_END
486
487 _IGNORE(gtk_widget_modify_fg, gtk_widget_modify_bg, gtk_widget_modify_font, gtk_widget_modify_text,
488 gtk_widget_modify_base, gtk_widget_modify_cursor) //deprecated
489
490 _WRAP_METHOD(void reset_style(), gtk_widget_reset_style)
491
492 //The parameter name is "the_property_name" to avoid a warning because there is a method with the "property_name" name.
493 /** Gets the value of a style property of @a widget.
494 * @param the_property_name The name of a style property.
495 * @param value Location to return the property value.
496 */
497 template <class PropertyType>
498 void get_style_property(const Glib::ustring& the_property_name, PropertyType& value) const;
499
500 _WRAP_METHOD(Glib::RefPtr<Pango::Context> create_pango_context(), gtk_widget_create_pango_context)
501 _WRAP_METHOD(Glib::RefPtr<Pango::Context> get_pango_context(), gtk_widget_get_pango_context, refreturn)
502
503 _WRAP_METHOD(void set_font_options(const ::Cairo::FontOptions& options), gtk_widget_set_font_options)
504 /** Undoes the effect of previous calls to set_font_options().
505 *
506 * @newin{3,20}
507 */
508 void unset_font_options();
509 // This returns a const, so we assume that we must copy it:
510 #m4 _CONVERSION(`const cairo_font_options_t*', `::Cairo::FontOptions', `::Cairo::FontOptions(const_cast<cairo_font_options_t*>($3), false /* take_ownership */)')
511 _WRAP_METHOD(::Cairo::FontOptions get_font_options() const, gtk_widget_get_font_options)
512
513 _WRAP_METHOD(Glib::RefPtr<Pango::Layout> create_pango_layout(const Glib::ustring& text), gtk_widget_create_pango_layout)
514
515 _IGNORE(gtk_widget_render_icon) //deprecated.
516 _WRAP_METHOD(Glib::RefPtr<Gdk::Pixbuf> render_icon_pixbuf(const StockID& stock_id, IconSize size), gtk_widget_render_icon_pixbuf, deprecated "Use IconTheme::load_icon() instead.")
517
518 _WRAP_METHOD(void set_composite_name(const Glib::ustring& name), gtk_widget_set_composite_name, deprecated "Use gtk_widget_class_set_template(), or don't use this API at all.")
519 #ifndef GTKMM_DISABLE_DEPRECATED
520 /** @deprecated Use gtk_widget_class_set_template(), or don't use this API at all.
521 */
522 void unset_composite_name();
523 #endif // GTKMM_DISABLE_DEPRECATED
524 _WRAP_METHOD(Glib::ustring get_composite_name() const, gtk_widget_get_composite_name, deprecated "Use gtk_widget_class_set_template(), or don't use this API at all.")
525
526 _WRAP_METHOD(static void push_composite_child(), gtk_widget_push_composite_child, deprecated "This API never really worked well and was mostly unused, now we have a more complete mechanism for composite children, see gtk_widget_class_set_template().")
527 _WRAP_METHOD(static void pop_composite_child(), gtk_widget_pop_composite_child, deprecated "Use gtk_widget_class_set_template(), or don't use this API at all.")
528
529 /* Directionality of Text */
530
531 _WRAP_METHOD(void set_direction(TextDirection dir), gtk_widget_set_direction)
532 _WRAP_METHOD(TextDirection get_direction() const, gtk_widget_get_direction)
533
534 _WRAP_METHOD(static void set_default_direction(TextDirection dir), gtk_widget_set_default_direction)
535 _WRAP_METHOD(static TextDirection get_default_direction(), gtk_widget_get_default_direction)
536
537 _WRAP_METHOD(void shape_combine_region(const ::Cairo::RefPtr<const ::Cairo::Region>& region), gtk_widget_shape_combine_region)
538 _WRAP_METHOD(void input_shape_combine_region(const ::Cairo::RefPtr<const ::Cairo::Region>& region), gtk_widget_input_shape_combine_region)
539
540 _WRAP_METHOD(WidgetPath get_path() const, gtk_widget_get_path)
541 _IGNORE(gtk_widget_path, gtk_widget_class_path) //deprecated
542
543 #m4 _CONVERSION(`GList*',`std::vector<Widget*>',`Glib::ListHandler<Widget*>::list_to_vector($3, Glib::OWNERSHIP_SHALLOW)')
544 _WRAP_METHOD(std::vector<Widget*> list_mnemonic_labels(), gtk_widget_list_mnemonic_labels)
545 #m4 _CONVERSION(`GList*',`std::vector<const Widget*>',`Glib::ListHandler<const Widget*>::list_to_vector($3, Glib::OWNERSHIP_SHALLOW)')
546 _WRAP_METHOD(std::vector<const Widget*> list_mnemonic_labels() const, gtk_widget_list_mnemonic_labels)
547 _WRAP_METHOD(void add_mnemonic_label(Widget& label), gtk_widget_add_mnemonic_label)
548 _WRAP_METHOD(void remove_mnemonic_label(Widget& label), gtk_widget_remove_mnemonic_label)
549
550 //TODO: Should drag_get_data() be const?
551 _WRAP_METHOD(void drag_get_data(const Glib::RefPtr<Gdk::DragContext>& context, const Glib::ustring& target, guint32 time), gtk_drag_get_data)
552
553 _WRAP_METHOD(void drag_highlight(), gtk_drag_highlight)
554 _WRAP_METHOD(void drag_unhighlight(), gtk_drag_unhighlight)
555
556 //TODO: Change the defaults? Maybe we should use ALL for DestDefaults. See other drag_dest_set() methods here and in other widgets.
557 void drag_dest_set(DestDefaults flags = DestDefaults(0), Gdk::DragAction actions = Gdk::DragAction(0));
558 void drag_dest_set(const std::vector<TargetEntry>& targets, DestDefaults flags = DEST_DEFAULT_ALL, Gdk::DragAction actions = Gdk::ACTION_COPY);
559 _IGNORE(gtk_drag_dest_set)
560
561 _WRAP_METHOD(void drag_dest_set_proxy(const Glib::RefPtr<Gdk::Window>& proxy_window, Gdk::DragProtocol protocol, bool use_coordinates), gtk_drag_dest_set_proxy,
562 deprecated "No replacement available.")
563 _WRAP_METHOD(void drag_dest_unset(), gtk_drag_dest_unset)
564 _WRAP_METHOD(Glib::ustring drag_dest_find_target(const Glib::RefPtr<Gdk::DragContext>& context, const Glib::RefPtr<TargetList>& target_list) const, gtk_drag_dest_find_target)
565 Glib::ustring drag_dest_find_target(const Glib::RefPtr<Gdk::DragContext>& context) const;
566
567 _WRAP_METHOD(Glib::RefPtr<TargetList> drag_dest_get_target_list(), gtk_drag_dest_get_target_list, refreturn)
568 _WRAP_METHOD(Glib::RefPtr<const TargetList> drag_dest_get_target_list() const, gtk_drag_dest_get_target_list, refreturn, constversion)
569 _WRAP_METHOD(void drag_dest_set_target_list(const Glib::RefPtr<TargetList>& target_list), gtk_drag_dest_set_target_list)
570
571 _WRAP_METHOD(void drag_dest_add_text_targets(), gtk_drag_dest_add_text_targets)
572 _WRAP_METHOD(void drag_dest_add_image_targets(), gtk_drag_dest_add_image_targets)
573 _WRAP_METHOD(void drag_dest_add_uri_targets(), gtk_drag_dest_add_uri_targets)
574
575 void drag_source_set(const std::vector<TargetEntry>& targets, Gdk::ModifierType start_button_mask = Gdk::MODIFIER_MASK, Gdk::DragAction actions = Gdk::ACTION_COPY);
576 _IGNORE(gtk_drag_source_set)
577
578 _WRAP_METHOD(void drag_source_unset(), gtk_drag_source_unset)
579
580 _WRAP_METHOD(void drag_source_set_icon(const Glib::RefPtr<Gdk::Pixbuf>& pixbuf), gtk_drag_source_set_icon_pixbuf)
581 _WRAP_METHOD(void drag_source_set_icon(const StockID& stock_id), gtk_drag_source_set_icon_stock, deprecated "Use the drag_source_set_icon() that takes a Glib::ustring instead.")
582 _WRAP_METHOD(void drag_source_set_icon(const Glib::ustring& icon_name), gtk_drag_source_set_icon_name)
583
584 _WRAP_METHOD(void drag_source_add_text_targets(), gtk_drag_source_add_text_targets)
585 _WRAP_METHOD(void drag_source_add_uri_targets(), gtk_drag_source_add_uri_targets)
586 _WRAP_METHOD(void drag_source_add_image_targets(), gtk_drag_source_add_image_targets)
587
588 _WRAP_METHOD(Glib::RefPtr<Gdk::DragContext> drag_begin(const Glib::RefPtr<TargetList>& targets, Gdk::DragAction actions, int button, GdkEvent* gdk_event), gtk_drag_begin, refreturn,
589 deprecated "Use the drag_begin() that takes x,y coordinates.")
590 _WRAP_METHOD(Glib::RefPtr<Gdk::DragContext> drag_begin(const Glib::RefPtr<TargetList>& targets, Gdk::DragAction actions, int button, GdkEvent* gdk_event, int x, int y), gtk_drag_begin_with_coordinates, refreturn)
591 _WRAP_METHOD(bool drag_check_threshold(int start_x, int start_y, int current_x, int current_y), gtk_drag_check_threshold)
592
593 //These should be a method of Gdk::DragContext, but gdkmm can't depend on gtkmm.
594 static Widget* drag_get_source_widget(const Glib::RefPtr<Gdk::DragContext>& context);
595 void drag_set_as_icon(const Glib::RefPtr<Gdk::DragContext>& context, int hot_x, int hot_y);
596
597 _WRAP_METHOD(void queue_resize_no_redraw(), gtk_widget_queue_resize_no_redraw)
598
599 _WRAP_METHOD(Glib::RefPtr<Gdk::FrameClock> get_frame_clock(), gtk_widget_get_frame_clock, refreturn, newin "3,24")
600 _WRAP_METHOD(Glib::RefPtr<const Gdk::FrameClock> get_frame_clock()const, gtk_widget_get_frame_clock, refreturn, constversion, newin "3,24")
601
602 _WRAP_METHOD(bool get_no_show_all() const, gtk_widget_get_no_show_all)
603 _WRAP_METHOD(void set_no_show_all(bool no_show_all = true), gtk_widget_set_no_show_all)
604
605 //Used when implementing containers:
606 _WRAP_METHOD(void set_parent(Widget& parent), gtk_widget_set_parent)
607 _WRAP_METHOD(void unparent(), gtk_widget_unparent)
608
609 //TODO: When exactly do we need to custom containers need to call map() on the child widgets?
610 //Most containers that derive from GtkContainer do not need to, but GtkNotebook does.
611 _WRAP_METHOD(void map(), gtk_widget_map)
612 _WRAP_METHOD(void unmap(), gtk_widget_unmap)
613
614 #ifndef GTKMM_DISABLE_DEPRECATED
615 /** Draws a text caret on @a cr at @a location.
616 * This is not a style function but merely a convenience function for drawing
617 * the standard cursor shape.
618 *
619 * @deprecated Use StyleContext::render_insertion_cursor() instead.
620 */
621 void draw_insertion_cursor(const ::Cairo::RefPtr< ::Cairo::Context>& cr, const Gdk::Rectangle& location, bool is_primary, TextDirection direction, bool draw_arrow = true);
622 #endif // GTKMM_DISABLE_DEPRECATED
623 _IGNORE(gtk_draw_insertion_cursor)
624
625 // Gtk+ 2.12 tooltip API
626 _WRAP_METHOD(void set_tooltip_window(Window& custom_window), gtk_widget_set_tooltip_window)
627 _WRAP_METHOD(Window* get_tooltip_window(), gtk_widget_get_tooltip_window)
628 _WRAP_METHOD(void trigger_tooltip_query(), gtk_widget_trigger_tooltip_query)
629 _WRAP_METHOD(void set_tooltip_text(const Glib::ustring& text), gtk_widget_set_tooltip_text)
630 _WRAP_METHOD(Glib::ustring get_tooltip_text() const, gtk_widget_get_tooltip_text)
631 _WRAP_METHOD(void set_tooltip_markup(const Glib::ustring& markup), gtk_widget_set_tooltip_markup)
632 _WRAP_METHOD(Glib::ustring get_tooltip_markup() const, gtk_widget_get_tooltip_markup)
633 _WRAP_METHOD(void set_has_tooltip(bool has_tooltip = TRUE), gtk_widget_set_has_tooltip)
634 _WRAP_METHOD(bool get_has_tooltip() const, gtk_widget_get_has_tooltip)
635
636 int get_width() const;
637 int get_height() const;
638
639 _WRAP_METHOD(bool is_composited() const, gtk_widget_is_composited,
640 deprecated "Use Gdk::Screen::is_composited() instead.")
641
642 _WRAP_METHOD(bool in_destruction() const, gtk_widget_in_destruction)
643
644 _WRAP_METHOD(Glib::RefPtr<StyleContext> get_style_context(), gtk_widget_get_style_context, refreturn)
645 _WRAP_METHOD(Glib::RefPtr<Gtk::StyleContext> get_style_context() const, gtk_widget_get_style_context, refreturn, constversion)
646
647 _WRAP_METHOD(Gdk::ModifierType get_modifier_mask(Gdk::ModifierIntent intent), gtk_widget_get_modifier_mask)
648
649 /** Callback type for adding a function to update animations. See add_tick_callback().
650 *
651 * For instance:
652 * @code
653 * bool on_tick(const Glib::RefPtr<Gdk::FrameClock>& frame_clock);
654 * @endcode
655 *
656 * @param frame_clock The frame clock for the widget (same as calling get_frame_clock()).
657 * @return <tt>true</tt> if the tick callback should continue to be called,
658 * <tt>false</tt> if the tick callback should be removed.
659 *
660 * @newin{3,24}
661 */
662 using SlotTick = sigc::slot<bool(const Glib::RefPtr<Gdk::FrameClock>&)>;
663
664 /** Queues an animation frame update and adds a callback to be called
665 * before each frame.
666 *
667 * Until the tick callback is removed, it will be
668 * called frequently (usually at the frame rate of the output device
669 * or as quickly as the application can be repainted, whichever is
670 * slower). For this reason, is most suitable for handling graphics
671 * that change every frame or every few frames. The tick callback does
672 * not automatically imply a relayout or repaint. If you want a
673 * repaint or relayout, and aren’t changing widget properties that
674 * would trigger that (for example, changing the text of a Gtk::Label),
675 * then you will have to call queue_resize() or queue_draw_area() yourself.
676 *
677 * Gdk::FrameClock::get_frame_time() should generally be used for timing
678 * continuous animations and
679 * Gdk::FrameTimings::get_predicted_presentation_time() if you are
680 * trying to display isolated frames at particular times.
681 *
682 * This is a more convenient alternative to connecting directly to the
683 * Gdk::FrameClock::signal_update() signal of Gdk::FrameClock, since you don't
684 * have to worry about when a Gdk::FrameClock is assigned to a widget.
685 *
686 * @newin{3,24}
687 *
688 * @param slot Slot to call for updating animations.
689 * @return An id for the connection of this callback. Remove the callback
690 * by passing it to remove_tick_callback().
691 */
692 guint add_tick_callback(const SlotTick& slot);
693 _IGNORE(gtk_widget_add_tick_callback)
694
695 _WRAP_METHOD(void remove_tick_callback(guint id), gtk_widget_remove_tick_callback, newin "3,24")
696
697 //This is mostly only needed by the class itself, so it could be protected,
698 //but it is sometimes helpful to call it from outside:
699 _WRAP_METHOD(void insert_action_group(const Glib::ustring& name, const Glib::RefPtr<Gio::ActionGroup>& group), gtk_widget_insert_action_group)
700
701 /** Removes a group from the widget.
702 * See insert_action_group().
703 *
704 * @param name The prefix for actions.
705 *
706 * @newin{3,10}
707 */
708 void remove_action_group(const Glib::ustring& name);
709
710 _WRAP_METHOD(Glib::RefPtr<Gio::ActionGroup> get_action_group(const Glib::ustring& prefix), gtk_widget_get_action_group, refreturn)
711 _WRAP_METHOD(Glib::RefPtr<const Gio::ActionGroup> get_action_group(const Glib::ustring& prefix) const, gtk_widget_get_action_group, refreturn, constversion)
712
713 #m4 _CONVERSION(`const gchar**',`std::vector<Glib::ustring>',`Glib::ArrayHandler<Glib::ustring>::array_to_vector($3, Glib::OWNERSHIP_SHALLOW)')
714 _WRAP_METHOD(std::vector<Glib::ustring> list_action_prefixes() const, gtk_widget_list_action_prefixes)
715
716 _WRAP_METHOD(void set_font_map(const Glib::RefPtr<Pango::FontMap>& font_map), gtk_widget_set_font_map)
717 _WRAP_METHOD(Glib::RefPtr<Pango::FontMap> get_font_map(), gtk_widget_get_font_map, refreturn)
718 _WRAP_METHOD(Glib::RefPtr<const Pango::FontMap> get_font_map() const, gtk_widget_get_font_map, refreturn, constversion)
719
720 _WRAP_SIGNAL(void show(),"show")
721 _WRAP_SIGNAL(void hide(),"hide", custom_c_callback)
722
723 /// Emitted on mapping of a widget to the screen.
724 //- See {flags.mapped}.
725 _WRAP_SIGNAL(void map(),"map")
726
727 //- See {flags.mapped}.
728 _WRAP_SIGNAL(void unmap(),"unmap")
729
730 /// Emitted on realization of a widget.
731 //- See {flags.realized}. This is also responsible for
732 //- setting {flags.realized} when it is done. Therefore,
733 //- when overriding the impl method, you should call the
734 //- default realize method.
735 _WRAP_SIGNAL(void realize(),"realize")
736
737 //- See {flags.realized}. This should not be called by the user.
738 //_WRAP(meth|sig|impl,void unrealize_(),gtk_widget_unrealize,"unrealize")
739 _WRAP_SIGNAL(void unrealize(),"unrealize")
740
741 #m4 _CONVERSION(`Allocation&',`GdkRectangle*',`($2)($3.gobj())')
742 #m4 _CONVERSION(`GdkRectangle*',`Allocation&',`($2)(Glib::wrap($3))')
743 _WRAP_SIGNAL(void size_allocate(Allocation& allocation), "size_allocate")
744
745 // Changed signals -- inform widget of internal changes.
746 // We rename parent_set => parent_changed
747 // and style_set => style_changed
748 // to avoid confusion with set_parent and set_style.
749
750 _WRAP_SIGNAL(void state_changed(Gtk::StateType previous_state), "state_changed", deprecated "Use signal_state_flags_changed() instead.")
751
752 //TODO: Remove no_default_handler when we can break ABI:
753 _WRAP_SIGNAL(void state_flags_changed(Gtk::StateFlags previous_state_flags), "state-flags-changed", no_default_handler)
754
755 /// Informs objects that their parent changed.
756 //- The widget passed is the former parent, which may be 0 if
757 //- there was no parent. (was parent_set in GTK+)
758 _WRAP_SIGNAL(void parent_changed(Widget* previous_parent), "parent_set")
759
760 _WRAP_SIGNAL(void hierarchy_changed(Widget* previous_toplevel), "hierarchy_changed")
761
762 _IGNORE_SIGNAL("style_set") //uses deprecated GtkStyle.
763 _WRAP_SIGNAL(void style_updated(), "style_updated")
764
765 _WRAP_SIGNAL(void direction_changed(TextDirection direction), "direction_changed")
766
767 _WRAP_SIGNAL(void grab_notify(bool was_grabbed), "grab_notify")
768
769 _WRAP_SIGNAL(void child_notify(GParamSpec* pspec), "child_notify",
770 detail_name child_property_name, two_signal_methods)
771
772 _WRAP_SIGNAL(bool mnemonic_activate(bool group_cycling), "mnemonic_activate")
773 _WRAP_SIGNAL(void grab_focus(), "grab_focus")
774 _WRAP_SIGNAL(bool focus(DirectionType direction), "focus")
775 _WRAP_SIGNAL(bool event(GdkEvent* gdk_event), "event")
776 _WRAP_SIGNAL(void event_after(GdkEvent* gdk_event), "event_after", no_default_handler)
777
778 /// Event triggered by user pressing button.
779 _WRAP_SIGNAL(bool button_press_event(GdkEventButton* button_event),"button_press_event")
780
781 /// Event triggered by user releasing button.
782 _WRAP_SIGNAL(bool button_release_event(GdkEventButton* release_event), "button_release_event")
783
784 _WRAP_SIGNAL(bool scroll_event(GdkEventScroll* scroll_event), "scroll_event")
785
786 /// Event triggered by user moving pointer.
787 _WRAP_SIGNAL(bool motion_notify_event(GdkEventMotion* motion_event), "motion_notify_event")
788
789 _WRAP_SIGNAL(bool delete_event(GdkEventAny* any_event), "delete_event")
790
791 #m4begin
792 dnl// Hook in special code to catch explicit uses of gtk_object_destroy() by
793 dnl// GTK+ code, e.g. when receiving the GDK_DELETE event. For details, look
794 dnl// at Gtk::Widget_Class::dispose_vfunc_callback() in widget.ccg.
795 dnl
796 _PUSH(SECTION_PCC_CLASS_INIT_VFUNCS)
797 reinterpret_cast<GObjectClass*>(klass)->dispose = &dispose_vfunc_callback;
798 _SECTION(SECTION_PH_VFUNCS)
799 static void dispose_vfunc_callback(GObject* self);
800 _POP()
801 #m4end
802
803 #m4 _CONVERSION(`cairo_t*',`const ::Cairo::RefPtr< ::Cairo::Context>&',`::Cairo::RefPtr< ::Cairo::Context>(new ::Cairo::Context($3, false /* has_reference */))')
804 _WRAP_SIGNAL(bool draw(const ::Cairo::RefPtr< ::Cairo::Context>& cr), "draw")
805
806 /// Event triggered by a key press will widget has focus.
807 _WRAP_SIGNAL(bool key_press_event(GdkEventKey* key_event), "key_press_event")
808
809 /// Event triggered by a key release will widget has focus.
810 _WRAP_SIGNAL(bool key_release_event(GdkEventKey* key_event), "key_release_event")
811
812 /// Event triggered by pointer entering widget area.
813 _WRAP_SIGNAL(bool enter_notify_event(GdkEventCrossing* crossing_event), "enter_notify_event")
814
815 /// Event triggered by pointer leaving widget area.
816 _WRAP_SIGNAL(bool leave_notify_event(GdkEventCrossing* crossing_event), "leave_notify_event")
817
818 /// Event triggered by a window resizing.
819 _WRAP_SIGNAL(bool configure_event(GdkEventConfigure* configure_event), "configure_event")
820 _WRAP_SIGNAL(bool focus_in_event(GdkEventFocus* focus_event), "focus_in_event")
821 _WRAP_SIGNAL(bool focus_out_event(GdkEventFocus* gdk_event), "focus_out_event")
822 _WRAP_SIGNAL(bool map_event(GdkEventAny* any_event), "map_event")
823 _WRAP_SIGNAL(bool unmap_event(GdkEventAny* any_event), "unmap_event")
824 _WRAP_SIGNAL(bool property_notify_event(GdkEventProperty* property_event), "property_notify_event")
825 _WRAP_SIGNAL(bool selection_clear_event(GdkEventSelection* selection_event), "selection_clear_event")
826 _WRAP_SIGNAL(bool selection_request_event(GdkEventSelection* selection_event), "selection_request_event")
827 _WRAP_SIGNAL(bool selection_notify_event(GdkEventSelection* selection_event), "selection_notify_event")
828 _WRAP_SIGNAL(bool proximity_in_event(GdkEventProximity* proximity_event), "proximity_in_event")
829 _WRAP_SIGNAL(bool proximity_out_event(GdkEventProximity* proximity_event), "proximity_out_event")
830 _WRAP_SIGNAL(bool visibility_notify_event(GdkEventVisibility* visibility_event), "visibility_notify_event",
831 deprecated "Modern composited windowing systems with pervasive transparency make it impossible to track the visibility of a window reliably, so this signal can not be guaranteed to provide useful information.")
832 _WRAP_SIGNAL(bool window_state_event(GdkEventWindowState* window_state_event), "window_state_event")
833
834 //We use the optional custom_c_callback parameter with _WRAP_SIGNAL() for some of these,
835 //so that we can write special code to wrap the non-const SelectionData& output parameters:
836 _WRAP_SIGNAL(void selection_get(SelectionData& selection_data, guint info, guint time), "selection_get", custom_c_callback)
837 _WRAP_SIGNAL(void selection_received(const SelectionData& selection_data, guint time), "selection_received")
838
839 #m4 _CONVERSION(`GdkDragContext*',`const Glib::RefPtr<Gdk::DragContext>&',Glib::wrap($3, true))
840
841 _WRAP_SIGNAL(void drag_begin(const Glib::RefPtr<Gdk::DragContext>& context), "drag_begin")
842 _WRAP_SIGNAL(void drag_end(const Glib::RefPtr<Gdk::DragContext>& context), "drag_end")
843 _WRAP_SIGNAL(void drag_data_get(const Glib::RefPtr<Gdk::DragContext>& context, SelectionData& selection_data, guint info, guint time), "drag_data_get", custom_c_callback)
844 _WRAP_SIGNAL(void drag_data_delete(const Glib::RefPtr<Gdk::DragContext>& context), "drag_data_delete")
845 _WRAP_SIGNAL(bool drag_failed(const Glib::RefPtr<Gdk::DragContext>& context, DragResult result), "drag_failed", no_default_handler)
846 _WRAP_SIGNAL(void drag_leave(const Glib::RefPtr<Gdk::DragContext>& context, guint time), "drag_leave")
847 _WRAP_SIGNAL(bool drag_motion(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, guint time), "drag_motion")
848 _WRAP_SIGNAL(bool drag_drop(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, guint time), "drag_drop")
849 _WRAP_SIGNAL(void drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, const SelectionData& selection_data, guint info, guint time), "drag_data_received")
850
851 _CONVERSION(`GdkScreen*',`const Glib::RefPtr<Gdk::Screen>&',`Glib::wrap($3, true)')
852 _WRAP_SIGNAL(void screen_changed(const Glib::RefPtr<Gdk::Screen>& previous_screen), "screen_changed")
853
854 _WRAP_SIGNAL(void composited_changed(), "composited_changed", no_default_handler,
855 deprecated "Use Gdk::Screen::signal_composited_changed() instead.")
856
857 //TODO: The signal_id is very C-like here:
858 //_WRAP_SIGNAL(bool can_activate_accel(guint signal_id), "can_activate_accel")
859
860 // TODO: Remove no_default_handler when we can break ABI:
861 _WRAP_SIGNAL(bool popup_menu(), "popup_menu", no_default_handler) //Note that popup-menu is a keybinding signal, but is really meant to be wrapped.
862
863 //Keybinding signals:
864 _IGNORE_SIGNAL("show_help")
865 _IGNORE_SIGNAL("keynav_failed")
866
867 _IGNORE_SIGNAL("destroy-event")
868
869 // TODO: Remove no_default_handler when we can break ABI:
870 #m4 _CONVERSION(`GtkTooltip*',`const Glib::RefPtr<Tooltip>&',`Glib::wrap($3, true)')
871 _WRAP_SIGNAL(bool query_tooltip(int x, int y, bool keyboard_tooltip, const Glib::RefPtr<Tooltip>& tooltip), "query_tooltip", no_default_handler)
872
873 //(This was added to GTK+ 2.8 but forgotten by us until gtkmm 2.13/14):
874 _WRAP_SIGNAL(bool grab_broken_event(GdkEventGrabBroken* grab_broken_event), "grab_broken_event", no_default_handler)
875
876 // TODO: Remove no_default_handler when we can break ABI:
877 _WRAP_SIGNAL(bool damage_event(GdkEventExpose* expose_event), "damage-event", no_default_handler)
878
879 // TODO: Remove no_default_handler when we can break ABI:
880 _WRAP_SIGNAL(bool touch_event(GdkEventTouch* touch_event), "touch_event", no_default_handler)
881
882 _WRAP_PROPERTY("name", Glib::ustring)
883 _WRAP_PROPERTY("parent", Container*)
884 _WRAP_PROPERTY("width_request", int)
885 _WRAP_PROPERTY("height_request", int)
886 _WRAP_PROPERTY("visible", bool)
887 _WRAP_PROPERTY("sensitive", bool)
888 _WRAP_PROPERTY("app_paintable", bool)
889 _WRAP_PROPERTY("can_focus", bool)
890 _WRAP_PROPERTY("has_focus", bool)
891 _WRAP_PROPERTY("is_focus", bool)
892 _WRAP_PROPERTY("focus_on_click", bool)
893 _WRAP_PROPERTY("can_default", bool)
894 _WRAP_PROPERTY("has_default", bool)
895 _WRAP_PROPERTY("receives_default", bool)
896 _WRAP_PROPERTY("composite_child", bool)
897 _WRAP_PROPERTY("style", Glib::RefPtr<Style>, deprecated "Don't use this API. There is no Style class in gtkmm 3.")
898 _WRAP_PROPERTY("events", Gdk::EventMask)
899 _WRAP_PROPERTY("has_tooltip", bool)
900 _WRAP_PROPERTY("tooltip_markup", Glib::ustring)
901 _WRAP_PROPERTY("tooltip_text", Glib::ustring)
902 _WRAP_PROPERTY("window", Glib::RefPtr<Gdk::Window>)
903 _WRAP_PROPERTY("no-show-all", bool)
904 _WRAP_PROPERTY("double-buffered", bool, deprecated "Widgets should not use this property.")
905
906 _WRAP_PROPERTY("halign", Align)
907 _WRAP_PROPERTY("valign", Align)
908 _WRAP_PROPERTY("margin-left", int, deprecated "Use property_margin_start() instead.")
909 _WRAP_PROPERTY("margin-right", int, deprecated "Use property_margin_end() instead.")
910 _WRAP_PROPERTY("margin-start", int)
911 _WRAP_PROPERTY("margin-end", int)
912 _WRAP_PROPERTY("margin-top", int)
913 _WRAP_PROPERTY("margin-bottom", int)
914 _WRAP_PROPERTY("margin", int)
915 _WRAP_PROPERTY("hexpand", bool)
916 _WRAP_PROPERTY("hexpand-set", bool)
917 _WRAP_PROPERTY("vexpand", bool)
918 _WRAP_PROPERTY("vexpand-set", bool)
919 _WRAP_PROPERTY("expand", bool)
920 _WRAP_PROPERTY("opacity", double)
921 _WRAP_PROPERTY("scale-factor", int)
922
923 protected:
924
925 //comment in GTK+ header: "seldomly overidden"
926 _WRAP_VFUNC(void dispatch_child_properties_changed(guint, GParamSpec**), "dispatch_child_properties_changed")
927
928 _WRAP_VFUNC(void show_all(), "show_all")
929 _WRAP_VFUNC(Glib::RefPtr<Atk::Object> get_accessible(), "get_accessible", refreturn, ifdef GTKMM_ATKMM_ENABLED)
930
931 _WRAP_VFUNC(SizeRequestMode get_request_mode() const, get_request_mode)
932 _WRAP_VFUNC(void get_preferred_width(int& minimum_width, int& natural_width) const, get_preferred_width, custom_vfunc_callback)
933 _WRAP_VFUNC(void get_preferred_height_for_width(int width, int& minimum_height, int& natural_height) const, get_preferred_height_for_width, custom_vfunc_callback)
934 _WRAP_VFUNC(void get_preferred_height(int& minimum_height, int& natural_height) const, get_preferred_height, custom_vfunc_callback)
935 _WRAP_VFUNC(void get_preferred_width_for_height(int height, int& minimum_width, int& natural_width) const, get_preferred_width_for_height, custom_vfunc_callback)
936 //TODO: Wrap all the new vfuncs when we can break ABI.
937
938 protected:
939 _CTOR_DEFAULT()
940
941 _WRAP_METHOD(void realize(), gtk_widget_realize)
942 _WRAP_METHOD(void unrealize(), gtk_widget_unrealize)
943
944 #m4 _CONVERSION(`const ::Cairo::RefPtr< ::Cairo::Context>&',`cairo_t*',`($3)->cobj()')
945 _WRAP_METHOD(void draw(const ::Cairo::RefPtr< ::Cairo::Context>& cr), gtk_widget_draw)
946
947 _WRAP_METHOD(void set_mapped(bool mapped = true), gtk_widget_set_mapped)
948 _WRAP_METHOD(void set_realized(bool realized = true), gtk_widget_set_realized)
949
950 _WRAP_METHOD(void set_has_window(bool has_window = true), gtk_widget_set_has_window)
951
952 /** Sets a widget's window. This function should only be used in a
953 * widget's Gtk::Widget::on_realize() implementation. The %window passed is
954 * usually either a new window created with Gdk::Window::create(), or the
955 * window of its parent widget as returned by get_parent_window().
956 *
957 * Widgets must indicate whether they will create their own Gdk::Window
958 * by calling set_has_window(). This is usually done in the
959 * widget's constructor.
960 *
961 * This function should only be called by custom widget implementations,
962 * and they should call it in their on_realize() function.
963 *
964 * @newin{2,18}
965 *
966 * @param window A Gdk::Window.
967 */
968 void set_window(const Glib::RefPtr<Gdk::Window>& window);
969 _IGNORE(gtk_widget_set_window)
970
971 _WRAP_METHOD(static bool should_draw_window(const ::Cairo::RefPtr<const ::Cairo::Context>& cr, const Glib::RefPtr<const Gdk::Window>& window), gtk_cairo_should_draw_window)
972
973 /** Transforms the given cairo context @a cr from widget-relative
974 * coordinates to window-relative coordinates.
975 * If the widget's window is not an ancestor of @a window, no
976 * modification will be applied.
977 *
978 * This is the inverse to the transformation GTK applies when
979 * preparing an expose event to be emitted with the Widget's draw
980 * signal. It is intended to help porting multiwindow widgets from
981 * GTK+ 2 to the rendering architecture of GTK+ 3.
982 *
983 * @param cr The cairo context to transform.
984 * @param window The window to transform the context to.
985 *
986 * @newin{3,0}
987 */
988 void transform_cairo_context_to_window(const ::Cairo::RefPtr< ::Cairo::Context>& cr, const Glib::RefPtr<const Gdk::Window>& window);
989 _IGNORE(gtk_cairo_transform_to_window)
990
991 #ifndef GTKMM_DISABLE_DEPRECATED
992 /** Retrieves the widget's requisition.
993 *
994 * This method should only be used by widget implementations in
995 * order to discover whether the widget's requisition has actually
996 * changed after some internal state change (so that they can call
997 * queue_resize() instead of queue_draw()).
998 *
999 * Normally, size_request() should be used.
1000 *
1001 * @result The widget's requisition.
1002 *
1003 * @newin{2,20}
1004 * @deprecated Use get_preferred_size() instead.
1005 */
1006 Requisition get_requisition() const;
1007 _IGNORE(gtk_widget_get_requisition)
1008 #endif // GTKMM_DISABLE_DEPRECATED
1009
1010 _IGNORE(gtk_widget_style_attach) //deprecated
1011 _IGNORE(gtk_widget_get_child_requisition) //deprecated.
1012
1013 //The parameter name is "the_property_name" to avoid a warning because there is a method with the "property_name" name.
1014 /** Gets the value of a style property of @a widget.
1015 *
1016 * It is usually easier to use get_style_property(), to avoid the use of
1017 * Glib::Value.
1018 *
1019 * @param the_property_name The name of a style property.
1020 * @param value Location to return the property value.
1021 */
1022 _WRAP_METHOD(void get_style_property_value(
1023 const Glib::ustring& the_property_name, Glib::ValueBase& value) const,
1024 gtk_widget_style_get_property)
1025
1026 void realize_if_needed();
1027
1028 #m4begin
1029 dnl// Hook in custom hierarchy_changed callback.
1030 dnl// It will use the generated callback.
1031 dnl
1032 _PUSH(SECTION_PCC_CLASS_INIT_DEFAULT_SIGNAL_HANDLERS)
1033 klass->hierarchy_changed = &hierarchy_changed_callback_custom;
1034 _SECTION(SECTION_PH_DEFAULT_SIGNAL_HANDLERS)
1035 static void hierarchy_changed_callback_custom(GtkWidget* self, GtkWidget* p0);
1036 _POP()
1037 #m4end
1038
1039 #m4begin
1040 dnl// Hook in custom hierarchy_changed callback.
1041 dnl// It will use the generated callback.
1042 dnl
1043 _PUSH(SECTION_PCC_CLASS_INIT_DEFAULT_SIGNAL_HANDLERS)
1044 klass->parent_set = &parent_set_callback_custom;
1045 _SECTION(SECTION_PH_DEFAULT_SIGNAL_HANDLERS)
1046 static void parent_set_callback_custom(GtkWidget* self, GtkWidget* p0);
1047 _POP()
1048 #m4end
1049
1050 };
1051
1052 #ifndef DOXYGEN_SHOULD_SKIP_THIS
1053
1054 //The parameter name is "the_property_name" to avoid a warning because there is a method with the "property_name" name.
1055 template <class PropertyType>
1056 void Widget::get_style_property(const Glib::ustring& the_property_name, PropertyType& value) const
1057 {
1058 Glib::Value<PropertyType> property_value;
1059 property_value.init(Glib::Value<PropertyType>::value_type());
1060
1061 this->get_style_property_value(the_property_name, property_value);
1062
1063 value = property_value.get();
1064 }
1065
1066 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
1067
1068 } // namespace Gtk