Re: painting widget (checkbutton) lookalikes.



On Sun, 2 May 2004 rgammans computer-surgery co uk wrote:
I'm trying to improve an existing spreadsheet-like control which paints
cells, and  if the cell is editted creates a widget inplace.

Ideally I'd like to ensure the cell when not being editting is painted
similiarly to the widget (to meet the principle of least suprise).

I've been trying the following code under debain stable (gtk+1.2.10 and
gtk+2.0.2):-

      GtkRequisition rect_size = { 7 , 13 };
      GdkRectangle   area =  { rect.GetX() , rect.GetY() ,
                                 rect.GetWidth(), rect.GetHeight() };

      static GtkWidget*    chkbox = gtk_check_button_new();

#ifdef GTK > 2
      // Gtk2.0 supports styles so overwrite the size with
      // the values from the current theme.
      gtk_widget_style_get(chkbox, "indicator_size", &rect_size, NULL);
#endif

      gtk_paint_check(gtk_widget_get_default_style(),
                        my_window,state,shadow,
                      &area,chkbox,"checkbutton",
                      dc.XLOG2DEV(rect.x) -1, rect.y -1,
                      rect_size.width, rect_size.width);


However this doesn't paint under either gtk versions in stable
altougth gtk1.2.10 as in debian testing works, although gtk2 (2.2.4)
there doesn't.

The not working behaviour is characterised by failure to draw anything
but usefully gives many wanings. Itheh gtk1.2 case all the warnings
are 'gc != NULL' assertion failues, and in gtk2 we have GDK_IS_GC(gc)
assertion failures .

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.

Regards,
                     Peter
-- 
====================================================================
Peter Krüger

applied software solutions (appss) GmbH
Sandtorstr. 23
D-39106 Magdeburg
Germany

Phone:  +49-(0)391-54486-19388
Fax:    +49-(0)391-54486-19222
email:  krueger appss de
URL:    http://www.appss.de/

Managing Director: Uwe Hess, Dietmar Schäfer
Register: HRB12386, AG Magdeburg

"Virtual business becomes reality!"

This e-mail may contain confidential and/or privileged information. If
you are not the intended recipient (or have received this e-mail in
error) please notify the sender immediately and destroy this e-mail. Any
unauthorised copying, disclosure or distribution of the material in this
e-mail is strictly forbidden.
====================================================================




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