summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bltGrMarkerBitmap.C95
-rw-r--r--bltGrMarkerBitmap.h32
-rwxr-xr-xconfigure1
-rwxr-xr-xconfigure.in1
-rw-r--r--src/bltGrBind.C241
-rw-r--r--src/bltGrBind.h3
-rw-r--r--src/bltGrElemLine.C59
-rw-r--r--src/bltGrMarker.C45
-rw-r--r--src/bltGrMarker.h20
-rw-r--r--src/bltGrMarkerLine.C130
-rw-r--r--src/bltGrMarkerLine.h36
-rw-r--r--src/bltGrMarkerPolygon.C194
-rw-r--r--src/bltGrMarkerPolygon.h42
-rw-r--r--src/bltGrMarkerText.C101
-rw-r--r--src/bltGrMarkerText.h30
-rw-r--r--src/bltGraph.C66
16 files changed, 503 insertions, 593 deletions
diff --git a/bltGrMarkerBitmap.C b/bltGrMarkerBitmap.C
index 19fff04..3a459eb 100644
--- a/bltGrMarkerBitmap.C
+++ b/bltGrMarkerBitmap.C
@@ -34,42 +34,47 @@ extern "C" {
#include "bltGrMarkerBitmap.h"
+// OptionSpecs
+
static Tk_OptionSpec optionSpecs[] = {
{TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor",
- "center", -1, Tk_Offset(BitmapMarker, anchor), 0, NULL, 0},
+ "center", -1, Tk_Offset(BitmapMarkerOptions, anchor), 0, NULL, 0},
{TK_OPTION_COLOR, "-background", "background", "Background",
- NULL, -1, Tk_Offset(BitmapMarker, fillColor), TK_OPTION_NULL_OK, NULL, 0},
+ NULL, -1, Tk_Offset(BitmapMarkerOptions, fillColor),
+ TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_SYNONYM, "-bg", NULL, NULL, NULL, -1, 0, 0, "-background", 0},
- {TK_OPTION_CUSTOM, "-bindtags", "bindTags", "BindTags",
- "Bitmap all", -1, Tk_Offset(BitmapMarker, obj.tags),
- TK_OPTION_NULL_OK, &listObjOption, 0},
+ // {TK_OPTION_CUSTOM, "-bindtags", "bindTags", "BindTags",
+ // "Bitmap all", -1, Tk_Offset(BitmapMarkerOptions, obj.tags),
+ // TK_OPTION_NULL_OK, &listObjOption, 0},
{TK_OPTION_BITMAP, "-bitmap", "bitmap", "Bitmap",
- NULL, -1, Tk_Offset(BitmapMarker, bitmap), TK_OPTION_NULL_OK, NULL, 0},
+ NULL, -1, Tk_Offset(BitmapMarkerOptions, bitmap),
+ TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_CUSTOM, "-coords", "coords", "Coords",
- NULL, -1, Tk_Offset(BitmapMarker, worldPts),
+ NULL, -1, Tk_Offset(BitmapMarkerOptions, worldPts),
TK_OPTION_NULL_OK, &coordsObjOption, MAP_ITEM},
{TK_OPTION_STRING, "-element", "element", "Element",
- NULL, -1, Tk_Offset(BitmapMarker, elemName), TK_OPTION_NULL_OK, NULL, 0},
+ NULL, -1, Tk_Offset(BitmapMarkerOptions, elemName),
+ TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_SYNONYM, "-fg", NULL, NULL, NULL, -1, 0, 0, "-foreground", 0},
{TK_OPTION_SYNONYM, "-fill", NULL, NULL, NULL, -1, 0, 0, "-background", 0},
{TK_OPTION_COLOR, "-foreground", "foreground", "Foreground",
- STD_NORMAL_FOREGROUND, -1, Tk_Offset(BitmapMarker, outlineColor),
+ STD_NORMAL_FOREGROUND, -1, Tk_Offset(BitmapMarkerOptions, outlineColor),
TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_BOOLEAN, "-hide", "hide", "Hide",
- "no", -1, Tk_Offset(BitmapMarker, hide), 0, NULL, 0},
+ "no", -1, Tk_Offset(BitmapMarkerOptions, hide), 0, NULL, 0},
{TK_OPTION_CUSTOM, "-mapx", "mapX", "MapX",
- "x", -1, Tk_Offset(BitmapMarker, axes.x), 0, &xAxisObjOption, 0},
+ "x", -1, Tk_Offset(BitmapMarkerOptions, axes.x), 0, &xAxisObjOption, 0},
{TK_OPTION_CUSTOM, "-mapy", "mapY", "MapY",
- "y", -1, Tk_Offset(BitmapMarker, axes.y), 0, &yAxisObjOption, 0},
+ "y", -1, Tk_Offset(BitmapMarkerOptions, axes.y), 0, &yAxisObjOption, 0},
{TK_OPTION_SYNONYM, "-outline", NULL, NULL, NULL, -1, 0, 0, "-foreground", 0},
{TK_OPTION_STRING_TABLE, "-state", "state", "State",
- "normal", -1, Tk_Offset(BitmapMarker, state), 0, &stateObjOption, 0},
+ "normal", -1, Tk_Offset(BitmapMarkerOptions, state), 0, &stateObjOption, 0},
{TK_OPTION_BOOLEAN, "-under", "under", "Under",
- "no", -1, Tk_Offset(BitmapMarker, drawUnder), 0, NULL, 0},
+ "no", -1, Tk_Offset(BitmapMarkerOptions, drawUnder), 0, NULL, 0},
{TK_OPTION_PIXELS, "-xoffset", "xOffset", "XOffset",
- "0", -1, Tk_Offset(BitmapMarker, xOffset), 0, NULL, 0},
+ "0", -1, Tk_Offset(BitmapMarkerOptions, xOffset), 0, NULL, 0},
{TK_OPTION_PIXELS, "-yoffset", "yOffset", "YOffset",
- "0", -1, Tk_Offset(BitmapMarker, yOffset), 0, NULL, 0},
+ "0", -1, Tk_Offset(BitmapMarkerOptions, yOffset), 0, NULL, 0},
{TK_OPTION_END, NULL, NULL, NULL, NULL, -1, 0, 0, NULL, 0}
};
@@ -97,6 +102,8 @@ Marker* Blt_CreateBitmapProc(Graph* graphPtr)
{
BitmapMarker* bmPtr = (BitmapMarker*)calloc(1, sizeof(BitmapMarker));
bmPtr->classPtr = &bitmapMarkerClass;
+ bmPtr->ops = (BitmapMarkerOptions*)calloc(1, sizeof(BitmapMarkerOptions));
+
bmPtr->optionTable = Tk_CreateOptionTable(graphPtr->interp, optionSpecs);
return (Marker*)bmPtr;
@@ -107,24 +114,24 @@ static int ConfigureBitmapProc(Marker* markerPtr)
Graph* graphPtr = markerPtr->obj.graphPtr;
BitmapMarker* bmPtr = (BitmapMarker*)markerPtr;
- if (bmPtr->bitmap == None)
+ if (bmPtr->ops->bitmap == None)
return TCL_OK;
XGCValues gcValues;
unsigned long gcMask = 0;
- if (bmPtr->outlineColor) {
+ if (bmPtr->ops->outlineColor) {
gcMask |= GCForeground;
- gcValues.foreground = bmPtr->outlineColor->pixel;
+ gcValues.foreground = bmPtr->ops->outlineColor->pixel;
}
- if (bmPtr->fillColor) {
+ if (bmPtr->ops->fillColor) {
// Opaque bitmap: both foreground and background (fill) colors are used
- gcValues.background = bmPtr->fillColor->pixel;
+ gcValues.background = bmPtr->ops->fillColor->pixel;
gcMask |= GCBackground;
}
else {
// Transparent bitmap: set the clip mask to the current bitmap
- gcValues.clip_mask = bmPtr->bitmap;
+ gcValues.clip_mask = bmPtr->ops->bitmap;
gcMask |= GCClipMask;
}
@@ -138,8 +145,8 @@ static int ConfigureBitmapProc(Marker* markerPtr)
bmPtr->gc = newGC;
// Create the background GC containing the fill color
- if (bmPtr->fillColor) {
- gcValues.foreground = bmPtr->fillColor->pixel;
+ if (bmPtr->ops->fillColor) {
+ gcValues.foreground = bmPtr->ops->fillColor->pixel;
newGC = Tk_GetGC(graphPtr->tkwin, gcMask, &gcValues);
if (bmPtr->fillGC)
Tk_FreeGC(graphPtr->display, bmPtr->fillGC);
@@ -147,7 +154,7 @@ static int ConfigureBitmapProc(Marker* markerPtr)
}
markerPtr->flags |= MAP_ITEM;
- if (markerPtr->drawUnder)
+ if (markerPtr->ops->drawUnder)
graphPtr->flags |= CACHE_DIRTY;
Blt_EventuallyRedrawGraph(graphPtr);
@@ -159,20 +166,21 @@ static void MapBitmapProc(Marker* markerPtr)
BitmapMarker* bmPtr = (BitmapMarker*)markerPtr;
Graph* graphPtr = markerPtr->obj.graphPtr;
- if (bmPtr->bitmap == None)
+ if (bmPtr->ops->bitmap == None)
return;
- if (!bmPtr->worldPts || (bmPtr->worldPts->num < 1))
+ if (!bmPtr->ops->worldPts || (bmPtr->ops->worldPts->num < 1))
return;
int width, height;
- Tk_SizeOfBitmap(graphPtr->display, bmPtr->bitmap, &width, &height);
+ Tk_SizeOfBitmap(graphPtr->display, bmPtr->ops->bitmap, &width, &height);
- Point2d anchorPt = Blt_MapPoint(bmPtr->worldPts->points, &markerPtr->axes);
+ Point2d anchorPt =
+ Blt_MapPoint(bmPtr->ops->worldPts->points, &markerPtr->ops->axes);
anchorPt = Blt_AnchorPoint(anchorPt.x, anchorPt.y, width, height,
- bmPtr->anchor);
- anchorPt.x += markerPtr->xOffset;
- anchorPt.y += markerPtr->yOffset;
+ bmPtr->ops->anchor);
+ anchorPt.x += markerPtr->ops->xOffset;
+ anchorPt.y += markerPtr->ops->yOffset;
Region2d extents;
extents.left = anchorPt.x;
@@ -216,7 +224,7 @@ static int PointInBitmapProc(Marker* markerPtr, Point2d *samplePtr)
{
BitmapMarker* bmPtr = (BitmapMarker*)markerPtr;
- if (bmPtr->bitmap == None)
+ if (bmPtr->ops->bitmap == None)
return 0;
return ((samplePtr->x >= bmPtr->anchorPt.x) &&
@@ -247,11 +255,11 @@ static void DrawBitmapProc(Marker* markerPtr, Drawable drawable)
{
Graph* graphPtr = markerPtr->obj.graphPtr;
BitmapMarker* bmPtr = (BitmapMarker*)markerPtr;
- if ((bmPtr->bitmap == None) || (bmPtr->width < 1) || (bmPtr->height < 1))
+ if ((bmPtr->ops->bitmap == None) || (bmPtr->width < 1) || (bmPtr->height < 1))
return;
- if (bmPtr->fillColor == NULL) {
- XSetClipMask(graphPtr->display, bmPtr->gc, bmPtr->bitmap);
+ if (bmPtr->ops->fillColor == NULL) {
+ XSetClipMask(graphPtr->display, bmPtr->gc, bmPtr->ops->bitmap);
XSetClipOrigin(graphPtr->display, bmPtr->gc, bmPtr->anchorPt.x,
bmPtr->anchorPt.y);
}
@@ -259,7 +267,7 @@ static void DrawBitmapProc(Marker* markerPtr, Drawable drawable)
XSetClipMask(graphPtr->display, bmPtr->gc, None);
XSetClipOrigin(graphPtr->display, bmPtr->gc, 0, 0);
}
- XCopyPlane(graphPtr->display, bmPtr->bitmap, drawable, bmPtr->gc, 0, 0,
+ XCopyPlane(graphPtr->display, bmPtr->ops->bitmap, drawable, bmPtr->gc, 0, 0,
bmPtr->width, bmPtr->height, bmPtr->anchorPt.x,
bmPtr->anchorPt.y, 1);
}
@@ -268,14 +276,14 @@ static void BitmapToPostscriptProc(Marker* markerPtr, Blt_Ps ps)
{
Graph* graphPtr = markerPtr->obj.graphPtr;
BitmapMarker* bmPtr = (BitmapMarker*)markerPtr;
- if ((bmPtr->bitmap == None) || (bmPtr->width < 1) || (bmPtr->height < 1))
+ if ((bmPtr->ops->bitmap == None) || (bmPtr->width < 1) || (bmPtr->height < 1))
return;
- if (bmPtr->fillColor) {
- Blt_Ps_XSetBackground(ps, bmPtr->fillColor);
+ if (bmPtr->ops->fillColor) {
+ Blt_Ps_XSetBackground(ps, bmPtr->ops->fillColor);
Blt_Ps_XFillPolygon(ps, bmPtr->outline, 4);
}
- Blt_Ps_XSetForeground(ps, bmPtr->outlineColor);
+ Blt_Ps_XSetForeground(ps, bmPtr->ops->outlineColor);
Blt_Ps_Format(ps,
" gsave\n %g %g translate\n %d %d scale\n",
@@ -284,7 +292,7 @@ static void BitmapToPostscriptProc(Marker* markerPtr, Blt_Ps ps)
Blt_Ps_Format(ps, " %d %d true [%d 0 0 %d 0 %d] {",
bmPtr->width, bmPtr->height, bmPtr->width,
-bmPtr->height, bmPtr->height);
- Blt_Ps_XSetBitmapData(ps, graphPtr->display, bmPtr->bitmap,
+ Blt_Ps_XSetBitmapData(ps, graphPtr->display, bmPtr->ops->bitmap,
bmPtr->width, bmPtr->height);
Blt_Ps_VarAppend(ps,
" } imagemask\n",
@@ -301,5 +309,8 @@ static void FreeBitmapProc(Marker* markerPtr)
if (bmPtr->fillGC)
Tk_FreeGC(graphPtr->display, bmPtr->fillGC);
+
+ if (bmPtr->ops)
+ free(bmPtr->ops);
}
diff --git a/bltGrMarkerBitmap.h b/bltGrMarkerBitmap.h
index 01e005b..e674351 100644
--- a/bltGrMarkerBitmap.h
+++ b/bltGrMarkerBitmap.h
@@ -32,6 +32,22 @@
#include "bltGrMarker.h"
+typedef struct {
+ Coords* worldPts;
+ const char* elemName;
+ Axis2d axes;
+ int hide;
+ int state;
+ int drawUnder;
+ int xOffset;
+ int yOffset;
+
+ Tk_Anchor anchor;
+ Pixmap bitmap;
+ XColor* fillColor;
+ XColor* outlineColor;
+} BitmapMarkerOptions;
+
class BitmapMarker {
public:
GraphObj obj;
@@ -42,29 +58,17 @@ class BitmapMarker {
int clipped;
unsigned int flags;
- Coords* worldPts;
- const char* elemName;
- Axis2d axes;
- int hide;
- int state;
- int drawUnder;
- int xOffset;
- int yOffset;
+ BitmapMarkerOptions* ops;
// Fields specific to bitmap
+ Point2d anchorPt;
GC gc;
GC fillGC;
Point2d outline[MAX_OUTLINE_POINTS];
int nOutlinePts;
int width;
int height;
-
- Tk_Anchor anchor;
- Pixmap bitmap;
- Point2d anchorPt;
- XColor* fillColor;
- XColor* outlineColor;
};
#endif
diff --git a/configure b/configure
index c0c8784..d3389d7 100755
--- a/configure
+++ b/configure
@@ -5527,7 +5527,6 @@ done
vars="
bltBind.C
- bltBitmap.C
bltChain.C
bltConfig.C
bltGrAxis.C
diff --git a/configure.in b/configure.in
index 09a43e5..16edbcc 100755
--- a/configure.in
+++ b/configure.in
@@ -72,7 +72,6 @@ TEA_SETUP_COMPILER
#-----------------------------------------------------------------------
TEA_ADD_SOURCES([
bltBind.C
- bltBitmap.C
bltChain.C
bltConfig.C
bltGrAxis.C
diff --git a/src/bltGrBind.C b/src/bltGrBind.C
index 54d9fbc..fe4e803 100644
--- a/src/bltGrBind.C
+++ b/src/bltGrBind.C
@@ -32,6 +32,8 @@ extern "C" {
#include "bltBind.h"
};
+#define MAX_STATIC_TAGS 64
+
static Tk_EventProc BindProc;
typedef struct _Blt_BindTable BindTable;
@@ -57,10 +59,7 @@ typedef struct _Blt_BindTable BindTable;
PointerMotionMask | VirtualEventMask)
static int buttonMasks[] =
- {
- 0, /* No buttons pressed */
- Button1Mask, Button2Mask, Button3Mask, Button4Mask, Button5Mask,
- };
+ {0, Button1Mask, Button2Mask, Button3Mask, Button4Mask, Button5Mask};
/*
@@ -91,52 +90,40 @@ typedef struct _Blt_BindTable BindTable;
*
*---------------------------------------------------------------------------
*/
-static void
-DoEvent(
- BindTable *bindPtr, /* Binding information for widget in which
- * event occurred. */
- XEvent *eventPtr, /* Real or simulated X event that is to be
- * processed. */
- ClientData item, /* Item picked. */
- ClientData context) /* Context of item. */
+static void DoEvent(BindTable *bindPtr, XEvent *eventPtr,
+ ClientData item, ClientData context)
{
Blt_List tagList;
- if ((bindPtr->tkwin == NULL) || (bindPtr->bindingTable == NULL)) {
+ if (!bindPtr->tkwin || !bindPtr->bindingTable)
return;
- }
+
if ((eventPtr->type == KeyPress) || (eventPtr->type == KeyRelease)) {
item = bindPtr->focusItem;
context = bindPtr->focusContext;
}
- if (item == NULL) {
+ if (!item)
return;
- }
- /*
- * Invoke the binding system.
- */
+
+ // Invoke the binding system.
tagList = Blt_List_Create(BLT_ONE_WORD_KEYS);
if (bindPtr->tagProc == NULL) {
Blt_List_Append(tagList, Tk_GetUid("all"), 0);
Blt_List_Append(tagList, (char *)item, 0);
- } else {
- (*bindPtr->tagProc) (bindPtr, item, context, tagList);
}
+ else
+ (*bindPtr->tagProc) (bindPtr, item, context, tagList);
+
if (Blt_List_GetLength(tagList) > 0) {
- int nTags;
- ClientData *tagArray;
-#define MAX_STATIC_TAGS 64
ClientData staticTags[MAX_STATIC_TAGS];
- Blt_ListNode node;
-
- tagArray = staticTags;
- nTags = Blt_List_GetLength(tagList);
+ ClientData *tagArray = staticTags;
+ int nTags = Blt_List_GetLength(tagList);
if (nTags >= MAX_STATIC_TAGS) {
tagArray = (ClientData*)malloc(sizeof(ClientData) * nTags);
}
nTags = 0;
- for (node = Blt_List_FirstNode(tagList); node != NULL;
+ for (Blt_ListNode node = Blt_List_FirstNode(tagList); node != NULL;
node = Blt_List_NextNode(node)) {
tagArray[nTags++] = (ClientData)Blt_List_GetKey(node);
}
@@ -149,48 +136,18 @@ DoEvent(
Blt_List_Destroy(tagList);
}
-/*
- *---------------------------------------------------------------------------
- *
- * PickCurrentItem --
- *
- * Find the topmost item in a legend that contains a given location and
- * mark the the current item. If the current item has changed, generate
- * a fake exit event on the old current item and a fake enter event on
- * the new current item.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The current item may change. If it does, then the commands associated
- * with item entry and exit could do just about anything. A binding
- * script could delete the legend, so callers should protect themselves
- * with Tcl_Preserve and Tcl_Release.
- *
- *---------------------------------------------------------------------------
- */
-static void
-PickCurrentItem(
- BindTable *bindPtr, /* Binding table information. */
- XEvent *eventPtr) /* Event describing location of mouse cursor.
- * Must be EnterWindow, LeaveWindow,
- * ButtonRelease, or MotionNotify. */
+static void PickCurrentItem(BindTable *bindPtr, XEvent *eventPtr)
{
- int buttonDown;
ClientData newItem, oldItem;
ClientData newContext;
- /*
- * Check whether or not a button is down. If so, we'll log entry and exit
- * into and out of the current item, but not entry into any other item.
- * This implements a form of grabbing equivalent to what the X server does
- * for windows.
- */
- buttonDown = (bindPtr->state & ALL_BUTTONS_MASK);
- if (!buttonDown) {
+ // Check whether or not a button is down. If so, we'll log entry and exit
+ // into and out of the current item, but not entry into any other item.
+ // This implements a form of grabbing equivalent to what the X server does
+ // for windows.
+ int buttonDown = (bindPtr->state & ALL_BUTTONS_MASK);
+ if (!buttonDown)
bindPtr->flags &= ~LEFT_GRABBED_ITEM;
- }
/*
* Save information about this event in the widget. The event in the
@@ -238,9 +195,9 @@ PickCurrentItem(
* handler for the old current item) then just return; the pending call
* will do everything that's needed.
*/
- if (bindPtr->flags & REPICK_IN_PROGRESS) {
+ if (bindPtr->flags & REPICK_IN_PROGRESS)
return;
- }
+
/*
* A LeaveNotify event automatically means that there's no current item,
* so the check for closest item can be skipped.
@@ -252,17 +209,16 @@ PickCurrentItem(
x = bindPtr->pickEvent.xcrossing.x;
y = bindPtr->pickEvent.xcrossing.y;
newItem = (*bindPtr->pickProc) (bindPtr->clientData, x, y, &newContext);
- } else {
- newItem = NULL;
}
+ else
+ newItem = NULL;
+
+ // Nothing to do: the current item hasn't changed.
if (((newItem == bindPtr->currentItem) &&
(newContext == bindPtr->currentContext)) &&
- ((bindPtr->flags & LEFT_GRABBED_ITEM) == 0)) {
- /*
- * Nothing to do: the current item hasn't changed.
- */
+ ((bindPtr->flags & LEFT_GRABBED_ITEM) == 0))
return;
- }
+
/*
* Simulate a LeaveNotify event on the previous current item and an
* EnterNotify event on the new current item. Remove the "current" tag
@@ -437,80 +393,17 @@ static void BindProc(ClientData clientData, XEvent *eventPtr)
Tcl_Release(bindPtr->clientData);
}
-int Blt_ConfigureBindings(
- Tcl_Interp* interp,
- BindTable *bindPtr,
- ClientData item,
- int argc,
- const char **argv)
+int Blt_ConfigureBindingsFromObj(Tcl_Interp* interp, BindTable *bindPtr,
+ ClientData item, int objc,
+ Tcl_Obj* const objv[])
{
- const char *command;
- unsigned long mask;
- const char *seq;
-
- if (argc == 0) {
+ if (objc == 0) {
Tk_GetAllBindings(interp, bindPtr->bindingTable, item);
return TCL_OK;
}
- if (argc == 1) {
- command = Tk_GetBinding(interp, bindPtr->bindingTable, item, argv[0]);
- if (command == NULL) {
- Tcl_AppendResult(interp, "can't find event \"", argv[0], "\"",
- (char *)NULL);
- return TCL_ERROR;
- }
- Tcl_SetStringObj(Tcl_GetObjResult(interp), command, -1);
- return TCL_OK;
- }
-
- seq = argv[0];
- command = argv[1];
-
- if (command[0] == '\0') {
- return Tk_DeleteBinding(interp, bindPtr->bindingTable, item, seq);
- }
-
- if (command[0] == '+') {
- mask = Tk_CreateBinding(interp, bindPtr->bindingTable, item, seq,
- command + 1, TRUE);
- } else {
- mask = Tk_CreateBinding(interp, bindPtr->bindingTable, item, seq,
- command, FALSE);
- }
- if (mask == 0) {
- Tcl_AppendResult(interp, "event mask can't be zero for \"", item, "\"",
- (char *)NULL);
- return TCL_ERROR;
- }
- if (mask & (unsigned)~ALL_VALID_EVENTS_MASK) {
- Tk_DeleteBinding(interp, bindPtr->bindingTable, item, seq);
- Tcl_ResetResult(interp);
- Tcl_AppendResult(interp, "requested illegal events; ",
- "only key, button, motion, enter, leave, and virtual ",
- "events may be used", (char *)NULL);
- return TCL_ERROR;
- }
- return TCL_OK;
-}
-
-int Blt_ConfigureBindingsFromObj(
- Tcl_Interp* interp,
- BindTable *bindPtr,
- ClientData item,
- int objc,
- Tcl_Obj* const objv[])
-{
+ const char *string = Tcl_GetString(objv[0]);
const char *command;
- unsigned long mask;
- const char *seq;
- const char *string;
-
- if (objc == 0) {
- Tk_GetAllBindings(interp, bindPtr->bindingTable, item);
- return TCL_OK;
- }
- string = Tcl_GetString(objv[0]);
if (objc == 1) {
command = Tk_GetBinding(interp, bindPtr->bindingTable, item, string);
if (command == NULL) {
@@ -523,23 +416,23 @@ int Blt_ConfigureBindingsFromObj(
return TCL_OK;
}
- seq = string;
+ const char *seq = string;
command = Tcl_GetString(objv[1]);
- if (command[0] == '\0') {
+ if (command[0] == '\0')
return Tk_DeleteBinding(interp, bindPtr->bindingTable, item, seq);
- }
- if (command[0] == '+') {
+ unsigned long mask;
+ if (command[0] == '+')
mask = Tk_CreateBinding(interp, bindPtr->bindingTable, item, seq,
command + 1, TRUE);
- } else {
+ else
mask = Tk_CreateBinding(interp, bindPtr->bindingTable, item, seq,
command, FALSE);
- }
- if (mask == 0) {
+
+ if (mask == 0)
return TCL_ERROR;
- }
+
if (mask & (unsigned)~ALL_VALID_EVENTS_MASK) {
Tk_DeleteBinding(interp, bindPtr->bindingTable, item, seq);
Tcl_ResetResult(interp);
@@ -548,40 +441,35 @@ int Blt_ConfigureBindingsFromObj(
"events may be used", (char *)NULL);
return TCL_ERROR;
}
+
return TCL_OK;
}
-Blt_BindTable Blt_CreateBindingTable(
- Tcl_Interp* interp,
- Tk_Window tkwin,
- ClientData clientData,
- Blt_BindPickProc *pickProc,
- Blt_BindTagProc *tagProc)
+Blt_BindTable Blt_CreateBindingTable(Tcl_Interp* interp, Tk_Window tkwin,
+ ClientData clientData,
+ Blt_BindPickProc *pickProc,
+ Blt_BindTagProc *tagProc)
{
- unsigned int mask;
- BindTable *bindPtr;
-
- bindPtr = (BindTable*)calloc(1, sizeof(BindTable));
+ BindTable *bindPtr = (BindTable*)calloc(1, sizeof(BindTable));
bindPtr->bindingTable = Tk_CreateBindingTable(interp);
bindPtr->clientData = clientData;
bindPtr->tkwin = tkwin;
bindPtr->pickProc = pickProc;
bindPtr->tagProc = tagProc;
- mask = (KeyPressMask | KeyReleaseMask | ButtonPressMask |
- ButtonReleaseMask | EnterWindowMask | LeaveWindowMask |
- PointerMotionMask);
+ unsigned int mask = (KeyPressMask | KeyReleaseMask | ButtonPressMask |
+ ButtonReleaseMask | EnterWindowMask | LeaveWindowMask |
+ PointerMotionMask);
Tk_CreateEventHandler(tkwin, mask, BindProc, bindPtr);
+
return bindPtr;
}
void Blt_DestroyBindingTable(BindTable *bindPtr)
{
- unsigned int mask;
-
Tk_DeleteBindingTable(bindPtr->bindingTable);
- mask = (KeyPressMask | KeyReleaseMask | ButtonPressMask |
- ButtonReleaseMask | EnterWindowMask | LeaveWindowMask |
- PointerMotionMask);
+ unsigned int mask = (KeyPressMask | KeyReleaseMask | ButtonPressMask |
+ ButtonReleaseMask | EnterWindowMask | LeaveWindowMask |
+ PointerMotionMask);
Tk_DeleteEventHandler(bindPtr->tkwin, mask, BindProc, bindPtr);
free(bindPtr);
bindPtr = NULL;
@@ -589,9 +477,8 @@ void Blt_DestroyBindingTable(BindTable *bindPtr)
void Blt_PickCurrentItem(BindTable *bindPtr)
{
- if (bindPtr->activePick) {
+ if (bindPtr->activePick)
PickCurrentItem(bindPtr, &bindPtr->pickEvent);
- }
}
void Blt_DeleteBindings(BindTable *bindPtr, ClientData object)
@@ -615,14 +502,12 @@ void Blt_DeleteBindings(BindTable *bindPtr, ClientData object)
void Blt_MoveBindingTable(BindTable *bindPtr, Tk_Window tkwin)
{
- unsigned int mask;
-
- mask = (KeyPressMask | KeyReleaseMask | ButtonPressMask |
- ButtonReleaseMask | EnterWindowMask | LeaveWindowMask |
- PointerMotionMask);
- if (bindPtr->tkwin != NULL) {
+ unsigned int mask = (KeyPressMask | KeyReleaseMask | ButtonPressMask |
+ ButtonReleaseMask | EnterWindowMask | LeaveWindowMask |
+ PointerMotionMask);
+ if (bindPtr->tkwin != NULL)
Tk_DeleteEventHandler(bindPtr->tkwin, mask, BindProc, bindPtr);
- }
+
Tk_CreateEventHandler(tkwin, mask, BindProc, bindPtr);
bindPtr->tkwin = tkwin;
}
diff --git a/src/bltGrBind.h b/src/bltGrBind.h
index 57197b2..7a04eed 100644
--- a/src/bltGrBind.h
+++ b/src/bltGrBind.h
@@ -95,9 +95,6 @@ extern Blt_BindTable Blt_CreateBindingTable(Tcl_Interp* interp,
Tk_Window tkwin, ClientData clientData, Blt_BindPickProc *pickProc,
Blt_BindTagProc *tagProc);
-extern int Blt_ConfigureBindings(Tcl_Interp* interp, Blt_BindTable table,
- ClientData item, int argc, const char **argv);
-
extern int Blt_ConfigureBindingsFromObj(Tcl_Interp* interp,
Blt_BindTable table, ClientData item, int objc, Tcl_Obj *const *objv);
diff --git a/src/bltGrElemLine.C b/src/bltGrElemLine.C
index dbb0d99..907ef82 100644
--- a/src/bltGrElemLine.C
+++ b/src/bltGrElemLine.C
@@ -2887,18 +2887,14 @@ static void DrawSymbols(Graph* graphPtr, Drawable drawable,
case SYMBOL_BITMAP:
{
- Pixmap bitmap, mask;
int w, h, bw, bh;
double scale, sx, sy;
int dx, dy;
Tk_SizeOfBitmap(graphPtr->display, penPtr->symbol.bitmap, &w, &h);
- mask = None;
- /*
- * Compute the size of the scaled bitmap. Stretch the bitmap to fit
- * a nxn bounding box.
- */
+ // Compute the size of the scaled bitmap. Stretch the bitmap to fit
+ // a nxn bounding box.
sx = (double)size / (double)w;
sy = (double)size / (double)h;
scale = MIN(sx, sy);
@@ -2906,57 +2902,46 @@ static void DrawSymbols(Graph* graphPtr, Drawable drawable,
bh = (int)(h * scale);
XSetClipMask(graphPtr->display, penPtr->symbol.outlineGC, None);
- if (penPtr->symbol.mask != None) {
- mask = Blt_ScaleBitmap(graphPtr->tkwin, penPtr->symbol.mask,
- w, h, bw, bh);
- XSetClipMask(graphPtr->display, penPtr->symbol.outlineGC, mask);
- }
- bitmap = Blt_ScaleBitmap(graphPtr->tkwin, penPtr->symbol.bitmap,
- w, h, bw, bh);
- if (penPtr->symbol.fillGC == NULL) {
+ if (penPtr->symbol.mask != None)
+ XSetClipMask(graphPtr->display, penPtr->symbol.outlineGC,
+ penPtr->symbol.mask);
+
+ if (penPtr->symbol.fillGC == NULL)
XSetClipMask(graphPtr->display, penPtr->symbol.outlineGC,
- bitmap);
- }
+ penPtr->symbol.bitmap);
+
dx = bw / 2;
dy = bh / 2;
+
if (elemPtr->symbolInterval > 0) {
Point2d *pp, *endp;
-
for (pp = symbolPts, endp = pp + nSymbolPts; pp < endp; pp++) {
if (DRAW_SYMBOL(elemPtr)) {
- int x, y;
-
- x = Round(pp->x) - dx;
- y = Round(pp->y) - dy;
- if ((penPtr->symbol.fillGC == NULL) || (mask != None)) {
+ int x = Round(pp->x) - dx;
+ int y = Round(pp->y) - dy;
+ if ((penPtr->symbol.fillGC == NULL) ||
+ (penPtr->symbol.mask != None))
XSetClipOrigin(graphPtr->display,
penPtr->symbol.outlineGC, x, y);
- }
- XCopyPlane(graphPtr->display, bitmap, drawable,
+ XCopyPlane(graphPtr->display, penPtr->symbol.bitmap, drawable,
penPtr->symbol.outlineGC, 0, 0, bw, bh, x, y, 1);
}
elemPtr->symbolCounter++;
}
- } else {
+ }
+ else {
Point2d *pp, *endp;
-
for (pp = symbolPts, endp = pp + nSymbolPts; pp < endp; pp++) {
- int x, y;
-
- x = Round(pp->x) - dx;
- y = Round(pp->y) - dy;
- if ((penPtr->symbol.fillGC == NULL) || (mask != None)) {
+ int x = Round(pp->x) - dx;
+ int y = Round(pp->y) - dy;
+ if ((penPtr->symbol.fillGC == NULL) ||
+ (penPtr->symbol.mask != None))
XSetClipOrigin(graphPtr->display,
penPtr->symbol.outlineGC, x, y);
- }
- XCopyPlane(graphPtr->display, bitmap, drawable,
+ XCopyPlane(graphPtr->display, penPtr->symbol.bitmap, drawable,
penPtr->symbol.outlineGC, 0, 0, bw, bh, x, y, 1);
}
}
- Tk_FreePixmap(graphPtr->display, bitmap);
- if (mask != None) {
- Tk_FreePixmap(graphPtr->display, mask);
- }
}
break;
}
diff --git a/src/bltGrMarker.C b/src/bltGrMarker.C
index 626766b..a92abd6 100644
--- a/src/bltGrMarker.C
+++ b/src/bltGrMarker.C
@@ -273,12 +273,11 @@ static int CreateMarker(Graph* graphPtr, Tcl_Interp* interp,
markerPtr->obj.name = Blt_Strdup(name);
markerPtr->obj.graphPtr = graphPtr;
- markerPtr->drawUnder = FALSE;
markerPtr->hashPtr = hPtr;
Tcl_SetHashValue(hPtr, markerPtr);
- if ((Tk_InitOptions(graphPtr->interp, (char*)markerPtr, markerPtr->optionTable, graphPtr->tkwin) != TCL_OK) || (MarkerObjConfigure(interp, graphPtr, markerPtr, objc-offset, objv+offset) != TCL_OK)) {
+ if ((Tk_InitOptions(graphPtr->interp, (char*)markerPtr->ops, markerPtr->optionTable, graphPtr->tkwin) != TCL_OK) || (MarkerObjConfigure(interp, graphPtr, markerPtr, objc-offset, objv+offset) != TCL_OK)) {
DestroyMarker(markerPtr);
return TCL_ERROR;
}
@@ -296,7 +295,7 @@ static void DestroyMarker(Marker *markerPtr)
// If the marker to be deleted is currently displayed below the
// elements, then backing store needs to be repaired.
- if (markerPtr->drawUnder)
+ if (markerPtr->ops->drawUnder)
graphPtr->flags |= CACHE_DIRTY;
// Call the marker's type-specific deallocation routine. We do it first
@@ -314,7 +313,7 @@ static void DestroyMarker(Marker *markerPtr)
if (markerPtr->link)
Blt_Chain_DeleteLink(graphPtr->markers.displayList, markerPtr->link);
- Tk_FreeConfigOptions((char*)markerPtr, markerPtr->optionTable,
+ Tk_FreeConfigOptions((char*)markerPtr->ops, markerPtr->optionTable,
graphPtr->tkwin);
free(markerPtr);
@@ -329,7 +328,7 @@ static int CgetOp(Graph* graphPtr, Tcl_Interp* interp,
if (GetMarkerFromObj(interp, graphPtr, objv[3], &markerPtr) != TCL_OK)
return TCL_ERROR;
- Tcl_Obj* objPtr = Tk_GetOptionValue(interp, (char*)markerPtr,
+ Tcl_Obj* objPtr = Tk_GetOptionValue(interp, (char*)markerPtr->ops,
markerPtr->optionTable,
objv[4], graphPtr->tkwin);
if (objPtr == NULL)
@@ -347,7 +346,7 @@ static int ConfigureOp(Graph* graphPtr, Tcl_Interp* interp,
return TCL_ERROR;
if (objc <= 5) {
- Tcl_Obj* objPtr = Tk_GetOptionInfo(graphPtr->interp, (char*)markerPtr,
+ Tcl_Obj* objPtr = Tk_GetOptionInfo(graphPtr->interp, (char*)markerPtr->ops,
markerPtr->optionTable,
(objc == 5) ? objv[4] : NULL,
graphPtr->tkwin);
@@ -372,7 +371,7 @@ static int MarkerObjConfigure( Tcl_Interp* interp, Graph* graphPtr,
for (error=0; error<=1; error++) {
if (!error) {
- if (Tk_SetOptions(interp, (char*)markerPtr, markerPtr->optionTable,
+ if (Tk_SetOptions(interp, (char*)markerPtr->ops, markerPtr->optionTable,
objc, objv, graphPtr->tkwin, &savedOptions, &mask)
!= TCL_OK)
continue;
@@ -512,7 +511,7 @@ static int FindOp(Graph* graphPtr, Tcl_Interp* interp,
for (Blt_ChainLink link = Blt_Chain_FirstLink(graphPtr->markers.displayList);
link; link = Blt_Chain_NextLink(link)) {
Marker* markerPtr = (Marker*)Blt_Chain_GetValue(link);
- if ((markerPtr->flags & DELETE_PENDING) || markerPtr->hide) {
+ if ((markerPtr->flags & DELETE_PENDING) || markerPtr->ops->hide) {
continue;
}
if (IsElementHidden(markerPtr))
@@ -602,7 +601,7 @@ static int RelinkOp(Graph* graphPtr, Tcl_Interp* interp,
else
Blt_Chain_LinkBefore(graphPtr->markers.displayList, link, place);
- if (markerPtr->drawUnder)
+ if (markerPtr->ops->drawUnder)
graphPtr->flags |= CACHE_DIRTY;
Blt_EventuallyRedrawGraph(graphPtr);
@@ -672,8 +671,8 @@ static int IsElementHidden(Marker *markerPtr)
Tcl_HashEntry *hPtr;
Graph* graphPtr = markerPtr->obj.graphPtr;
- if (markerPtr->elemName) {
- hPtr = Tcl_FindHashEntry(&graphPtr->elements.table, markerPtr->elemName);
+ if (markerPtr->ops->elemName) {
+ hPtr = Tcl_FindHashEntry(&graphPtr->elements.table, markerPtr->ops->elemName);
if (hPtr) {
Element* elemPtr = (Element*)Tcl_GetHashValue(hPtr);
if (!elemPtr->link || elemPtr->hide)
@@ -769,10 +768,10 @@ void Blt_MarkersToPostScript(Graph* graphPtr, Blt_Ps ps, int under)
if (markerPtr->classPtr->postscriptProc == NULL)
continue;
- if (markerPtr->drawUnder != under)
+ if (markerPtr->ops->drawUnder != under)
continue;
- if ((markerPtr->flags & DELETE_PENDING) || markerPtr->hide)
+ if ((markerPtr->flags & DELETE_PENDING) || markerPtr->ops->hide)
continue;
if (IsElementHidden(markerPtr))
@@ -790,10 +789,10 @@ void Blt_DrawMarkers(Graph* graphPtr, Drawable drawable, int under)
link; link = Blt_Chain_PrevLink(link)) {
Marker* markerPtr = (Marker*)Blt_Chain_GetValue(link);
- if ((markerPtr->drawUnder != under) ||
+ if ((markerPtr->ops->drawUnder != under) ||
(markerPtr->clipped) ||
(markerPtr->flags & DELETE_PENDING) ||
- (markerPtr->hide))
+ (markerPtr->ops->hide))
continue;
if (IsElementHidden(markerPtr))
@@ -818,7 +817,7 @@ void Blt_MapMarkers(Graph* graphPtr)
link; link = Blt_Chain_NextLink(link)) {
Marker *markerPtr = (Marker*)Blt_Chain_GetValue(link);
- if ((markerPtr->flags & DELETE_PENDING) || markerPtr->hide)
+ if ((markerPtr->flags & DELETE_PENDING) || markerPtr->ops->hide)
continue;
if ((graphPtr->flags & MAP_ALL) || (markerPtr->flags & MAP_ITEM)) {
@@ -853,19 +852,15 @@ Marker* Blt_NearestMarker(Graph* graphPtr, int x, int y, int under)
for (Blt_ChainLink link = Blt_Chain_FirstLink(graphPtr->markers.displayList);
link; link = Blt_Chain_NextLink(link)) {
Marker* markerPtr = (Marker*)Blt_Chain_GetValue(link);
- if ((markerPtr->flags & (DELETE_PENDING|MAP_ITEM)) || (markerPtr->hide))
- continue; /* Don't consider markers that are
- * pending to be mapped. Even if the
- * marker has already been mapped, the
- * coordinates could be invalid now.
- * Better to pick no marker than the
- * wrong marker. */
+ if ((markerPtr->flags & (DELETE_PENDING|MAP_ITEM)) ||
+ (markerPtr->ops->hide))
+ continue;
if (IsElementHidden(markerPtr))
continue;
- if ((markerPtr->drawUnder == under) &&
- (markerPtr->state == BLT_STATE_NORMAL))
+ if ((markerPtr->ops->drawUnder == under) &&
+ (markerPtr->ops->state == BLT_STATE_NORMAL))
if ((*markerPtr->classPtr->pointProc) (markerPtr, &point))
return markerPtr;
}
diff --git a/src/bltGrMarker.h b/src/bltGrMarker.h
index 8fc2f02..e823153 100644
--- a/src/bltGrMarker.h
+++ b/src/bltGrMarker.h
@@ -57,6 +57,17 @@ typedef struct {
int num;
} Coords;
+typedef struct {
+ Coords* worldPts;
+ const char* elemName;
+ Axis2d axes;
+ int hide;
+ int state;
+ int drawUnder;
+ int xOffset;
+ int yOffset;
+} MarkerOptions;
+
struct _Marker {
GraphObj obj;
MarkerClass *classPtr;
@@ -66,14 +77,7 @@ struct _Marker {
int clipped;
unsigned int flags;
- Coords* worldPts;
- const char* elemName;
- Axis2d axes;
- int hide;
- int state;
- int drawUnder;
- int xOffset;
- int yOffset;
+ MarkerOptions* ops;
};
Point2d Blt_MapPoint(Point2d *pointPtr, Axis2d *axesPtr);
diff --git a/src/bltGrMarkerLine.C b/src/bltGrMarkerLine.C
index 8fbc552..916f585 100644
--- a/src/bltGrMarkerLine.C
+++ b/src/bltGrMarkerLine.C
@@ -33,51 +33,53 @@ extern "C" {
#include "bltGrMarkerLine.h"
-// Defs
-
// OptionSpecs
static Tk_OptionSpec optionSpecs[] = {
- {TK_OPTION_CUSTOM, "-bindtags", "bindTags", "BindTags",
- "Line all", -1, Tk_Offset(LineMarker, obj.tags),
- TK_OPTION_NULL_OK, &listObjOption, 0},
+ // {TK_OPTION_CUSTOM, "-bindtags", "bindTags", "BindTags",
+ // "Line all", -1, Tk_Offset(LineMarkerOptions, obj.tags),
+ // TK_OPTION_NULL_OK, &listObjOption, 0},
{TK_OPTION_CUSTOM, "-cap", "cap", "Cap",
- "butt", -1, Tk_Offset(LineMarker, capStyle), 0, &capStyleObjOption, 0},
+ "butt", -1, Tk_Offset(LineMarkerOptions, capStyle),
+ 0, &capStyleObjOption, 0},
{TK_OPTION_CUSTOM, "-coords", "coords", "Coords",
- NULL, -1, Tk_Offset(LineMarker, worldPts),
+ NULL, -1, Tk_Offset(LineMarkerOptions, worldPts),
TK_OPTION_NULL_OK, &coordsObjOption, MAP_ITEM},
{TK_OPTION_CUSTOM, "-dashes", "dashes", "Dashes",
- NULL, -1, Tk_Offset(LineMarker, dashes),
+ NULL, -1, Tk_Offset(LineMarkerOptions, dashes),
TK_OPTION_NULL_OK, &dashesObjOption, 0},
{TK_OPTION_PIXELS, "-dashoffset", "dashOffset", "DashOffset",
- "0", -1, Tk_Offset(LineMarker, dashes.offset), 0, NULL, 0},
+ "0", -1, Tk_Offset(LineMarkerOptions, dashes.offset), 0, NULL, 0},
{TK_OPTION_STRING, "-element", "element", "Element",
- NULL, -1, Tk_Offset(LineMarker, elemName), TK_OPTION_NULL_OK, NULL, 0},
+ NULL, -1, Tk_Offset(LineMarkerOptions, elemName),
+ TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_COLOR, "-fill", "fill", "Fill",
- NULL, -1, Tk_Offset(LineMarker, fillColor), TK_OPTION_NULL_OK, NULL, 0},
+ NULL, -1, Tk_Offset(LineMarkerOptions, fillColor),
+ TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_CUSTOM, "-join", "join", "Join",
- "miter", -1, Tk_Offset(LineMarker, joinStyle), 0, &joinStyleObjOption, 0},
+ "miter", -1, Tk_Offset(LineMarkerOptions, joinStyle),
+ 0, &joinStyleObjOption, 0},
{TK_OPTION_PIXELS, "-linewidth", "lineWidth", "LineWidth",
- "1", -1, Tk_Offset(LineMarker, lineWidth), 0, NULL, 0},
+ "1", -1, Tk_Offset(LineMarkerOptions, lineWidth), 0, NULL, 0},
{TK_OPTION_BOOLEAN, "-hide", "hide", "Hide",
- "no", -1, Tk_Offset(LineMarker, hide), 0, NULL, 0},
+ "no", -1, Tk_Offset(LineMarkerOptions, hide), 0, NULL, 0},
{TK_OPTION_CUSTOM, "-mapx", "mapX", "MapX",
- "x", -1, Tk_Offset(LineMarker, axes.x), 0, &xAxisObjOption, 0},
+ "x", -1, Tk_Offset(LineMarkerOptions, axes.x), 0, &xAxisObjOption, 0},
{TK_OPTION_CUSTOM, "-mapy", "mapY", "MapY",
- "y", -1, Tk_Offset(LineMarker, axes.y), 0, &yAxisObjOption, 0},
+ "y", -1, Tk_Offset(LineMarkerOptions, axes.y), 0, &yAxisObjOption, 0},
{TK_OPTION_COLOR, "-outline", "outline", "Outline",
- STD_NORMAL_FOREGROUND, -1, Tk_Offset(LineMarker, outlineColor),
+ STD_NORMAL_FOREGROUND, -1, Tk_Offset(LineMarkerOptions, outlineColor),
TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_STRING_TABLE, "-state", "state", "State",
- "normal", -1, Tk_Offset(LineMarker, state), 0, &stateObjOption, 0},
+ "normal", -1, Tk_Offset(LineMarkerOptions, state), 0, &stateObjOption, 0},
{TK_OPTION_BOOLEAN, "-under", "under", "Under",
- "no", -1, Tk_Offset(LineMarker, drawUnder), 0, NULL, 0},
+ "no", -1, Tk_Offset(LineMarkerOptions, drawUnder), 0, NULL, 0},
{TK_OPTION_PIXELS, "-xoffset", "xOffset", "XOffset",
- "0", -1, Tk_Offset(LineMarker, xOffset), 0, NULL, 0},
+ "0", -1, Tk_Offset(LineMarkerOptions, xOffset), 0, NULL, 0},
{TK_OPTION_BOOLEAN, "-xor", "xor", "Xor",
- "no", -1, Tk_Offset(LineMarker, xorr), 0, NULL, 0},
+ "no", -1, Tk_Offset(LineMarkerOptions, xorr), 0, NULL, 0},
{TK_OPTION_PIXELS, "-yoffset", "yOffset", "YOffset",
- "0", -1, Tk_Offset(LineMarker, yOffset), 0, NULL, 0},
+ "0", -1, Tk_Offset(LineMarkerOptions, yOffset), 0, NULL, 0},
{TK_OPTION_END, NULL, NULL, NULL, NULL, -1, 0, 0, NULL, 0}
};
@@ -105,7 +107,9 @@ Marker* Blt_CreateLineProc(Graph* graphPtr)
{
LineMarker* lmPtr = (LineMarker*)calloc(1, sizeof(LineMarker));
lmPtr->classPtr = &lineMarkerClass;
- lmPtr->xorr = FALSE;
+ lmPtr->ops = (LineMarkerOptions*)calloc(1, sizeof(LineMarkerOptions));
+
+ lmPtr->ops->xorr = FALSE;
lmPtr->optionTable = Tk_CreateOptionTable(graphPtr->interp, optionSpecs);
return (Marker*)lmPtr;
@@ -123,15 +127,15 @@ static int RegionInLineProc(Marker *markerPtr, Region2d *extsPtr, int enclosed)
{
LineMarker *lmPtr = (LineMarker*)markerPtr;
- if (!lmPtr->worldPts || lmPtr->worldPts->num < 2)
+ if (!lmPtr->ops->worldPts || lmPtr->ops->worldPts->num < 2)
return FALSE;
if (enclosed) {
Point2d *pp, *pend;
- for (pp = lmPtr->worldPts->points, pend = pp + lmPtr->worldPts->num;
+ for (pp = lmPtr->ops->worldPts->points, pend = pp + lmPtr->ops->worldPts->num;
pp < pend; pp++) {
- Point2d p = Blt_MapPoint(pp, &markerPtr->axes);
+ Point2d p = Blt_MapPoint(pp, &markerPtr->ops->axes);
if ((p.x < extsPtr->left) && (p.x > extsPtr->right) &&
(p.y < extsPtr->top) && (p.y > extsPtr->bottom)) {
return FALSE;
@@ -142,10 +146,10 @@ static int RegionInLineProc(Marker *markerPtr, Region2d *extsPtr, int enclosed)
else {
Point2d *pp, *pend;
int count = 0;
- for (pp = lmPtr->worldPts->points, pend = pp + (lmPtr->worldPts->num - 1);
+ for (pp = lmPtr->ops->worldPts->points, pend = pp + (lmPtr->ops->worldPts->num - 1);
pp < pend; pp++) {
- Point2d p = Blt_MapPoint(pp, &markerPtr->axes);
- Point2d q = Blt_MapPoint(pp + 1, &markerPtr->axes);
+ Point2d p = Blt_MapPoint(pp, &markerPtr->ops->axes);
+ Point2d q = Blt_MapPoint(pp + 1, &markerPtr->ops->axes);
if (Blt_LineRectClip(extsPtr, &p, &q))
count++;
}
@@ -163,7 +167,7 @@ static void DrawLineProc(Marker *markerPtr, Drawable drawable)
Blt_Draw2DSegments(graphPtr->display, drawable, lmPtr->gc,
lmPtr->segments, lmPtr->nSegments);
- if (lmPtr->xorr)
+ if (lmPtr->ops->xorr)
lmPtr->xorState = (lmPtr->xorState == 0);
}
}
@@ -176,23 +180,23 @@ static int ConfigureLineProc(Marker *markerPtr)
Drawable drawable = Tk_WindowId(graphPtr->tkwin);
unsigned long gcMask = (GCLineWidth | GCLineStyle | GCCapStyle | GCJoinStyle);
XGCValues gcValues;
- if (lmPtr->outlineColor) {
+ if (lmPtr->ops->outlineColor) {
gcMask |= GCForeground;
- gcValues.foreground = lmPtr->outlineColor->pixel;
+ gcValues.foreground = lmPtr->ops->outlineColor->pixel;
}
- if (lmPtr->fillColor) {
+ if (lmPtr->ops->fillColor) {
gcMask |= GCBackground;
- gcValues.background = lmPtr->fillColor->pixel;
+ gcValues.background = lmPtr->ops->fillColor->pixel;
}
- gcValues.cap_style = lmPtr->capStyle;
- gcValues.join_style = lmPtr->joinStyle;
- gcValues.line_width = LineWidth(lmPtr->lineWidth);
+ gcValues.cap_style = lmPtr->ops->capStyle;
+ gcValues.join_style = lmPtr->ops->joinStyle;
+ gcValues.line_width = LineWidth(lmPtr->ops->lineWidth);
gcValues.line_style = LineSolid;
- if (LineIsDashed(lmPtr->dashes)) {
+ if (LineIsDashed(lmPtr->ops->dashes)) {
gcValues.line_style =
(gcMask & GCBackground) ? LineDoubleDash : LineOnOffDash;
}
- if (lmPtr->xorr) {
+ if (lmPtr->ops->xorr) {
unsigned long pixel;
gcValues.function = GXxor;
@@ -210,11 +214,11 @@ static int ConfigureLineProc(Marker *markerPtr)
if (lmPtr->gc)
Blt_FreePrivateGC(graphPtr->display, lmPtr->gc);
- if (LineIsDashed(lmPtr->dashes))
- Blt_SetDashes(graphPtr->display, newGC, &lmPtr->dashes);
+ if (LineIsDashed(lmPtr->ops->dashes))
+ Blt_SetDashes(graphPtr->display, newGC, &lmPtr->ops->dashes);
lmPtr->gc = newGC;
- if (lmPtr->xorr) {
+ if (lmPtr->ops->xorr) {
if (drawable != None) {
MapLineProc(markerPtr);
DrawLineProc(markerPtr, drawable);
@@ -222,7 +226,7 @@ static int ConfigureLineProc(Marker *markerPtr)
return TCL_OK;
}
markerPtr->flags |= MAP_ITEM;
- if (markerPtr->drawUnder)
+ if (markerPtr->ops->drawUnder)
graphPtr->flags |= CACHE_DIRTY;
Blt_EventuallyRedrawGraph(graphPtr);
@@ -234,21 +238,24 @@ static void LineToPostscriptProc(Marker *markerPtr, Blt_Ps ps)
LineMarker *lmPtr = (LineMarker*)markerPtr;
if (lmPtr->nSegments > 0) {
- Blt_Ps_XSetLineAttributes(ps, lmPtr->outlineColor,
- lmPtr->lineWidth, &lmPtr->dashes, lmPtr->capStyle,
- lmPtr->joinStyle);
- if ((LineIsDashed(lmPtr->dashes)) && (lmPtr->fillColor)) {
+ Blt_Ps_XSetLineAttributes(ps, lmPtr->ops->outlineColor,
+ lmPtr->ops->lineWidth,
+ &lmPtr->ops->dashes,
+ lmPtr->ops->capStyle,
+ lmPtr->ops->joinStyle);
+ if ((LineIsDashed(lmPtr->ops->dashes)) && (lmPtr->ops->fillColor)) {
Blt_Ps_Append(ps, "/DashesProc {\n gsave\n ");
- Blt_Ps_XSetBackground(ps, lmPtr->fillColor);
+ Blt_Ps_XSetBackground(ps, lmPtr->ops->fillColor);
Blt_Ps_Append(ps, " ");
Blt_Ps_XSetDashes(ps, (Blt_Dashes*)NULL);
Blt_Ps_VarAppend(ps,
"stroke\n",
" grestore\n",
"} def\n", (char*)NULL);
- } else {
+ }
+ else
Blt_Ps_Append(ps, "/DashesProc {} def\n");
- }
+
Blt_Ps_Draw2DSegments(ps, lmPtr->segments, lmPtr->nSegments);
}
}
@@ -263,6 +270,9 @@ static void FreeLineProc(Marker *markerPtr)
if (lmPtr->segments)
free(lmPtr->segments);
+
+ if (lmPtr->ops)
+ free(lmPtr->ops);
}
static void MapLineProc(Marker *markerPtr)
@@ -274,7 +284,7 @@ static void MapLineProc(Marker *markerPtr)
if (lmPtr->segments)
free(lmPtr->segments);
- if (!lmPtr->worldPts || (lmPtr->worldPts->num < 2))
+ if (!lmPtr->ops->worldPts || (lmPtr->ops->worldPts->num < 2))
return;
Region2d extents;
@@ -287,19 +297,19 @@ static void MapLineProc(Marker *markerPtr)
* disconnected segments.
*/
Segment2d* segments =
- (Segment2d*)malloc(lmPtr->worldPts->num * sizeof(Segment2d));
- Point2d* srcPtr = lmPtr->worldPts->points;
- Point2d p = Blt_MapPoint(srcPtr, &markerPtr->axes);
- p.x += markerPtr->xOffset;
- p.y += markerPtr->yOffset;
+ (Segment2d*)malloc(lmPtr->ops->worldPts->num * sizeof(Segment2d));
+ Point2d* srcPtr = lmPtr->ops->worldPts->points;
+ Point2d p = Blt_MapPoint(srcPtr, &markerPtr->ops->axes);
+ p.x += markerPtr->ops->xOffset;
+ p.y += markerPtr->ops->yOffset;
Segment2d* segPtr = segments;
Point2d* pend;
- for (srcPtr++, pend = lmPtr->worldPts->points + lmPtr->worldPts->num;
+ for (srcPtr++, pend = lmPtr->ops->worldPts->points + lmPtr->ops->worldPts->num;
srcPtr < pend; srcPtr++) {
- Point2d next = Blt_MapPoint(srcPtr, &markerPtr->axes);
- next.x += lmPtr->xOffset;
- next.y += lmPtr->yOffset;
+ Point2d next = Blt_MapPoint(srcPtr, &markerPtr->ops->axes);
+ next.x += lmPtr->ops->xOffset;
+ next.y += lmPtr->ops->yOffset;
Point2d q = next;
if (Blt_LineRectClip(&extents, &p, &q)) {
diff --git a/src/bltGrMarkerLine.h b/src/bltGrMarkerLine.h
index 94c1303..206cc81 100644
--- a/src/bltGrMarkerLine.h
+++ b/src/bltGrMarkerLine.h
@@ -32,6 +32,25 @@
#include "bltGrMarker.h"
+typedef struct {
+ Coords* worldPts;
+ const char* elemName;
+ Axis2d axes;
+ int hide;
+ int state;
+ int drawUnder;
+ int xOffset;
+ int yOffset;
+
+ int capStyle;
+ Blt_Dashes dashes;
+ XColor* fillColor;
+ int joinStyle;
+ int lineWidth;
+ XColor* outlineColor;
+ int xorr;
+} LineMarkerOptions;
+
class LineMarker {
public:
GraphObj obj;
@@ -42,14 +61,7 @@ class LineMarker {
int clipped;
unsigned int flags;
- Coords* worldPts;
- const char* elemName;
- Axis2d axes;
- int hide;
- int state;
- int drawUnder;
- int xOffset;
- int yOffset;
+ LineMarkerOptions* ops;
// Fields specific to line
@@ -57,14 +69,6 @@ class LineMarker {
Segment2d *segments;
int nSegments;
int xorState;
-
- int capStyle;
- Blt_Dashes dashes;
- XColor* fillColor;
- int joinStyle;
- int lineWidth;
- XColor* outlineColor;
- int xorr;
};
#endif
diff --git a/src/bltGrMarkerPolygon.C b/src/bltGrMarkerPolygon.C
index 47c411e..2517cec 100644
--- a/src/bltGrMarkerPolygon.C
+++ b/src/bltGrMarkerPolygon.C
@@ -36,51 +36,58 @@ extern "C" {
// OptionSpecs
static Tk_OptionSpec optionSpecs[] = {
- {TK_OPTION_CUSTOM, "-bindtags", "bindTags", "BindTags",
- "Polygon all", -1, Tk_Offset(PolygonMarker, obj.tags),
- TK_OPTION_NULL_OK, &listObjOption, 0},
+ // {TK_OPTION_CUSTOM, "-bindtags", "bindTags", "BindTags",
+ // "Polygon all", -1, Tk_Offset(PolygonMarkerOptions, obj.tags),
+ // TK_OPTION_NULL_OK, &listObjOption, 0},
{TK_OPTION_CUSTOM, "-cap", "cap", "Cap",
- "butt", -1, Tk_Offset(PolygonMarker, capStyle), 0, &capStyleObjOption, 0},
+ "butt", -1, Tk_Offset(PolygonMarkerOptions, capStyle),
+ 0, &capStyleObjOption, 0},
{TK_OPTION_CUSTOM, "-coords", "coords", "Coords",
- NULL, -1, Tk_Offset(PolygonMarker, worldPts),
+ NULL, -1, Tk_Offset(PolygonMarkerOptions, worldPts),
TK_OPTION_NULL_OK, &coordsObjOption, 0},
{TK_OPTION_CUSTOM, "-dashes", "dashes", "Dashes",
- NULL, -1, Tk_Offset(PolygonMarker, dashes),
+ NULL, -1, Tk_Offset(PolygonMarkerOptions, dashes),
TK_OPTION_NULL_OK, &dashesObjOption, 0},
{TK_OPTION_STRING, "-element", "element", "Element",
- NULL, -1, Tk_Offset(PolygonMarker, elemName), TK_OPTION_NULL_OK, NULL, 0},
+ NULL, -1, Tk_Offset(PolygonMarkerOptions, elemName),
+ TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_COLOR, "-fill", "fill", "Fill",
- NULL, -1, Tk_Offset(PolygonMarker, fill), TK_OPTION_NULL_OK, NULL, 0},
+ NULL, -1, Tk_Offset(PolygonMarkerOptions, 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},
+ NULL, -1, Tk_Offset(PolygonMarkerOptions, fillBg),
+ TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_CUSTOM, "-join", "join", "Join",
- "miter", -1, Tk_Offset(PolygonMarker, joinStyle), 0, &joinStyleObjOption, 0},
+ "miter", -1, Tk_Offset(PolygonMarkerOptions, joinStyle),
+ 0, &joinStyleObjOption, 0},
{TK_OPTION_PIXELS, "-polygonwidth", "polygonWidth", "PolygonWidth",
- "1", -1, Tk_Offset(PolygonMarker, lineWidth), 0, NULL, 0},
+ "1", -1, Tk_Offset(PolygonMarkerOptions, lineWidth), 0, NULL, 0},
{TK_OPTION_BOOLEAN, "-hide", "hide", "Hide",
- "no", -1, Tk_Offset(PolygonMarker, hide), 0, NULL, 0},
+ "no", -1, Tk_Offset(PolygonMarkerOptions, hide), 0, NULL, 0},
{TK_OPTION_CUSTOM, "-mapx", "mapX", "MapX",
- "x", -1, Tk_Offset(PolygonMarker, axes.x), 0, &xAxisObjOption, 0},
+ "x", -1, Tk_Offset(PolygonMarkerOptions, axes.x), 0, &xAxisObjOption, 0},
{TK_OPTION_CUSTOM, "-mapy", "mapY", "MapY",
- "y", -1, Tk_Offset(PolygonMarker, axes.y), 0, &yAxisObjOption, 0},
+ "y", -1, Tk_Offset(PolygonMarkerOptions, axes.y), 0, &yAxisObjOption, 0},
{TK_OPTION_COLOR, "-outline", "outline", "Outline",
- STD_NORMAL_FOREGROUND, -1, Tk_Offset(PolygonMarker, outline),
+ STD_NORMAL_FOREGROUND, -1, Tk_Offset(PolygonMarkerOptions, outline),
TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_COLOR, "-outlinebg", "outlinebg", "OutlineBg",
- NULL, -1, Tk_Offset(PolygonMarker, outlineBg),
+ NULL, -1, Tk_Offset(PolygonMarkerOptions, outlineBg),
TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_STRING_TABLE, "-state", "state", "State",
- "normal", -1, Tk_Offset(PolygonMarker, state), 0, &stateObjOption, 0},
+ "normal", -1, Tk_Offset(PolygonMarkerOptions, state),
+ 0, &stateObjOption, 0},
{TK_OPTION_BITMAP, "-stipple", "stipple", "Stipple",
- NULL, -1, Tk_Offset(PolygonMarker, stipple), TK_OPTION_NULL_OK, NULL, 0},
+ NULL, -1, Tk_Offset(PolygonMarkerOptions, stipple),
+ TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_BOOLEAN, "-under", "under", "Under",
- "no", -1, Tk_Offset(PolygonMarker, drawUnder), 0, NULL, 0},
+ "no", -1, Tk_Offset(PolygonMarkerOptions, drawUnder), 0, NULL, 0},
{TK_OPTION_PIXELS, "-xoffset", "xOffset", "XOffset",
- "0", -1, Tk_Offset(PolygonMarker, xOffset), 0, NULL, 0},
+ "0", -1, Tk_Offset(PolygonMarkerOptions, xOffset), 0, NULL, 0},
{TK_OPTION_BOOLEAN, "-xor", "xor", "Xor",
- "no", -1, Tk_Offset(PolygonMarker, xorr), 0, NULL, 0},
+ "no", -1, Tk_Offset(PolygonMarkerOptions, xorr), 0, NULL, 0},
{TK_OPTION_PIXELS, "-yoffset", "yOffset", "YOffset",
- "0", -1, Tk_Offset(PolygonMarker, yOffset), 0, NULL, 0},
+ "0", -1, Tk_Offset(PolygonMarkerOptions, yOffset), 0, NULL, 0},
{TK_OPTION_END, NULL, NULL, NULL, NULL, -1, 0, 0, NULL, 0}
};
@@ -108,6 +115,8 @@ Marker* Blt_CreatePolygonProc(Graph* graphPtr)
{
PolygonMarker* pmPtr = (PolygonMarker*)calloc(1, sizeof(PolygonMarker));
pmPtr->classPtr = &polygonMarkerClass;
+ pmPtr->ops = (PolygonMarkerOptions*)calloc(1, sizeof(PolygonMarkerOptions));
+
pmPtr->optionTable = Tk_CreateOptionTable(graphPtr->interp, optionSpecs);
return (Marker*)pmPtr;
@@ -117,9 +126,11 @@ static int PointInPolygonProc(Marker *markerPtr, Point2d *samplePtr)
{
PolygonMarker *pmPtr = (PolygonMarker *)markerPtr;
- if (pmPtr->worldPts && (pmPtr->worldPts->num >= 3) && (pmPtr->screenPts))
+ if (pmPtr->ops->worldPts &&
+ (pmPtr->ops->worldPts->num >= 3) &&
+ (pmPtr->screenPts))
return Blt_PointInPolygon(samplePtr, pmPtr->screenPts,
- pmPtr->worldPts->num + 1);
+ pmPtr->ops->worldPts->num + 1);
return FALSE;
}
@@ -129,9 +140,11 @@ static int RegionInPolygonProc(Marker *markerPtr, Region2d *extsPtr,
{
PolygonMarker *pmPtr = (PolygonMarker *)markerPtr;
- if (pmPtr->worldPts && (pmPtr->worldPts->num >= 3) && (pmPtr->screenPts))
+ if (pmPtr->ops->worldPts &&
+ (pmPtr->ops->worldPts->num >= 3) &&
+ (pmPtr->screenPts))
return Blt_RegionInPolygon(extsPtr, pmPtr->screenPts,
- pmPtr->worldPts->num, enclosed);
+ pmPtr->ops->worldPts->num, enclosed);
return FALSE;
}
@@ -142,7 +155,7 @@ static void DrawPolygonProc(Marker *markerPtr, Drawable drawable)
PolygonMarker *pmPtr = (PolygonMarker *)markerPtr;
/* Draw polygon fill region */
- if ((pmPtr->nFillPts > 0) && (pmPtr->fill)) {
+ if ((pmPtr->nFillPts > 0) && (pmPtr->ops->fill)) {
XPoint* points = (XPoint*)malloc(pmPtr->nFillPts * sizeof(XPoint));
if (!points)
return;
@@ -161,8 +174,8 @@ static void DrawPolygonProc(Marker *markerPtr, Drawable drawable)
free(points);
}
/* and then the outline */
- if ((pmPtr->nOutlinePts > 0) && (pmPtr->lineWidth > 0) &&
- (pmPtr->outline)) {
+ if ((pmPtr->nOutlinePts > 0) && (pmPtr->ops->lineWidth > 0) &&
+ (pmPtr->ops->outline)) {
Blt_Draw2DSegments(graphPtr->display, drawable, pmPtr->outlineGC,
pmPtr->outlinePts, pmPtr->nOutlinePts);
}
@@ -173,7 +186,7 @@ static void PolygonToPostscriptProc(Marker *markerPtr, Blt_Ps ps)
Graph* graphPtr = markerPtr->obj.graphPtr;
PolygonMarker *pmPtr = (PolygonMarker *)markerPtr;
- if (pmPtr->fill) {
+ if (pmPtr->ops->fill) {
/*
* Options: fg bg
@@ -187,38 +200,40 @@ 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->fillBg) {
+ if (pmPtr->ops->fillBg) {
/* Draw the solid background as the background layer of the opaque
* stipple */
- Blt_Ps_XSetBackground(ps, pmPtr->fillBg);
+ Blt_Ps_XSetBackground(ps, pmPtr->ops->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);
- if (pmPtr->stipple != None) {
+ Blt_Ps_XSetForeground(ps, pmPtr->ops->fill);
+ if (pmPtr->ops->stipple != None) {
/* Draw the stipple in the foreground color. */
- Blt_Ps_XSetStipple(ps, graphPtr->display, pmPtr->stipple);
+ Blt_Ps_XSetStipple(ps, graphPtr->display, pmPtr->ops->stipple);
} else {
Blt_Ps_Append(ps, "fill\n");
}
}
/* Draw the outline in the foreground color. */
- if ((pmPtr->lineWidth > 0) && (pmPtr->outline)) {
+ if ((pmPtr->ops->lineWidth > 0) && (pmPtr->ops->outline)) {
/* Set up the line attributes. */
- Blt_Ps_XSetLineAttributes(ps, pmPtr->outline,
- pmPtr->lineWidth, &pmPtr->dashes, pmPtr->capStyle,
- pmPtr->joinStyle);
+ Blt_Ps_XSetLineAttributes(ps, pmPtr->ops->outline,
+ pmPtr->ops->lineWidth,
+ &pmPtr->ops->dashes,
+ pmPtr->ops->capStyle,
+ pmPtr->ops->joinStyle);
/*
* Define on-the-fly a PostScript macro "DashesProc" that will be
* executed for each call to the Polygon drawing routine. If the line
* isn't dashed, simply make this an empty definition.
*/
- if ((pmPtr->outlineBg) && (LineIsDashed(pmPtr->dashes))) {
+ if ((pmPtr->ops->outlineBg) && (LineIsDashed(pmPtr->ops->dashes))) {
Blt_Ps_Append(ps, "/DashesProc {\ngsave\n ");
- Blt_Ps_XSetBackground(ps, pmPtr->outlineBg);
+ Blt_Ps_XSetBackground(ps, pmPtr->ops->outlineBg);
Blt_Ps_Append(ps, " ");
Blt_Ps_XSetDashes(ps, (Blt_Dashes *)NULL);
Blt_Ps_Append(ps, "stroke\n grestore\n} def\n");
@@ -240,25 +255,25 @@ static int ConfigurePolygonProc(Marker *markerPtr)
drawable = Tk_WindowId(graphPtr->tkwin);
gcMask = (GCLineWidth | GCLineStyle);
- if (pmPtr->outline) {
+ if (pmPtr->ops->outline) {
gcMask |= GCForeground;
- gcValues.foreground = pmPtr->outline->pixel;
+ gcValues.foreground = pmPtr->ops->outline->pixel;
}
- if (pmPtr->outlineBg) {
+ if (pmPtr->ops->outlineBg) {
gcMask |= GCBackground;
- gcValues.background = pmPtr->outlineBg->pixel;
+ gcValues.background = pmPtr->ops->outlineBg->pixel;
}
gcMask |= (GCCapStyle | GCJoinStyle);
- gcValues.cap_style = pmPtr->capStyle;
- gcValues.join_style = pmPtr->joinStyle;
+ gcValues.cap_style = pmPtr->ops->capStyle;
+ gcValues.join_style = pmPtr->ops->joinStyle;
gcValues.line_style = LineSolid;
gcValues.dash_offset = 0;
- gcValues.line_width = LineWidth(pmPtr->lineWidth);
- if (LineIsDashed(pmPtr->dashes)) {
- gcValues.line_style = (pmPtr->outlineBg == NULL)
+ gcValues.line_width = LineWidth(pmPtr->ops->lineWidth);
+ if (LineIsDashed(pmPtr->ops->dashes)) {
+ gcValues.line_style = (pmPtr->ops->outlineBg == NULL)
? LineOnOffDash : LineDoubleDash;
}
- if (pmPtr->xorr) {
+ if (pmPtr->ops->xorr) {
unsigned long pixel;
gcValues.function = GXxor;
@@ -273,8 +288,8 @@ static int ConfigurePolygonProc(Marker *markerPtr)
}
}
newGC = Blt_GetPrivateGC(graphPtr->tkwin, gcMask, &gcValues);
- if (LineIsDashed(pmPtr->dashes)) {
- Blt_SetDashes(graphPtr->display, newGC, &pmPtr->dashes);
+ if (LineIsDashed(pmPtr->ops->dashes)) {
+ Blt_SetDashes(graphPtr->display, newGC, &pmPtr->ops->dashes);
}
if (pmPtr->outlineGC) {
Blt_FreePrivateGC(graphPtr->display, pmPtr->outlineGC);
@@ -282,17 +297,17 @@ static int ConfigurePolygonProc(Marker *markerPtr)
pmPtr->outlineGC = newGC;
gcMask = 0;
- if (pmPtr->fill) {
+ if (pmPtr->ops->fill) {
gcMask |= GCForeground;
- gcValues.foreground = pmPtr->fill->pixel;
+ gcValues.foreground = pmPtr->ops->fill->pixel;
}
- if (pmPtr->fillBg) {
+ if (pmPtr->ops->fillBg) {
gcMask |= GCBackground;
- gcValues.background = pmPtr->fillBg->pixel;
+ gcValues.background = pmPtr->ops->fillBg->pixel;
}
- if (pmPtr->stipple != None) {
- gcValues.stipple = pmPtr->stipple;
- gcValues.fill_style = (pmPtr->fillBg)
+ if (pmPtr->ops->stipple != None) {
+ gcValues.stipple = pmPtr->ops->stipple;
+ gcValues.fill_style = (pmPtr->ops->fillBg)
? FillOpaqueStippled : FillStippled;
gcMask |= (GCStipple | GCFillStyle);
}
@@ -302,7 +317,7 @@ static int ConfigurePolygonProc(Marker *markerPtr)
}
pmPtr->fillGC = newGC;
- if ((gcMask == 0) && !(graphPtr->flags & RESET_AXES) && (pmPtr->xorr)) {
+ if ((gcMask == 0) && !(graphPtr->flags & RESET_AXES) && (pmPtr->ops->xorr)) {
if (drawable != None) {
MapPolygonProc(markerPtr);
DrawPolygonProc(markerPtr, drawable);
@@ -310,7 +325,7 @@ static int ConfigurePolygonProc(Marker *markerPtr)
return TCL_OK;
}
markerPtr->flags |= MAP_ITEM;
- if (markerPtr->drawUnder) {
+ if (markerPtr->ops->drawUnder) {
graphPtr->flags |= CACHE_DIRTY;
}
graphPtr->flags |= RESET_WORLD;
@@ -323,21 +338,23 @@ static void FreePolygonProc(Marker *markerPtr)
PolygonMarker *pmPtr = (PolygonMarker *)markerPtr;
Graph* graphPtr = markerPtr->obj.graphPtr;
- if (pmPtr->fillGC) {
+ if (pmPtr->fillGC)
Tk_FreeGC(graphPtr->display, pmPtr->fillGC);
- }
- if (pmPtr->outlineGC) {
+
+ if (pmPtr->outlineGC)
Blt_FreePrivateGC(graphPtr->display, pmPtr->outlineGC);
- }
- if (pmPtr->fillPts) {
+
+ if (pmPtr->fillPts)
free(pmPtr->fillPts);
- }
- if (pmPtr->outlinePts) {
+
+ if (pmPtr->outlinePts)
free(pmPtr->outlinePts);
- }
- if (pmPtr->screenPts) {
+
+ if (pmPtr->screenPts)
free(pmPtr->screenPts);
- }
+
+ if (pmPtr->ops)
+ free(pmPtr->ops);
}
static void MapPolygonProc(Marker *markerPtr)
@@ -359,24 +376,24 @@ static void MapPolygonProc(Marker *markerPtr)
free(pmPtr->screenPts);
pmPtr->screenPts = NULL;
}
- if (!pmPtr->worldPts || pmPtr->worldPts->num < 3)
+ if (!pmPtr->ops->worldPts || pmPtr->ops->worldPts->num < 3)
return;
/*
* Allocate and fill a temporary array to hold the screen coordinates of
* the polygon.
*/
- int nScreenPts = pmPtr->worldPts->num + 1;
+ int nScreenPts = pmPtr->ops->worldPts->num + 1;
Point2d* screenPts = (Point2d*)malloc((nScreenPts + 1) * sizeof(Point2d));
{
Point2d *sp, *dp, *send;
dp = screenPts;
- for (sp = pmPtr->worldPts->points, send = sp + pmPtr->worldPts->num;
+ for (sp = pmPtr->ops->worldPts->points, send = sp + pmPtr->ops->worldPts->num;
sp < send; sp++) {
- *dp = Blt_MapPoint(sp, &pmPtr->axes);
- dp->x += pmPtr->xOffset;
- dp->y += pmPtr->yOffset;
+ *dp = Blt_MapPoint(sp, &pmPtr->ops->axes);
+ dp->x += pmPtr->ops->xOffset;
+ dp->y += pmPtr->ops->yOffset;
dp++;
}
*dp = screenPts[0];
@@ -384,18 +401,19 @@ static void MapPolygonProc(Marker *markerPtr)
Region2d extents;
Blt_GraphExtents(graphPtr, &extents);
pmPtr->clipped = TRUE;
- if (pmPtr->fill) { /* Polygon fill required. */
+ if (pmPtr->ops->fill) {
Point2d* fillPts = (Point2d*)malloc(sizeof(Point2d) * nScreenPts * 3);
- int n = Blt_PolyRectClip(&extents, screenPts, pmPtr->worldPts->num,fillPts);
- if (n < 3) {
+ int n =
+ Blt_PolyRectClip(&extents, screenPts, pmPtr->ops->worldPts->num,fillPts);
+ if (n < 3)
free(fillPts);
- } else {
+ else {
pmPtr->nFillPts = n;
pmPtr->fillPts = fillPts;
pmPtr->clipped = FALSE;
}
}
- if ((pmPtr->outline) && (pmPtr->lineWidth > 0)) {
+ if ((pmPtr->ops->outline) && (pmPtr->ops->lineWidth > 0)) {
Segment2d *segPtr;
Point2d *sp, *send;
@@ -404,13 +422,11 @@ static void MapPolygonProc(Marker *markerPtr)
* resulting outline may or may not be closed from viewport clipping.
*/
Segment2d* outlinePts = (Segment2d*)malloc(nScreenPts * sizeof(Segment2d));
- if (outlinePts == NULL)
- return; /* Can't allocate point array */
+ if (!outlinePts)
+ return;
- /*
- * Note that this assumes that the point array contains an extra point
- * that closes the polygon.
- */
+ // Note that this assumes that the point array contains an extra point
+ // that closes the polygon.
segPtr = outlinePts;
for (sp = screenPts, send = sp + (nScreenPts - 1); sp < send; sp++) {
segPtr->p = sp[0];
diff --git a/src/bltGrMarkerPolygon.h b/src/bltGrMarkerPolygon.h
index 0838604..70e84f6 100644
--- a/src/bltGrMarkerPolygon.h
+++ b/src/bltGrMarkerPolygon.h
@@ -32,6 +32,28 @@
#include "bltGrMarker.h"
+typedef struct {
+ Coords* worldPts;
+ const char* elemName;
+ Axis2d axes;
+ int hide;
+ int state;
+ int drawUnder;
+ int xOffset;
+ int yOffset;
+
+ int capStyle;
+ Blt_Dashes dashes;
+ XColor* fill;
+ XColor* fillBg;
+ int joinStyle;
+ int lineWidth;
+ XColor* outline;
+ XColor* outlineBg;
+ Pixmap stipple;
+ int xorr;
+} PolygonMarkerOptions;
+
class PolygonMarker {
public:
GraphObj obj;
@@ -42,14 +64,7 @@ class PolygonMarker {
int clipped;
unsigned int flags;
- Coords* worldPts;
- const char* elemName;
- Axis2d axes;
- int hide;
- int state;
- int drawUnder;
- int xOffset;
- int yOffset;
+ PolygonMarkerOptions* ops;
// Fields specific to polygon
@@ -61,17 +76,6 @@ class PolygonMarker {
Segment2d *outlinePts;
int nOutlinePts;
int xorState;
-
- int capStyle;
- Blt_Dashes dashes;
- XColor* fill;
- XColor* fillBg;
- int joinStyle;
- int lineWidth;
- XColor* outline;
- XColor* outlineBg;
- Pixmap stipple;
- int xorr;
};
#endif
diff --git a/src/bltGrMarkerText.C b/src/bltGrMarkerText.C
index fbcfa0b..719d03a 100644
--- a/src/bltGrMarkerText.C
+++ b/src/bltGrMarkerText.C
@@ -36,45 +36,48 @@ extern "C" {
static Tk_OptionSpec optionSpecs[] = {
{TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor",
- "center", -1, Tk_Offset(TextMarker, anchor), 0, NULL, 0},
+ "center", -1, Tk_Offset(TextMarkerOptions, anchor), 0, NULL, 0},
{TK_OPTION_COLOR, "-background", "background", "Background",
- NULL, -1, Tk_Offset(TextMarker, fillColor), TK_OPTION_NULL_OK, NULL, 0},
+ NULL, -1, Tk_Offset(TextMarkerOptions, fillColor),
+ TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_SYNONYM, "-bg", NULL, NULL, NULL, -1, 0, 0, "-background", 0},
- {TK_OPTION_CUSTOM, "-bindtags", "bindTags", "BindTags",
- "Text all", -1, Tk_Offset(TextMarker, obj.tags),
- TK_OPTION_NULL_OK, &listObjOption, 0},
+ // {TK_OPTION_CUSTOM, "-bindtags", "bindTags", "BindTags",
+ // "Text all", -1, Tk_Offset(TextMarkerOptions, obj.tags),
+ // TK_OPTION_NULL_OK, &listObjOption, 0},
{TK_OPTION_CUSTOM, "-coords", "coords", "Coords",
- NULL, -1, Tk_Offset(TextMarker, worldPts),
+ NULL, -1, Tk_Offset(TextMarkerOptions, worldPts),
TK_OPTION_NULL_OK, &coordsObjOption, MAP_ITEM},
{TK_OPTION_STRING, "-element", "element", "Element",
- NULL, -1, Tk_Offset(TextMarker, elemName), TK_OPTION_NULL_OK, NULL, 0},
+ NULL, -1, Tk_Offset(TextMarkerOptions, elemName),
+ TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_SYNONYM, "-fg", NULL, NULL, NULL, -1, 0, 0, "-foreground", 0},
{TK_OPTION_SYNONYM, "-fill", NULL, NULL, NULL, -1, 0, 0, "-background", 0},
{TK_OPTION_FONT, "-font", "font", "Font",
- STD_FONT_NORMAL, -1, Tk_Offset(TextMarker, style.font), 0, NULL, 0},
+ STD_FONT_NORMAL, -1, Tk_Offset(TextMarkerOptions, style.font), 0, NULL, 0},
{TK_OPTION_COLOR, "-foreground", "foreground", "Foreground",
- STD_NORMAL_FOREGROUND, -1, Tk_Offset(TextMarker, style.color), 0, NULL, 0},
+ STD_NORMAL_FOREGROUND, -1, Tk_Offset(TextMarkerOptions, style.color),
+ 0, NULL, 0},
{TK_OPTION_JUSTIFY, "-justify", "justify", "Justify",
- "left", -1, Tk_Offset(TextMarker, style.justify), 0, NULL, 0},
+ "left", -1, Tk_Offset(TextMarkerOptions, style.justify), 0, NULL, 0},
{TK_OPTION_BOOLEAN, "-hide", "hide", "Hide",
- "no", -1, Tk_Offset(TextMarker, hide), 0, NULL, 0},
+ "no", -1, Tk_Offset(TextMarkerOptions, hide), 0, NULL, 0},
{TK_OPTION_CUSTOM, "-mapx", "mapX", "MapX",
- "x", -1, Tk_Offset(TextMarker, axes.x), 0, &xAxisObjOption, 0},
+ "x", -1, Tk_Offset(TextMarkerOptions, axes.x), 0, &xAxisObjOption, 0},
{TK_OPTION_CUSTOM, "-mapy", "mapY", "MapY",
- "y", -1, Tk_Offset(TextMarker, axes.y), 0, &yAxisObjOption, 0},
+ "y", -1, Tk_Offset(TextMarkerOptions, axes.y), 0, &yAxisObjOption, 0},
{TK_OPTION_SYNONYM, "-outline", NULL, NULL, NULL, -1, 0, 0, "-foreground", 0},
{TK_OPTION_DOUBLE, "-rotate", "rotate", "Rotate",
- "0", -1, Tk_Offset(TextMarker, style.angle), 0, NULL, 0},
+ "0", -1, Tk_Offset(TextMarkerOptions, style.angle), 0, NULL, 0},
{TK_OPTION_STRING_TABLE, "-state", "state", "State",
- "normal", -1, Tk_Offset(TextMarker, state), 0, &stateObjOption, 0},
+ "normal", -1, Tk_Offset(TextMarkerOptions, state), 0, &stateObjOption, 0},
{TK_OPTION_STRING, "-text", "text", "Text",
- NULL, -1, Tk_Offset(TextMarker, string), TK_OPTION_NULL_OK, NULL, 0},
+ NULL, -1, Tk_Offset(TextMarkerOptions, string), TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_BOOLEAN, "-under", "under", "Under",
- "no", -1, Tk_Offset(TextMarker, drawUnder), 0, NULL, 0},
+ "no", -1, Tk_Offset(TextMarkerOptions, drawUnder), 0, NULL, 0},
{TK_OPTION_PIXELS, "-xoffset", "xOffset", "XOffset",
- "0", -1, Tk_Offset(TextMarker, xOffset), 0, NULL, 0},
+ "0", -1, Tk_Offset(TextMarkerOptions, xOffset), 0, NULL, 0},
{TK_OPTION_PIXELS, "-yoffset", "yOffset", "YOffset",
- "0", -1, Tk_Offset(TextMarker, yOffset), 0, NULL, 0},
+ "0", -1, Tk_Offset(TextMarkerOptions, yOffset), 0, NULL, 0},
{TK_OPTION_END, NULL, NULL, NULL, NULL, -1, 0, 0, NULL, 0}
};
@@ -102,7 +105,9 @@ Marker* Blt_CreateTextProc(Graph* graphPtr)
{
TextMarker* tmPtr = (TextMarker*)calloc(1, sizeof(TextMarker));
tmPtr->classPtr = &textMarkerClass;
- Blt_Ts_InitStyle(tmPtr->style);
+ tmPtr->ops = (TextMarkerOptions*)calloc(1, sizeof(TextMarkerOptions));
+
+ Blt_Ts_InitStyle(tmPtr->ops->style);
tmPtr->optionTable = Tk_CreateOptionTable(graphPtr->interp, optionSpecs);
return (Marker*)tmPtr;
@@ -113,17 +118,17 @@ static int ConfigureTextProc(Marker* markerPtr)
Graph* graphPtr = markerPtr->obj.graphPtr;
TextMarker* tmPtr = (TextMarker*)markerPtr;
- tmPtr->style.angle = (float)fmod(tmPtr->style.angle, 360.0);
- if (tmPtr->style.angle < 0.0f) {
- tmPtr->style.angle += 360.0f;
+ tmPtr->ops->style.angle = (float)fmod(tmPtr->ops->style.angle, 360.0);
+ if (tmPtr->ops->style.angle < 0.0f) {
+ tmPtr->ops->style.angle += 360.0f;
}
GC newGC = NULL;
XGCValues gcValues;
unsigned long gcMask;
- if (tmPtr->fillColor) {
+ if (tmPtr->ops->fillColor) {
gcMask = GCForeground;
- gcValues.foreground = tmPtr->fillColor->pixel;
+ gcValues.foreground = tmPtr->ops->fillColor->pixel;
newGC = Tk_GetGC(graphPtr->tkwin, gcMask, &gcValues);
}
if (tmPtr->fillGC)
@@ -131,7 +136,7 @@ static int ConfigureTextProc(Marker* markerPtr)
tmPtr->fillGC = newGC;
markerPtr->flags |= MAP_ITEM;
- if (markerPtr->drawUnder)
+ if (markerPtr->ops->drawUnder)
graphPtr->flags |= CACHE_DIRTY;
Blt_EventuallyRedrawGraph(graphPtr);
@@ -143,20 +148,20 @@ static void MapTextProc(Marker* markerPtr)
Graph* graphPtr = markerPtr->obj.graphPtr;
TextMarker* tmPtr = (TextMarker*)markerPtr;
- if (!tmPtr->string)
+ if (!tmPtr->ops->string)
return;
- if (!tmPtr->worldPts || (tmPtr->worldPts->num < 1))
+ if (!tmPtr->ops->worldPts || (tmPtr->ops->worldPts->num < 1))
return;
tmPtr->width =0;
tmPtr->height =0;
unsigned int w, h;
- Blt_Ts_GetExtents(&tmPtr->style, tmPtr->string, &w, &h);
+ Blt_Ts_GetExtents(&tmPtr->ops->style, tmPtr->ops->string, &w, &h);
double rw, rh;
- Blt_GetBoundingBox(w, h, tmPtr->style.angle, &rw, &rh, tmPtr->outline);
+ Blt_GetBoundingBox(w, h, tmPtr->ops->style.angle, &rw, &rh, tmPtr->outline);
tmPtr->width = ROUND(rw);
tmPtr->height = ROUND(rh);
for (int ii=0; ii<4; ii++) {
@@ -166,11 +171,12 @@ static void MapTextProc(Marker* markerPtr)
tmPtr->outline[4].x = tmPtr->outline[0].x;
tmPtr->outline[4].y = tmPtr->outline[0].y;
- Point2d anchorPt = Blt_MapPoint(tmPtr->worldPts->points, &markerPtr->axes);
+ Point2d anchorPt =
+ Blt_MapPoint(tmPtr->ops->worldPts->points, &markerPtr->ops->axes);
anchorPt = Blt_AnchorPoint(anchorPt.x, anchorPt.y, tmPtr->width,
- tmPtr->height, tmPtr->anchor);
- anchorPt.x += markerPtr->xOffset;
- anchorPt.y += markerPtr->yOffset;
+ tmPtr->height, tmPtr->ops->anchor);
+ anchorPt.x += markerPtr->ops->xOffset;
+ anchorPt.y += markerPtr->ops->yOffset;
Region2d extents;
extents.left = anchorPt.x;
@@ -185,10 +191,10 @@ static int PointInTextProc(Marker* markerPtr, Point2d *samplePtr)
{
TextMarker* tmPtr = (TextMarker*)markerPtr;
- if (!tmPtr->string)
+ if (!tmPtr->ops->string)
return 0;
- if (tmPtr->style.angle != 0.0f) {
+ if (tmPtr->ops->style.angle != 0.0f) {
Point2d points[5];
// Figure out the bounding polygon (isolateral) for the text and see
@@ -210,7 +216,7 @@ static int RegionInTextProc(Marker* markerPtr, Region2d *extsPtr, int enclosed)
{
TextMarker* tmPtr = (TextMarker*)markerPtr;
- if (tmPtr->style.angle != 0.0f) {
+ if (tmPtr->ops->style.angle != 0.0f) {
// Generate the bounding polygon (isolateral) for the bitmap and see
// if the point is inside of it.
Point2d points[5];
@@ -238,7 +244,7 @@ static void DrawTextProc(Marker* markerPtr, Drawable drawable)
TextMarker* tmPtr = (TextMarker*)markerPtr;
Graph* graphPtr = markerPtr->obj.graphPtr;
- if (!tmPtr->string)
+ if (!tmPtr->ops->string)
return;
if (tmPtr->fillGC) {
@@ -254,16 +260,16 @@ static void DrawTextProc(Marker* markerPtr, Drawable drawable)
}
// be sure to update style->gc, things might have changed
- tmPtr->style.flags |= UPDATE_GC;
- Blt_Ts_DrawText(graphPtr->tkwin, drawable, tmPtr->string, -1,
- &tmPtr->style, tmPtr->anchorPt.x, tmPtr->anchorPt.y);
+ tmPtr->ops->style.flags |= UPDATE_GC;
+ Blt_Ts_DrawText(graphPtr->tkwin, drawable, tmPtr->ops->string, -1,
+ &tmPtr->ops->style, tmPtr->anchorPt.x, tmPtr->anchorPt.y);
}
static void TextToPostscriptProc(Marker* markerPtr, Blt_Ps ps)
{
TextMarker* tmPtr = (TextMarker*)markerPtr;
- if (!tmPtr->string)
+ if (!tmPtr->ops->string)
return;
if (tmPtr->fillGC) {
@@ -274,12 +280,12 @@ static void TextToPostscriptProc(Marker* markerPtr, Blt_Ps ps)
points[ii].x = tmPtr->outline[ii].x + tmPtr->anchorPt.x;
points[ii].y = tmPtr->outline[ii].y + tmPtr->anchorPt.y;
}
- Blt_Ps_XSetBackground(ps, tmPtr->fillColor);
+ Blt_Ps_XSetBackground(ps, tmPtr->ops->fillColor);
Blt_Ps_XFillPolygon(ps, points, 4);
}
- Blt_Ps_DrawText(ps, tmPtr->string, &tmPtr->style, tmPtr->anchorPt.x,
- tmPtr->anchorPt.y);
+ Blt_Ps_DrawText(ps, tmPtr->ops->string, &tmPtr->ops->style,
+ tmPtr->anchorPt.x, tmPtr->anchorPt.y);
}
static void FreeTextProc(Marker* markerPtr)
@@ -287,6 +293,9 @@ static void FreeTextProc(Marker* markerPtr)
TextMarker* tmPtr = (TextMarker*)markerPtr;
Graph* graphPtr = markerPtr->obj.graphPtr;
- Blt_Ts_FreeStyle(graphPtr->display, &tmPtr->style);
+ Blt_Ts_FreeStyle(graphPtr->display, &tmPtr->ops->style);
+
+ if (tmPtr->ops)
+ free(tmPtr->ops);
}
diff --git a/src/bltGrMarkerText.h b/src/bltGrMarkerText.h
index c5db678..436e01d 100644
--- a/src/bltGrMarkerText.h
+++ b/src/bltGrMarkerText.h
@@ -32,6 +32,22 @@
#include "bltGrMarker.h"
+typedef struct {
+ Coords* worldPts;
+ const char* elemName;
+ Axis2d axes;
+ int hide;
+ int state;
+ int drawUnder;
+ int xOffset;
+ int yOffset;
+
+ Tk_Anchor anchor;
+ XColor* fillColor;
+ TextStyle style;
+ const char* string;
+} TextMarkerOptions;
+
class TextMarker {
public:
GraphObj obj;
@@ -42,14 +58,7 @@ class TextMarker {
int clipped;
unsigned int flags;
- Coords* worldPts;
- const char* elemName;
- Axis2d axes;
- int hide;
- int state;
- int drawUnder;
- int xOffset;
- int yOffset;
+ TextMarkerOptions* ops;
// Fields specific to text
@@ -58,11 +67,6 @@ class TextMarker {
int height;
GC fillGC;
Point2d outline[5];
-
- Tk_Anchor anchor;
- XColor* fillColor;
- TextStyle style;
- const char* string;
};
#endif
diff --git a/src/bltGraph.C b/src/bltGraph.C
index 552e4ae..ca0925d 100644
--- a/src/bltGraph.C
+++ b/src/bltGraph.C
@@ -914,9 +914,9 @@ void Blt_EventuallyRedrawGraph(Graph* graphPtr)
const char* Blt_GraphClassName(ClassId classId)
{
- if ((classId >= CID_NONE) && (classId <= CID_MARKER_WINDOW)) {
+ if ((classId >= CID_NONE) && (classId <= CID_MARKER_WINDOW))
return objectClassNames[classId];
- }
+
return NULL;
}
@@ -933,7 +933,8 @@ static void AdjustAxisPointers(Graph* graphPtr)
graphPtr->bottomMargin.axes = graphPtr->axisChain[1];
graphPtr->rightMargin.axes = graphPtr->axisChain[2];
graphPtr->topMargin.axes = graphPtr->axisChain[3];
- } else {
+ }
+ else {
graphPtr->leftMargin.axes = graphPtr->axisChain[1];
graphPtr->bottomMargin.axes = graphPtr->axisChain[0];
graphPtr->rightMargin.axes = graphPtr->axisChain[3];
@@ -968,12 +969,6 @@ void Blt_GraphTags(Blt_BindTable table, ClientData object, ClientData context,
Blt_List list)
{
Graph* graphPtr = (Graph*)Blt_GetBindingData(table);
-
- /*
- * All graph objects (markers, elements, axes, etc) have the same starting
- * fields in their structures, such as "classId", "name", "className", and
- * "tags".
- */
GraphObj* graphObjPtr = (GraphObj*)object;
MakeTagProc* tagProc;
@@ -987,7 +982,6 @@ void Blt_GraphTags(Blt_BindTable table, ClientData object, ClientData context,
tagProc = Blt_MakeAxisTag;
break;
case CID_MARKER_BITMAP:
- case CID_MARKER_IMAGE:
case CID_MARKER_LINE:
case CID_MARKER_POLYGON:
case CID_MARKER_TEXT:
@@ -1002,7 +996,7 @@ void Blt_GraphTags(Blt_BindTable table, ClientData object, ClientData context,
break;
}
- /* Always add the name of the object to the tag array. */
+ // Always add the name of the object to the tag array.
Blt_List_Append(list,
(const char*)(*tagProc)(graphPtr, graphObjPtr->name), 0);
Blt_List_Append(list,
@@ -1012,43 +1006,33 @@ void Blt_GraphTags(Blt_BindTable table, ClientData object, ClientData context,
Blt_List_Append(list, (const char*)(*tagProc)(graphPtr, *p), 0);
}
-/*
- * Find the closest point from the set of displayed elements, searching
- * the display list from back to front. That way, if the points from
- * two different elements overlay each other exactly, the one that's on
- * top (visible) is picked.
- */
-
+// Find the closest point from the set of displayed elements, searching
+// the display list from back to front. That way, if the points from
+// two different elements overlay each other exactly, the one that's on
+// top (visible) is picked.
static ClientData PickEntry(ClientData clientData, int x, int y,
ClientData* contextPtr)
{
Graph* graphPtr = (Graph*)clientData;
- if (graphPtr->flags & MAP_ALL) {
- return NULL; /* Don't pick anything until the next
- * redraw occurs. */
- }
+ if (graphPtr->flags & MAP_ALL)
+ return NULL;
+
Region2d exts;
Blt_GraphExtents(graphPtr, &exts);
+ // Sample coordinate is in one of the graph margins. Can only pick an axis.
if ((x >= exts.right) || (x < exts.left) ||
- (y >= exts.bottom) || (y < exts.top)) {
- /*
- * Sample coordinate is in one of the graph margins. Can only pick an
- * axis.
- */
+ (y >= exts.bottom) || (y < exts.top))
return Blt_NearestAxis(graphPtr, x, y);
- }
- /*
- * From top-to-bottom check:
- * 1. markers drawn on top (-under false).
- * 2. elements using its display list back to front.
- * 3. markers drawn under element (-under true).
- */
+
+ // From top-to-bottom check:
+ // 1. markers drawn on top (-under false).
+ // 2. elements using its display list back to front.
+ // 3. markers drawn under element (-under true).
Marker* markerPtr = Blt_NearestMarker(graphPtr, x, y, FALSE);
- if (markerPtr != NULL) {
- return markerPtr; /* Found a marker (-under false). */
- }
+ if (markerPtr)
+ return markerPtr;
ClosestSearch* searchPtr = &graphPtr->search;
searchPtr->index = -1;
@@ -1072,10 +1056,10 @@ static ClientData PickEntry(ClientData clientData, int x, int y,
return searchPtr->elemPtr;
markerPtr = Blt_NearestMarker(graphPtr, x, y, TRUE);
- if (markerPtr != NULL) {
- return markerPtr; /* Found a marker (-under true) */
- }
- return NULL; /* Nothing found. */
+ if (markerPtr)
+ return markerPtr;
+
+ return NULL;
}
/*