1/* gtklayoutmanager.h: Layout manager base class
2 * Copyright 2019 The GNOME Foundation
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.1 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 * Author: Emmanuele Bassi
18 */
19#pragma once
20
21#include <gsk/gsk.h>
22#include <gtk/gtktypes.h>
23#include <gtk/gtkwidget.h>
24#include <gtk/gtklayoutchild.h>
25
26G_BEGIN_DECLS
27
28#define GTK_TYPE_LAYOUT_MANAGER (gtk_layout_manager_get_type ())
29
30GDK_AVAILABLE_IN_ALL
31G_DECLARE_DERIVABLE_TYPE (GtkLayoutManager, gtk_layout_manager, GTK, LAYOUT_MANAGER, GObject)
32
33/**
34 * GtkLayoutManagerClass:
35 * @get_request_mode: a virtual function, used to return the preferred
36 * request mode for the layout manager; for instance, "width for height"
37 * or "height for width"; see `GtkSizeRequestMode`
38 * @measure: a virtual function, used to measure the minimum and preferred
39 * sizes of the widget using the layout manager for a given orientation
40 * @allocate: a virtual function, used to allocate the size of the widget
41 * using the layout manager
42 * @layout_child_type: the type of `GtkLayoutChild` used by this layout manager
43 * @create_layout_child: a virtual function, used to create a `GtkLayoutChild`
44 * meta object for the layout properties
45 * @root: a virtual function, called when the widget using the layout
46 * manager is attached to a `GtkRoot`
47 * @unroot: a virtual function, called when the widget using the layout
48 * manager is detached from a `GtkRoot`
49 *
50 * The `GtkLayoutManagerClass` structure contains only private data, and
51 * should only be accessed through the provided API, or when subclassing
52 * `GtkLayoutManager`.
53 */
54struct _GtkLayoutManagerClass
55{
56 /*< private >*/
57 GObjectClass parent_class;
58
59 /*< public >*/
60 GtkSizeRequestMode (* get_request_mode) (GtkLayoutManager *manager,
61 GtkWidget *widget);
62
63 void (* measure) (GtkLayoutManager *manager,
64 GtkWidget *widget,
65 GtkOrientation orientation,
66 int for_size,
67 int *minimum,
68 int *natural,
69 int *minimum_baseline,
70 int *natural_baseline);
71
72 void (* allocate) (GtkLayoutManager *manager,
73 GtkWidget *widget,
74 int width,
75 int height,
76 int baseline);
77
78 GType layout_child_type;
79
80 /**
81 * GtkLayoutManagerClass::create_layout_child:
82 * @manager: the `GtkLayoutManager`
83 * @widget: the widget using the @manager
84 * @for_child: the child of @widget
85 *
86 * Create a `GtkLayoutChild` instance for the given @for_child widget.
87 *
88 * Returns: (transfer full): a `GtkLayoutChild`
89 */
90 GtkLayoutChild * (* create_layout_child) (GtkLayoutManager *manager,
91 GtkWidget *widget,
92 GtkWidget *for_child);
93
94 void (* root) (GtkLayoutManager *manager);
95 void (* unroot) (GtkLayoutManager *manager);
96
97 /*< private >*/
98 gpointer _padding[16];
99};
100
101GDK_AVAILABLE_IN_ALL
102void gtk_layout_manager_measure (GtkLayoutManager *manager,
103 GtkWidget *widget,
104 GtkOrientation orientation,
105 int for_size,
106 int *minimum,
107 int *natural,
108 int *minimum_baseline,
109 int *natural_baseline);
110GDK_AVAILABLE_IN_ALL
111void gtk_layout_manager_allocate (GtkLayoutManager *manager,
112 GtkWidget *widget,
113 int width,
114 int height,
115 int baseline);
116GDK_AVAILABLE_IN_ALL
117GtkSizeRequestMode gtk_layout_manager_get_request_mode (GtkLayoutManager *manager);
118
119GDK_AVAILABLE_IN_ALL
120GtkWidget * gtk_layout_manager_get_widget (GtkLayoutManager *manager);
121
122GDK_AVAILABLE_IN_ALL
123void gtk_layout_manager_layout_changed (GtkLayoutManager *manager);
124
125GDK_AVAILABLE_IN_ALL
126GtkLayoutChild * gtk_layout_manager_get_layout_child (GtkLayoutManager *manager,
127 GtkWidget *child);
128
129G_END_DECLS
130

source code of gtk/gtk/gtklayoutmanager.h