summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorjoye <joye>2014-04-08 20:36:58 (GMT)
committerjoye <joye>2014-04-08 20:36:58 (GMT)
commit3f1545dd5cb9770a763d87f95a1ea877ba5dc9a5 (patch)
tree29668942b3ad3730fa7a1390e3c66b9b8c9bc700 /src
parent44dad6bcb8780bec637ddbd47a3b4596fb9b528a (diff)
downloadblt-3f1545dd5cb9770a763d87f95a1ea877ba5dc9a5.zip
blt-3f1545dd5cb9770a763d87f95a1ea877ba5dc9a5.tar.gz
blt-3f1545dd5cb9770a763d87f95a1ea877ba5dc9a5.tar.bz2
*** empty log message ***
Diffstat (limited to 'src')
-rw-r--r--src/bltGrLegd.C97
-rw-r--r--src/bltGrLegd.h11
-rw-r--r--src/bltGrLegdOp.C28
3 files changed, 69 insertions, 67 deletions
diff --git a/src/bltGrLegd.C b/src/bltGrLegd.C
index 942dacb..cb98e6b 100644
--- a/src/bltGrLegd.C
+++ b/src/bltGrLegd.C
@@ -242,15 +242,23 @@ static Tk_OptionSpec optionSpecs[] = {
// Create
+Legend::Legend()
+{
+}
+
+Legend::~Legend()
+{
+}
+
int Blt_CreateLegend(Graph* graphPtr)
{
Legend* legendPtr = (Legend*)calloc(1, sizeof(Legend));
- legendPtr->ops = (void*)calloc(1, sizeof(LegendOptions));
- LegendOptions* ops = (LegendOptions*)legendPtr->ops;
+ legendPtr->ops_ = (void*)calloc(1, sizeof(LegendOptions));
+ LegendOptions* ops = (LegendOptions*)legendPtr->ops_;
ops->legendPtr = legendPtr;
graphPtr->legend = legendPtr;
- legendPtr->graphPtr = graphPtr;
+ legendPtr->graphPtr_ = graphPtr;
legendPtr->tkwin = graphPtr->tkwin;
legendPtr->xReq = -SHRT_MAX;
legendPtr->yReq = -SHRT_MAX;
@@ -271,9 +279,9 @@ int Blt_CreateLegend(Graph* graphPtr)
legendPtr->onTime = 600;
legendPtr->offTime = 300;
- legendPtr->optionTable =Tk_CreateOptionTable(graphPtr->interp, optionSpecs);
- return Tk_InitOptions(graphPtr->interp, (char*)legendPtr->ops,
- legendPtr->optionTable, graphPtr->tkwin);
+ legendPtr->optionTable_ =Tk_CreateOptionTable(graphPtr->interp, optionSpecs);
+ return Tk_InitOptions(graphPtr->interp, (char*)legendPtr->ops_,
+ legendPtr->optionTable_, graphPtr->tkwin);
}
void Blt_DestroyLegend(Graph* graphPtr)
@@ -282,7 +290,7 @@ void Blt_DestroyLegend(Graph* graphPtr)
if (!legendPtr)
return;
- LegendOptions* ops = (LegendOptions*)legendPtr->ops;
+ LegendOptions* ops = (LegendOptions*)legendPtr->ops_;
Blt_Ts_FreeStyle(graphPtr->display, &ops->style);
Blt_Ts_FreeStyle(graphPtr->display, &ops->titleStyle);
@@ -299,11 +307,11 @@ void Blt_DestroyLegend(Graph* graphPtr)
Blt_Chain_Destroy(legendPtr->selected);
- Tk_FreeConfigOptions((char*)legendPtr->ops, legendPtr->optionTable,
+ Tk_FreeConfigOptions((char*)legendPtr->ops_, legendPtr->optionTable_,
graphPtr->tkwin);
- if (legendPtr->ops)
- free(legendPtr->ops);
+ if (legendPtr->ops_)
+ free(legendPtr->ops_);
free(legendPtr);
}
@@ -313,7 +321,7 @@ void Blt_DestroyLegend(Graph* graphPtr)
void ConfigureLegend(Graph* graphPtr)
{
Legend* legendPtr = graphPtr->legend;
- LegendOptions* ops = (LegendOptions*)legendPtr->ops;
+ LegendOptions* ops = (LegendOptions*)legendPtr->ops_;
/* GC for active label. Dashed outline. */
unsigned long gcMask = GCForeground | GCLineStyle;
@@ -337,17 +345,13 @@ void ConfigureLegend(Graph* graphPtr)
static void DisplayLegend(ClientData clientData)
{
Legend* legendPtr = (Legend*)clientData;
- Graph* graphPtr;
legendPtr->flags &= ~REDRAW_PENDING;
- if (legendPtr->tkwin == NULL) {
- return; /* Window has been destroyed. */
- }
- graphPtr = legendPtr->graphPtr;
+ if (legendPtr->tkwin == NULL)
+ return;
- if (Tk_IsMapped(legendPtr->tkwin)) {
- Blt_DrawLegend(graphPtr, Tk_WindowId(legendPtr->tkwin));
- }
+ if (Tk_IsMapped(legendPtr->tkwin))
+ Blt_DrawLegend(legendPtr->graphPtr_, Tk_WindowId(legendPtr->tkwin));
}
void Blt_Legend_EventuallyRedraw(Graph* graphPtr)
@@ -362,13 +366,13 @@ void Blt_Legend_EventuallyRedraw(Graph* graphPtr)
static void SetLegendOrigin(Legend* legendPtr)
{
- Graph* graphPtr;
- int x, y, w, h;
-
- graphPtr = legendPtr->graphPtr;
- LegendOptions* ops = (LegendOptions*)legendPtr->ops;
+ Graph* graphPtr = legendPtr->graphPtr_;
+ LegendOptions* ops = (LegendOptions*)legendPtr->ops_;
- x = y = w = h = 0; /* Suppress compiler warning. */
+ int x =0;
+ int y =0;
+ int w =0;
+ int h =0;
switch (legendPtr->site) {
case LEGEND_RIGHT:
w = graphPtr->rightMargin.width - graphPtr->rightMargin.axesOffset;
@@ -542,18 +546,15 @@ static ClientData PickEntryProc(ClientData clientData, int x, int y,
ClientData *contextPtr)
{
Graph* graphPtr = (Graph*)clientData;
- Legend* legendPtr;
- int w, h;
-
- legendPtr = graphPtr->legend;
- LegendOptions* ops = (LegendOptions*)legendPtr->ops;
+ Legend* legendPtr = graphPtr->legend;
+ LegendOptions* ops = (LegendOptions*)legendPtr->ops_;
- w = legendPtr->width;
- h = legendPtr->height;
+ int w = legendPtr->width;
+ int h = legendPtr->height;
- if (legendPtr->titleHeight > 0) {
+ if (legendPtr->titleHeight > 0)
y -= legendPtr->titleHeight + ops->yPad;
- }
+
x -= legendPtr->x + ops->borderWidth;
y -= legendPtr->y + ops->borderWidth;
w -= 2 * ops->borderWidth + 2*ops->xPad;
@@ -595,7 +596,7 @@ static ClientData PickEntryProc(ClientData clientData, int x, int y,
void Blt_MapLegend(Graph* graphPtr, int plotWidth, int plotHeight)
{
Legend* legendPtr = graphPtr->legend;
- LegendOptions* ops = (LegendOptions*)legendPtr->ops;
+ LegendOptions* ops = (LegendOptions*)legendPtr->ops_;
Blt_ChainLink link;
int nRows, nColumns, nEntries;
@@ -746,7 +747,7 @@ void Blt_DrawLegend(Graph* graphPtr, Drawable drawable)
Blt_ChainLink link;
Tk_FontMetrics fontMetrics;
Legend* legendPtr = graphPtr->legend;
- LegendOptions* ops = (LegendOptions*)legendPtr->ops;
+ LegendOptions* ops = (LegendOptions*)legendPtr->ops_;
Pixmap pixmap;
Tk_Window tkwin;
@@ -760,7 +761,7 @@ void Blt_DrawLegend(Graph* graphPtr, Drawable drawable)
}
SetLegendOrigin(legendPtr);
- graphPtr = legendPtr->graphPtr;
+ graphPtr = legendPtr->graphPtr_;
tkwin = legendPtr->tkwin;
w = legendPtr->width;
h = legendPtr->height;
@@ -899,7 +900,7 @@ void Blt_DrawLegend(Graph* graphPtr, Drawable drawable)
void Blt_LegendToPostScript(Graph* graphPtr, Blt_Ps ps)
{
Legend* legendPtr = graphPtr->legend;
- LegendOptions* ops = (LegendOptions*)legendPtr->ops;
+ LegendOptions* ops = (LegendOptions*)legendPtr->ops_;
double x, y, yStart;
int xLabel, xSymbol, ySymbol;
@@ -919,7 +920,7 @@ void Blt_LegendToPostScript(Graph* graphPtr, Blt_Ps ps)
height = legendPtr->height - 2*ops->yPad;
Blt_Ps_Append(ps, "% Legend\n");
- graphPtr = legendPtr->graphPtr;
+ graphPtr = legendPtr->graphPtr_;
if (graphPtr->pageSetup->decorations) {
if (ops->normalBg)
Blt_Ps_Fill3DRectangle(ps, ops->normalBg, x, y, width, height,
@@ -1187,14 +1188,14 @@ int Blt_Legend_Height(Graph* graphPtr)
int Blt_Legend_IsHidden(Graph* graphPtr)
{
Legend* legendPtr = graphPtr->legend;
- LegendOptions* ops = (LegendOptions*)legendPtr->ops;
+ LegendOptions* ops = (LegendOptions*)legendPtr->ops_;
return (ops->hide);
}
int Blt_Legend_IsRaised(Graph* graphPtr)
{
Legend* legendPtr = graphPtr->legend;
- LegendOptions* ops = (LegendOptions*)legendPtr->ops;
+ LegendOptions* ops = (LegendOptions*)legendPtr->ops_;
return (ops->raised);
}
@@ -1217,7 +1218,7 @@ static int SelectionProc(ClientData clientData, int offset,
char *buffer, int maxBytes)
{
Legend* legendPtr = (Legend*)clientData;
- LegendOptions* ops = (LegendOptions*)legendPtr->ops;
+ LegendOptions* ops = (LegendOptions*)legendPtr->ops_;
int nBytes;
Tcl_DString dString;
@@ -1236,14 +1237,10 @@ static int SelectionProc(ClientData clientData, int offset,
Tcl_DStringAppend(&dString, elemPtr->name(), -1);
Tcl_DStringAppend(&dString, "\n", -1);
}
- } else {
- Blt_ChainLink link;
- Graph* graphPtr;
-
- graphPtr = legendPtr->graphPtr;
- /* List of selected entries is in stacking order. */
- for (link = Blt_Chain_FirstLink(graphPtr->elements.displayList);
- link != NULL; link = Blt_Chain_NextLink(link)) {
+ }
+ else {
+ Graph* graphPtr = legendPtr->graphPtr_;
+ for (Blt_ChainLink link = Blt_Chain_FirstLink(graphPtr->elements.displayList); link != NULL; link = Blt_Chain_NextLink(link)) {
Element* elemPtr = (Element*)Blt_Chain_GetValue(link);
if (EntryIsSelected(legendPtr, elemPtr)) {
Tcl_DStringAppend(&dString, elemPtr->name(), -1);
diff --git a/src/bltGrLegd.h b/src/bltGrLegd.h
index a1cc276..e780a47 100644
--- a/src/bltGrLegd.h
+++ b/src/bltGrLegd.h
@@ -112,9 +112,10 @@ typedef struct {
class Legend {
public:
- Graph* graphPtr;
- Tk_OptionTable optionTable;
- void* ops;
+ Graph* graphPtr_;
+ Tk_OptionTable optionTable_;
+ void* ops_;
+
unsigned int flags;
int nEntries;
int nColumns;
@@ -151,6 +152,10 @@ class Legend {
Blt_Chain selected;
unsigned int titleWidth;
unsigned int titleHeight;
+
+ public:
+ Legend();
+ virtual ~Legend();
};
extern int Blt_CreateLegend(Graph *graphPtr);
diff --git a/src/bltGrLegdOp.C b/src/bltGrLegdOp.C
index 8bfd895..7f62970 100644
--- a/src/bltGrLegdOp.C
+++ b/src/bltGrLegdOp.C
@@ -66,8 +66,8 @@ static int CgetOp(Graph* graphPtr, Tcl_Interp* interp,
Legend* legendPtr = graphPtr->legend;
Tcl_Obj* objPtr = Tk_GetOptionValue(interp,
- (char*)legendPtr->ops,
- legendPtr->optionTable,
+ (char*)legendPtr->ops_,
+ legendPtr->optionTable_,
objv[3], graphPtr->tkwin);
if (objPtr == NULL)
return TCL_ERROR;
@@ -82,8 +82,8 @@ static int ConfigureOp(Graph* graphPtr, Tcl_Interp* interp,
Legend* legendPtr = graphPtr->legend;
if (objc <= 4) {
Tcl_Obj* objPtr = Tk_GetOptionInfo(graphPtr->interp,
- (char*)legendPtr->ops,
- legendPtr->optionTable,
+ (char*)legendPtr->ops_,
+ legendPtr->optionTable_,
(objc == 4) ? objv[3] : NULL,
graphPtr->tkwin);
if (objPtr == NULL)
@@ -107,7 +107,7 @@ static int LegendObjConfigure(Tcl_Interp* interp, Graph* graphPtr,
for (error=0; error<=1; error++) {
if (!error) {
- if (Tk_SetOptions(interp, (char*)legendPtr->ops, legendPtr->optionTable,
+ if (Tk_SetOptions(interp, (char*)legendPtr->ops_, legendPtr->optionTable_,
objc, objv, graphPtr->tkwin, &savedOptions, &mask)
!= TCL_OK)
continue;
@@ -143,7 +143,7 @@ static int ActivateOp(Graph* graphPtr, Tcl_Interp* interp,
int objc, Tcl_Obj* const objv[])
{
Legend* legendPtr = graphPtr->legend;
- LegendOptions* ops = (LegendOptions*)legendPtr->ops;
+ LegendOptions* ops = (LegendOptions*)legendPtr->ops_;
unsigned int active, redraw;
const char *string;
@@ -299,7 +299,7 @@ static int GetOp(Graph* graphPtr, Tcl_Interp* interp,
int objc, Tcl_Obj* const objv[])
{
Legend* legendPtr = graphPtr->legend;
- LegendOptions* ops = (LegendOptions*)legendPtr->ops;
+ LegendOptions* ops = (LegendOptions*)legendPtr->ops_;
if (((ops->hide) == 0) && (legendPtr->nEntries > 0)) {
Element* elemPtr;
@@ -387,7 +387,7 @@ static int SelectionMarkOp(Graph* graphPtr, Tcl_Interp* interp,
int objc, Tcl_Obj* const objv[])
{
Legend* legendPtr = graphPtr->legend;
- LegendOptions* ops = (LegendOptions*)legendPtr->ops;
+ LegendOptions* ops = (LegendOptions*)legendPtr->ops_;
Element* elemPtr;
if (GetElementFromObj(graphPtr, objv[4], &elemPtr) != TCL_OK) {
@@ -437,7 +437,7 @@ static int SelectionSetOp(Graph* graphPtr, Tcl_Interp* interp,
int objc, Tcl_Obj* const objv[])
{
Legend* legendPtr = graphPtr->legend;
- LegendOptions* ops = (LegendOptions*)legendPtr->ops;
+ LegendOptions* ops = (LegendOptions*)legendPtr->ops_;
Element *firstPtr, *lastPtr;
const char *string;
@@ -520,7 +520,7 @@ static int SelectionOp(Graph* graphPtr, Tcl_Interp* interp,
static void LostSelectionProc(ClientData clientData)
{
Legend* legendPtr = (Legend*)clientData;
- LegendOptions* ops = (LegendOptions*)legendPtr->ops;
+ LegendOptions* ops = (LegendOptions*)legendPtr->ops_;
if (ops->exportSelection)
ClearSelection(legendPtr);
@@ -528,13 +528,13 @@ static void LostSelectionProc(ClientData clientData)
static void ClearSelection(Legend* legendPtr)
{
- LegendOptions* ops = (LegendOptions*)legendPtr->ops;
+ LegendOptions* ops = (LegendOptions*)legendPtr->ops_;
Tcl_DeleteHashTable(&legendPtr->selectTable);
Tcl_InitHashTable(&legendPtr->selectTable, TCL_ONE_WORD_KEYS);
Blt_Chain_Reset(legendPtr->selected);
- Blt_Legend_EventuallyRedraw(legendPtr->graphPtr);
+ Blt_Legend_EventuallyRedraw(legendPtr->graphPtr_);
if (ops->selectCmd)
EventuallyInvokeSelectCmd(legendPtr);
}
@@ -550,14 +550,14 @@ static void EventuallyInvokeSelectCmd(Legend* legendPtr)
static void SelectCmdProc(ClientData clientData)
{
Legend* legendPtr = (Legend*)clientData;
- LegendOptions* ops = (LegendOptions*)legendPtr->ops;
+ LegendOptions* ops = (LegendOptions*)legendPtr->ops_;
Tcl_Preserve(legendPtr);
legendPtr->flags &= ~SELECT_PENDING;
if (ops->selectCmd) {
Tcl_Interp* interp;
- interp = legendPtr->graphPtr->interp;
+ interp = legendPtr->graphPtr_->interp;
if (Tcl_GlobalEval(interp, ops->selectCmd) != TCL_OK) {
Tcl_BackgroundError(interp);
}