~ubuntu-branches/ubuntu/precise/gtkmm3.0/precise

« back to all changes in this revision

Viewing changes to gtk/gtkmm/checkbutton.cc

  • Committer: Bazaar Package Importer
  • Author(s): Michael Biebl
  • Date: 2011-06-17 00:12:44 UTC
  • Revision ID: james.westby@ubuntu.com-20110617001244-9hl5an15hiaaahi6
Tags: upstream-3.0.1
ImportĀ upstreamĀ versionĀ 3.0.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Generated by gtkmmproc -- DO NOT MODIFY!
 
2
 
 
3
 
 
4
#include <gtkmm/checkbutton.h>
 
5
#include <gtkmm/private/checkbutton_p.h>
 
6
 
 
7
// -*- c++ -*-
 
8
/* $Id: checkbutton.ccg,v 1.1 2003/01/21 13:38:44 murrayc Exp $ */
 
9
 
 
10
/* 
 
11
 *
 
12
 * Copyright 1998-2002 The gtkmm Development Team
 
13
 *
 
14
 * This library is free software; you can redistribute it and/or
 
15
 * modify it under the terms of the GNU Lesser General Public
 
16
 * License as published by the Free Software Foundation; either
 
17
 * version 2.1 of the License, or (at your option) any later version.
 
18
 *
 
19
 * This library is distributed in the hope that it will be useful,
 
20
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
21
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
22
 * Lesser General Public License for more details.
 
23
 *
 
24
 * You should have received a copy of the GNU Lesser General Public
 
25
 * License along with this library; if not, write to the Free
 
26
 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
27
 */
 
28
 
 
29
#include <gtk/gtk.h>
 
30
 
 
31
namespace Gtk
 
32
{
 
33
 
 
34
CheckButton::CheckButton(const Glib::ustring& label, bool mnemonic)
 
35
:
 
36
  // Mark this class as non-derived to allow C++ vfuncs to be skipped.
 
37
  Glib::ObjectBase(0),
 
38
  Gtk::ToggleButton(Glib::ConstructParams(checkbutton_class_.init(), "label",label.c_str(),"use_underline",gboolean(mnemonic), static_cast<char*>(0)))
 
39
{}
 
40
 
 
41
} // namespace Gtk
 
42
 
 
43
 
 
44
namespace
 
45
{
 
46
} // anonymous namespace
 
47
 
 
48
 
 
49
namespace Glib
 
50
{
 
51
 
 
52
Gtk::CheckButton* wrap(GtkCheckButton* object, bool take_copy)
 
53
{
 
54
  return dynamic_cast<Gtk::CheckButton *> (Glib::wrap_auto ((GObject*)(object), take_copy));
 
55
}
 
56
 
 
57
} /* namespace Glib */
 
58
 
 
59
namespace Gtk
 
60
{
 
61
 
 
62
 
 
63
/* The *_Class implementation: */
 
64
 
 
65
const Glib::Class& CheckButton_Class::init()
 
66
{
 
67
  if(!gtype_) // create the GType if necessary
 
68
  {
 
69
    // Glib::Class has to know the class init function to clone custom types.
 
70
    class_init_func_ = &CheckButton_Class::class_init_function;
 
71
 
 
72
    // This is actually just optimized away, apparently with no harm.
 
73
    // Make sure that the parent type has been created.
 
74
    //CppClassParent::CppObjectType::get_type();
 
75
 
 
76
    // Create the wrapper type, with the same class/instance size as the base type.
 
77
    register_derived_type(gtk_check_button_get_type());
 
78
 
 
79
    // Add derived versions of interfaces, if the C type implements any interfaces:
 
80
 
 
81
  }
 
82
 
 
83
  return *this;
 
84
}
 
85
 
 
86
 
 
87
void CheckButton_Class::class_init_function(void* g_class, void* class_data)
 
88
{
 
89
  BaseClassType *const klass = static_cast<BaseClassType*>(g_class);
 
90
  CppClassParent::class_init_function(klass, class_data);
 
91
 
 
92
  klass->draw_indicator = &draw_indicator_vfunc_callback;
 
93
 
 
94
}
 
95
 
 
96
void CheckButton_Class::draw_indicator_vfunc_callback(GtkCheckButton* self, cairo_t* cr)
 
97
{
 
98
  Glib::ObjectBase *const obj_base = static_cast<Glib::ObjectBase*>(
 
99
      Glib::ObjectBase::_get_current_wrapper((GObject*)self));
 
100
 
 
101
  // Non-gtkmmproc-generated custom classes implicitly call the default
 
102
  // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
 
103
  // generated classes can use this optimisation, which avoids the unnecessary
 
104
  // parameter conversions if there is no possibility of the virtual function
 
105
  // being overridden:
 
106
  if(obj_base && obj_base->is_derived_())
 
107
  {
 
108
    CppObjectType *const obj = dynamic_cast<CppObjectType* const>(obj_base);
 
109
    if(obj) // This can be NULL during destruction.
 
110
    {
 
111
      #ifdef GLIBMM_EXCEPTIONS_ENABLED
 
112
      try // Trap C++ exceptions which would normally be lost because this is a C callback.
 
113
      {
 
114
      #endif //GLIBMM_EXCEPTIONS_ENABLED
 
115
        // Call the virtual member method, which derived classes might override.
 
116
        obj->draw_indicator_vfunc(Cairo::RefPtr<Cairo::Context>(new Cairo::Context(cr, false /* has_reference */))
 
117
);
 
118
        return;
 
119
      #ifdef GLIBMM_EXCEPTIONS_ENABLED
 
120
      }
 
121
      catch(...)
 
122
      {
 
123
        Glib::exception_handlers_invoke();
 
124
      }
 
125
      #endif //GLIBMM_EXCEPTIONS_ENABLED
 
126
    }
 
127
  }
 
128
  
 
129
  BaseClassType *const base = static_cast<BaseClassType*>(
 
130
      g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
 
131
  );
 
132
 
 
133
  // Call the original underlying C function:
 
134
  if(base && base->draw_indicator)
 
135
    (*base->draw_indicator)(self, cr);
 
136
 
 
137
}
 
138
 
 
139
 
 
140
Glib::ObjectBase* CheckButton_Class::wrap_new(GObject* o)
 
141
{
 
142
  return manage(new CheckButton((GtkCheckButton*)(o)));
 
143
 
 
144
}
 
145
 
 
146
 
 
147
/* The implementation: */
 
148
 
 
149
CheckButton::CheckButton(const Glib::ConstructParams& construct_params)
 
150
:
 
151
  Gtk::ToggleButton(construct_params)
 
152
{
 
153
  }
 
154
 
 
155
CheckButton::CheckButton(GtkCheckButton* castitem)
 
156
:
 
157
  Gtk::ToggleButton((GtkToggleButton*)(castitem))
 
158
{
 
159
  }
 
160
 
 
161
CheckButton::~CheckButton()
 
162
{
 
163
  destroy_();
 
164
}
 
165
 
 
166
CheckButton::CppClassType CheckButton::checkbutton_class_; // initialize static member
 
167
 
 
168
GType CheckButton::get_type()
 
169
{
 
170
  return checkbutton_class_.init().get_type();
 
171
}
 
172
 
 
173
 
 
174
GType CheckButton::get_base_type()
 
175
{
 
176
  return gtk_check_button_get_type();
 
177
}
 
178
 
 
179
 
 
180
CheckButton::CheckButton()
 
181
:
 
182
  // Mark this class as non-derived to allow C++ vfuncs to be skipped.
 
183
  Glib::ObjectBase(0),
 
184
  Gtk::ToggleButton(Glib::ConstructParams(checkbutton_class_.init()))
 
185
{
 
186
  
 
187
 
 
188
}
 
189
 
 
190
 
 
191
void Gtk::CheckButton::draw_indicator_vfunc(const Cairo::RefPtr<Cairo::Context>& cr) 
 
192
{
 
193
  BaseClassType *const base = static_cast<BaseClassType*>(
 
194
      g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_)) // Get the parent class of the object class (The original underlying C class).
 
195
  );
 
196
 
 
197
  if(base && base->draw_indicator)
 
198
    (*base->draw_indicator)(gobj(),(cr)->cobj());
 
199
}
 
200
 
 
201
 
 
202
} // namespace Gtk
 
203
 
 
204