VkMeter(3x) VkMeter(3x)
VkMeter - Display a layered bar graph
VkDoubleBuffer : VkComponent : VkCallbackObject
#include <Vk/VkMeter.h>
PUBLIC PROTOCOL SUMMARY
Constructor/Destructor
VkMeter(const char *name, Widget parent);
virtual void ~VkMeter(void);
Adding Data [Toc] [Back]
void reset(int range = -1, int units = -1);
void add(int value, char *color, char *label = NULL);
void add(int value, Pixel pixel, char *label = NULL);
void add(int value, int thickness, char *color,
char *label = NULL);
void add(int value, int thickness, Pixel pixel,
char *label = NULL);
void add(int start, int size, int sideValue, int thickness,
char *color, char *label = NULL);
void add(int start, int size, int sideValue, int thickness,
Pixel color, char *label = NULL);
Drawing the Meter [Toc] [Back]
void update();
Geometry [Toc] [Back]
void setOrientation();
void setResizePolicy( unsigned char policy);
X RESOURCES ASSOCIATED WITH THIS CLASS [Toc] [Back] orientation,
colorList,
autoScale
The VkMeter class supports simple compound bar charts. Single or
multiple data items can be displayed in a double-buffered window.
The meter can be displayed in vertical or horizontal mode.
The VkMeter class allows one or more integer values to be displayed
graphically. Values are added one at a time, and displayed by
calling an update() member function. The range of values displayed
Page 1
VkMeter(3x) VkMeter(3x)
can be specified by calling the reset() member function with a new
value. See examples below.
FUNCTION DESCRIPTIONS [Toc] [Back] VkMeter()
VkMeter(const char *name, Widget parent);
Initialize an instance of VkMeter.
~VkMeter()
virtual void ~VkMeter(void);
Free all memory allocated by an VkMeter object.
reset()
void reset(int peak = -1, int units = -1);
This function clears the values of all currently displayed data and
optionally sets the peak value to be displayed by the meter. The
second argument can be used to specify a scale factor to be applied
to the "width" of the data displayed by the meter. If no values are
specified, the peak value defaults to 100, and the unit size
defaults to 1.
add()
void add(int value, char *color, char *label = NULL);
void add(int value, Pixel pixel, char *label = NULL);
void add(int value, int thickness,
char *color, char *label = NULL);
void add(int value, int thickness,
Pixel pixel, char *label = NULL);
void add(int start, int size, int sideValue,
int thickness, char *color, char *label = NULL);
void add(int start, int size, int sideValue,
int thickness, Pixel color, char *label = NULL);
All forms of this overloaded function add a data item to be
displayed by the meter. The value argument indicates a value to be
displayed in the graph. When one of the first four forms of this
function are used, multiple data items are displayed sequentially.
For example, if the range is set to 100 (the default) and value of
10, 20, and 30 are added, the meter will display a bar from 0-10,
10-30, and 30-60.
Page 2
VkMeter(3x) VkMeter(3x)
All data items must have an associated color. The color can be
specified as a pixel value, or as a string. When a string is
provided, the string is first treated as the name of a resource to
be looked up and converted to the desired color. If no such resource
is found, the string is taken to be the name of a color. For
example, items might be added as follows:
add(10, "red")
add(20, "DataTwoColor");
The second and third forms of the add() function allow a thickness
to be specified as well. This value controls the width of each item
in the bar when the bar is vertical and the height when the bar is
horizontal.
The final two forms of the add() function provide the most control
over the data displayed in the meter. The first and second arguments
specify the starting point of the data (the bottom, when the meter
is vertical) and the size. The third and fourth arguments specify a
starting point and size in the opposite dimension. For example:
add(0, 10, 0, 1, "red");
add(0, 10, 1, 1, "blue");
add(0, 10, 2, 1, "green");
add(20, 10, 0, 3, "yellow");
When the graph is vertical, this produces a display with three
vertical lines from 0-10, side by side, in red, yellow and green.
Above these three lines is a space, and a yellow bar starts at 20
and extends to thirty. This yellow strip is as wide as all three of
the previous lines. The total width of the displayed graph is equal
to the sum of the widths times the scale factor specified in the
call to reset.
update()
void update();
This function causes all values added with the add() member function
to be displayed.
setResizePolicy()
void setResizePolicy( unsigned char policy )
Page 3
VkMeter(3x) VkMeter(3x)
This function allows applications to determine the dynamic resize
policy followed by the meter. Possible values are XmRESIZE_NONE,
XmRESIZE_GROW, or XmRESIZE_ANY. If the policy is set to
XmRESIZE_NONE, the meter will never attempt to resize itself. The
application, or managing widget is in complete control. If the value
is set to XmRESIZE_GROW, the meter will call XtSetValues() on the
widget used to display the meter to attempt to grow as needed. The
success of the call to XtSetValues() depends, of course, on the
parent widget's policy. If The resize policy is set to XmRESIZE_ANY,
the meter will attempt to resize itself to grow or shrink as needed.
This function is not currently used by the VkMeter class, but is
used by derived classes.
setTitle()
void setTitle( const char *title )
Specifies a title to be displayed by the meter. This function is
not currently used by the VkMeter class, but is used by derived
classes.
The following example creates a meter component that displays four
values.
#include <Vk/VkApp.h>
#include <Vk/VkSimpleWindow.h>
#include <Vk/VkMeter.h>
#include <math.h>
class MeterWindow: public VkSimpleWindow {
public:
MeterWindow ( const char *name );
~MeterWindow ();
virtual const char* className();
};
MeterWindow::~MeterWindow ()
{
// Empty
}
const char* MeterWindow::className()
{
return "MeterWindow";
}
MeterWindow::MeterWindow(const char *name) :
Page 4
VkMeter(3x) VkMeter(3x)
VkSimpleWindow(name)
{
VkMeter *meter = new VkMeter("meter",
mainWindowWidget());
meter->reset(100);
meter->add ((int) (10.0 ), 20, "red" );
meter->add( (int) (20.0), 20, "green" );
meter->add( (int) (30.0 ), 20, "blue" );
meter->add( (int) (40.0), 20, "orange");
meter->update( );
meter->show();
addView( meter);
}
void main ( int argc, char **argv )
{
VkApp *meterApp = new VkApp("MeterApp",
&argc, argv);
MeterWindow *meterWin = new MeterWindow("meter");
meterWin->show();
meterApp->run();
}
INHERITED MEMBER FUNCTIONS [Toc] [Back] Inherited from VkDoubleBuffer
_canvas, _width, _height
Inherited from VkComponent [Toc] [Back]
installDestroyHandler(), removeDestroyHandler(), widgetDestroyed(),
setDefaultResources(), getResources(), manage(), unmanage(),
baseWidget(), okToQuit(), _name, _baseWidget, _w, deleteCallback
Inherited from VkCallbackObject [Toc] [Back]
callCallbacks(), addCallback(), removeCallback(),
removeAllCallbacks()
KNOWN DERIVED CLASSES [Toc] [Back] VkPie
Page 5
VkMeter(3x) VkMeter(3x)
CLASSES USED BY THIS CLASS
VkApp
VkDoubleBuffer, VkComponent, VkApp, VkPie
ViewKit Programmer's Guide
The X Window System, DEC Press, Bob Sheifler and Jim Gettys
The X Window System Toolkit, DEC Press, Paul Asente and Ralph Swick
The OSF/Motif Programmers Reference, Prentice Hall, OSF
PPPPaaaaggggeeee 6666 [ Back ]
|