Main Page   Class Hierarchy   Compound List   Compound Members   Examples   Search  

QdbtTableCell Class Reference

The QdbtTableCell class represents a cell in a QdbtTabular object. More...

#include <qdbttabcell.h>

List of all members.

Public Members

 QdbtTableCell ()
 QdbtTableCell (const char *text,const QPixmap *pixmap, const QColor &color=Qt::black,int align=Qt::AlignLeft, bool edit=FALSE)
virtual ~QdbtTableCell ()
void setText (const char *text)
const char* text () const
void setPixmap (const QPixmap *pixmap)
const QPixmappixmap () const
void setColor (const QColor &color)
const QColorcolor () const
void setBackground (const QColor &color)
const QColorbackground () const
void setEditable (bool state)
bool isEditable () const
void setSelectable (bool enable)
bool isSelectable () const
void setSelected (bool enable)
bool isSelected () const
void setAlignment (int alignment)
int alignment () const
void setPixmapAlignment (int alignment)
int pixmapAlignment () const
virtual int widthHint (const QFontMetrics &fm) const
virtual int heightHint (const QFontMetrics &fm) const
void setBorderMode (int borderStyle)

Protected Members

virtual void paint (QPainter *p,int w,int h, bool rowSelected,bool selectByRow,bool editing=FALSE, int focusBar=NoBar)
virtual QRect getTextArea () const
virtual QRect getEditArea (int width) const


Detailed Description

The QdbtTableCell class represents a cell in a QdbtTabular object.

This class represents a cell of a QdbtTabular. A cell consists of a text (default the empty string) and a pixmap (default the null Pixmap).

The cell itself is not aware of its width and height, but can compute its preferred size given the font metrics that are used for the text.

The alignment of the pixmap with respect to the text can be controlled using setPixmapAlignment(). The alignment of the cell as a whole can be controlled using setAlignment().

Suppose you have table widget called tabular. To change some properties of the cell at location (row,\e col) in this table use the following code:

  // create a local copy of the cell
  QdbtTableCell cell(*tabular->cell(row,col));

  // change some properties of the cell

  .
  .
  .

  // update the cell at (row,col) in the table
  tabular->changeCell(&cell,row,col);
Examples:
example1.cpp, example2.cpp, example3.cpp, and example4.cpp.

Member Function Documentation

QdbtTableCell::QdbtTableCell ()

Constructs a cell with the following properties:

QdbtTableCell::QdbtTableCell (const char * t, const QPixmap * p, const QColor & c = Qt::black, int a = Qt::AlignLeft, bool edit = FALSE)

Constructs a cell with the following properties:

QdbtTableCell::~QdbtTableCell () [virtual]

Destroys the cell

void QdbtTableCell::setText (const char * text) [inline]

Set the text of the cell to text.

See also:
text().
Examples:
example1.cpp, example2.cpp, example3.cpp, and example4.cpp.

const char * QdbtTableCell::text () const [inline]

Returns the text string of the cell.

See also:
setText().

void QdbtTableCell::setPixmap (const QPixmap * pixmap) [inline]

Set the pixmap of the cell to pixmap.

See also:
pixmap().
Examples:
example1.cpp, and example4.cpp.

const QPixmap & QdbtTableCell::pixmap () const [inline]

Returns the pixmap of the cell.

See also:
setPixmap().

void QdbtTableCell::setColor (const QColor & color) [inline]

Sets the color of the text to color.

See also:
color().
Examples:
example1.cpp.

const QColor & QdbtTableCell::color () const [inline]

Returns the color of the cell's text.

See also:
setColor().

void QdbtTableCell::setBackground (const QColor & color) [inline]

Sets the color of the background of the cell.

If an invalid color is supplied (the default), then the background color of the table will be used.

See also:
background().
Examples:
example4.cpp.

const QColor & QdbtTableCell::background () const [inline]

Returns the background color of the cell.

See also:
setBackground().

void QdbtTableCell::setEditable (bool state) [inline]

Sets whether or not the cell may be edited by the application user.

If state is TRUE the cell may be edited.

If state is FALSE the cell may not be edited.

See also:
isEditable().
Examples:
example1.cpp, example3.cpp, and example4.cpp.

bool QdbtTableCell::isEditable () const [inline]

Returns TRUE if the cell may be edited by the user.

See also:
setEditable().

void QdbtTableCell::setSelectable (bool enable) [inline]

Sets whether or not the cell may be selected by the user.

If enable is TRUE the cell may be selected (highlighted or unhighlighted) by the user.

If enable is FALSE the cell can only be highlighted from within the application.

See also:
isSelectable().
Examples:
example4.cpp.

bool QdbtTableCell::isSelectable () const [inline]

Returns TRUE if the cell is currently highlighted.

See also:
setSelected().

void QdbtTableCell::setSelected (bool enable) [inline]

Sets whether or not the cell should be displayed as being selected.

If enable is TRUE the cell is highlighted (drawn in inverse).

If enable is FALSE the cell is unhighlighted (drawn normal).

See also:
isSelected().
Examples:
example4.cpp.

bool QdbtTableCell::isSelected () const [inline]

Returns TRUE if the cell is currently highlighted.

See also:
setSelected().

void QdbtTableCell::setAlignment (int alignment) [inline]

Set the alignment of the text-pixmap pair. Possible values are:

See also:
alignment().
Examples:
example1.cpp, example2.cpp, and example4.cpp.

int QdbtTableCell::alignment () const [inline]

Returns the alignment of the text-pixmap pair.

See also:
alignment().

void QdbtTableCell::setPixmapAlignment (int alignment) [inline]

Sets the alignment of the pixmap with respect to the text. Possible values are:

See also:
pixmapAlignment().
Examples:
example1.cpp, and example4.cpp.

int QdbtTableCell::pixmapAlignment () const [inline]

Returns the align of the pixmap with respect to the text. Possible values are: AlignLeft, AlignRight, AlignTop, AlignBottom.

See also:
setPixmapAlignment().

int QdbtTableCell::widthHint (const QFontMetrics & fm) const [virtual]

Returns the preferred width of the cell. This is not the actual cell width, but the width that is required to fit both text and pixmap in the cell.

See also:
heightHint().

int QdbtTableCell::heightHint (const QFontMetrics & fm) const [virtual]

Returns the preferred height of the cell. This is not the actual cell height, but the height that is required to fit both text and pixmap in the cell.

See also:
widthHint().

void QdbtTableCell::setBorderMode (int borderStyle)

Sets the mode, in which cell borders are drawn. They may be composed (or'ed) out of the following components:

void QdbtTableCell::paint (QPainter * p, int w, int h, bool rowSelected, bool selectByRow, bool editing = FALSE, int focusBar = NoBar) [protected, virtual]

This function is called whenever the cell needs to be repainted. The width of the cell is w and the height is h. The painter p automatically clips against the area of the cell. The boolean rowSelected indicates if the row, that this cell belongs to, is selected. This should only have an effect if selectByRow is TRUE. The boolean editing indicates if the cell is currently being edited. The focusBar argument specify the the type of focus that needs to be drawn. Possible values are

QRect QdbtTableCell::getTextArea () const [protected, virtual]

Returns the area inside the cell, where the text is being drawn. The coordinates of the rectangle are in pixels and relative to the cell. The top left of the cell has coordinates (0,0).

QRect QdbtTableCell::getEditArea (int width) const [protected, virtual]

Returns the area inside the cell, where the edit focus may be placed. The coordinates of the rectangle are in pixels and relative to the cell. The top left of the cell has coordinates (0,0).


The documentation for this class was generated from the following files:
Generated 11:09, 1999/10/02 for QdbtTabular by doxygen  written by Dimitri van Heesch, © 1997-1998