summaryrefslogtreecommitdiff
path: root/gtk/gtklayoutmanager.h
blob: 676edcd4ffeec725282b5b45e32cf5b135ad71ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/* gtklayoutmanager.h: Layout manager base class
 * Copyright 2019  The GNOME Foundation
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
 *
 * Author: Emmanuele Bassi
 */
#pragma once

#include <gsk/gsk.h>
#include <gtk/gtktypes.h>
#include <gtk/gtkwidget.h>
#include <gtk/gtklayoutchild.h>

G_BEGIN_DECLS

#define GTK_TYPE_LAYOUT_MANAGER (gtk_layout_manager_get_type ())

GDK_AVAILABLE_IN_ALL
G_DECLARE_DERIVABLE_TYPE (GtkLayoutManager, gtk_layout_manager, GTK, LAYOUT_MANAGER, GObject)

/**
 * GtkLayoutManagerClass:
 * @get_request_mode: a virtual function, used to return the preferred
 *   request mode for the layout manager; for instance, "width for height"
 *   or "height for width"; see `GtkSizeRequestMode`
 * @measure: a virtual function, used to measure the minimum and preferred
 *   sizes of the widget using the layout manager for a given orientation
 * @allocate: a virtual function, used to allocate the size of the widget
 *   using the layout manager
 * @layout_child_type: the type of `GtkLayoutChild` used by this layout manager
 * @create_layout_child: a virtual function, used to create a `GtkLayoutChild`
 *   meta object for the layout properties
 * @root: a virtual function, called when the widget using the layout
 *   manager is attached to a `GtkRoot`
 * @unroot: a virtual function, called when the widget using the layout
 *   manager is detached from a `GtkRoot`
 *
 * The `GtkLayoutManagerClass` structure contains only private data, and
 * should only be accessed through the provided API, or when subclassing
 * `GtkLayoutManager`.
 */
struct _GtkLayoutManagerClass
{
  /*< private >*/
  GObjectClass parent_class;

  /*< public >*/
  GtkSizeRequestMode (* get_request_mode)    (GtkLayoutManager *manager,
                                              GtkWidget        *widget);

  void               (* measure)             (GtkLayoutManager *manager,
                                              GtkWidget        *widget,
                                              GtkOrientation    orientation,
                                              int               for_size,
                                              int              *minimum,
                                              int              *natural,
                                              int              *minimum_baseline,
                                              int              *natural_baseline);

  void               (* allocate)            (GtkLayoutManager *manager,
                                              GtkWidget        *widget,
                                              int               width,
                                              int               height,
                                              int               baseline);

  GType              layout_child_type;

  /**
   * GtkLayoutManagerClass::create_layout_child:
   * @manager: the `GtkLayoutManager`
   * @widget: the widget using the @manager
   * @for_child: the child of @widget
   *
   * Create a `GtkLayoutChild` instance for the given @for_child widget.
   *
   * Returns: (transfer full): a `GtkLayoutChild`
   */
  GtkLayoutChild *   (* create_layout_child) (GtkLayoutManager *manager,
                                              GtkWidget        *widget,
                                              GtkWidget        *for_child);

  void               (* root)                (GtkLayoutManager *manager);
  void               (* unroot)              (GtkLayoutManager *manager);

  /*< private >*/
  gpointer _padding[16];
};

GDK_AVAILABLE_IN_ALL
void                    gtk_layout_manager_measure              (GtkLayoutManager *manager,
                                                                 GtkWidget        *widget,
                                                                 GtkOrientation    orientation,
                                                                 int               for_size,
                                                                 int              *minimum,
                                                                 int              *natural,
                                                                 int              *minimum_baseline,
                                                                 int              *natural_baseline);
GDK_AVAILABLE_IN_ALL
void                    gtk_layout_manager_allocate             (GtkLayoutManager *manager,
                                                                 GtkWidget        *widget,
                                                                 int               width,
                                                                 int               height,
                                                                 int               baseline);
GDK_AVAILABLE_IN_ALL
GtkSizeRequestMode      gtk_layout_manager_get_request_mode     (GtkLayoutManager *manager);

GDK_AVAILABLE_IN_ALL
GtkWidget *             gtk_layout_manager_get_widget           (GtkLayoutManager *manager);

GDK_AVAILABLE_IN_ALL
void                    gtk_layout_manager_layout_changed       (GtkLayoutManager *manager);

GDK_AVAILABLE_IN_ALL
GtkLayoutChild *        gtk_layout_manager_get_layout_child     (GtkLayoutManager *manager,
                                                                 GtkWidget        *child);

G_END_DECLS