Gdk_draw_rectangle



Hoi,

I'm trying to figure out this GTK stuff, but it's not getting anywhere. I'm trying to draw a simple rectangle in a window, but I keep getting the same error message everytime.
Here below is the probably childies program, but aslong as I don't understand the functions it's as good as it gets.


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

GtkWidget *drawingarea = NULL;

gint main (gint argc, gchar *argv[])
{
	gint x,y;
	GtkWidget *window;

	gtk_init (&argc,&argv);

	x = 51; y = 39;	

	window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
	gtk_window_set_title (GTK_WINDOW(window), " PowerBar ");
	
	gtk_signal_connect (GTK_OBJECT(window), "delete_event", (GtkSignalFunc) gtk_exit, NULL);
	gtk_signal_connect (GTK_OBJECT(window), "destroy" , (GtkSignalFunc) gtk_exit, NULL);

	drawingarea = gtk_drawing_area_new ();
	gtk_drawing_area_size (GTK_DRAWING_AREA(drawingarea), 200, 200);
	
-->	gdk_draw_rectangle (drawingarea->window,window->style->black_gc, 1,(gint)x ,(gint)y , 20, 5);

	gtk_container_add (GTK_CONTAINER(window), drawingarea);

	gtk_widget_show (drawingarea);
	gtk_widget_show (window);
	
	gtk_main ();
	
	return (0);
}

When I run this program I get the following error message:

Gdk-CRITICAL **: file gdkdraw.c: line 89 (gdk_draw_rectangle): assertion 'drawable != NULL' failed.

What is wrong with my function call and can somebody explain the first two arguments, it would be all the help I need.

Thanks,

EV



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