1 // Generated by gtkmmproc -- DO NOT MODIFY!
3 #include <gtkmm/colorselection.h>
4 #include <gtkmm/private/colorselection_p.h>
9 /* Copyright 1998-2002 The gtkmm Development Team
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Library General Public
13 * License as published by the Free Software Foundation; either
14 * version 2 of the License, or (at your option) any later version.
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Library General Public License for more details.
21 * You should have received a copy of the GNU Library General Public
22 * License along with this library; if not, write to the Free
23 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 #include <gtk/gtkcolorsel.h>
27 #include <gtk/gtkcolorseldialog.h>
33 Gtk::ColorSelection::SlotChangePaletteHook* global_change_palette_hook = 0;
35 void global_change_palette_hook_callback(GdkScreen* screen, const GdkColor* colors, int n_colors)
37 g_return_if_fail(global_change_palette_hook != 0);
41 (*global_change_palette_hook)(
42 Glib::wrap(screen, true),
43 Gdk::ArrayHandle_Color(colors, n_colors, Glib::OWNERSHIP_NONE));
47 Glib::exception_handlers_invoke();
51 void old_change_palette_hook_callback(const Glib::RefPtr<Gdk::Screen>& screen,
52 const Gdk::ArrayHandle_Color& colors,
53 GtkColorSelectionChangePaletteWithScreenFunc func)
55 g_return_if_fail(func != 0);
57 (*func)(Glib::unwrap(screen), colors.data(), colors.size());
60 } // anonymous namespace
66 Gdk::Color ColorSelection::get_current_color() const
68 Gdk::Color color; //GdkColor Just a simple struct.
69 gtk_color_selection_get_current_color(const_cast<GtkColorSelection*>(gobj()), color.gobj());
73 Gdk::Color ColorSelection::get_previous_color() const
75 Gdk::Color color; //GdkColor Just a simple struct.
76 gtk_color_selection_get_previous_color(const_cast<GtkColorSelection*>(gobj()), color.gobj());
81 Gdk::ArrayHandle_Color ColorSelection::palette_from_string(const Glib::ustring& str)
86 gtk_color_selection_palette_from_string(str.c_str(), &colors, &n_colors);
88 return Gdk::ArrayHandle_Color(colors, n_colors, Glib::OWNERSHIP_SHALLOW);
92 Glib::ustring ColorSelection::palette_to_string(const Gdk::ArrayHandle_Color& colors)
94 if(char *const str = gtk_color_selection_palette_to_string(colors.data(), colors.size()))
95 return Glib::ustring(Glib::ScopedPtr<char>(str).get());
97 return Glib::ustring();
101 ColorSelection::SlotChangePaletteHook
102 ColorSelection::set_change_palette_hook(const ColorSelection::SlotChangePaletteHook& slot)
104 GtkColorSelectionChangePaletteWithScreenFunc new_func = 0;
105 SlotChangePaletteHook* new_slot = 0;
106 SlotChangePaletteHook old_slot;
110 new_func = &global_change_palette_hook_callback;
111 new_slot = new SlotChangePaletteHook(slot);
114 const GtkColorSelectionChangePaletteWithScreenFunc old_func =
115 gtk_color_selection_set_change_palette_with_screen_hook(new_func);
121 if(old_func != &global_change_palette_hook_callback)
122 old_slot = sigc::bind<-1>(sigc::ptr_fun(&old_change_palette_hook_callback), old_func);
123 else if(global_change_palette_hook)
124 old_slot = *global_change_palette_hook;
128 gtk_color_selection_set_change_palette_with_screen_hook(old_func);
134 delete global_change_palette_hook;
135 global_change_palette_hook = new_slot;
146 const Glib::SignalProxyInfo ColorSelection_signal_color_changed_info =
149 (GCallback) &Glib::SignalProxyNormal::slot0_void_callback,
150 (GCallback) &Glib::SignalProxyNormal::slot0_void_callback
153 } // anonymous namespace
159 Gtk::ColorSelection* wrap(GtkColorSelection* object, bool take_copy)
161 return dynamic_cast<Gtk::ColorSelection *> (Glib::wrap_auto ((GObject*)(object), take_copy));
164 } /* namespace Glib */
170 /* The *_Class implementation: */
172 const Glib::Class& ColorSelection_Class::init()
174 if(!gtype_) // create the GType if necessary
176 // Glib::Class has to know the class init function to clone custom types.
177 class_init_func_ = &ColorSelection_Class::class_init_function;
179 // This is actually just optimized away, apparently with no harm.
180 // Make sure that the parent type has been created.
181 //CppClassParent::CppObjectType::get_type();
183 // Create the wrapper type, with the same class/instance size as the base type.
184 register_derived_type(gtk_color_selection_get_type());
186 // Add derived versions of interfaces, if the C type implements any interfaces:
192 void ColorSelection_Class::class_init_function(void* g_class, void* class_data)
194 BaseClassType *const klass = static_cast<BaseClassType*>(g_class);
195 CppClassParent::class_init_function(klass, class_data);
197 klass->color_changed = &color_changed_callback;
201 void ColorSelection_Class::color_changed_callback(GtkColorSelection* self)
203 CppObjectType *const obj = dynamic_cast<CppObjectType*>(
204 Glib::ObjectBase::_get_current_wrapper((GObject*)self));
206 // Non-gtkmmproc-generated custom classes implicitly call the default
207 // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
208 // generated classes can use this optimisation, which avoids the unnecessary
209 // parameter conversions if there is no possibility of the virtual function
211 if(obj && obj->is_derived_())
213 try // Trap C++ exceptions which would normally be lost because this is a C callback.
215 // Call the virtual member method, which derived classes might override.
216 obj->on_color_changed();
220 Glib::exception_handlers_invoke();
225 BaseClassType *const base = static_cast<BaseClassType*>(
226 g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
229 // Call the original underlying C function:
230 if(base && base->color_changed)
231 (*base->color_changed)(self);
236 Glib::ObjectBase* ColorSelection_Class::wrap_new(GObject* o)
238 return manage(new ColorSelection((GtkColorSelection*)(o)));
243 /* The implementation: */
245 ColorSelection::ColorSelection(const Glib::ConstructParams& construct_params)
247 Gtk::VBox(construct_params)
251 ColorSelection::ColorSelection(GtkColorSelection* castitem)
253 Gtk::VBox((GtkVBox*)(castitem))
257 ColorSelection::~ColorSelection()
262 ColorSelection::CppClassType ColorSelection::colorselection_class_; // initialize static member
264 GType ColorSelection::get_type()
266 return colorselection_class_.init().get_type();
269 GType ColorSelection::get_base_type()
271 return gtk_color_selection_get_type();
275 ColorSelection::ColorSelection()
277 Glib::ObjectBase(0), //Mark this class as gtkmmproc-generated, rather than a custom class, to allow vfunc optimisations.
278 Gtk::VBox(Glib::ConstructParams(colorselection_class_.init()))
282 bool ColorSelection::get_has_opacity_control() const
284 return gtk_color_selection_get_has_opacity_control(const_cast<GtkColorSelection*>(gobj()));
287 void ColorSelection::set_has_opacity_control(bool has_opacity)
289 gtk_color_selection_set_has_opacity_control(gobj(), static_cast<int>(has_opacity));
292 bool ColorSelection::get_has_palette() const
294 return gtk_color_selection_get_has_palette(const_cast<GtkColorSelection*>(gobj()));
297 void ColorSelection::set_has_palette(bool has_palette)
299 gtk_color_selection_set_has_palette(gobj(), static_cast<int>(has_palette));
302 void ColorSelection::set_current_color(const Gdk::Color& color)
304 gtk_color_selection_set_current_color(gobj(), (color).gobj());
307 void ColorSelection::set_current_alpha(guint16 alpha)
309 gtk_color_selection_set_current_alpha(gobj(), alpha);
312 guint16 ColorSelection::get_current_alpha() const
314 return gtk_color_selection_get_current_alpha(const_cast<GtkColorSelection*>(gobj()));
317 void ColorSelection::set_previous_color(const Gdk::Color& color)
319 gtk_color_selection_set_previous_color(gobj(), (color).gobj());
322 void ColorSelection::set_previous_alpha(guint16 alpha)
324 gtk_color_selection_set_previous_alpha(gobj(), alpha);
327 guint16 ColorSelection::get_previous_alpha() const
329 return gtk_color_selection_get_previous_alpha(const_cast<GtkColorSelection*>(gobj()));
332 bool ColorSelection::is_adjusting() const
334 return gtk_color_selection_is_adjusting(const_cast<GtkColorSelection*>(gobj()));
338 Glib::SignalProxy0< void > ColorSelection::signal_color_changed()
340 return Glib::SignalProxy0< void >(this, &ColorSelection_signal_color_changed_info);
344 Glib::PropertyProxy<bool> ColorSelection::property_has_palette()
346 return Glib::PropertyProxy<bool>(this, "has-palette");
349 Glib::PropertyProxy_ReadOnly<bool> ColorSelection::property_has_palette() const
351 return Glib::PropertyProxy_ReadOnly<bool>(this, "has-palette");
354 Glib::PropertyProxy<bool> ColorSelection::property_has_opacity_control()
356 return Glib::PropertyProxy<bool>(this, "has-opacity-control");
359 Glib::PropertyProxy_ReadOnly<bool> ColorSelection::property_has_opacity_control() const
361 return Glib::PropertyProxy_ReadOnly<bool>(this, "has-opacity-control");
364 Glib::PropertyProxy<Gdk::Color> ColorSelection::property_current_color()
366 return Glib::PropertyProxy<Gdk::Color>(this, "current-color");
369 Glib::PropertyProxy_ReadOnly<Gdk::Color> ColorSelection::property_current_color() const
371 return Glib::PropertyProxy_ReadOnly<Gdk::Color>(this, "current-color");
374 Glib::PropertyProxy<guint> ColorSelection::property_current_alpha()
376 return Glib::PropertyProxy<guint>(this, "current-alpha");
379 Glib::PropertyProxy_ReadOnly<guint> ColorSelection::property_current_alpha() const
381 return Glib::PropertyProxy_ReadOnly<guint>(this, "current-alpha");
385 void Gtk::ColorSelection::on_color_changed()
387 BaseClassType *const base = static_cast<BaseClassType*>(
388 g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_)) // Get the parent class of the object class (The original underlying C class).
391 if(base && base->color_changed)
392 (*base->color_changed)(gobj());
402 Gtk::ColorSelectionDialog* wrap(GtkColorSelectionDialog* object, bool take_copy)
404 return dynamic_cast<Gtk::ColorSelectionDialog *> (Glib::wrap_auto ((GObject*)(object), take_copy));
407 } /* namespace Glib */
413 /* The *_Class implementation: */
415 const Glib::Class& ColorSelectionDialog_Class::init()
417 if(!gtype_) // create the GType if necessary
419 // Glib::Class has to know the class init function to clone custom types.
420 class_init_func_ = &ColorSelectionDialog_Class::class_init_function;
422 // This is actually just optimized away, apparently with no harm.
423 // Make sure that the parent type has been created.
424 //CppClassParent::CppObjectType::get_type();
426 // Create the wrapper type, with the same class/instance size as the base type.
427 register_derived_type(gtk_color_selection_dialog_get_type());
429 // Add derived versions of interfaces, if the C type implements any interfaces:
435 void ColorSelectionDialog_Class::class_init_function(void* g_class, void* class_data)
437 BaseClassType *const klass = static_cast<BaseClassType*>(g_class);
438 CppClassParent::class_init_function(klass, class_data);
443 Glib::ObjectBase* ColorSelectionDialog_Class::wrap_new(GObject* o)
445 return new ColorSelectionDialog((GtkColorSelectionDialog*)(o)); //top-level windows can not be manage()ed.
450 /* The implementation: */
452 ColorSelectionDialog::ColorSelectionDialog(const Glib::ConstructParams& construct_params)
454 Gtk::Dialog(construct_params)
458 ColorSelectionDialog::ColorSelectionDialog(GtkColorSelectionDialog* castitem)
460 Gtk::Dialog((GtkDialog*)(castitem))
464 ColorSelectionDialog::~ColorSelectionDialog()
469 ColorSelectionDialog::CppClassType ColorSelectionDialog::colorselectiondialog_class_; // initialize static member
471 GType ColorSelectionDialog::get_type()
473 return colorselectiondialog_class_.init().get_type();
476 GType ColorSelectionDialog::get_base_type()
478 return gtk_color_selection_dialog_get_type();
481 ColorSelectionDialog::ColorSelectionDialog()
483 Glib::ObjectBase(0), //Mark this class as gtkmmproc-generated, rather than a custom class, to allow vfunc optimisations.
484 Gtk::Dialog(Glib::ConstructParams(colorselectiondialog_class_.init()))
488 ColorSelectionDialog::ColorSelectionDialog(const Glib::ustring& title)
490 Glib::ObjectBase(0), //Mark this class as gtkmmproc-generated, rather than a custom class, to allow vfunc optimisations.
491 Gtk::Dialog(Glib::ConstructParams(colorselectiondialog_class_.init(), "title", title.c_str(), (char*) 0))
495 ColorSelection* ColorSelectionDialog::get_colorsel()
497 return Glib::wrap((GtkColorSelection*)(gobj()->colorsel));
500 const ColorSelection* ColorSelectionDialog::get_colorsel() const
502 return Glib::wrap((GtkColorSelection*)(gobj()->colorsel));
505 Button* ColorSelectionDialog::get_ok_button()
507 return Glib::wrap((GtkButton*)(gobj()->ok_button));
510 const Button* ColorSelectionDialog::get_ok_button() const
512 return Glib::wrap((GtkButton*)(gobj()->ok_button));
515 Button* ColorSelectionDialog::get_cancel_button()
517 return Glib::wrap((GtkButton*)(gobj()->cancel_button));
520 const Button* ColorSelectionDialog::get_cancel_button() const
522 return Glib::wrap((GtkButton*)(gobj()->cancel_button));
525 Button* ColorSelectionDialog::get_help_button()
527 return Glib::wrap((GtkButton*)(gobj()->help_button));
530 const Button* ColorSelectionDialog::get_help_button() const
532 return Glib::wrap((GtkButton*)(gobj()->help_button));