Trying to draw in a window




I am trying to draw in a line in a window; I connect
a function drawing the line to the expose event, and there
is the following problem:
if the window is (partly) behind another window and I click on it
to bring it in the foreground, only the part of the line that
was already in the uncovered part of the window appears;
the other part is immediatly overwritten (by who?);

here is the code: thanks for any help



#include <gdk/gdk.h>
#include <gtk/gtk.h>

GdkGC *gc;
GdkDrawable *ww;

gint expose_event(GtkWidget *widget, GdkEvent *event, gpointer data)
{
  gdk_draw_line (ww, gc, 10, 20, 100, 20);
  return FALSE;
}


int main (int argc, char *argv[])
{
  GtkWidget *w;
  gtk_init (&argc, &argv);
  w = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_widget_show (w);
  ww = w->window;
  gc = gdk_gc_new(ww);
  gtk_signal_connect (GTK_OBJECT(w), "expose_event",
		      GTK_SIGNAL_FUNC(expose_event), NULL);
  gdk_draw_line (ww, gc, 10, 20, 100, 20);
  gtk_main ();
  return 0;
}


Hubert



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