#include <CLabelPanel.h>
Inheritance diagram for cLabelPanel:
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 |
The panel can be auto-sized to fit its contents.
This class is intended to be used for 2D rendering.
cLabelPanel::cLabelPanel | ( | cWorld * | a_world | ) |
cLabelPanel::~cLabelPanel | ( | ) | [virtual] |
Destructor for cLabelPanel.
Destructor of cLabelPanel
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.
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.
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
a_index | Which label do you want to read? |
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
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
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?
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
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
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.
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
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