Re: Redrawing a widget



I'm doing something similar to your beeds with GTK+.
The redraw I call from several places.  many of the key press events.
The draw_cell draws my data into the pixmap,  it is a recursive function
as I have hierarchial data.

Hope this helps :)

void redraw(void)
{
  GdkEventConfigure   ev;
  ev.window = drawing_area->window;
  ev.x      = drawing_area->allocation.x;
  ev.y      = drawing_area->allocation.y;
  ev.width  = drawing_area->allocation.width;
  ev.height = drawing_area->allocation.height;
  ev.type = GDK_CONFIGURE;
  gtk_widget_event(drawing_area,(GdkEvent*)&ev);
}

gint configure_event( GtkWidget *widget
                     ,GdkEventConfigure *event )
{
  if (pixmap) gdk_pixmap_unref(pixmap);
  canvas_x        = widget->allocation.width;
  canvas_y        = widget->allocation.height;
  windowExt.ll.x  = 0;
  windowExt.ll.y  = 0;
  windowExt.ur.x  = canvas_x;
  windowExt.ur.y  = canvas_y;
  pixmap = gdk_pixmap_new(widget->window,
                          widget->allocation.width ,
                          widget->allocation.height,
                          -1);
  gdk_draw_rectangle(  pixmap
                      ,widget->style->black_gc
                      ,TRUE
                      ,0,0
                      ,widget->allocation.width
                      ,widget->allocation.height);
  draw_cell(fcellp,1,0,0);  
  return TRUE;
}


Ignacio Nodal wrote:
> 
> Hi, i'm working on an OpenGL project using GTK+ & GtkGLArea. My question
> is... how can i force a widget to be redraw? Not by an expose event, but at
> anytime.
> A simple example, suppose i want to clear the widget contents, call the
> glClear function and then i call gtk_widget_draw passing the widget and the
> area i want to be redraw, but it doesn't work.. is this a problem with
> OpenGL code or GTK+ one?? I mean.. Is gtk_widget_draw the correct way to
> redraw any kind of widget?
> 
> Here is an example code:
> 
>   GdkRectangle area;
>   area.x = 0;
>   area.y = 0;
>   area.width  = _glarea->allocation.width;
>   area.height = _glarea->allocation.height;
> 
>   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
>   gtk_widget_draw(_glarea, &area);
>   g_print("Cleared Rectangle:(%d,%d)
> (%d,%d)\n",area.x,area.y,area.width,area.height);
> 
> Ignacio Nodal
> 
> _______________________________________________
> gtk-list mailing list
> gtk-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtk-list

-- 
=========+=========+=========+=========+=========+=========+=========+
   ___  _ ____       ___       __  __          
  / _ )(_) / /_ __  / _ \___ _/ /_/ /____  ___ 
 / _  / / / / // / / ___/ _ `/ __/ __/ _ \/ _ \
/____/_/_/_/\_, / /_/   \_,_/\__/\__/\___/_//_/
           /___/                               
Texas Instruments ASIC Circuit Design Methology Group
Dallas, Texas
214-480-4455
bpatton dal asp ti com
=========+=========+=========+=========+=========+=========+=========+




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