[Redbutton-devel] SF.net SVN: redbutton: [254] redbutton-browser/trunk
Brought to you by:
skilvington
|
From: <ski...@us...> - 2007-03-23 13:45:26
|
Revision: 254
http://svn.sourceforge.net/redbutton/?rev=254&view=rev
Author: skilvington
Date: 2007-03-23 06:45:24 -0700 (Fri, 23 Mar 2007)
Log Message:
-----------
DrawPolyline DynamicLineArtClass method
Modified Paths:
--------------
redbutton-browser/trunk/DynamicLineArtClass.c
redbutton-browser/trunk/MHEGCanvas.c
redbutton-browser/trunk/MHEGCanvas.h
Modified: redbutton-browser/trunk/DynamicLineArtClass.c
===================================================================
--- redbutton-browser/trunk/DynamicLineArtClass.c 2007-03-22 17:42:27 UTC (rev 253)
+++ redbutton-browser/trunk/DynamicLineArtClass.c 2007-03-23 13:45:24 UTC (rev 254)
@@ -626,10 +626,30 @@
void
DynamicLineArtClass_DrawPolyline(DynamicLineArtClass *t, DrawPolyline *params, OctetString *caller_gid)
{
+ LIST_OF(XYPosition) *xy_list = NULL;
+ LIST_TYPE(XYPosition) *xy;
+ LIST_TYPE(Point) *pt;
+
verbose("DynamicLineArtClass: %s; DrawPolyline", ExternalReference_name(&t->rootClass.inst.ref));
-/* TODO */
-printf("TODO: DynamicLineArtClass_DrawPolyline not yet implemented\n");
+ for(pt=params->pointlist; pt; pt=pt->next)
+ {
+ xy = safe_malloc(sizeof(LIST_TYPE(XYPosition)));
+ xy->item.x_position = GenericInteger_getInteger(&pt->item.x, caller_gid);
+ xy->item.y_position = GenericInteger_getInteger(&pt->item.y, caller_gid);
+ LIST_APPEND(&xy_list, xy);
+ }
+
+ MHEGCanvas_drawPolyline(t->inst.canvas, xy_list,
+ t->inst.LineWidth, t->inst.LineStyle,
+ &t->inst.RefLineColour);
+
+ /* if it is active, redraw it */
+ if(t->rootClass.inst.RunningStatus)
+ MHEGEngine_redrawArea(&t->inst.Position, &t->inst.BoxSize);
+
+ LIST_FREE(&xy_list, XYPosition, safe_free);
+
return;
}
Modified: redbutton-browser/trunk/MHEGCanvas.c
===================================================================
--- redbutton-browser/trunk/MHEGCanvas.c 2007-03-22 17:42:27 UTC (rev 253)
+++ redbutton-browser/trunk/MHEGCanvas.c 2007-03-23 13:45:24 UTC (rev 254)
@@ -390,6 +390,60 @@
}
/*
+ * draw a set of joined lines
+ * the lines are drawn width pixels wide in the given colour
+ */
+
+void
+MHEGCanvas_drawPolyline(MHEGCanvas *c, LIST_OF(XYPosition) *xy_list, int width, int style, MHEGColour *colour)
+{
+ MHEGDisplay *d = MHEGEngine_getDisplay();
+ LIST_TYPE(XYPosition) *pos;
+ unsigned int nxpts;
+ XPoint *xpts;
+ unsigned int i;
+ XGCValues gcvals;
+
+ if(width <= 0)
+ return;
+
+ if(style != LineStyle_solid)
+ error("MHEGCanvas_drawPolyline: LineStyle %d not supported (using a solid line)", style);
+
+ /* scale up if fullscreen */
+ width = (width * d->xres) / MHEG_XRES;
+
+ /* convert the XYPosition list into an array of XPoint's */
+ nxpts = 0;
+ for(pos=xy_list; pos; pos=pos->next)
+ nxpts ++;
+
+ xpts = safe_malloc(nxpts * sizeof(XPoint));
+
+ pos = xy_list;
+ for(i=0; i<nxpts; i++)
+ {
+ /* scale up if fullscreen */
+ xpts[i].x = (pos->item.x_position * d->xres) / MHEG_XRES;
+ xpts[i].y = (pos->item.y_position * d->yres) / MHEG_YRES;
+ pos = pos->next;
+ }
+
+ /* set the line width and colour */
+ gcvals.foreground = pixel_value(c->pic_format, colour);
+ gcvals.line_width = width;
+ XChangeGC(d->dpy, c->gc, GCForeground | GCLineWidth, &gcvals);
+
+ /* draw it */
+ XDrawLines(d->dpy, c->contents, c->gc, xpts, nxpts, CoordModeOrigin);
+
+ /* clean up */
+ safe_free(xpts);
+
+ return;
+}
+
+/*
* draw a rectangle
* the outline is drawn width pixels wide (ie it may stick out of the box) in line_col
* it is filled with fill_col
Modified: redbutton-browser/trunk/MHEGCanvas.h
===================================================================
--- redbutton-browser/trunk/MHEGCanvas.h 2007-03-22 17:42:27 UTC (rev 253)
+++ redbutton-browser/trunk/MHEGCanvas.h 2007-03-23 13:45:24 UTC (rev 254)
@@ -30,6 +30,7 @@
void MHEGCanvas_drawLine(MHEGCanvas *, XYPosition *, XYPosition *, int, int, MHEGColour *);
void MHEGCanvas_drawOval(MHEGCanvas *, XYPosition *, OriginalBoxSize *, int, int, MHEGColour *, MHEGColour *);
void MHEGCanvas_drawPolygon(MHEGCanvas *, LIST_OF(XYPosition) *, int, int, MHEGColour *, MHEGColour *);
+void MHEGCanvas_drawPolyline(MHEGCanvas *, LIST_OF(XYPosition) *, int, int, MHEGColour *);
void MHEGCanvas_drawRectangle(MHEGCanvas *, XYPosition *, OriginalBoxSize *, int, int, MHEGColour *, MHEGColour *);
#endif /* __MHEGCANVAS_H__ */
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|