[Redbutton-devel] SF.net SVN: redbutton: [248] redbutton-browser/trunk
Brought to you by:
skilvington
|
From: <ski...@us...> - 2007-03-13 17:10:39
|
Revision: 248
http://svn.sourceforge.net/redbutton/?rev=248&view=rev
Author: skilvington
Date: 2007-03-13 10:10:33 -0700 (Tue, 13 Mar 2007)
Log Message:
-----------
DrawLine/Oval/Rectangle DynamicLineArtClass methods
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-13 14:27:19 UTC (rev 247)
+++ redbutton-browser/trunk/DynamicLineArtClass.c 2007-03-13 17:10:33 UTC (rev 248)
@@ -479,20 +479,46 @@
void
DynamicLineArtClass_DrawLine(DynamicLineArtClass *t, DrawLine *params, OctetString *caller_gid)
{
+ XYPosition p1;
+ XYPosition p2;
+
verbose("DynamicLineArtClass: %s; DrawLine", ExternalReference_name(&t->rootClass.inst.ref));
-/* TODO */
-printf("TODO: DynamicLineArtClass_DrawLine not yet implemented\n");
+ p1.x_position = GenericInteger_getInteger(¶ms->x1, caller_gid);
+ p1.y_position = GenericInteger_getInteger(¶ms->y1, caller_gid);
+ 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);
+
+ /* if it is active, redraw it */
+ if(t->rootClass.inst.RunningStatus)
+ MHEGEngine_redrawArea(&t->inst.Position, &t->inst.BoxSize);
+
return;
}
void
DynamicLineArtClass_DrawOval(DynamicLineArtClass *t, DrawOval *params, OctetString *caller_gid)
{
+ XYPosition pos;
+ OriginalBoxSize box;
+
verbose("DynamicLineArtClass: %s; DrawOval", ExternalReference_name(&t->rootClass.inst.ref));
-/* TODO */
-printf("TODO: DynamicLineArtClass_DrawOval not yet implemented\n");
+ pos.x_position = GenericInteger_getInteger(¶ms->x, caller_gid);
+ pos.y_position = GenericInteger_getInteger(¶ms->y, caller_gid);
+ box.x_length = GenericInteger_getInteger(¶ms->ellipse_width, caller_gid);
+ box.y_length = GenericInteger_getInteger(¶ms->ellipse_height, caller_gid);
+
+ MHEGCanvas_drawOval(t->inst.canvas, &pos, &box,
+ 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);
+
return;
}
@@ -519,10 +545,24 @@
void
DynamicLineArtClass_DrawRectangle(DynamicLineArtClass *t, DrawRectangle *params, OctetString *caller_gid)
{
+ XYPosition pos;
+ OriginalBoxSize box;
+
verbose("DynamicLineArtClass: %s; DrawRectangle", ExternalReference_name(&t->rootClass.inst.ref));
-/* TODO */
-printf("TODO: DynamicLineArtClass_DrawRectangle not yet implemented\n");
+ pos.x_position = GenericInteger_getInteger(¶ms->x1, caller_gid);
+ pos.y_position = GenericInteger_getInteger(¶ms->y1, caller_gid);
+ box.x_length = GenericInteger_getInteger(¶ms->x2, caller_gid) - pos.x_position;
+ box.y_length = GenericInteger_getInteger(¶ms->y2, caller_gid) - pos.y_position;
+
+ MHEGCanvas_drawRectangle(t->inst.canvas, &pos, &box,
+ 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);
+
return;
}
Modified: redbutton-browser/trunk/MHEGCanvas.c
===================================================================
--- redbutton-browser/trunk/MHEGCanvas.c 2007-03-13 14:27:19 UTC (rev 247)
+++ redbutton-browser/trunk/MHEGCanvas.c 2007-03-13 17:10:33 UTC (rev 248)
@@ -110,7 +110,12 @@
* drawing routine notes:
* if border width is W, then coord {W,W} is the first pixel that will not be hidden by the border
* all coords will be scaled up by these drawing routines if we are using full screen mode
- * UK MHEG Profile says we can treat ALL line styles as solid
+ * the line width will also be scaled up in full screen mode (based on the resolution in the X direction)
+ * line style should be one of:
+ * LineStyle_solid
+ * LineStyle_dashed
+ * LineStyle_dotted
+ * but, the UK MHEG Profile says we can treat ALL line styles as solid
* UK MHEG Profile says no alpha blending is done within the DynamicLineArtClass canvas
* ie all pixel values are put directly onto the canvas, replacing what was there before
*/
@@ -135,6 +140,125 @@
}
/*
+ * draw a line between p1 and p2
+ */
+
+void
+MHEGCanvas_drawLine(MHEGCanvas *c, XYPosition *p1, XYPosition *p2, int width, int style, MHEGColour *colour)
+{
+ MHEGDisplay *d = MHEGEngine_getDisplay();
+ XGCValues gcvals;
+ int x1, y1, x2, y2;
+
+ if(width <= 0)
+ return;
+
+ if(style != LineStyle_solid)
+ error("MHEGCanvas_drawLine: LineStyle %d not supported (using a solid line)", style);
+
+ /* scale up if fullscreen */
+ x1 = (p1->x_position * d->xres) / MHEG_XRES;
+ y1 = (p1->y_position * d->yres) / MHEG_YRES;
+ x2 = (p2->x_position * d->xres) / MHEG_XRES;
+ y2 = (p2->y_position * d->yres) / MHEG_YRES;
+ width = (width * d->xres) / MHEG_XRES;
+
+ /* set up the GC values */
+ gcvals.foreground = pixel_value(c->pic_format, colour);
+ gcvals.line_width = width;
+ XChangeGC(d->dpy, c->gc, GCForeground | GCLineWidth, &gcvals);
+
+ XDrawLine(d->dpy, c->contents, c->gc, x1, y1, x2, y2);
+
+ return;
+}
+
+/*
+ * draw an oval enclosed by the given box
+ * the outline is drawn width pixels wide (ie it may stick out of the box) in line_col
+ * the oval is filled with fill_col
+ */
+
+void
+MHEGCanvas_drawOval(MHEGCanvas *c, XYPosition *pos, OriginalBoxSize *box, int width, int style, MHEGColour *line_col, MHEGColour *fill_col)
+{
+ MHEGDisplay *d = MHEGEngine_getDisplay();
+ XGCValues gcvals;
+ int x, y, w, h;
+
+ /* corrigendum puts these limits on the ellipse size */
+ if(box->x_length < 0 || box->y_length < 0)
+ {
+ error("MHEGCanvas_drawOval: invalid box size (%d,%d)", box->x_length, box->y_length);
+ return;
+ }
+
+ if(style != LineStyle_solid)
+ error("MHEGCanvas_drawOval: LineStyle %d not supported (using a solid line)", style);
+
+ /* scale up if fullscreen */
+ x = (pos->x_position * d->xres) / MHEG_XRES;
+ y = (pos->y_position * d->yres) / MHEG_YRES;
+ w = (box->x_length * d->xres) / MHEG_XRES;
+ h = (box->y_length * d->yres) / MHEG_YRES;
+ width = (width * d->xres) / MHEG_XRES;
+
+ /* fill it */
+ gcvals.foreground = pixel_value(c->pic_format, fill_col);
+ XChangeGC(d->dpy, c->gc, GCForeground, &gcvals);
+
+ XFillArc(d->dpy, c->contents, c->gc, x, y, w, h, 0, 360 * 64);
+
+ /* draw the outline */
+ gcvals.foreground = pixel_value(c->pic_format, line_col);
+ gcvals.line_width = width;
+ XChangeGC(d->dpy, c->gc, GCForeground | GCLineWidth, &gcvals);
+
+ XDrawArc(d->dpy, c->contents, c->gc, x, y, w, h, 0, 360 * 64);
+
+ 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
+ */
+
+void
+MHEGCanvas_drawRectangle(MHEGCanvas *c, XYPosition *pos, OriginalBoxSize *box, int width, int style, MHEGColour *line_col, MHEGColour *fill_col)
+{
+ MHEGDisplay *d = MHEGEngine_getDisplay();
+ XGCValues gcvals;
+ int x, y, w, h;
+
+ if(style != LineStyle_solid)
+ error("MHEGCanvas_drawRectangle: LineStyle %d not supported (using a solid line)", style);
+
+ /* scale up if fullscreen */
+ x = (pos->x_position * d->xres) / MHEG_XRES;
+ y = (pos->y_position * d->yres) / MHEG_YRES;
+ w = (box->x_length * d->xres) / MHEG_XRES;
+ h = (box->y_length * d->yres) / MHEG_YRES;
+ width = (width * d->xres) / MHEG_XRES;
+
+ /* fill it */
+ gcvals.foreground = pixel_value(c->pic_format, fill_col);
+ XChangeGC(d->dpy, c->gc, GCForeground, &gcvals);
+
+ XFillRectangle(d->dpy, c->contents, c->gc, x, y, w, h);
+
+ /* draw the outline */
+ gcvals.foreground = pixel_value(c->pic_format, line_col);
+ gcvals.line_width = width;
+ XChangeGC(d->dpy, c->gc, GCForeground | GCLineWidth, &gcvals);
+
+ XDrawRectangle(d->dpy, c->contents, c->gc, x, y, w, h);
+
+ return;
+}
+
+/*
* convert the MHEGColour to a pixel value
*/
Modified: redbutton-browser/trunk/MHEGCanvas.h
===================================================================
--- redbutton-browser/trunk/MHEGCanvas.h 2007-03-13 14:27:19 UTC (rev 247)
+++ redbutton-browser/trunk/MHEGCanvas.h 2007-03-13 17:10:33 UTC (rev 248)
@@ -25,6 +25,9 @@
void MHEGCanvas_setBorder(MHEGCanvas *, int, int, MHEGColour *);
void MHEGCanvas_clear(MHEGCanvas *, MHEGColour *);
+void MHEGCanvas_drawLine(MHEGCanvas *, XYPosition *, XYPosition *, int, int, MHEGColour *);
+void MHEGCanvas_drawOval(MHEGCanvas *, XYPosition *, OriginalBoxSize *, 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.
|