summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjoye <joye>2014-04-18 16:46:17 (GMT)
committerjoye <joye>2014-04-18 16:46:17 (GMT)
commit604926c867bd9ce5943b063de3417e0aba6b3aee (patch)
treef6966ab50a6f17c255019b411860cc6cdae892b0
parent4386e01eb7fed74e77effedf319ef722770d5c6f (diff)
downloadblt-604926c867bd9ce5943b063de3417e0aba6b3aee.zip
blt-604926c867bd9ce5943b063de3417e0aba6b3aee.tar.gz
blt-604926c867bd9ce5943b063de3417e0aba6b3aee.tar.bz2
*** empty log message ***
-rw-r--r--src/bltGrElemOp.C3
-rw-r--r--src/bltGrElemOption.C2
-rw-r--r--src/bltGrPenOp.C73
-rw-r--r--src/bltGrPenOp.h1
-rw-r--r--src/bltGrPenOption.C3
-rw-r--r--src/bltGraph.C20
-rw-r--r--src/bltGraph.h2
7 files changed, 28 insertions, 76 deletions
diff --git a/src/bltGrElemOp.C b/src/bltGrElemOp.C
index 6904378..d8050b0 100644
--- a/src/bltGrElemOp.C
+++ b/src/bltGrElemOp.C
@@ -43,9 +43,6 @@ extern "C" {
// Defs
-extern int Blt_GetPenFromObj(Tcl_Interp* interp, Graph* graphPtr,
- Tcl_Obj *objPtr, ClassId classId, Pen **penPtrPtr);
-
static Tcl_Obj *DisplayListObj(Graph* graphPtr);
static void FreeElement(char* data);
static int GetIndex(Tcl_Interp* interp, Element* elemPtr,
diff --git a/src/bltGrElemOption.C b/src/bltGrElemOption.C
index 181a00c..2f3c528 100644
--- a/src/bltGrElemOption.C
+++ b/src/bltGrElemOption.C
@@ -357,7 +357,7 @@ static int GetPenStyleFromObj(Tcl_Interp* interp, Graph* graphPtr,
}
Pen* penPtr;
- if (Blt_GetPenFromObj(interp, graphPtr, objv[0], classId, &penPtr) != TCL_OK)
+ if (graphPtr->getPen(objv[0], &penPtr) != TCL_OK)
return TCL_ERROR;
if (objc == 3) {
diff --git a/src/bltGrPenOp.C b/src/bltGrPenOp.C
index d073560..ee2982f 100644
--- a/src/bltGrPenOp.C
+++ b/src/bltGrPenOp.C
@@ -37,9 +37,6 @@ extern "C" {
#include "bltGrPenLine.h"
#include "bltGrPenBar.h"
-static int GetPenFromObj(Tcl_Interp* interp, Graph* graphPtr, Tcl_Obj *objPtr,
- Pen **penPtrPtr);
-
static int PenObjConfigure(Tcl_Interp* interp, Graph* graphPtr, Pen* penPtr,
int objc, Tcl_Obj* const objv[])
{
@@ -133,10 +130,9 @@ static int CgetOp(Tcl_Interp* interp, Graph* graphPtr,
}
Pen* penPtr;
- if (GetPenFromObj(interp, graphPtr, objv[3], &penPtr) != TCL_OK)
+ if (graphPtr->getPen(objv[3], &penPtr) != TCL_OK)
return TCL_ERROR;
-
Tcl_Obj* objPtr = Tk_GetOptionValue(interp,
(char*)penPtr->ops(),
penPtr->optionTable(),
@@ -152,7 +148,7 @@ static int ConfigureOp(Tcl_Interp* interp, Graph* graphPtr,
int objc, Tcl_Obj* const objv[])
{
Pen* penPtr;
- if (GetPenFromObj(interp, graphPtr, objv[3], &penPtr) != TCL_OK)
+ if (graphPtr->getPen(objv[3], &penPtr) != TCL_OK)
return TCL_ERROR;
if (objc <= 5) {
@@ -188,12 +184,8 @@ static int DeleteOp(Tcl_Interp* interp, Graph* graphPtr,
return TCL_ERROR;
Pen* penPtr;
- if (GetPenFromObj(interp, graphPtr, objv[3], &penPtr) != TCL_OK) {
- Tcl_AppendResult(interp, "can't find pen \"",
- Tcl_GetString(objv[3]), "\" in \"",
- Tk_PathName(graphPtr->tkwin_), "\"", NULL);
+ if (graphPtr->getPen(objv[3], &penPtr) != TCL_OK)
return TCL_ERROR;
- }
penPtr->flags |= DELETE_PENDING;
if (penPtr->refCount == 0)
@@ -241,7 +233,7 @@ static int TypeOp(Tcl_Interp* interp, Graph* graphPtr,
int objc, Tcl_Obj* const objv[])
{
Pen* penPtr;
- if (GetPenFromObj(interp, graphPtr, objv[3], &penPtr) != TCL_OK)
+ if (graphPtr->getPen(objv[3], &penPtr) != TCL_OK)
return TCL_ERROR;
Tcl_SetStringObj(Tcl_GetObjResult(interp), penPtr->typeName(), -1);
@@ -282,60 +274,3 @@ void Blt_FreePen(Pen* penPtr)
delete penPtr;
}
}
-
-int Blt_GetPenFromObj(Tcl_Interp* interp, Graph* graphPtr, Tcl_Obj *objPtr,
- ClassId classId, Pen **penPtrPtr)
-{
- Pen* penPtr = NULL;
- const char *name = Tcl_GetString(objPtr);
- Tcl_HashEntry *hPtr = Tcl_FindHashEntry(&graphPtr->penTable_, name);
- if (hPtr != NULL) {
- penPtr = (Pen*)Tcl_GetHashValue(hPtr);
- if (penPtr->flags & DELETE_PENDING)
- penPtr = NULL;
- }
-
- if (!penPtr) {
- Tcl_AppendResult(interp, "can't find pen \"", name, "\" in \"",
- Tk_PathName(graphPtr->tkwin_), "\"", (char *)NULL);
- return TCL_ERROR;
- }
-
- if (penPtr->classId() != classId) {
- Tcl_AppendResult(interp, "pen \"", name,
- "\" is the wrong type (is \"", penPtr->className(),
- "\")", (char *)NULL);
- return TCL_ERROR;
- }
-
- penPtr->refCount++;
- *penPtrPtr = penPtr;
-
- return TCL_OK;
-}
-
-// Support
-
-static int GetPenFromObj(Tcl_Interp* interp, Graph* graphPtr, Tcl_Obj *objPtr,
- Pen **penPtrPtr)
-{
- Pen* penPtr = NULL;
- const char *name = Tcl_GetString(objPtr);
- Tcl_HashEntry *hPtr = Tcl_FindHashEntry(&graphPtr->penTable_, name);
- if (hPtr != NULL) {
- penPtr = (Pen*)Tcl_GetHashValue(hPtr);
- if (penPtr->flags & DELETE_PENDING)
- penPtr = NULL;
- }
- if (penPtr == NULL) {
- if (interp != NULL) {
- Tcl_AppendResult(interp, "can't find pen \"", name, "\" in \"",
- Tk_PathName(graphPtr->tkwin_), "\"", (char *)NULL);
- }
- return TCL_ERROR;
- }
- *penPtrPtr = penPtr;
- return TCL_OK;
-}
-
-
diff --git a/src/bltGrPenOp.h b/src/bltGrPenOp.h
index 9b8835c..1415511 100644
--- a/src/bltGrPenOp.h
+++ b/src/bltGrPenOp.h
@@ -30,7 +30,6 @@
#ifndef __BltGrPenOp_h__
#define __BltGrPenOp_h__
-extern int Blt_GetPenFromObj(Tcl_Interp* interp, Graph* graphPtr, Tcl_Obj *objPtr, ClassId classId, Pen **penPtrPtr);
extern void Blt_FreePen(Pen* penPtr);
extern int Blt_PenOp(Graph* graphPtr, Tcl_Interp* interp, int objc,
Tcl_Obj* const objv[]);
diff --git a/src/bltGrPenOption.C b/src/bltGrPenOption.C
index 4b3576e..13cd46a 100644
--- a/src/bltGrPenOption.C
+++ b/src/bltGrPenOption.C
@@ -62,9 +62,8 @@ static int PenSetProc(ClientData clientData, Tcl_Interp* interp,
}
Graph* graphPtr = Blt_GetGraphFromWindowData(tkwin);
- ClassId classId = (ClassId)(long(clientData));
Pen* penPtr;
- if (Blt_GetPenFromObj(interp, graphPtr, *objPtr, classId, &penPtr) != TCL_OK)
+ if (graphPtr->getPen(*objPtr, &penPtr) != TCL_OK)
return TCL_ERROR;
*penPtrPtr = penPtr;
diff --git a/src/bltGraph.C b/src/bltGraph.C
index 998690f..c3e1ce5 100644
--- a/src/bltGraph.C
+++ b/src/bltGraph.C
@@ -842,6 +842,26 @@ void Graph::destroyPens()
Tcl_DeleteHashTable(&penTable_);
}
+int Graph::getPen(Tcl_Obj* objPtr, Pen** penPtrPtr)
+{
+ *penPtrPtr = NULL;
+ const char *name = Tcl_GetString(objPtr);
+ if (!name || !name[0])
+ return TCL_ERROR;
+
+ Tcl_HashEntry *hPtr = Tcl_FindHashEntry(&penTable_, name);
+ if (!hPtr) {
+ Tcl_AppendResult(interp_, "can't find pen \"", name, "\" in \"",
+ Tk_PathName(tkwin_), "\"", NULL);
+ return TCL_ERROR;
+ }
+
+ *penPtrPtr = (Pen*)Tcl_GetHashValue(hPtr);
+ (*penPtrPtr)->refCount++;
+
+ return TCL_OK;
+}
+
// Elements
void Graph::destroyElements()
diff --git a/src/bltGraph.h b/src/bltGraph.h
index 0cc2c33..62a099d 100644
--- a/src/bltGraph.h
+++ b/src/bltGraph.h
@@ -43,6 +43,7 @@ class Crosshairs;
class Axis;
class Element;
class Legend;
+class Pen;
namespace Blt {
class Marker;
@@ -260,6 +261,7 @@ class Graph {
int getElement(Tcl_Obj*, Element**);
int getAxis(Tcl_Obj*, Axis**);
+ int getPen(Tcl_Obj*, Pen**);
};
extern Blt_BindTagProc Blt_GraphTags;