[gtkmm] CellArea, CellRenderer, Widget: Modify and add some vfuncs.



commit f59cf50729a41b7d6d48b42c0a12462148596051
Author: Kjell Ahlstedt <kjell ahlstedt bredband net>
Date:   Thu Feb 3 09:38:18 2011 +0100

    CellArea, CellRenderer, Widget: Modify and add some vfuncs.
    
    * gtk/src/gtk_vfuncs.defs:
    * gtk/src/cellarea.[hg|ccg]:
    * gtk/src/cellrenderer.[hg|ccg]: Add vfuncs get_request_mode,
    get_preferred_[width|height_for_width|height|width_for_height].
    * gtk/src/widget.[hg|ccg]: Change int* to int& in
    get_preferred_[width|height_for_width|height|width_for_height]_vfunc.
    Bug 639073, comment 19.

 ChangeLog                |   12 +++
 gtk/src/cellarea.ccg     |  187 +++++++++++++++++++++++++++++++++++++++++++++-
 gtk/src/cellarea.hg      |    8 ++
 gtk/src/cellrenderer.ccg |  183 +++++++++++++++++++++++++++++++++++++++++++++
 gtk/src/cellrenderer.hg  |    6 ++
 gtk/src/gtk_vfuncs.defs  |  100 ++++++++++++++++++++++++
 gtk/src/widget.ccg       |  183 +++++++++++++++++++++++++++++++++++++++++++++
 gtk/src/widget.hg        |    8 +-
 8 files changed, 682 insertions(+), 5 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 2ce1927..8d25cf5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2011-02-03  Kjell Ahlstedt  <kjell ahlstedt bredband net>
+
+  CellArea, CellRenderer, Widget: Modify and add some vfuncs.
+
+  * gtk/src/gtk_vfuncs.defs:
+  * gtk/src/cellarea.[hg|ccg]:
+  * gtk/src/cellrenderer.[hg|ccg]: Add vfuncs get_request_mode,
+ 	get_preferred_[width|height_for_width|height|width_for_height].
+ 	* gtk/src/widget.[hg|ccg]: Change int* to int& in 
+ 	get_preferred_[width|height_for_width|height|width_for_height]_vfunc.
+  Bug #639073, comment 19.
+
 2.99.4:
 
 2011-02-10  Murray Cumming  <murrayc murrayc com>
diff --git a/gtk/src/cellarea.ccg b/gtk/src/cellarea.ccg
index fd09ff7..fab95e5 100644
--- a/gtk/src/cellarea.ccg
+++ b/gtk/src/cellarea.ccg
@@ -20,7 +20,192 @@
 
 namespace Gtk
 {
+//These vfunc callbacks are custom implemented because we want the output
+//arguments of the C++ vfuncs to be int& (not int*), and the vfunc_callback
+//functions may be called from gtk+ with a NULL pointer.
+void CellArea_Class::get_preferred_width_vfunc_callback(GtkCellArea* self, GtkCellAreaContext* context, GtkWidget* widget, gint* minimum_width, gint* natural_width)
+{
+  Glib::ObjectBase *const obj_base = static_cast<Glib::ObjectBase*>(
+      Glib::ObjectBase::_get_current_wrapper((GObject*)self));
 
-} //namespace Gtk
+  // Non-gtkmmproc-generated custom classes implicitly call the default
+  // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
+  // generated classes can use this optimisation, which avoids the unnecessary
+  // parameter conversions if there is no possibility of the virtual function
+  // being overridden:
+  if(obj_base && obj_base->is_derived_())
+  {
+    CppObjectType *const obj = dynamic_cast<CppObjectType* const>(obj_base);
+    if(obj) // This can be NULL during destruction.
+    {
+      #ifdef GLIBMM_EXCEPTIONS_ENABLED
+      try // Trap C++ exceptions which would normally be lost because this is a C callback.
+      {
+      #endif //GLIBMM_EXCEPTIONS_ENABLED
+        // Call the virtual member method, which derived classes might override.
+        int min_width = 0;
+        int nat_width = 0;
+        obj->get_preferred_width_vfunc(Glib::wrap(context, true),
+             *Glib::wrap(widget),
+             (minimum_width ? *minimum_width : min_width),
+             (natural_width ? *natural_width : nat_width));
+        return;
+      #ifdef GLIBMM_EXCEPTIONS_ENABLED
+      }
+      catch(...)
+      {
+        Glib::exception_handlers_invoke();
+      }
+      #endif //GLIBMM_EXCEPTIONS_ENABLED
+    }
+  }
+  
+  BaseClassType *const base = static_cast<BaseClassType*>(
+      g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
+  );
+
+  // Call the original underlying C function:
+  if(base && base->get_preferred_width)
+    (*base->get_preferred_width)(self, context, widget, minimum_width, natural_width);
+}
+
+void CellArea_Class::get_preferred_height_for_width_vfunc_callback(GtkCellArea* self, GtkCellAreaContext* context, GtkWidget* widget, gint width, gint* minimum_height, gint* natural_height)
+{
+  Glib::ObjectBase *const obj_base = static_cast<Glib::ObjectBase*>(
+      Glib::ObjectBase::_get_current_wrapper((GObject*)self));
+
+  // Non-gtkmmproc-generated custom classes implicitly call the default
+  // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
+  // generated classes can use this optimisation, which avoids the unnecessary
+  // parameter conversions if there is no possibility of the virtual function
+  // being overridden:
+  if(obj_base && obj_base->is_derived_())
+  {
+    CppObjectType *const obj = dynamic_cast<CppObjectType* const>(obj_base);
+    if(obj) // This can be NULL during destruction.
+    {
+      #ifdef GLIBMM_EXCEPTIONS_ENABLED
+      try // Trap C++ exceptions which would normally be lost because this is a C callback.
+      {
+      #endif //GLIBMM_EXCEPTIONS_ENABLED
+        // Call the virtual member method, which derived classes might override.
+        int min_height = 0;
+        int nat_height = 0;
+        obj->get_preferred_height_for_width_vfunc(Glib::wrap(context, true),
+             *Glib::wrap(widget), width,
+             (minimum_height ? *minimum_height : min_height),
+             (natural_height ? *natural_height : nat_height));
+        return;
+      #ifdef GLIBMM_EXCEPTIONS_ENABLED
+      }
+      catch(...)
+      {
+        Glib::exception_handlers_invoke();
+      }
+      #endif //GLIBMM_EXCEPTIONS_ENABLED
+    }
+  }
+  
+  BaseClassType *const base = static_cast<BaseClassType*>(
+      g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
+  );
+
+  // Call the original underlying C function:
+  if(base && base->get_preferred_height_for_width)
+    (*base->get_preferred_height_for_width)(self, context, widget, width, minimum_height, natural_height);
+}
+
+void CellArea_Class::get_preferred_height_vfunc_callback(GtkCellArea* self, GtkCellAreaContext* context, GtkWidget* widget, gint* minimum_height, gint* natural_height)
+{
+  Glib::ObjectBase *const obj_base = static_cast<Glib::ObjectBase*>(
+      Glib::ObjectBase::_get_current_wrapper((GObject*)self));
+
+  // Non-gtkmmproc-generated custom classes implicitly call the default
+  // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
+  // generated classes can use this optimisation, which avoids the unnecessary
+  // parameter conversions if there is no possibility of the virtual function
+  // being overridden:
+  if(obj_base && obj_base->is_derived_())
+  {
+    CppObjectType *const obj = dynamic_cast<CppObjectType* const>(obj_base);
+    if(obj) // This can be NULL during destruction.
+    {
+      #ifdef GLIBMM_EXCEPTIONS_ENABLED
+      try // Trap C++ exceptions which would normally be lost because this is a C callback.
+      {
+      #endif //GLIBMM_EXCEPTIONS_ENABLED
+        // Call the virtual member method, which derived classes might override.
+        int min_height = 0;
+        int nat_height = 0;
+        obj->get_preferred_height_vfunc(Glib::wrap(context, true),
+             *Glib::wrap(widget),
+             (minimum_height ? *minimum_height : min_height),
+             (natural_height ? *natural_height : nat_height));
+        return;
+      #ifdef GLIBMM_EXCEPTIONS_ENABLED
+      }
+      catch(...)
+      {
+        Glib::exception_handlers_invoke();
+      }
+      #endif //GLIBMM_EXCEPTIONS_ENABLED
+    }
+  }
+  
+  BaseClassType *const base = static_cast<BaseClassType*>(
+      g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
+  );
+
+  // Call the original underlying C function:
+  if(base && base->get_preferred_height)
+    (*base->get_preferred_height)(self, context, widget, minimum_height, natural_height);
+}
+
+void CellArea_Class::get_preferred_width_for_height_vfunc_callback(GtkCellArea* self, GtkCellAreaContext* context, GtkWidget* widget, gint height, gint* minimum_width, gint* natural_width)
+{
+  Glib::ObjectBase *const obj_base = static_cast<Glib::ObjectBase*>(
+      Glib::ObjectBase::_get_current_wrapper((GObject*)self));
+
+  // Non-gtkmmproc-generated custom classes implicitly call the default
+  // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
+  // generated classes can use this optimisation, which avoids the unnecessary
+  // parameter conversions if there is no possibility of the virtual function
+  // being overridden:
+  if(obj_base && obj_base->is_derived_())
+  {
+    CppObjectType *const obj = dynamic_cast<CppObjectType* const>(obj_base);
+    if(obj) // This can be NULL during destruction.
+    {
+      #ifdef GLIBMM_EXCEPTIONS_ENABLED
+      try // Trap C++ exceptions which would normally be lost because this is a C callback.
+      {
+      #endif //GLIBMM_EXCEPTIONS_ENABLED
+        // Call the virtual member method, which derived classes might override.
+        int min_width = 0;
+        int nat_width = 0;
+        obj->get_preferred_width_for_height_vfunc(Glib::wrap(context, true),
+             *Glib::wrap(widget), height,
+             (minimum_width ? *minimum_width : min_width),
+             (natural_width ? *natural_width : nat_width));
+        return;
+      #ifdef GLIBMM_EXCEPTIONS_ENABLED
+      }
+      catch(...)
+      {
+        Glib::exception_handlers_invoke();
+      }
+      #endif //GLIBMM_EXCEPTIONS_ENABLED
+    }
+  }
+  
+  BaseClassType *const base = static_cast<BaseClassType*>(
+      g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
+  );
 
+  // Call the original underlying C function:
+  if(base && base->get_preferred_width_for_height)
+    (*base->get_preferred_width_for_height)(self, context, widget, height, minimum_width, natural_width);
+}
+
+} //namespace Gtk
 
diff --git a/gtk/src/cellarea.hg b/gtk/src/cellarea.hg
index aa6c797..7379fdd 100644
--- a/gtk/src/cellarea.hg
+++ b/gtk/src/cellarea.hg
@@ -106,6 +106,14 @@ public:
 
   _WRAP_METHOD(void request_renderer(CellRenderer& renderer, Orientation orientation, Widget& widget, int for_size, int& minimum_size, int& natural_size), gtk_cell_area_request_renderer)
 
+protected:
+  #m4 _CONVERSION(`GtkCellAreaContext*',`const Glib::RefPtr<CellAreaContext>&',`Glib::wrap($3, true)')
+
+  _WRAP_VFUNC(SizeRequestMode get_request_mode() const, get_request_mode)
+  _WRAP_VFUNC(void get_preferred_width(const Glib::RefPtr<CellAreaContext>& context, Widget& widget, int& minimum_width, int& natural_width), get_preferred_width, custom_vfunc_callback)
+  _WRAP_VFUNC(void get_preferred_height_for_width(const Glib::RefPtr<CellAreaContext>& context, Widget& widget, int width, int& minimum_height, int& natural_height), get_preferred_height_for_width, custom_vfunc_callback)
+  _WRAP_VFUNC(void get_preferred_height(const Glib::RefPtr<CellAreaContext>& context, Widget& widget, int& minimum_height, int& natural_height), get_preferred_height, custom_vfunc_callback)
+  _WRAP_VFUNC(void get_preferred_width_for_height(const Glib::RefPtr<CellAreaContext>& context, Widget& widget, int height, int& minimum_width, int& natural_width), get_preferred_width_for_height, custom_vfunc_callback)
 };
 
 } // namespace Gtk
diff --git a/gtk/src/cellrenderer.ccg b/gtk/src/cellrenderer.ccg
index 4355483..ed1266e 100644
--- a/gtk/src/cellrenderer.ccg
+++ b/gtk/src/cellrenderer.ccg
@@ -29,4 +29,187 @@ Glib::PropertyProxy_Base CellRenderer::_property_renderable()
   return Glib::PropertyProxy<int>(0, 0); // shut up warnings
 }
 
+//These vfunc callbacks are custom implemented because we want the output
+//arguments of the C++ vfuncs to be int& (not int*), and the vfunc_callback
+//functions may be called from gtk+ with a NULL pointer.
+void CellRenderer_Class::get_preferred_width_vfunc_callback(GtkCellRenderer* self, GtkWidget* widget, gint* minimum_width, gint* natural_width)
+{
+  Glib::ObjectBase *const obj_base = static_cast<Glib::ObjectBase*>(
+      Glib::ObjectBase::_get_current_wrapper((GObject*)self));
+
+  // Non-gtkmmproc-generated custom classes implicitly call the default
+  // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
+  // generated classes can use this optimisation, which avoids the unnecessary
+  // parameter conversions if there is no possibility of the virtual function
+  // being overridden:
+  if(obj_base && obj_base->is_derived_())
+  {
+    CppObjectType *const obj = dynamic_cast<CppObjectType* const>(obj_base);
+    if(obj) // This can be NULL during destruction.
+    {
+      #ifdef GLIBMM_EXCEPTIONS_ENABLED
+      try // Trap C++ exceptions which would normally be lost because this is a C callback.
+      {
+      #endif //GLIBMM_EXCEPTIONS_ENABLED
+        // Call the virtual member method, which derived classes might override.
+        int min_width = 0;
+        int nat_width = 0;
+        obj->get_preferred_width_vfunc(*Glib::wrap(widget),
+             (minimum_width ? *minimum_width : min_width),
+             (natural_width ? *natural_width : nat_width));
+        return;
+      #ifdef GLIBMM_EXCEPTIONS_ENABLED
+      }
+      catch(...)
+      {
+        Glib::exception_handlers_invoke();
+      }
+      #endif //GLIBMM_EXCEPTIONS_ENABLED
+    }
+  }
+  
+  BaseClassType *const base = static_cast<BaseClassType*>(
+      g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
+  );
+
+  // Call the original underlying C function:
+  if(base && base->get_preferred_width)
+    (*base->get_preferred_width)(self, widget, minimum_width, natural_width);
+}
+
+void CellRenderer_Class::get_preferred_height_for_width_vfunc_callback(GtkCellRenderer* self, GtkWidget* widget, gint width, gint* minimum_height, gint* natural_height)
+{
+  Glib::ObjectBase *const obj_base = static_cast<Glib::ObjectBase*>(
+      Glib::ObjectBase::_get_current_wrapper((GObject*)self));
+
+  // Non-gtkmmproc-generated custom classes implicitly call the default
+  // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
+  // generated classes can use this optimisation, which avoids the unnecessary
+  // parameter conversions if there is no possibility of the virtual function
+  // being overridden:
+  if(obj_base && obj_base->is_derived_())
+  {
+    CppObjectType *const obj = dynamic_cast<CppObjectType* const>(obj_base);
+    if(obj) // This can be NULL during destruction.
+    {
+      #ifdef GLIBMM_EXCEPTIONS_ENABLED
+      try // Trap C++ exceptions which would normally be lost because this is a C callback.
+      {
+      #endif //GLIBMM_EXCEPTIONS_ENABLED
+        // Call the virtual member method, which derived classes might override.
+        int min_height = 0;
+        int nat_height = 0;
+        obj->get_preferred_height_for_width_vfunc(*Glib::wrap(widget), width,
+             (minimum_height ? *minimum_height : min_height),
+             (natural_height ? *natural_height : nat_height));
+        return;
+      #ifdef GLIBMM_EXCEPTIONS_ENABLED
+      }
+      catch(...)
+      {
+        Glib::exception_handlers_invoke();
+      }
+      #endif //GLIBMM_EXCEPTIONS_ENABLED
+    }
+  }
+  
+  BaseClassType *const base = static_cast<BaseClassType*>(
+      g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
+  );
+
+  // Call the original underlying C function:
+  if(base && base->get_preferred_height_for_width)
+    (*base->get_preferred_height_for_width)(self, widget, width, minimum_height, natural_height);
+}
+
+void CellRenderer_Class::get_preferred_height_vfunc_callback(GtkCellRenderer* self, GtkWidget* widget, gint* minimum_height, gint* natural_height)
+{
+  Glib::ObjectBase *const obj_base = static_cast<Glib::ObjectBase*>(
+      Glib::ObjectBase::_get_current_wrapper((GObject*)self));
+
+  // Non-gtkmmproc-generated custom classes implicitly call the default
+  // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
+  // generated classes can use this optimisation, which avoids the unnecessary
+  // parameter conversions if there is no possibility of the virtual function
+  // being overridden:
+  if(obj_base && obj_base->is_derived_())
+  {
+    CppObjectType *const obj = dynamic_cast<CppObjectType* const>(obj_base);
+    if(obj) // This can be NULL during destruction.
+    {
+      #ifdef GLIBMM_EXCEPTIONS_ENABLED
+      try // Trap C++ exceptions which would normally be lost because this is a C callback.
+      {
+      #endif //GLIBMM_EXCEPTIONS_ENABLED
+        // Call the virtual member method, which derived classes might override.
+        int min_height = 0;
+        int nat_height = 0;
+        obj->get_preferred_height_vfunc(*Glib::wrap(widget),
+             (minimum_height ? *minimum_height : min_height),
+             (natural_height ? *natural_height : nat_height));
+        return;
+      #ifdef GLIBMM_EXCEPTIONS_ENABLED
+      }
+      catch(...)
+      {
+        Glib::exception_handlers_invoke();
+      }
+      #endif //GLIBMM_EXCEPTIONS_ENABLED
+    }
+  }
+  
+  BaseClassType *const base = static_cast<BaseClassType*>(
+      g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
+  );
+
+  // Call the original underlying C function:
+  if(base && base->get_preferred_height)
+    (*base->get_preferred_height)(self, widget, minimum_height, natural_height);
+}
+
+void CellRenderer_Class::get_preferred_width_for_height_vfunc_callback(GtkCellRenderer* self, GtkWidget* widget, gint height, gint* minimum_width, gint* natural_width)
+{
+  Glib::ObjectBase *const obj_base = static_cast<Glib::ObjectBase*>(
+      Glib::ObjectBase::_get_current_wrapper((GObject*)self));
+
+  // Non-gtkmmproc-generated custom classes implicitly call the default
+  // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
+  // generated classes can use this optimisation, which avoids the unnecessary
+  // parameter conversions if there is no possibility of the virtual function
+  // being overridden:
+  if(obj_base && obj_base->is_derived_())
+  {
+    CppObjectType *const obj = dynamic_cast<CppObjectType* const>(obj_base);
+    if(obj) // This can be NULL during destruction.
+    {
+      #ifdef GLIBMM_EXCEPTIONS_ENABLED
+      try // Trap C++ exceptions which would normally be lost because this is a C callback.
+      {
+      #endif //GLIBMM_EXCEPTIONS_ENABLED
+        // Call the virtual member method, which derived classes might override.
+        int min_width = 0;
+        int nat_width = 0;
+        obj->get_preferred_width_for_height_vfunc(*Glib::wrap(widget), height,
+             (minimum_width ? *minimum_width : min_width),
+             (natural_width ? *natural_width : nat_width));
+        return;
+      #ifdef GLIBMM_EXCEPTIONS_ENABLED
+      }
+      catch(...)
+      {
+        Glib::exception_handlers_invoke();
+      }
+      #endif //GLIBMM_EXCEPTIONS_ENABLED
+    }
+  }
+  
+  BaseClassType *const base = static_cast<BaseClassType*>(
+      g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
+  );
+
+  // Call the original underlying C function:
+  if(base && base->get_preferred_width_for_height)
+    (*base->get_preferred_width_for_height)(self, widget, height, minimum_width, natural_width);
+}
+
 } // namespace Gtk
diff --git a/gtk/src/cellrenderer.hg b/gtk/src/cellrenderer.hg
index 90542af..f19d762 100644
--- a/gtk/src/cellrenderer.hg
+++ b/gtk/src/cellrenderer.hg
@@ -176,6 +176,12 @@ _CONVERSION(`cairo_t*',`const Cairo::RefPtr<Cairo::Context>&',`Cairo::RefPtr<Cai
 #m4 _CONVERSION(`const GdkRectangle*',`const Gdk::Rectangle&',`Glib::wrap($3)')
 #m4 _CONVERSION(`GdkRectangle*',`const Gdk::Rectangle&',`Glib::wrap($3)')
 
+  _WRAP_VFUNC(SizeRequestMode get_request_mode() const, get_request_mode)
+  _WRAP_VFUNC(void get_preferred_width(Widget& widget, int& minimum_width, int& natural_width) const, get_preferred_width, custom_vfunc_callback)
+  _WRAP_VFUNC(void get_preferred_height_for_width(Widget& widget, int width, int& minimum_height, int& natural_height) const, get_preferred_height_for_width, custom_vfunc_callback)
+  _WRAP_VFUNC(void get_preferred_height(Widget& widget, int& minimum_height, int& natural_height) const, get_preferred_height, custom_vfunc_callback)
+  _WRAP_VFUNC(void get_preferred_width_for_height(Widget& widget, int height, int& minimum_width, int& natural_width) const, get_preferred_width_for_height, custom_vfunc_callback)
+
   _WRAP_VFUNC(void render(
                   const Cairo::RefPtr<Cairo::Context>& cr,
                   Widget& widget,
diff --git a/gtk/src/gtk_vfuncs.defs b/gtk/src/gtk_vfuncs.defs
index 2f51cfb..f62a4de 100644
--- a/gtk/src/gtk_vfuncs.defs
+++ b/gtk/src/gtk_vfuncs.defs
@@ -49,6 +49,59 @@
   )
 )
 
+; GtkCellArea
+
+(define-vfunc get_request_mode
+  (of-object "GtkCellArea")
+  (return-type "GtkSizeRequestMode")
+)
+
+(define-vfunc get_preferred_width
+  (of-object "GtkCellArea")
+  (return-type "void")
+  (parameters
+    '("GtkCellAreaContext*" "context")
+    '("GtkWidget*" "widget")
+    '("gint*" "minimum_width")
+    '("gint*" "natural_width")
+  )
+)
+
+(define-vfunc get_preferred_height_for_width
+  (of-object "GtkCellArea")
+  (return-type "void")
+  (parameters
+    '("GtkCellAreaContext*" "context")
+    '("GtkWidget*" "widget")
+    '("gint" "width")
+    '("gint*" "minimum_height")
+    '("gint*" "natural_height")
+  )
+)
+
+(define-vfunc get_preferred_height
+  (of-object "GtkCellArea")
+  (return-type "void")
+  (parameters
+    '("GtkCellAreaContext*" "context")
+    '("GtkWidget*" "widget")
+    '("gint*" "minimum_height")
+    '("gint*" "natural_height")
+  )
+)
+
+(define-vfunc get_preferred_width_for_height
+  (of-object "GtkCellArea")
+  (return-type "void")
+  (parameters
+    '("GtkCellAreaContext*" "context")
+    '("GtkWidget*" "widget")
+    '("gint" "height")
+    '("gint*" "minimum_width")
+    '("gint*" "natural_width")
+  )
+)
+
 ; GtkCellEditable
 
 (define-vfunc start_editing
@@ -117,6 +170,53 @@
 
 ; GtkCellRenderer
 
+(define-vfunc get_request_mode
+  (of-object "GtkCellRenderer")
+  (return-type "GtkSizeRequestMode")
+)
+
+(define-vfunc get_preferred_width
+  (of-object "GtkCellRenderer")
+  (return-type "void")
+  (parameters
+    '("GtkWidget*" "widget")
+    '("gint*" "minimum_width")
+    '("gint*" "natural_width")
+  )
+)
+
+(define-vfunc get_preferred_height_for_width
+  (of-object "GtkCellRenderer")
+  (return-type "void")
+  (parameters
+    '("GtkWidget*" "widget")
+    '("gint" "width")
+    '("gint*" "minimum_height")
+    '("gint*" "natural_height")
+  )
+)
+
+(define-vfunc get_preferred_height
+  (of-object "GtkCellRenderer")
+  (return-type "void")
+  (parameters
+    '("GtkWidget*" "widget")
+    '("gint*" "minimum_height")
+    '("gint*" "natural_height")
+  )
+)
+
+(define-vfunc get_preferred_width_for_height
+  (of-object "GtkCellRenderer")
+  (return-type "void")
+  (parameters
+    '("GtkWidget*" "widget")
+    '("gint" "height")
+    '("gint*" "minimum_width")
+    '("gint*" "natural_width")
+  )
+)
+
 (define-vfunc get_size
   (of-object "GtkCellRenderer")
   (return-type "none")
diff --git a/gtk/src/widget.ccg b/gtk/src/widget.ccg
index 4527370..c0a86a3 100644
--- a/gtk/src/widget.ccg
+++ b/gtk/src/widget.ccg
@@ -160,6 +160,189 @@ void Widget_Class::drag_data_get_callback(GtkWidget* self, GdkDragContext* p0, G
   }
 }
 
+//These vfunc callbacks are custom implemented because we want the output
+//arguments of the C++ vfuncs to be int& (not int*), and the vfunc_callback
+//functions may be called from gtk+ with a NULL pointer.
+void Widget_Class::get_preferred_width_vfunc_callback(GtkWidget* self, gint* minimum_width, gint* natural_width)
+{
+  Glib::ObjectBase *const obj_base = static_cast<Glib::ObjectBase*>(
+      Glib::ObjectBase::_get_current_wrapper((GObject*)self));
+
+  // Non-gtkmmproc-generated custom classes implicitly call the default
+  // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
+  // generated classes can use this optimisation, which avoids the unnecessary
+  // parameter conversions if there is no possibility of the virtual function
+  // being overridden:
+  if(obj_base && obj_base->is_derived_())
+  {
+    CppObjectType *const obj = dynamic_cast<CppObjectType* const>(obj_base);
+    if(obj) // This can be NULL during destruction.
+    {
+      #ifdef GLIBMM_EXCEPTIONS_ENABLED
+      try // Trap C++ exceptions which would normally be lost because this is a C callback.
+      {
+      #endif //GLIBMM_EXCEPTIONS_ENABLED
+        // Call the virtual member method, which derived classes might override.
+        int min_width = 0;
+        int nat_width = 0;
+        obj->get_preferred_width_vfunc(
+             (minimum_width ? *minimum_width : min_width),
+             (natural_width ? *natural_width : nat_width));
+        return;
+      #ifdef GLIBMM_EXCEPTIONS_ENABLED
+      }
+      catch(...)
+      {
+        Glib::exception_handlers_invoke();
+      }
+      #endif //GLIBMM_EXCEPTIONS_ENABLED
+    }
+  }
+  
+  BaseClassType *const base = static_cast<BaseClassType*>(
+      g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
+  );
+
+  // Call the original underlying C function:
+  if(base && base->get_preferred_width)
+    (*base->get_preferred_width)(self, minimum_width, natural_width);
+}
+
+void Widget_Class::get_preferred_height_for_width_vfunc_callback(GtkWidget* self, gint width, gint* minimum_height, gint* natural_height)
+{
+  Glib::ObjectBase *const obj_base = static_cast<Glib::ObjectBase*>(
+      Glib::ObjectBase::_get_current_wrapper((GObject*)self));
+
+  // Non-gtkmmproc-generated custom classes implicitly call the default
+  // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
+  // generated classes can use this optimisation, which avoids the unnecessary
+  // parameter conversions if there is no possibility of the virtual function
+  // being overridden:
+  if(obj_base && obj_base->is_derived_())
+  {
+    CppObjectType *const obj = dynamic_cast<CppObjectType* const>(obj_base);
+    if(obj) // This can be NULL during destruction.
+    {
+      #ifdef GLIBMM_EXCEPTIONS_ENABLED
+      try // Trap C++ exceptions which would normally be lost because this is a C callback.
+      {
+      #endif //GLIBMM_EXCEPTIONS_ENABLED
+        // Call the virtual member method, which derived classes might override.
+        int min_height = 0;
+        int nat_height = 0;
+        obj->get_preferred_height_for_width_vfunc(width,
+             (minimum_height ? *minimum_height : min_height),
+             (natural_height ? *natural_height : nat_height));
+        return;
+      #ifdef GLIBMM_EXCEPTIONS_ENABLED
+      }
+      catch(...)
+      {
+        Glib::exception_handlers_invoke();
+      }
+      #endif //GLIBMM_EXCEPTIONS_ENABLED
+    }
+  }
+  
+  BaseClassType *const base = static_cast<BaseClassType*>(
+      g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
+  );
+
+  // Call the original underlying C function:
+  if(base && base->get_preferred_height_for_width)
+    (*base->get_preferred_height_for_width)(self, width, minimum_height, natural_height);
+}
+
+void Widget_Class::get_preferred_height_vfunc_callback(GtkWidget* self, gint* minimum_height, gint* natural_height)
+{
+  Glib::ObjectBase *const obj_base = static_cast<Glib::ObjectBase*>(
+      Glib::ObjectBase::_get_current_wrapper((GObject*)self));
+
+  // Non-gtkmmproc-generated custom classes implicitly call the default
+  // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
+  // generated classes can use this optimisation, which avoids the unnecessary
+  // parameter conversions if there is no possibility of the virtual function
+  // being overridden:
+  if(obj_base && obj_base->is_derived_())
+  {
+    CppObjectType *const obj = dynamic_cast<CppObjectType* const>(obj_base);
+    if(obj) // This can be NULL during destruction.
+    {
+      #ifdef GLIBMM_EXCEPTIONS_ENABLED
+      try // Trap C++ exceptions which would normally be lost because this is a C callback.
+      {
+      #endif //GLIBMM_EXCEPTIONS_ENABLED
+        // Call the virtual member method, which derived classes might override.
+        int min_height = 0;
+        int nat_height = 0;
+        obj->get_preferred_height_vfunc(
+             (minimum_height ? *minimum_height : min_height),
+             (natural_height ? *natural_height : nat_height));
+        return;
+      #ifdef GLIBMM_EXCEPTIONS_ENABLED
+      }
+      catch(...)
+      {
+        Glib::exception_handlers_invoke();
+      }
+      #endif //GLIBMM_EXCEPTIONS_ENABLED
+    }
+  }
+  
+  BaseClassType *const base = static_cast<BaseClassType*>(
+      g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
+  );
+
+  // Call the original underlying C function:
+  if(base && base->get_preferred_height)
+    (*base->get_preferred_height)(self, minimum_height, natural_height);
+}
+
+void Widget_Class::get_preferred_width_for_height_vfunc_callback(GtkWidget* self, gint height, gint* minimum_width, gint* natural_width)
+{
+  Glib::ObjectBase *const obj_base = static_cast<Glib::ObjectBase*>(
+      Glib::ObjectBase::_get_current_wrapper((GObject*)self));
+
+  // Non-gtkmmproc-generated custom classes implicitly call the default
+  // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
+  // generated classes can use this optimisation, which avoids the unnecessary
+  // parameter conversions if there is no possibility of the virtual function
+  // being overridden:
+  if(obj_base && obj_base->is_derived_())
+  {
+    CppObjectType *const obj = dynamic_cast<CppObjectType* const>(obj_base);
+    if(obj) // This can be NULL during destruction.
+    {
+      #ifdef GLIBMM_EXCEPTIONS_ENABLED
+      try // Trap C++ exceptions which would normally be lost because this is a C callback.
+      {
+      #endif //GLIBMM_EXCEPTIONS_ENABLED
+        // Call the virtual member method, which derived classes might override.
+        int min_width = 0;
+        int nat_width = 0;
+        obj->get_preferred_width_for_height_vfunc(height,
+             (minimum_width ? *minimum_width : min_width),
+             (natural_width ? *natural_width : nat_width));
+        return;
+      #ifdef GLIBMM_EXCEPTIONS_ENABLED
+      }
+      catch(...)
+      {
+        Glib::exception_handlers_invoke();
+      }
+      #endif //GLIBMM_EXCEPTIONS_ENABLED
+    }
+  }
+  
+  BaseClassType *const base = static_cast<BaseClassType*>(
+      g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
+  );
+
+  // Call the original underlying C function:
+  if(base && base->get_preferred_width_for_height)
+    (*base->get_preferred_width_for_height)(self, height, minimum_width, natural_width);
+}
+
 Widget::~Widget()
 {}
 
diff --git a/gtk/src/widget.hg b/gtk/src/widget.hg
index 3e01bb3..f2a664f 100644
--- a/gtk/src/widget.hg
+++ b/gtk/src/widget.hg
@@ -822,10 +822,10 @@ protected:
   _WRAP_VFUNC(Glib::RefPtr<Atk::Object> get_accessible(), "get_accessible", refreturn, ifdef GTKMM_ATKMM_ENABLED)
 
   _WRAP_VFUNC(SizeRequestMode get_request_mode() const, get_request_mode)
-  _WRAP_VFUNC(void get_preferred_width(int* minimum_width, int* natural_width) const, get_preferred_width)
-  _WRAP_VFUNC(void get_preferred_height_for_width(int width, int* minimum_height, int* natural_height) const, get_preferred_height_for_width)
-  _WRAP_VFUNC(void get_preferred_height(int* minimum_height, int* natural_height) const, get_preferred_height)
-  _WRAP_VFUNC(void get_preferred_width_for_height(int height, int* minimum_width, int* natural_width) const, get_preferred_width_for_height)
+  _WRAP_VFUNC(void get_preferred_width(int& minimum_width, int& natural_width) const, get_preferred_width, custom_vfunc_callback)
+  _WRAP_VFUNC(void get_preferred_height_for_width(int width, int& minimum_height, int& natural_height) const, get_preferred_height_for_width, custom_vfunc_callback)
+  _WRAP_VFUNC(void get_preferred_height(int& minimum_height, int& natural_height) const, get_preferred_height, custom_vfunc_callback)
+  _WRAP_VFUNC(void get_preferred_width_for_height(int height, int& minimum_width, int& natural_width) const, get_preferred_width_for_height, custom_vfunc_callback)
 
 protected:
   _CTOR_DEFAULT()



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]