1 | /* gtkcustomlayout.h: Simple layout manager |
2 | * Copyright 2019 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 | #pragma once |
18 | |
19 | #include <gtk/gtklayoutmanager.h> |
20 | |
21 | G_BEGIN_DECLS |
22 | |
23 | #define GTK_TYPE_CUSTOM_LAYOUT (gtk_custom_layout_get_type ()) |
24 | |
25 | /** |
26 | * GtkCustomRequestModeFunc: |
27 | * @widget: the widget to be queried |
28 | * |
29 | * Queries a widget for its preferred size request mode. |
30 | * |
31 | * Returns: the size request mode |
32 | */ |
33 | typedef GtkSizeRequestMode (* GtkCustomRequestModeFunc) (GtkWidget *widget); |
34 | |
35 | /** |
36 | * GtkCustomMeasureFunc: |
37 | * @widget: the widget to be measured |
38 | * @orientation: the direction to be measured |
39 | * @for_size: the size to be measured for |
40 | * @minimum: (out): the measured minimum size of the widget |
41 | * @natural: (out): the measured natural size of the widget |
42 | * @minimum_baseline: (out): the measured minimum baseline of the widget |
43 | * @natural_baseline: (out): the measured natural baseline of the widget |
44 | * |
45 | * A function to be used by `GtkCustomLayout` to measure a widget. |
46 | */ |
47 | typedef void (* GtkCustomMeasureFunc) (GtkWidget *widget, |
48 | GtkOrientation orientation, |
49 | int for_size, |
50 | int *minimum, |
51 | int *natural, |
52 | int *minimum_baseline, |
53 | int *natural_baseline); |
54 | |
55 | /** |
56 | * GtkCustomAllocateFunc: |
57 | * @widget: the widget to allocate |
58 | * @width: the new width of the widget |
59 | * @height: the new height of the widget |
60 | * @baseline: the new baseline of the widget, or -1 |
61 | * |
62 | * A function to be used by `GtkCustomLayout` to allocate a widget. |
63 | */ |
64 | typedef void (* GtkCustomAllocateFunc) (GtkWidget *widget, |
65 | int width, |
66 | int height, |
67 | int baseline); |
68 | |
69 | GDK_AVAILABLE_IN_ALL |
70 | G_DECLARE_FINAL_TYPE (GtkCustomLayout, gtk_custom_layout, GTK, CUSTOM_LAYOUT, GtkLayoutManager) |
71 | |
72 | GDK_AVAILABLE_IN_ALL |
73 | GtkLayoutManager * gtk_custom_layout_new (GtkCustomRequestModeFunc request_mode, |
74 | GtkCustomMeasureFunc measure, |
75 | GtkCustomAllocateFunc allocate); |
76 | |
77 | G_END_DECLS |
78 | |