diff options
author | joye <joye> | 2014-07-03 21:09:16 (GMT) |
---|---|---|
committer | joye <joye> | 2014-07-03 21:09:16 (GMT) |
commit | 2afe0c03f7b0853538c7c2b26659bc1bc2dd7545 (patch) | |
tree | e3a75ec885e22e5f3c184dee8c95cd18047b8ced /src | |
parent | ef198d617f331ec83d70217a270123910556c6fb (diff) | |
download | blt-2afe0c03f7b0853538c7c2b26659bc1bc2dd7545.zip blt-2afe0c03f7b0853538c7c2b26659bc1bc2dd7545.tar.gz blt-2afe0c03f7b0853538c7c2b26659bc1bc2dd7545.tar.bz2 |
*** empty log message ***
Diffstat (limited to 'src')
-rw-r--r-- | src/bltGrAxis.C | 25 | ||||
-rw-r--r-- | src/bltGrAxis.h | 10 |
2 files changed, 21 insertions, 14 deletions
diff --git a/src/bltGrAxis.C b/src/bltGrAxis.C index 43d0ca7..93e749b 100644 --- a/src/bltGrAxis.C +++ b/src/bltGrAxis.C @@ -185,10 +185,19 @@ static Tk_OptionSpec optionSpecs[] = { {TK_OPTION_END, NULL, NULL, NULL, NULL, -1, 0, 0, NULL, 0} }; -Ticks::Ticks() +TickLabel::TickLabel(char* str) { - nTicks =0; - values =NULL; + anchorPos.x = DBL_MAX; + anchorPos.y = DBL_MAX; + width =0; + height =0; + string = dupstr(str); +} + +TickLabel::~TickLabel() +{ + if (string) + delete [] string; } Ticks::Ticks(int cnt) @@ -1022,9 +1031,7 @@ void Axis::freeTickLabels() for (Blt_ChainLink link=Blt_Chain_FirstLink(chain); link; link = Blt_Chain_NextLink(link)) { TickLabel* labelPtr = (TickLabel*)Blt_Chain_GetValue(link); - if (labelPtr->string) - delete [] labelPtr->string; - delete(labelPtr); + delete labelPtr; } Blt_Chain_Reset(chain); } @@ -1063,11 +1070,7 @@ TickLabel* Axis::makeLabel(double value) } } - TickLabel* labelPtr = new TickLabel; - labelPtr->string = new char[strlen(string)+1]; - strcpy(labelPtr->string, string); - labelPtr->anchorPos.x = DBL_MAX; - labelPtr->anchorPos.y = DBL_MAX; + TickLabel* labelPtr = new TickLabel(string); return labelPtr; } diff --git a/src/bltGrAxis.h b/src/bltGrAxis.h index 1d82f76..12ef74a 100644 --- a/src/bltGrAxis.h +++ b/src/bltGrAxis.h @@ -78,12 +78,17 @@ namespace Blt { double scale; } AxisRange; - typedef struct { + class TickLabel { + public: Point2d anchorPos; unsigned int width; unsigned int height; char* string; - } TickLabel; + + public: + TickLabel(char*); + virtual ~TickLabel(); + }; class Ticks { public: @@ -91,7 +96,6 @@ namespace Blt { double* values; public: - Ticks(); Ticks(int); virtual ~Ticks(); }; |