[Redbutton-devel] SF.net SVN: redbutton: [253] redbutton-browser/trunk
Brought to you by:
skilvington
|
From: <ski...@us...> - 2007-03-22 17:42:33
|
Revision: 253
http://svn.sourceforge.net/redbutton/?rev=253&view=rev
Author: skilvington
Date: 2007-03-22 10:42:27 -0700 (Thu, 22 Mar 2007)
Log Message:
-----------
DrawPolygon 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 09:35:08 UTC (rev 252)
+++ redbutton-browser/trunk/DynamicLineArtClass.c 2007-03-22 17:42:27 UTC (rev 253)
@@ -486,7 +486,9 @@
return;
}
- MHEGCanvas_drawArc(t->inst.canvas, &pos, &box, start, arc, t->inst.LineWidth, t->inst.LineStyle, &t->inst.RefLineColour);
+ MHEGCanvas_drawArc(t->inst.canvas, &pos, &box, start, arc,
+ t->inst.LineWidth, t->inst.LineStyle,
+ &t->inst.RefLineColour);
/* if it is active, redraw it */
if(t->rootClass.inst.RunningStatus)
@@ -526,7 +528,8 @@
}
MHEGCanvas_drawSector(t->inst.canvas, &pos, &box, start, arc,
- t->inst.LineWidth, t->inst.LineStyle, &t->inst.RefLineColour, &t->inst.RefFillColour);
+ t->inst.LineWidth, t->inst.LineStyle,
+ &t->inst.RefLineColour, &t->inst.RefFillColour);
/* if it is active, redraw it */
if(t->rootClass.inst.RunningStatus)
@@ -548,7 +551,9 @@
p2.x_position = GenericInteger_getInteger(¶ms->x2, caller_gid);
p2.y_position = GenericInteger_getInteger(¶ms->y2, caller_gid);
- MHEGCanvas_drawLine(t->inst.canvas, &p1, &p2, t->inst.LineWidth, t->inst.LineStyle, &t->inst.RefLineColour);
+ MHEGCanvas_drawLine(t->inst.canvas, &p1, &p2,
+ t->inst.LineWidth, t->inst.LineStyle,
+ &t->inst.RefLineColour);
/* if it is active, redraw it */
if(t->rootClass.inst.RunningStatus)
@@ -591,10 +596,30 @@
void
DynamicLineArtClass_DrawPolygon(DynamicLineArtClass *t, DrawPolygon *params, OctetString *caller_gid)
{
+ LIST_OF(XYPosition) *xy_list = NULL;
+ LIST_TYPE(XYPosition) *xy;
+ LIST_TYPE(Point) *pt;
+
verbose("DynamicLineArtClass: %s; DrawPolygon", ExternalReference_name(&t->rootClass.inst.ref));
-/* TODO */
-printf("TODO: DynamicLineArtClass_DrawPolygon 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_drawPolygon(t->inst.canvas, xy_list,
+ t->inst.LineWidth, t->inst.LineStyle,
+ &t->inst.RefLineColour, &t->inst.RefFillColour);
+
+ /* 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 09:35:08 UTC (rev 252)
+++ redbutton-browser/trunk/MHEGCanvas.c 2007-03-22 17:42:27 UTC (rev 253)
@@ -324,6 +324,72 @@
}
/*
+ * draw a closed polygon
+ * the outline is drawn width pixels wide (ie it may stick out of the box) in line_col
+ * it is filled with fill_col
+ * UK MHEG Profile says polygons must be convex
+ */
+
+void
+MHEGCanvas_drawPolygon(MHEGCanvas *c, LIST_OF(XYPosition) *xy_list, int width, int style, MHEGColour *line_col, MHEGColour *fill_col)
+{
+ MHEGDisplay *d = MHEGEngine_getDisplay();
+ LIST_TYPE(XYPosition) *pos;
+ unsigned int nxpts;
+ XPoint *xpts;
+ unsigned int i;
+ XGCValues gcvals;
+
+ if(style != LineStyle_solid)
+ error("MHEGCanvas_drawPolygon: 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 ++;
+
+ /* +1 so we can close it for XDrawLines */
+ xpts = safe_malloc((nxpts + 1) * 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;
+ }
+
+ /* fill it */
+ gcvals.foreground = pixel_value(c->pic_format, fill_col);
+ XChangeGC(d->dpy, c->gc, GCForeground, &gcvals);
+
+ XFillPolygon(d->dpy, c->contents, c->gc, xpts, nxpts, Convex, CoordModeOrigin);
+
+ /* draw the outline */
+ if(width > 0)
+ {
+ /* close the polygon */
+ xpts[nxpts].x = (xy_list->item.x_position * d->xres) / MHEG_XRES;
+ xpts[nxpts].y = (xy_list->item.y_position * d->yres) / MHEG_YRES;
+ /* set the line width and colour */
+ gcvals.foreground = pixel_value(c->pic_format, line_col);
+ gcvals.line_width = width;
+ XChangeGC(d->dpy, c->gc, GCForeground | GCLineWidth, &gcvals);
+ /* draw it */
+ XDrawLines(d->dpy, c->contents, c->gc, xpts, nxpts + 1, 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 09:35:08 UTC (rev 252)
+++ redbutton-browser/trunk/MHEGCanvas.h 2007-03-22 17:42:27 UTC (rev 253)
@@ -29,6 +29,7 @@
void MHEGCanvas_drawSector(MHEGCanvas *, XYPosition *, OriginalBoxSize *, int, int, int, int, MHEGColour *, MHEGColour *);
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_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.
|