1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
//
// Copyright (c) 1994, 1995 by Mike Romberg ( romberg@fsl.noaa.gov )
//
// This file may be distributed under terms of the GPL
//
//
// $Id: meter.cc,v 1.9 1999/11/12 05:13:21 romberg Exp $
//
#include "general.h"
#include "meter.h"
#include "xosview.h"
CVSID("$Id: meter.cc,v 1.9 1999/11/12 05:13:21 romberg Exp $");
CVSID_DOT_H(METER_H_CVSID);
Meter::Meter( XOSView *parent, const char *title, const char *legend,
int docaptions, int dolegends, int dousedlegends ) {
title_ = legend_ = NULL;
Meter::title( title );
Meter::legend( legend );
parent_ = parent;
docaptions_ = docaptions;
dolegends_ = dolegends;
dousedlegends_ = dousedlegends;
priority_ = 1;
counter_ = 0;
resize( parent->xoff(), parent->newypos(), parent->width() - 10, 10 );
}
Meter::~Meter( void ){
delete[] title_;
delete[] legend_;
}
void Meter::checkResources( void ){
textcolor_ = parent_->allocColor( parent_->getResource( "meterLabelColor") );
}
void Meter::title( const char *title ){
delete[] title_;
int len = strlen(title);
title_ = new char[len + 1];
strncpy( title_, title, len );
title_[len] = '\0'; // strncpy() will not null terminate if s2 > len
}
void Meter::legend( const char *legend ){
delete[] legend_;
int len = strlen(legend);
legend_ = new char[len + 1];
strncpy( legend_, legend, len );
legend_[len] = '\0'; // strncpy() will not null terminate if s2 > len
}
void Meter::resize( int x, int y, int width, int height ){
x_ = x;
y_ = y;
width_ = (width>=0) ? width : 0; // fix for cosmetical bug:
height_ = (height>=0) ? height : 0; // beware of values < 0 !
width_ &= ~1; // only allow even width_ values
}
|