Re: Help requested with drawing lines in a child window.
- From: John Cupitt <john cupitt ng-london org uk>
- To: Michael John Holme <M Holme doc mmu ac uk>
- Cc: gtk-list gnome org
- Subject: Re: Help requested with drawing lines in a child window.
- Date: Tue, 06 Mar 2001 11:42:52 +0000
Michael John Holme wrote:
> I understand that I'm calling gtk_draw_line with a NULL first parameter, but
> why is it NULL. I've followed a similar example from the book 'Beginning
> GTK+/GNOME Programming' by Peter Wright.
Hi Michael, you need to do the paint in response to an expose signal.
Have a look at the 'scribble' example program. You want something like
this:
--
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size(GTK_WINDOW(window), 200, 200);
gtk_window_set_title(GTK_WINDOW(window), "Output window");
drawingarea = gtk_drawing_area_new();
gtk_container_add(GTK_CONTAINER(window), drawingarea);
grk_signal_connect( GTK_OBJECT( drawingarea ), "expose_event",
GTK_SIGNAL_FUNC( expose_cb ), NULL );
gtk_widget_show_all(window);
--
then expose_cb needs to be something like:
--
static gint expose_cb( Gtkwidget *widget, GdkExposeEvent *event )
{
GdkDrawable *drawable = widget->window;
gdk_draw_line(drawable, widget->style->white_gc,
0, 0, 100, 100);
return( FALSE );
}
--
(this is from memory, I've probably messed up the details)
HTH, John
--
John Cupitt, john cupitt ng-london org uk, +44 (0)20 7747 2570
VASARI Lab, The National Gallery, Trafalgar Square, London, WC2N 5DN
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]