Debian Codegraph @

gtk/src/cellrenderer.ccg

raw
1 /* Copyright (C) 1998-2002 The gtkmm Development Team
2 *
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; either
6 * version 2.1 of the License, or (at your option) any later version.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, see <https://www.gnu.org/licenses/>.
15 */
16
17 #include <gtk/gtk.h>
18
19 namespace Gtk
20 {
21
22 Glib::PropertyProxy_Base CellRenderer::_property_renderable()
23 {
24 g_assert_not_reached();
25 return Glib::PropertyProxy<int>(nullptr, nullptr); // shut up warnings
26 }
27
28 //These vfunc callbacks are custom implemented because we want the output
29 //arguments of the C++ vfuncs to be int& (not int*), and the vfunc_callback
30 //functions may be called from gtk+ with a NULL pointer.
31 void CellRenderer_Class::get_preferred_width_vfunc_callback(GtkCellRenderer* self, GtkWidget* widget, gint* minimum_width, gint* natural_width)
32 {
33 const auto obj_base = static_cast<Glib::ObjectBase*>(
34 Glib::ObjectBase::_get_current_wrapper((GObject*)self));
35
36 // Non-gtkmmproc-generated custom classes implicitly call the default
37 // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
38 // generated classes can use this optimisation, which avoids the unnecessary
39 // parameter conversions if there is no possibility of the virtual function
40 // being overridden:
41 if(obj_base && obj_base->is_derived_())
42 {
43 const auto obj = dynamic_cast<CppObjectType* const>(obj_base);
44 if(obj) // This can be NULL during destruction.
45 {
46 try // Trap C++ exceptions which would normally be lost because this is a C callback.
47 {
48 // Call the virtual member method, which derived classes might override.
49 int min_width = 0;
50 int nat_width = 0;
51 obj->get_preferred_width_vfunc(*Glib::wrap(widget),
52 (minimum_width ? *minimum_width : min_width),
53 (natural_width ? *natural_width : nat_width));
54 return;
55 }
56 catch(...)
57 {
58 Glib::exception_handlers_invoke();
59 }
60 }
61 }
62
63 const auto base = static_cast<BaseClassType*>(
64 g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
65 );
66
67 // Call the original underlying C function:
68 if(base && base->get_preferred_width)
69 (*base->get_preferred_width)(self, widget, minimum_width, natural_width);
70 }
71
72 void CellRenderer_Class::get_preferred_height_for_width_vfunc_callback(GtkCellRenderer* self, GtkWidget* widget, gint width, gint* minimum_height, gint* natural_height)
73 {
74 const auto obj_base = static_cast<Glib::ObjectBase*>(
75 Glib::ObjectBase::_get_current_wrapper((GObject*)self));
76
77 // Non-gtkmmproc-generated custom classes implicitly call the default
78 // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
79 // generated classes can use this optimisation, which avoids the unnecessary
80 // parameter conversions if there is no possibility of the virtual function
81 // being overridden:
82 if(obj_base && obj_base->is_derived_())
83 {
84 const auto obj = dynamic_cast<CppObjectType* const>(obj_base);
85 if(obj) // This can be NULL during destruction.
86 {
87 try // Trap C++ exceptions which would normally be lost because this is a C callback.
88 {
89 // Call the virtual member method, which derived classes might override.
90 int min_height = 0;
91 int nat_height = 0;
92 obj->get_preferred_height_for_width_vfunc(*Glib::wrap(widget), width,
93 (minimum_height ? *minimum_height : min_height),
94 (natural_height ? *natural_height : nat_height));
95 return;
96 }
97 catch(...)
98 {
99 Glib::exception_handlers_invoke();
100 }
101 }
102 }
103
104 const auto base = static_cast<BaseClassType*>(
105 g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
106 );
107
108 // Call the original underlying C function:
109 if(base && base->get_preferred_height_for_width)
110 (*base->get_preferred_height_for_width)(self, widget, width, minimum_height, natural_height);
111 }
112
113 void CellRenderer_Class::get_preferred_height_vfunc_callback(GtkCellRenderer* self, GtkWidget* widget, gint* minimum_height, gint* natural_height)
114 {
115 const auto obj_base = static_cast<Glib::ObjectBase*>(
116 Glib::ObjectBase::_get_current_wrapper((GObject*)self));
117
118 // Non-gtkmmproc-generated custom classes implicitly call the default
119 // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
120 // generated classes can use this optimisation, which avoids the unnecessary
121 // parameter conversions if there is no possibility of the virtual function
122 // being overridden:
123 if(obj_base && obj_base->is_derived_())
124 {
125 const auto obj = dynamic_cast<CppObjectType* const>(obj_base);
126 if(obj) // This can be NULL during destruction.
127 {
128 try // Trap C++ exceptions which would normally be lost because this is a C callback.
129 {
130 // Call the virtual member method, which derived classes might override.
131 int min_height = 0;
132 int nat_height = 0;
133 obj->get_preferred_height_vfunc(*Glib::wrap(widget),
134 (minimum_height ? *minimum_height : min_height),
135 (natural_height ? *natural_height : nat_height));
136 return;
137 }
138 catch(...)
139 {
140 Glib::exception_handlers_invoke();
141 }
142 }
143 }
144
145 const auto base = static_cast<BaseClassType*>(
146 g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
147 );
148
149 // Call the original underlying C function:
150 if(base && base->get_preferred_height)
151 (*base->get_preferred_height)(self, widget, minimum_height, natural_height);
152 }
153
154 void CellRenderer_Class::get_preferred_width_for_height_vfunc_callback(GtkCellRenderer* self, GtkWidget* widget, gint height, gint* minimum_width, gint* natural_width)
155 {
156 const auto obj_base = static_cast<Glib::ObjectBase*>(
157 Glib::ObjectBase::_get_current_wrapper((GObject*)self));
158
159 // Non-gtkmmproc-generated custom classes implicitly call the default
160 // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
161 // generated classes can use this optimisation, which avoids the unnecessary
162 // parameter conversions if there is no possibility of the virtual function
163 // being overridden:
164 if(obj_base && obj_base->is_derived_())
165 {
166 const auto obj = dynamic_cast<CppObjectType* const>(obj_base);
167 if(obj) // This can be NULL during destruction.
168 {
169 try // Trap C++ exceptions which would normally be lost because this is a C callback.
170 {
171 // Call the virtual member method, which derived classes might override.
172 int min_width = 0;
173 int nat_width = 0;
174 obj->get_preferred_width_for_height_vfunc(*Glib::wrap(widget), height,
175 (minimum_width ? *minimum_width : min_width),
176 (natural_width ? *natural_width : nat_width));
177 return;
178 }
179 catch(...)
180 {
181 Glib::exception_handlers_invoke();
182 }
183 }
184 }
185
186 const auto base = static_cast<BaseClassType*>(
187 g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
188 );
189
190 // Call the original underlying C function:
191 if(base && base->get_preferred_width_for_height)
192 (*base->get_preferred_width_for_height)(self, widget, height, minimum_width, natural_width);
193 }
194
195 } // namespace Gtk