Panda3D
|
The primary interface to this module. More...
#include "textNode.h"
Public Types | |
enum | FlattenFlags { FF_none = 0x0000, FF_light = 0x0001, FF_medium = 0x0002, FF_strong = 0x0004, FF_dynamic_merge = 0x0008 } |
Public Member Functions | |
TextNode (const string &name) | |
TextNode (const string &name, const TextProperties ©) | |
It's sort of a copy constructor: it copies the indicated TextProperties, without copying a complete TextNode. | |
void | append_text (const string &text) |
Appends the indicates string to the end of the stored text. | |
void | append_unicode_char (wchar_t character) |
Appends a single character to the end of the stored text. | |
void | append_wtext (const wstring &text) |
Appends the indicates string to the end of the stored wide-character text. | |
virtual void | apply_attribs_to_vertices (const AccumulatedAttribs &attribs, int attrib_types, GeomTransformer &transformer) |
Applies whatever attributes are specified in the AccumulatedAttribs object (and by the attrib_types bitmask) to the vertices on this node, if appropriate. | |
PN_stdfloat | calc_width (wchar_t character) const |
Returns the width of a single character of the font, or 0.0 if the character is not known. | |
PN_stdfloat | calc_width (const string &line) const |
Returns the width of a line of text of arbitrary characters. | |
PN_stdfloat | calc_width (const wstring &line) const |
Returns the width of a line of text of arbitrary characters. | |
void | clear_align () |
Restores the default alignment of the text. | |
void | clear_bin () |
Removes the effect of a previous call to set_bin(). | |
void | clear_card () |
Specifies that a card will not be drawn behind the text. | |
void | clear_card_border () |
void | clear_card_texture () |
void | clear_draw_order () |
void | clear_font () |
Resets the font to the default font. | |
void | clear_frame () |
Specifies that a border will not be drawn around the text. | |
void | clear_glyph_scale () |
void | clear_glyph_shift () |
void | clear_indent () |
Removes the indent setting from the text. | |
void | clear_max_rows () |
Resets the TextNode's default behavior of not limiting the number of rows of text. | |
void | clear_shadow () |
Specifies that a shadow will not be drawn behind the text. | |
void | clear_shadow_color () |
Removes the shadow color specification. | |
void | clear_slant () |
void | clear_small_caps () |
void | clear_small_caps_scale () |
void | clear_tab_width () |
void | clear_text () |
Removes the text from the TextNode. | |
void | clear_text_color () |
Removes the text color specification; the text will be colored whatever it was in the source font file. | |
void | clear_wordwrap () |
Removes the wordwrap setting from the TextNode. | |
virtual void | compute_internal_bounds (CPT(BoundingVolume)&internal_bounds, int &internal_vertices, int pipeline_stage, Thread *current_thread) const |
Called when needed to recompute the node's _internal_bound object. | |
virtual | CPT (TransformState) calc_tight_bounds(LPoint3 &min_point |
virtual bool | cull_callback (CullTraverser *trav, CullTraverserData &data) |
This function will be called during the cull traversal to perform any additional operations that should be performed at cull time. | |
virtual TypeHandle | force_init_type () |
void | force_update () |
Forces the TextNode to recompute itself now, even if it believes nothing has changed. | |
PN_stdfloat | get_bottom () const |
Returns the bottommost extent of the text in local 2-d coordinates, unmodified by the set_transform() matrix. | |
LVecBase4 | get_card_actual () const |
Returns the actual dimensions of the card around the text. | |
LVecBase4 | get_card_as_set () const |
Returns the dimensions of the card as set by set_card_as_margin() or set_card_actual(). | |
PN_stdfloat | get_card_border_size () const |
PN_stdfloat | get_card_border_uv_portion () const |
LColor | get_card_color () const |
bool | get_card_decal () const |
Returns the card_decal flag. | |
Texture * | get_card_texture () const |
LVecBase4 | get_card_transformed () const |
Returns the actual card dimensions, transformed by the matrix set by set_transform(). | |
CoordinateSystem | get_coordinate_system () const |
int | get_flatten_flags () const |
Returns the flatten flags. | |
LVecBase4 | get_frame_actual () const |
Returns the actual dimensions of the frame around the text. | |
LVecBase4 | get_frame_as_set () const |
Returns the dimensions of the frame as set by set_frame_as_margin() or set_frame_actual(). | |
LColor | get_frame_color () const |
bool | get_frame_corners () const |
PN_stdfloat | get_frame_line_width () const |
Returns the thickness of the lines that will be used to draw the frame. | |
PN_stdfloat | get_height () const |
Returns the net height of the text in local 2-d coordinates. | |
PandaNode * | get_internal_geom () const |
Returns the actual node that is used internally to render the text, if the TextNode is parented within the scene graph. | |
PN_stdfloat | get_left () const |
Returns the leftmost extent of the text in local 2-d coordinates, unmodified by the set_transform() matrix. | |
PN_stdfloat | get_line_height () const |
Returns the number of units high each line of text is. | |
LPoint3 | get_lower_right_3d () const |
Returns the lower-right extent of the text object, after it has been transformed into 3-d space by applying the set_transform() matrix. | |
int | get_max_rows () const |
Returns the limit on the height of the TextNode specified by set_max_rows(). | |
int | get_num_rows () const |
Returns the number of rows of text that were generated. | |
PN_stdfloat | get_right () const |
Returns the rightmost extent of the text in local 2-d coordinates, unmodified by the set_transform() matrix. | |
PN_stdfloat | get_top () const |
Returns the topmost extent of the text in local 2-d coordinates, unmodified by the set_transform() matrix. | |
LMatrix4 | get_transform () const |
virtual TypeHandle | get_type () const |
virtual int | get_unsafe_to_apply_attribs () const |
Returns the union of all attributes from SceneGraphReducer::AttribTypes that may not safely be applied to the vertices of this node. | |
LPoint3 | get_upper_left_3d () const |
Returns the upper-left extent of the text object, after it has been transformed into 3-d space by applying the set_transform() matrix. | |
Geom::UsageHint | get_usage_hint () const |
Returns the UsageHint that will be applied to generated geometry. | |
PN_stdfloat | get_width () const |
Returns the net width of the text in local 2-d coordinates. | |
string | get_wordwrapped_text () const |
Returns a string that represents the contents of the text, as it has been formatted by wordwrap rules. | |
wstring | get_wordwrapped_wtext () const |
Returns a wstring that represents the contents of the text, as it has been formatted by wordwrap rules. | |
bool | has_card () const |
bool | has_card_border () const |
bool | has_card_texture () const |
bool | has_character (wchar_t character) const |
Returns true if the named character exists in the font or can be synthesized by Panda, false otherwise. | |
bool | has_exact_character (wchar_t character) const |
Returns true if the named character exists in the font exactly as named, false otherwise. | |
bool | has_frame () const |
bool | has_max_rows () const |
Returns true if a limit on the height of the TextNode has been set via set_max_rows(), false otherwise. | |
bool | has_overflow () const |
Returns true if the last text set on the text node exceeded the max_rows constraint, or false if it all fit. | |
bool | is_card_as_margin () const |
If this is true, the card was set via a call to set_card_as_margin(), and the dimension of the card as returned by get_card_as_set() represent a margin all around the text. | |
bool | is_frame_as_margin () const |
If this is true, the frame was set via a call to set_frame_as_margin(), and the dimension of the frame as returned by get_frame_as_set() represent a margin all around the text. | |
virtual bool | is_renderable () const |
Returns true if there is some value to visiting this particular node during the cull traversal for any camera, false otherwise. | |
bool | is_whitespace (wchar_t character) const |
Returns true if the indicated character represents whitespace in the font, or false if anything visible will be rendered for it. | |
virtual void | output (ostream &out) const |
Outputs the Namable. | |
PT (PandaNode) generate() | |
virtual void | r_prepare_scene (GraphicsStateGuardianBase *gsg, const RenderState *node_state, GeomTransformer &transformer, Thread *current_thread) |
The recursive implementation of prepare_scene(). | |
void | set_align (Alignment align_type) |
Specifies the alignment of the text within its margins. | |
void | set_bin (const string &bin) |
Names the GeomBin that the TextNode geometry should be assigned to. | |
void | set_card_actual (PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top) |
Similar to set_card_as_margin, except the card is specified in actual coordinate units (relative to the text's origin), irrespective of the size of the text. | |
void | set_card_as_margin (PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top) |
Specifies that a (possibly opaque or semitransparent) card will be held behind the text when it is next created. | |
void | set_card_border (PN_stdfloat size, PN_stdfloat uv_portion) |
void | set_card_color (PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a) |
void | set_card_color (const LColor &card_color) |
void | set_card_decal (bool card_decal) |
Sets the card_decal flag. | |
void | set_card_texture (Texture *card_texture) |
void | set_coordinate_system (CoordinateSystem cs) |
Specifies the coordinate system in which the text will be generated. | |
int | set_draw_order (int draw_order) |
Sets the drawing order of text created by the TextMaker. | |
void | set_flatten_flags (int flatten_flags) |
Sets the flatten flags. | |
void | set_font (TextFont *font) |
Sets the font that will be used when making text. | |
void | set_frame_actual (PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top) |
Similar to set_frame_as_margin, except the frame is specified in actual coordinate units (relative to the text's origin), irrespective of the size of the text. | |
void | set_frame_as_margin (PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top) |
Specifies that a border will be drawn around the text when it is next created. | |
void | set_frame_color (PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a) |
void | set_frame_color (const LColor &frame_color) |
void | set_frame_corners (bool corners) |
Enables or disables the drawing of corners for the frame. | |
void | set_frame_line_width (PN_stdfloat line_width) |
Specifies the thickness of the lines that will be used to draw the frame. | |
void | set_glyph_scale (PN_stdfloat glyph_scale) |
Specifies the factor by which to scale each letter of the text as it is placed. | |
void | set_glyph_shift (PN_stdfloat glyph_shift) |
Specifies a vertical amount to shift each letter of the text as it is placed. | |
void | set_indent (PN_stdfloat indent) |
Specifies the amount of extra space that is inserted before the first character of each line. | |
void | set_max_rows (int max_rows) |
Sets the maximum number of rows that may be formatted by the TextNode. | |
void | set_shadow (PN_stdfloat xoffset, PN_stdfloat yoffset) |
Specifies that the text should be drawn with a shadow, by creating a second copy of the text and offsetting it slightly behind the first. | |
void | set_shadow (const LVecBase2 &shadow_offset) |
Specifies that the text should be drawn with a shadow, by creating a second copy of the text and offsetting it slightly behind the first. | |
void | set_shadow_color (PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a) |
void | set_shadow_color (const LColor &shadow_color) |
void | set_slant (PN_stdfloat slant) |
Specifies the factor by which the text slants to the right. | |
void | set_small_caps (bool small_caps) |
Sets the small_caps flag. | |
void | set_small_caps_scale (PN_stdfloat small_caps_scale) |
Sets the scale factor applied to lowercase letters from their uppercase equivalents, when the small_caps flag is in effect. | |
void | set_tab_width (PN_stdfloat tab_width) |
Sets the width of each tab stop, in screen units. | |
void | set_text (const string &text) |
Changes the text that is displayed under the TextNode. | |
void | set_text (const string &text, Encoding encoding) |
The two-parameter version of set_text() accepts an explicit encoding; the text is immediately decoded and stored as a wide-character string. | |
void | set_text_color (PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a) |
void | set_text_color (const LColor &text_color) |
void | set_transform (const LMatrix4 &transform) |
Sets an additional transform that is applied to the entire text paragraph. | |
void | set_usage_hint (Geom::UsageHint usage_hint) |
Specifies the UsageHint that will be applied to generated geometry. | |
void | set_wordwrap (PN_stdfloat wordwrap) |
Sets the text up to automatically wordwrap when it exceeds the indicated width. | |
void | set_wtext (const wstring &wtext) |
Changes the text that is displayed under the TextNode, with a wide text. | |
void | update () |
Can be called after the TextNode has been fully configured, to force the node to recompute its text immediately, rather than waiting for it to be drawn. | |
virtual void | write (ostream &out, int indent_level=0) const |
Static Public Member Functions | |
static TypeHandle | get_class_type () |
static void | init_type () |
Public Attributes | |
virtual LPoint3 bool const TransformState Thread *current_thread | const |
virtual LPoint3 bool & | found_any |
virtual LPoint3 & | max_point |
virtual LPoint3 bool const TransformState * | transform |
Protected Member Functions | |
TextNode (const TextNode ©) | |
OK, this is a true copy constructor. | |
virtual PandaNode * | make_copy () const |
Returns a newly-allocated Node that is a shallow copy of this one. |
The primary interface to this module.
This class does basic text assembly; given a string of text and a TextFont object, it creates a piece of geometry that may be placed in the 3-d or 2-d world to represent the indicated text.
The TextNode may be used in one of two ways. Naively, it may simply be parented directly into the scene graph and rendered as if it were a GeomNode; in this mode, the actual polygon geometry that renders the text is not directly visible or accessible, but remains hidden within the TextNode.
The second way TextNode may be used is as a text generator. To use it in this way, do not parent the TextNode to the scene graph; instead, set the properties of the text and call generate() to return an ordinary node, containing ordinary geometry, which you may use however you like. Each time you call generate() a new node is returned.
Definition at line 52 of file textNode.h.
TextNode::TextNode | ( | const string & | name, |
const TextProperties & | copy | ||
) |
It's sort of a copy constructor: it copies the indicated TextProperties, without copying a complete TextNode.
Definition at line 106 of file textNode.cxx.
References LMatrix4f::ident_mat().
TextNode::TextNode | ( | const TextNode & | copy | ) | [protected] |
OK, this is a true copy constructor.
Definition at line 136 of file textNode.cxx.
void TextNode::append_text | ( | const string & | text | ) | [inline] |
Appends the indicates string to the end of the stored text.
Reimplemented from TextEncoder.
Definition at line 1210 of file textNode.I.
void TextNode::append_unicode_char | ( | wchar_t | character | ) | [inline] |
Appends a single character to the end of the stored text.
This may be a wide character, up to 16 bits in Unicode.
Definition at line 1223 of file textNode.I.
void TextNode::append_wtext | ( | const wstring & | text | ) | [inline] |
Appends the indicates string to the end of the stored wide-character text.
Reimplemented from TextEncoder.
Definition at line 1276 of file textNode.I.
void TextNode::apply_attribs_to_vertices | ( | const AccumulatedAttribs & | attribs, |
int | attrib_types, | ||
GeomTransformer & | transformer | ||
) | [virtual] |
Applies whatever attributes are specified in the AccumulatedAttribs object (and by the attrib_types bitmask) to the vertices on this node, if appropriate.
If this node uses geom arrays like a GeomNode, the supplied GeomTransformer may be used to unify shared arrays across multiple different nodes.
This is a generalization of xform().
Reimplemented from PandaNode.
Definition at line 558 of file textNode.cxx.
References SceneGraphReducer::apply_attribs(), ColorAttrib::get_color(), ColorAttrib::get_color_type(), and ColorScaleAttrib::get_scale().
PN_stdfloat TextNode::calc_width | ( | wchar_t | character | ) | const |
Returns the width of a single character of the font, or 0.0 if the character is not known.
This may be a wide character (greater than 255).
Definition at line 191 of file textNode.cxx.
References TextProperties::get_font().
Referenced by calc_width().
PN_stdfloat TextNode::calc_width | ( | const string & | line | ) | const [inline] |
Returns the width of a line of text of arbitrary characters.
The line should not include the newline character.
Definition at line 1251 of file textNode.I.
References calc_width(), and TextEncoder::decode_text().
PN_stdfloat TextNode::calc_width | ( | const wstring & | line | ) | const |
Returns the width of a line of text of arbitrary characters.
The line should not include the newline character or any embedded control characters like \1 or \3.
Definition at line 291 of file textNode.cxx.
References calc_width().
void TextNode::clear_align | ( | ) | [inline] |
Restores the default alignment of the text.
Reimplemented from TextProperties.
Definition at line 868 of file textNode.I.
void TextNode::clear_bin | ( | ) | [inline] |
Removes the effect of a previous call to set_bin().
Text will be drawn in whatever bin it would like to be drawn in, with no explicit ordering.
Reimplemented from TextProperties.
Definition at line 1052 of file textNode.I.
void TextNode::clear_card | ( | ) | [inline] |
Specifies that a card will not be drawn behind the text.
Definition at line 506 of file textNode.I.
void TextNode::clear_font | ( | ) | [inline] |
Resets the font to the default font.
Reimplemented from TextProperties.
Definition at line 761 of file textNode.I.
void TextNode::clear_frame | ( | ) | [inline] |
Specifies that a border will not be drawn around the text.
Definition at line 315 of file textNode.I.
void TextNode::clear_indent | ( | ) | [inline] |
Removes the indent setting from the text.
Text will be as wide as it is.
Reimplemented from TextProperties.
Definition at line 892 of file textNode.I.
void TextNode::clear_max_rows | ( | ) | [inline] |
Resets the TextNode's default behavior of not limiting the number of rows of text.
Definition at line 56 of file textNode.I.
void TextNode::clear_shadow | ( | ) | [inline] |
Specifies that a shadow will not be drawn behind the text.
Reimplemented from TextProperties.
Definition at line 1019 of file textNode.I.
void TextNode::clear_shadow_color | ( | ) | [inline] |
Removes the shadow color specification.
Reimplemented from TextProperties.
Definition at line 982 of file textNode.I.
void TextNode::clear_text | ( | ) | [inline] |
Removes the text from the TextNode.
Reimplemented from TextEncoder.
Definition at line 1198 of file textNode.I.
void TextNode::clear_text_color | ( | ) | [inline] |
Removes the text color specification; the text will be colored whatever it was in the source font file.
Reimplemented from TextProperties.
Definition at line 950 of file textNode.I.
void TextNode::clear_wordwrap | ( | ) | [inline] |
Removes the wordwrap setting from the TextNode.
Text will be as wide as it is.
Reimplemented from TextProperties.
Definition at line 917 of file textNode.I.
void TextNode::compute_internal_bounds | ( | CPT(BoundingVolume)& | internal_bounds, |
int & | internal_vertices, | ||
int | pipeline_stage, | ||
Thread * | current_thread | ||
) | const [virtual] |
Called when needed to recompute the node's _internal_bound object.
Nodes that contain anything of substance should redefine this to do the right thing.
Reimplemented from PandaNode.
Definition at line 721 of file textNode.cxx.
References GeometricBoundingVolume::around().
bool TextNode::cull_callback | ( | CullTraverser * | trav, |
CullTraverserData & | data | ||
) | [virtual] |
This function will be called during the cull traversal to perform any additional operations that should be performed at cull time.
This may include additional manipulation of render state or additional visible/invisible decisions, or any other arbitrary operation.
Note that this function will *not* be called unless set_cull_callback() is called in the constructor of the derived class. It is necessary to call set_cull_callback() to indicated that we require cull_callback() to be called.
By the time this function is called, the node has already passed the bounding-volume test for the viewing frustum, and the node's transform and state have already been applied to the indicated CullTraverserData object.
The return value is true if this node should be visible, or false if it should be culled.
Reimplemented from PandaNode.
Reimplemented in FrameRateMeter, and SceneGraphAnalyzerMeter.
Definition at line 685 of file textNode.cxx.
References CullTraverser::traverse().
void TextNode::force_update | ( | ) | [inline] |
Forces the TextNode to recompute itself now, even if it believes nothing has changed.
Normally, this should not need to be called, but it may be useful if some properties change outside of the TextNode's knowledge (for instance, within the font).
Definition at line 1435 of file textNode.I.
PN_stdfloat TextNode::get_bottom | ( | ) | const [inline] |
Returns the bottommost extent of the text in local 2-d coordinates, unmodified by the set_transform() matrix.
Definition at line 1331 of file textNode.I.
LVecBase4 TextNode::get_card_actual | ( | ) | const [inline] |
Returns the actual dimensions of the card around the text.
If the card was set via set_card_as_margin(), the result returned by this function reflects the size of the current text; if the card was set via set_card_actual(), this returns the values actually set.
If the text has no card at all, this returns the dimensions of the text itself, as if the card were set with a margin of 0, 0, 0, 0.
Definition at line 578 of file textNode.I.
References get_card_as_set(), and is_card_as_margin().
Referenced by get_card_transformed(), and PGButton::setup().
LVecBase4 TextNode::get_card_as_set | ( | ) | const [inline] |
Returns the dimensions of the card as set by set_card_as_margin() or set_card_actual().
Use is_card_actual() to determine how to interpret the values returned by this function. It is an error to call this if has_card() is false.
Definition at line 558 of file textNode.I.
Referenced by get_card_actual().
bool TextNode::get_card_decal | ( | ) | const [inline] |
LVecBase4 TextNode::get_card_transformed | ( | ) | const [inline] |
Returns the actual card dimensions, transformed by the matrix set by set_transform().
This returns the card dimensions in actual coordinates as seen by the rest of the world. Also see get_upper_left_3d() and get_lower_right_3d().
Definition at line 604 of file textNode.I.
References get_card_actual().
int TextNode::get_flatten_flags | ( | ) | const [inline] |
LVecBase4 TextNode::get_frame_actual | ( | ) | const [inline] |
Returns the actual dimensions of the frame around the text.
If the frame was set via set_frame_as_margin(), the result returned by this function reflects the size of the current text; if the frame was set via set_frame_actual(), this returns the values actually set.
If the text has no frame at all, this returns the dimensions of the text itself, as if the frame were set with a margin of 0, 0, 0, 0.
Definition at line 377 of file textNode.I.
References get_frame_as_set(), and is_frame_as_margin().
Referenced by PandaFramework::event_question().
LVecBase4 TextNode::get_frame_as_set | ( | ) | const [inline] |
Returns the dimensions of the frame as set by set_frame_as_margin() or set_frame_actual().
Use is_frame_actual() to determine how to interpret the values returned by this function. It is an error to call this if has_frame() is false.
Definition at line 357 of file textNode.I.
Referenced by get_frame_actual().
PN_stdfloat TextNode::get_frame_line_width | ( | ) | const [inline] |
Returns the thickness of the lines that will be used to draw the frame.
Definition at line 412 of file textNode.I.
PN_stdfloat TextNode::get_height | ( | ) | const [inline] |
Returns the net height of the text in local 2-d coordinates.
Definition at line 1356 of file textNode.I.
PandaNode * TextNode::get_internal_geom | ( | ) | const |
Returns the actual node that is used internally to render the text, if the TextNode is parented within the scene graph.
In general, you should not call this method. Call generate() instead if you want to get a handle to geometry that represents the text. This method is provided as a debugging aid only.
Definition at line 515 of file textNode.cxx.
PN_stdfloat TextNode::get_left | ( | ) | const [inline] |
Returns the leftmost extent of the text in local 2-d coordinates, unmodified by the set_transform() matrix.
Definition at line 1305 of file textNode.I.
PN_stdfloat TextNode::get_line_height | ( | ) | const [inline] |
Returns the number of units high each line of text is.
This is based on the font. Note that it is possible for the text to include nested font change commands, in which case the value of this method is questionable.
Definition at line 26 of file textNode.I.
References TextProperties::get_font(), and TextFont::get_line_height().
Referenced by PGEntry::setup(), and PGEntry::setup_minimal().
LPoint3 TextNode::get_lower_right_3d | ( | ) | const [inline] |
Returns the lower-right extent of the text object, after it has been transformed into 3-d space by applying the set_transform() matrix.
Definition at line 1394 of file textNode.I.
int TextNode::get_max_rows | ( | ) | const [inline] |
Returns the limit on the height of the TextNode specified by set_max_rows().
Definition at line 79 of file textNode.I.
int TextNode::get_num_rows | ( | ) | const [inline] |
Returns the number of rows of text that were generated.
This counts word-wrapped rows as well as rows generated due to embedded newlines.
Definition at line 1407 of file textNode.I.
PN_stdfloat TextNode::get_right | ( | ) | const [inline] |
Returns the rightmost extent of the text in local 2-d coordinates, unmodified by the set_transform() matrix.
Definition at line 1318 of file textNode.I.
PN_stdfloat TextNode::get_top | ( | ) | const [inline] |
Returns the topmost extent of the text in local 2-d coordinates, unmodified by the set_transform() matrix.
Definition at line 1344 of file textNode.I.
int TextNode::get_unsafe_to_apply_attribs | ( | ) | const [virtual] |
Returns the union of all attributes from SceneGraphReducer::AttribTypes that may not safely be applied to the vertices of this node.
If this is nonzero, these attributes must be dropped at this node as a state change.
This is a generalization of safe_to_transform().
Reimplemented from PandaNode.
Definition at line 536 of file textNode.cxx.
LPoint3 TextNode::get_upper_left_3d | ( | ) | const [inline] |
Returns the upper-left extent of the text object, after it has been transformed into 3-d space by applying the set_transform() matrix.
Definition at line 1381 of file textNode.I.
Geom::UsageHint TextNode::get_usage_hint | ( | ) | const [inline] |
Returns the UsageHint that will be applied to generated geometry.
See set_usage_hint().
Definition at line 679 of file textNode.I.
PN_stdfloat TextNode::get_width | ( | ) | const [inline] |
Returns the net width of the text in local 2-d coordinates.
Definition at line 1368 of file textNode.I.
string TextNode::get_wordwrapped_text | ( | ) | const [inline] |
Returns a string that represents the contents of the text, as it has been formatted by wordwrap rules.
In earlier versions, this did not contain any embedded special characters like \1 or \3; now it does.
Definition at line 1239 of file textNode.I.
References TextEncoder::encode_wtext(), and get_wordwrapped_wtext().
wstring TextNode::get_wordwrapped_wtext | ( | ) | const [inline] |
Returns a wstring that represents the contents of the text, as it has been formatted by wordwrap rules.
In earlier versions, this did not contain any embedded special characters like \1 or \3; now it does.
Definition at line 1292 of file textNode.I.
Referenced by get_wordwrapped_text().
bool TextNode::has_character | ( | wchar_t | character | ) | const |
Returns true if the named character exists in the font or can be synthesized by Panda, false otherwise.
(Panda can synthesize some accented characters by combining similar-looking glyphs from the font.)
This returns true for whitespace and Unicode whitespace characters (if they exist in the font), but returns false for characters that would render with the "invalid glyph".
Definition at line 242 of file textNode.cxx.
References TextProperties::get_font().
bool TextNode::has_exact_character | ( | wchar_t | character | ) | const |
Returns true if the named character exists in the font exactly as named, false otherwise.
Note that because Panda can assemble glyphs together automatically using cheesy accent marks, this is not a reliable indicator of whether a suitable glyph can be rendered for the character. For that, use has_character() instead.
This returns true for whitespace and Unicode whitespace characters (if they exist in the font), but returns false for characters that would render with the "invalid glyph". It also returns false for characters that would be synthesized within Panda, but see has_character().
Definition at line 219 of file textNode.cxx.
References TextProperties::get_font().
bool TextNode::has_max_rows | ( | ) | const [inline] |
Returns true if a limit on the height of the TextNode has been set via set_max_rows(), false otherwise.
Definition at line 68 of file textNode.I.
bool TextNode::has_overflow | ( | ) | const [inline] |
Returns true if the last text set on the text node exceeded the max_rows constraint, or false if it all fit.
Definition at line 91 of file textNode.I.
bool TextNode::is_card_as_margin | ( | ) | const [inline] |
If this is true, the card was set via a call to set_card_as_margin(), and the dimension of the card as returned by get_card_as_set() represent a margin all around the text.
If false, then the card was set via a call to set_card_actual(), and the dimensions of the card as returned by get_card_as_set() are relative to the text's origin.
Definition at line 543 of file textNode.I.
Referenced by get_card_actual().
bool TextNode::is_frame_as_margin | ( | ) | const [inline] |
If this is true, the frame was set via a call to set_frame_as_margin(), and the dimension of the frame as returned by get_frame_as_set() represent a margin all around the text.
If false, then the frame was set via a call to set_frame_actual(), and the dimensions of the frame as returned by get_frame_as_set() are relative to the text's origin.
Definition at line 342 of file textNode.I.
Referenced by get_frame_actual().
bool TextNode::is_renderable | ( | ) | const [virtual] |
Returns true if there is some value to visiting this particular node during the cull traversal for any camera, false otherwise.
This will be used to optimize the result of get_net_draw_show_mask(), so that any subtrees that contain only nodes for which is_renderable() is false need not be visited.
Reimplemented from PandaNode.
Definition at line 708 of file textNode.cxx.
bool TextNode::is_whitespace | ( | wchar_t | character | ) | const |
Returns true if the indicated character represents whitespace in the font, or false if anything visible will be rendered for it.
This returns true for whitespace and Unicode whitespace characters (if they exist in the font), and returns false for any other characters, including characters that do not exist in the font (these would be rendered with the "invalid glyph", which is visible).
Note that this function can be reliably used to identify Unicode whitespace characters only if the font has all of the whitespace characters defined. It will return false for any character not in the font, even if it is an official Unicode whitespace character.
Definition at line 273 of file textNode.cxx.
References TextProperties::get_font().
PandaNode * TextNode::make_copy | ( | ) | const [protected, virtual] |
void TextNode::output | ( | ostream & | out | ) | const [virtual] |
Outputs the Namable.
This function simply writes the name to the output stream; most Namable derivatives will probably redefine this.
Reimplemented from PandaNode.
Definition at line 308 of file textNode.cxx.
void TextNode::r_prepare_scene | ( | GraphicsStateGuardianBase * | gsg, |
const RenderState * | node_state, | ||
GeomTransformer & | transformer, | ||
Thread * | current_thread | ||
) | [virtual] |
The recursive implementation of prepare_scene().
Don't call this directly; call PandaNode::prepare_scene() or NodePath::prepare_scene() instead.
Reimplemented from PandaNode.
Definition at line 760 of file textNode.cxx.
References PandaNode::get_state(), and PandaNode::r_prepare_scene().
void TextNode::set_align | ( | TextNode::Alignment | align_type | ) | [inline] |
Specifies the alignment of the text within its margins.
Reimplemented from TextProperties.
Definition at line 857 of file textNode.I.
Referenced by PandaFramework::event_f9(), and PandaFramework::event_question().
void TextNode::set_bin | ( | const string & | bin | ) | [inline] |
Names the GeomBin that the TextNode geometry should be assigned to.
If this is set, then a GeomBinTransition will be created to explicitly place each component in the named bin.
The draw_order value will also be passed to each GeomBinTransition as appropriate; this is particularly useful if this names a GeomBinFixed, e.g. "fixed".
Reimplemented from TextProperties.
Definition at line 1038 of file textNode.I.
void TextNode::set_card_actual | ( | PN_stdfloat | left, |
PN_stdfloat | right, | ||
PN_stdfloat | bottom, | ||
PN_stdfloat | top | ||
) | [inline] |
Similar to set_card_as_margin, except the card is specified in actual coordinate units (relative to the text's origin), irrespective of the size of the text.
The left and bottom coordinates should generally be negative, while the right and top coordinates should generally be positive.
Definition at line 473 of file textNode.I.
void TextNode::set_card_as_margin | ( | PN_stdfloat | left, |
PN_stdfloat | right, | ||
PN_stdfloat | bottom, | ||
PN_stdfloat | top | ||
) | [inline] |
Specifies that a (possibly opaque or semitransparent) card will be held behind the text when it is next created.
Like set_frame_as_margin, the parameters are the amount of additional padding to insert around the text in each dimension, and all should generally be positive.
Definition at line 455 of file textNode.I.
void TextNode::set_card_decal | ( | bool | card_decal | ) | [inline] |
Sets the card_decal flag.
When this is true, the text is decalled onto the card, which is necessary if the TextNode is to be rendered in the 3-d world without putting it in a bin.
Definition at line 490 of file textNode.I.
void TextNode::set_coordinate_system | ( | CoordinateSystem | cs | ) | [inline] |
Specifies the coordinate system in which the text will be generated.
Definition at line 641 of file textNode.I.
int TextNode::set_draw_order | ( | int | draw_order | ) | [inline] |
Sets the drawing order of text created by the TextMaker.
This is actually the draw order of the card and frame. The shadow is drawn at _draw_order+1, and the text at _draw_order+2.
This affects the sorting order assigned to the arcs as they are created, and also is passed to whatever bin may be assigned via set_bin().
The return value is the first unused draw_order number, e.g. _draw_order + 3.
Reimplemented from TextProperties.
Definition at line 1073 of file textNode.I.
void TextNode::set_flatten_flags | ( | int | flatten_flags | ) | [inline] |
Sets the flatten flags.
This should be a union of the TextNode::FlattenFlags options. This controls the degree of flattening performed on the TextNode's internal geometry (i.e. the scene graph returned by generate()) each time the text is changed. In general, more flattening means a more optimal result, but it will take more time to generate.
The choice may be any of these three:
FF_none - No flatten operation is called. The letters are left as independent Geoms.
FF_light - A flatten_light() operation is called. The attributes are applied to the vertices, but no nodes are removed.
FF_medium - A flatten_medium() operation is called. The attributes are applied to the vertices, and a few trivial nodes are removed.
FF_strong - A flatten_strong() operation is called. The attributes are applied to the vertices, and the resulting nodes are aggressively combined into as few nodes as possible.
In addition to the above choices, you may optionally include the following flag:
FF_dynamic_merge - Copy the geoms into a single GeomVertexData as we go, instead of relying on the flatten operation at the end. This pre-flattens the text considerably, and may obviate the need for flatten altogether; it also tends to improve performance considerably even if you do call flatten. However, it is not as fast as not calling flatten at all.
The default is taken from the text-flatten and text-dynamic-merge config variables.
Definition at line 728 of file textNode.I.
void TextNode::set_font | ( | TextFont * | font | ) | [inline] |
Sets the font that will be used when making text.
If this is set to NULL, the default font will be used, which can be set via set_default_font().
Reimplemented from TextProperties.
Definition at line 750 of file textNode.I.
void TextNode::set_frame_actual | ( | PN_stdfloat | left, |
PN_stdfloat | right, | ||
PN_stdfloat | bottom, | ||
PN_stdfloat | top | ||
) | [inline] |
Similar to set_frame_as_margin, except the frame is specified in actual coordinate units (relative to the text's origin), irrespective of the size of the text.
The left and bottom coordinates should generally be negative, while the right and top coordinates should generally be positive.
Definition at line 300 of file textNode.I.
void TextNode::set_frame_as_margin | ( | PN_stdfloat | left, |
PN_stdfloat | right, | ||
PN_stdfloat | bottom, | ||
PN_stdfloat | top | ||
) | [inline] |
Specifies that a border will be drawn around the text when it is next created.
The parameters are the amount of additional padding to insert between the frame and the text in each dimension, and all should generally be positive.
Definition at line 282 of file textNode.I.
void TextNode::set_frame_corners | ( | bool | corners | ) | [inline] |
Enables or disables the drawing of corners for the frame.
These are extra points drawn at each of the four corners, to soften the ugly edges generated when the line width is greater than one.
Definition at line 425 of file textNode.I.
void TextNode::set_frame_line_width | ( | PN_stdfloat | line_width | ) | [inline] |
Specifies the thickness of the lines that will be used to draw the frame.
Definition at line 400 of file textNode.I.
void TextNode::set_glyph_scale | ( | PN_stdfloat | glyph_scale | ) | [inline] |
Specifies the factor by which to scale each letter of the text as it is placed.
This can be used (possibly in conjunction with set_glyph_shift()) to implement superscripting or subscripting.
Reimplemented from TextProperties.
Definition at line 1122 of file textNode.I.
void TextNode::set_glyph_shift | ( | PN_stdfloat | glyph_shift | ) | [inline] |
Specifies a vertical amount to shift each letter of the text as it is placed.
This can be used (possibly in conjunction with set_glyph_scale()) to implement superscripting or subscripting.
Reimplemented from TextProperties.
Definition at line 1147 of file textNode.I.
void TextNode::set_indent | ( | PN_stdfloat | indent | ) | [inline] |
Specifies the amount of extra space that is inserted before the first character of each line.
This can be thought of as a left margin.
Reimplemented from TextProperties.
Definition at line 881 of file textNode.I.
void TextNode::set_max_rows | ( | int | max_rows | ) | [inline] |
Sets the maximum number of rows that may be formatted by the TextNode.
If more text than this is attempted, it will be truncated and has_overflow() will return true.
Definition at line 44 of file textNode.I.
void TextNode::set_shadow | ( | PN_stdfloat | xoffset, |
PN_stdfloat | yoffset | ||
) | [inline] |
Specifies that the text should be drawn with a shadow, by creating a second copy of the text and offsetting it slightly behind the first.
Reimplemented from TextProperties.
Definition at line 995 of file textNode.I.
Referenced by PandaFramework::event_f9(), PandaFramework::event_question(), and set_shadow().
void TextNode::set_shadow | ( | const LVecBase2 & | shadow_offset | ) | [inline] |
Specifies that the text should be drawn with a shadow, by creating a second copy of the text and offsetting it slightly behind the first.
Reimplemented from TextProperties.
Definition at line 1007 of file textNode.I.
References set_shadow().
void TextNode::set_slant | ( | PN_stdfloat | slant | ) | [inline] |
Specifies the factor by which the text slants to the right.
Reimplemented from TextProperties.
Definition at line 835 of file textNode.I.
void TextNode::set_small_caps | ( | bool | small_caps | ) | [inline] |
Sets the small_caps flag.
When this is set, lowercase letters are generated as scaled-down versions of their uppercase equivalents. This is particularly useful to set for fonts that do not have lowercase letters.
It is also a good idea to set this for a (dynamic) font that has already implemented lowercase letters as scaled-down versions of their uppercase equivalents, since without this flag the texture memory may needlessly duplicate equivalent glyphs for upper and lowercase letters. Setting this flag causes the texture memory to share the mixed-case letters.
The amount by which the lowercase letters are scaled is specified by set_small_caps_scale().
Reimplemented from TextProperties.
Definition at line 788 of file textNode.I.
void TextNode::set_small_caps_scale | ( | PN_stdfloat | small_caps_scale | ) | [inline] |
Sets the scale factor applied to lowercase letters from their uppercase equivalents, when the small_caps flag is in effect.
See set_small_caps(). Normally, this will be a number less than one.
Reimplemented from TextProperties.
Definition at line 813 of file textNode.I.
void TextNode::set_tab_width | ( | PN_stdfloat | tab_width | ) | [inline] |
Sets the width of each tab stop, in screen units.
A tab character embedded in the text will advance the horizontal position to the next tab stop.
Reimplemented from TextProperties.
Definition at line 1097 of file textNode.I.
void TextNode::set_text | ( | const string & | text | ) | [inline] |
Changes the text that is displayed under the TextNode.
Reimplemented from TextEncoder.
Definition at line 1171 of file textNode.I.
Referenced by PandaFramework::event_f9(), PandaFramework::event_question(), set_text(), and PGButton::setup().
void TextNode::set_text | ( | const string & | text, |
TextNode::Encoding | encoding | ||
) | [inline] |
The two-parameter version of set_text() accepts an explicit encoding; the text is immediately decoded and stored as a wide-character string.
Subsequent calls to get_text() will return the same text re-encoded using whichever encoding is specified by set_encoding().
Reimplemented from TextEncoder.
Definition at line 1187 of file textNode.I.
References set_text().
void TextNode::set_transform | ( | const LMatrix4 & | transform | ) | [inline] |
Sets an additional transform that is applied to the entire text paragraph.
Definition at line 619 of file textNode.I.
void TextNode::set_usage_hint | ( | Geom::UsageHint | usage_hint | ) | [inline] |
Specifies the UsageHint that will be applied to generated geometry.
The default is UH_static, which is probably the right setting, but if you know the TextNode's geometry will have a short lifespan, it may be better to set it to UH_stream. See geomEnums.h.
Definition at line 667 of file textNode.I.
void TextNode::set_wordwrap | ( | PN_stdfloat | wordwrap | ) | [inline] |
Sets the text up to automatically wordwrap when it exceeds the indicated width.
This can be thought of as a right margin or margin width.
Reimplemented from TextProperties.
Definition at line 905 of file textNode.I.
void TextNode::set_wtext | ( | const wstring & | wtext | ) | [inline] |
Changes the text that is displayed under the TextNode, with a wide text.
This automatically sets the string reported by get_text() to the 8-bit encoded version of the same string.
Reimplemented from TextEncoder.
Definition at line 1264 of file textNode.I.
void TextNode::update | ( | ) | [inline] |
Can be called after the TextNode has been fully configured, to force the node to recompute its text immediately, rather than waiting for it to be drawn.
This call is optional.
Reimplemented in FrameRateMeter, and SceneGraphAnalyzerMeter.
Definition at line 1421 of file textNode.I.