Re: [gtkmm] writing a custom cellrenderer
- From: Roel Vanhout <rvanhout riks nl>
- To: Daniel Sundberg <dss home se>
- Cc: gtkmm-list gnome org
- Subject: Re: [gtkmm] writing a custom cellrenderer
- Date: Wed, 30 Jun 2004 12:00:32 +0200
Hi,
These examples are very useful, especially cellrenderertoggle.cc in the
gtkmm examples. What I don't understand in the cellrendererpopup and
cellrendererlist is that they don't have any code (as far as I see) that
does some actual drawing (ie, they don't override either render() or
render_vfunc(). Is that because the only custom thing about them is that
they emit different signals? Anyway, thanks a lot, I think I can get
things to work with the cellrenderertoggle.cc example.
cheers,
roel
Daniel Sundberg wrote:
> Roel Vanhout wrote:
> > Hello all,
> >
>
> Hi,
>
> have you looked at the example located in examples/customcellrenderer in
> the gtkmm source distribution. I have successfully created a custom cell
> renderer in my program GSpeakers based on this example. Please have a
> look at:
>
>
http://cvs.sourceforge.net/viewcvs.py/gspeakers/gspeakers2/src/cellrendererp
opup.h?view=markup
>
>
http://cvs.sourceforge.net/viewcvs.py/gspeakers/gspeakers2/src/cellrendererp
opup.cc?view=markup
>
>
>
http://cvs.sourceforge.net/viewcvs.py/gspeakers/gspeakers2/src/cellitemcross
over.h?view=markup
>
>
http://cvs.sourceforge.net/viewcvs.py/gspeakers/gspeakers2/src/cellitemcross
over.cc?view=markup
>
>
> Regards
>
> Daniel Sundberg
>
> ---
> http://sumpan.com
>
> > I spend the bigger part of yesterday evening trying to write a custom
> > cellrenderer for Gtk::TreeView but I didn't get it to work. I'm porting
> > an application from plain C Gtk to C++ with gtkmm. In the original
> > application I used the code from
> > http://scentric.net/tutorial/sec-custom-cell-renderers.html, which was
> > luckily exactly what I needed (in C). I thought that for a C++ version
> > all I'd have to is derive my own class from Gtk::CellRenderer, override
> > a few methods (that would have been declare pure virtual so that the
> > compiler would point me to them) and that would be it. Turns out I was
> > wrong.
> > I started by looking at
> >
>
http://www.gtkmm.org/docs/gtkmm-2.4/docs/reference/html/classGtk_1_1CellRend
>
> > erer.html.
> > I didn't see anything there that indicated what functions I had to
> > override to make my own so I just write a small class, overriding
> > get_size(), _property_renderable() and render() and copied the code
from
> > my original C renderer to the corresponding functions. I had to massage
> > it a bit to get it into C++ format and then it compiled. I used the
> > add_column() method that takes a custom renderer and when all of that
> > compiled I thought it'd work, but all I saw was a blank cell. So I
> > looked at the implementation of the CellRendererText and -Pixbut in the
> > gtkmm source and to my horror I found all the structs from the C
version
> > in there - the init thing and a sort of virtual vtable and all the
> > things I hoped I would never have to bother with again when I switched
> > to gtkmm. I'm still hoping that this is only because they wrap the C
> > version and that it is possible to write one in pure C++.
> > Ok so sorry if this sounds frustrated (it's because I am), but here are
> > a few questions that I have:
> >
> > - What functions do I have to override and what do I have to implement
> > to get a custom cellrenderer, a complete new one and not one that just
> > wraps a C version? I think I'm missing two things: first, registering a
> > custom property ('progress' in my case), and secondly registring the
> > cellrenderer itself somewhere.
> > - All properties (like property_xalign()) have comments like "You
rarely
> > need to use properties because there are get_ and set_ methods for
> > almost all of them.". But are there really? Where are they declared?
How
> > should I use those properties?
> > - What are the protected methods in CellRenderer (like get_size_vfunc()
> > ) used for? Should I override them?
> > - Why are there two versions of get_size? Is there an easy way to
> > implement the one in terms of the other or should I write full
> > implementations for both?
> >
> > I've attached the code that I have so far. Some of it is commented out,
> > that's what I was trying after I got everything to compile but when it
> > didn't work. It's mostly copied from CellRendererText, but that one
> > wraps the C version so it's not quite the same as what I try to do.
> > Thanks in advance.
> >
> >
> > cheers,
> >
> > roel
> >
> >
> >
> >
> >
> >
------------------------------------------------------------------------
> >
> > _______________________________________________
> > gtkmm-list mailing list
> > gtkmm-list gnome org
> > http://mail.gnome.org/mailman/listinfo/gtkmm-list
>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]