| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | #include "general.h" |
|---|
| 10 | #include "meter.h" |
|---|
| 11 | #include "xosview.h" |
|---|
| 12 | |
|---|
| 13 | CVSID("$Id: meter.cc,v 1.1.1.1 2008/05/04 15:53:48 emasson Exp $"); |
|---|
| 14 | CVSID_DOT_H(METER_H_CVSID); |
|---|
| 15 | |
|---|
| 16 | Meter::Meter( XOSView *parent, const char *title, const char *legend, |
|---|
| 17 | int docaptions, int dolegends, int dousedlegends ) { |
|---|
| 18 | title_ = legend_ = NULL; |
|---|
| 19 | Meter::title( title ); |
|---|
| 20 | Meter::legend( legend ); |
|---|
| 21 | parent_ = parent; |
|---|
| 22 | docaptions_ = docaptions; |
|---|
| 23 | dolegends_ = dolegends; |
|---|
| 24 | dousedlegends_ = dousedlegends; |
|---|
| 25 | priority_ = 1; |
|---|
| 26 | counter_ = 0; |
|---|
| 27 | resize( parent->xoff(), parent->newypos(), parent->width() - 10, 10 ); |
|---|
| 28 | |
|---|
| 29 | } |
|---|
| 30 | |
|---|
| 31 | Meter::~Meter( void ){ |
|---|
| 32 | if ( title_ ) |
|---|
| 33 | delete[] title_; |
|---|
| 34 | if ( legend_ ) |
|---|
| 35 | delete[] legend_; |
|---|
| 36 | } |
|---|
| 37 | |
|---|
| 38 | void Meter::checkResources( void ){ |
|---|
| 39 | textcolor_ = parent_->allocColor( parent_->getResource( "meterLabelColor") ); |
|---|
| 40 | } |
|---|
| 41 | |
|---|
| 42 | void Meter::title( const char *title ){ |
|---|
| 43 | |
|---|
| 44 | if ( title_ ) |
|---|
| 45 | delete[] title_; |
|---|
| 46 | |
|---|
| 47 | int len = strlen(title); |
|---|
| 48 | title_ = new char[len + 1]; |
|---|
| 49 | strncpy( title_, title, len ); |
|---|
| 50 | title_[len] = '\0'; |
|---|
| 51 | } |
|---|
| 52 | |
|---|
| 53 | void Meter::legend( const char *legend ){ |
|---|
| 54 | |
|---|
| 55 | if ( legend_ ) |
|---|
| 56 | delete[] legend_; |
|---|
| 57 | |
|---|
| 58 | int len = strlen(legend); |
|---|
| 59 | legend_ = new char[len + 1]; |
|---|
| 60 | strncpy( legend_, legend, len ); |
|---|
| 61 | legend_[len] = '\0'; |
|---|
| 62 | } |
|---|
| 63 | |
|---|
| 64 | void Meter::resize( int x, int y, int width, int height ){ |
|---|
| 65 | x_ = x; |
|---|
| 66 | y_ = y; |
|---|
| 67 | width_ = (width>=0) ? width : 0; |
|---|
| 68 | height_ = (height>=0) ? height : 0; |
|---|
| 69 | width_ &= ~1; |
|---|
| 70 | } |
|---|