1 // Generated by gtkmmproc -- DO NOT MODIFY!
3 #include <gtkmm/button.h>
4 #include <gtkmm/private/button_p.h>
11 * Copyright 1998-2002 The gtkmm Development Team
13 * This library is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU Library General Public
15 * License as published by the Free Software Foundation; either
16 * version 2 of the License, or (at your option) any later version.
18 * This library is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 * Library General Public License for more details.
23 * You should have received a copy of the GNU Library General Public
24 * License along with this library; if not, write to the Free
25 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 #include <gtk/gtklabel.h>
29 #include <gtk/gtkmisc.h>
30 #include <gtk/gtkbutton.h>
31 #include <gtkmm/stock.h>
37 Button::Button(const Glib::ustring& label, bool mnemonic)
39 Glib::ObjectBase(0), //Mark this class as gtkmmproc-generated, rather than a custom class, to allow vfunc optimisations.
40 Gtk::Bin(Glib::ConstructParams(button_class_.init(), "label",label.c_str(),"use_underline",gboolean(mnemonic), (char*) 0))
43 Button::Button(const StockID& stock_id)
45 Glib::ObjectBase(0), //Mark this class as gtkmmproc-generated, rather than a custom class, to allow vfunc optimisations.
46 Gtk::Bin(Glib::ConstructParams(button_class_.init(), "use_stock",1,"label",stock_id.get_c_str(), (char*) 0))
55 const Glib::SignalProxyInfo Button_signal_pressed_info =
58 (GCallback) &Glib::SignalProxyNormal::slot0_void_callback,
59 (GCallback) &Glib::SignalProxyNormal::slot0_void_callback
63 const Glib::SignalProxyInfo Button_signal_released_info =
66 (GCallback) &Glib::SignalProxyNormal::slot0_void_callback,
67 (GCallback) &Glib::SignalProxyNormal::slot0_void_callback
71 const Glib::SignalProxyInfo Button_signal_clicked_info =
74 (GCallback) &Glib::SignalProxyNormal::slot0_void_callback,
75 (GCallback) &Glib::SignalProxyNormal::slot0_void_callback
79 const Glib::SignalProxyInfo Button_signal_enter_info =
82 (GCallback) &Glib::SignalProxyNormal::slot0_void_callback,
83 (GCallback) &Glib::SignalProxyNormal::slot0_void_callback
87 const Glib::SignalProxyInfo Button_signal_leave_info =
90 (GCallback) &Glib::SignalProxyNormal::slot0_void_callback,
91 (GCallback) &Glib::SignalProxyNormal::slot0_void_callback
95 const Glib::SignalProxyInfo Button_signal_activate_info =
98 (GCallback) &Glib::SignalProxyNormal::slot0_void_callback,
99 (GCallback) &Glib::SignalProxyNormal::slot0_void_callback
102 } // anonymous namespace
108 Gtk::Button* wrap(GtkButton* object, bool take_copy)
110 return dynamic_cast<Gtk::Button *> (Glib::wrap_auto ((GObject*)(object), take_copy));
113 } /* namespace Glib */
119 /* The *_Class implementation: */
121 const Glib::Class& Button_Class::init()
123 if(!gtype_) // create the GType if necessary
125 // Glib::Class has to know the class init function to clone custom types.
126 class_init_func_ = &Button_Class::class_init_function;
128 // This is actually just optimized away, apparently with no harm.
129 // Make sure that the parent type has been created.
130 //CppClassParent::CppObjectType::get_type();
132 // Create the wrapper type, with the same class/instance size as the base type.
133 register_derived_type(gtk_button_get_type());
135 // Add derived versions of interfaces, if the C type implements any interfaces:
141 void Button_Class::class_init_function(void* g_class, void* class_data)
143 BaseClassType *const klass = static_cast<BaseClassType*>(g_class);
144 CppClassParent::class_init_function(klass, class_data);
146 klass->pressed = &pressed_callback;
147 klass->released = &released_callback;
148 klass->clicked = &clicked_callback;
149 klass->enter = &enter_callback;
150 klass->leave = &leave_callback;
151 klass->activate = &activate_callback;
155 void Button_Class::pressed_callback(GtkButton* self)
157 CppObjectType *const obj = dynamic_cast<CppObjectType*>(
158 Glib::ObjectBase::_get_current_wrapper((GObject*)self));
160 // Non-gtkmmproc-generated custom classes implicitly call the default
161 // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
162 // generated classes can use this optimisation, which avoids the unnecessary
163 // parameter conversions if there is no possibility of the virtual function
165 if(obj && obj->is_derived_())
167 try // Trap C++ exceptions which would normally be lost because this is a C callback.
169 // Call the virtual member method, which derived classes might override.
174 Glib::exception_handlers_invoke();
179 BaseClassType *const base = static_cast<BaseClassType*>(
180 g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
183 // Call the original underlying C function:
184 if(base && base->pressed)
185 (*base->pressed)(self);
189 void Button_Class::released_callback(GtkButton* self)
191 CppObjectType *const obj = dynamic_cast<CppObjectType*>(
192 Glib::ObjectBase::_get_current_wrapper((GObject*)self));
194 // Non-gtkmmproc-generated custom classes implicitly call the default
195 // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
196 // generated classes can use this optimisation, which avoids the unnecessary
197 // parameter conversions if there is no possibility of the virtual function
199 if(obj && obj->is_derived_())
201 try // Trap C++ exceptions which would normally be lost because this is a C callback.
203 // Call the virtual member method, which derived classes might override.
208 Glib::exception_handlers_invoke();
213 BaseClassType *const base = static_cast<BaseClassType*>(
214 g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
217 // Call the original underlying C function:
218 if(base && base->released)
219 (*base->released)(self);
223 void Button_Class::clicked_callback(GtkButton* self)
225 CppObjectType *const obj = dynamic_cast<CppObjectType*>(
226 Glib::ObjectBase::_get_current_wrapper((GObject*)self));
228 // Non-gtkmmproc-generated custom classes implicitly call the default
229 // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
230 // generated classes can use this optimisation, which avoids the unnecessary
231 // parameter conversions if there is no possibility of the virtual function
233 if(obj && obj->is_derived_())
235 try // Trap C++ exceptions which would normally be lost because this is a C callback.
237 // Call the virtual member method, which derived classes might override.
242 Glib::exception_handlers_invoke();
247 BaseClassType *const base = static_cast<BaseClassType*>(
248 g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
251 // Call the original underlying C function:
252 if(base && base->clicked)
253 (*base->clicked)(self);
257 void Button_Class::enter_callback(GtkButton* self)
259 CppObjectType *const obj = dynamic_cast<CppObjectType*>(
260 Glib::ObjectBase::_get_current_wrapper((GObject*)self));
262 // Non-gtkmmproc-generated custom classes implicitly call the default
263 // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
264 // generated classes can use this optimisation, which avoids the unnecessary
265 // parameter conversions if there is no possibility of the virtual function
267 if(obj && obj->is_derived_())
269 try // Trap C++ exceptions which would normally be lost because this is a C callback.
271 // Call the virtual member method, which derived classes might override.
276 Glib::exception_handlers_invoke();
281 BaseClassType *const base = static_cast<BaseClassType*>(
282 g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
285 // Call the original underlying C function:
286 if(base && base->enter)
287 (*base->enter)(self);
291 void Button_Class::leave_callback(GtkButton* self)
293 CppObjectType *const obj = dynamic_cast<CppObjectType*>(
294 Glib::ObjectBase::_get_current_wrapper((GObject*)self));
296 // Non-gtkmmproc-generated custom classes implicitly call the default
297 // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
298 // generated classes can use this optimisation, which avoids the unnecessary
299 // parameter conversions if there is no possibility of the virtual function
301 if(obj && obj->is_derived_())
303 try // Trap C++ exceptions which would normally be lost because this is a C callback.
305 // Call the virtual member method, which derived classes might override.
310 Glib::exception_handlers_invoke();
315 BaseClassType *const base = static_cast<BaseClassType*>(
316 g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
319 // Call the original underlying C function:
320 if(base && base->leave)
321 (*base->leave)(self);
325 void Button_Class::activate_callback(GtkButton* self)
327 CppObjectType *const obj = dynamic_cast<CppObjectType*>(
328 Glib::ObjectBase::_get_current_wrapper((GObject*)self));
330 // Non-gtkmmproc-generated custom classes implicitly call the default
331 // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
332 // generated classes can use this optimisation, which avoids the unnecessary
333 // parameter conversions if there is no possibility of the virtual function
335 if(obj && obj->is_derived_())
337 try // Trap C++ exceptions which would normally be lost because this is a C callback.
339 // Call the virtual member method, which derived classes might override.
344 Glib::exception_handlers_invoke();
349 BaseClassType *const base = static_cast<BaseClassType*>(
350 g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
353 // Call the original underlying C function:
354 if(base && base->activate)
355 (*base->activate)(self);
360 Glib::ObjectBase* Button_Class::wrap_new(GObject* o)
362 return manage(new Button((GtkButton*)(o)));
367 /* The implementation: */
369 Button::Button(const Glib::ConstructParams& construct_params)
371 Gtk::Bin(construct_params)
375 Button::Button(GtkButton* castitem)
377 Gtk::Bin((GtkBin*)(castitem))
386 Button::CppClassType Button::button_class_; // initialize static member
388 GType Button::get_type()
390 return button_class_.init().get_type();
393 GType Button::get_base_type()
395 return gtk_button_get_type();
401 Glib::ObjectBase(0), //Mark this class as gtkmmproc-generated, rather than a custom class, to allow vfunc optimisations.
402 Gtk::Bin(Glib::ConstructParams(button_class_.init()))
406 void Button::pressed()
408 gtk_button_pressed(gobj());
411 void Button::released()
413 gtk_button_released(gobj());
416 void Button::clicked()
418 gtk_button_clicked(gobj());
423 gtk_button_enter(gobj());
428 gtk_button_leave(gobj());
431 void Button::set_relief(ReliefStyle newstyle)
433 gtk_button_set_relief(gobj(), ((GtkReliefStyle)(newstyle)));
436 ReliefStyle Button::get_relief() const
438 return ((ReliefStyle)(gtk_button_get_relief(const_cast<GtkButton*>(gobj()))));
441 void Button::set_label(const Glib::ustring& label)
443 gtk_button_set_label(gobj(), label.c_str());
446 Glib::ustring Button::get_label() const
448 return Glib::convert_const_gchar_ptr_to_ustring(gtk_button_get_label(const_cast<GtkButton*>(gobj())));
451 void Button::set_use_underline(bool use_underline)
453 gtk_button_set_use_underline(gobj(), static_cast<int>(use_underline));
456 bool Button::get_use_underline() const
458 return gtk_button_get_use_underline(const_cast<GtkButton*>(gobj()));
461 void Button::set_use_stock(bool use_stock)
463 gtk_button_set_use_stock(gobj(), static_cast<int>(use_stock));
466 bool Button::get_use_stock() const
468 return gtk_button_get_use_stock(const_cast<GtkButton*>(gobj()));
471 void Button::set_focus_on_click(bool focus_on_click)
473 gtk_button_set_focus_on_click(gobj(), static_cast<int>(focus_on_click));
476 bool Button::get_focus_on_click() const
478 return gtk_button_get_focus_on_click(const_cast<GtkButton*>(gobj()));
481 void Button::set_alignment(float xalign, float yalign)
483 gtk_button_set_alignment(gobj(), xalign, yalign);
486 void Button::get_alignment(float& xalign, float& yalign)
488 gtk_button_get_alignment(gobj(), &(xalign), &(yalign));
491 void Button::set_image(Widget& image)
493 gtk_button_set_image(gobj(), (image).gobj());
496 Widget* Button::get_image()
498 return Glib::wrap(gtk_button_get_image(gobj()));
501 const Widget* Button::get_image() const
503 return Glib::wrap(gtk_button_get_image(const_cast<GtkButton*>(gobj())));
507 Glib::SignalProxy0< void > Button::signal_pressed()
509 return Glib::SignalProxy0< void >(this, &Button_signal_pressed_info);
512 Glib::SignalProxy0< void > Button::signal_released()
514 return Glib::SignalProxy0< void >(this, &Button_signal_released_info);
517 Glib::SignalProxy0< void > Button::signal_clicked()
519 return Glib::SignalProxy0< void >(this, &Button_signal_clicked_info);
522 Glib::SignalProxy0< void > Button::signal_enter()
524 return Glib::SignalProxy0< void >(this, &Button_signal_enter_info);
527 Glib::SignalProxy0< void > Button::signal_leave()
529 return Glib::SignalProxy0< void >(this, &Button_signal_leave_info);
532 Glib::SignalProxy0< void > Button::signal_activate()
534 return Glib::SignalProxy0< void >(this, &Button_signal_activate_info);
538 Glib::PropertyProxy<Glib::ustring> Button::property_label()
540 return Glib::PropertyProxy<Glib::ustring>(this, "label");
543 Glib::PropertyProxy_ReadOnly<Glib::ustring> Button::property_label() const
545 return Glib::PropertyProxy_ReadOnly<Glib::ustring>(this, "label");
548 Glib::PropertyProxy<ReliefStyle> Button::property_relief()
550 return Glib::PropertyProxy<ReliefStyle>(this, "relief");
553 Glib::PropertyProxy_ReadOnly<ReliefStyle> Button::property_relief() const
555 return Glib::PropertyProxy_ReadOnly<ReliefStyle>(this, "relief");
558 Glib::PropertyProxy<bool> Button::property_use_underline()
560 return Glib::PropertyProxy<bool>(this, "use-underline");
563 Glib::PropertyProxy_ReadOnly<bool> Button::property_use_underline() const
565 return Glib::PropertyProxy_ReadOnly<bool>(this, "use-underline");
568 Glib::PropertyProxy<bool> Button::property_use_stock()
570 return Glib::PropertyProxy<bool>(this, "use-stock");
573 Glib::PropertyProxy_ReadOnly<bool> Button::property_use_stock() const
575 return Glib::PropertyProxy_ReadOnly<bool>(this, "use-stock");
578 Glib::PropertyProxy<bool> Button::property_focus_on_click()
580 return Glib::PropertyProxy<bool>(this, "focus-on-click");
583 Glib::PropertyProxy_ReadOnly<bool> Button::property_focus_on_click() const
585 return Glib::PropertyProxy_ReadOnly<bool>(this, "focus-on-click");
588 Glib::PropertyProxy<float> Button::property_xalign()
590 return Glib::PropertyProxy<float>(this, "xalign");
593 Glib::PropertyProxy_ReadOnly<float> Button::property_xalign() const
595 return Glib::PropertyProxy_ReadOnly<float>(this, "xalign");
598 Glib::PropertyProxy<float> Button::property_yalign()
600 return Glib::PropertyProxy<float>(this, "yalign");
603 Glib::PropertyProxy_ReadOnly<float> Button::property_yalign() const
605 return Glib::PropertyProxy_ReadOnly<float>(this, "yalign");
608 Glib::PropertyProxy<Gtk::Widget*> Button::property_image()
610 return Glib::PropertyProxy<Gtk::Widget*>(this, "image");
613 Glib::PropertyProxy_ReadOnly<Gtk::Widget*> Button::property_image() const
615 return Glib::PropertyProxy_ReadOnly<Gtk::Widget*>(this, "image");
619 void Gtk::Button::on_pressed()
621 BaseClassType *const base = static_cast<BaseClassType*>(
622 g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_)) // Get the parent class of the object class (The original underlying C class).
625 if(base && base->pressed)
626 (*base->pressed)(gobj());
629 void Gtk::Button::on_released()
631 BaseClassType *const base = static_cast<BaseClassType*>(
632 g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_)) // Get the parent class of the object class (The original underlying C class).
635 if(base && base->released)
636 (*base->released)(gobj());
639 void Gtk::Button::on_clicked()
641 BaseClassType *const base = static_cast<BaseClassType*>(
642 g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_)) // Get the parent class of the object class (The original underlying C class).
645 if(base && base->clicked)
646 (*base->clicked)(gobj());
649 void Gtk::Button::on_enter()
651 BaseClassType *const base = static_cast<BaseClassType*>(
652 g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_)) // Get the parent class of the object class (The original underlying C class).
655 if(base && base->enter)
656 (*base->enter)(gobj());
659 void Gtk::Button::on_leave()
661 BaseClassType *const base = static_cast<BaseClassType*>(
662 g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_)) // Get the parent class of the object class (The original underlying C class).
665 if(base && base->leave)
666 (*base->leave)(gobj());
669 void Gtk::Button::on_activate()
671 BaseClassType *const base = static_cast<BaseClassType*>(
672 g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_)) // Get the parent class of the object class (The original underlying C class).
675 if(base && base->activate)
676 (*base->activate)(gobj());