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

Re: drawing circles and lines



Am Tue, 13 May 2003 07:29:22 -0700 schrieb Ken Steen:

> > I need an area in my gtk2-application where some lines and circles
> > are drawed. I think that the gtk_drawing_area could fit, but in the
> > "GTK+ 2.0 Tutorial" it's categorized under "Undocumented Widgets"
> > :-(
> > 
> > Has someome a minimal application which opens a window and draws
> > some lines, circles or boxes?

> The scribble-simple example included with gtk+ source used the
> drawing_area widget and is a good example.

Thanks. I tried it out, but I've still some problems.

I could paint in the "scribble-simple example" in function

static gint configure_event( GtkWidget         *widget,
              		               GdkEventConfigure *event )
{
...
  gdk_draw_rectangle (pixmap,
		      widget->style->white_gc,
		      TRUE,
		      update_rect.x, update_rect.y,
		      update_rect.width, update_rect.height);
...
}

But I don't want only to paint in this callback function. Now I tried to
paint from within main():

static GdkPixmap *pixmap = NULL;

int main(..){
  GtkWidget *window;
  GtkWidget *drawing_area;
...
  gdk_draw_rectangle (pixmap,
		      drawing_area->style->black_gc, /*1*/
		      TRUE,
		      0, 0,
		      30,
		      30);
...
}

And if I execute it:

> ./scribble-simple 

| (scribble-simple:6671): Gdk-CRITICAL **: file gdkdraw.c: line 410
| (gdk_draw_rectangle): assertion `GDK_IS_DRAWABLE (drawable)' failed

I tried also also to give "window" here /*1*/ instead of "drawing_area",
with no other results.

What should I give as second paramter to "gdk_draw_rectangle" instead of
"widget"?

Thanks
Andreas



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