gdk_gc_new() and gdk_draw_point()



hi all,
In order to understand how to draw a point on  a background image
i've designed a short example using glade.  It consists of a main window
containing an image, and i want to draw a line on it using gdk_draw_point()
on the "on_image1_expose_event" event in the callbacks.c file.
Can anyone show me how to get the graphic context (GdkGC *gc) using
gdk_gc_new () and how to complete the gdk_draw_point() function if
it's false , and to make this example run ?
these are the 3 main files (without the headers):

MAIN.C:
int
main (int argc, char *argv[])
{
  GtkWidget *window1;

  gtk_set_locale ();
  gtk_init (&argc, &argv);

  add_pixmap_directory (PACKAGE_DATA_DIR "/" PACKAGE "/pixmaps");
  window1 = create_window1 ();
  gtk_widget_show (window1);
  gtk_main ();
  return 0;
}

INTERFACE.C:
GtkWidget*
create_window1 (void)
{
  GtkWidget *window1;
  GtkWidget *image1;

  window1 = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW (window1), _("window1"));

  image1 = create_pixmap (window1, "world_map-960.png");
  gtk_widget_show (image1);
  gtk_container_add (GTK_CONTAINER (window1), image1);

  g_signal_connect ((gpointer) image1, "expose_event",
                    G_CALLBACK (on_image1_expose_event),
                    NULL);

  /* Store pointers to all widgets, for use by lookup_widget(). */
  GLADE_HOOKUP_OBJECT_NO_REF (window1, window1, "window1");
  GLADE_HOOKUP_OBJECT (window1, image1, "image1");

  return window1;
}

CALLBACKS.c:
gboolean
on_image1_expose_event                 (GtkWidget       *widget,
                                                      GdkEventExpose  *event,
                                                   gpointer         user_data)
{
  gint x;
  GtkWidget * world_map = lookup_widget(GTK_WIDGET(widget), "image1");
  GdkGC *gc;
  gc = gdk_gc_new (?????);

  for(x=0;x<100;x++)
  {
  gdk_draw_point(world_map, gc,x,100);
  }
  return FALSE;
}

Thanks for your help :)
Chris




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