[Redbutton-devel] SF.net SVN: redbutton: [243] redbutton-browser/trunk
Brought to you by:
skilvington
|
From: <ski...@us...> - 2007-03-12 17:08:36
|
Revision: 243
http://svn.sourceforge.net/redbutton/?rev=243&view=rev
Author: skilvington
Date: 2007-03-12 10:08:27 -0700 (Mon, 12 Mar 2007)
Log Message:
-----------
the easy DynamicLineArtClass methods
Modified Paths:
--------------
redbutton-browser/trunk/DynamicLineArtClass.c
redbutton-browser/trunk/MHEGCanvas.c
Modified: redbutton-browser/trunk/DynamicLineArtClass.c
===================================================================
--- redbutton-browser/trunk/DynamicLineArtClass.c 2007-03-12 12:21:15 UTC (rev 242)
+++ redbutton-browser/trunk/DynamicLineArtClass.c 2007-03-12 17:08:27 UTC (rev 243)
@@ -205,11 +205,19 @@
t->inst.BoxSize.x_length = GenericInteger_getInteger(¶ms->x_new_box_size, caller_gid);
t->inst.BoxSize.y_length = GenericInteger_getInteger(¶ms->y_new_box_size, caller_gid);
-/* TODO */
-/* clear to OriginalRefFillColour */
-/* dont forget to update the border */
-printf("TODO: DynamicLineArtClass_SetBoxSize clear to OriginalRefFillColour\n");
+ /* spec says we should fill the drawing area with OriginalRefFillColour */
+ /* delete the old drawing area and create a new one at the new size */
+ free_MHEGCanvas(t->inst.canvas);
+ t->inst.canvas = new_MHEGCanvas(t->inst.BoxSize.x_length, t->inst.BoxSize.y_length);
+
+ /* default value for BorderedBoundingBox is true */
+ if(!t->have_bordered_bounding_box || t->bordered_bounding_box)
+ MHEGCanvas_setBorder(t->inst.canvas, t->original_line_width, t->original_line_style, &t->inst.OriginalRefLineColour);
+
+ /* now we have set the border, clear the drawing area */
+ MHEGCanvas_clear(t->inst.canvas, &t->inst.OriginalRefFillColour);
+
/* if it is active, redraw it */
if(t->rootClass.inst.RunningStatus)
{
@@ -345,8 +353,8 @@
{
verbose("DynamicLineArtClass: %s; SetLineWidth", ExternalReference_name(&t->rootClass.inst.ref));
-/* TODO */
-printf("TODO: DynamicLineArtClass_SetLineWidth not yet implemented\n");
+ t->inst.LineWidth = GenericInteger_getInteger(¶ms->new_line_width, caller_gid);
+
return;
}
@@ -355,8 +363,8 @@
{
verbose("DynamicLineArtClass: %s; SetLineStyle", ExternalReference_name(&t->rootClass.inst.ref));
-/* TODO */
-printf("TODO: DynamicLineArtClass_SetLineStyle not yet implemented\n");
+ t->inst.LineStyle = GenericInteger_getInteger(¶ms->new_line_style, caller_gid);
+
return;
}
@@ -365,8 +373,8 @@
{
verbose("DynamicLineArtClass: %s; SetLineColour", ExternalReference_name(&t->rootClass.inst.ref));
-/* TODO */
-printf("TODO: DynamicLineArtClass_SetLineColour not yet implemented\n");
+ MHEGColour_fromNewColour(&t->inst.RefLineColour, ¶ms->new_line_colour, caller_gid);
+
return;
}
@@ -375,28 +383,56 @@
{
verbose("DynamicLineArtClass: %s; SetFillColour", ExternalReference_name(&t->rootClass.inst.ref));
-/* TODO */
-printf("TODO: DynamicLineArtClass_SetFillColour not yet implemented\n");
+ /* if no colour is given, use transparent */
+ if(params->have_new_fill_colour)
+ MHEGColour_fromNewColour(&t->inst.RefFillColour, ¶ms->new_fill_colour, caller_gid);
+ else
+ MHEGColour_transparent(&t->inst.RefFillColour);
+
return;
}
void
DynamicLineArtClass_GetLineWidth(DynamicLineArtClass *t, GetLineWidth *params, OctetString *caller_gid)
{
+ VariableClass *var;
+
verbose("DynamicLineArtClass: %s; GetLineWidth", ExternalReference_name(&t->rootClass.inst.ref));
-/* TODO */
-printf("TODO: DynamicLineArtClass_GetLineWidth not yet implemented\n");
+ if((var = (VariableClass *) MHEGEngine_findObjectReference(¶ms->line_width_var, caller_gid)) == NULL)
+ return;
+
+ if(var->rootClass.inst.rtti != RTTI_VariableClass
+ || VariableClass_type(var) != OriginalValue_integer)
+ {
+ error("DynamicLineArtClass: GetLineWidth: type mismatch");
+ return;
+ }
+
+ IntegerVariableClass_setInteger(var, t->inst.LineWidth);
+
return;
}
void
DynamicLineArtClass_GetLineStyle(DynamicLineArtClass *t, GetLineStyle *params, OctetString *caller_gid)
{
+ VariableClass *var;
+
verbose("DynamicLineArtClass: %s; GetLineStyle", ExternalReference_name(&t->rootClass.inst.ref));
-/* TODO */
-printf("TODO: DynamicLineArtClass_GetLineStyle not yet implemented\n");
+ if((var = (VariableClass *) MHEGEngine_findObjectReference(¶ms->line_style_var, caller_gid)) == NULL)
+ return;
+
+ if(var->rootClass.inst.rtti != RTTI_VariableClass
+ || VariableClass_type(var) != OriginalValue_integer)
+ {
+ error("DynamicLineArtClass: GetLineStyle: type mismatch");
+ return;
+ }
+
+ IntegerVariableClass_setInteger(var, t->inst.LineStyle);
+
return;
}
@@ -495,8 +531,13 @@
{
verbose("DynamicLineArtClass: %s; Clear", ExternalReference_name(&t->rootClass.inst.ref));
-/* TODO */
-printf("TODO: DynamicLineArtClass_Clear not yet implemented\n");
+ /* fill with OriginalRefFillColour */
+ MHEGCanvas_clear(t->inst.canvas, &t->inst.OriginalRefFillColour);
+
+ /* 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-12 12:21:15 UTC (rev 242)
+++ redbutton-browser/trunk/MHEGCanvas.c 2007-03-12 17:08:27 UTC (rev 243)
@@ -21,15 +21,18 @@
free_MHEGCanvas(MHEGCanvas *c)
{
safe_free(c);
+
+ return;
}
/*
* set a border, no drawing will be done in the border (apart from the border itself)
* width is in pixels
* style should be one of:
- * original_line_style_solid
- * original_line_style_dashed
- * original_line_style_dotted
+ * LineStyle_solid
+ * LineStyle_dashed
+ * LineStyle_dotted
+ * (note: UK MHEG Profile says we can treat ALL line styles as solid)
*/
void
@@ -38,6 +41,9 @@
if(width <= 0)
return;
+ if(style != LineStyle_solid)
+ error("MHEGCanvas_setBorder: LineStyle %d not supported (using a solid line)", style);
+
/* TODO */
printf("TODO: MHEGCanvas_setBorder: width=%d style=%d RGBT=%02x%02x%02x%02x\n", width, style, colour->r, colour->g, colour->b, colour->t);
@@ -45,6 +51,14 @@
}
/*
+ * drawing routine notes:
+ * if border width is W, then coord {W,W} is the first pixel that will not be hidden by the border
+ * UK MHEG Profile says we can treat ALL line styles as solid
+ * UK MHEG Profile says no alpha blending is done within the DynamicLineArt canvas
+ * ie all pixel values are put directly onto the canvas, replacing what was there before
+ */
+
+/*
* fill the image (excluding the border) with the given colour
*/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|