Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

QwtLegend Class Reference

The legend widget. More...

#include <qwt_legend.h>

List of all members.

Signals

void pressed (int index)
void clicked (int index)

Public Methods

 QwtLegend (QWidget *w=0, const char *name=0)
 ~QwtLegend ()
bool insertItem (const QString &txt, const QwtSymbol &s, const QPen &p, long key, uint index)
uint appendItem (const QString &txt, const QwtSymbol &s, const QPen &p, long key)
bool setText (uint index, const QString &s)
bool setSymbol (uint index, const QwtSymbol &s)
bool setPen (uint index, const QPen &pn)
bool setKey (uint index, long key)
long key (uint index) const
bool removeItem (uint index)
void setMaxCols (int columns)
int maxCols () const
void setMaxRows (int rows)
int maxRows () const
int colWidth () const
int rowHeight () const
void clear ()
QSize sizeHint () const
QSize cellSizeHint (const QFontMetrics &) const
uint itemCnt () const
uint findFirstKey (long key)

Protected Methods

virtual void paintCell (QPainter *p, int row, int col, const QRect &, bool selected)
virtual void contentsMousePressEvent (QMouseEvent *e)
virtual void contentsMouseReleaseEvent (QMouseEvent *e)
virtual QWidget * createEditor (int row, int col, bool initFromCell) const
virtual void resizeEvent (QResizeEvent *)
void resizeCells ()
void resizeTable ()
void updateTable ()
virtual void fontChange (const QFont &oldFont)

Protected Attributes

QList< QwtLegendItemd_item


Detailed Description

The legend widget.

The QwtLegend widget is a tabular arrangement of cells, called legend items, which consist of a label, a line a symbol, and a key of type long as an identifier. The symbol is drawn on top of the line at the left side of the label. An item's property can be accessed using the item's index, which is independent of the key. The cells can be arranged in row or column order with QwtLegend::setMaxRows or QwtLegend::setMaxCols. Scrollbars are displayed automatically if the cells don't fit into the widget area.


Constructor & Destructor Documentation

QwtLegend::QwtLegend QWidget *    p = 0,
const char *    name = 0
 

Constructor.

Parameters:
p  Parent widget
name  Widget name

QwtLegend::~QwtLegend  
 

Destructor.


Member Function Documentation

uint QwtLegend::appendItem const QString &    txt,
const QwtSymbol   s,
const QPen &    p,
long    key
 

Append a new item to the legend.

Parameters:
txt  Label
s  Symbol
Line  pen
key  Key
Returns:
The new size of the list

QSize QwtLegend::cellSizeHint const QFontMetrics &    fm const
 

a size hint for each cell for given font metrics.

void QwtLegend::clear  
 

Remove all items from a legend.

void QwtLegend::clicked int    index [signal]
 

Emitted when the user clicks on an item.

Parameters:
index  The item's index

int QwtLegend::colWidth   const
 

the column width.

void QwtLegend::contentsMousePressEvent QMouseEvent *    e [protected, virtual]
 

See also:
QWidget::mousePressEvent(QMouseEvent *e)

void QwtLegend::contentsMouseReleaseEvent QMouseEvent *    e [protected, virtual]
 

See also:
QWidget::mouseReleaseEvent(QMouseEvent *e)

QWidget * QwtLegend::createEditor int    row,
int    col,
bool    initFromCell
const [protected, virtual]
 

Empty implementation to disable QTable behaviour.

uint QwtLegend::findFirstKey long    key
 

Find the index of an item with a specified key.

Parameters:
key  Key
Returns:
The index of the first item which has the specified key or the total number of items if the key was not found.

void QwtLegend::fontChange const QFont &    oldFont [protected, virtual]
 

Notify a font change.

Parameters:
oldFont  Old font

bool QwtLegend::insertItem const QString &    txt,
const QwtSymbol   s,
const QPen &    p,
long    key,
uint    index
 

Insert a new item at a specified position.

Parameters:
txt  Label
s  Symbol
line  pen
key  key
index  position where to insert the item

uint QwtLegend::itemCnt   const
 

the number of items.

long QwtLegend::key uint    index const
 

Return an item's key.

Parameters:
index  The item's index
Returns:
The item's key, or 0 if the specified index is invalid

int QwtLegend::maxCols   const
 

Max. number of columns.

int QwtLegend::maxRows   const
 

Max. number of rows.

void QwtLegend::paintCell QPainter *    p,
int    row,
int    col,
const QRect &   ,
bool    selected
[protected, virtual]
 

Paint the contents of a cell.

void QwtLegend::pressed int    index [signal]
 

Emitted when the user presses a mouse button down on an item.

Parameters:
index  The item's index

bool QwtLegend::removeItem uint    index
 

Remove an item.

Parameters:
index  The item's index

void QwtLegend::resizeCells   [protected]
 

Resize the cells.

This function is called when an item has been inserted, removed or changed. It adjusts the dimensions of the table according to the layout policy and sets the cell dimensions such that all items fit into the cells.

void QwtLegend::resizeEvent QResizeEvent *    re [protected, virtual]
 

Reorganizes columns rows.

void QwtLegend::resizeTable   [protected]
 

Update the table dimensions (rows x cols).

This function is called when an item has been appended or deleted or when the max. number of rows/columns has been changed.

int QwtLegend::rowHeight   const
 

the row height.

bool QwtLegend::setKey uint    index,
long    key
 

Change the key of an item.

Parameters:
index  The item's index
key  New key

void QwtLegend::setMaxCols int    n
 

Set the maximum number of columns and the layout policy.

The setMaxCols and setMaxRows members determine in which order the cells are arranged in the table. If a maximum number of columns is set, the legend items will be arranged in rows from the left to the right, starting at the first row, and beginning a new row when the actual number of columns has reached that maximum. The number of rows is thereby unlimited.

The default setting is a maximum of 5 columns with an unlimited number of rows.

Parameters:
n  max. number of columns
Warning:
setMaxRows and setMaxCols are mutually exclusive. The last one wins.

void QwtLegend::setMaxRows int    n
 

Specify the maximum number of rows and the layout policy.

The setMaxRows and setMaxCols members determine in which order the cells are arranged in the table. If a maximum number of rows is set, the legend items will be arranged in columns from the top to the bottom, starting at the first column, and beginning a new column when the actual number or rows has reached that maximum. The number of columns is thereby unlimited.

The default setting is a maximum of 5 columns with an unlimited number of rows.

Parameters:
n  max. number of rows
Warning:
setMaxRows and setMaxCols are mutually exclusive. The last one wins.

bool QwtLegend::setPen uint    index,
const QPen &    pn
 

Change the line pen of an item.

Parameters:
index  The item's index
pn  New pen
Returns:
TRUE if the index is valid

bool QwtLegend::setSymbol uint    index,
const QwtSymbol   s
 

Change the symbol of an item.

Parameters:
index  The item's index
s  New symbol
Returns:
TRUE if the index is valid

bool QwtLegend::setText uint    index,
const QString &    s
 

Change the label of an item.

Parameters:
index  The item's index
s  New label
Returns:
TRUE if the index is valid

QSize QwtLegend::sizeHint   const
 

a size hint.

void QwtLegend::updateTable   [protected]
 

Update the cell dimendions and the table dimensions.

This function combines QwtLegend::resizeCells() and QwtLegend::resizeTable()


Generated on Tue May 28 15:30:58 2002 for Qwt User's Guide by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001