diff options
author | joye <joye> | 2014-04-22 20:03:27 (GMT) |
---|---|---|
committer | joye <joye> | 2014-04-22 20:03:27 (GMT) |
commit | 9151d2e9af0fa1d6dd6000a792f37e34babf00bf (patch) | |
tree | a7d3db4916e4df52f630cf5d94c45c18e0d1ec94 /src | |
parent | aabaad3e8de1dcbb7f64af59e864ef2638b06bf8 (diff) | |
download | blt-9151d2e9af0fa1d6dd6000a792f37e34babf00bf.zip blt-9151d2e9af0fa1d6dd6000a792f37e34babf00bf.tar.gz blt-9151d2e9af0fa1d6dd6000a792f37e34babf00bf.tar.bz2 |
*** empty log message ***
Diffstat (limited to 'src')
-rw-r--r-- | src/bltGrAxis.C | 3 | ||||
-rw-r--r-- | src/bltGrHairsOp.C | 16 | ||||
-rw-r--r-- | src/bltGrHairsOp.h | 6 | ||||
-rw-r--r-- | src/bltGrLegdOp.C | 17 | ||||
-rw-r--r-- | src/bltGrLegdOp.h | 6 | ||||
-rw-r--r-- | src/bltGrXAxisOp.C | 32 | ||||
-rw-r--r-- | src/bltGrXAxisOp.h | 6 | ||||
-rw-r--r-- | src/bltGraphOp.C | 28 | ||||
-rw-r--r-- | src/bltOp.C | 20 | ||||
-rw-r--r-- | src/bltOp.h | 16 |
10 files changed, 139 insertions, 11 deletions
diff --git a/src/bltGrAxis.C b/src/bltGrAxis.C index 19cb963..f0edb23 100644 --- a/src/bltGrAxis.C +++ b/src/bltGrAxis.C @@ -43,10 +43,9 @@ extern "C" { using namespace Blt; +#define AXIS_PAD_TITLE 2 #define EXP10(x) (pow(10.0,(x))) #define ROUND(x) ((int)((x) + (((x)<0.0) ? -0.5 : 0.5))) -#define AXIS_PAD_TITLE 2 - #define UROUND(x,u) (Round((x)/(u))*(u)) #define UCEIL(x,u) (ceil((x)/(u))*(u)) #define UFLOOR(x,u) (floor((x)/(u))*(u)) diff --git a/src/bltGrHairsOp.C b/src/bltGrHairsOp.C index 7666ad2..53a8d13 100644 --- a/src/bltGrHairsOp.C +++ b/src/bltGrHairsOp.C @@ -36,6 +36,7 @@ extern "C" { #include "bltGraph.h" #include "bltGrHairs.h" +#include "bltGrHairsOp.h" using namespace Blt; @@ -78,9 +79,10 @@ static int CrosshairsObjConfigure(Tcl_Interp* interp, Graph* graphPtr, } } -static int CgetOp(Graph* graphPtr, Tcl_Interp* interp, +static int CgetOp(ClientData clientData, Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]) { + Graph* graphPtr = (Graph*)clientData; if (objc != 4) { Tcl_WrongNumArgs(interp, 2, objv, "cget option"); return TCL_ERROR; @@ -98,9 +100,10 @@ static int CgetOp(Graph* graphPtr, Tcl_Interp* interp, return TCL_OK; } -static int ConfigureOp(Graph* graphPtr, Tcl_Interp* interp, +static int ConfigureOp(ClientData clientData, Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]) { + Graph* graphPtr = (Graph*)clientData; Crosshairs* chPtr = graphPtr->crosshairs_; if (objc <= 4) { Tcl_Obj* objPtr = Tk_GetOptionInfo(interp, (char*)chPtr->ops(), @@ -158,6 +161,13 @@ static int ToggleOp(Graph* graphPtr, Tcl_Interp* interp, return TCL_OK; } +const BltEnsemble crosshairsEnsemble[] = { + { "cget", CgetOp,0 }, + { "configure", ConfigureOp,0 }, + { 0,0,0 } +}; + +/* static Blt_OpSpec xhairOps[] = { {"cget", 2, (void*)CgetOp, 4, 4, "option",}, @@ -180,5 +190,5 @@ int Blt_CrosshairsOp(Graph* graphPtr, Tcl_Interp* interp, return (*proc)(graphPtr, interp, objc, objv); } - +*/ diff --git a/src/bltGrHairsOp.h b/src/bltGrHairsOp.h index dadf2bb..9588ffb 100644 --- a/src/bltGrHairsOp.h +++ b/src/bltGrHairsOp.h @@ -33,6 +33,12 @@ #ifndef __BltGrHairsOp_h__ #define __BltGrHairsOp_h__ +extern "C" { +#include "bltOp.h" +} + +extern const BltEnsemble crosshairsEnsemble[]; + extern int Blt_CrosshairsOp(Graph* graphPtr, Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]); diff --git a/src/bltGrLegdOp.C b/src/bltGrLegdOp.C index 169e544..ffce2df 100644 --- a/src/bltGrLegdOp.C +++ b/src/bltGrLegdOp.C @@ -39,6 +39,7 @@ extern "C" { #include "bltGraph.h" #include "bltGrLegd.h" +#include "bltGrLegdOp.h" #include "bltGrElem.h" using namespace Blt; @@ -89,9 +90,10 @@ static int LegendObjConfigure(Tcl_Interp* interp, Graph* graphPtr, } } -static int CgetOp(Graph* graphPtr, Tcl_Interp* interp, +static int CgetOp(ClientData clientData, Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]) { + Graph* graphPtr = (Graph*)clientData; if (objc != 4) { Tcl_WrongNumArgs(interp, 2, objv, "cget option"); return TCL_ERROR; @@ -109,9 +111,10 @@ static int CgetOp(Graph* graphPtr, Tcl_Interp* interp, return TCL_OK; } -static int ConfigureOp(Graph* graphPtr, Tcl_Interp* interp, +static int ConfigureOp(ClientData clientData, Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]) { + Graph* graphPtr = (Graph*)clientData; Legend* legendPtr = graphPtr->legend_; if (objc <= 4) { Tcl_Obj* objPtr = Tk_GetOptionInfo(interp, (char*)legendPtr->ops(), @@ -300,6 +303,13 @@ static int GetOp(Graph* graphPtr, Tcl_Interp* interp, return TCL_OK; } +const BltEnsemble legendEnsemble[] = { + { "cget", CgetOp,0 }, + { "configure", ConfigureOp,0 }, + { 0,0,0 } +}; + +/* static Blt_OpSpec legendOps[] = { {"activate", 1, (void*)ActivateOp, 3, 0, "?pattern?...",}, @@ -326,6 +336,7 @@ int Blt_LegendOp(Graph* graphPtr, Tcl_Interp* interp, return (*proc)(graphPtr, interp, objc, objv); } +*/ // Selection Widget Ops @@ -487,6 +498,7 @@ static int SelectionSetOp(Graph* graphPtr, Tcl_Interp* interp, return TCL_OK; } +/* static Blt_OpSpec selectionOps[] = { {"anchor", 1, (void*)SelectionAnchorOp, 5, 5, "elem",}, @@ -509,6 +521,7 @@ static int SelectionOp(Graph* graphPtr, Tcl_Interp* interp, return (*proc)(graphPtr, interp, objc, objv); } +*/ // Support diff --git a/src/bltGrLegdOp.h b/src/bltGrLegdOp.h index 4615f83..4237e6c 100644 --- a/src/bltGrLegdOp.h +++ b/src/bltGrLegdOp.h @@ -30,6 +30,12 @@ #ifndef __BltGrLegdOp_h__ #define __BltGrLegdOp_h__ +extern "C" { +#include "bltOp.h" +} + +extern const BltEnsemble legendEnsemble[]; + extern int Blt_LegendOp(Graph *graphPtr, Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]); diff --git a/src/bltGrXAxisOp.C b/src/bltGrXAxisOp.C index 0bb573c..cdde564 100644 --- a/src/bltGrXAxisOp.C +++ b/src/bltGrXAxisOp.C @@ -33,6 +33,7 @@ extern "C" { }; #include "bltGraph.h" +#include "bltGrXAxisOp.h" #include "bltGrAxis.h" #include "bltGrAxisOp.h" @@ -148,6 +149,35 @@ static int UseOp(Tcl_Interp* interp, Axis* axisPtr, return TCL_OK; } +static int CgetOp(ClientData clientData,Tcl_Interp* interp, + int objc, Tcl_Obj* const objv[]) +{ + Graph* graphPtr = (Graph*)clientData; + GraphOptions* gops = (GraphOptions*)graphPtr->ops_; + int margin = (gops->inverted) ? MARGIN_LEFT : MARGIN_BOTTOM; + Axis* axisPtr = Blt_GetFirstAxis(gops->margins[margin].axes); + + return AxisCgetOp(interp, axisPtr, objc, objv); +} + +static int ConfigureOp(ClientData clientData, Tcl_Interp* interp, + int objc, Tcl_Obj* const objv[]) +{ + Graph* graphPtr = (Graph*)clientData; + GraphOptions* gops = (GraphOptions*)graphPtr->ops_; + int margin = (gops->inverted) ? MARGIN_LEFT : MARGIN_BOTTOM; + Axis* axisPtr = Blt_GetFirstAxis(gops->margins[margin].axes); + + return AxisConfigureOp(interp, axisPtr, objc, objv); +} + +const BltEnsemble xaxisEnsemble[] = { + { "cget", CgetOp,0 }, + { "configure", ConfigureOp,0 }, + { 0,0,0 } +}; + +/* static Blt_OpSpec axisOps[] = { {"activate", 1, (void*)AxisActivateOp, 3, 3, "",}, {"bind", 1, (void*)BindOp, 2, 5, "sequence command",}, @@ -185,4 +215,4 @@ int Blt_XAxisOp(Tcl_Interp* interp, Graph* graphPtr, int margin, return (*proc)(interp, axisPtr, objc, objv); } } - +*/ diff --git a/src/bltGrXAxisOp.h b/src/bltGrXAxisOp.h index 10a2ad5..f8fb90b 100644 --- a/src/bltGrXAxisOp.h +++ b/src/bltGrXAxisOp.h @@ -30,6 +30,12 @@ #ifndef __BltGrXAxisOp_h__ #define __BltGrXAxisOp_h__ +extern "C" { +#include "bltOp.h" +} + +extern const BltEnsemble xaxisEnsemble[]; + extern int Blt_XAxisOp(Tcl_Interp* interp, Graph* graphPtr, int margin, int objc, Tcl_Obj* const objv[]); diff --git a/src/bltGraphOp.C b/src/bltGraphOp.C index 767add6..015094f 100644 --- a/src/bltGraphOp.C +++ b/src/bltGraphOp.C @@ -138,9 +138,10 @@ int GraphObjConfigure(Tcl_Interp* interp, Graph* graphPtr, } } -static int CgetOp(Graph* graphPtr, Tcl_Interp* interp, +static int CgetOp(ClientData clientData, Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]) { + Graph* graphPtr = (Graph*)clientData; if (objc != 3) { Tcl_WrongNumArgs(interp, 1, objv, "cget option"); return TCL_ERROR; @@ -156,9 +157,10 @@ static int CgetOp(Graph* graphPtr, Tcl_Interp* interp, return TCL_OK; } -static int ConfigureOp(Graph* graphPtr, Tcl_Interp* interp, +static int ConfigureOp(ClientData clientData, Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]) { + Graph* graphPtr = (Graph*)clientData; if (objc <= 3) { Tcl_Obj* objPtr = Tk_GetOptionInfo(interp, (char*)graphPtr->ops_, graphPtr->optionTable_, @@ -382,6 +384,27 @@ static int TransformOp(Graph* graphPtr, Tcl_Interp* interp, int objc, return TCL_OK; } +#include "bltGrLegdOp.h" + +static const BltEnsemble graphEnsemble[] = { + { "cget", CgetOp,0 }, + { "configure", ConfigureOp,0 }, + { "crosshairs", 0, crosshairsEnsemble }, + { "legend", 0, legendEnsemble }, + { "xaxis", 0, xaxisEnsemble }, + { 0,0,0 } +}; + +int GraphInstCmdProc(ClientData clientData, Tcl_Interp* interp, + int objc, Tcl_Obj* const objv[]) +{ + Tcl_Preserve(clientData); + int result = BltInvokeEnsemble(graphEnsemble, 1, clientData, interp, objc, objv); + Tcl_Release(clientData); + return result; +} + +/* static Blt_OpSpec graphOps[] = { {"axis", 1, (void*)Blt_AxisOp, 2, 0, "oper ?args?",}, @@ -422,6 +445,7 @@ int GraphInstCmdProc(ClientData clientData, Tcl_Interp* interp, Tcl_Release(graphPtr); return result; } +*/ // called by Tcl_DeleteCommand void GraphInstCmdDeleteProc(ClientData clientData) diff --git a/src/bltOp.C b/src/bltOp.C index 429e8f9..53d5e28 100644 --- a/src/bltOp.C +++ b/src/bltOp.C @@ -33,6 +33,26 @@ extern "C" { #include "bltOp.h" }; +int BltInvokeEnsemble(const BltEnsemble* ensemble, int cmdIndex, + void* clientData, Tcl_Interp* interp, + int objc, Tcl_Obj* const objv[]) +{ + while (cmdIndex < objc) { + int index; + if (Tcl_GetIndexFromObjStruct(interp, objv[cmdIndex], ensemble, sizeof(ensemble[0]), "command", 0, &index) != TCL_OK) + return TCL_ERROR; + + if (ensemble[index].command) + return ensemble[index].command(clientData, interp, objc, objv); + + ensemble = (const BltEnsemble*)ensemble[index].ensemble; + ++cmdIndex; + } + + Tcl_WrongNumArgs(interp, cmdIndex, objv, "option ?arg ...?"); + return TCL_ERROR; +} + static int BinaryOpSearch(Blt_OpSpec *specs, int nSpecs, const char *string, int length) { diff --git a/src/bltOp.h b/src/bltOp.h index 41dfdba..5ddc679 100644 --- a/src/bltOp.h +++ b/src/bltOp.h @@ -30,9 +30,17 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include <tcl.h> +#ifndef __BltOp_h__ +#define __BltOp_h__ + #include <tk.h> +typedef struct BltEnsemble { + const char* name; /* subcommand name */ + Tcl_ObjCmdProc* command; /* subcommand implementation, OR: */ + const struct BltEnsemble* ensemble; /* subcommand ensemble */ +} BltEnsemble; + typedef struct { const char *name; /* Name of operation */ int minChars; /* Minimum # characters to disambiguate */ @@ -54,7 +62,13 @@ typedef enum { #define BLT_OP_BINARY_SEARCH 0 #define BLT_OP_LINEAR_SEARCH 1 +int BltInvokeEnsemble(const BltEnsemble* ensemble, int cmdIndex, + void* clientData, Tcl_Interp* interp, + int objc, Tcl_Obj* const objv[]); + void *Blt_GetOpFromObj(Tcl_Interp* interp, int nSpecs, Blt_OpSpec *specs, int operPos, int objc, Tcl_Obj* const objv[], int flags); +#endif + |