Re: painting widget (checkbutton) lookalikes.



On Mon, May 03, 2004 at 09:24:20AM +0200, Peter Krueger wrote:
On Sun, 2 May 2004 rgammans computer-surgery co uk wrote:

So what do I have to do to get gtk_paint_check() to find/create a
valid gc?
Hi!
Your gc problem seems to have its origin in the
gtk_widget_get_default_style() call. Try to use
gtk_widget_get_style(GtkWidget *widget) with the widget you want to paint
to instead.

Ahh, therein lies the rub, I've spent some time investigating and think
I now understand whats going on.

Your suggestion:- (at least I think this is what you meant) 

        chkbox = gtk_check_button_new();
        style  = gtk_widget_style_get(chkbox);
        gtk_paint_check(style, mywindow,state,shadow,
                        area,chkbox,"checkbutton",
                        rect.x -1, rect.y -1,
                        rect_size.width, rect_size.width);


Doesn't work either but after all chkbox isn't a real widget, it's
just a proxy for one so that I can query the Gtk runtime about
the how it should look.

AFAICT from reading the gtk source a widget's style is not 
initialised untill it is added to a container - which is reasonable
as as this means styles have containership inheirtance - so chkbox's
style isn't initialised

Unfortunately I don't want to add a widget to my window , just draw one,
as if it were there - but since we know it style is going to initialised
from mywindow I take the style thus:-
        style=gtk_widget_get_style(mywindow);
        
     and set the widget's style from it:0.
        
        gtk_wiget_set_style(chkbox,style);

Doing this I can now get the window is now painted correctly.

So is just copying the style from the window, to a proxy widget
like this ok, or is it likely to be fragile when deployed?

TTFN
-- 
Roger.                          Home| http://www.sandman.uklinux.net/
Master of Peng Shui.      (Ancient oriental art of Penguin Arranging)
Work|Independent Sys Consultant | http://www.computer-surgery.co.uk/
So what are the eigenvalues and eigenvectors of 'The Matrix'? --anon

Attachment: pgpXVChQWGqZm.pgp
Description: PGP signature



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