summaryrefslogtreecommitdiff
path: root/gtk/gtkcssgadgetprivate.h
blob: fa3c40902884ae4b3cdd252038cc4608f005ecd5 (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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/*
 * Copyright © 2015 Red Hat Inc.
 *
 * 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/>.
 *
 * Authors: Benjamin Otte <otte@gnome.org>
 */

#ifndef __GTK_CSS_GADGET_PRIVATE_H__
#define __GTK_CSS_GADGET_PRIVATE_H__

#include <cairo.h>
#include <glib-object.h>

#include "gtk/gtkwidget.h"
#include "gtk/gtkcssstylechangeprivate.h"
#include "gtk/gtkcsstypesprivate.h"

G_BEGIN_DECLS

#define GTK_TYPE_CSS_GADGET           (gtk_css_gadget_get_type ())
#define GTK_CSS_GADGET(obj)           (G_TYPE_CHECK_INSTANCE_CAST (obj, GTK_TYPE_CSS_GADGET, GtkCssGadget))
#define GTK_CSS_GADGET_CLASS(cls)     (G_TYPE_CHECK_CLASS_CAST (cls, GTK_TYPE_CSS_GADGET, GtkCssGadgetClass))
#define GTK_IS_CSS_GADGET(obj)        (G_TYPE_CHECK_INSTANCE_TYPE (obj, GTK_TYPE_CSS_GADGET))
#define GTK_IS_CSS_GADGET_CLASS(obj)  (G_TYPE_CHECK_CLASS_TYPE (obj, GTK_TYPE_CSS_GADGET))
#define GTK_CSS_GADGET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_CSS_GADGET, GtkCssGadgetClass))

typedef struct _GtkCssGadget           GtkCssGadget;
typedef struct _GtkCssGadgetClass      GtkCssGadgetClass;

struct _GtkCssGadget
{
  GObject parent;
};

struct _GtkCssGadgetClass
{
  GObjectClass  parent_class;

  void          (* get_preferred_size)                  (GtkCssGadget           *gadget,
                                                         GtkOrientation          orientation,
                                                         gint                    for_size,
                                                         gint                   *minimum,
                                                         gint                   *natural,
                                                         gint                   *minimum_baseline,
                                                         gint                   *natural_baseline);

  void          (* allocate)                            (GtkCssGadget           *gadget,
                                                         const GtkAllocation    *allocation,
                                                         int                     baseline,
                                                         GtkAllocation          *out_clip);

  gboolean      (* draw)                                (GtkCssGadget           *gadget,
                                                         cairo_t                *cr,
                                                         int                     x,
                                                         int                     y,
                                                         int                     width,
                                                         int                     height);

  void          (* style_changed)                       (GtkCssGadget           *gadget,
                                                         GtkCssStyleChange      *change);
};

GType           gtk_css_gadget_get_type                 (void) G_GNUC_CONST;

GtkCssNode *    gtk_css_gadget_get_node                 (GtkCssGadget           *gadget);
GtkCssStyle *   gtk_css_gadget_get_style                (GtkCssGadget           *gadget);
GtkWidget *     gtk_css_gadget_get_owner                (GtkCssGadget           *gadget);

void            gtk_css_gadget_set_node                 (GtkCssGadget           *gadget,
                                                         GtkCssNode             *node);
void            gtk_css_gadget_set_visible              (GtkCssGadget           *gadget,
                                                         gboolean                visible);
gboolean        gtk_css_gadget_get_visible              (GtkCssGadget           *gadget);

gboolean        gtk_css_gadget_margin_box_contains_point (GtkCssGadget          *gadget,
                                                          int                    x,
                                                          int                    y);
gboolean        gtk_css_gadget_border_box_contains_point (GtkCssGadget          *gadget,
                                                          int                    x,
                                                          int                    y);
gboolean        gtk_css_gadget_content_box_contains_point (GtkCssGadget         *gadget,
                                                           int                   x,
                                                           int                   y);
void            gtk_css_gadget_get_margin_box           (GtkCssGadget           *gadget,
                                                         GtkAllocation          *box);
void            gtk_css_gadget_get_border_box           (GtkCssGadget           *gadget,
                                                         GtkAllocation          *box);
void            gtk_css_gadget_get_content_box          (GtkCssGadget           *gadget,
                                                         GtkAllocation          *box);

void            gtk_css_gadget_add_class                (GtkCssGadget           *gadget,
                                                         const char             *name);
void            gtk_css_gadget_remove_class             (GtkCssGadget           *gadget,
                                                         const char             *name);
void            gtk_css_gadget_set_state                (GtkCssGadget           *gadget,
                                                         GtkStateFlags           state);
void            gtk_css_gadget_add_state                (GtkCssGadget           *gadget,
                                                         GtkStateFlags           state);
void            gtk_css_gadget_remove_state             (GtkCssGadget           *gadget,
                                                         GtkStateFlags           state);

void            gtk_css_gadget_get_preferred_size       (GtkCssGadget           *gadget,
                                                         GtkOrientation          orientation,
                                                         gint                    for_size,
                                                         gint                   *minimum,
                                                         gint                   *natural,
                                                         gint                   *minimum_baseline,
                                                         gint                   *natural_baseline);
void            gtk_css_gadget_allocate                 (GtkCssGadget           *gadget,
                                                         const GtkAllocation    *allocation,
                                                         int                     baseline,
                                                         GtkAllocation          *out_clip);
void            gtk_css_gadget_draw                     (GtkCssGadget           *gadget,
                                                         cairo_t                *cr);

void            gtk_css_gadget_queue_resize             (GtkCssGadget           *gadget);
void            gtk_css_gadget_queue_allocate           (GtkCssGadget           *gadget);
void            gtk_css_gadget_queue_draw               (GtkCssGadget           *gadget);

void            gtk_css_gadget_get_margin_allocation    (GtkCssGadget           *gadget,
                                                         GtkAllocation          *allocation,
                                                         int                    *baseline);
void            gtk_css_gadget_get_border_allocation    (GtkCssGadget           *gadget,
                                                         GtkAllocation          *allocation,
                                                         int                    *baseline);
void            gtk_css_gadget_get_content_allocation   (GtkCssGadget           *gadget,
                                                         GtkAllocation          *allocation,
                                                         int                    *baseline);

G_END_DECLS

#endif /* __GTK_CSS_GADGET_PRIVATE_H__ */