Panda3D
|
This defines all of the TextProperties structures that might be referenced by name from an embedded text string. More...
#include "textPropertiesManager.h"
Public Member Functions | |
void | clear_graphic (const string &name) |
Removes the named TextGraphic structure from the manager. | |
void | clear_properties (const string &name) |
Removes the named TextProperties structure from the manager. | |
TextGraphic | get_graphic (const string &name) |
Returns the TextGraphic associated with the indicated name. | |
const TextGraphic * | get_graphic_ptr (const string &name) |
Returns a pointer to the TextGraphic with the indicated name, or NULL if there is no graphic with that name. | |
TextProperties | get_properties (const string &name) |
Returns the TextProperties associated with the indicated name. | |
const TextProperties * | get_properties_ptr (const string &name) |
Returns a pointer to the TextProperties with the indicated name, or NULL if there is no properties with that name. | |
bool | has_graphic (const string &name) const |
Returns true if a TextGraphic structure has been associated with the indicated name, false otherwise. | |
bool | has_properties (const string &name) const |
Returns true if a TextProperties structure has been associated with the indicated name, false otherwise. | |
void | set_graphic (const string &name, const TextGraphic &graphic) |
Defines the TextGraphic associated with the indicated name. | |
void | set_graphic (const string &name, const NodePath &model) |
This flavor of set_graphic implicitly creates a frame for the model using the model's actual computed bounding volume, as derived from NodePath::calc_tight_bounds(). | |
void | set_properties (const string &name, const TextProperties &properties) |
Defines the TextProperties associated with the indicated name. | |
void | write (ostream &out, int indent_level=0) const |
Static Public Member Functions | |
static TextPropertiesManager * | get_global_ptr () |
Returns the pointer to the global TextPropertiesManager object. | |
Protected Member Functions | |
TextPropertiesManager () | |
The constructor is not intended to be called directly; there is only one TextPropertiesManager and it constructs itself. | |
~TextPropertiesManager () | |
Don't call the destructor. |
This defines all of the TextProperties structures that might be referenced by name from an embedded text string.
A text string, as rendered by a TextNode, can contain embedded references to one of the TextProperties defined here, by enclosing the name between \1 (ASCII 0x01) characters; this causes a "push" to the named state. All text following the closing \1 character will then be rendered in the new state. The next \2 (ASCII 0x02) character will then restore the previous state for subsequent text.
For instance, "x\1up\1n\2 + y" indicates that the character "x" will be rendered in the normal state, the character "n" will be rendered in the "up" state, and then " + y" will be rendered in the normal state again.
This can also be used to define arbitrary models that can serve as embedded graphic images in a text paragraph. This works similarly; the convention is to create a TextGraphic that describes the graphic image, and then associate it here via the set_graphic() call. Then "\5name\5" will embed the named graphic.
Definition at line 53 of file textPropertiesManager.h.
TextPropertiesManager::TextPropertiesManager | ( | ) | [protected] |
The constructor is not intended to be called directly; there is only one TextPropertiesManager and it constructs itself.
This could have been a private constructor, but gcc issues a spurious warning if the constructor is private and the class has no friends.
Definition at line 30 of file textPropertiesManager.cxx.
Referenced by get_global_ptr().
TextPropertiesManager::~TextPropertiesManager | ( | ) | [protected] |
Don't call the destructor.
Definition at line 39 of file textPropertiesManager.cxx.
void TextPropertiesManager::clear_graphic | ( | const string & | name | ) |
Removes the named TextGraphic structure from the manager.
Definition at line 212 of file textPropertiesManager.cxx.
void TextPropertiesManager::clear_properties | ( | const string & | name | ) |
Removes the named TextProperties structure from the manager.
Definition at line 113 of file textPropertiesManager.cxx.
TextPropertiesManager * TextPropertiesManager::get_global_ptr | ( | ) | [static] |
Returns the pointer to the global TextPropertiesManager object.
Definition at line 238 of file textPropertiesManager.cxx.
References TextPropertiesManager().
TextGraphic TextPropertiesManager::get_graphic | ( | const string & | name | ) |
Returns the TextGraphic associated with the indicated name.
If there was not previously a TextGraphic associated with this name, a warning is printed and then a default TextGraphic structure is associated with the name, and returned.
Call has_graphic() instead to check whether a particular name has been defined.
Definition at line 172 of file textPropertiesManager.cxx.
const TextGraphic * TextPropertiesManager::get_graphic_ptr | ( | const string & | name | ) |
Returns a pointer to the TextGraphic with the indicated name, or NULL if there is no graphic with that name.
Definition at line 270 of file textPropertiesManager.cxx.
TextProperties TextPropertiesManager::get_properties | ( | const string & | name | ) |
Returns the TextProperties associated with the indicated name.
If there was not previously a TextProperties associated with this name, a warning is printed and then a default TextProperties structure is associated with the name, and returned.
Call has_properties() instead to check whether a particular name has been defined.
Definition at line 73 of file textPropertiesManager.cxx.
const TextProperties * TextPropertiesManager::get_properties_ptr | ( | const string & | name | ) |
Returns a pointer to the TextProperties with the indicated name, or NULL if there is no properties with that name.
Definition at line 253 of file textPropertiesManager.cxx.
bool TextPropertiesManager::has_graphic | ( | const string & | name | ) | const |
Returns true if a TextGraphic structure has been associated with the indicated name, false otherwise.
Normally this means set_graphic() has been called with this name, but because get_graphic() will implicitly create a default TextGraphic structure, it may also mean simply that get_graphic() has been called with the indicated name.
Definition at line 199 of file textPropertiesManager.cxx.
bool TextPropertiesManager::has_properties | ( | const string & | name | ) | const |
Returns true if a TextProperties structure has been associated with the indicated name, false otherwise.
Normally this means set_properties() has been called with this name, but because get_properties() will implicitly create a default TextProperties structure, it may also mean simply that get_properties() has been called with the indicated name.
Definition at line 100 of file textPropertiesManager.cxx.
void TextPropertiesManager::set_graphic | ( | const string & | name, |
const TextGraphic & | graphic | ||
) |
Defines the TextGraphic associated with the indicated name.
When the name is subsequently encountered in text embedded between \5 characters in a TextNode string, the specified graphic will be embedded in the text at that point.
If there was already a TextGraphic structure associated with this name, it is quietly replaced with the new definition.
Definition at line 131 of file textPropertiesManager.cxx.
void TextPropertiesManager::set_graphic | ( | const string & | name, |
const NodePath & | model | ||
) |
This flavor of set_graphic implicitly creates a frame for the model using the model's actual computed bounding volume, as derived from NodePath::calc_tight_bounds().
Create a TextGraphic object first if you want to have explicit control of the frame.
Definition at line 146 of file textPropertiesManager.cxx.
References NodePath::calc_tight_bounds(), LVector3f::right(), and LVector3f::up().
void TextPropertiesManager::set_properties | ( | const string & | name, |
const TextProperties & | properties | ||
) |
Defines the TextProperties associated with the indicated name.
When the name is subsequently encountered in text embedded between \1 characters in a TextNode string, the following text will be rendered with these properties.
If there was already a TextProperties structure associated with this name, it is quietly replaced with the new definition.
Definition at line 56 of file textPropertiesManager.cxx.