Install ardour as a binary, a script and a set of shared
[ardour.git] / libs / gtkmm2 / gtk / gtkmm / colorselection.cc
1 // Generated by gtkmmproc -- DO NOT MODIFY!
2
3 #include <gtkmm/colorselection.h>
4 #include <gtkmm/private/colorselection_p.h>
5
6 // -*- c++ -*-
7 /* $Id$ */
8
9 /* Copyright 1998-2002 The gtkmm Development Team
10  *
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.
15  *
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.
20  *
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.
24  */
25
26 #include <gtk/gtkcolorsel.h>
27 #include <gtk/gtkcolorseldialog.h>
28
29
30 namespace
31 {
32
33 Gtk::ColorSelection::SlotChangePaletteHook* global_change_palette_hook = 0;
34
35 void global_change_palette_hook_callback(GdkScreen* screen, const GdkColor* colors, int n_colors)
36 {
37   g_return_if_fail(global_change_palette_hook != 0);
38
39   try
40   {
41     (*global_change_palette_hook)(
42         Glib::wrap(screen, true),
43         Gdk::ArrayHandle_Color(colors, n_colors, Glib::OWNERSHIP_NONE));
44   }
45   catch(...)
46   {
47     Glib::exception_handlers_invoke();
48   }
49 }
50
51 void old_change_palette_hook_callback(const Glib::RefPtr<Gdk::Screen>& screen,
52                                       const Gdk::ArrayHandle_Color&    colors,
53                                       GtkColorSelectionChangePaletteWithScreenFunc func)
54 {
55   g_return_if_fail(func != 0);
56
57   (*func)(Glib::unwrap(screen), colors.data(), colors.size());
58 }
59
60 } // anonymous namespace
61
62
63 namespace Gtk
64 {
65
66 Gdk::Color ColorSelection::get_current_color() const
67 {
68   Gdk::Color color; //GdkColor Just a simple struct.
69   gtk_color_selection_get_current_color(const_cast<GtkColorSelection*>(gobj()), color.gobj());
70   return color;
71 }
72
73 Gdk::Color ColorSelection::get_previous_color() const
74 {
75   Gdk::Color color; //GdkColor Just a simple struct.
76   gtk_color_selection_get_previous_color(const_cast<GtkColorSelection*>(gobj()), color.gobj());
77   return color;
78 }
79
80 // static
81 Gdk::ArrayHandle_Color ColorSelection::palette_from_string(const Glib::ustring& str)
82 {
83   GdkColor* colors = 0;
84   int     n_colors = 0;
85
86   gtk_color_selection_palette_from_string(str.c_str(), &colors, &n_colors);
87
88   return Gdk::ArrayHandle_Color(colors, n_colors, Glib::OWNERSHIP_SHALLOW);
89 }
90
91 // static
92 Glib::ustring ColorSelection::palette_to_string(const Gdk::ArrayHandle_Color& colors)
93 {
94   if(char *const str = gtk_color_selection_palette_to_string(colors.data(), colors.size()))
95     return Glib::ustring(Glib::ScopedPtr<char>(str).get());
96   else
97     return Glib::ustring();
98 }
99
100 // static
101 ColorSelection::SlotChangePaletteHook
102 ColorSelection::set_change_palette_hook(const ColorSelection::SlotChangePaletteHook& slot)
103 {
104   GtkColorSelectionChangePaletteWithScreenFunc new_func = 0;
105   SlotChangePaletteHook* new_slot = 0;
106   SlotChangePaletteHook  old_slot;
107
108   if(slot)
109   {
110     new_func = &global_change_palette_hook_callback;
111     new_slot = new SlotChangePaletteHook(slot);
112   }
113
114   const GtkColorSelectionChangePaletteWithScreenFunc old_func =
115       gtk_color_selection_set_change_palette_with_screen_hook(new_func);
116
117   if(old_func)
118   {
119     try
120     {
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;
125     }
126     catch(...)
127     {
128       gtk_color_selection_set_change_palette_with_screen_hook(old_func);
129       delete new_slot;
130       throw;
131     }
132   }
133
134   delete global_change_palette_hook;
135   global_change_palette_hook = new_slot;
136
137   return old_slot;
138 }
139
140 } // namespace Gtk
141
142
143 namespace
144 {
145
146 const Glib::SignalProxyInfo ColorSelection_signal_color_changed_info =
147 {
148   "color_changed",
149   (GCallback) &Glib::SignalProxyNormal::slot0_void_callback,
150   (GCallback) &Glib::SignalProxyNormal::slot0_void_callback
151 };
152
153 } // anonymous namespace
154
155
156 namespace Glib
157 {
158
159 Gtk::ColorSelection* wrap(GtkColorSelection* object, bool take_copy)
160 {
161   return dynamic_cast<Gtk::ColorSelection *> (Glib::wrap_auto ((GObject*)(object), take_copy));
162 }
163
164 } /* namespace Glib */
165
166 namespace Gtk
167 {
168
169
170 /* The *_Class implementation: */
171
172 const Glib::Class& ColorSelection_Class::init()
173 {
174   if(!gtype_) // create the GType if necessary
175   {
176     // Glib::Class has to know the class init function to clone custom types.
177     class_init_func_ = &ColorSelection_Class::class_init_function;
178
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();
182
183     // Create the wrapper type, with the same class/instance size as the base type.
184     register_derived_type(gtk_color_selection_get_type());
185
186     // Add derived versions of interfaces, if the C type implements any interfaces:
187   }
188
189   return *this;
190 }
191
192 void ColorSelection_Class::class_init_function(void* g_class, void* class_data)
193 {
194   BaseClassType *const klass = static_cast<BaseClassType*>(g_class);
195   CppClassParent::class_init_function(klass, class_data);
196
197   klass->color_changed = &color_changed_callback;
198 }
199
200
201 void ColorSelection_Class::color_changed_callback(GtkColorSelection* self)
202 {
203   CppObjectType *const obj = dynamic_cast<CppObjectType*>(
204       Glib::ObjectBase::_get_current_wrapper((GObject*)self));
205
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
210   // being overridden:
211   if(obj && obj->is_derived_())
212   {
213     try // Trap C++ exceptions which would normally be lost because this is a C callback.
214     {
215       // Call the virtual member method, which derived classes might override.
216       obj->on_color_changed();
217     }
218     catch(...)
219     {
220       Glib::exception_handlers_invoke();
221     }
222   }
223   else
224   {
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).
227     );
228
229     // Call the original underlying C function:
230     if(base && base->color_changed)
231       (*base->color_changed)(self);
232   }
233 }
234
235
236 Glib::ObjectBase* ColorSelection_Class::wrap_new(GObject* o)
237 {
238   return manage(new ColorSelection((GtkColorSelection*)(o)));
239
240 }
241
242
243 /* The implementation: */
244
245 ColorSelection::ColorSelection(const Glib::ConstructParams& construct_params)
246 :
247   Gtk::VBox(construct_params)
248 {
249   }
250
251 ColorSelection::ColorSelection(GtkColorSelection* castitem)
252 :
253   Gtk::VBox((GtkVBox*)(castitem))
254 {
255   }
256
257 ColorSelection::~ColorSelection()
258 {
259   destroy_();
260 }
261
262 ColorSelection::CppClassType ColorSelection::colorselection_class_; // initialize static member
263
264 GType ColorSelection::get_type()
265 {
266   return colorselection_class_.init().get_type();
267 }
268
269 GType ColorSelection::get_base_type()
270 {
271   return gtk_color_selection_get_type();
272 }
273
274
275 ColorSelection::ColorSelection()
276 :
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()))
279 {
280   }
281
282 bool ColorSelection::get_has_opacity_control() const
283 {
284   return gtk_color_selection_get_has_opacity_control(const_cast<GtkColorSelection*>(gobj()));
285 }
286
287 void ColorSelection::set_has_opacity_control(bool has_opacity)
288 {
289   gtk_color_selection_set_has_opacity_control(gobj(), static_cast<int>(has_opacity));
290 }
291
292 bool ColorSelection::get_has_palette() const
293 {
294   return gtk_color_selection_get_has_palette(const_cast<GtkColorSelection*>(gobj()));
295 }
296
297 void ColorSelection::set_has_palette(bool has_palette)
298 {
299   gtk_color_selection_set_has_palette(gobj(), static_cast<int>(has_palette));
300 }
301
302 void ColorSelection::set_current_color(const Gdk::Color& color)
303 {
304   gtk_color_selection_set_current_color(gobj(), (color).gobj());
305 }
306
307 void ColorSelection::set_current_alpha(guint16 alpha)
308 {
309   gtk_color_selection_set_current_alpha(gobj(), alpha);
310 }
311
312 guint16 ColorSelection::get_current_alpha() const
313 {
314   return gtk_color_selection_get_current_alpha(const_cast<GtkColorSelection*>(gobj()));
315 }
316
317 void ColorSelection::set_previous_color(const Gdk::Color& color)
318 {
319   gtk_color_selection_set_previous_color(gobj(), (color).gobj());
320 }
321
322 void ColorSelection::set_previous_alpha(guint16 alpha)
323 {
324   gtk_color_selection_set_previous_alpha(gobj(), alpha);
325 }
326
327 guint16 ColorSelection::get_previous_alpha() const
328 {
329   return gtk_color_selection_get_previous_alpha(const_cast<GtkColorSelection*>(gobj()));
330 }
331
332 bool ColorSelection::is_adjusting() const
333 {
334   return gtk_color_selection_is_adjusting(const_cast<GtkColorSelection*>(gobj()));
335 }
336
337
338 Glib::SignalProxy0< void > ColorSelection::signal_color_changed()
339 {
340   return Glib::SignalProxy0< void >(this, &ColorSelection_signal_color_changed_info);
341 }
342
343
344 Glib::PropertyProxy<bool> ColorSelection::property_has_palette() 
345 {
346   return Glib::PropertyProxy<bool>(this, "has-palette");
347 }
348
349 Glib::PropertyProxy_ReadOnly<bool> ColorSelection::property_has_palette() const
350 {
351   return Glib::PropertyProxy_ReadOnly<bool>(this, "has-palette");
352 }
353
354 Glib::PropertyProxy<bool> ColorSelection::property_has_opacity_control() 
355 {
356   return Glib::PropertyProxy<bool>(this, "has-opacity-control");
357 }
358
359 Glib::PropertyProxy_ReadOnly<bool> ColorSelection::property_has_opacity_control() const
360 {
361   return Glib::PropertyProxy_ReadOnly<bool>(this, "has-opacity-control");
362 }
363
364 Glib::PropertyProxy<Gdk::Color> ColorSelection::property_current_color() 
365 {
366   return Glib::PropertyProxy<Gdk::Color>(this, "current-color");
367 }
368
369 Glib::PropertyProxy_ReadOnly<Gdk::Color> ColorSelection::property_current_color() const
370 {
371   return Glib::PropertyProxy_ReadOnly<Gdk::Color>(this, "current-color");
372 }
373
374 Glib::PropertyProxy<guint> ColorSelection::property_current_alpha() 
375 {
376   return Glib::PropertyProxy<guint>(this, "current-alpha");
377 }
378
379 Glib::PropertyProxy_ReadOnly<guint> ColorSelection::property_current_alpha() const
380 {
381   return Glib::PropertyProxy_ReadOnly<guint>(this, "current-alpha");
382 }
383
384
385 void Gtk::ColorSelection::on_color_changed()
386 {
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).
389   );
390
391   if(base && base->color_changed)
392     (*base->color_changed)(gobj());
393 }
394
395
396 } // namespace Gtk
397
398
399 namespace Glib
400 {
401
402 Gtk::ColorSelectionDialog* wrap(GtkColorSelectionDialog* object, bool take_copy)
403 {
404   return dynamic_cast<Gtk::ColorSelectionDialog *> (Glib::wrap_auto ((GObject*)(object), take_copy));
405 }
406
407 } /* namespace Glib */
408
409 namespace Gtk
410 {
411
412
413 /* The *_Class implementation: */
414
415 const Glib::Class& ColorSelectionDialog_Class::init()
416 {
417   if(!gtype_) // create the GType if necessary
418   {
419     // Glib::Class has to know the class init function to clone custom types.
420     class_init_func_ = &ColorSelectionDialog_Class::class_init_function;
421
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();
425
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());
428
429     // Add derived versions of interfaces, if the C type implements any interfaces:
430   }
431
432   return *this;
433 }
434
435 void ColorSelectionDialog_Class::class_init_function(void* g_class, void* class_data)
436 {
437   BaseClassType *const klass = static_cast<BaseClassType*>(g_class);
438   CppClassParent::class_init_function(klass, class_data);
439
440 }
441
442
443 Glib::ObjectBase* ColorSelectionDialog_Class::wrap_new(GObject* o)
444 {
445   return new ColorSelectionDialog((GtkColorSelectionDialog*)(o)); //top-level windows can not be manage()ed.
446
447 }
448
449
450 /* The implementation: */
451
452 ColorSelectionDialog::ColorSelectionDialog(const Glib::ConstructParams& construct_params)
453 :
454   Gtk::Dialog(construct_params)
455 {
456   }
457
458 ColorSelectionDialog::ColorSelectionDialog(GtkColorSelectionDialog* castitem)
459 :
460   Gtk::Dialog((GtkDialog*)(castitem))
461 {
462   }
463
464 ColorSelectionDialog::~ColorSelectionDialog()
465 {
466   destroy_();
467 }
468
469 ColorSelectionDialog::CppClassType ColorSelectionDialog::colorselectiondialog_class_; // initialize static member
470
471 GType ColorSelectionDialog::get_type()
472 {
473   return colorselectiondialog_class_.init().get_type();
474 }
475
476 GType ColorSelectionDialog::get_base_type()
477 {
478   return gtk_color_selection_dialog_get_type();
479 }
480
481 ColorSelectionDialog::ColorSelectionDialog()
482 :
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()))
485 {
486   }
487
488 ColorSelectionDialog::ColorSelectionDialog(const Glib::ustring& title)
489 :
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))
492 {
493   }
494
495 ColorSelection* ColorSelectionDialog::get_colorsel()
496 {
497   return Glib::wrap((GtkColorSelection*)(gobj()->colorsel));
498 }
499
500 const ColorSelection* ColorSelectionDialog::get_colorsel() const
501 {
502   return Glib::wrap((GtkColorSelection*)(gobj()->colorsel));
503 }
504
505 Button* ColorSelectionDialog::get_ok_button()
506 {
507   return Glib::wrap((GtkButton*)(gobj()->ok_button));
508 }
509
510 const Button* ColorSelectionDialog::get_ok_button() const
511 {
512   return Glib::wrap((GtkButton*)(gobj()->ok_button));
513 }
514
515 Button* ColorSelectionDialog::get_cancel_button()
516 {
517   return Glib::wrap((GtkButton*)(gobj()->cancel_button));
518 }
519
520 const Button* ColorSelectionDialog::get_cancel_button() const
521 {
522   return Glib::wrap((GtkButton*)(gobj()->cancel_button));
523 }
524
525 Button* ColorSelectionDialog::get_help_button()
526 {
527   return Glib::wrap((GtkButton*)(gobj()->help_button));
528 }
529
530 const Button* ColorSelectionDialog::get_help_button() const
531 {
532   return Glib::wrap((GtkButton*)(gobj()->help_button));
533 }
534
535
536 } // namespace Gtk
537
538