Christian Storgaard wrote:

> Hi all.
>
> I'm trying to implement colour-formatted CList-items, by creating a pixmap and
> placing the coloured text on it.
> This works fine, but if it is to be used proberbly in a CList, the background
> colour should change when selected,
> this I know would be relatively simple by just making two pixmaps, but I change
> the style of the rows dynamically and this would sum up in quite a lot of pixmaps
> (2 for each style).
>
> So, my solution would have to be to make the pixmap transparent, but when I make a
> pixmap with depth 1 (which is supposed to be a GdkBitmap, used for masks), and use
> it in the GtkPixmap call like this:
>   pixm=GtkPixmap(pixmap,mask)
> I get this error:
>   Gdk-ERROR **: BadMatch (invalid parameter attributes)
>     serial 251 error_code 8 request_code 70 minor_code 0
> I even get it if I change the GtkPixmap mask call to None, and so, don't even use
> the mask.
> Can anyone tell me what's going on? Or maybe come up with another way to implement
> colour-formatting in CList (styling (weight,slant) is something I'm trying to do
> too, btw.)
>

It sounds like you want to have text in different colors and font styles in different
rows. And I'm assuming that you want different text colors and styles in columns in
the same row otherwise the set_row_style() and set_foreground() methods would seem to
do the job. So that's why you are trying to use pixmaps with text drawn in them.

It seems to me that you'd have to have a different bitmap for each different text
style and content but you could reuse the different colored pixmaps. The pixmap
provides the foreground text color and the mask provides the text in whatever font
style you want.

The pixmaps could be created like:

green = widget.get_colomap.alloc('green')
pixmap = create_pixmap(widget, 100, 15)
pmgc = pixmap.new_gc()
pmgc.foreground = green
draw_rectangle(pixmap, pmgc, TRUE, 0, 0, 100, 15)

The bitmaps could be created like:

font = load_font(font_spec)
mask = create_pixmap(None, 100, 15, 1)
black_maskgc = mask.new_gc()
white_maskgc = mask.new_gc()
black_maskgc.foreground = black_maskgc.background
draw_rectangle(mask, white_maskgc, TRUE, 0, 0, 100, 15)  # clear the bitmap
draw_text(mask, font, black_maskgc, 0, 10, 'Example Text')

Then you'd add them to the CList row and column like:

clist.set_pixmap(1, 0, pixmap, mask)

John

_______________________________________________
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk

Reply via email to