summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorjoye <joye>2014-02-10 21:40:01 (GMT)
committerjoye <joye>2014-02-10 21:40:01 (GMT)
commit1b5777512ab2c4aed0ab186edfe36c86fb40590c (patch)
treeb6b5a64cbebb1e0c38048fa107b1b9cb94808522 /src
parent62fe876c51161d8682cc0ffc8f054d36116b649d (diff)
downloadblt-1b5777512ab2c4aed0ab186edfe36c86fb40590c.zip
blt-1b5777512ab2c4aed0ab186edfe36c86fb40590c.tar.gz
blt-1b5777512ab2c4aed0ab186edfe36c86fb40590c.tar.bz2
*** empty log message ***
Diffstat (limited to 'src')
-rw-r--r--src/bltConfig.C104
-rw-r--r--src/bltConfig.h1
-rw-r--r--src/bltGrHairs.C3
3 files changed, 106 insertions, 2 deletions
diff --git a/src/bltConfig.C b/src/bltConfig.C
index e095eaf..dc69c33 100644
--- a/src/bltConfig.C
+++ b/src/bltConfig.C
@@ -135,8 +135,8 @@ Tk_ObjCustomOption pointObjOption =
};
static int PointSetProc(ClientData clientData, Tcl_Interp *interp,
- Tk_Window tkwin, Tcl_Obj** objPtr, char* widgRec,
- int offset, char* save, int flags)
+ Tk_Window tkwin, Tcl_Obj** objPtr, char* widgRec,
+ int offset, char* save, int flags)
{
XPoint *pointPtr = (XPoint *)(widgRec + offset);
int x, y;
@@ -164,6 +164,106 @@ static Tcl_Obj* PointGetProc(ClientData clientData, Tk_Window tkwin,
return Tcl_NewStringObj("", -1);
};
+// Dashes
+static Tk_CustomOptionSetProc DashesSetProc;
+static Tk_CustomOptionGetProc DashesGetProc;
+Tk_ObjCustomOption dashesObjOption =
+ {
+ "dashes", DashesSetProc, DashesGetProc, NULL, NULL, NULL
+ };
+
+static int DashesSetProc(ClientData clientData, Tcl_Interp *interp,
+ Tk_Window tkwin, Tcl_Obj** objPtr, char* widgRec,
+ int offset, char* save, int flags)
+{
+ Blt_Dashes* dashesPtr = (Blt_Dashes*)(widgRec + offset);
+
+ int length;
+ const char* string = Tcl_GetStringFromObj(*objPtr, &length);
+ if (string == NULL) {
+ dashesPtr->values[0] = 0;
+ return TCL_OK;
+ }
+
+ if (!string[0]) {
+ dashesPtr->values[0] = 0;
+ } else if (!strncmp(string, "dot", length)) {
+ /* 1 */
+ dashesPtr->values[0] = 1;
+ dashesPtr->values[1] = 0;
+ } else if (!strncmp(string, "dash", length)) {
+ /* 5 2 */
+ dashesPtr->values[0] = 5;
+ dashesPtr->values[1] = 2;
+ dashesPtr->values[2] = 0;
+ } else if (!strncmp(string, "dashdot", length)) {
+ /* 2 4 2 */
+ dashesPtr->values[0] = 2;
+ dashesPtr->values[1] = 4;
+ dashesPtr->values[2] = 2;
+ dashesPtr->values[3] = 0;
+ } else if (!strncmp(string, "dashdotdot", length)) {
+ /* 2 4 2 2 */
+ dashesPtr->values[0] = 2;
+ dashesPtr->values[1] = 4;
+ dashesPtr->values[2] = 2;
+ dashesPtr->values[3] = 2;
+ dashesPtr->values[4] = 0;
+ } else {
+ int objc;
+ Tcl_Obj** objv;
+ if (Tcl_ListObjGetElements(interp, *objPtr, &objc, &objv) != TCL_OK)
+ return TCL_ERROR;
+
+ if (objc > 11) { /* This is the postscript limit */
+ Tcl_AppendResult(interp, "too many values in dash list \"",
+ string, "\"", (char *)NULL);
+ return TCL_ERROR;
+ }
+ int ii;
+ for (ii=0; ii<objc; ii++) {
+ int value;
+ if (Tcl_GetIntFromObj(interp, objv[ii], &value) != TCL_OK)
+ return TCL_ERROR;
+
+ /*
+ * Backward compatibility:
+ * Allow list of 0 to turn off dashes
+ */
+ if ((value == 0) && (objc == 1))
+ break;
+
+ if ((value < 1) || (value > 255)) {
+ Tcl_AppendResult(interp, "dash value \"",
+ Tcl_GetString(objv[ii]), "\" is out of range",
+ (char *)NULL);
+ return TCL_ERROR;
+ }
+ dashesPtr->values[ii] = (unsigned char)value;
+ }
+ /* Make sure the array ends with a NUL byte */
+ dashesPtr->values[ii] = 0;
+ }
+ return TCL_OK;
+};
+
+static Tcl_Obj* DashesGetProc(ClientData clientData, Tk_Window tkwin,
+ char *widgRec, int offset)
+{
+ Blt_Dashes* dashesPtr = (Blt_Dashes*)(widgRec + offset);
+
+ Tcl_Obj* listObjPtr = Tcl_NewListObj(0, (Tcl_Obj**)NULL);
+ Tcl_Obj* ll[12];
+ int ii=0;
+ while (dashesPtr->values[ii]) {
+ ll[ii] = Tcl_NewIntObj(dashesPtr->values[ii]);
+ ii++;
+ }
+ Tcl_SetListObj(listObjPtr, ii, ll);
+
+ return listObjPtr;
+};
+
/* STATE */
static Blt_OptionParseProc ObjToStateProc;
diff --git a/src/bltConfig.h b/src/bltConfig.h
index f5132fe..4529bdc 100644
--- a/src/bltConfig.h
+++ b/src/bltConfig.h
@@ -175,6 +175,7 @@ typedef struct {
extern Tk_ObjCustomOption backgroundObjOption;
extern Tk_ObjCustomOption pointObjOption;
+extern Tk_ObjCustomOption dashesObjOption;
extern Blt_CustomOption stateOption;
extern Blt_CustomOption dashesOption;
diff --git a/src/bltGrHairs.C b/src/bltGrHairs.C
index f34bb3b..e3cffd9 100644
--- a/src/bltGrHairs.C
+++ b/src/bltGrHairs.C
@@ -70,6 +70,9 @@ static Tk_OptionSpec optionSpecs[] = {
{TK_OPTION_COLOR, "-color", "color", "Color",
DEF_HAIRS_FOREGROUND,
-1, Tk_Offset(Crosshairs, colorPtr), 0, NULL, 0},
+ {TK_OPTION_CUSTOM, "-dashes", "dashes", "Dashes",
+ DEF_HAIRS_DASHES,
+ -1, Tk_Offset(Crosshairs, dashes), TK_OPTION_NULL_OK, &dashesObjOption, 0},
{TK_OPTION_BOOLEAN, "-hide", "hide", "Hide",
DEF_HAIRS_HIDE,
-1, Tk_Offset(Crosshairs, hidden), 0, NULL, 0},