Please help. GDK drawing
- From: "Diego Sevilla Ruiz (dsevilla um es)" <dsevilla ditec um es>
- To: gnome-devel-list gnome org
- Subject: Please help. GDK drawing
- Date: Thu, 08 Mar 2001 16:16:08 +0100
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi all!
I've built a very simple C program to draw some things in a window
using GDK. The question is that, although the window is displayed OK,
the rectangle I try to draw inside does not appear. What I'm doing
wrong? I send you the program. Please, enlightment me some!! The only
I want is to draw a red rectangle somewhere in the window, but I don't
know how...
Regards and thanks in advance.
diego.
#include <gdk/gdk.h>
int
main (int argc, char *argv[])
{
GdkWindow* win;
GdkWindowAttr attr;
GdkEvent* e;
GdkGCValues dcval;
GdkGC* gc;
GdkColormap* colormap;
int i;
/* Initialize GDK. */
gdk_init (&argc, &argv);
/* Initialize window attributes */
attr.x = attr.y = 0;
attr.height = attr.width = 200;
attr.wclass = GDK_INPUT_OUTPUT;
attr.window_type = GDK_WINDOW_TOPLEVEL;
win = gdk_window_new(NULL,&attr,0);
/* Initialize GdkGCAttributes */
dcval.foreground.red = 65535;
dcval.foreground.green = 0;
dcval.foreground.blue = 0;
dcval.background = dcval.foreground;
colormap = gdk_window_get_colormap ( win );
if (gdk_colormap_alloc_color(colormap, &dcval.foreground,
FALSE,TRUE))
printf( " OK color \n");
gc = gdk_gc_new_with_values ( win, &dcval,
GDK_GC_BACKGROUND |
GDK_GC_FOREGROUND);
/* Draw a rectangle */
gdk_draw_rectangle ( win , gc, 1, 10,10,100,100);
/* Show window */
gdk_window_show(win);
while (1)
{
if (gdk_events_pending() && (e = gdk_event_get())) {
printf("[Event: %d]\n", e->type);
}
}
scanf("%d",&i);
/* Exit from GDK...this call will never return. */
gdk_exit (0);
/* Keep compiler from issuing a warning */
return 0;
}
--
Diego Sevilla Ruiz -- http://ditec.um.es/~dsevilla/ -- dsevilla um es
Dep. Ingeniería y Tecnología de Computadores, Facultad de Informática
Univ.de Murcia,Campus Espinardo,30080 Murcia (SPAIN),Tel.+34968367658
lynx -dump ditec.um.es/~dsevilla/face |uncompface | ikon2xbm |display
PGP: http://pgp.rediris.es:11371/pks/lookup?op=get&search=0xC9B964B7
perl -e'$_="\x4\ FLe\x2&B";for(/../g){print unpack("b*",$_),"\n"}'|tr 01 " #"
-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 5.0i for non-commercial use
MessageID: P2d9OIQYxekRX2JlK8SgH4ApRBgIUfKX
iQA/AwUBOqeiOdoq0AfJuWS3EQJfxACcDPv9lpK+bnoDeImvkTAC9/Vu3fgAn2AL
1n03ygH8+JL+pu+6vvKWaXdl
=vQ+J
-----END PGP SIGNATURE-----
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]