Re: "undrawing" a line



Pavel Cisler wrote:
> 
> Davina Armstrong wrote:
> >
> > I posted earlier that I was trying to draw decorations around a GtkLabel
> > (which is actually part of a composite widget I wrote that packs a
> > GtkLabel and GtkEntry into a GtkHBox), which I've done successfully -
> > thanks.  The idea is that I want the decorations to be drawn when
> > MyWidget gets focus, and "undraw" them when it loses the focus.  I wrote
> > the following draw_focus function, which is called from
> > my_widget_focus_in() and my_widget_focus_out():
> >
> > static void my_widget_draw_focus(GtkWidget* widget)
> > {
> >     g_return_if_fail(widget != NULL);
> >     g_return_if_fail(IS_MY_WIDGET(widget));
> >
> >     if (GTK_WIDGET_HAS_FOCUS(widget)) {
> >         /* draw the decoration */
> >     } else {
> >         gtk_widget_draw(widget, NULL);
> >     }
> > }
> >
> > The decorations draw when MyWidget gets focus, but don't go away when it
> > loses the focus.  I've verified that gtk_widget_draw() is being called.
> > Can anyone tell me what I'm doing wrong?
> >
> > Thanks!
> > Davina
> 
> Davina,
> 
> My guess is that the extra decorations don't go away because the
> gtk_widget_draw doesn't erase any of the backgrounds your decorations
> are drawn on -- they normally come erased for you in the exposure
> callback. You could easily verify this by de-focusing your widget and
> causing it to redraw by invalidating it by another window. The part that
> you invalidate should redraw without the decorations.
> 
> Pavel

Pavel -

I'm sorry it has taken so long to check this.  You are right, covering
it with another window does cause the decorations to disappear, but I
don't know how to invalidate it in code.  Can you (or anyone else)
please help?

Thanks again!
Davina




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