Re: A custom cellrenderer for a bixbuf with text



Hello!

On Thu, 29 Apr 2004 20:23:52 -0400, muppet said:

[..]
i tried it -- a window pops up and immediately explodes, with the  
message

Huh, it didn't do that here (running XFree 4.3.0).

[...] 
in your RENDER override, you're creating a GC to render the pixbuf to  
the window.  specifically, you're creating a new GC, using a new  
Pixmap.  this is bad for three reasons:
[...]

I already thought that this construct might be a really bad idea. However
I didn't really know what such a GC thing is, just that the draw_pixbuf
required one as its first argument. Thanks for explaining it to me.

Concerns about using few resources and being quick would have come next.

   3) but even the two solutions mentioned above aren't the right thing  
to do.  GtkWidget keeps a pointer to a GtkStyle, which has a bunch of  
GdkGCs in it, already configured for the current mode!  you should be  
using those!

I would certainly have done this, if I would have know this. I suppose
that I've again overseen it in the docs somewhere.

[...] 
sure they are; the column sets up the properties before calling  
get_size().  the cell_area always seems to be undef.  i have seen it  
defined in the past but i don't remember the circumstances.

Hmm, I thought to have tried to access the cell properties from withing
get_size, too, but without success. Well, as you have proven, I must have
done something wrong.

what you'll probably want to do is break the text handling out into a  
separate function, so you can find the size for yourself the same way  
you do in the RENDER method.

Yep, if I can use the information for get_size as well, this is certainly
the way to go.

[...]
perldoc Gtk2::Pango::Layout lists

    (width, height) = $layout->get_pixel_size

(available since Gtk2 0.20)

Ouch, I tried $layout->get_size, but this call just returned numbers way
too large.

here are my changes, incorporating most of what i mentioned above:
[...]

Well, what can I say? I'm deeply impressed, this is certainly the most
helpful mail I've ever gotten on a mailing list! Thanks a lot for taking
the time to help me.

Ciao
Florian

Attachment: pgp5OA750VIBL.pgp
Description: PGP signature



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