Re: [gtkmm] Gdk::Window problem



Murray Cumming wrote:

I found the problem, why Gdk::Window in GTKMM-2.4 is not compatible now
with GdkWindow in GTK+-2.4.

What do you mean? Exactly what problem are you encountering?
Example for custom cellrenderer:

CustomCellRenderer : public Gtk::CellRenderer
{
...
protected:
virtual void get_size_vfunc(...) const;

virtual void render_vfunc (
const Glib::RefPtr<Gdk::Drawable>& window, // render function accepts GdkDrawable* as argument in GTK+
   Gtk::Widget& widget,
   const Gdk::Rectangle& background_area,
   const Gdk::Rectangle& cell_area,
   const Gdk::Rectangle& expose_area,
   Gtk::CellRendererState flags);
...
};
---------------------------
...
// method to draw simple text cell in tree view (removed extra Pango attributes to speed up rendering)
virtual void CustomCellRenderer::render_vfunc(
const Glib::RefPtr<Gdk::Drawable>& window, // render function accepts GdkDrawable* as argument in GTK+
   Gtk::Widget& widget,
   const Gdk::Rectangle& background_area,
   const Gdk::Rectangle& cell_area,
   const Gdk::Rectangle& expose_area,
   Gtk::CellRendererState flags)
{
// get text value
...
Glib::RefPtr<Pango::Layout> ptrLayout = widget.create_pango_layout (text);
// get cell dimension
...
// draw the text. Function was taken from cellrenderertext.c
   widget.get_style ()->paint_layout (
/*
GTKMM declaring paint_layout fucntion that take Glib::RefPtr<Gdk::Window> as parameter, but we cannot cast Gdk::Drawable to Gdk::Window, because Gdk::Drawable is base of Gdk::Window (see Glib::RefPtr casting rules). In this case problem could be fixed by replacing Gtk::Style::paint_layout() Glib::RefPtr<Gdk::Window> parameter with Glib::RefPtr<Gdk::Drawable>.

Also, If you look at GTK+ code, you will find that almost all functions are taking GdkWindow (equal to GdkDrawable) as argument. And that may cause potential problems for developers in GTKMM. */ window, // COMPILATION ERROR !!!
                       state,
                       true,
                       cell_area,
                       widget,
                       "cellrenderertext",
                       cell_area.get_x () + x_offset + cell_xpad,
                       cell_area.get_y () + y_offset + cell_ypad,
                       ptrLayout );
}

Regards,
-andrew




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