Re: [gtk-list] drawing pixel ??



On 10/10/98 Enrique F. Cespedes Sanchez uttered the following other thing:
> Please, I want to make a little program with a window where I can draw
> pixels. How can I do it.
> I don't found a put_pixel function in gtk. And I saw it a
> gdk_image_put_pixel in gdk library, but where can I get a maual for GDK?
> 
> Or can someone send me a little program wich draws pixels in a box?

How about Scribble, which is an example program in the GTK+ Tutorial?

It draws pixels in a box, albeit as the result of mouse clicks.

Basically, you need a drawing_area widget, and then use gdk_draw_point()
using the window of the drawing_area widget:

GtkWidget *da;

da = gtk_drawing_area_new ();
gtk_drawing_area_size (GTK_DRAWING_AREA (da), 50, 50);
gtk_container_add (GTK_CONTAINER (window), da);
gtk_realize_widget (da);
gdk_draw_point (da->window, da->style->black_gc, 10, 10);

Note, that the window doesn't "remember" where things are drawn, so you
usually have to trap expose events and redraw things when they occur.
The scribble app creates an offscreen pixmap to draw into during the
configure event, allowing it to handle expose events by just copying the
affected area from the pixmap to the window.

Hmm, which reminds me, does GTK optimize expose events?  Ie, if you
could a bunch of expose events in a row, will GTK combine them?

Brandon
-- 
 Brandon Long          "Join the Army, meet interesting people, kill them."
 Fiction Networks                              -- Steven Wright
 blong@fiction.net		  http://www.fiction.net/blong/



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