[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gtk-app-devel
Subject:    Re: Dealing with drawingArea update (refresh) for multiple drawings.
From:       "Gustavo Sikora" <wildsoul () gmail ! com>
Date:       2006-08-30 10:47:50
Message-ID: a80f566e0608300347y6ce916f7q35802156ef8c159 () mail ! gmail ! com
[Download RAW message or body]

Thanks for all replies =)
I manage to get it work a few days, I'm in a hurry to finish some
other things now... yet I'm still drawing some data stuctures.

It's good to have all of this help.

Once again, thanks a lot ppl.



On 8/29/06, Ivan Baldo <ibaldo@adinet.com.uy> wrote:
>   If you have the drawing area in a variable called "da", then you can do:
>
> gtk_widget_queue_draw_area(da, 0, 0, da->allocation.width,
> da->allocation.height);
>
> ... everytime you want to update the drawing area, it generates an
> expose event and will call your expose_event_callback.
>
> It works for me.
> HTH, bye.
>
>
>
> El 26/08/06 09:38, Gustavo Sikora escribió:
>
> >Hi there,
> >
> >I'll go straight to the point: I'm trying to draw some data structures
> >like, leftist heaps, B tree, binomial heaps and I'm in a hurry trying
> >to use gtk and cairo to draw and develop all of the GUI. But I'm new
> >to this matters, and I'm not finding an apropriate way to draw
> >multiple nodes as I walk the structures. ie: I have an empty
> >drawingArea and buttons to let me insert elements. After each insetion
> >I wish to draw the current state of the structure. Now, I'm only able
> >to draw the first node, and for some reason the expose_event only
> >applies when I minimize the interface and open it again.
> >
> >Some code of what I'm doing:
> >
> >gboolean expose_event_callback (GtkWidget *widget, GdkEventExpose *event)
> >{
> >   cairo_t *cr;
> >
> >       /* get a cairo_t */
> >       cr = gdk_cairo_create (widget->window);
> >
> >       cairo_rectangle (cr,
> >                       event->area.x, event->area.y,
> >                       event->area.width, event->area.height);
> >       cairo_clip (cr);
> >
> >       newHeap->drawHeap(cr);
> >
> >       cairo_destroy (cr);
> >
> >   return TRUE;
> >}
> >
> >void insert_callback(GtkWidget *widget, gpointer info)
> >{
> >   const gchar *key, *priority;
> >
> >   key = gtk_entry_get_text(GTK_ENTRY(keyValue));
> >   priority = gtk_entry_get_text(GTK_ENTRY(priorityValue));
> >   gtk_entry_set_text (GTK_ENTRY (keyValue), "");
> >   gtk_entry_set_text (GTK_ENTRY (priorityValue), "");
> >   insert(atoi(key), atoi(priority), newHeap);
> >}
> >
> >...
> >//initialization of my drawingArea
> >drawArea = gtk_drawing_area_new();
> >gtk_box_pack_start (GTK_BOX (box1), drawArea, FALSE, FALSE, 0);
> >gtk_drawing_area_size(GTK_DRAWING_AREA (drawArea), 1010, 657);
> >gtk_signal_connect(GTK_OBJECT (drawArea), "expose_event",
> >GTK_SIGNAL_FUNC (expose_event_callback), 0);
> >gtk_widget_show(drawArea);
> >...
> >
> >//drawHeap from my leftistHeap.h - not complete, only testing for real drawing
> >...
> >template<class T>
> >void leftisitHeap<T>::drawHeap(cairo_t *cr)
> >{
> >       drawHeap(raizPtr, cr);
> >}
> >
> >template<class T>
> >void leftistHeap<T>::drawHeap(nodeLeftHeap<T> *auxPtr, cairo_t *cr)
> >{
> >       if (raizPtr == 0)
> >               return;
> >       else
> >       {
> >               if (auxPtr != 0)
> >               {
> >
> >               double x, y;
> >               x = 505;
> >               y = 25;
> >               double radius;
> >               radius = 12;
> >               cairo_arc (cr, x, y, radius, 0, 2 * M_PI);
> >               cairo_set_source_rgb (cr, i, i, i);
> >               cairo_fill_preserve (cr);
> >               cairo_set_source_rgb (cr, 0, 0, 0);
> >               cairo_stroke (cr);
> >
> >
> >               drawHeap(auxPtr->getClftPtr(), cr);
> >               drawHeap(auxPtr->getCrgtPtr(), cr);
> >               }
> >       }
> >}
> >....
> >
> >My question again: How can I draw multiple figures (nodes) and make
> >them visible as soon as I insert a new element?
> >
> >I found something like swapbuffers for ogl + gtk; pixmap or pixbuff
> >for simple gtk+ and even only the regular expose_event callback...
> >
> >I'll really apreciate any help. (links, materials, tutorials... I
> >"googled" a lot and find a lot of stuff, but too many things regarding
> >python and ruby... I'm dealing with C/C++
> >
> >btw, I sent this same question to a Cairo list, and they told me to
> >use gtk_widget_queue_draw_area everytime I should draw something new
> >and also said that I could use gdk_window_invalidate_rect on my
> >insetion callback.
> >Once they told me this list would help me more then the cairo one,
> >since it's more of a gtk doubt, here I am.
> >
> >Once more, I would really be glad with any help. I'll try now what
> >they told me.
> >
> >Thanks in advance
> >_______________________________________________
> >gtk-app-devel-list mailing list
> >gtk-app-devel-list@gnome.org
> >http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
> >
> >
> >
>
> --
> Ivan Baldo - ibaldo@adinet.com.uy - http://ibaldo.codigolibre.net/
> ICQ 10215364 - Phone/FAX (598) (2) 613 3223.
> Caldas 1781, Malvin, Montevideo, Uruguay, South America.
> We believe that we are free, but in reality we are not! Are we?
> Alternatives: ibaldo@codigolibre.net - http://go.to/ibaldo
>
>
>
>


-- 
Gustavo
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic