1/* GTK - The GIMP Toolkit
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18/*
19 * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
20 * file for a list of people on the GTK+ Team. See the ChangeLog
21 * files for a list of changes. These files are distributed with
22 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
23 */
24
25#ifndef __GTK_WIDGET_H__
26#define __GTK_WIDGET_H__
27
28#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
29#error "Only <gtk/gtk.h> can be included directly."
30#endif
31
32#include <gdk/gdk.h>
33#include <gsk/gsk.h>
34#include <gtk/gtkaccelgroup.h>
35#include <gtk/gtkborder.h>
36#include <gtk/gtkshortcut.h>
37#include <gtk/gtkshortcutaction.h>
38#include <gtk/gtktypes.h>
39
40G_BEGIN_DECLS
41
42/* Macro for casting a pointer to a GtkWidget or GtkWidgetClass pointer.
43 * Macros for testing whether widget or klass are of type GTK_TYPE_WIDGET.
44 */
45#define GTK_TYPE_WIDGET (gtk_widget_get_type ())
46#define GTK_WIDGET(widget) (G_TYPE_CHECK_INSTANCE_CAST ((widget), GTK_TYPE_WIDGET, GtkWidget))
47#define GTK_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_WIDGET, GtkWidgetClass))
48#define GTK_IS_WIDGET(widget) (G_TYPE_CHECK_INSTANCE_TYPE ((widget), GTK_TYPE_WIDGET))
49#define GTK_IS_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_WIDGET))
50#define GTK_WIDGET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_WIDGET, GtkWidgetClass))
51
52#define GTK_TYPE_REQUISITION (gtk_requisition_get_type ())
53
54typedef struct _GtkWidgetPrivate GtkWidgetPrivate;
55typedef struct _GtkWidgetClass GtkWidgetClass;
56typedef struct _GtkWidgetClassPrivate GtkWidgetClassPrivate;
57
58/**
59 * GtkAllocation:
60 * @x: the X position of the widget’s area relative to its parents allocation.
61 * @y: the Y position of the widget’s area relative to its parents allocation.
62 * @width: the width of the widget’s allocated area.
63 * @height: the height of the widget’s allocated area.
64 *
65 * The rectangle representing the area allocated for a widget by its parent.
66 */
67typedef GdkRectangle GtkAllocation;
68
69/**
70 * GtkTickCallback:
71 * @widget: the widget
72 * @frame_clock: the frame clock for the widget (same as calling gtk_widget_get_frame_clock())
73 * @user_data: user data passed to gtk_widget_add_tick_callback().
74 *
75 * Callback type for adding a function to update animations. See gtk_widget_add_tick_callback().
76 *
77 * Returns: %G_SOURCE_CONTINUE if the tick callback should continue to be called,
78 * %G_SOURCE_REMOVE if the tick callback should be removed.
79 */
80typedef gboolean (*GtkTickCallback) (GtkWidget *widget,
81 GdkFrameClock *frame_clock,
82 gpointer user_data);
83
84/**
85 * GtkRequisition:
86 * @width: the widget’s desired width
87 * @height: the widget’s desired height
88 *
89 * A `GtkRequisition` represents the desired size of a widget. See
90 * [GtkWidget’s geometry management section](class.Widget.html#height-for-width-geometry-management) for
91 * more information.
92 */
93struct _GtkRequisition
94{
95 int width;
96 int height;
97};
98
99/* The widget is the base of the tree for displayable objects.
100 * (A displayable object is one which takes up some amount
101 * of screen real estate). It provides a common base and interface
102 * which actual widgets must adhere to.
103 */
104struct _GtkWidget
105{
106 GInitiallyUnowned parent_instance;
107
108 /*< private >*/
109
110 GtkWidgetPrivate *priv;
111};
112
113/**
114 * GtkWidgetClass:
115 * @parent_class: The object class structure needs to be the first
116 * element in the widget class structure in order for the class mechanism
117 * to work correctly. This allows a GtkWidgetClass pointer to be cast to
118 * a GObjectClass pointer.
119 * @show: Signal emitted when widget is shown
120 * @hide: Signal emitted when widget is hidden.
121 * @map: Signal emitted when widget is going to be mapped, that is
122 * when the widget is visible (which is controlled with
123 * gtk_widget_set_visible()) and all its parents up to the toplevel
124 * widget are also visible.
125 * @unmap: Signal emitted when widget is going to be unmapped, which
126 * means that either it or any of its parents up to the toplevel
127 * widget have been set as hidden.
128 * @realize: Signal emitted when widget is associated with a
129 * `GdkSurface`, which means that gtk_widget_realize() has been called or
130 * the widget has been mapped (that is, it is going to be drawn).
131 * @unrealize: Signal emitted when the GdkSurface associated with
132 * widget is destroyed, which means that gtk_widget_unrealize() has
133 * been called or the widget has been unmapped (that is, it is going
134 * to be hidden).
135 * @root: Called when the widget gets added to a `GtkRoot` widget. Must
136 * chain up
137 * @unroot: Called when the widget is about to be removed from its
138 * `GtkRoot` widget. Must chain up
139 * @size_allocate: Called to set the allocation, if the widget does
140 * not have a layout manager.
141 * @state_flags_changed: Signal emitted when the widget state changes,
142 * see gtk_widget_get_state_flags().
143 * @direction_changed: Signal emitted when the text direction of a
144 * widget changes.
145 * @get_request_mode: Called to get the request mode, if the widget
146 * does not have a layout manager.
147 * This allows a widget to tell its parent container whether
148 * it prefers to be allocated in %GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH or
149 * %GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT mode.
150 * %GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH means the widget prefers to have
151 * `GtkWidgetClass.measure()` called first to get the default width (passing
152 * a for_size of -1), then again to get the height for said default width.
153 * %GTK_SIZE_REQUEST_CONSTANT_SIZE disables any height-for-width or
154 * width-for-height geometry management for said widget and is the
155 * default return.
156 * It’s important to note that any widget
157 * which trades height-for-width or width-for-height must respond properly
158 * to a for_size value >= -1 passed to `GtkWidgetClass.measure`, for both
159 * possible orientations.
160 * @measure: Called to obtain the minimum and natural size of the widget,
161 * if the widget does not have a layout manager.
162 * Depending on the orientation parameter, the passed for_size can be
163 * interpreted as width or height. A widget will never be allocated less
164 * than its minimum size.
165 * @mnemonic_activate: Activates the @widget if @group_cycling is
166 * %FALSE, and just grabs the focus if @group_cycling is %TRUE.
167 * @grab_focus: Causes @widget to have the keyboard focus for the
168 * `GtkWindow` it’s inside.
169 * @focus: Vfunc for gtk_widget_child_focus()
170 * @set_focus_child: Sets the focused child of a widget. Must chain up
171 * @move_focus: Signal emitted when a change of focus is requested
172 * @keynav_failed: Signal emitted if keyboard navigation fails.
173 * @query_tooltip: Signal emitted when “has-tooltip” is %TRUE and the
174 * hover timeout has expired with the cursor hovering “above”
175 * widget; or emitted when widget got focus in keyboard mode.
176 * @compute_expand: Computes whether a container should give this
177 * widget extra space when possible.
178 * @css_changed: Vfunc called when the CSS used by widget was changed. Widgets
179 * should then discard their caches that depend on CSS and queue resizes or
180 * redraws accordingly. The default implementation will take care of this for
181 * all the default CSS properties, so implementations must chain up.
182 * @system_setting_changed: Emitted when a system setting was changed. Must chain up.
183 * @snapshot: Vfunc called when a new snapshot of the widget has to be taken.
184 * @contains: Vfunc for gtk_widget_contains().
185 */
186struct _GtkWidgetClass
187{
188 GInitiallyUnownedClass parent_class;
189
190 /*< public >*/
191
192 /* basics */
193 void (* show) (GtkWidget *widget);
194 void (* hide) (GtkWidget *widget);
195 void (* map) (GtkWidget *widget);
196 void (* unmap) (GtkWidget *widget);
197 void (* realize) (GtkWidget *widget);
198 void (* unrealize) (GtkWidget *widget);
199 void (* root) (GtkWidget *widget);
200 void (* unroot) (GtkWidget *widget);
201 void (* size_allocate) (GtkWidget *widget,
202 int width,
203 int height,
204 int baseline);
205 void (* state_flags_changed) (GtkWidget *widget,
206 GtkStateFlags previous_state_flags);
207 void (* direction_changed) (GtkWidget *widget,
208 GtkTextDirection previous_direction);
209
210 /* size requests */
211 GtkSizeRequestMode (* get_request_mode) (GtkWidget *widget);
212 void (* measure) (GtkWidget *widget,
213 GtkOrientation orientation,
214 int for_size,
215 int *minimum,
216 int *natural,
217 int *minimum_baseline,
218 int *natural_baseline);
219
220 /* Mnemonics */
221 gboolean (* mnemonic_activate) (GtkWidget *widget,
222 gboolean group_cycling);
223
224 /* explicit focus */
225 gboolean (* grab_focus) (GtkWidget *widget);
226 gboolean (* focus) (GtkWidget *widget,
227 GtkDirectionType direction);
228 void (* set_focus_child) (GtkWidget *widget,
229 GtkWidget *child);
230
231 /* keyboard navigation */
232 void (* move_focus) (GtkWidget *widget,
233 GtkDirectionType direction);
234 gboolean (* keynav_failed) (GtkWidget *widget,
235 GtkDirectionType direction);
236
237 gboolean (* query_tooltip) (GtkWidget *widget,
238 int x,
239 int y,
240 gboolean keyboard_tooltip,
241 GtkTooltip *tooltip);
242
243 void (* compute_expand) (GtkWidget *widget,
244 gboolean *hexpand_p,
245 gboolean *vexpand_p);
246
247 void (* css_changed) (GtkWidget *widget,
248 GtkCssStyleChange *change);
249
250 void (* system_setting_changed) (GtkWidget *widget,
251 GtkSystemSetting settings);
252
253 void (* snapshot) (GtkWidget *widget,
254 GtkSnapshot *snapshot);
255
256 gboolean (* contains) (GtkWidget *widget,
257 double x,
258 double y);
259
260 /*< private >*/
261
262 GtkWidgetClassPrivate *priv;
263
264 gpointer padding[8];
265};
266
267
268GDK_AVAILABLE_IN_ALL
269GType gtk_widget_get_type (void) G_GNUC_CONST;
270GDK_AVAILABLE_IN_ALL
271void gtk_widget_unparent (GtkWidget *widget);
272GDK_AVAILABLE_IN_ALL
273void gtk_widget_show (GtkWidget *widget);
274GDK_AVAILABLE_IN_ALL
275void gtk_widget_hide (GtkWidget *widget);
276GDK_AVAILABLE_IN_ALL
277void gtk_widget_map (GtkWidget *widget);
278GDK_AVAILABLE_IN_ALL
279void gtk_widget_unmap (GtkWidget *widget);
280GDK_AVAILABLE_IN_ALL
281void gtk_widget_realize (GtkWidget *widget);
282GDK_AVAILABLE_IN_ALL
283void gtk_widget_unrealize (GtkWidget *widget);
284
285/* Queuing draws */
286GDK_AVAILABLE_IN_ALL
287void gtk_widget_queue_draw (GtkWidget *widget);
288GDK_AVAILABLE_IN_ALL
289void gtk_widget_queue_resize (GtkWidget *widget);
290GDK_AVAILABLE_IN_ALL
291void gtk_widget_queue_allocate (GtkWidget *widget);
292GDK_AVAILABLE_IN_ALL
293GdkFrameClock* gtk_widget_get_frame_clock (GtkWidget *widget);
294
295GDK_AVAILABLE_IN_ALL
296void gtk_widget_size_allocate (GtkWidget *widget,
297 const GtkAllocation *allocation,
298 int baseline);
299GDK_AVAILABLE_IN_ALL
300void gtk_widget_allocate (GtkWidget *widget,
301 int width,
302 int height,
303 int baseline,
304 GskTransform *transform);
305
306GDK_AVAILABLE_IN_ALL
307GtkSizeRequestMode gtk_widget_get_request_mode (GtkWidget *widget);
308GDK_AVAILABLE_IN_ALL
309void gtk_widget_measure (GtkWidget *widget,
310 GtkOrientation orientation,
311 int for_size,
312 int *minimum,
313 int *natural,
314 int *minimum_baseline,
315 int *natural_baseline);
316GDK_AVAILABLE_IN_ALL
317void gtk_widget_get_preferred_size (GtkWidget *widget,
318 GtkRequisition *minimum_size,
319 GtkRequisition *natural_size);
320
321GDK_AVAILABLE_IN_ALL
322void gtk_widget_set_layout_manager (GtkWidget *widget,
323 GtkLayoutManager *layout_manager);
324GDK_AVAILABLE_IN_ALL
325GtkLayoutManager * gtk_widget_get_layout_manager (GtkWidget *widget);
326
327GDK_AVAILABLE_IN_ALL
328void gtk_widget_class_set_layout_manager_type (GtkWidgetClass *widget_class,
329 GType type);
330GDK_AVAILABLE_IN_ALL
331GType gtk_widget_class_get_layout_manager_type (GtkWidgetClass *widget_class);
332
333GDK_AVAILABLE_IN_ALL
334void gtk_widget_class_add_binding (GtkWidgetClass *widget_class,
335 guint keyval,
336 GdkModifierType mods,
337 GtkShortcutFunc callback,
338 const char *format_string,
339 ...);
340GDK_AVAILABLE_IN_ALL
341void gtk_widget_class_add_binding_signal
342 (GtkWidgetClass *widget_class,
343 guint keyval,
344 GdkModifierType mods,
345 const char *signal,
346 const char *format_string,
347 ...);
348GDK_AVAILABLE_IN_ALL
349void gtk_widget_class_add_binding_action
350 (GtkWidgetClass *widget_class,
351 guint keyval,
352 GdkModifierType mods,
353 const char *action_name,
354 const char *format_string,
355 ...);
356GDK_AVAILABLE_IN_ALL
357void gtk_widget_class_add_shortcut (GtkWidgetClass *widget_class,
358 GtkShortcut *shortcut);
359
360GDK_AVAILABLE_IN_ALL
361void gtk_widget_class_set_activate_signal (GtkWidgetClass *widget_class,
362 guint signal_id);
363GDK_AVAILABLE_IN_ALL
364void gtk_widget_class_set_activate_signal_from_name (GtkWidgetClass *widget_class,
365 const char *signal_name);
366GDK_AVAILABLE_IN_ALL
367guint gtk_widget_class_get_activate_signal (GtkWidgetClass *widget_class);
368
369GDK_AVAILABLE_IN_ALL
370gboolean gtk_widget_mnemonic_activate (GtkWidget *widget,
371 gboolean group_cycling);
372GDK_AVAILABLE_IN_ALL
373gboolean gtk_widget_activate (GtkWidget *widget);
374
375GDK_AVAILABLE_IN_ALL
376void gtk_widget_set_can_focus (GtkWidget *widget,
377 gboolean can_focus);
378GDK_AVAILABLE_IN_ALL
379gboolean gtk_widget_get_can_focus (GtkWidget *widget);
380GDK_AVAILABLE_IN_ALL
381void gtk_widget_set_focusable (GtkWidget *widget,
382 gboolean focusable);
383GDK_AVAILABLE_IN_ALL
384gboolean gtk_widget_get_focusable (GtkWidget *widget);
385GDK_AVAILABLE_IN_ALL
386gboolean gtk_widget_has_focus (GtkWidget *widget);
387GDK_AVAILABLE_IN_ALL
388gboolean gtk_widget_is_focus (GtkWidget *widget);
389GDK_AVAILABLE_IN_ALL
390gboolean gtk_widget_has_visible_focus (GtkWidget *widget);
391GDK_AVAILABLE_IN_ALL
392gboolean gtk_widget_grab_focus (GtkWidget *widget);
393GDK_AVAILABLE_IN_ALL
394void gtk_widget_set_focus_on_click (GtkWidget *widget,
395 gboolean focus_on_click);
396GDK_AVAILABLE_IN_ALL
397gboolean gtk_widget_get_focus_on_click (GtkWidget *widget);
398
399GDK_AVAILABLE_IN_ALL
400void gtk_widget_set_can_target (GtkWidget *widget,
401 gboolean can_target);
402GDK_AVAILABLE_IN_ALL
403gboolean gtk_widget_get_can_target (GtkWidget *widget);
404
405GDK_AVAILABLE_IN_ALL
406gboolean gtk_widget_has_default (GtkWidget *widget);
407
408GDK_AVAILABLE_IN_ALL
409void gtk_widget_set_receives_default (GtkWidget *widget,
410 gboolean receives_default);
411GDK_AVAILABLE_IN_ALL
412gboolean gtk_widget_get_receives_default (GtkWidget *widget);
413
414
415GDK_AVAILABLE_IN_ALL
416void gtk_widget_set_name (GtkWidget *widget,
417 const char *name);
418GDK_AVAILABLE_IN_ALL
419const char * gtk_widget_get_name (GtkWidget *widget);
420
421
422GDK_AVAILABLE_IN_ALL
423void gtk_widget_set_state_flags (GtkWidget *widget,
424 GtkStateFlags flags,
425 gboolean clear);
426GDK_AVAILABLE_IN_ALL
427void gtk_widget_unset_state_flags (GtkWidget *widget,
428 GtkStateFlags flags);
429GDK_AVAILABLE_IN_ALL
430GtkStateFlags gtk_widget_get_state_flags (GtkWidget *widget);
431
432GDK_AVAILABLE_IN_ALL
433void gtk_widget_set_sensitive (GtkWidget *widget,
434 gboolean sensitive);
435GDK_AVAILABLE_IN_ALL
436gboolean gtk_widget_get_sensitive (GtkWidget *widget);
437GDK_AVAILABLE_IN_ALL
438gboolean gtk_widget_is_sensitive (GtkWidget *widget);
439
440GDK_AVAILABLE_IN_ALL
441void gtk_widget_set_visible (GtkWidget *widget,
442 gboolean visible);
443GDK_AVAILABLE_IN_ALL
444gboolean gtk_widget_get_visible (GtkWidget *widget);
445GDK_AVAILABLE_IN_ALL
446gboolean gtk_widget_is_visible (GtkWidget *widget);
447
448GDK_AVAILABLE_IN_ALL
449gboolean gtk_widget_is_drawable (GtkWidget *widget);
450GDK_AVAILABLE_IN_ALL
451gboolean gtk_widget_get_realized (GtkWidget *widget);
452GDK_AVAILABLE_IN_ALL
453gboolean gtk_widget_get_mapped (GtkWidget *widget);
454
455GDK_AVAILABLE_IN_ALL
456void gtk_widget_set_parent (GtkWidget *widget,
457 GtkWidget *parent);
458GDK_AVAILABLE_IN_ALL
459GtkWidget * gtk_widget_get_parent (GtkWidget *widget);
460
461GDK_AVAILABLE_IN_ALL
462GtkRoot * gtk_widget_get_root (GtkWidget *widget);
463
464GDK_AVAILABLE_IN_ALL
465GtkNative * gtk_widget_get_native (GtkWidget *widget);
466
467GDK_AVAILABLE_IN_ALL
468void gtk_widget_set_child_visible (GtkWidget *widget,
469 gboolean child_visible);
470GDK_AVAILABLE_IN_ALL
471gboolean gtk_widget_get_child_visible (GtkWidget *widget);
472
473GDK_AVAILABLE_IN_ALL
474int gtk_widget_get_allocated_width (GtkWidget *widget);
475GDK_AVAILABLE_IN_ALL
476int gtk_widget_get_allocated_height (GtkWidget *widget);
477GDK_AVAILABLE_IN_ALL
478int gtk_widget_get_allocated_baseline (GtkWidget *widget);
479
480GDK_AVAILABLE_IN_ALL
481void gtk_widget_get_allocation (GtkWidget *widget,
482 GtkAllocation *allocation);
483GDK_AVAILABLE_IN_ALL
484gboolean gtk_widget_compute_transform (GtkWidget *widget,
485 GtkWidget *target,
486 graphene_matrix_t *out_transform) G_GNUC_WARN_UNUSED_RESULT;
487GDK_AVAILABLE_IN_ALL
488gboolean gtk_widget_compute_bounds (GtkWidget *widget,
489 GtkWidget *target,
490 graphene_rect_t *out_bounds) G_GNUC_WARN_UNUSED_RESULT;
491GDK_AVAILABLE_IN_ALL
492gboolean gtk_widget_compute_point (GtkWidget *widget,
493 GtkWidget *target,
494 const graphene_point_t *point,
495 graphene_point_t *out_point) G_GNUC_WARN_UNUSED_RESULT;
496
497GDK_AVAILABLE_IN_ALL
498int gtk_widget_get_width (GtkWidget *widget);
499GDK_AVAILABLE_IN_ALL
500int gtk_widget_get_height (GtkWidget *widget);
501GDK_AVAILABLE_IN_ALL
502int gtk_widget_get_size (GtkWidget *widget,
503 GtkOrientation orientation);
504
505GDK_AVAILABLE_IN_ALL
506gboolean gtk_widget_child_focus (GtkWidget *widget,
507 GtkDirectionType direction);
508GDK_AVAILABLE_IN_ALL
509gboolean gtk_widget_keynav_failed (GtkWidget *widget,
510 GtkDirectionType direction);
511GDK_AVAILABLE_IN_ALL
512void gtk_widget_error_bell (GtkWidget *widget);
513
514GDK_AVAILABLE_IN_ALL
515void gtk_widget_set_size_request (GtkWidget *widget,
516 int width,
517 int height);
518GDK_AVAILABLE_IN_ALL
519void gtk_widget_get_size_request (GtkWidget *widget,
520 int *width,
521 int *height);
522GDK_AVAILABLE_IN_ALL
523void gtk_widget_set_opacity (GtkWidget *widget,
524 double opacity);
525GDK_AVAILABLE_IN_ALL
526double gtk_widget_get_opacity (GtkWidget *widget);
527GDK_AVAILABLE_IN_ALL
528void gtk_widget_set_overflow (GtkWidget *widget,
529 GtkOverflow overflow);
530GDK_AVAILABLE_IN_ALL
531GtkOverflow gtk_widget_get_overflow (GtkWidget *widget);
532
533GDK_AVAILABLE_IN_ALL
534GtkWidget* gtk_widget_get_ancestor (GtkWidget *widget,
535 GType widget_type);
536
537GDK_AVAILABLE_IN_ALL
538int gtk_widget_get_scale_factor (GtkWidget *widget);
539GDK_AVAILABLE_IN_ALL
540GdkDisplay * gtk_widget_get_display (GtkWidget *widget);
541GDK_AVAILABLE_IN_ALL
542GtkSettings* gtk_widget_get_settings (GtkWidget *widget);
543GDK_AVAILABLE_IN_ALL
544GdkClipboard *gtk_widget_get_clipboard (GtkWidget *widget);
545GDK_AVAILABLE_IN_ALL
546GdkClipboard *gtk_widget_get_primary_clipboard (GtkWidget *widget);
547
548
549/* Expand flags and related support */
550GDK_AVAILABLE_IN_ALL
551gboolean gtk_widget_get_hexpand (GtkWidget *widget);
552GDK_AVAILABLE_IN_ALL
553void gtk_widget_set_hexpand (GtkWidget *widget,
554 gboolean expand);
555GDK_AVAILABLE_IN_ALL
556gboolean gtk_widget_get_hexpand_set (GtkWidget *widget);
557GDK_AVAILABLE_IN_ALL
558void gtk_widget_set_hexpand_set (GtkWidget *widget,
559 gboolean set);
560GDK_AVAILABLE_IN_ALL
561gboolean gtk_widget_get_vexpand (GtkWidget *widget);
562GDK_AVAILABLE_IN_ALL
563void gtk_widget_set_vexpand (GtkWidget *widget,
564 gboolean expand);
565GDK_AVAILABLE_IN_ALL
566gboolean gtk_widget_get_vexpand_set (GtkWidget *widget);
567GDK_AVAILABLE_IN_ALL
568void gtk_widget_set_vexpand_set (GtkWidget *widget,
569 gboolean set);
570GDK_AVAILABLE_IN_ALL
571gboolean gtk_widget_compute_expand (GtkWidget *widget,
572 GtkOrientation orientation);
573
574/* Margin and alignment */
575GDK_AVAILABLE_IN_ALL
576GtkAlign gtk_widget_get_halign (GtkWidget *widget);
577GDK_AVAILABLE_IN_ALL
578void gtk_widget_set_halign (GtkWidget *widget,
579 GtkAlign align);
580GDK_AVAILABLE_IN_ALL
581GtkAlign gtk_widget_get_valign (GtkWidget *widget);
582GDK_AVAILABLE_IN_ALL
583void gtk_widget_set_valign (GtkWidget *widget,
584 GtkAlign align);
585GDK_AVAILABLE_IN_ALL
586int gtk_widget_get_margin_start (GtkWidget *widget);
587GDK_AVAILABLE_IN_ALL
588void gtk_widget_set_margin_start (GtkWidget *widget,
589 int margin);
590GDK_AVAILABLE_IN_ALL
591int gtk_widget_get_margin_end (GtkWidget *widget);
592GDK_AVAILABLE_IN_ALL
593void gtk_widget_set_margin_end (GtkWidget *widget,
594 int margin);
595GDK_AVAILABLE_IN_ALL
596int gtk_widget_get_margin_top (GtkWidget *widget);
597GDK_AVAILABLE_IN_ALL
598void gtk_widget_set_margin_top (GtkWidget *widget,
599 int margin);
600GDK_AVAILABLE_IN_ALL
601int gtk_widget_get_margin_bottom (GtkWidget *widget);
602GDK_AVAILABLE_IN_ALL
603void gtk_widget_set_margin_bottom (GtkWidget *widget,
604 int margin);
605
606GDK_AVAILABLE_IN_ALL
607gboolean gtk_widget_is_ancestor (GtkWidget *widget,
608 GtkWidget *ancestor);
609
610GDK_AVAILABLE_IN_ALL
611gboolean gtk_widget_translate_coordinates (GtkWidget *src_widget,
612 GtkWidget *dest_widget,
613 double src_x,
614 double src_y,
615 double *dest_x,
616 double *dest_y);
617
618GDK_AVAILABLE_IN_ALL
619gboolean gtk_widget_contains (GtkWidget *widget,
620 double x,
621 double y);
622GDK_AVAILABLE_IN_ALL
623GtkWidget * gtk_widget_pick (GtkWidget *widget,
624 double x,
625 double y,
626 GtkPickFlags flags);
627
628GDK_AVAILABLE_IN_ALL
629void gtk_widget_add_controller (GtkWidget *widget,
630 GtkEventController *controller);
631GDK_AVAILABLE_IN_ALL
632void gtk_widget_remove_controller (GtkWidget *widget,
633 GtkEventController *controller);
634
635GDK_AVAILABLE_IN_ALL
636PangoContext *gtk_widget_create_pango_context (GtkWidget *widget);
637GDK_AVAILABLE_IN_ALL
638PangoContext *gtk_widget_get_pango_context (GtkWidget *widget);
639GDK_AVAILABLE_IN_ALL
640void gtk_widget_set_font_options (GtkWidget *widget,
641 const cairo_font_options_t *options);
642GDK_AVAILABLE_IN_ALL
643const cairo_font_options_t *gtk_widget_get_font_options (GtkWidget *widget);
644GDK_AVAILABLE_IN_ALL
645PangoLayout *gtk_widget_create_pango_layout (GtkWidget *widget,
646 const char *text);
647
648/* Functions for setting directionality for widgets */
649
650GDK_AVAILABLE_IN_ALL
651void gtk_widget_set_direction (GtkWidget *widget,
652 GtkTextDirection dir);
653GDK_AVAILABLE_IN_ALL
654GtkTextDirection gtk_widget_get_direction (GtkWidget *widget);
655
656GDK_AVAILABLE_IN_ALL
657void gtk_widget_set_default_direction (GtkTextDirection dir);
658GDK_AVAILABLE_IN_ALL
659GtkTextDirection gtk_widget_get_default_direction (void);
660
661GDK_AVAILABLE_IN_ALL
662void gtk_widget_set_cursor (GtkWidget *widget,
663 GdkCursor *cursor);
664GDK_AVAILABLE_IN_ALL
665void gtk_widget_set_cursor_from_name (GtkWidget *widget,
666 const char *name);
667GDK_AVAILABLE_IN_ALL
668GdkCursor * gtk_widget_get_cursor (GtkWidget *widget);
669
670GDK_AVAILABLE_IN_ALL
671GList* gtk_widget_list_mnemonic_labels (GtkWidget *widget);
672GDK_AVAILABLE_IN_ALL
673void gtk_widget_add_mnemonic_label (GtkWidget *widget,
674 GtkWidget *label);
675GDK_AVAILABLE_IN_ALL
676void gtk_widget_remove_mnemonic_label (GtkWidget *widget,
677 GtkWidget *label);
678
679GDK_AVAILABLE_IN_ALL
680void gtk_widget_trigger_tooltip_query (GtkWidget *widget);
681GDK_AVAILABLE_IN_ALL
682void gtk_widget_set_tooltip_text (GtkWidget *widget,
683 const char *text);
684GDK_AVAILABLE_IN_ALL
685const char * gtk_widget_get_tooltip_text (GtkWidget *widget);
686GDK_AVAILABLE_IN_ALL
687void gtk_widget_set_tooltip_markup (GtkWidget *widget,
688 const char *markup);
689GDK_AVAILABLE_IN_ALL
690const char * gtk_widget_get_tooltip_markup (GtkWidget *widget);
691GDK_AVAILABLE_IN_ALL
692void gtk_widget_set_has_tooltip (GtkWidget *widget,
693 gboolean has_tooltip);
694GDK_AVAILABLE_IN_ALL
695gboolean gtk_widget_get_has_tooltip (GtkWidget *widget);
696
697GDK_AVAILABLE_IN_ALL
698GType gtk_requisition_get_type (void) G_GNUC_CONST;
699GDK_AVAILABLE_IN_ALL
700GtkRequisition *gtk_requisition_new (void) G_GNUC_MALLOC;
701GDK_AVAILABLE_IN_ALL
702GtkRequisition *gtk_requisition_copy (const GtkRequisition *requisition);
703GDK_AVAILABLE_IN_ALL
704void gtk_requisition_free (GtkRequisition *requisition);
705
706GDK_AVAILABLE_IN_ALL
707gboolean gtk_widget_in_destruction (GtkWidget *widget);
708
709GDK_AVAILABLE_IN_ALL
710GtkStyleContext * gtk_widget_get_style_context (GtkWidget *widget);
711
712GDK_AVAILABLE_IN_ALL
713void gtk_widget_class_set_css_name (GtkWidgetClass *widget_class,
714 const char *name);
715GDK_AVAILABLE_IN_ALL
716const char * gtk_widget_class_get_css_name (GtkWidgetClass *widget_class);
717
718GDK_AVAILABLE_IN_ALL
719guint gtk_widget_add_tick_callback (GtkWidget *widget,
720 GtkTickCallback callback,
721 gpointer user_data,
722 GDestroyNotify notify);
723
724GDK_AVAILABLE_IN_ALL
725void gtk_widget_remove_tick_callback (GtkWidget *widget,
726 guint id);
727
728/**
729 * gtk_widget_class_bind_template_callback:
730 * @widget_class: a `GtkWidgetClass`
731 * @callback: the callback symbol
732 *
733 * Binds a callback function defined in a template to the @widget_class.
734 *
735 * This macro is a convenience wrapper around the
736 * gtk_widget_class_bind_template_callback_full() function. It is not
737 * supported after gtk_widget_class_set_template_scope() has been used
738 * on @widget_class.
739 */
740#define gtk_widget_class_bind_template_callback(widget_class, callback) \
741 gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (widget_class), \
742 #callback, \
743 G_CALLBACK (callback))
744
745/**
746 * gtk_widget_class_bind_template_child:
747 * @widget_class: a `GtkWidgetClass`
748 * @TypeName: the type name of this widget
749 * @member_name: name of the instance member in the instance struct for @data_type
750 *
751 * Binds a child widget defined in a template to the @widget_class.
752 *
753 * This macro is a convenience wrapper around the
754 * gtk_widget_class_bind_template_child_full() function.
755 *
756 * This macro will use the offset of the @member_name inside the @TypeName
757 * instance structure.
758 */
759#define gtk_widget_class_bind_template_child(widget_class, TypeName, member_name) \
760 gtk_widget_class_bind_template_child_full (widget_class, \
761 #member_name, \
762 FALSE, \
763 G_STRUCT_OFFSET (TypeName, member_name))
764
765/**
766 * gtk_widget_class_bind_template_child_internal:
767 * @widget_class: a `GtkWidgetClass`
768 * @TypeName: the type name, in CamelCase
769 * @member_name: name of the instance member in the instance struct for @data_type
770 *
771 * Binds a child widget defined in a template to the @widget_class, and
772 * also makes it available as an internal child in GtkBuilder, under the
773 * name @member_name.
774 *
775 * This macro is a convenience wrapper around the
776 * gtk_widget_class_bind_template_child_full() function.
777 *
778 * This macro will use the offset of the @member_name inside the @TypeName
779 * instance structure.
780 */
781#define gtk_widget_class_bind_template_child_internal(widget_class, TypeName, member_name) \
782 gtk_widget_class_bind_template_child_full (widget_class, \
783 #member_name, \
784 TRUE, \
785 G_STRUCT_OFFSET (TypeName, member_name))
786
787/**
788 * gtk_widget_class_bind_template_child_private:
789 * @widget_class: a `GtkWidgetClass`
790 * @TypeName: the type name of this widget
791 * @member_name: name of the instance private member in the private struct for @data_type
792 *
793 * Binds a child widget defined in a template to the @widget_class.
794 *
795 * This macro is a convenience wrapper around the
796 * gtk_widget_class_bind_template_child_full() function.
797 *
798 * This macro will use the offset of the @member_name inside the @TypeName
799 * private data structure (it uses G_PRIVATE_OFFSET(), so the private struct
800 * must be added with G_ADD_PRIVATE()).
801 */
802#define gtk_widget_class_bind_template_child_private(widget_class, TypeName, member_name) \
803 gtk_widget_class_bind_template_child_full (widget_class, \
804 #member_name, \
805 FALSE, \
806 G_PRIVATE_OFFSET (TypeName, member_name))
807
808/**
809 * gtk_widget_class_bind_template_child_internal_private:
810 * @widget_class: a `GtkWidgetClass`
811 * @TypeName: the type name, in CamelCase
812 * @member_name: name of the instance private member on the private struct for @data_type
813 *
814 * Binds a child widget defined in a template to the @widget_class, and
815 * also makes it available as an internal child in GtkBuilder, under the
816 * name @member_name.
817 *
818 * This macro is a convenience wrapper around the
819 * gtk_widget_class_bind_template_child_full() function.
820 *
821 * This macro will use the offset of the @member_name inside the @TypeName
822 * private data structure.
823 */
824#define gtk_widget_class_bind_template_child_internal_private(widget_class, TypeName, member_name) \
825 gtk_widget_class_bind_template_child_full (widget_class, \
826 #member_name, \
827 TRUE, \
828 G_PRIVATE_OFFSET (TypeName, member_name))
829
830GDK_AVAILABLE_IN_ALL
831void gtk_widget_init_template (GtkWidget *widget);
832GDK_AVAILABLE_IN_ALL
833GObject *gtk_widget_get_template_child (GtkWidget *widget,
834 GType widget_type,
835 const char *name);
836GDK_AVAILABLE_IN_ALL
837void gtk_widget_class_set_template (GtkWidgetClass *widget_class,
838 GBytes *template_bytes);
839GDK_AVAILABLE_IN_ALL
840void gtk_widget_class_set_template_from_resource (GtkWidgetClass *widget_class,
841 const char *resource_name);
842GDK_AVAILABLE_IN_ALL
843void gtk_widget_class_bind_template_callback_full (GtkWidgetClass *widget_class,
844 const char *callback_name,
845 GCallback callback_symbol);
846GDK_AVAILABLE_IN_ALL
847void gtk_widget_class_set_template_scope (GtkWidgetClass *widget_class,
848 GtkBuilderScope *scope);
849GDK_AVAILABLE_IN_ALL
850void gtk_widget_class_bind_template_child_full (GtkWidgetClass *widget_class,
851 const char *name,
852 gboolean internal_child,
853 gssize struct_offset);
854
855GDK_AVAILABLE_IN_ALL
856void gtk_widget_insert_action_group (GtkWidget *widget,
857 const char *name,
858 GActionGroup *group);
859
860GDK_AVAILABLE_IN_ALL
861gboolean gtk_widget_activate_action (GtkWidget *widget,
862 const char *name,
863 const char *format_string,
864 ...);
865GDK_AVAILABLE_IN_ALL
866gboolean gtk_widget_activate_action_variant (GtkWidget *widget,
867 const char *name,
868 GVariant *args);
869
870GDK_AVAILABLE_IN_ALL
871void gtk_widget_activate_default (GtkWidget *widget);
872
873GDK_AVAILABLE_IN_ALL
874void gtk_widget_set_font_map (GtkWidget *widget,
875 PangoFontMap *font_map);
876GDK_AVAILABLE_IN_ALL
877PangoFontMap * gtk_widget_get_font_map (GtkWidget *widget);
878
879GDK_AVAILABLE_IN_ALL
880GtkWidget * gtk_widget_get_first_child (GtkWidget *widget);
881GDK_AVAILABLE_IN_ALL
882GtkWidget * gtk_widget_get_last_child (GtkWidget *widget);
883GDK_AVAILABLE_IN_ALL
884GtkWidget * gtk_widget_get_next_sibling (GtkWidget *widget);
885GDK_AVAILABLE_IN_ALL
886GtkWidget * gtk_widget_get_prev_sibling (GtkWidget *widget);
887GDK_AVAILABLE_IN_ALL
888GListModel * gtk_widget_observe_children (GtkWidget *widget);
889GDK_AVAILABLE_IN_ALL
890GListModel * gtk_widget_observe_controllers (GtkWidget *widget);
891GDK_AVAILABLE_IN_ALL
892void gtk_widget_insert_after (GtkWidget *widget,
893 GtkWidget *parent,
894 GtkWidget *previous_sibling);
895GDK_AVAILABLE_IN_ALL
896void gtk_widget_insert_before (GtkWidget *widget,
897 GtkWidget *parent,
898 GtkWidget *next_sibling);
899GDK_AVAILABLE_IN_ALL
900void gtk_widget_set_focus_child (GtkWidget *widget,
901 GtkWidget *child);
902GDK_AVAILABLE_IN_ALL
903GtkWidget * gtk_widget_get_focus_child (GtkWidget *widget);
904
905GDK_AVAILABLE_IN_ALL
906void gtk_widget_snapshot_child (GtkWidget *widget,
907 GtkWidget *child,
908 GtkSnapshot *snapshot);
909GDK_AVAILABLE_IN_ALL
910gboolean gtk_widget_should_layout (GtkWidget *widget);
911GDK_AVAILABLE_IN_ALL
912const char * gtk_widget_get_css_name (GtkWidget *self) G_GNUC_PURE;
913GDK_AVAILABLE_IN_ALL
914void gtk_widget_add_css_class (GtkWidget *widget,
915 const char *css_class);
916GDK_AVAILABLE_IN_ALL
917void gtk_widget_remove_css_class (GtkWidget *widget,
918 const char *css_class);
919GDK_AVAILABLE_IN_ALL
920gboolean gtk_widget_has_css_class (GtkWidget *widget,
921 const char *css_class);
922GDK_AVAILABLE_IN_ALL
923char ** gtk_widget_get_css_classes (GtkWidget *widget);
924GDK_AVAILABLE_IN_ALL
925void gtk_widget_set_css_classes (GtkWidget *widget,
926 const char **classes);
927
928
929
930
931/**
932 * GtkWidgetActionActivateFunc:
933 * @widget: the widget to which the action belongs
934 * @action_name: the action name
935 * @parameter: parameter for activation
936 *
937 * The type of the callback functions used for activating
938 * actions installed with gtk_widget_class_install_action().
939 *
940 * The @parameter must match the @parameter_type of the action.
941 */
942typedef void (* GtkWidgetActionActivateFunc) (GtkWidget *widget,
943 const char *action_name,
944 GVariant *parameter);
945
946GDK_AVAILABLE_IN_ALL
947void gtk_widget_class_install_action (GtkWidgetClass *widget_class,
948 const char *action_name,
949 const char *parameter_type,
950 GtkWidgetActionActivateFunc activate);
951
952GDK_AVAILABLE_IN_ALL
953void gtk_widget_class_install_property_action (GtkWidgetClass *widget_class,
954 const char *action_name,
955 const char *property_name);
956
957GDK_AVAILABLE_IN_ALL
958gboolean gtk_widget_class_query_action (GtkWidgetClass *widget_class,
959 guint index_,
960 GType *owner,
961 const char **action_name,
962 const GVariantType **parameter_type,
963 const char **property_name);
964
965GDK_AVAILABLE_IN_ALL
966void gtk_widget_action_set_enabled (GtkWidget *widget,
967 const char *action_name,
968 gboolean enabled);
969
970
971GDK_AVAILABLE_IN_ALL
972void gtk_widget_class_set_accessible_role (GtkWidgetClass *widget_class,
973 GtkAccessibleRole accessible_role);
974GDK_AVAILABLE_IN_ALL
975GtkAccessibleRole gtk_widget_class_get_accessible_role (GtkWidgetClass *widget_class);
976
977G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkWidget, g_object_unref)
978G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkRequisition, gtk_requisition_free)
979
980G_END_DECLS
981
982#endif /* __GTK_WIDGET_H__ */
983

source code of gtk/gtk/gtkwidget.h