[Gtk-sharp-list] GnomeCanvas questions

Jorge García jgarcia@ac.upc.es
Mon, 26 Apr 2004 19:41:02 +0200


Hi,

does someone know how is the best method for declare a CanvasGroup?

With this sentence I get the following error:
CanvasGroup group = new CanvasGroup(canvas.Root(),CanvasGroup.GType);		

ui.cs(196) error CS1501: No overload for method `Gnome.CanvasGroup'
takes `2' arguments

But if I make like samples/Fifteen.cs example and I define a subclass of
CanvasGroup then it works:

MyGroup group = new MyGroup(canvas.Root());

...

public class MyGroup: Gnome.CanvasGroup{
		public MyGroup (CanvasGroup group)
			: base (group, CanvasGroup.GType)
			{
				
			}
}



Another question that I have is how to write lines fast. I use this
function (ported from George Lebl's DeveloperWorks article):

void DrawALine(CanvasGroup group,double x1, double y1, double x2, double
y2, string color){

	double[] coords = {x1, y1, x2, y2};
	/* allocate a new points array */
	CanvasPoints points = new CanvasPoints(coords);

	/* draw the line */
	CanvasLine item = new CanvasLine(group);
	item.Points = points;
	item.FillColor = color;
	item.WidthUnits = 1.0;
	item.CanvasEvent += new Gnome.CanvasEventHandler (Item_Event);
}

The problem with this function is that each time that it calls to
"new CanvasPoints(coords)" the coordinates are showed by the console,
and its makes veeeery slow my program (that uses thousands of lines)


Thank you very much in advance,

Jorge