Debian Codegraph @

gtk/src/range.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 #include <gtkmm/adjustment.h>
19
20 namespace Gtk
21 {
22
23 void Range::unset_adjustment()
24 {
25 gtk_range_set_adjustment(gobj(), nullptr);
26 }
27
28 void Range_Class::get_range_border_vfunc_callback(GtkRange* self, GtkBorder* border)
29 {
30 const auto obj_base = static_cast<Glib::ObjectBase*>(
31 Glib::ObjectBase::_get_current_wrapper((GObject*)self));
32
33 // Non-gtkmmproc-generated custom classes implicitly call the default
34 // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
35 // generated classes can use this optimisation, which avoids the unnecessary
36 // parameter conversions if there is no possibility of the virtual function
37 // being overridden:
38 if(obj_base && obj_base->is_derived_())
39 {
40 const auto obj = dynamic_cast<CppObjectType* const>(obj_base);
41 if(obj) // This can be NULL during destruction.
42 {
43 try // Trap C++ exceptions which would normally be lost because this is a C callback.
44 {
45 // Call the virtual member method, which derived classes might override.
46 Gtk::Border cxx_border(border, true);
47 obj->get_range_border_vfunc(cxx_border);
48 *border = *(cxx_border.gobj());
49 return;
50 }
51 catch(...)
52 {
53 Glib::exception_handlers_invoke();
54 }
55 }
56 }
57
58 const auto base = static_cast<BaseClassType*>(
59 g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
60 );
61
62 // Call the original underlying C function:
63 if(base && base->get_range_border)
64 (*base->get_range_border)(self, border);
65
66 }
67
68 Gdk::Rectangle Range::get_range_rect() const
69 {
70 Gdk::Rectangle result;
71 gtk_range_get_range_rect(const_cast<GtkRange*>(gobj()), result.gobj());
72 return result;
73 }
74
75 } // namespace Gtk