/***************************************************************************
qvalbar.h - description
-------------------
begin : Fri Jun 21 2002
copyright : (C) 2002 by Werner Schulte
email : werner@schulte.-ac.de
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. 1 *
* *
***************************************************************************/
#ifndef QVALBAR_H
#define QVALBAR_H
// include files for QT
#include
#include
#include
#include
#include
#include
#define FROMLEFT 0
#define FROMRIGHT 1
#define FROMCENTER 2
#include
/**
* This Class provides a Bargraph QWidget.
QValbar can be used as a custom Widget in Designer, to add
Bargraphs to your application.
@author Werner Schulte (email : werner@schulte-ac.de, homepage : www.uv-ac.de)
@version 0.1.0 - sc - 27.07.2002
The bargraphs paremeters can be defined via public methods supplied by
the class.
The bargraphs support automatic scaling, 3 different colors (dependent on
the value and 3 different bargraph types (FROMLEF, FROMRIGHT, FROMCENTER).
example
Insert QValbar element into your "ui" file and name it e.g. BitrateValBar. Adjust
the bargraph calling
info.maxbitrate may be the maximal bitrate to show.
BitrateValBar->setMinMaxValue( 0, (int)(qdata->info.maxbitrate ), FROMLEFT );
BitrateValBar->setNokRange( 0.0, 0.2 );
BitrateValBar->setCriticalRange( 0.2, 0.6 );
setText( "11MHz" );
// qdata->info.bitrate may be the actual bitrate.
// The value is multiplied by 1 and added by 0 (no value change).
BitrateValBar->setValue( qdata->info.bitrate, 1, 0 );
@p col : the color to be set.
**/
void setColor( const QColor &col );
/**
setNokColor sets the actual bars nok color.
@p col : the color to be set.
**/
void setNokColor( const QColor &col );
/**
setCritColor sets the actual bars critical color.
@p col : the color to be set.
**/
void setCritColor( const QColor &col );
/**
setOkColor sets the actual bars ok color.
@p col : the color to be set.
**/
void setOkColor( const QColor &col );
/**
setText sets the bargraphs text.
The text is shown in the text field.
@p text : the text to be set.
**/
void setText( const QString &text="" );
/**
setCriticalRange sets the critical range (where the
bargraph is shown in critical color).
@p min : the minimal value of the range.
The value has to be entered in percent (value from 0.0 to 1.0).
@p max : the maximal value of the range.
The value has to be entered in percent (value from 0.0 to 1.0).
**/
void setCriticalRange( double min = 0, double max = 0 );
/**
setNokRange sets the NOK range (where the
bargraph is shown in NOK color).
@p min : the minimal value of the range.
The value has to be entered in percent (value from 0.0 to 1.0).
@p max : the maximal value of the range.
The value has to be entered in percent (value from 0.0 to 1.0).
**/
void setNokRange ( double min = 0, double max = 0 );
/**
setMinMaxValue sets minimum and maximum values.
These values are used to calculate above mentioned critical and nok
ranges.
@p minval : the minimal value of the bargraph.
@p maxval : the maximal value of the bargraph.
@p type : the bargraphs type. Possible types are:
#define FROMLEFT 0
#define FROMRIGHT 1
#define FROMCENTER 2
**/
void setMinMaxValue( int minval = -1, int maxval = -1, int type = FROMLEFT );
/**
setValue sets the actual value.
@p val : the actual value of the bargraph.
@p mult : a value multiplier.
@p sum : a value summand.
**/
void setValue( int val=-1, int mult=1, int sum=0 );
/** construtor */
QValBar( QWidget *parent = 0, const char *name = "", WFlags f = 0 );
/** destructor */
~QValBar();
private:
/**
This are the 3 possible colors.
critcol : critical color (standard is yellow)
nokcol : NOK color (standard is red)
okcol : OK color (standard is green)
**/
QColor critcol, nokcol, okcol;
int bary, barx, barheight, barwidth, liwidth;
QLabel *barlabel;
bool isint;
QString formstring, appendstring;
int intminvalue, intmaxvalue, intvalue, bartype;
double barproz, mincrit, maxcrit, minnok, maxnok;
/**
shows the Bargraph
**/
void showBar();
/**
sets the bars color dependent on the actual parameters.
**/
void setBarColor();
/**
is called while resize is called.
**/
virtual void resizeEvent( QResizeEvent* );
};
#endif
| Generated by: sc on schomep4 on Sun Nov 23 16:54:25 2003, using kdoc 2.0a54. |