summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjoye <joye>2014-01-08 21:06:07 (GMT)
committerjoye <joye>2014-01-08 21:06:07 (GMT)
commit8767a050c74f1e5d6b4de84bdd0c442f6fc5529c (patch)
tree4e3a46e86e82db909778e52c1281acf202282629
parent28149cc169d7259ce89140897ee9856b825d4f02 (diff)
downloadblt-8767a050c74f1e5d6b4de84bdd0c442f6fc5529c.zip
blt-8767a050c74f1e5d6b4de84bdd0c442f6fc5529c.tar.gz
blt-8767a050c74f1e5d6b4de84bdd0c442f6fc5529c.tar.bz2
*** empty log message ***
-rw-r--r--src/bltConfig.C89
-rw-r--r--src/bltConfig.h14
-rw-r--r--src/bltGrElemBar.C6
-rw-r--r--src/bltGrElemLine.C5
-rw-r--r--src/bltGrMarker.C23
-rw-r--r--src/bltGraph.C2
6 files changed, 66 insertions, 73 deletions
diff --git a/src/bltConfig.C b/src/bltConfig.C
index d6073f1..a1ca658 100644
--- a/src/bltConfig.C
+++ b/src/bltConfig.C
@@ -89,48 +89,53 @@
#define PIXELS_POS 1
#define PIXELS_ANY 2
-int
-Blt_GetStateFromObj(
- Tcl_Interp *interp, /* Interpreter to send results back to */
- Tcl_Obj *objPtr, /* Pixel value string */
- int *statePtr)
+/* STATE */
+
+static Blt_OptionParseProc ObjToStateProc;
+static Blt_OptionPrintProc StateToObjProc;
+Blt_CustomOption stateOption =
{
- char c;
- const char *string;
- int length;
+ ObjToStateProc, StateToObjProc, NULL, (ClientData)0
+};
- string = Tcl_GetStringFromObj(objPtr, &length);
- c = string[0];
- if ((c == 'n') && (strncmp(string, "normal", length) == 0)) {
- *statePtr = STATE_NORMAL;
- } else if ((c == 'd') && (strncmp(string, "disabled", length) == 0)) {
- *statePtr = STATE_DISABLED;
- } else if ((c == 'a') && (strncmp(string, "active", length) == 0)) {
- *statePtr = STATE_ACTIVE;
- } else {
- Tcl_AppendResult(interp, "bad state \"", string,
- "\": should be normal, active, or disabled", (char *)NULL);
- return TCL_ERROR;
- }
- return TCL_OK;
+static int ObjToStateProc(ClientData clientData, Tcl_Interp *interp,
+ Tk_Window tkwin, Tcl_Obj *objPtr, char *widgRec,
+ int offset, int flags)
+{
+ const char* string;
+ int length;
+ int* statePtr = (int*)(widgRec + offset);
+
+ string = Tcl_GetStringFromObj(objPtr, &length);
+ if (!strncmp(string, "normal", length)) {
+ *statePtr = BLT_STATE_NORMAL;
+ } else if (!strncmp(string, "disabled", length)) {
+ *statePtr = BLT_STATE_DISABLED;
+ } else if (!strncmp(string, "active", length)) {
+ *statePtr = BLT_STATE_ACTIVE;
+ } else {
+ Tcl_AppendResult(interp, "bad state \"", string,
+ "\": should be normal, active, or disabled", (char *)NULL);
+ return TCL_ERROR;
+ }
+ return TCL_OK;
}
-
-const char *
-Blt_NameOfState(int state)
+
+static Tcl_Obj* StateToObjProc(ClientData clientData, Tcl_Interp *interp,
+ Tk_Window tkwin, char *widgRec,
+ int offset, int flags)
{
- switch (state) {
- case STATE_ACTIVE:
- return "active";
- case STATE_DISABLED:
- return "disabled";
- case STATE_NORMAL:
- return "normal";
- default:
- return "???";
- }
+ int* statePtr = (int*)(widgRec + offset);
+ switch (*statePtr) {
+ case BLT_STATE_ACTIVE:
+ return Tcl_NewStringObj("active", -1);
+ case BLT_STATE_DISABLED:
+ return Tcl_NewStringObj("disabled", -1);
+ case BLT_STATE_NORMAL:
+ return Tcl_NewStringObj("normal", -1);
+ }
+ return Tcl_NewStringObj("unknown", -1);
}
-
-
/*
*---------------------------------------------------------------------------
*
@@ -664,12 +669,6 @@ DoConfig(
}
break;
- case BLT_CONFIG_STATE:
- if (Blt_GetStateFromObj(interp, objPtr, (int *)ptr) != TCL_OK) {
- return TCL_ERROR;
- }
- break;
-
case BLT_CONFIG_BACKGROUND:
{
Blt_Background style;
@@ -856,10 +855,6 @@ FormatConfigValue(
}
break;
- case BLT_CONFIG_STATE:
- string = Blt_NameOfState(*(int *)ptr);
- break;
-
case BLT_CONFIG_BACKGROUND:
if (*(Blt_Background *)ptr != NULL) {
string = Blt_NameOfBackground(*(Blt_Background *)ptr);
diff --git a/src/bltConfig.h b/src/bltConfig.h
index 0fb383b..6d11a54 100644
--- a/src/bltConfig.h
+++ b/src/bltConfig.h
@@ -134,7 +134,6 @@ typedef enum {
BLT_CONFIG_FILL,
BLT_CONFIG_LIST,
BLT_CONFIG_OBJ,
- BLT_CONFIG_STATE,
BLT_CONFIG_BACKGROUND
} Blt_ConfigTypes;
@@ -165,9 +164,9 @@ typedef enum {
#define BLT_CONFIG_OPTION_SPECIFIED (1<<5)
#define BLT_CONFIG_USER_BIT (1<<8)
-#define STATE_NORMAL (0)
-#define STATE_ACTIVE (1<<0)
-#define STATE_DISABLED (1<<1)
+#define BLT_STATE_NORMAL (0)
+#define BLT_STATE_ACTIVE (1<<0)
+#define BLT_STATE_DISABLED (1<<1)
/*
*---------------------------------------------------------------------------
@@ -201,6 +200,8 @@ typedef struct {
#define LineIsDashed(d) ((d).values[0] != 0)
+extern Blt_CustomOption stateOption;
+
/*
* Blt_Limits --
*
@@ -234,14 +235,9 @@ extern int Blt_ConfigureComponentFromObj(Tcl_Interp *interp,
extern int Blt_ConfigModified TCL_VARARGS(Blt_ConfigSpec *, specs);
-extern const char *Blt_NameOfState(int state);
-
extern void Blt_FreeOptions(Blt_ConfigSpec *specs, char *widgRec,
Display *display, int needFlags);
-extern int Blt_GetStateFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr,
- int *statePtr);
-
extern int Blt_GetFillFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr,
int *fillPtr);
diff --git a/src/bltGrElemBar.C b/src/bltGrElemBar.C
index 75327e6..1c02c62 100644
--- a/src/bltGrElemBar.C
+++ b/src/bltGrElemBar.C
@@ -38,6 +38,7 @@
#include "bltMath.h"
#include "bltGraph.h"
#include "bltGrElem.h"
+#include "bltConfig.h"
#define CLAMP(x,l,h) ((x) = (((x)<(l))? (l) : ((x)>(h)) ? (h) : (x)))
@@ -367,8 +368,8 @@ static Blt_ConfigSpec barElemConfigSpecs[] = {
BLT_CONFIG_DONT_SET_DEFAULT},
{BLT_CONFIG_STRING, "-stack", "stack", "Stack", DEF_BAR_STACK,
Tk_Offset(BarElement, groupName), BLT_CONFIG_NULL_OK},
- {BLT_CONFIG_STATE, "-state", "state", "State", DEF_BAR_STATE,
- Tk_Offset(BarElement, state), BLT_CONFIG_DONT_SET_DEFAULT},
+ {BLT_CONFIG_CUSTOM, "-state", "state", "State", DEF_BAR_STATE,
+ Tk_Offset(BarElement, state), BLT_CONFIG_DONT_SET_DEFAULT, &stateOption},
{BLT_CONFIG_BITMAP, "-stipple", "stipple", "Stipple",
DEF_BAR_NORMAL_STIPPLE, Tk_Offset(BarElement, builtinPen.stipple),
BLT_CONFIG_NULL_OK},
@@ -550,7 +551,6 @@ BarModeToObj(
return Tcl_NewStringObj(NameOfBarMode(mode), -1);
}
-
/*
* Zero out the style's number of bars and errorbars.
*/
diff --git a/src/bltGrElemLine.C b/src/bltGrElemLine.C
index 7c5b5c8..da92422 100644
--- a/src/bltGrElemLine.C
+++ b/src/bltGrElemLine.C
@@ -43,6 +43,7 @@
#include "bltGraph.h"
#include "bltGrElem.h"
#include "bltBitmap.h"
+#include "bltConfig.h"
#define COLOR_DEFAULT (XColor *)1
#define PATTERN_SOLID ((Pixmap)1)
@@ -516,8 +517,8 @@ static Blt_ConfigSpec lineElemConfigSpecs[] =
{BLT_CONFIG_CUSTOM, "-smooth", "smooth", "Smooth", DEF_LINE_SMOOTH,
Tk_Offset(LineElement, reqSmooth), BLT_CONFIG_DONT_SET_DEFAULT,
&smoothOption},
- {BLT_CONFIG_STATE, "-state", "state", "State", DEF_LINE_STATE,
- Tk_Offset(LineElement, state), BLT_CONFIG_DONT_SET_DEFAULT},
+ {BLT_CONFIG_CUSTOM, "-state", "state", "State", DEF_LINE_STATE,
+ Tk_Offset(LineElement, state), BLT_CONFIG_DONT_SET_DEFAULT, &stateOption},
{BLT_CONFIG_CUSTOM, "-styles", "styles", "Styles", DEF_LINE_STYLES,
Tk_Offset(LineElement, styles), 0, &bltLineStylesOption},
{BLT_CONFIG_CUSTOM, "-symbol", "symbol", "Symbol", DEF_LINE_SYMBOL,
diff --git a/src/bltGrMarker.C b/src/bltGrMarker.C
index 144d776..e536d4f 100644
--- a/src/bltGrMarker.C
+++ b/src/bltGrMarker.C
@@ -40,6 +40,7 @@
#include "bltImage.h"
#include "bltGrElem.h"
#include "bltBitmap.h"
+#include "bltConfig.h"
typedef int (GraphMarkerProc)(Graph *graphPtr, Tcl_Interp *interp, int objc,
Tcl_Obj *const *objv);
@@ -291,8 +292,8 @@ static Blt_ConfigSpec bitmapConfigSpecs[] =
0, 0},
{BLT_CONFIG_DOUBLE, "-rotate", "rotate", "Rotate", DEF_MARKER_ANGLE,
Tk_Offset(BitmapMarker, reqAngle), BLT_CONFIG_DONT_SET_DEFAULT},
- {BLT_CONFIG_STATE, "-state", "state", "State", DEF_MARKER_STATE,
- Tk_Offset(BitmapMarker, state), BLT_CONFIG_DONT_SET_DEFAULT},
+ {BLT_CONFIG_CUSTOM, "-state", "state", "State", DEF_MARKER_STATE,
+ Tk_Offset(BitmapMarker, state), BLT_CONFIG_DONT_SET_DEFAULT, &stateOption},
{BLT_CONFIG_BOOLEAN, "-under", "under", "Under", DEF_MARKER_UNDER,
Tk_Offset(BitmapMarker, drawUnder), BLT_CONFIG_DONT_SET_DEFAULT},
{BLT_CONFIG_PIXELS, "-xoffset", "xOffset", "XOffset", DEF_MARKER_X_OFFSET,
@@ -421,8 +422,8 @@ static Blt_ConfigSpec lineConfigSpecs[] =
{BLT_CONFIG_COLOR, "-outline", "outline", "Outline",
DEF_MARKER_OUTLINE_COLOR, Tk_Offset(LineMarker, outlineColor),
BLT_CONFIG_NULL_OK},
- {BLT_CONFIG_STATE, "-state", "state", "State", DEF_MARKER_STATE,
- Tk_Offset(LineMarker, state), BLT_CONFIG_DONT_SET_DEFAULT},
+ {BLT_CONFIG_CUSTOM, "-state", "state", "State", DEF_MARKER_STATE,
+ Tk_Offset(LineMarker, state), BLT_CONFIG_DONT_SET_DEFAULT, &stateOption},
{BLT_CONFIG_BOOLEAN, "-under", "under", "Under", DEF_MARKER_UNDER,
Tk_Offset(LineMarker, drawUnder), BLT_CONFIG_DONT_SET_DEFAULT},
{BLT_CONFIG_PIXELS, "-xoffset", "xOffset", "XOffset", DEF_MARKER_X_OFFSET,
@@ -573,8 +574,8 @@ static Blt_ConfigSpec polygonConfigSpecs[] =
{BLT_CONFIG_CUSTOM, "-outline", "outline", "Outline",
DEF_MARKER_OUTLINE_COLOR, Tk_Offset(PolygonMarker, outline),
BLT_CONFIG_NULL_OK, &colorPairOption},
- {BLT_CONFIG_STATE, "-state", "state", "State", DEF_MARKER_STATE,
- Tk_Offset(PolygonMarker, state), BLT_CONFIG_DONT_SET_DEFAULT},
+ {BLT_CONFIG_CUSTOM, "-state", "state", "State", DEF_MARKER_STATE,
+ Tk_Offset(PolygonMarker, state), BLT_CONFIG_DONT_SET_DEFAULT, &stateOption},
{BLT_CONFIG_BITMAP, "-stipple", "stipple", "Stipple", DEF_MARKER_STIPPLE,
Tk_Offset(PolygonMarker, stipple), BLT_CONFIG_NULL_OK},
{BLT_CONFIG_BOOLEAN, "-under", "under", "Under", DEF_MARKER_UNDER,
@@ -700,8 +701,8 @@ static Blt_ConfigSpec textConfigSpecs[] =
Tk_Offset(TextMarker, style.yPad), BLT_CONFIG_DONT_SET_DEFAULT},
{BLT_CONFIG_DOUBLE, "-rotate", "rotate", "Rotate", DEF_MARKER_ANGLE,
Tk_Offset(TextMarker, style.angle), BLT_CONFIG_DONT_SET_DEFAULT},
- {BLT_CONFIG_STATE, "-state", "state", "State", DEF_MARKER_STATE,
- Tk_Offset(TextMarker, state), BLT_CONFIG_DONT_SET_DEFAULT},
+ {BLT_CONFIG_CUSTOM, "-state", "state", "State", DEF_MARKER_STATE,
+ Tk_Offset(TextMarker, state), BLT_CONFIG_DONT_SET_DEFAULT, &stateOption},
{BLT_CONFIG_STRING, "-text", "text", "Text", DEF_MARKER_TEXT,
Tk_Offset(TextMarker, string), BLT_CONFIG_NULL_OK},
{BLT_CONFIG_BOOLEAN, "-under", "under", "Under", DEF_MARKER_UNDER,
@@ -813,8 +814,8 @@ static Blt_ConfigSpec windowConfigSpecs[] =
Tk_Offset(WindowMarker, axes.y), 0, &bltYAxisOption},
{BLT_CONFIG_STRING, "-name", (char *)NULL, (char *)NULL, DEF_MARKER_NAME,
Tk_Offset(WindowMarker, obj.name), BLT_CONFIG_NULL_OK},
- {BLT_CONFIG_STATE, "-state", "state", "State", DEF_MARKER_STATE,
- Tk_Offset(WindowMarker, state), BLT_CONFIG_DONT_SET_DEFAULT},
+ {BLT_CONFIG_CUSTOM, "-state", "state", "State", DEF_MARKER_STATE,
+ Tk_Offset(WindowMarker, state), BLT_CONFIG_DONT_SET_DEFAULT, &stateOption},
{BLT_CONFIG_BOOLEAN, "-under", "under", "Under", DEF_MARKER_UNDER,
Tk_Offset(WindowMarker, drawUnder), BLT_CONFIG_DONT_SET_DEFAULT},
{BLT_CONFIG_PIXELS, "-width", "width", "Width", DEF_MARKER_WIDTH,
@@ -4354,7 +4355,7 @@ Blt_NearestMarker(
continue;
}
if ((markerPtr->drawUnder == under) &&
- (markerPtr->state == STATE_NORMAL)) {
+ (markerPtr->state == BLT_STATE_NORMAL)) {
if ((*markerPtr->classPtr->pointProc) (markerPtr, &point)) {
return markerPtr;
}
diff --git a/src/bltGraph.C b/src/bltGraph.C
index 72905f9..15fb14f 100644
--- a/src/bltGraph.C
+++ b/src/bltGraph.C
@@ -597,7 +597,7 @@ PickEntry(ClientData clientData, int x, int y, ClientData *contextPtr)
if (elemPtr->flags & (HIDE|MAP_ITEM)) {
continue;
}
- if (elemPtr->state == STATE_NORMAL) {
+ if (elemPtr->state == BLT_STATE_NORMAL) {
(*elemPtr->procsPtr->closestProc) (graphPtr, elemPtr, &search);
}
}