drawing a line and a button in a window



Hi there,

I've got a problem with drawing a line and a button in a window at the same time. When I run the following program I can see the line only and no button... Can anybody advise me how display those two items simultaneously? My intention is to have a number of buttons displayed in the window (those buttons are to represent the nodes in a graph) and a mumber of lines among them (those lines are to represent the links/connections between the selected pairs of nodes).

I've tried many diffrent things and I'm not sure if this is feasible with GTK...

Thanks,
Michal


#include <gtk/gtk.h>


gint expose (GtkWidget *widget, GdkEventExpose *event, gpointer data) {
  gdk_draw_line (widget->window, widget->style->black_gc, 100, 50, 50, 100);
}


int main (int argc, char **argv) {
  GtkWidget *window;
  GtkWidget *button;
 
  gtk_init (&argc, &argv);
  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  button = gtk_button_new_with_label("Button");
  gtk_container_add(GTK_CONTAINER(window), button);

  gtk_signal_connect (GTK_OBJECT (window), "expose_event", GTK_SIGNAL_FUNC (expose), NULL);
 
  gtk_widget_show(button);
  gtk_widget_show (window);
 
  gtk_main ();
  return 0;
}



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