diff options
author | joye <joye> | 2014-03-12 21:31:18 (GMT) |
---|---|---|
committer | joye <joye> | 2014-03-12 21:31:18 (GMT) |
commit | 4e985ca5db74a47f985d49ea8bc9fc07670bf419 (patch) | |
tree | 8a7227b682191ade23352fd2e07cf5407c203ba3 /src | |
parent | a0a16e9c78def9991b7cf10c4463493b4c7d12e3 (diff) | |
download | blt-4e985ca5db74a47f985d49ea8bc9fc07670bf419.zip blt-4e985ca5db74a47f985d49ea8bc9fc07670bf419.tar.gz blt-4e985ca5db74a47f985d49ea8bc9fc07670bf419.tar.bz2 |
*** empty log message ***
Diffstat (limited to 'src')
39 files changed, 854 insertions, 1184 deletions
diff --git a/src/bltChain.C b/src/bltChain.C index e5534ff..b95e520 100644 --- a/src/bltChain.C +++ b/src/bltChain.C @@ -5,10 +5,6 @@ */ /* - * bltChain.c -- - * - * The module implements a generic linked list package. - * * Copyright 1991-2004 George A Howlett. * * Permission is hereby granted, free of charge, to any person obtaining diff --git a/src/bltChain.h b/src/bltChain.h index a2b264f..0fc63a3 100644 --- a/src/bltChain.h +++ b/src/bltChain.h @@ -5,8 +5,6 @@ */ /* - * bltChain.h -- - * * Copyright 1993-2004 George A Howlett. * * Permission is hereby granted, free of charge, to any person diff --git a/src/bltConfig.C b/src/bltConfig.C index 3576174..1528135 100644 --- a/src/bltConfig.C +++ b/src/bltConfig.C @@ -5,11 +5,6 @@ */ /* - * bltConfig.c -- - * - * This file contains a Tcl_Obj based replacement for the widget - * configuration functions in Tk. - * * Copyright (c) 1990-1994 The Regents of the University of California. * Copyright (c) 1994-1997 Sun Microsystems, Inc. * diff --git a/src/bltConfig.h b/src/bltConfig.h index 6488f8b..76e087e 100644 --- a/src/bltConfig.h +++ b/src/bltConfig.h @@ -5,8 +5,6 @@ */ /* - * bltConfig.h -- - * * Copyright 1993-2004 George A Howlett. * * Permission is hereby granted, free of charge, to any person diff --git a/src/bltGrAxis.C b/src/bltGrAxis.C index 5d66948..9343890 100644 --- a/src/bltGrAxis.C +++ b/src/bltGrAxis.C @@ -5,10 +5,6 @@ */ /* - * bltGrAxis.c -- - * - * This module implements coordinate axes for the BLT graph widget. - * * Copyright 1993-2004 George A Howlett. * * Permission is hereby granted, free of charge, to any person obtaining diff --git a/src/bltGrAxis.h b/src/bltGrAxis.h index 1e33826..f231bea 100644 --- a/src/bltGrAxis.h +++ b/src/bltGrAxis.h @@ -5,8 +5,6 @@ */ /* - * bltGrAxis.h -- - * * Copyright 1993-2004 George A Howlett. * * Permission is hereby granted, free of charge, to any person diff --git a/src/bltGrBind.C b/src/bltGrBind.C index ed1e5b3..44eee4e 100644 --- a/src/bltGrBind.C +++ b/src/bltGrBind.C @@ -5,10 +5,6 @@ */ /* - * bltBind.c -- - * - * This module implements object binding procedures for the BLT toolkit. - * * Copyright 1998 George A Howlett. * * Permission is hereby granted, free of charge, to any person obtaining diff --git a/src/bltGrBind.h b/src/bltGrBind.h index 01a72a9..57197b2 100644 --- a/src/bltGrBind.h +++ b/src/bltGrBind.h @@ -5,8 +5,6 @@ */ /* - * bltBind.h -- - * * Copyright 1998-2004 George A Howlett. * * Permission is hereby granted, free of charge, to any person obtaining diff --git a/src/bltGrElemBar.C b/src/bltGrElemBar.C index 01af537..db68647 100644 --- a/src/bltGrElemBar.C +++ b/src/bltGrElemBar.C @@ -5,10 +5,6 @@ */ /* - * bltGrBar.c -- - * - * This module implements barchart elements for the BLT graph widget. - * * Copyright 1993-2004 George A Howlett. * * Permission is hereby granted, free of charge, to any person obtaining diff --git a/src/bltGrElemLine.C b/src/bltGrElemLine.C index a2505e1..a1a4e40 100644 --- a/src/bltGrElemLine.C +++ b/src/bltGrElemLine.C @@ -5,11 +5,6 @@ */ /* - * bltGrLine.c -- - * - * This module implements line graph and stripchart elements for the BLT graph - * widget. - * * Copyright (c) 1993 George A Howlett. * * Permission is hereby granted, free of charge, to any person obtaining diff --git a/src/bltGrElemOp.C b/src/bltGrElemOp.C index 979e317..871640e 100644 --- a/src/bltGrElemOp.C +++ b/src/bltGrElemOp.C @@ -5,10 +5,6 @@ */ /* - * bltGrElem.c -- - * - * This module implements generic elements for the BLT graph widget. - * * Copyright 1993-2004 George A Howlett. * * Permission is hereby granted, free of charge, to any person obtaining diff --git a/src/bltGrElemOp.h b/src/bltGrElemOp.h index 868f047..a499532 100644 --- a/src/bltGrElemOp.h +++ b/src/bltGrElemOp.h @@ -5,8 +5,6 @@ */ /* - * bltGrElem.h -- - * * Copyright 1993-2004 George A Howlett. * * Permission is hereby granted, free of charge, to any person obtaining diff --git a/src/bltGrHairs.C b/src/bltGrHairs.C index 62cec86..4e88b71 100644 --- a/src/bltGrHairs.C +++ b/src/bltGrHairs.C @@ -5,10 +5,6 @@ */ /* - * bltGrHairs.c -- - * - * This module implements crosshairs for the BLT graph widget. - * * Copyright 1993-2004 George A Howlett. * * Permission is hereby granted, free of charge, to any person diff --git a/src/bltGrLegd.C b/src/bltGrLegd.C index 6630bfd..a162f63 100644 --- a/src/bltGrLegd.C +++ b/src/bltGrLegd.C @@ -5,10 +5,6 @@ */ /* - * bltGrLegd.c -- - * - * This module implements the legend for the BLT graph widget. - * * Copyright 1993-2004 George A Howlett. * * Permission is hereby granted, free of charge, to any person obtaining diff --git a/src/bltGrLegd.h b/src/bltGrLegd.h index 0962358..a7be266 100644 --- a/src/bltGrLegd.h +++ b/src/bltGrLegd.h @@ -5,8 +5,6 @@ */ /* - * bltGrLegd.h -- - * * Copyright 1993-2004 George A Howlett. * * Permission is hereby granted, free of charge, to any person diff --git a/src/bltGrMarkerLine.C b/src/bltGrMarkerLine.C index 21736a6..d6093d2 100644 --- a/src/bltGrMarkerLine.C +++ b/src/bltGrMarkerLine.C @@ -59,7 +59,7 @@ static Tk_OptionSpec optionSpecs[] = { {TK_OPTION_CUSTOM, "-mapy", "mapY", "MapY", "y", -1, Tk_Offset(LineMarker, axes.y), 0, &yAxisObjOption, 0}, {TK_OPTION_COLOR, "-outline", "outline", "Outline", - "black", -1, Tk_Offset(LineMarker, outlineColor), + STD_NORMAL_FOREGROUND, -1, Tk_Offset(LineMarker, outlineColor), TK_OPTION_NULL_OK, NULL, 0}, {TK_OPTION_STRING_TABLE, "-state", "state", "State", "normal", -1, Tk_Offset(LineMarker, state), 0, &stateObjOption, 0}, diff --git a/src/bltGrMarkerPolygon.C b/src/bltGrMarkerPolygon.C index a5c0ca4..35bae35 100644 --- a/src/bltGrMarkerPolygon.C +++ b/src/bltGrMarkerPolygon.C @@ -45,7 +45,7 @@ static Tk_OptionSpec optionSpecs[] = { {TK_OPTION_STRING, "-element", "element", "Element", NULL, -1, Tk_Offset(PolygonMarker, elemName), TK_OPTION_NULL_OK, NULL, 0}, {TK_OPTION_COLOR, "-fill", "fill", "Fill", - "red", -1, Tk_Offset(PolygonMarker, fill), TK_OPTION_NULL_OK, NULL, 0}, + NULL, -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", @@ -59,7 +59,7 @@ static Tk_OptionSpec optionSpecs[] = { {TK_OPTION_CUSTOM, "-mapy", "mapY", "MapY", "y", -1, Tk_Offset(PolygonMarker, axes.y), 0, &yAxisObjOption, 0}, {TK_OPTION_COLOR, "-outline", "outline", "Outline", - "black", -1, Tk_Offset(PolygonMarker, outline), + STD_NORMAL_FOREGROUND, -1, Tk_Offset(PolygonMarker, outline), TK_OPTION_NULL_OK, NULL, 0}, {TK_OPTION_COLOR, "-outlinebg", "outlinebg", "OutlineBg", NULL, -1, Tk_Offset(PolygonMarker, outlineBg), diff --git a/src/bltGrMarkerText.C b/src/bltGrMarkerText.C index da047e4..5071904 100644 --- a/src/bltGrMarkerText.C +++ b/src/bltGrMarkerText.C @@ -50,7 +50,7 @@ static Tk_OptionSpec optionSpecs[] = { {TK_OPTION_FONT, "-font", "font", "Font", STD_FONT_NORMAL, -1, Tk_Offset(TextMarker, style.font), 0, NULL, 0}, {TK_OPTION_COLOR, "-foreground", "foreground", "Foreground", - "black", -1, Tk_Offset(TextMarker, style.color), + STD_NORMAL_FOREGROUND, -1, Tk_Offset(TextMarker, style.color), TK_OPTION_NULL_OK, NULL, 0}, {TK_OPTION_JUSTIFY, "-justify", "justify", "Justify", "left", -1, Tk_Offset(TextMarker, style.justify), 0, NULL, 0}, diff --git a/src/bltGrMisc.C b/src/bltGrMisc.C index b293ef7..1e6bebd 100644 --- a/src/bltGrMisc.C +++ b/src/bltGrMisc.C @@ -5,10 +5,6 @@ */ /* - * bltGrMisc.c -- - * - * This module implements miscellaneous routines for the BLT graph widget. - * * Copyright 1993-2004 George A Howlett. * * Permission is hereby granted, free of charge, to any person obtaining diff --git a/src/bltGrPSOutput.C b/src/bltGrPSOutput.C index bff4ba2..2188827 100644 --- a/src/bltGrPSOutput.C +++ b/src/bltGrPSOutput.C @@ -5,10 +5,6 @@ */ /* - * bltPs.c -- - * - * This module implements general PostScript conversion routines. - * * Copyright 1991-2004 George A Howlett. * * Permission is hereby granted, free of charge, to any person obtaining @@ -58,533 +54,397 @@ static Tcl_Interp *psInterp = NULL; -/* - *--------------------------------------------------------------------------- - * - * Blt_Ps_GetPica -- - * - * Given a string, returns the number of pica corresponding to that - * string. - * - * Results: - * The return value is a standard TCL return result. If TCL_OK is - * returned, then everything went well and the pixel distance is stored - * at *doublePtr; otherwise TCL_ERROR is returned and an error message is - * left in interp->result. - * - * Side effects: - * None. - * - *--------------------------------------------------------------------------- - */ -int -Blt_Ps_GetPicaFromObj( - Tcl_Interp* interp, /* Use this for error reporting. */ - Tcl_Obj *objPtr, /* String describing a number of - * pixels. */ - int *picaPtr) /* Place to store converted result. */ +int Blt_Ps_GetPicaFromObj(Tcl_Interp* interp, Tcl_Obj *objPtr, int *picaPtr) { - char *p; - double pica; - const char *string; + char *p; + double pica; + const char *string; - string = Tcl_GetString(objPtr); - pica = strtod((char *)string, &p); - if (p == string) { - goto error; - } - if (pica < 0.0) { - goto error; - } - while ((*p != '\0') && isspace((unsigned char)(*p))) { - p++; - } - switch (*p) { - case '\0': break; - case 'c': pica *= PICA_CM; p++; break; - case 'i': pica *= PICA_INCH; p++; break; - case 'm': pica *= PICA_MM; p++; break; - case 'p': p++; break; - default: goto error; - } - while ((*p != '\0') && isspace((unsigned char)(*p))) { - p++; - } - if (*p == '\0') { - *picaPtr = ROUND(pica); - return TCL_OK; - } + string = Tcl_GetString(objPtr); + pica = strtod((char *)string, &p); + if (p == string) { + goto error; + } + if (pica < 0.0) { + goto error; + } + while ((*p != '\0') && isspace((unsigned char)(*p))) { + p++; + } + switch (*p) { + case '\0': break; + case 'c': pica *= PICA_CM; p++; break; + case 'i': pica *= PICA_INCH; p++; break; + case 'm': pica *= PICA_MM; p++; break; + case 'p': p++; break; + default: goto error; + } + while ((*p != '\0') && isspace((unsigned char)(*p))) { + p++; + } + if (*p == '\0') { + *picaPtr = ROUND(pica); + return TCL_OK; + } error: - Tcl_AppendResult(interp, "bad screen distance \"", string, "\"", - (char *) NULL); - return TCL_ERROR; + Tcl_AppendResult(interp, "bad screen distance \"", string, "\"", + (char *) NULL); + return TCL_ERROR; } -/* - *--------------------------------------------------------------------------- - * - * Blt_Ps_ComputeBoundingBox -- - * - * Computes the bounding box for the PostScript plot. First get the size - * of the plot (by default, it's the size of graph's X window). If the - * plot plus the page border is bigger than the designated paper size, or - * if the "-maxpect" option is turned on, scale the plot to the page. - * - * Note: All coordinates/sizes are in screen coordinates, not PostScript - * coordinates. This includes the computed bounding box and paper - * size. They will be scaled to printer points later. - * - * Results: - * Returns the height of the paper in screen coordinates. - * - * Side Effects: - * The graph dimensions (width and height) are changed to the requested - * PostScript plot size. - * - *--------------------------------------------------------------------------- - */ -int -Blt_Ps_ComputeBoundingBox(PageSetup *setupPtr, int width, int height) +int Blt_Ps_ComputeBoundingBox(PageSetup *setupPtr, int width, int height) { - int paperWidth, paperHeight; - int x, y, hSize, vSize, hBorder, vBorder; - float hScale, vScale, scale; - - x = setupPtr->xPad; - y = setupPtr->yPad; - - hBorder = 2*setupPtr->xPad; - vBorder = 2*setupPtr->yPad; - - if (setupPtr->flags & PS_LANDSCAPE) { - hSize = height; - vSize = width; - } else { - hSize = width; - vSize = height; + int paperWidth, paperHeight; + int x, y, hSize, vSize, hBorder, vBorder; + float hScale, vScale, scale; + + x = setupPtr->xPad; + y = setupPtr->yPad; + + hBorder = 2*setupPtr->xPad; + vBorder = 2*setupPtr->yPad; + + if (setupPtr->flags & PS_LANDSCAPE) { + hSize = height; + vSize = width; + } else { + hSize = width; + vSize = height; + } + /* + * If the paper size wasn't specified, set it to the graph size plus the + * paper border. + */ + paperWidth = (setupPtr->reqPaperWidth > 0) ? setupPtr->reqPaperWidth : + hSize + hBorder; + paperHeight = (setupPtr->reqPaperHeight > 0) ? setupPtr->reqPaperHeight : + vSize + vBorder; + + /* + * Scale the plot size (the graph itself doesn't change size) if it's + * bigger than the paper or if -maxpect was set. + */ + hScale = vScale = 1.0f; + if ((setupPtr->flags & PS_MAXPECT) || ((hSize + hBorder) > paperWidth)) { + hScale = (float)(paperWidth - hBorder) / (float)hSize; + } + if ((setupPtr->flags & PS_MAXPECT) || ((vSize + vBorder) > paperHeight)) { + vScale = (float)(paperHeight - vBorder) / (float)vSize; + } + scale = MIN(hScale, vScale); + if (scale != 1.0f) { + hSize = (int)((hSize * scale) + 0.5f); + vSize = (int)((vSize * scale) + 0.5f); + } + setupPtr->scale = scale; + if (setupPtr->flags & PS_CENTER) { + if (paperWidth > hSize) { + x = (paperWidth - hSize) / 2; } - /* - * If the paper size wasn't specified, set it to the graph size plus the - * paper border. - */ - paperWidth = (setupPtr->reqPaperWidth > 0) ? setupPtr->reqPaperWidth : - hSize + hBorder; - paperHeight = (setupPtr->reqPaperHeight > 0) ? setupPtr->reqPaperHeight : - vSize + vBorder; - - /* - * Scale the plot size (the graph itself doesn't change size) if it's - * bigger than the paper or if -maxpect was set. - */ - hScale = vScale = 1.0f; - if ((setupPtr->flags & PS_MAXPECT) || ((hSize + hBorder) > paperWidth)) { - hScale = (float)(paperWidth - hBorder) / (float)hSize; - } - if ((setupPtr->flags & PS_MAXPECT) || ((vSize + vBorder) > paperHeight)) { - vScale = (float)(paperHeight - vBorder) / (float)vSize; - } - scale = MIN(hScale, vScale); - if (scale != 1.0f) { - hSize = (int)((hSize * scale) + 0.5f); - vSize = (int)((vSize * scale) + 0.5f); - } - setupPtr->scale = scale; - if (setupPtr->flags & PS_CENTER) { - if (paperWidth > hSize) { - x = (paperWidth - hSize) / 2; - } - if (paperHeight > vSize) { - y = (paperHeight - vSize) / 2; - } + if (paperHeight > vSize) { + y = (paperHeight - vSize) / 2; } - setupPtr->left = x; - setupPtr->bottom = y; - setupPtr->right = x + hSize - 1; - setupPtr->top = y + vSize - 1; - setupPtr->paperHeight = paperHeight; - setupPtr->paperWidth = paperWidth; - return paperHeight; + } + setupPtr->left = x; + setupPtr->bottom = y; + setupPtr->right = x + hSize - 1; + setupPtr->top = y + vSize - 1; + setupPtr->paperHeight = paperHeight; + setupPtr->paperWidth = paperWidth; + return paperHeight; } -PostScript * -Blt_Ps_Create(Tcl_Interp* interp, PageSetup *setupPtr) +PostScript *Blt_Ps_Create(Tcl_Interp* interp, PageSetup *setupPtr) { - PostScript *psPtr; + PostScript *psPtr; - psPtr = malloc(sizeof(PostScript)); - psPtr->setupPtr = setupPtr; - psPtr->interp = interp; - Tcl_DStringInit(&psPtr->dString); - return psPtr; + psPtr = malloc(sizeof(PostScript)); + psPtr->setupPtr = setupPtr; + psPtr->interp = interp; + Tcl_DStringInit(&psPtr->dString); + return psPtr; } -void -Blt_Ps_SetPrinting(PostScript *psPtr, int state) +void Blt_Ps_SetPrinting(PostScript *psPtr, int state) { - psInterp = ((state) && (psPtr != NULL)) ? psPtr->interp : NULL; + psInterp = ((state) && (psPtr != NULL)) ? psPtr->interp : NULL; } -int -Blt_Ps_IsPrinting(void) +int Blt_Ps_IsPrinting(void) { - return (psInterp != NULL); + return (psInterp != NULL); } -void -Blt_Ps_Free(PostScript *psPtr) +void Blt_Ps_Free(PostScript *psPtr) { - Tcl_DStringFree(&psPtr->dString); - free(psPtr); + Tcl_DStringFree(&psPtr->dString); + free(psPtr); } -const char * -Blt_Ps_GetValue(PostScript *psPtr, int *lengthPtr) +const char *Blt_Ps_GetValue(PostScript *psPtr, int *lengthPtr) { - *lengthPtr = strlen(Tcl_DStringValue(&psPtr->dString)); - return Tcl_DStringValue(&psPtr->dString); + *lengthPtr = strlen(Tcl_DStringValue(&psPtr->dString)); + return Tcl_DStringValue(&psPtr->dString); } -void -Blt_Ps_SetInterp(PostScript *psPtr, Tcl_Interp* interp) +void Blt_Ps_SetInterp(PostScript *psPtr, Tcl_Interp* interp) { - Tcl_DStringResult(interp, &psPtr->dString); + Tcl_DStringResult(interp, &psPtr->dString); } -char * -Blt_Ps_GetScratchBuffer(PostScript *psPtr) +char *Blt_Ps_GetScratchBuffer(PostScript *psPtr) { - return psPtr->scratchArr; + return psPtr->scratchArr; } -Tcl_Interp * -Blt_Ps_GetInterp(PostScript *psPtr) +Tcl_Interp *Blt_Ps_GetInterp(PostScript *psPtr) { - return psPtr->interp; + return psPtr->interp; } -Tcl_DString * -Blt_Ps_GetDString(PostScript *psPtr) +Tcl_DString *Blt_Ps_GetDString(PostScript *psPtr) { - return &psPtr->dString; + return &psPtr->dString; } -int -Blt_Ps_SaveFile(Tcl_Interp* interp, PostScript *psPtr, const char *fileName) +int Blt_Ps_SaveFile(Tcl_Interp* interp, PostScript *psPtr, const char *fileName) { - Tcl_Channel channel; - int nWritten, nBytes; - char *bytes; + Tcl_Channel channel; + int nWritten, nBytes; + char *bytes; - channel = Tcl_OpenFileChannel(interp, fileName, "w", 0660); - if (channel == NULL) { - return TCL_ERROR; - } - nBytes = Tcl_DStringLength(&psPtr->dString); - bytes = Tcl_DStringValue(&psPtr->dString); - nWritten = Tcl_Write(channel, bytes, nBytes); - Tcl_Close(interp, channel); - if (nWritten != nBytes) { - Tcl_AppendResult(interp, "short file \"", fileName, (char *)NULL); - Tcl_AppendResult(interp, "\" : wrote ", Blt_Itoa(nWritten), " of ", - (char *)NULL); - Tcl_AppendResult(interp, Blt_Itoa(nBytes), " bytes.", (char *)NULL); - return TCL_ERROR; - } - return TCL_OK; + channel = Tcl_OpenFileChannel(interp, fileName, "w", 0660); + if (channel == NULL) { + return TCL_ERROR; + } + nBytes = Tcl_DStringLength(&psPtr->dString); + bytes = Tcl_DStringValue(&psPtr->dString); + nWritten = Tcl_Write(channel, bytes, nBytes); + Tcl_Close(interp, channel); + if (nWritten != nBytes) { + Tcl_AppendResult(interp, "short file \"", fileName, (char *)NULL); + Tcl_AppendResult(interp, "\" : wrote ", Blt_Itoa(nWritten), " of ", + (char *)NULL); + Tcl_AppendResult(interp, Blt_Itoa(nBytes), " bytes.", (char *)NULL); + return TCL_ERROR; + } + return TCL_OK; } -void -Blt_Ps_VarAppend -TCL_VARARGS_DEF(PostScript *, arg1) +void Blt_Ps_VarAppend TCL_VARARGS_DEF(PostScript *, arg1) { - va_list argList; - PostScript *psPtr; - const char *string; - - psPtr = TCL_VARARGS_START(PostScript, arg1, argList); - for (;;) { - string = va_arg(argList, char *); - if (string == NULL) { - break; - } - Tcl_DStringAppend(&psPtr->dString, string, -1); + va_list argList; + PostScript *psPtr; + const char *string; + + psPtr = TCL_VARARGS_START(PostScript, arg1, argList); + for (;;) { + string = va_arg(argList, char *); + if (string == NULL) { + break; } + Tcl_DStringAppend(&psPtr->dString, string, -1); + } } -void -Blt_Ps_AppendBytes(PostScript *psPtr, const char *bytes, int length) +void Blt_Ps_AppendBytes(PostScript *psPtr, const char *bytes, int length) { - Tcl_DStringAppend(&psPtr->dString, bytes, length); + Tcl_DStringAppend(&psPtr->dString, bytes, length); } -void -Blt_Ps_Append(PostScript *psPtr, const char *string) +void Blt_Ps_Append(PostScript *psPtr, const char *string) { - Tcl_DStringAppend(&psPtr->dString, string, -1); + Tcl_DStringAppend(&psPtr->dString, string, -1); } -void -Blt_Ps_Format -TCL_VARARGS_DEF(PostScript *, arg1) +void Blt_Ps_Format TCL_VARARGS_DEF(PostScript *, arg1) { - va_list argList; - PostScript *psPtr; - char *fmt; - - psPtr = TCL_VARARGS_START(PostScript, arg1, argList); - fmt = va_arg(argList, char *); - vsnprintf(psPtr->scratchArr, POSTSCRIPT_BUFSIZ, fmt, argList); - va_end(argList); - Tcl_DStringAppend(&psPtr->dString, psPtr->scratchArr, -1); + va_list argList; + PostScript *psPtr; + char *fmt; + + psPtr = TCL_VARARGS_START(PostScript, arg1, argList); + fmt = va_arg(argList, char *); + vsnprintf(psPtr->scratchArr, POSTSCRIPT_BUFSIZ, fmt, argList); + va_end(argList); + Tcl_DStringAppend(&psPtr->dString, psPtr->scratchArr, -1); } -int -Blt_Ps_IncludeFile(Tcl_Interp* interp, Blt_Ps ps, const char *fileName) +int Blt_Ps_IncludeFile(Tcl_Interp* interp, Blt_Ps ps, const char *fileName) { - Tcl_Channel channel; - Tcl_DString dString; - char *buf; - char *libDir; - int nBytes; - - buf = Blt_Ps_GetScratchBuffer(ps); - - /* - * Read in a standard prolog file from file and append it to the - * PostScript output stored in the Tcl_DString in psPtr. - */ - - libDir = (char *)Tcl_GetVar(interp, "tkblt_library", TCL_GLOBAL_ONLY); - if (libDir == NULL) { - Tcl_AppendResult(interp, "couldn't find TKBLT script library:", - "global variable \"tkblt_library\" doesn't exist", (char *)NULL); - return TCL_ERROR; + Tcl_Channel channel; + Tcl_DString dString; + char *buf; + char *libDir; + int nBytes; + + buf = Blt_Ps_GetScratchBuffer(ps); + + /* + * Read in a standard prolog file from file and append it to the + * PostScript output stored in the Tcl_DString in psPtr. + */ + + libDir = (char *)Tcl_GetVar(interp, "tkblt_library", TCL_GLOBAL_ONLY); + if (libDir == NULL) { + Tcl_AppendResult(interp, "couldn't find TKBLT script library:", + "global variable \"tkblt_library\" doesn't exist", (char *)NULL); + return TCL_ERROR; + } + Tcl_DStringInit(&dString); + Tcl_DStringAppend(&dString, libDir, -1); + Tcl_DStringAppend(&dString, "/", -1); + Tcl_DStringAppend(&dString, fileName, -1); + fileName = Tcl_DStringValue(&dString); + Blt_Ps_VarAppend(ps, "\n% including file \"", fileName, "\"\n\n", + (char *)NULL); + channel = Tcl_OpenFileChannel(interp, fileName, "r", 0); + if (channel == NULL) { + Tcl_AppendResult(interp, "couldn't open prologue file \"", fileName, + "\": ", Tcl_PosixError(interp), (char *)NULL); + return TCL_ERROR; + } + for(;;) { + nBytes = Tcl_Read(channel, buf, POSTSCRIPT_BUFSIZ); + if (nBytes < 0) { + Tcl_AppendResult(interp, "error reading prologue file \"", + fileName, "\": ", Tcl_PosixError(interp), + (char *)NULL); + Tcl_Close(interp, channel); + Tcl_DStringFree(&dString); + return TCL_ERROR; } - Tcl_DStringInit(&dString); - Tcl_DStringAppend(&dString, libDir, -1); - Tcl_DStringAppend(&dString, "/", -1); - Tcl_DStringAppend(&dString, fileName, -1); - fileName = Tcl_DStringValue(&dString); - Blt_Ps_VarAppend(ps, "\n% including file \"", fileName, "\"\n\n", - (char *)NULL); - channel = Tcl_OpenFileChannel(interp, fileName, "r", 0); - if (channel == NULL) { - Tcl_AppendResult(interp, "couldn't open prologue file \"", fileName, - "\": ", Tcl_PosixError(interp), (char *)NULL); - return TCL_ERROR; + if (nBytes == 0) { + break; } - for(;;) { - nBytes = Tcl_Read(channel, buf, POSTSCRIPT_BUFSIZ); - if (nBytes < 0) { - Tcl_AppendResult(interp, "error reading prologue file \"", - fileName, "\": ", Tcl_PosixError(interp), - (char *)NULL); - Tcl_Close(interp, channel); - Tcl_DStringFree(&dString); - return TCL_ERROR; - } - if (nBytes == 0) { - break; - } - buf[nBytes] = '\0'; - Blt_Ps_Append(ps, buf); - } - Tcl_DStringFree(&dString); - Tcl_Close(interp, channel); - return TCL_OK; + buf[nBytes] = '\0'; + Blt_Ps_Append(ps, buf); + } + Tcl_DStringFree(&dString); + Tcl_Close(interp, channel); + return TCL_OK; } -/* - *--------------------------------------------------------------------------- - * - * XColorToPostScript -- - * - * Convert the a XColor (from its RGB values) to a PostScript command. - * If a Tk color map variable exists, it will be consulted for a - * PostScript translation based upon the color name. - * - * Maps an X color intensity (0 to 2^16-1) to a floating point value - * [0..1]. Many versions of Tk don't properly handle the the lower 8 - * bits of the color intensity, so we can only consider the upper 8 bits. - * - * Results: - * The string representing the color mode is returned. - * - *--------------------------------------------------------------------------- - */ -static void -XColorToPostScript(Blt_Ps ps, XColor* colorPtr) +static void XColorToPostScript(Blt_Ps ps, XColor* colorPtr) { - /* - * Shift off the lower byte before dividing because some versions of Tk - * don't fill the lower byte correctly. - */ - Blt_Ps_Format(ps, "%g %g %g", - ((double)(colorPtr->red >> 8) / 255.0), - ((double)(colorPtr->green >> 8) / 255.0), - ((double)(colorPtr->blue >> 8) / 255.0)); + Blt_Ps_Format(ps, "%g %g %g", + ((double)(colorPtr->red >> 8) / 255.0), + ((double)(colorPtr->green >> 8) / 255.0), + ((double)(colorPtr->blue >> 8) / 255.0)); } -void -Blt_Ps_XSetBackground(PostScript *psPtr, XColor* colorPtr) +void Blt_Ps_XSetBackground(PostScript *psPtr, XColor* colorPtr) { - /* If the color name exists in TCL array variable, use that translation */ - if ((psPtr->setupPtr != NULL) && (psPtr->setupPtr->colorVarName != NULL)) { - const char *psColor; - - psColor = Tcl_GetVar2(psPtr->interp, psPtr->setupPtr->colorVarName, - Tk_NameOfColor(colorPtr), 0); - if (psColor != NULL) { - Blt_Ps_VarAppend(psPtr, " ", psColor, "\n", (char *)NULL); - return; - } - } - XColorToPostScript(psPtr, colorPtr); - Blt_Ps_Append(psPtr, " setrgbcolor\n"); - if (psPtr->setupPtr->flags & PS_GREYSCALE) { - Blt_Ps_Append(psPtr, " currentgray setgray\n"); + /* If the color name exists in TCL array variable, use that translation */ + if ((psPtr->setupPtr != NULL) && (psPtr->setupPtr->colorVarName != NULL)) { + const char *psColor; + + psColor = Tcl_GetVar2(psPtr->interp, psPtr->setupPtr->colorVarName, + Tk_NameOfColor(colorPtr), 0); + if (psColor != NULL) { + Blt_Ps_VarAppend(psPtr, " ", psColor, "\n", (char *)NULL); + return; } + } + XColorToPostScript(psPtr, colorPtr); + Blt_Ps_Append(psPtr, " setrgbcolor\n"); + if (psPtr->setupPtr->flags & PS_GREYSCALE) { + Blt_Ps_Append(psPtr, " currentgray setgray\n"); + } } -void -Blt_Ps_XSetForeground(PostScript *psPtr, XColor* colorPtr) +void Blt_Ps_XSetForeground(PostScript *psPtr, XColor* colorPtr) { - /* If the color name exists in TCL array variable, use that translation */ - if ((psPtr->setupPtr != NULL) && (psPtr->setupPtr->colorVarName != NULL)) { - const char *psColor; - - psColor = Tcl_GetVar2(psPtr->interp, psPtr->setupPtr->colorVarName, - Tk_NameOfColor(colorPtr), 0); - if (psColor != NULL) { - Blt_Ps_VarAppend(psPtr, " ", psColor, "\n", (char *)NULL); - return; - } - } - XColorToPostScript(psPtr, colorPtr); - Blt_Ps_Append(psPtr, " setrgbcolor\n"); - if (psPtr->setupPtr->flags & PS_GREYSCALE) { - Blt_Ps_Append(psPtr, " currentgray setgray\n"); + /* If the color name exists in TCL array variable, use that translation */ + if ((psPtr->setupPtr != NULL) && (psPtr->setupPtr->colorVarName != NULL)) { + const char *psColor; + + psColor = Tcl_GetVar2(psPtr->interp, psPtr->setupPtr->colorVarName, + Tk_NameOfColor(colorPtr), 0); + if (psColor != NULL) { + Blt_Ps_VarAppend(psPtr, " ", psColor, "\n", (char *)NULL); + return; } + } + XColorToPostScript(psPtr, colorPtr); + Blt_Ps_Append(psPtr, " setrgbcolor\n"); + if (psPtr->setupPtr->flags & PS_GREYSCALE) { + Blt_Ps_Append(psPtr, " currentgray setgray\n"); + } } -/* - *--------------------------------------------------------------------------- - * - * ReverseBits -- - * - * Convert a byte from a X image into PostScript image order. This - * requires not only the nybbles to be reversed but also their bit - * values. - * - * Results: - * The converted byte is returned. - * - *--------------------------------------------------------------------------- - */ -INLINE static unsigned char -ReverseBits(unsigned char byte) +static unsigned char ReverseBits(unsigned char byte) { - byte = ((byte >> 1) & 0x55) | ((byte << 1) & 0xaa); - byte = ((byte >> 2) & 0x33) | ((byte << 2) & 0xcc); - byte = ((byte >> 4) & 0x0f) | ((byte << 4) & 0xf0); - return byte; + byte = ((byte >> 1) & 0x55) | ((byte << 1) & 0xaa); + byte = ((byte >> 2) & 0x33) | ((byte << 2) & 0xcc); + byte = ((byte >> 4) & 0x0f) | ((byte << 4) & 0xf0); + return byte; } -/* - *--------------------------------------------------------------------------- - * - * ByteToHex -- - * - * Convert a byte to its ASCII hexidecimal equivalent. - * - * Results: - * The converted 2 ASCII character string is returned. - * - *--------------------------------------------------------------------------- - */ -INLINE static void -ByteToHex(unsigned char byte, char *string) +static void ByteToHex(unsigned char byte, char *string) { - static char hexDigits[] = "0123456789ABCDEF"; + static char hexDigits[] = "0123456789ABCDEF"; - string[0] = hexDigits[byte >> 4]; - string[1] = hexDigits[byte & 0x0F]; + string[0] = hexDigits[byte >> 4]; + string[1] = hexDigits[byte & 0x0F]; } -/* - *--------------------------------------------------------------------------- - * - * Blt_Ps_XSetBitmapData -- - * - * Output a PostScript image string of the given bitmap image. It is - * assumed the image is one bit deep and a zero value indicates an - * off-pixel. To convert to PostScript, the bits need to be reversed - * from the X11 image order. - * - * Results: - * None. - * - * Side Effects: - * The PostScript image string is appended to interp->result. - * - *--------------------------------------------------------------------------- - */ -void -Blt_Ps_XSetBitmapData(Blt_Ps ps, Display *display, Pixmap bitmap, int w, int h) +void Blt_Ps_XSetBitmapData(Blt_Ps ps, Display *display, Pixmap bitmap, + int w, int h) { - XImage *imagePtr; - int byteCount; - int y, bitPos; - - imagePtr = XGetImage(display, bitmap, 0, 0, w, h, 1, ZPixmap); - Blt_Ps_Append(ps, "\t<"); - byteCount = bitPos = 0; /* Suppress compiler warning */ - for (y = 0; y < h; y++) { - unsigned char byte; - char string[10]; - int x; - + XImage *imagePtr; + int byteCount; + int y, bitPos; + + imagePtr = XGetImage(display, bitmap, 0, 0, w, h, 1, ZPixmap); + Blt_Ps_Append(ps, "\t<"); + byteCount = bitPos = 0; /* Suppress compiler warning */ + for (y = 0; y < h; y++) { + unsigned char byte; + char string[10]; + int x; + + byte = 0; + for (x = 0; x < w; x++) { + unsigned long pixel; + + pixel = XGetPixel(imagePtr, x, y); + bitPos = x % 8; + byte |= (unsigned char)(pixel << bitPos); + if (bitPos == 7) { + byte = ReverseBits(byte); + ByteToHex(byte, string); + string[2] = '\0'; + byteCount++; byte = 0; - for (x = 0; x < w; x++) { - unsigned long pixel; - - pixel = XGetPixel(imagePtr, x, y); - bitPos = x % 8; - byte |= (unsigned char)(pixel << bitPos); - if (bitPos == 7) { - byte = ReverseBits(byte); - ByteToHex(byte, string); - string[2] = '\0'; - byteCount++; - byte = 0; - if (byteCount >= 30) { - string[2] = '\n'; - string[3] = '\t'; - string[4] = '\0'; - byteCount = 0; - } - Blt_Ps_Append(ps, string); - } - } /* x */ - if (bitPos != 7) { - byte = ReverseBits(byte); - ByteToHex(byte, string); - string[2] = '\0'; - Blt_Ps_Append(ps, string); - byteCount++; + if (byteCount >= 30) { + string[2] = '\n'; + string[3] = '\t'; + string[4] = '\0'; + byteCount = 0; } - } /* y */ - Blt_Ps_Append(ps, ">\n"); - XDestroyImage(imagePtr); + Blt_Ps_Append(ps, string); + } + } /* x */ + if (bitPos != 7) { + byte = ReverseBits(byte); + ByteToHex(byte, string); + string[2] = '\0'; + Blt_Ps_Append(ps, string); + byteCount++; + } + } /* y */ + Blt_Ps_Append(ps, ">\n"); + XDestroyImage(imagePtr); } typedef struct { - const char *alias; - const char *fontName; + const char *alias; + const char *fontName; } FamilyMap; static FamilyMap familyMap[] = -{ + { { "Arial", "Helvetica" }, { "AvantGarde", "AvantGarde" }, { "Bookman", "Bookman" }, @@ -608,704 +468,623 @@ static FamilyMap familyMap[] = { "Times", "Times" }, { "ZapfChancery", "ZapfChancery" }, { "ZapfDingbats", "ZapfDingbats" } -}; + }; static int nFamilyNames = (sizeof(familyMap) / sizeof(FamilyMap)); -static const char * -FamilyToPsFamily(const char *family) +static const char *FamilyToPsFamily(const char *family) { - FamilyMap *fp, *fend; - - if (strncasecmp(family, "itc ", 4) == 0) { - family += 4; - } - for (fp = familyMap, fend = fp + nFamilyNames; fp < fend; fp++) { - if (strcasecmp(fp->alias, family) == 0) { - return fp->fontName; - } + FamilyMap *fp, *fend; + + if (strncasecmp(family, "itc ", 4) == 0) { + family += 4; + } + for (fp = familyMap, fend = fp + nFamilyNames; fp < fend; fp++) { + if (strcasecmp(fp->alias, family) == 0) { + return fp->fontName; } - return NULL; + } + return NULL; } -/* - *--------------------------------------------------------------------------- - * Routines to convert X drawing functions to PostScript commands. - *--------------------------------------------------------------------------- - */ -void -Blt_Ps_SetClearBackground(Blt_Ps ps) +void Blt_Ps_SetClearBackground(Blt_Ps ps) { - Blt_Ps_Append(ps, "1 1 1 setrgbcolor\n"); + Blt_Ps_Append(ps, "1 1 1 setrgbcolor\n"); } -void -Blt_Ps_XSetCapStyle(Blt_Ps ps, int capStyle) +void Blt_Ps_XSetCapStyle(Blt_Ps ps, int capStyle) { - /* - * X11:not last = 0, butt = 1, round = 2, projecting = 3 - * PS: butt = 0, round = 1, projecting = 2 - */ - if (capStyle > 0) { - capStyle--; - } - Blt_Ps_Format(ps, "%d setlinecap\n", capStyle); + /* + * X11:not last = 0, butt = 1, round = 2, projecting = 3 + * PS: butt = 0, round = 1, projecting = 2 + */ + if (capStyle > 0) { + capStyle--; + } + Blt_Ps_Format(ps, "%d setlinecap\n", capStyle); } -void -Blt_Ps_XSetJoinStyle(Blt_Ps ps, int joinStyle) +void Blt_Ps_XSetJoinStyle(Blt_Ps ps, int joinStyle) { - /* - * miter = 0, round = 1, bevel = 2 - */ - Blt_Ps_Format(ps, "%d setlinejoin\n", joinStyle); + /* + * miter = 0, round = 1, bevel = 2 + */ + Blt_Ps_Format(ps, "%d setlinejoin\n", joinStyle); } -void -Blt_Ps_XSetLineWidth(Blt_Ps ps, int lineWidth) +void Blt_Ps_XSetLineWidth(Blt_Ps ps, int lineWidth) { - if (lineWidth < 1) { - lineWidth = 1; - } - Blt_Ps_Format(ps, "%d setlinewidth\n", lineWidth); + if (lineWidth < 1) { + lineWidth = 1; + } + Blt_Ps_Format(ps, "%d setlinewidth\n", lineWidth); } -void -Blt_Ps_XSetDashes(Blt_Ps ps, Blt_Dashes *dashesPtr) +void Blt_Ps_XSetDashes(Blt_Ps ps, Blt_Dashes *dashesPtr) { - Blt_Ps_Append(ps, "[ "); - if (dashesPtr != NULL) { - unsigned char *vp; + Blt_Ps_Append(ps, "[ "); + if (dashesPtr != NULL) { + unsigned char *vp; - for (vp = dashesPtr->values; *vp != 0; vp++) { - Blt_Ps_Format(ps, " %d", *vp); - } + for (vp = dashesPtr->values; *vp != 0; vp++) { + Blt_Ps_Format(ps, " %d", *vp); } - Blt_Ps_Append(ps, "] 0 setdash\n"); + } + Blt_Ps_Append(ps, "] 0 setdash\n"); } -void -Blt_Ps_XSetLineAttributes( - Blt_Ps ps, - XColor* colorPtr, - int lineWidth, - Blt_Dashes *dashesPtr, - int capStyle, - int joinStyle) +void Blt_Ps_XSetLineAttributes( + Blt_Ps ps, + XColor* colorPtr, + int lineWidth, + Blt_Dashes *dashesPtr, + int capStyle, + int joinStyle) { - Blt_Ps_XSetJoinStyle(ps, joinStyle); - Blt_Ps_XSetCapStyle(ps, capStyle); - Blt_Ps_XSetForeground(ps, colorPtr); - Blt_Ps_XSetLineWidth(ps, lineWidth); - Blt_Ps_XSetDashes(ps, dashesPtr); - Blt_Ps_Append(ps, "/DashesProc {} def\n"); + Blt_Ps_XSetJoinStyle(ps, joinStyle); + Blt_Ps_XSetCapStyle(ps, capStyle); + Blt_Ps_XSetForeground(ps, colorPtr); + Blt_Ps_XSetLineWidth(ps, lineWidth); + Blt_Ps_XSetDashes(ps, dashesPtr); + Blt_Ps_Append(ps, "/DashesProc {} def\n"); } -void -Blt_Ps_Rectangle(Blt_Ps ps, int x, int y, int width, int height) +void Blt_Ps_Rectangle(Blt_Ps ps, int x, int y, int width, int height) { - Blt_Ps_Append(ps, "newpath\n"); - Blt_Ps_Format(ps, " %d %d moveto\n", x, y); - Blt_Ps_Format(ps, " %d %d rlineto\n", width, 0); - Blt_Ps_Format(ps, " %d %d rlineto\n", 0, height); - Blt_Ps_Format(ps, " %d %d rlineto\n", -width, 0); - Blt_Ps_Append(ps, "closepath\n"); + Blt_Ps_Append(ps, "newpath\n"); + Blt_Ps_Format(ps, " %d %d moveto\n", x, y); + Blt_Ps_Format(ps, " %d %d rlineto\n", width, 0); + Blt_Ps_Format(ps, " %d %d rlineto\n", 0, height); + Blt_Ps_Format(ps, " %d %d rlineto\n", -width, 0); + Blt_Ps_Append(ps, "closepath\n"); } -void -Blt_Ps_XFillRectangle(Blt_Ps ps, double x, double y, int width, int height) +void Blt_Ps_XFillRectangle(Blt_Ps ps, double x, double y, int width, int height) { - Blt_Ps_Rectangle(ps, (int)x, (int)y, width, height); - Blt_Ps_Append(ps, "fill\n"); + Blt_Ps_Rectangle(ps, (int)x, (int)y, width, height); + Blt_Ps_Append(ps, "fill\n"); } -void -Blt_Ps_PolylineFromXPoints(Blt_Ps ps, XPoint *points, int n) +void Blt_Ps_PolylineFromXPoints(Blt_Ps ps, XPoint *points, int n) { - XPoint *pp, *pend; - - pp = points; - Blt_Ps_Append(ps, "newpath\n"); - Blt_Ps_Format(ps, " %d %d moveto\n", pp->x, pp->y); - pp++; - for (pend = points + n; pp < pend; pp++) { - Blt_Ps_Format(ps, " %d %d lineto\n", pp->x, pp->y); - } + XPoint *pp, *pend; + + pp = points; + Blt_Ps_Append(ps, "newpath\n"); + Blt_Ps_Format(ps, " %d %d moveto\n", pp->x, pp->y); + pp++; + for (pend = points + n; pp < pend; pp++) { + Blt_Ps_Format(ps, " %d %d lineto\n", pp->x, pp->y); + } } -void -Blt_Ps_Polyline(Blt_Ps ps, Point2d *screenPts, int nScreenPts) +void Blt_Ps_Polyline(Blt_Ps ps, Point2d *screenPts, int nScreenPts) { - Point2d *pp, *pend; - - pp = screenPts; - Blt_Ps_Append(ps, "newpath\n"); - Blt_Ps_Format(ps, " %g %g moveto\n", pp->x, pp->y); - for (pp++, pend = screenPts + nScreenPts; pp < pend; pp++) { - Blt_Ps_Format(ps, " %g %g lineto\n", pp->x, pp->y); - } + Point2d *pp, *pend; + + pp = screenPts; + Blt_Ps_Append(ps, "newpath\n"); + Blt_Ps_Format(ps, " %g %g moveto\n", pp->x, pp->y); + for (pp++, pend = screenPts + nScreenPts; pp < pend; pp++) { + Blt_Ps_Format(ps, " %g %g lineto\n", pp->x, pp->y); + } } -void -Blt_Ps_Polygon(Blt_Ps ps, Point2d *screenPts, int nScreenPts) +void Blt_Ps_Polygon(Blt_Ps ps, Point2d *screenPts, int nScreenPts) { - Point2d *pp, *pend; - - pp = screenPts; - Blt_Ps_Append(ps, "newpath\n"); - Blt_Ps_Format(ps, " %g %g moveto\n", pp->x, pp->y); - for (pp++, pend = screenPts + nScreenPts; pp < pend; pp++) { - Blt_Ps_Format(ps, " %g %g lineto\n", pp->x, pp->y); - } - Blt_Ps_Format(ps, " %g %g lineto\n", screenPts[0].x, screenPts[0].y); - Blt_Ps_Append(ps, "closepath\n"); + Point2d *pp, *pend; + + pp = screenPts; + Blt_Ps_Append(ps, "newpath\n"); + Blt_Ps_Format(ps, " %g %g moveto\n", pp->x, pp->y); + for (pp++, pend = screenPts + nScreenPts; pp < pend; pp++) { + Blt_Ps_Format(ps, " %g %g lineto\n", pp->x, pp->y); + } + Blt_Ps_Format(ps, " %g %g lineto\n", screenPts[0].x, screenPts[0].y); + Blt_Ps_Append(ps, "closepath\n"); } -void -Blt_Ps_XFillPolygon(Blt_Ps ps, Point2d *screenPts, int nScreenPts) +void Blt_Ps_XFillPolygon(Blt_Ps ps, Point2d *screenPts, int nScreenPts) { - Blt_Ps_Polygon(ps, screenPts, nScreenPts); - Blt_Ps_Append(ps, "fill\n"); + Blt_Ps_Polygon(ps, screenPts, nScreenPts); + Blt_Ps_Append(ps, "fill\n"); } -void -Blt_Ps_XDrawSegments(Blt_Ps ps, XSegment *segments, int nSegments) +void Blt_Ps_XDrawSegments(Blt_Ps ps, XSegment *segments, int nSegments) { - XSegment *sp, *send; + XSegment *sp, *send; - for (sp = segments, send = sp + nSegments; sp < send; sp++) { - Blt_Ps_Format(ps, "%d %d moveto %d %d lineto\n", sp->x1, sp->y1, - sp->x2, sp->y2); - Blt_Ps_Append(ps, "DashesProc stroke\n"); - } + for (sp = segments, send = sp + nSegments; sp < send; sp++) { + Blt_Ps_Format(ps, "%d %d moveto %d %d lineto\n", sp->x1, sp->y1, + sp->x2, sp->y2); + Blt_Ps_Append(ps, "DashesProc stroke\n"); + } } - -void -Blt_Ps_XFillRectangles(Blt_Ps ps, XRectangle *rectangles, int nRectangles) +void Blt_Ps_XFillRectangles(Blt_Ps ps, XRectangle *rectangles, int nRectangles) { - XRectangle *rp, *rend; + XRectangle *rp, *rend; - for (rp = rectangles, rend = rp + nRectangles; rp < rend; rp++) { - Blt_Ps_XFillRectangle(ps, (double)rp->x, (double)rp->y, - (int)rp->width, (int)rp->height); - } + for (rp = rectangles, rend = rp + nRectangles; rp < rend; rp++) { + Blt_Ps_XFillRectangle(ps, (double)rp->x, (double)rp->y, + (int)rp->width, (int)rp->height); + } } #ifndef TK_RELIEF_SOLID #define TK_RELIEF_SOLID -1 /* Set the an impossible value. */ #endif /* TK_RELIEF_SOLID */ -void -Blt_Ps_Draw3DRectangle( - Blt_Ps ps, - Tk_3DBorder border, /* Token for border to draw. */ - double x, double y, /* Coordinates of rectangle */ - int width, int height, /* Region to be drawn. */ - int borderWidth, /* Desired width for border, in pixels. */ - int relief) /* Should be either TK_RELIEF_RAISED or - * TK_RELIEF_SUNKEN; indicates position of - * interior of window relative to exterior. */ +void Blt_Ps_Draw3DRectangle( + Blt_Ps ps, + Tk_3DBorder border, /* Token for border to draw. */ + double x, double y, /* Coordinates of rectangle */ + int width, int height, /* Region to be drawn. */ + int borderWidth, /* Desired width for border, in pixels. */ + int relief) /* Should be either TK_RELIEF_RAISED or + * TK_RELIEF_SUNKEN; indicates position of + * interior of window relative to exterior. */ { - Point2d points[7]; - TkBorder *borderPtr = (TkBorder *) border; - XColor* lightPtr, *darkPtr; - XColor* topPtr, *bottomPtr; - XColor light, dark; - int twiceWidth = (borderWidth * 2); - - if ((width < twiceWidth) || (height < twiceWidth)) { - return; - } - if ((relief == TK_RELIEF_SOLID) || - (borderPtr->lightColorPtr == NULL) || (borderPtr->darkColorPtr == NULL)) { - if (relief == TK_RELIEF_SOLID) { - dark.red = dark.blue = dark.green = 0x00; - light.red = light.blue = light.green = 0x00; - relief = TK_RELIEF_SUNKEN; - } else { - light = *borderPtr->bgColorPtr; - dark.red = dark.blue = dark.green = 0xFF; - } - lightPtr = &light; - darkPtr = &dark; + Point2d points[7]; + TkBorder *borderPtr = (TkBorder *) border; + XColor* lightPtr, *darkPtr; + XColor* topPtr, *bottomPtr; + XColor light, dark; + int twiceWidth = (borderWidth * 2); + + if ((width < twiceWidth) || (height < twiceWidth)) { + return; + } + if ((relief == TK_RELIEF_SOLID) || + (borderPtr->lightColorPtr == NULL) || (borderPtr->darkColorPtr == NULL)) { + if (relief == TK_RELIEF_SOLID) { + dark.red = dark.blue = dark.green = 0x00; + light.red = light.blue = light.green = 0x00; + relief = TK_RELIEF_SUNKEN; } else { - lightPtr = borderPtr->lightColorPtr; - darkPtr = borderPtr->darkColorPtr; - } - - - /* Handle grooves and ridges with recursive calls. */ - - if ((relief == TK_RELIEF_GROOVE) || (relief == TK_RELIEF_RIDGE)) { - int halfWidth, insideOffset; - - halfWidth = borderWidth / 2; - insideOffset = borderWidth - halfWidth; - Blt_Ps_Draw3DRectangle(ps, border, (double)x, (double)y, - width, height, halfWidth, - (relief == TK_RELIEF_GROOVE) ? TK_RELIEF_SUNKEN : TK_RELIEF_RAISED); - Blt_Ps_Draw3DRectangle(ps, border, - (double)(x + insideOffset), (double)(y + insideOffset), - width - insideOffset * 2, height - insideOffset * 2, halfWidth, - (relief == TK_RELIEF_GROOVE) ? TK_RELIEF_RAISED : TK_RELIEF_SUNKEN); - return; - } - if (relief == TK_RELIEF_RAISED) { - topPtr = lightPtr; - bottomPtr = darkPtr; - } else if (relief == TK_RELIEF_SUNKEN) { - topPtr = darkPtr; - bottomPtr = lightPtr; - } else { - topPtr = bottomPtr = borderPtr->bgColorPtr; - } - Blt_Ps_XSetBackground(ps, bottomPtr); - Blt_Ps_XFillRectangle(ps, x, y + height - borderWidth, width, borderWidth); - Blt_Ps_XFillRectangle(ps, x + width - borderWidth, y, borderWidth, height); - points[0].x = points[1].x = points[6].x = x; - points[0].y = points[6].y = y + height; - points[1].y = points[2].y = y; - points[2].x = x + width; - points[3].x = x + width - borderWidth; - points[3].y = points[4].y = y + borderWidth; - points[4].x = points[5].x = x + borderWidth; - points[5].y = y + height - borderWidth; - if (relief != TK_RELIEF_FLAT) { - Blt_Ps_XSetBackground(ps, topPtr); + light = *borderPtr->bgColorPtr; + dark.red = dark.blue = dark.green = 0xFF; } - Blt_Ps_XFillPolygon(ps, points, 7); + lightPtr = &light; + darkPtr = &dark; + } else { + lightPtr = borderPtr->lightColorPtr; + darkPtr = borderPtr->darkColorPtr; + } + + + /* Handle grooves and ridges with recursive calls. */ + + if ((relief == TK_RELIEF_GROOVE) || (relief == TK_RELIEF_RIDGE)) { + int halfWidth, insideOffset; + + halfWidth = borderWidth / 2; + insideOffset = borderWidth - halfWidth; + Blt_Ps_Draw3DRectangle(ps, border, (double)x, (double)y, + width, height, halfWidth, + (relief == TK_RELIEF_GROOVE) ? TK_RELIEF_SUNKEN : TK_RELIEF_RAISED); + Blt_Ps_Draw3DRectangle(ps, border, + (double)(x + insideOffset), (double)(y + insideOffset), + width - insideOffset * 2, height - insideOffset * 2, halfWidth, + (relief == TK_RELIEF_GROOVE) ? TK_RELIEF_RAISED : TK_RELIEF_SUNKEN); + return; + } + if (relief == TK_RELIEF_RAISED) { + topPtr = lightPtr; + bottomPtr = darkPtr; + } else if (relief == TK_RELIEF_SUNKEN) { + topPtr = darkPtr; + bottomPtr = lightPtr; + } else { + topPtr = bottomPtr = borderPtr->bgColorPtr; + } + Blt_Ps_XSetBackground(ps, bottomPtr); + Blt_Ps_XFillRectangle(ps, x, y + height - borderWidth, width, borderWidth); + Blt_Ps_XFillRectangle(ps, x + width - borderWidth, y, borderWidth, height); + points[0].x = points[1].x = points[6].x = x; + points[0].y = points[6].y = y + height; + points[1].y = points[2].y = y; + points[2].x = x + width; + points[3].x = x + width - borderWidth; + points[3].y = points[4].y = y + borderWidth; + points[4].x = points[5].x = x + borderWidth; + points[5].y = y + height - borderWidth; + if (relief != TK_RELIEF_FLAT) { + Blt_Ps_XSetBackground(ps, topPtr); + } + Blt_Ps_XFillPolygon(ps, points, 7); } -void -Blt_Ps_Fill3DRectangle( - Blt_Ps ps, - Tk_3DBorder border, /* Token for border to draw. */ - double x, double y, /* Coordinates of top-left of border area */ - int width, int height, /* Dimension of border to be drawn. */ - int borderWidth, /* Desired width for border, in pixels. */ - int relief) /* Should be either TK_RELIEF_RAISED or - * TK_RELIEF_SUNKEN; indicates position of - * interior of window relative to exterior. */ +void Blt_Ps_Fill3DRectangle( + Blt_Ps ps, + Tk_3DBorder border, /* Token for border to draw. */ + double x, double y, /* Coordinates of top-left of border area */ + int width, int height, /* Dimension of border to be drawn. */ + int borderWidth, /* Desired width for border, in pixels. */ + int relief) /* Should be either TK_RELIEF_RAISED or + * TK_RELIEF_SUNKEN; indicates position of + * interior of window relative to exterior. */ { - TkBorder *borderPtr = (TkBorder *) border; + TkBorder *borderPtr = (TkBorder *) border; - Blt_Ps_XSetBackground(ps, borderPtr->bgColorPtr); - Blt_Ps_XFillRectangle(ps, x, y, width, height); - Blt_Ps_Draw3DRectangle(ps, border, x, y, width, height, borderWidth, - relief); + Blt_Ps_XSetBackground(ps, borderPtr->bgColorPtr); + Blt_Ps_XFillRectangle(ps, x, y, width, height); + Blt_Ps_Draw3DRectangle(ps, border, x, y, width, height, borderWidth, + relief); } -void -Blt_Ps_XSetStipple(Blt_Ps ps, Display *display, Pixmap bitmap) +void Blt_Ps_XSetStipple(Blt_Ps ps, Display *display, Pixmap bitmap) { - int width, height; - - Tk_SizeOfBitmap(display, bitmap, &width, &height); - Blt_Ps_Format(ps, - "gsave\n" - " clip\n" - " %d %d\n", - width, height); - Blt_Ps_XSetBitmapData(ps, display, bitmap, width, height); - Blt_Ps_VarAppend(ps, - " StippleFill\n" - "grestore\n", (char *)NULL); + int width, height; + + Tk_SizeOfBitmap(display, bitmap, &width, &height); + Blt_Ps_Format(ps, + "gsave\n" + " clip\n" + " %d %d\n", + width, height); + Blt_Ps_XSetBitmapData(ps, display, bitmap, width, height); + Blt_Ps_VarAppend(ps, + " StippleFill\n" + "grestore\n", (char *)NULL); } -/* - *--------------------------------------------------------------------------- - * - * Blt_Ps_XSetFont -- - * - * Map the Tk font to a PostScript font and point size. - * - * If a TCL array variable was specified, each element should be indexed - * by the X11 font name and contain a list of 1-2 elements; the - * PostScript font name and the desired point size. The point size may - * be omitted and the X font point size will be used. - * - * Otherwise, if the foundry is "Adobe", we try to do a plausible mapping - * looking at the full name of the font and building a string in the form - * of "Family-TypeFace". - * - * Returns: - * None. - * - * Side Effects: - * PostScript commands are output to change the type and the point size - * of the current font. - * - *--------------------------------------------------------------------------- - */ - -void -Blt_Ps_XSetFont(PostScript *psPtr, Tk_Font font) +void Blt_Ps_XSetFont(PostScript *psPtr, Tk_Font font) { #if 0 - Tcl_Interp* interp = psPtr->interp; - const char *family; - - /* Use the font variable information if it exists. */ - if ((psPtr->setupPtr != NULL) && (psPtr->setupPtr->fontVarName != NULL)) { - char *value; - - value = (char *)Tcl_GetVar2(interp, psPtr->setupPtr->fontVarName, - Tk_NameOfFont(font), 0); - if (value != NULL) { - const char **argv = NULL; - int argc; - int newSize; - double pointSize; - const char *fontName; - - if (Tcl_SplitList(NULL, value, &argc, &argv) != TCL_OK) { - return; - } - fontName = argv[0]; - if ((argc != 2) || - (Tcl_GetInt(interp, argv[1], &newSize) != TCL_OK)) { - free(argv); - return; - } - pointSize = (double)newSize; - Blt_Ps_Format(psPtr, "%g /%s SetFont\n", pointSize, - fontName); - free(argv); - return; - } - /*FallThru*/ - } - - /* - * Check to see if it's a PostScript font. Tk_PostScriptFontName silently - * generates a bogus PostScript font name, so we have to check to see if - * this is really a PostScript font first before we call it. - */ - family = FamilyToPsFamily(Blt_FamilyOfFont(font)); - if (family != NULL) { - Tcl_DString dString; - double pointSize; - - Tcl_DStringInit(&dString); - pointSize = (double)Blt_PostscriptFontName(font, &dString); - Blt_Ps_Format(psPtr, "%g /%s SetFont\n", pointSize, - Tcl_DStringValue(&dString)); - Tcl_DStringFree(&dString); + Tcl_Interp* interp = psPtr->interp; + const char *family; + + /* Use the font variable information if it exists. */ + if ((psPtr->setupPtr != NULL) && (psPtr->setupPtr->fontVarName != NULL)) { + char *value; + + value = (char *)Tcl_GetVar2(interp, psPtr->setupPtr->fontVarName, + Tk_NameOfFont(font), 0); + if (value != NULL) { + const char **argv = NULL; + int argc; + int newSize; + double pointSize; + const char *fontName; + + if (Tcl_SplitList(NULL, value, &argc, &argv) != TCL_OK) { return; + } + fontName = argv[0]; + if ((argc != 2) || + (Tcl_GetInt(interp, argv[1], &newSize) != TCL_OK)) { + free(argv); + return; + } + pointSize = (double)newSize; + Blt_Ps_Format(psPtr, "%g /%s SetFont\n", pointSize, + fontName); + free(argv); + return; } - Blt_Ps_Append(psPtr, "12.0 /Helvetica-Bold SetFont\n"); + /*FallThru*/ + } + + /* + * Check to see if it's a PostScript font. Tk_PostScriptFontName silently + * generates a bogus PostScript font name, so we have to check to see if + * this is really a PostScript font first before we call it. + */ + family = FamilyToPsFamily(Blt_FamilyOfFont(font)); + if (family != NULL) { + Tcl_DString dString; + double pointSize; + + Tcl_DStringInit(&dString); + pointSize = (double)Blt_PostscriptFontName(font, &dString); + Blt_Ps_Format(psPtr, "%g /%s SetFont\n", pointSize, + Tcl_DStringValue(&dString)); + Tcl_DStringFree(&dString); + return; + } + Blt_Ps_Append(psPtr, "12.0 /Helvetica-Bold SetFont\n"); #endif } #if 0 -static void -TextLayoutToPostScript(Blt_Ps ps, int x, int y, TextLayout *textPtr) +static void TextLayoutToPostScript(Blt_Ps ps, int x, int y, TextLayout *textPtr) { - char *bp, *dst; - int count; /* Counts the # of bytes written to the + char *bp, *dst; + int count; /* Counts the # of bytes written to the * intermediate scratch buffer. */ - const char *src, *end; - TextFragment *fragPtr; - int i; - unsigned char c; + const char *src, *end; + TextFragment *fragPtr; + int i; + unsigned char c; #if HAVE_UTF - Tcl_UniChar ch; + Tcl_UniChar ch; #endif - int limit; + int limit; - limit = POSTSCRIPT_BUFSIZ - 4; /* High water mark for scratch buffer. */ - fragPtr = textPtr->fragments; - for (i = 0; i < textPtr->nFrags; i++, fragPtr++) { - if (fragPtr->count < 1) { - continue; - } - Blt_Ps_Append(ps, "("); - count = 0; + limit = POSTSCRIPT_BUFSIZ - 4; /* High water mark for scratch buffer. */ + fragPtr = textPtr->fragments; + for (i = 0; i < textPtr->nFrags; i++, fragPtr++) { + if (fragPtr->count < 1) { + continue; + } + Blt_Ps_Append(ps, "("); + count = 0; + dst = Blt_Ps_GetScratchBuffer(ps); + src = fragPtr->text; + end = fragPtr->text + fragPtr->count; + while (src < end) { + if (count > limit) { + /* Don't let the scatch buffer overflow */ dst = Blt_Ps_GetScratchBuffer(ps); - src = fragPtr->text; - end = fragPtr->text + fragPtr->count; - while (src < end) { - if (count > limit) { - /* Don't let the scatch buffer overflow */ - dst = Blt_Ps_GetScratchBuffer(ps); - dst[count] = '\0'; - Blt_Ps_Append(ps, dst); - count = 0; - } + dst[count] = '\0'; + Blt_Ps_Append(ps, dst); + count = 0; + } #if HAVE_UTF - /* - * INTL: For now we just treat the characters as binary data and - * display the lower byte. Eventually this should be revised to - * handle international postscript fonts. - */ - src += Tcl_UtfToUniChar(src, &ch); - c = (unsigned char)(ch & 0xff); + /* + * INTL: For now we just treat the characters as binary data and + * display the lower byte. Eventually this should be revised to + * handle international postscript fonts. + */ + src += Tcl_UtfToUniChar(src, &ch); + c = (unsigned char)(ch & 0xff); #else - c = *src++; + c = *src++; #endif - if ((c == '\\') || (c == '(') || (c == ')')) { - /* - * If special PostScript characters characters "\", "(", and - * ")" are contained in the text string, prepend backslashes - * to them. - */ - *dst++ = '\\'; - *dst++ = c; - count += 2; - } else if ((c < ' ') || (c > '~')) { - /* Convert non-printable characters into octal. */ - sprintf_s(dst, 5, "\\%03o", c); - dst += 4; - count += 4; - } else { - *dst++ = c; - count++; - } - } - bp = Blt_Ps_GetScratchBuffer(ps); - bp[count] = '\0'; - Blt_Ps_Append(ps, bp); - Blt_Ps_Format(ps, ") %d %d %d DrawAdjText\n", - fragPtr->width, x + fragPtr->x, y + fragPtr->y); + if ((c == '\\') || (c == '(') || (c == ')')) { + /* + * If special PostScript characters characters "\", "(", and + * ")" are contained in the text string, prepend backslashes + * to them. + */ + *dst++ = '\\'; + *dst++ = c; + count += 2; + } else if ((c < ' ') || (c > '~')) { + /* Convert non-printable characters into octal. */ + sprintf_s(dst, 5, "\\%03o", c); + dst += 4; + count += 4; + } else { + *dst++ = c; + count++; + } } + bp = Blt_Ps_GetScratchBuffer(ps); + bp[count] = '\0'; + Blt_Ps_Append(ps, bp); + Blt_Ps_Format(ps, ") %d %d %d DrawAdjText\n", + fragPtr->width, x + fragPtr->x, y + fragPtr->y); + } } #endif -/* - *--------------------------------------------------------------------------- - * - * Blt_Ps_DrawText -- - * - * Output PostScript commands to print a text string. The string may be - * rotated at any arbitrary angle, and placed according the anchor type - * given. The anchor indicates how to interpret the window coordinates as - * an anchor for the text bounding box. - * - * Results: - * None. - * - * Side Effects: - * Text string is drawn using the given font and GC on the graph window - * at the given coordinates, anchor, and rotation - * - *--------------------------------------------------------------------------- - */ -void -Blt_Ps_DrawText( - Blt_Ps ps, - const char *string, /* String to convert to PostScript */ - TextStyle *tsPtr, /* Text attribute information */ - double x, double y) /* Window coordinates where to print text */ +void Blt_Ps_DrawText( + Blt_Ps ps, + const char *string, /* String to convert to PostScript */ + TextStyle *tsPtr, /* Text attribute information */ + double x, double y) /* Window coordinates where to print text */ { #if 0 - TextLayout *textPtr; - Point2d t; - - if ((string == NULL) || (*string == '\0')) { /* Empty string, do nothing */ - return; - } - textPtr = Blt_Ts_CreateLayout(string, -1, tsPtr); - { - float angle; - double rw, rh; + TextLayout *textPtr; + Point2d t; + + if ((string == NULL) || (*string == '\0')) { /* Empty string, do nothing */ + return; + } + textPtr = Blt_Ts_CreateLayout(string, -1, tsPtr); + { + float angle; + double rw, rh; - angle = fmod(tsPtr->angle, (double)360.0); - Blt_GetBoundingBox(textPtr->width, textPtr->height, angle, &rw, &rh, - (Point2d *)NULL); - /* - * Find the center of the bounding box - */ - t = Blt_AnchorPoint(x, y, rw, rh, tsPtr->anchor); - t.x += rw * 0.5; - t.y += rh * 0.5; - } + angle = fmod(tsPtr->angle, (double)360.0); + Blt_GetBoundingBox(textPtr->width, textPtr->height, angle, &rw, &rh, + (Point2d *)NULL); + /* + * Find the center of the bounding box + */ + t = Blt_AnchorPoint(x, y, rw, rh, tsPtr->anchor); + t.x += rw * 0.5; + t.y += rh * 0.5; + } - /* Initialize text (sets translation and rotation) */ - Blt_Ps_Format(ps, "%d %d %g %g %g BeginText\n", textPtr->width, - textPtr->height, tsPtr->angle, t.x, t.y); + /* Initialize text (sets translation and rotation) */ + Blt_Ps_Format(ps, "%d %d %g %g %g BeginText\n", textPtr->width, + textPtr->height, tsPtr->angle, t.x, t.y); - Blt_Ps_XSetFont(ps, tsPtr->font); + Blt_Ps_XSetFont(ps, tsPtr->font); - Blt_Ps_XSetForeground(ps, tsPtr->color); - TextLayoutToPostScript(ps, 0, 0, textPtr); - free(textPtr); - Blt_Ps_Append(ps, "EndText\n"); + Blt_Ps_XSetForeground(ps, tsPtr->color); + TextLayoutToPostScript(ps, 0, 0, textPtr); + free(textPtr); + Blt_Ps_Append(ps, "EndText\n"); #endif } -void -Blt_Ps_XDrawLines(Blt_Ps ps, XPoint *points, int n) +void Blt_Ps_XDrawLines(Blt_Ps ps, XPoint *points, int n) { - int nLeft; - - if (n <= 0) { - return; - } - for (nLeft = n; nLeft > 0; nLeft -= PS_MAXPATH) { - int length; - - length = MIN(PS_MAXPATH, nLeft); - Blt_Ps_PolylineFromXPoints(ps, points, length); - Blt_Ps_Append(ps, "DashesProc stroke\n"); - points += length; - } + int nLeft; + + if (n <= 0) { + return; + } + for (nLeft = n; nLeft > 0; nLeft -= PS_MAXPATH) { + int length; + + length = MIN(PS_MAXPATH, nLeft); + Blt_Ps_PolylineFromXPoints(ps, points, length); + Blt_Ps_Append(ps, "DashesProc stroke\n"); + points += length; + } } -void -Blt_Ps_DrawPolyline(Blt_Ps ps, Point2d *points, int nPoints) +void Blt_Ps_DrawPolyline(Blt_Ps ps, Point2d *points, int nPoints) { - int nLeft; - - if (nPoints <= 0) { - return; - } - for (nLeft = nPoints; nLeft > 0; nLeft -= PS_MAXPATH) { - int length; - - length = MIN(PS_MAXPATH, nLeft); - Blt_Ps_Polyline(ps, points, length); - Blt_Ps_Append(ps, "DashesProc stroke\n"); - points += length; - } + int nLeft; + + if (nPoints <= 0) { + return; + } + for (nLeft = nPoints; nLeft > 0; nLeft -= PS_MAXPATH) { + int length; + + length = MIN(PS_MAXPATH, nLeft); + Blt_Ps_Polyline(ps, points, length); + Blt_Ps_Append(ps, "DashesProc stroke\n"); + points += length; + } } -void -Blt_Ps_DrawBitmap( - Blt_Ps ps, - Display *display, - Pixmap bitmap, /* Bitmap to be converted to PostScript */ - double xScale, double yScale) +void Blt_Ps_DrawBitmap( + Blt_Ps ps, + Display *display, + Pixmap bitmap, /* Bitmap to be converted to PostScript */ + double xScale, double yScale) { - int width, height; - double sw, sh; - - Tk_SizeOfBitmap(display, bitmap, &width, &height); - sw = (double)width * xScale; - sh = (double)height * yScale; - Blt_Ps_Append(ps, " gsave\n"); - Blt_Ps_Format(ps, " %g %g translate\n", sw * -0.5, sh * 0.5); - Blt_Ps_Format(ps, " %g %g scale\n", sw, -sh); - Blt_Ps_Format(ps, " %d %d true [%d 0 0 %d 0 %d] {", - width, height, width, -height, height); - Blt_Ps_XSetBitmapData(ps, display, bitmap, width, height); - Blt_Ps_Append(ps, " } imagemask\n grestore\n"); + int width, height; + double sw, sh; + + Tk_SizeOfBitmap(display, bitmap, &width, &height); + sw = (double)width * xScale; + sh = (double)height * yScale; + Blt_Ps_Append(ps, " gsave\n"); + Blt_Ps_Format(ps, " %g %g translate\n", sw * -0.5, sh * 0.5); + Blt_Ps_Format(ps, " %g %g scale\n", sw, -sh); + Blt_Ps_Format(ps, " %d %d true [%d 0 0 %d 0 %d] {", + width, height, width, -height, height); + Blt_Ps_XSetBitmapData(ps, display, bitmap, width, height); + Blt_Ps_Append(ps, " } imagemask\n grestore\n"); } -void -Blt_Ps_Draw2DSegments(Blt_Ps ps, Segment2d *segments, int nSegments) +void Blt_Ps_Draw2DSegments(Blt_Ps ps, Segment2d *segments, int nSegments) { - Segment2d *sp, *send; - - Blt_Ps_Append(ps, "newpath\n"); - for (sp = segments, send = sp + nSegments; sp < send; sp++) { - Blt_Ps_Format(ps, " %g %g moveto %g %g lineto\n", - sp->p.x, sp->p.y, sp->q.x, sp->q.y); - Blt_Ps_Append(ps, "DashesProc stroke\n"); - } + Segment2d *sp, *send; + + Blt_Ps_Append(ps, "newpath\n"); + for (sp = segments, send = sp + nSegments; sp < send; sp++) { + Blt_Ps_Format(ps, " %g %g moveto %g %g lineto\n", + sp->p.x, sp->p.y, sp->q.x, sp->q.y); + Blt_Ps_Append(ps, "DashesProc stroke\n"); + } } -void -Blt_Ps_FontName(const char *family, int flags, Tcl_DString *resultPtr) +void Blt_Ps_FontName(const char *family, int flags, Tcl_DString *resultPtr) { - const char *familyName, *weightName, *slantName; - int len; + const char *familyName, *weightName, *slantName; + int len; - len = Tcl_DStringLength(resultPtr); + len = Tcl_DStringLength(resultPtr); - familyName = FamilyToPsFamily(family); - if (familyName == NULL) { - Tcl_UniChar ch; - char *src, *dest; - int upper; + familyName = FamilyToPsFamily(family); + if (familyName == NULL) { + Tcl_UniChar ch; + char *src, *dest; + int upper; - /* - * Inline, capitalize the first letter of each word, lowercase the - * rest of the letters in each word, and then take out the spaces - * between the words. This may make the DString shorter, which is - * safe to do. - */ - Tcl_DStringAppend(resultPtr, family, -1); - src = dest = Tcl_DStringValue(resultPtr) + len; + /* + * Inline, capitalize the first letter of each word, lowercase the + * rest of the letters in each word, and then take out the spaces + * between the words. This may make the DString shorter, which is + * safe to do. + */ + Tcl_DStringAppend(resultPtr, family, -1); + src = dest = Tcl_DStringValue(resultPtr) + len; + upper = TRUE; + while (*src != '\0') { + while (isspace(*src)) { /* INTL: ISO space */ + src++; upper = TRUE; - while (*src != '\0') { - while (isspace(*src)) { /* INTL: ISO space */ - src++; - upper = TRUE; - } - src += Tcl_UtfToUniChar(src, &ch); - if (upper) { - ch = Tcl_UniCharToUpper(ch); - upper = FALSE; - } else { - ch = Tcl_UniCharToLower(ch); - } - dest += Tcl_UniCharToUtf(ch, dest); - } - *dest = '\0'; - Tcl_DStringSetLength(resultPtr, dest - Tcl_DStringValue(resultPtr)); - familyName = Tcl_DStringValue(resultPtr) + len; + } + src += Tcl_UtfToUniChar(src, &ch); + if (upper) { + ch = Tcl_UniCharToUpper(ch); + upper = FALSE; + } else { + ch = Tcl_UniCharToLower(ch); + } + dest += Tcl_UniCharToUtf(ch, dest); } - if (familyName != Tcl_DStringValue(resultPtr) + len) { - Tcl_DStringAppend(resultPtr, familyName, -1); - familyName = Tcl_DStringValue(resultPtr) + len; + *dest = '\0'; + Tcl_DStringSetLength(resultPtr, dest - Tcl_DStringValue(resultPtr)); + familyName = Tcl_DStringValue(resultPtr) + len; + } + if (familyName != Tcl_DStringValue(resultPtr) + len) { + Tcl_DStringAppend(resultPtr, familyName, -1); + familyName = Tcl_DStringValue(resultPtr) + len; + } + if (strcasecmp(familyName, "NewCenturySchoolbook") == 0) { + Tcl_DStringSetLength(resultPtr, len); + Tcl_DStringAppend(resultPtr, "NewCenturySchlbk", -1); + familyName = Tcl_DStringValue(resultPtr) + len; + } + + /* Get the string to use for the weight. */ + weightName = NULL; + if (flags & FONT_BOLD) { + if ((strcmp(familyName, "Bookman") == 0) || + (strcmp(familyName, "AvantGarde") == 0)) { + weightName = "Demi"; + } else { + weightName = "Bold"; } - if (strcasecmp(familyName, "NewCenturySchoolbook") == 0) { - Tcl_DStringSetLength(resultPtr, len); - Tcl_DStringAppend(resultPtr, "NewCenturySchlbk", -1); - familyName = Tcl_DStringValue(resultPtr) + len; + } else { + if (strcmp(familyName, "Bookman") == 0) { + weightName = "Light"; + } else if (strcmp(familyName, "AvantGarde") == 0) { + weightName = "Book"; + } else if (strcmp(familyName, "ZapfChancery") == 0) { + weightName = "Medium"; } - - /* Get the string to use for the weight. */ - weightName = NULL; - if (flags & FONT_BOLD) { - if ((strcmp(familyName, "Bookman") == 0) || - (strcmp(familyName, "AvantGarde") == 0)) { - weightName = "Demi"; - } else { - weightName = "Bold"; - } + } + + /* Get the string to use for the slant. */ + slantName = NULL; + if (flags & FONT_ITALIC) { + if ((strcmp(familyName, "Helvetica") == 0) || + (strcmp(familyName, "Courier") == 0) || + (strcmp(familyName, "AvantGarde") == 0)) { + slantName = "Oblique"; } else { - if (strcmp(familyName, "Bookman") == 0) { - weightName = "Light"; - } else if (strcmp(familyName, "AvantGarde") == 0) { - weightName = "Book"; - } else if (strcmp(familyName, "ZapfChancery") == 0) { - weightName = "Medium"; - } + slantName = "Italic"; } + } - /* Get the string to use for the slant. */ - slantName = NULL; - if (flags & FONT_ITALIC) { - if ((strcmp(familyName, "Helvetica") == 0) || - (strcmp(familyName, "Courier") == 0) || - (strcmp(familyName, "AvantGarde") == 0)) { - slantName = "Oblique"; - } else { - slantName = "Italic"; - } + if ((slantName == NULL) && (weightName == NULL)) { + if ((strcmp(familyName, "Times") == 0) || + (strcmp(familyName, "NewCenturySchlbk") == 0) || + (strcmp(familyName, "Palatino") == 0)) { + Tcl_DStringAppend(resultPtr, "-Roman", -1); } - - /* - * The string "Roman" needs to be added to some fonts that are not bold - * and not italic. - */ - if ((slantName == NULL) && (weightName == NULL)) { - if ((strcmp(familyName, "Times") == 0) || - (strcmp(familyName, "NewCenturySchlbk") == 0) || - (strcmp(familyName, "Palatino") == 0)) { - Tcl_DStringAppend(resultPtr, "-Roman", -1); - } - } else { - Tcl_DStringAppend(resultPtr, "-", -1); - if (weightName != NULL) { - Tcl_DStringAppend(resultPtr, weightName, -1); - } - if (slantName != NULL) { - Tcl_DStringAppend(resultPtr, slantName, -1); - } + } else { + Tcl_DStringAppend(resultPtr, "-", -1); + if (weightName != NULL) { + Tcl_DStringAppend(resultPtr, weightName, -1); + } + if (slantName != NULL) { + Tcl_DStringAppend(resultPtr, slantName, -1); } + } } diff --git a/src/bltGrPSOutput.h b/src/bltGrPSOutput.h index c12c088..88284d5 100644 --- a/src/bltGrPSOutput.h +++ b/src/bltGrPSOutput.h @@ -5,8 +5,6 @@ */ /* - * bltPs.h -- - * * Copyright 1993-2004 George A Howlett. * * Permission is hereby granted, free of charge, to any person obtaining @@ -34,47 +32,38 @@ #include "bltConfig.h" -/* - * PageSetup -- - * - * Structure contains information specific to the layout of the page for - * printing the graph. - * - */ typedef struct { - /* User configurable fields */ - - int reqWidth, reqHeight; /* If greater than zero, represents the + int reqWidth, reqHeight; /* If greater than zero, represents the * requested dimensions of the printed graph */ - int reqPaperWidth; - int reqPaperHeight; /* Requested dimensions for the PostScript + int reqPaperWidth; + int reqPaperHeight; /* Requested dimensions for the PostScript * page. Can constrain the size of the graph * if the graph (plus padding) is larger than * the size of the page. */ - int xPad, yPad; /* Requested padding on the exterior of the + int xPad, yPad; /* Requested padding on the exterior of the * graph. This forms the bounding box for * the page. */ - const char *colorVarName; /* If non-NULL, is the name of a TCL array + const char *colorVarName; /* If non-NULL, is the name of a TCL array * variable containing X to output device color * translations */ - const char *fontVarName; /* If non-NULL, is the name of a TCL array + const char *fontVarName; /* If non-NULL, is the name of a TCL array * variable containing X to output device font * translations */ - int level; /* PostScript Language level 1-3 */ - unsigned int flags; + int level; /* PostScript Language level 1-3 */ + unsigned int flags; - const char **comments; /* User supplied comments to be added. */ + const char **comments; /* User supplied comments to be added. */ - /* Computed fields */ + /* Computed fields */ - short int left, bottom; /* Bounding box of the plot in the page. */ - short int right, top; + short int left, bottom; /* Bounding box of the plot in the page. */ + short int right, top; - float scale; /* Scale of page. Set if "-maxpect" option - * is set, otherwise 1.0. */ + float scale; /* Scale of page. Set if "-maxpect" option + * is set, otherwise 1.0. */ - int paperHeight; - int paperWidth; + int paperHeight; + int paperWidth; } PageSetup; @@ -117,10 +106,10 @@ extern void Blt_Ps_Format TCL_VARARGS(Blt_Ps, ps); extern void Blt_Ps_SetClearBackground(Blt_Ps ps); extern int Blt_Ps_IncludeFile(Tcl_Interp* interp, Blt_Ps ps, - const char *fileName); + const char *fileName); extern int Blt_Ps_GetPicaFromObj(Tcl_Interp* interp, Tcl_Obj *objPtr, - int *picaPtr); + int *picaPtr); extern int Blt_Ps_ComputeBoundingBox(PageSetup *setupPtr, int w, int h); @@ -128,7 +117,7 @@ extern void Blt_Ps_Rectangle(Blt_Ps ps, int x, int y, int w, int h); extern int Blt_Ps_SaveFile(Tcl_Interp* interp, Blt_Ps ps, - const char *fileName); + const char *fileName); #ifdef _TK @@ -139,7 +128,7 @@ extern void Blt_Ps_XSetLineWidth(Blt_Ps ps, int lineWidth); extern void Blt_Ps_XSetBackground(Blt_Ps ps, XColor* colorPtr); extern void Blt_Ps_XSetBitmapData(Blt_Ps ps, Display *display, - Pixmap bitmap, int width, int height); + Pixmap bitmap, int width, int height); extern void Blt_Ps_XSetForeground(Blt_Ps ps, XColor* colorPtr); @@ -148,7 +137,7 @@ extern void Blt_Ps_XSetFont(Blt_Ps ps, Tk_Font font); extern void Blt_Ps_XSetDashes(Blt_Ps ps, Blt_Dashes *dashesPtr); extern void Blt_Ps_XSetLineAttributes(Blt_Ps ps, XColor* colorPtr, - int lineWidth, Blt_Dashes *dashesPtr, int capStyle, int joinStyle); + int lineWidth, Blt_Dashes *dashesPtr, int capStyle, int joinStyle); extern void Blt_Ps_XSetStipple(Blt_Ps ps, Display *display, Pixmap bitmap); @@ -157,38 +146,38 @@ extern void Blt_Ps_Polyline(Blt_Ps ps, Point2d *screenPts, int nScreenPts); extern void Blt_Ps_XDrawLines(Blt_Ps ps, XPoint *points, int n); extern void Blt_Ps_XDrawSegments(Blt_Ps ps, XSegment *segments, - int nSegments); + int nSegments); extern void Blt_Ps_DrawPolyline(Blt_Ps ps, Point2d *points, int n); extern void Blt_Ps_Draw2DSegments(Blt_Ps ps, Segment2d *segments, - int nSegments); + int nSegments); extern void Blt_Ps_Draw3DRectangle(Blt_Ps ps, Tk_3DBorder border, - double x, double y, int width, int height, int borderWidth, int relief); + double x, double y, int width, int height, int borderWidth, int relief); extern void Blt_Ps_Fill3DRectangle(Blt_Ps ps, Tk_3DBorder border, double x, - double y, int width, int height, int borderWidth, int relief); + double y, int width, int height, int borderWidth, int relief); extern void Blt_Ps_XFillRectangle(Blt_Ps ps, double x, double y, - int width, int height); + int width, int height); extern void Blt_Ps_XFillRectangles(Blt_Ps ps, XRectangle *rects, int n); extern void Blt_Ps_XFillPolygon(Blt_Ps ps, Point2d *screenPts, - int nScreenPts); + int nScreenPts); extern void Blt_Ps_DrawPhoto(Blt_Ps ps, Tk_PhotoHandle photoToken, - double x, double y); + double x, double y); extern void Blt_Ps_XDrawWindow(Blt_Ps ps, Tk_Window tkwin, - double x, double y); + double x, double y); extern void Blt_Ps_DrawText(Blt_Ps ps, const char *string, - TextStyle *attrPtr, double x, double y); + TextStyle *attrPtr, double x, double y); extern void Blt_Ps_DrawBitmap(Blt_Ps ps, Display *display, Pixmap bitmap, - double scaleX, double scaleY); + double scaleX, double scaleY); extern void Blt_Ps_XSetCapStyle(Blt_Ps ps, int capStyle); @@ -206,7 +195,7 @@ extern int Blt_Ps_TextWidth(Tk_Font font, const char *string, int nBytes); extern int Blt_Ps_GetFontMetrics(Tk_Font font, Tk_FontMetrics *fmPtr); extern void Blt_Ps_FontName(const char *family, int flags, - Tcl_DString *resultPtr); + Tcl_DString *resultPtr); #endif /* _TK */ diff --git a/src/bltGrPenOp.C b/src/bltGrPenOp.C index 4be0a95..1725847 100644 --- a/src/bltGrPenOp.C +++ b/src/bltGrPenOp.C @@ -5,10 +5,6 @@ */ /* - * bltGrPen.c -- - * - * This module implements pens for the BLT graph widget. - * * Copyright 1996-2004 George A Howlett. * * Permission is hereby granted, free of charge, to any person obtaining diff --git a/src/bltGrText.C b/src/bltGrText.C index 6a9986d..f733d8b 100644 --- a/src/bltGrText.C +++ b/src/bltGrText.C @@ -5,10 +5,6 @@ */ /* - * bltText.c -- - * - * This module implements multi-line, rotate-able text for the BLT toolkit. - * * Copyright 1993-2004 George A Howlett. * * Permission is hereby granted, free of charge, to any person obtaining diff --git a/src/bltGrText.h b/src/bltGrText.h index 3f1cc61..ec9399e 100644 --- a/src/bltGrText.h +++ b/src/bltGrText.h @@ -5,9 +5,6 @@ */ /* - * bltText.h -- - * - * * Copyright 1993-2004 George A Howlett. * * Permission is hereby granted, free of charge, to any person obtaining diff --git a/src/bltGraph.C b/src/bltGraph.C index 52bc774..b0e5f79 100644 --- a/src/bltGraph.C +++ b/src/bltGraph.C @@ -5,12 +5,6 @@ */ /* - * bltGraph.c -- - * - * This module implements a graph widget for the BLT toolkit. - * - * The graph widget was created by Sani Nassif and George Howlett. - * * Copyright 1991-2004 George A Howlett. * * Permission is hereby granted, free of charge, to any person obtaining diff --git a/src/bltGraph.h b/src/bltGraph.h index 3b33368..339fcae 100644 --- a/src/bltGraph.h +++ b/src/bltGraph.h @@ -5,8 +5,6 @@ */ /* - * bltGraph.h -- - * * Copyright 1993-2004 George A Howlett. * * Permission is hereby granted, free of charge, to any person obtaining diff --git a/src/bltInt.C b/src/bltInt.C index 284b72e..130b55a 100644 --- a/src/bltInt.C +++ b/src/bltInt.C @@ -5,11 +5,6 @@ */ /* - * bltCoreInit.c -- - * - * This module initials the non-Tk command of the BLT toolkit, registering the - * commands with the TCL interpreter. - * * Copyright 1991-2004 George A Howlett. * * Permission is hereby granted, free of charge, to any person obtaining diff --git a/src/bltNsUtil.C b/src/bltNsUtil.C index 8b43b19..34cfb5a 100644 --- a/src/bltNsUtil.C +++ b/src/bltNsUtil.C @@ -5,8 +5,6 @@ */ /* - * bltNsUtil.c -- - * * This module implements utility namespace procedures for the BLT toolkit. * * Copyright 1997-2008 George A Howlett. diff --git a/src/bltNsUtil.h b/src/bltNsUtil.h index 1affdb7..5b9bb28 100644 --- a/src/bltNsUtil.h +++ b/src/bltNsUtil.h @@ -5,8 +5,6 @@ */ /* - * bltNsUtil.h -- - * * Copyright 1993-2004 George A Howlett. * * Permission is hereby granted, free of charge, to any person diff --git a/src/bltOp.h b/src/bltOp.h index 25db5c4..8ab1980 100644 --- a/src/bltOp.h +++ b/src/bltOp.h @@ -5,16 +5,31 @@ */ /* - *--------------------------------------------------------------------------- + * Copyright 1993-2004 George A Howlett. * - * Blt_OpSpec -- + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: * - * Structure to specify a set of operations for a TCL command. - * This is passed to the Blt_GetOp procedure to look - * for a function pointer associated with the operation name. + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the + * Software. * - *--------------------------------------------------------------------------- + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE + * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR + * PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS + * OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ + typedef struct { const char *name; /* Name of operation */ int minChars; /* Minimum # characters to disambiguate */ diff --git a/src/bltParse.C b/src/bltParse.C index 283b042..a2fa375 100644 --- a/src/bltParse.C +++ b/src/bltParse.C @@ -5,11 +5,6 @@ */ /* - * bltParse.c -- - * - * Contains a collection of procedures that are used to parse Tcl - * commands or parts of commands (like quoted strings or nested - * sub-commands). * * This file is copied from tclParse.c in the TCL library distribution. * diff --git a/src/bltParse.h b/src/bltParse.h index 9e2ee79..b9cb298 100644 --- a/src/bltParse.h +++ b/src/bltParse.h @@ -5,8 +5,6 @@ */ /* - * bltParse.h -- - * * Copyright 1993-2004 George A Howlett. * * Permission is hereby granted, free of charge, to any person obtaining diff --git a/src/bltSwitch.C b/src/bltSwitch.C index 891a47f..b764eb6 100644 --- a/src/bltSwitch.C +++ b/src/bltSwitch.C @@ -5,11 +5,6 @@ */ /* - * bltSwitch.c -- - * - * This module implements command/argument switch parsing procedures for the - * BLT toolkit. - * * Copyright 1991-2004 George A Howlett. * * Permission is hereby granted, free of charge, to any person obtaining diff --git a/src/bltSwitch.h b/src/bltSwitch.h index f2c9c27..20c7f80 100644 --- a/src/bltSwitch.h +++ b/src/bltSwitch.h @@ -5,8 +5,6 @@ */ /* - * bltSwitch.h -- - * * Copyright 1993-2004 George A Howlett. * * Permission is hereby granted, free of charge, to any person diff --git a/src/bltVecCmd.C b/src/bltVecCmd.C index 44cb1bf..beb70f1 100644 --- a/src/bltVecCmd.C +++ b/src/bltVecCmd.C @@ -5,10 +5,6 @@ */ /* - * bltVecCmd.c -- - * - * This module implements vector data objects. - * * Copyright 1995-2004 George A Howlett. * * Permission is hereby granted, free of charge, to any person obtaining diff --git a/src/bltVecInt.h b/src/bltVecInt.h index 953e0b7..ad83fac 100644 --- a/src/bltVecInt.h +++ b/src/bltVecInt.h @@ -5,8 +5,6 @@ */ /* - * bltVecInt.h -- - * * Copyright 1995-2004 George A Howlett. * * Permission is hereby granted, free of charge, to any person obtaining diff --git a/src/bltVecMath.C b/src/bltVecMath.C index 918d119..be09a1a 100644 --- a/src/bltVecMath.C +++ b/src/bltVecMath.C @@ -5,11 +5,6 @@ */ /* - * bltVecMath.c -- - * - * This module implements mathematical expressions with vector data - * objects. - * * Copyright 1995-2004 George A Howlett. * * Permission is hereby granted, free of charge, to any person diff --git a/src/bltVector.C b/src/bltVector.C index 50fac01..23dee15 100644 --- a/src/bltVector.C +++ b/src/bltVector.C @@ -5,10 +5,6 @@ */ /* - * bltVector.c -- - * - * This module implements vector data objects. - * * Copyright 1995-2004 George A Howlett. * * Permission is hereby granted, free of charge, to any person obtaining diff --git a/src/bltVector.h b/src/bltVector.h index 52b907c..fed6360 100644 --- a/src/bltVector.h +++ b/src/bltVector.h @@ -5,8 +5,6 @@ */ /* - * bltVector.h -- - * * Copyright 1993-2004 George A Howlett. * * Permission is hereby granted, free of charge, to any person |