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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
|
#include "gtkgizmoprivate.h"
#include "gtkwidgetprivate.h"
G_DEFINE_TYPE (GtkGizmo, gtk_gizmo, GTK_TYPE_WIDGET);
static void
gtk_gizmo_measure (GtkWidget *widget,
GtkOrientation orientation,
int for_size,
int *minimum,
int *natural,
int *minimum_baseline,
int *natural_baseline)
{
GtkGizmo *self = GTK_GIZMO (widget);
if (self->measure_func)
self->measure_func (self, orientation, for_size,
minimum, natural,
minimum_baseline, natural_baseline);
}
static void
gtk_gizmo_size_allocate (GtkWidget *widget,
int width,
int height,
int baseline)
{
GtkGizmo *self = GTK_GIZMO (widget);
if (self->allocate_func)
self->allocate_func (self, width, height, baseline);
}
static void
gtk_gizmo_snapshot (GtkWidget *widget,
GtkSnapshot *snapshot)
{
GtkGizmo *self = GTK_GIZMO (widget);
if (self->snapshot_func)
self->snapshot_func (self, snapshot);
else
GTK_WIDGET_CLASS (gtk_gizmo_parent_class)->snapshot (widget, snapshot);
}
static gboolean
gtk_gizmo_contains (GtkWidget *widget,
double x,
double y)
{
GtkGizmo *self = GTK_GIZMO (widget);
if (self->contains_func)
return self->contains_func (self, x, y);
else
return GTK_WIDGET_CLASS (gtk_gizmo_parent_class)->contains (widget, x, y);
}
static gboolean
gtk_gizmo_focus (GtkWidget *widget,
GtkDirectionType direction)
{
GtkGizmo *self = GTK_GIZMO (widget);
if (self->focus_func)
return self->focus_func (self, direction);
return FALSE;
}
static gboolean
gtk_gizmo_grab_focus (GtkWidget *widget)
{
GtkGizmo *self = GTK_GIZMO (widget);
if (self->grab_focus_func)
return self->grab_focus_func (self);
return FALSE;
}
static void
gtk_gizmo_finalize (GObject *object)
{
GtkGizmo *self = GTK_GIZMO (object);
GtkWidget *widget;
widget = _gtk_widget_get_first_child (GTK_WIDGET (self));
while (widget != NULL)
{
GtkWidget *next = _gtk_widget_get_next_sibling (widget);
gtk_widget_unparent (widget);
widget = next;
}
G_OBJECT_CLASS (gtk_gizmo_parent_class)->finalize (object);
}
static void
gtk_gizmo_class_init (GtkGizmoClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
object_class->finalize = gtk_gizmo_finalize;
widget_class->measure = gtk_gizmo_measure;
widget_class->size_allocate = gtk_gizmo_size_allocate;
widget_class->snapshot = gtk_gizmo_snapshot;
widget_class->contains = gtk_gizmo_contains;
widget_class->grab_focus = gtk_gizmo_grab_focus;
widget_class->focus = gtk_gizmo_focus;
}
static void
gtk_gizmo_init (GtkGizmo *self)
{
}
GtkWidget *
gtk_gizmo_new (const char *css_name,
GtkGizmoMeasureFunc measure_func,
GtkGizmoAllocateFunc allocate_func,
GtkGizmoSnapshotFunc snapshot_func,
GtkGizmoContainsFunc contains_func,
GtkGizmoFocusFunc focus_func,
GtkGizmoGrabFocusFunc grab_focus_func)
{
return gtk_gizmo_new_with_role (css_name,
GTK_ACCESSIBLE_ROLE_WIDGET,
measure_func,
allocate_func,
snapshot_func,
contains_func,
focus_func,
grab_focus_func);
}
GtkWidget *
gtk_gizmo_new_with_role (const char *css_name,
GtkAccessibleRole role,
GtkGizmoMeasureFunc measure_func,
GtkGizmoAllocateFunc allocate_func,
GtkGizmoSnapshotFunc snapshot_func,
GtkGizmoContainsFunc contains_func,
GtkGizmoFocusFunc focus_func,
GtkGizmoGrabFocusFunc grab_focus_func)
{
GtkGizmo *gizmo = GTK_GIZMO (g_object_new (GTK_TYPE_GIZMO,
"css-name", css_name,
"accessible-role", role,
NULL));
gizmo->measure_func = measure_func;
gizmo->allocate_func = allocate_func;
gizmo->snapshot_func = snapshot_func;
gizmo->contains_func = contains_func;
gizmo->focus_func = focus_func;
gizmo->grab_focus_func = grab_focus_func;
return GTK_WIDGET (gizmo);
}
|