- Main Page
- Classes
- Files
- Directories

- Class List
- Class Hierarchy
- Class Members

# cLabelPanel Class Reference

This class represents a 2D panel with at least one piece of text on it, optionally including several pieces of text with colored markers next to them (like the key on a graph). More...

`#include <CLabelPanel.h>`

Inheritance diagram for cLabelPanel:

List of all members.

## Public Member Functions
| cLabelPanel (cWorld *a_world)
| Constructor for cLabelPanel.
virtual | ~cLabelPanel ()
| Destructor for cLabelPanel.
void | addLabel (const char *a_label, const cMaterial *a_mat=0)
| Add a label (an additional line of text) to the panel.
void | setLabel (const unsigned int &a_index, const char *a_label)
| Set an existing label to a new line of text.
unsigned int | getNumLabels () const
| How many labels are currently displayed?
const char * | getLabel (const unsigned int &a_index) const
| Read out a particular label.
void | clearLabels ()
| Clear all labels from the panel.
virtual void | render (const int a_renderMode=0)
| The panel's drawing function.
virtual void | onDisplayReset (const bool a_affectChildren=true)
| Allows us to re-create font information after a GL context change.
void | setShowSquares (const bool &a_showSquares)
| Should we show iconic squares along with each label?
bool | getShowSquares () const
| Are we showing iconic squares along with each label?
void | setBorders (const int &a_topBorder, const int &a_bottomBorder, const int &a_leftBorder, const int &a_rightBorder, const int &a_interLabelSpacing)
| Set the border size and spacing for labels within the panel.
void | getBorders (int &a_topBorder, int &a_bottomBorder, int &a_leftBorder, int &a_rightBorder, int &a_interLabelSpacing) const
| Get the border size and spacing for labels within the panel.
void | setAlignment (const int &a_horizontalAlignment, const int &a_verticalAlignment)
| Set the alignment of the _panel_ relative to its position (_not_ the text alignment).
void | getAlignment (int &a_horizontalAlignment, int &a_verticalAlignment) const
| Get the alignment of the _panel_ relative to its position (_not_ the text alignment).
cFont * | getFont () const
| Get the font object used for text rendering.
void | layout ()
void | layoutImmediately ()
## Public Attributes
cColorf | m_textColor
| What color should be used for text?
## Protected Member Functions
void | buildFont ()
| Build a font object, optionally referring to our "backup" copy of an old font.
## Protected Attributes
bool | m_showSquares
| Should we show iconic squares for the different supplied materials?
int | m_topBorder
| The sizes, in pixels, of the borders (padding) inside the panel.
int | m_interLabelSpacing
| The spacing - in pixels - between the lines in the panel.
int | m_halignment
| The horizontal alignment of the panel relative to its position.
int | m_valignment
| The vertical alignment of the panel relative to its position.
int | m_layoutPending
| Do we need to re-layout the next time we render?
std::vector< char * > | m_labels
| The actual label strings.
std::vector< cMaterial > | m_materials
| The materials used for the iconic squares.
int | m_yStep
| The total step from one label to the next.
cFont * | m_font
| The font used for text rendering.
cFont * | m_backupFont

## Detailed Description

This class represents a 2D panel with at least one piece of text on it, optionally including several pieces of text with colored markers next to them (like the key on a graph).

The panel can be auto-sized to fit its contents.

This class is intended to be used for 2D rendering.

## Constructor & Destructor Documentation

cLabelPanel::cLabelPanel | ( | cWorld * | a_world | ) |

Constructor for cLabelPanel.

Constructor of cLabelPanel

Parameters:

  | a_world | The parent CHAI world

cLabelPanel::~cLabelPanel | ( |  | ) | `[virtual]`

Destructor for cLabelPanel.

Destructor of cLabelPanel

## Member Function Documentation

void cLabelPanel::addLabel | ( | const char * | a_label,
|  | const cMaterial * | a_mat = `0` |
| ) |  |  |

Add a label (an additional line of text) to the panel.

Add a new line of text to be rendered.

Parameters:

  | a_label | The text to print
  | a_mat | The color to put in the iconic box for this string, if you have called setShowSquares(true) to render squares for each label. Pass 0 (the default) to use a default material.

void cLabelPanel::setLabel | ( | const unsigned int & | a_index,
|  | const char * | a_label |
| ) |  |  |

Set an existing label to a new line of text.

Add a new line of text to be rendered.

Parameters:

  | a_index | Which label are we changing?
  | a_label | The text to print

const char * cLabelPanel::getLabel | ( | const unsigned int & | a_index | ) | const

Read out a particular label.

Read out a particular label

Parameters:

  | a_index | Which label do you want to read?

Returns:
  The requested label, or 0 for an error

void cLabelPanel::clearLabels | ( |  | ) |

Clear all labels from the panel.

Clear all stored strings

void cLabelPanel::render | ( | const int | a_renderMode = `0` | ) | `[virtual]`

The panel's drawing function.

Render the panel and all strings to the screen

Parameters:

  | a_renderMode | The current rendering pass; see cGenericObject

Reimplemented from cPanel.

void cLabelPanel::onDisplayReset | ( | const bool | a_affectChildren = `true` | ) | `[virtual]`

Allows us to re-create font information after a GL context change.

Allows us to re-create font information after a GL context change

Parameters:

  | a_affectChildren | Should we recursively affect our children?

Reimplemented from cMesh.

void cLabelPanel::setShowSquares | ( | const bool & | a_showSquares | ) |

Should we show iconic squares along with each label?

Should we show iconic colored squares next to each line of text?

Parameters:

  | a_showSquares | True to show iconic squares

void cLabelPanel::setBorders | ( | const int & | a_topBorder,
|  | const int & | a_bottomBorder,
|  | const int & | a_leftBorder,
|  | const int & | a_rightBorder,
|  | const int & | a_interLabelSpacing |
| ) |  |  |

Set the border size and spacing for labels within the panel.

Set the border size and spacing for labels within the panel

Parameters:

  | a_topBorder | Sets the width, in pixels, of a particular border.
  | a_bottomBorder | Sets the width, in pixels, of a particular border.
  | a_leftBorder | Sets the width, in pixels, of a particular border.
  | a_rightBorder | Sets the width, in pixels, of a particular border.
  | a_interLabelSpacing | Sets the spacing, in pixels, between labels.

void cLabelPanel::getBorders | ( | int & | a_topBorder,
|  | int & | a_bottomBorder,
|  | int & | a_leftBorder,
|  | int & | a_rightBorder,
|  | int & | a_interLabelSpacing |
| ) |  |  | const

Get the border size and spacing for labels within the panel.

Get the border size and spacing for labels within the panel

Parameters:

  | a_topBorder | Returns the width, in pixels, of a particular border.
  | a_bottomBorder | Returns the width, in pixels, of a particular border.
  | a_leftBorder | Returns the width, in pixels, of a particular border.
  | a_rightBorder | Returns the width, in pixels, of a particular border.
  | a_interLabelSpacing | Returns the spacing, in pixels, between labels.

void cLabelPanel::setAlignment | ( | const int & | a_horizontalAlignment,
|  | const int & | a_verticalAlignment |
| ) |  |  |

Set the alignment of the _panel_ relative to its position (_not_ the text alignment).

Set the alignment of the _panel_ relative to its position (_not_ the text alignment). Use the horizontal_label_panel_alignments and vertical_label_panel_alignments enumerations found in cLabelPanel.h . For example, a right-aligned panel extends to the left of its current position and vice-versa.

Parameters:

  | a_horizontalAlignment | Should be ALIGN_CENTER, ALIGN_LEFT, or ALIGN_RIGHT
  | a_verticalAlignment | Should be VALIGN_CENTER, VALIGN_TOP, or VALIGN_BOTTOM

void cLabelPanel::layout | ( |  | ) |

Tell the panel to re-arrange its labels the next time it renders

It's not usually necessary to call this directly.

void cLabelPanel::layoutImmediately | ( |  | ) |

Tell the panel to re-arrange its labels _right now_

It's not usually necessary to call this directly.

void cLabelPanel::buildFont | ( |  | ) | `[protected]`

Build a font object, optionally referring to our "backup" copy of an old font.

Build a font object, optionally referring to our "backup" copy of an old font

## Member Data Documentation

cFont* cLabelPanel::m_backupFont`[protected]`

If the display context is nuked, we keep a copy of our font around so we can re-create the same font

The documentation for this class was generated from the following files:

- chai3d/src/widgets/CLabelPanel.h
- chai3d/src/widgets/CLabelPanel.cpp