1 // Generated by gmmproc 2.45.3 -- DO NOT MODIFY!
2 
3 
4 #include <glibmm.h>
5 
6 #include <gtkmm/scale.h>
7 #include <gtkmm/private/scale_p.h>
8 
9 
10 // -*- c++ -*-
11 /* $Id: scale.ccg,v 1.2 2004/01/19 19:48:44 murrayc Exp $ */
12 
13 /*
14  *
15  * Copyright 1998-2002 The gtkmm Development Team
16  *
17  * This library is free software; you can redistribute it and/or
18  * modify it under the terms of the GNU Lesser General Public
19  * License as published by the Free Software Foundation; either
20  * version 2.1 of the License, or (at your option) any later version.
21  *
22  * This library is distributed in the hope that it will be useful,
23  * but WITHOUT ANY WARRANTY; without even the implied warranty of
24  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
25  * Lesser General Public License for more details.
26  *
27  * You should have received a copy of the GNU Lesser General Public
28  * License along with this library; if not, write to the Free
29  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
30  */
31 
32 #include <gtkmm/adjustment.h>
33 
34 #include <gtk/gtk.h>
35 #include <math.h>
36 #include <cstring> //For strlen()
37 #include <memory>
38 
39 using std::strlen;
40 
41 namespace Gtk
42 {
43 
calc_digits_(double step) const44 int Scale::calc_digits_(double step) const
45 {
46   int digits = 0;
47 
48   //Copied from gtk_[h|v]scale_new_with_range():
49   if (fabs (step) >= 1.0 || step == 0.0)
50      digits = 0;
51   else {
52     digits = abs ((int) floor (log10 (fabs (step))));
53     if (digits > 5)
54       digits = 5;
55   }
56 
57   return digits;
58 }
59 
VScale(double min,double max,double step)60 VScale::VScale(double min, double max, double step)
61 :
62   // Mark this class as non-derived to allow C++ vfuncs to be skipped.
63   Glib::ObjectBase(0),
64   Scale(Glib::ConstructParams(vscale_class_.init()))
65 {
66   Adjustment* adjustment = manage(new Adjustment(min, min, max, step, 10 * step, step));
67   // The adjustment will be destroyed along with the object
68   set_adjustment(*adjustment);
69 
70   set_digits( calc_digits_(step) );
71 }
72 
VScale(Adjustment & adjustment)73 VScale::VScale(Adjustment& adjustment)
74 :
75   // Mark this class as non-derived to allow C++ vfuncs to be skipped.
76   Glib::ObjectBase(0),
77   Scale(Glib::ConstructParams(vscale_class_.init()))
78 {
79   set_adjustment(adjustment);
80 }
81 
VScale()82 VScale::VScale()
83 :
84   // Mark this class as non-derived to allow C++ vfuncs to be skipped.
85   Glib::ObjectBase(0),
86   Scale(Glib::ConstructParams(vscale_class_.init()))
87 {
88   Adjustment* adjustment = manage(new Adjustment(0.0, 0.0, 0.0,
89 						  0.0, 0.0, 0.0));
90   // The adjustment will be destroyed along with the object
91   set_adjustment(*adjustment);
92 }
93 
94 
HScale(double min,double max,double step)95 HScale::HScale(double min, double max, double step)
96 :
97   // Mark this class as non-derived to allow C++ vfuncs to be skipped.
98   Glib::ObjectBase(0),
99   Scale(Glib::ConstructParams(hscale_class_.init()))
100 {
101   Adjustment* adjustment = manage(new Adjustment(min, min, max, step, 10 * step, step));
102   // The adjustment will be destroyed along with the object
103   set_adjustment(*adjustment);
104 
105   set_digits( calc_digits_(step) );
106 }
107 
HScale()108 HScale::HScale()
109 :
110   // Mark this class as non-derived to allow C++ vfuncs to be skipped.
111   Glib::ObjectBase(0),
112   Scale(Glib::ConstructParams(hscale_class_.init()))
113 {
114   Adjustment* adjustment = manage(new Adjustment(0.0, 0.0, 0.0,
115 						  0.0, 0.0, 0.0));
116   // The adjustment will be destroyed along with the object
117   set_adjustment(*adjustment);
118 }
119 
HScale(Adjustment & adjustment)120 HScale::HScale(Adjustment& adjustment)
121 :
122   // Mark this class as non-derived to allow C++ vfuncs to be skipped.
123   Glib::ObjectBase(0),
124   Scale(Glib::ConstructParams(hscale_class_.init()))
125 {
126   set_adjustment(adjustment);
127 }
128 
129 } // namespace Gtk
130 
131 
132 namespace
133 {
134 
135 
Scale_signal_format_value_callback(GtkScale * self,gdouble p0,void * data)136 static gchar* Scale_signal_format_value_callback(GtkScale* self, gdouble p0,void* data)
137 {
138   using namespace Gtk;
139   typedef sigc::slot< Glib::ustring,double > SlotType;
140 
141   Scale* obj = dynamic_cast<Scale*>(Glib::ObjectBase::_get_current_wrapper((GObject*) self));
142   // Do not try to call a signal on a disassociated wrapper.
143   if(obj)
144   {
145     try
146     {
147       if(sigc::slot_base *const slot = Glib::SignalProxyNormal::data_to_slot(data))
148         return (strlen((*static_cast<SlotType*>(slot))(p0
149 ).c_str()) ? g_strdup((*static_cast<SlotType*>(slot))(p0
150 ).c_str()) : 0);
151     }
152     catch(...)
153     {
154        Glib::exception_handlers_invoke();
155     }
156   }
157 
158   typedef gchar* RType;
159   return RType();
160 }
161 
Scale_signal_format_value_notify_callback(GtkScale * self,gdouble p0,void * data)162 static gchar* Scale_signal_format_value_notify_callback(GtkScale* self, gdouble p0, void* data)
163 {
164   using namespace Gtk;
165   typedef sigc::slot< void,double > SlotType;
166 
167   Scale* obj = dynamic_cast<Scale*>(Glib::ObjectBase::_get_current_wrapper((GObject*) self));
168   // Do not try to call a signal on a disassociated wrapper.
169   if(obj)
170   {
171     try
172     {
173       if(sigc::slot_base *const slot = Glib::SignalProxyNormal::data_to_slot(data))
174         (*static_cast<SlotType*>(slot))(p0
175 );
176     }
177     catch(...)
178     {
179       Glib::exception_handlers_invoke();
180     }
181   }
182 
183   typedef gchar* RType;
184   return RType();
185 }
186 
187 static const Glib::SignalProxyInfo Scale_signal_format_value_info =
188 {
189   "format_value",
190   (GCallback) &Scale_signal_format_value_callback,
191   (GCallback) &Scale_signal_format_value_notify_callback
192 };
193 
194 
195 } // anonymous namespace
196 
197 
198 namespace Glib
199 {
200 
wrap(GtkScale * object,bool take_copy)201 Gtk::Scale* wrap(GtkScale* object, bool take_copy)
202 {
203   return dynamic_cast<Gtk::Scale *> (Glib::wrap_auto ((GObject*)(object), take_copy));
204 }
205 
206 } /* namespace Glib */
207 
208 namespace Gtk
209 {
210 
211 
212 /* The *_Class implementation: */
213 
init()214 const Glib::Class& Scale_Class::init()
215 {
216   if(!gtype_) // create the GType if necessary
217   {
218     // Glib::Class has to know the class init function to clone custom types.
219     class_init_func_ = &Scale_Class::class_init_function;
220 
221     // This is actually just optimized away, apparently with no harm.
222     // Make sure that the parent type has been created.
223     //CppClassParent::CppObjectType::get_type();
224 
225     // Create the wrapper type, with the same class/instance size as the base type.
226     register_derived_type(gtk_scale_get_type());
227 
228     // Add derived versions of interfaces, if the C type implements any interfaces:
229 
230   }
231 
232   return *this;
233 }
234 
235 
class_init_function(void * g_class,void * class_data)236 void Scale_Class::class_init_function(void* g_class, void* class_data)
237 {
238   BaseClassType *const klass = static_cast<BaseClassType*>(g_class);
239   CppClassParent::class_init_function(klass, class_data);
240 
241   klass->draw_value = &draw_value_vfunc_callback;
242 
243   klass->format_value = &format_value_callback;
244 }
245 
draw_value_vfunc_callback(GtkScale * self)246 void Scale_Class::draw_value_vfunc_callback(GtkScale* self)
247 {
248   Glib::ObjectBase *const obj_base = static_cast<Glib::ObjectBase*>(
249       Glib::ObjectBase::_get_current_wrapper((GObject*)self));
250 
251   // Non-gtkmmproc-generated custom classes implicitly call the default
252   // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
253   // generated classes can use this optimisation, which avoids the unnecessary
254   // parameter conversions if there is no possibility of the virtual function
255   // being overridden:
256   if(obj_base && obj_base->is_derived_())
257   {
258     CppObjectType *const obj = dynamic_cast<CppObjectType* const>(obj_base);
259     if(obj) // This can be NULL during destruction.
260     {
261       try // Trap C++ exceptions which would normally be lost because this is a C callback.
262       {
263         // Call the virtual member method, which derived classes might override.
264         obj->draw_value_vfunc();
265         return;
266       }
267       catch(...)
268       {
269         Glib::exception_handlers_invoke();
270       }
271     }
272   }
273 
274   BaseClassType *const base = static_cast<BaseClassType*>(
275       g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
276   );
277 
278   // Call the original underlying C function:
279   if(base && base->draw_value)
280   {
281     (*base->draw_value)(self);
282   }
283 
284 }
285 
format_value_callback(GtkScale * self,gdouble p0)286 gchar* Scale_Class::format_value_callback(GtkScale* self, gdouble p0)
287 {
288   Glib::ObjectBase *const obj_base = static_cast<Glib::ObjectBase*>(
289       Glib::ObjectBase::_get_current_wrapper((GObject*)self));
290 
291   // Non-gtkmmproc-generated custom classes implicitly call the default
292   // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
293   // generated classes can use this optimisation, which avoids the unnecessary
294   // parameter conversions if there is no possibility of the virtual function
295   // being overridden:
296   if(obj_base && obj_base->is_derived_())
297   {
298     CppObjectType *const obj = dynamic_cast<CppObjectType* const>(obj_base);
299     if(obj) // This can be NULL during destruction.
300     {
301       try // Trap C++ exceptions which would normally be lost because this is a C callback.
302       {
303         // Call the virtual member method, which derived classes might override.
304         return (strlen(obj->on_format_value(p0
305 ).c_str()) ? g_strdup(obj->on_format_value(p0
306 ).c_str()) : 0);
307       }
308       catch(...)
309       {
310         Glib::exception_handlers_invoke();
311       }
312     }
313   }
314 
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).
317     );
318 
319   // Call the original underlying C function:
320   if(base && base->format_value)
321     return (*base->format_value)(self, p0);
322 
323   typedef gchar* RType;
324   return RType();
325 }
326 
327 
wrap_new(GObject * o)328 Glib::ObjectBase* Scale_Class::wrap_new(GObject* o)
329 {
330   return manage(new Scale((GtkScale*)(o)));
331 
332 }
333 
334 
335 /* The implementation: */
336 
Scale(const Glib::ConstructParams & construct_params)337 Scale::Scale(const Glib::ConstructParams& construct_params)
338 :
339   Gtk::Range(construct_params)
340 {
341   }
342 
Scale(GtkScale * castitem)343 Scale::Scale(GtkScale* castitem)
344 :
345   Gtk::Range((GtkRange*)(castitem))
346 {
347   }
348 
~Scale()349 Scale::~Scale()
350 {
351   destroy_();
352 }
353 
354 Scale::CppClassType Scale::scale_class_; // initialize static member
355 
get_type()356 GType Scale::get_type()
357 {
358   return scale_class_.init().get_type();
359 }
360 
361 
get_base_type()362 GType Scale::get_base_type()
363 {
364   return gtk_scale_get_type();
365 }
366 
367 
Scale()368 Scale::Scale()
369 :
370   // Mark this class as non-derived to allow C++ vfuncs to be skipped.
371   Glib::ObjectBase(0),
372   Gtk::Range(Glib::ConstructParams(scale_class_.init()))
373 {
374 
375 
376 }
377 
set_digits(int digits)378 void Scale::set_digits(int digits)
379 {
380   gtk_scale_set_digits(gobj(), digits);
381 }
382 
get_digits() const383 int Scale::get_digits() const
384 {
385   return gtk_scale_get_digits(const_cast<GtkScale*>(gobj()));
386 }
387 
set_draw_value(bool draw_value)388 void Scale::set_draw_value(bool draw_value)
389 {
390   gtk_scale_set_draw_value(gobj(), static_cast<int>(draw_value));
391 }
392 
get_draw_value() const393 bool Scale::get_draw_value() const
394 {
395   return gtk_scale_get_draw_value(const_cast<GtkScale*>(gobj()));
396 }
397 
set_value_pos(PositionType pos)398 void Scale::set_value_pos(PositionType pos)
399 {
400   gtk_scale_set_value_pos(gobj(), ((GtkPositionType)(pos)));
401 }
402 
get_value_pos() const403 PositionType Scale::get_value_pos() const
404 {
405   return ((PositionType)(gtk_scale_get_value_pos(const_cast<GtkScale*>(gobj()))));
406 }
407 
get_layout()408 Glib::RefPtr<Pango::Layout> Scale::get_layout()
409 {
410   Glib::RefPtr<Pango::Layout> retvalue = Glib::wrap(gtk_scale_get_layout(gobj()));
411   if(retvalue)
412     retvalue->reference(); //The function does not do a ref for us.
413   return retvalue;
414 }
415 
get_layout() const416 Glib::RefPtr<const Pango::Layout> Scale::get_layout() const
417 {
418   return const_cast<Scale*>(this)->get_layout();
419 }
420 
get_layout_offsets(int & x,int & y) const421 void Scale::get_layout_offsets(int& x, int& y) const
422 {
423   gtk_scale_get_layout_offsets(const_cast<GtkScale*>(gobj()), &(x), &(y));
424 }
425 
add_mark(double value,PositionType position,const Glib::ustring & markup)426 void Scale::add_mark(double value, PositionType position, const Glib::ustring& markup)
427 {
428   gtk_scale_add_mark(gobj(), value, ((GtkPositionType)(position)), markup.c_str());
429 }
430 
clear_marks()431 void Scale::clear_marks()
432 {
433   gtk_scale_clear_marks(gobj());
434 }
435 
436 
signal_format_value()437 Glib::SignalProxy1< Glib::ustring,double > Scale::signal_format_value()
438 {
439   return Glib::SignalProxy1< Glib::ustring,double >(this, &Scale_signal_format_value_info);
440 }
441 
442 
property_digits()443 Glib::PropertyProxy< int > Scale::property_digits()
444 {
445   return Glib::PropertyProxy< int >(this, "digits");
446 }
447 
property_digits() const448 Glib::PropertyProxy_ReadOnly< int > Scale::property_digits() const
449 {
450   return Glib::PropertyProxy_ReadOnly< int >(this, "digits");
451 }
452 
property_draw_value()453 Glib::PropertyProxy< bool > Scale::property_draw_value()
454 {
455   return Glib::PropertyProxy< bool >(this, "draw-value");
456 }
457 
property_draw_value() const458 Glib::PropertyProxy_ReadOnly< bool > Scale::property_draw_value() const
459 {
460   return Glib::PropertyProxy_ReadOnly< bool >(this, "draw-value");
461 }
462 
property_value_pos()463 Glib::PropertyProxy< PositionType > Scale::property_value_pos()
464 {
465   return Glib::PropertyProxy< PositionType >(this, "value-pos");
466 }
467 
property_value_pos() const468 Glib::PropertyProxy_ReadOnly< PositionType > Scale::property_value_pos() const
469 {
470   return Glib::PropertyProxy_ReadOnly< PositionType >(this, "value-pos");
471 }
472 
473 
on_format_value(double value)474 Glib::ustring Gtk::Scale::on_format_value(double value)
475 {
476   BaseClassType *const base = static_cast<BaseClassType*>(
477       g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_)) // Get the parent class of the object class (The original underlying C class).
478   );
479 
480   if(base && base->format_value)
481     return Glib::convert_const_gchar_ptr_to_ustring((*base->format_value)(gobj(),value));
482 
483   typedef Glib::ustring RType;
484   return RType();
485 }
486 
draw_value_vfunc()487 void Gtk::Scale::draw_value_vfunc()
488 {
489   BaseClassType *const base = static_cast<BaseClassType*>(
490       g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_)) // Get the parent class of the object class (The original underlying C class).
491   );
492 
493   if(base && base->draw_value)
494   {
495     (*base->draw_value)(gobj());
496   }
497 }
498 
499 
500 } // namespace Gtk
501 
502 
503 namespace Glib
504 {
505 
wrap(GtkVScale * object,bool take_copy)506 Gtk::VScale* wrap(GtkVScale* object, bool take_copy)
507 {
508   return dynamic_cast<Gtk::VScale *> (Glib::wrap_auto ((GObject*)(object), take_copy));
509 }
510 
511 } /* namespace Glib */
512 
513 namespace Gtk
514 {
515 
516 
517 /* The *_Class implementation: */
518 
init()519 const Glib::Class& VScale_Class::init()
520 {
521   if(!gtype_) // create the GType if necessary
522   {
523     // Glib::Class has to know the class init function to clone custom types.
524     class_init_func_ = &VScale_Class::class_init_function;
525 
526     // This is actually just optimized away, apparently with no harm.
527     // Make sure that the parent type has been created.
528     //CppClassParent::CppObjectType::get_type();
529 
530     // Create the wrapper type, with the same class/instance size as the base type.
531     register_derived_type(gtk_vscale_get_type());
532 
533     // Add derived versions of interfaces, if the C type implements any interfaces:
534 
535   }
536 
537   return *this;
538 }
539 
540 
class_init_function(void * g_class,void * class_data)541 void VScale_Class::class_init_function(void* g_class, void* class_data)
542 {
543   BaseClassType *const klass = static_cast<BaseClassType*>(g_class);
544   CppClassParent::class_init_function(klass, class_data);
545 
546 
547 }
548 
549 
wrap_new(GObject * o)550 Glib::ObjectBase* VScale_Class::wrap_new(GObject* o)
551 {
552   return manage(new VScale((GtkVScale*)(o)));
553 
554 }
555 
556 
557 /* The implementation: */
558 
VScale(const Glib::ConstructParams & construct_params)559 VScale::VScale(const Glib::ConstructParams& construct_params)
560 :
561   Gtk::Scale(construct_params)
562 {
563   }
564 
VScale(GtkVScale * castitem)565 VScale::VScale(GtkVScale* castitem)
566 :
567   Gtk::Scale((GtkScale*)(castitem))
568 {
569   }
570 
~VScale()571 VScale::~VScale()
572 {
573   destroy_();
574 }
575 
576 VScale::CppClassType VScale::vscale_class_; // initialize static member
577 
get_type()578 GType VScale::get_type()
579 {
580   return vscale_class_.init().get_type();
581 }
582 
583 
get_base_type()584 GType VScale::get_base_type()
585 {
586   return gtk_vscale_get_type();
587 }
588 
589 
590 } // namespace Gtk
591 
592 
593 namespace Glib
594 {
595 
wrap(GtkHScale * object,bool take_copy)596 Gtk::HScale* wrap(GtkHScale* object, bool take_copy)
597 {
598   return dynamic_cast<Gtk::HScale *> (Glib::wrap_auto ((GObject*)(object), take_copy));
599 }
600 
601 } /* namespace Glib */
602 
603 namespace Gtk
604 {
605 
606 
607 /* The *_Class implementation: */
608 
init()609 const Glib::Class& HScale_Class::init()
610 {
611   if(!gtype_) // create the GType if necessary
612   {
613     // Glib::Class has to know the class init function to clone custom types.
614     class_init_func_ = &HScale_Class::class_init_function;
615 
616     // This is actually just optimized away, apparently with no harm.
617     // Make sure that the parent type has been created.
618     //CppClassParent::CppObjectType::get_type();
619 
620     // Create the wrapper type, with the same class/instance size as the base type.
621     register_derived_type(gtk_hscale_get_type());
622 
623     // Add derived versions of interfaces, if the C type implements any interfaces:
624 
625   }
626 
627   return *this;
628 }
629 
630 
class_init_function(void * g_class,void * class_data)631 void HScale_Class::class_init_function(void* g_class, void* class_data)
632 {
633   BaseClassType *const klass = static_cast<BaseClassType*>(g_class);
634   CppClassParent::class_init_function(klass, class_data);
635 
636 
637 }
638 
639 
wrap_new(GObject * o)640 Glib::ObjectBase* HScale_Class::wrap_new(GObject* o)
641 {
642   return manage(new HScale((GtkHScale*)(o)));
643 
644 }
645 
646 
647 /* The implementation: */
648 
HScale(const Glib::ConstructParams & construct_params)649 HScale::HScale(const Glib::ConstructParams& construct_params)
650 :
651   Gtk::Scale(construct_params)
652 {
653   }
654 
HScale(GtkHScale * castitem)655 HScale::HScale(GtkHScale* castitem)
656 :
657   Gtk::Scale((GtkScale*)(castitem))
658 {
659   }
660 
~HScale()661 HScale::~HScale()
662 {
663   destroy_();
664 }
665 
666 HScale::CppClassType HScale::hscale_class_; // initialize static member
667 
get_type()668 GType HScale::get_type()
669 {
670   return hscale_class_.init().get_type();
671 }
672 
673 
get_base_type()674 GType HScale::get_base_type()
675 {
676   return gtk_hscale_get_type();
677 }
678 
679 
680 } // namespace Gtk
681 
682 
683