summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorjoye <joye>2014-03-11 21:01:10 (GMT)
committerjoye <joye>2014-03-11 21:01:10 (GMT)
commit68e56908fcd1a8764f404f71197c028cd6bc8f48 (patch)
treefb367ae71fcc85cb3b012817d620c40417a048bf /src
parent98824f81b4f511fdf02222942ac61272274155e6 (diff)
downloadblt-68e56908fcd1a8764f404f71197c028cd6bc8f48.zip
blt-68e56908fcd1a8764f404f71197c028cd6bc8f48.tar.gz
blt-68e56908fcd1a8764f404f71197c028cd6bc8f48.tar.bz2
*** empty log message ***
Diffstat (limited to 'src')
-rw-r--r--src/bltGrMarker.C140
-rw-r--r--src/bltGrMarker.h1
-rw-r--r--src/bltGrMarkerPolygon.C72
-rw-r--r--src/bltGrMarkerPolygon.h6
4 files changed, 44 insertions, 175 deletions
diff --git a/src/bltGrMarker.C b/src/bltGrMarker.C
index 7922e0c..83cbcbd 100644
--- a/src/bltGrMarker.C
+++ b/src/bltGrMarker.C
@@ -132,14 +132,6 @@ Blt_CustomOption coordsOption =
ObjToCoordsProc, CoordsToObjProc, FreeCoordsProc, NULL
};
-static Blt_OptionFreeProc FreeColorPairProc;
-static Blt_OptionParseProc ObjToColorPairProc;
-static Blt_OptionPrintProc ColorPairToObjProc;
-Blt_CustomOption colorPairOption =
- {
- ObjToColorPairProc, ColorPairToObjProc, FreeColorPairProc, (ClientData)0
- };
-
static int GetCoordinate(Tcl_Interp* interp, Tcl_Obj *objPtr, double *valuePtr)
{
char c;
@@ -296,138 +288,6 @@ static Tcl_Obj* CoordsToObjProc(ClientData clientData, Tcl_Interp* interp,
return listObjPtr;
}
-static int GetColorPair(Tcl_Interp* interp, Tk_Window tkwin,
- Tcl_Obj *fgObjPtr, Tcl_Obj *bgObjPtr,
- ColorPair *pairPtr, int allowDefault)
-{
- XColor* fgColor, *bgColor;
- const char* string;
-
- fgColor = bgColor = NULL;
- if (fgObjPtr != NULL) {
- int length;
-
- string = Tcl_GetStringFromObj(fgObjPtr, &length);
- if (string[0] == '\0') {
- fgColor = NULL;
- } else if ((allowDefault) && (string[0] == 'd') &&
- (strncmp(string, "defcolor", length) == 0)) {
- fgColor = COLOR_DEFAULT;
- } else {
- fgColor = Tk_AllocColorFromObj(interp, tkwin, fgObjPtr);
- if (fgColor == NULL) {
- return TCL_ERROR;
- }
- }
- }
- if (bgObjPtr != NULL) {
- int length;
-
- string = Tcl_GetStringFromObj(bgObjPtr, &length);
- if (string[0] == '\0') {
- bgColor = NULL;
- } else if ((allowDefault) && (string[0] == 'd') &&
- (strncmp(string, "defcolor", length) == 0)) {
- bgColor = COLOR_DEFAULT;
- } else {
- bgColor = Tk_AllocColorFromObj(interp, tkwin, bgObjPtr);
- if (bgColor == NULL) {
- return TCL_ERROR;
- }
- }
- }
- if (pairPtr->fgColor != NULL) {
- Tk_FreeColor(pairPtr->fgColor);
- }
- if (pairPtr->bgColor != NULL) {
- Tk_FreeColor(pairPtr->bgColor);
- }
- pairPtr->fgColor = fgColor;
- pairPtr->bgColor = bgColor;
- return TCL_OK;
-}
-
-void Blt_FreeColorPair(ColorPair *pairPtr)
-{
- if ((pairPtr->bgColor != NULL) && (pairPtr->bgColor != COLOR_DEFAULT)) {
- Tk_FreeColor(pairPtr->bgColor);
- }
- if ((pairPtr->fgColor != NULL) && (pairPtr->fgColor != COLOR_DEFAULT)) {
- Tk_FreeColor(pairPtr->fgColor);
- }
- pairPtr->bgColor = pairPtr->fgColor = NULL;
-}
-
-static void FreeColorPairProc(ClientData clientData, Display *display,
- char* widgRec, int offset)
-{
- ColorPair *pairPtr = (ColorPair *)(widgRec + offset);
- Blt_FreeColorPair(pairPtr);
-}
-
-static int ObjToColorPairProc(ClientData clientData, Tcl_Interp* interp,
- Tk_Window tkwin, Tcl_Obj *objPtr, char* widgRec,
- int offset, int flags)
-{
- ColorPair *pairPtr = (ColorPair *)(widgRec + offset);
- long longValue = (long)clientData;
- int bool;
- int objc;
- Tcl_Obj **objv;
-
- if (Tcl_ListObjGetElements(interp, objPtr, &objc, &objv) != TCL_OK) {
- return TCL_ERROR;
- }
- if (objc > 2) {
- Tcl_AppendResult(interp, "too many names in colors list",
- (char*)NULL);
- return TCL_ERROR;
- }
- if (objc == 0) {
- Blt_FreeColorPair(pairPtr);
- return TCL_OK;
- }
- bool = (int)longValue;
- if (objc == 1) {
- if (GetColorPair(interp, tkwin, objv[0], NULL, pairPtr, bool)
- != TCL_OK) {
- return TCL_ERROR;
- }
- } else {
- if (GetColorPair(interp, tkwin, objv[0], objv[1], pairPtr, bool)
- != TCL_OK) {
- return TCL_ERROR;
- }
- }
- return TCL_OK;
-}
-
-static const char* NameOfColor(XColor* colorPtr)
-{
- if (colorPtr == NULL) {
- return "";
- } else if (colorPtr == COLOR_DEFAULT) {
- return "defcolor";
- } else {
- return Tk_NameOfColor(colorPtr);
- }
-}
-
-static Tcl_Obj* ColorPairToObjProc(ClientData clientData, Tcl_Interp* interp,
- Tk_Window tkwin, char* widgRec,
- int offset, int flags)
-{
- ColorPair *pairPtr = (ColorPair *)(widgRec + offset);
- Tcl_Obj *listObjPtr;
-
- listObjPtr = Tcl_NewListObj(0, (Tcl_Obj **)NULL);
- Tcl_ListObjAppendElement(interp, listObjPtr,
- Tcl_NewStringObj(NameOfColor(pairPtr->fgColor), -1));
- Tcl_ListObjAppendElement(interp, listObjPtr,
- Tcl_NewStringObj(NameOfColor(pairPtr->bgColor), -1));
- return listObjPtr;
-}
-
static int IsElementHidden(Marker *markerPtr)
{
Tcl_HashEntry *hPtr;
diff --git a/src/bltGrMarker.h b/src/bltGrMarker.h
index f4493d7..5ae42bb 100644
--- a/src/bltGrMarker.h
+++ b/src/bltGrMarker.h
@@ -33,7 +33,6 @@
#define MAX_OUTLINE_POINTS 12
extern Blt_CustomOption coordsOption;
-extern Blt_CustomOption colorPairOption;
extern Blt_CustomOption bltXAxisOption;
extern Blt_CustomOption bltYAxisOption;
diff --git a/src/bltGrMarkerPolygon.C b/src/bltGrMarkerPolygon.C
index 57b08a5..fea7a07 100644
--- a/src/bltGrMarkerPolygon.C
+++ b/src/bltGrMarkerPolygon.C
@@ -44,8 +44,10 @@ static Tk_OptionSpec polygonOptionSpecs[] = {
TK_OPTION_NULL_OK, &dashesObjOption, 0},
{TK_OPTION_STRING, "-element", "element", "Element",
NULL, -1, Tk_Offset(PolygonMarker, elemName), TK_OPTION_NULL_OK, NULL, 0},
- // {BLT_CONFIG_CUSTOM, "-fill", "fill", "Fill", "rred",
- // Tk_Offset(PolygonMarker, fill), BLT_CONFIG_NULL_OK, &colorPairOption},
+ {TK_OPTION_COLOR, "-fill", "fill", "Fill",
+ "red", -1, Tk_Offset(PolygonMarker, fill), TK_OPTION_NULL_OK, NULL, 0},
+ {TK_OPTION_COLOR, "-fillbg", "fillbg", "FillBg",
+ NULL, -1, Tk_Offset(PolygonMarker, fillBg), TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_CUSTOM, "-join", "join", "Join",
"miter", -1, Tk_Offset(PolygonMarker, joinStyle), 0, &capStyleObjOption, 0},
{TK_OPTION_PIXELS, "-polygonwidth", "polygonWidth", "PolygonWidth",
@@ -58,9 +60,12 @@ static Tk_OptionSpec polygonOptionSpecs[] = {
"y", -1, Tk_Offset(PolygonMarker, axes.y), 0, &yAxisObjOption, 0},
{TK_OPTION_STRING, "-name", "name", "Name",
NULL, -1, Tk_Offset(PolygonMarker, obj.name), TK_OPTION_NULL_OK, NULL, 0},
- // {BLT_CONFIG_CUSTOM, "-outline", "outline", "Outline",
- // "black", Tk_Offset(PolygonMarker, outline),
- // BLT_CONFIG_NULL_OK, &colorPairOption},
+ {TK_OPTION_COLOR, "-outline", "outline", "Outline",
+ "black", -1, Tk_Offset(PolygonMarker, outline),
+ TK_OPTION_NULL_OK, NULL, 0},
+ {TK_OPTION_COLOR, "-outlinebg", "outlinebg", "OutlineBg",
+ NULL, -1, Tk_Offset(PolygonMarker, outlineBg),
+ TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_CUSTOM, "-state", "state", "State",
"normal", -1, Tk_Offset(PolygonMarker, state), 0, &stateObjOption, 0},
{TK_OPTION_BITMAP, "-stipple", "stipple", "Stipple",
@@ -88,8 +93,10 @@ static Blt_ConfigSpec polygonConfigSpecs[] = {
Tk_Offset(PolygonMarker, dashes), BLT_CONFIG_NULL_OK, &dashesOption},
{BLT_CONFIG_STRING, "-element", "element", "Element", NULL,
Tk_Offset(PolygonMarker, elemName), BLT_CONFIG_NULL_OK},
- {BLT_CONFIG_CUSTOM, "-fill", "fill", "Fill", "rred",
- Tk_Offset(PolygonMarker, fill), BLT_CONFIG_NULL_OK, &colorPairOption},
+ {BLT_CONFIG_COLOR, "-fill", "fill", "Fill", "rred",
+ Tk_Offset(PolygonMarker, fill), BLT_CONFIG_NULL_OK, NULL},
+ {BLT_CONFIG_COLOR, "-fillbg", "fillbg", "FillBg", NULL,
+ Tk_Offset(PolygonMarker, fillBg), BLT_CONFIG_NULL_OK, NULL},
{BLT_CONFIG_JOIN_STYLE, "-join", "join", "Join", "miter",
Tk_Offset(PolygonMarker, joinStyle), BLT_CONFIG_DONT_SET_DEFAULT},
{BLT_CONFIG_PIXELS, "-linewidth", "lineWidth", "LineWidth",
@@ -103,9 +110,10 @@ static Blt_ConfigSpec polygonConfigSpecs[] = {
Tk_Offset(PolygonMarker, axes.y), 0, &bltYAxisOption},
{BLT_CONFIG_STRING, "-name", (char*)NULL, (char*)NULL, NULL,
Tk_Offset(PolygonMarker, obj.name), BLT_CONFIG_NULL_OK},
- {BLT_CONFIG_CUSTOM, "-outline", "outline", "Outline",
- "black", Tk_Offset(PolygonMarker, outline),
- BLT_CONFIG_NULL_OK, &colorPairOption},
+ {BLT_CONFIG_COLOR, "-outline", "outline", "Outline",
+ "black", Tk_Offset(PolygonMarker, outline), BLT_CONFIG_NULL_OK, NULL},
+ {BLT_CONFIG_COLOR, "-outlinebg", "outlinebg", "OutlineBg", NULL,
+ Tk_Offset(PolygonMarker, outlineBg), BLT_CONFIG_NULL_OK, NULL},
{BLT_CONFIG_CUSTOM, "-state", "state", "State", "normal",
Tk_Offset(PolygonMarker, state), BLT_CONFIG_DONT_SET_DEFAULT, &stateOption},
{BLT_CONFIG_BITMAP, "-stipple", "stipple", "Stipple", NULL,
@@ -182,7 +190,7 @@ static void DrawPolygonProc(Marker *markerPtr, Drawable drawable)
PolygonMarker *pmPtr = (PolygonMarker *)markerPtr;
/* Draw polygon fill region */
- if ((pmPtr->nFillPts > 0) && (pmPtr->fill.fgColor != NULL)) {
+ if ((pmPtr->nFillPts > 0) && (pmPtr->fill != NULL)) {
XPoint *dp, *points;
Point2d *sp, *send;
@@ -204,7 +212,7 @@ static void DrawPolygonProc(Marker *markerPtr, Drawable drawable)
}
/* and then the outline */
if ((pmPtr->nOutlinePts > 0) && (pmPtr->lineWidth > 0) &&
- (pmPtr->outline.fgColor != NULL)) {
+ (pmPtr->outline != NULL)) {
Blt_Draw2DSegments(graphPtr->display, drawable, pmPtr->outlineGC,
pmPtr->outlinePts, pmPtr->nOutlinePts);
}
@@ -215,7 +223,7 @@ static void PolygonToPostscriptProc(Marker *markerPtr, Blt_Ps ps)
Graph* graphPtr = markerPtr->obj.graphPtr;
PolygonMarker *pmPtr = (PolygonMarker *)markerPtr;
- if (pmPtr->fill.fgColor != NULL) {
+ if (pmPtr->fill != NULL) {
/*
* Options: fg bg
@@ -229,14 +237,14 @@ static void PolygonToPostscriptProc(Marker *markerPtr, Blt_Ps ps)
/* If the background fill color was specified, draw the polygon in a
* solid fashion with that color. */
- if (pmPtr->fill.bgColor != NULL) {
+ if (pmPtr->fillBg != NULL) {
/* Draw the solid background as the background layer of the opaque
* stipple */
- Blt_Ps_XSetBackground(ps, pmPtr->fill.bgColor);
+ Blt_Ps_XSetBackground(ps, pmPtr->fillBg);
/* Retain the path. We'll need it for the foreground layer. */
Blt_Ps_Append(ps, "gsave fill grestore\n");
}
- Blt_Ps_XSetForeground(ps, pmPtr->fill.fgColor);
+ Blt_Ps_XSetForeground(ps, pmPtr->fill);
if (pmPtr->stipple != None) {
/* Draw the stipple in the foreground color. */
Blt_Ps_XSetStipple(ps, graphPtr->display, pmPtr->stipple);
@@ -246,10 +254,10 @@ static void PolygonToPostscriptProc(Marker *markerPtr, Blt_Ps ps)
}
/* Draw the outline in the foreground color. */
- if ((pmPtr->lineWidth > 0) && (pmPtr->outline.fgColor != NULL)) {
+ if ((pmPtr->lineWidth > 0) && (pmPtr->outline != NULL)) {
/* Set up the line attributes. */
- Blt_Ps_XSetLineAttributes(ps, pmPtr->outline.fgColor,
+ Blt_Ps_XSetLineAttributes(ps, pmPtr->outline,
pmPtr->lineWidth, &pmPtr->dashes, pmPtr->capStyle,
pmPtr->joinStyle);
@@ -258,9 +266,9 @@ static void PolygonToPostscriptProc(Marker *markerPtr, Blt_Ps ps)
* executed for each call to the Polygon drawing routine. If the line
* isn't dashed, simply make this an empty definition.
*/
- if ((pmPtr->outline.bgColor != NULL) && (LineIsDashed(pmPtr->dashes))) {
+ if ((pmPtr->outlineBg != NULL) && (LineIsDashed(pmPtr->dashes))) {
Blt_Ps_Append(ps, "/DashesProc {\ngsave\n ");
- Blt_Ps_XSetBackground(ps, pmPtr->outline.bgColor);
+ Blt_Ps_XSetBackground(ps, pmPtr->outlineBg);
Blt_Ps_Append(ps, " ");
Blt_Ps_XSetDashes(ps, (Blt_Dashes *)NULL);
Blt_Ps_Append(ps, "stroke\n grestore\n} def\n");
@@ -282,13 +290,13 @@ static int ConfigurePolygonProc(Marker *markerPtr)
drawable = Tk_WindowId(graphPtr->tkwin);
gcMask = (GCLineWidth | GCLineStyle);
- if (pmPtr->outline.fgColor != NULL) {
+ if (pmPtr->outline != NULL) {
gcMask |= GCForeground;
- gcValues.foreground = pmPtr->outline.fgColor->pixel;
+ gcValues.foreground = pmPtr->outline->pixel;
}
- if (pmPtr->outline.bgColor != NULL) {
+ if (pmPtr->outlineBg != NULL) {
gcMask |= GCBackground;
- gcValues.background = pmPtr->outline.bgColor->pixel;
+ gcValues.background = pmPtr->outlineBg->pixel;
}
gcMask |= (GCCapStyle | GCJoinStyle);
gcValues.cap_style = pmPtr->capStyle;
@@ -297,7 +305,7 @@ static int ConfigurePolygonProc(Marker *markerPtr)
gcValues.dash_offset = 0;
gcValues.line_width = LineWidth(pmPtr->lineWidth);
if (LineIsDashed(pmPtr->dashes)) {
- gcValues.line_style = (pmPtr->outline.bgColor == NULL)
+ gcValues.line_style = (pmPtr->outlineBg == NULL)
? LineOnOffDash : LineDoubleDash;
}
if (pmPtr->xor) {
@@ -324,17 +332,17 @@ static int ConfigurePolygonProc(Marker *markerPtr)
pmPtr->outlineGC = newGC;
gcMask = 0;
- if (pmPtr->fill.fgColor != NULL) {
+ if (pmPtr->fill != NULL) {
gcMask |= GCForeground;
- gcValues.foreground = pmPtr->fill.fgColor->pixel;
+ gcValues.foreground = pmPtr->fill->pixel;
}
- if (pmPtr->fill.bgColor != NULL) {
+ if (pmPtr->fillBg != NULL) {
gcMask |= GCBackground;
- gcValues.background = pmPtr->fill.bgColor->pixel;
+ gcValues.background = pmPtr->fillBg->pixel;
}
if (pmPtr->stipple != None) {
gcValues.stipple = pmPtr->stipple;
- gcValues.fill_style = (pmPtr->fill.bgColor != NULL)
+ gcValues.fill_style = (pmPtr->fillBg != NULL)
? FillOpaqueStippled : FillStippled;
gcMask |= (GCStipple | GCFillStyle);
}
@@ -429,7 +437,7 @@ static void MapPolygonProc(Marker *markerPtr)
}
Blt_GraphExtents(graphPtr, &extents);
markerPtr->clipped = TRUE;
- if (pmPtr->fill.fgColor != NULL) { /* Polygon fill required. */
+ if (pmPtr->fill != NULL) { /* Polygon fill required. */
Point2d *fillPts;
int n;
@@ -443,7 +451,7 @@ static void MapPolygonProc(Marker *markerPtr)
markerPtr->clipped = FALSE;
}
}
- if ((pmPtr->outline.fgColor != NULL) && (pmPtr->lineWidth > 0)) {
+ if ((pmPtr->outline != NULL) && (pmPtr->lineWidth > 0)) {
Segment2d *outlinePts;
Segment2d *segPtr;
Point2d *sp, *send;
diff --git a/src/bltGrMarkerPolygon.h b/src/bltGrMarkerPolygon.h
index deb156e..dbc13ff 100644
--- a/src/bltGrMarkerPolygon.h
+++ b/src/bltGrMarkerPolygon.h
@@ -77,8 +77,10 @@ typedef struct {
* possibly clipped outline and filled
* polygon. */
- ColorPair outline;
- ColorPair fill;
+ XColor* outline;
+ XColor* outlineBg;
+ XColor* fill;
+ XColor* fillBg;
Pixmap stipple; /* Stipple pattern to fill the
* polygon. */