Yet Another Question About Gnome(Gtk)Canvas



Hy,

I'm using a Gtk Canvas (should be the same as the Gnome Canvas) I'm trying
to draw a quadrilatere (a polygon with 4 sides which can be different than a
rectangle like a losange or trapezoid). I'm using the code bellow for that!
Once drawn I can see the object but only the outline part is shown. The fill
color is not used! I've tryed to draw a rectangle instead (just to see, I
don't want this behaviour...), I've replaced the type of the item and didn't
send the GtkCanvasPoints struct but 4 coordinates (x1, y1, x2, y2). Then I
launched my program again and I saw a rectangle with a border line and a
fill color. So it works, but not always... Any body know why?
I'm using
- Linux Mandrake 8.0 (k2.4.3)
- gtk 1.2.10
- gtkcanvas 0.1(should be the last version and also the same as the last
GnomeCanvas version - dunno the version number...)

Here is how I'm creating the canvas and intialising gtk, etc.
 gtk_init(&argc, &argv);
 gdk_rgb_init();
 gtk_canvas_init();

 gtk_widget_push_visual(gdk_rgb_get_visual());
 gtk_widget_push_colormap(gdk_rgb_get_cmap());

 cnvCanvas = gtk_canvas_new_aa();

 gtk_widget_pop_colormap();
 gtk_widget_pop_visual();



Here is the code use to draw the quadrilatere (I'm using nothing more that
should influence the result...):
 GtkCanvasPoints *points;
 gint32 *paFillColor_E;
 gint32 *paOutlineColor_E;

 paFillColor_E = (gint32*)malloc(sizeof(gint32));
 *paFillColor_E = 0xAFCAE970;
 paOutlineColor_E = (gint32*)malloc(sizeof(gint32));
 *paOutlineColor_E = 0xC23A3AFF;

 points = gtk_canvas_points_new (4);

 points->coords[0] = 110.0;
 points->coords[1] = 220.0;
 points->coords[2] = 110.0;
 points->coords[3] = 280.0;
 points->coords[4] = 160.0;
 points->coords[5] = 280.0;
 points->coords[6] = 160.0;
 points->coords[7] = 220.0;

 gtk_canvas_item_new
  (
   gtk_canvas_root (GTK_CANVAS (canvas)),
   gtk_canvas_polygon_get_type(),
   "points",    points,
   "fill_color_rgba",    *paFillColor_E,
   "outline_color_rgba",  *paOutlineColor_E,
   "width_pixels",   1,
   NULL
  );



Best regards,
---
Jean-Christophe Berthon

Cap Gemini -- Ernst & Young
France
Skill Integration System -- Image Quality
Email: Jean-Christophe Berthon cgey com
Tel: (+33) 561 31 6639







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