18 #include "pandabase.h" 20 #include "config_text.h" 21 #include "textEncoder.h" 22 #include "textProperties.h" 24 #include "textAssembler.h" 25 #include "pandaNode.h" 68 FF_dynamic_merge = 0x0008,
71 INLINE PN_stdfloat get_line_height()
const;
73 INLINE
void set_max_rows(
int max_rows);
74 INLINE
void clear_max_rows();
75 INLINE
bool has_max_rows()
const;
76 INLINE
int get_max_rows()
const;
77 INLINE
bool has_overflow()
const;
79 INLINE
void set_frame_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a);
80 INLINE
void set_frame_color(
const LColor &frame_color);
81 INLINE
LColor get_frame_color()
const;
83 INLINE
void set_card_border(PN_stdfloat size, PN_stdfloat uv_portion);
84 INLINE
void clear_card_border();
85 INLINE PN_stdfloat get_card_border_size()
const;
86 INLINE PN_stdfloat get_card_border_uv_portion()
const;
87 INLINE
bool has_card_border()
const;
89 INLINE
void set_card_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a);
90 INLINE
void set_card_color(
const LColor &card_color);
91 INLINE
LColor get_card_color()
const;
93 INLINE
void set_card_texture(
Texture *card_texture);
94 INLINE
void clear_card_texture();
95 INLINE
bool has_card_texture()
const;
96 INLINE
Texture *get_card_texture()
const;
98 INLINE
void set_frame_as_margin(PN_stdfloat left, PN_stdfloat right,
99 PN_stdfloat bottom, PN_stdfloat top);
100 INLINE
void set_frame_actual(PN_stdfloat left, PN_stdfloat right,
101 PN_stdfloat bottom, PN_stdfloat top);
102 INLINE
void clear_frame();
103 INLINE
bool has_frame()
const;
104 INLINE
bool is_frame_as_margin()
const;
105 INLINE
LVecBase4 get_frame_as_set()
const;
106 INLINE
LVecBase4 get_frame_actual()
const;
108 INLINE
void set_frame_line_width(PN_stdfloat line_width);
109 INLINE PN_stdfloat get_frame_line_width()
const;
110 INLINE
void set_frame_corners(
bool corners);
111 INLINE
bool get_frame_corners()
const;
113 INLINE
void set_card_as_margin(PN_stdfloat left, PN_stdfloat right,
114 PN_stdfloat bottom, PN_stdfloat top);
115 INLINE
void set_card_actual(PN_stdfloat left, PN_stdfloat right,
116 PN_stdfloat bottom, PN_stdfloat top);
117 INLINE
void set_card_decal(
bool card_decal);
118 INLINE
void clear_card();
119 INLINE
bool has_card()
const;
120 INLINE
bool get_card_decal()
const;
121 INLINE
bool is_card_as_margin()
const;
122 INLINE
LVecBase4 get_card_as_set()
const;
123 INLINE
LVecBase4 get_card_actual()
const;
124 INLINE
LVecBase4 get_card_transformed()
const;
127 INLINE
LMatrix4 get_transform()
const;
129 INLINE
void set_coordinate_system(CoordinateSystem cs);
130 INLINE CoordinateSystem get_coordinate_system()
const;
132 INLINE
void set_usage_hint(Geom::UsageHint usage_hint);
133 INLINE Geom::UsageHint get_usage_hint()
const;
135 INLINE
void set_flatten_flags(
int flatten_flags);
136 INLINE
int get_flatten_flags()
const;
146 INLINE
void clear_small_caps();
149 INLINE
void clear_small_caps_scale();
151 INLINE
void set_slant(PN_stdfloat slant);
152 INLINE
void clear_slant();
154 INLINE
void set_align(Alignment align_type);
163 INLINE
void set_text_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a);
164 INLINE
void set_text_color(
const LColor &text_color);
167 INLINE
void set_shadow_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a);
168 INLINE
void set_shadow_color(
const LColor &shadow_color);
171 INLINE
void set_shadow(PN_stdfloat xoffset, PN_stdfloat yoffset);
175 INLINE
void set_bin(
const string &bin);
179 INLINE
void clear_draw_order();
182 INLINE
void clear_tab_width();
185 INLINE
void clear_glyph_scale();
188 INLINE
void clear_glyph_shift();
193 INLINE
void set_text(
const string &text);
194 INLINE
void set_text(
const string &text, Encoding encoding);
201 INLINE
string get_wordwrapped_text()
const;
205 PN_stdfloat calc_width(
wchar_t character)
const;
206 INLINE PN_stdfloat calc_width(
const string &line)
const;
208 bool has_exact_character(
wchar_t character)
const;
209 bool has_character(
wchar_t character)
const;
210 bool is_whitespace(
wchar_t character)
const;
213 INLINE
void set_wtext(
const wstring &wtext);
216 INLINE wstring get_wordwrapped_wtext()
const;
217 PN_stdfloat calc_width(
const wstring &line)
const;
219 virtual void output(ostream &out)
const;
220 virtual void write(ostream &out,
int indent_level = 0)
const;
224 INLINE PN_stdfloat get_left()
const;
225 INLINE PN_stdfloat get_right()
const;
226 INLINE PN_stdfloat get_bottom()
const;
227 INLINE PN_stdfloat get_top()
const;
228 INLINE PN_stdfloat get_height()
const;
229 INLINE PN_stdfloat get_width()
const;
231 INLINE
LPoint3 get_upper_left_3d()
const;
232 INLINE
LPoint3 get_lower_right_3d()
const;
234 INLINE
int get_num_rows()
const;
237 INLINE
void update();
238 INLINE
void force_update();
248 virtual CPT(TransformState)
251 const TransformState *transform,
252 Thread *current_thread)
const;
257 virtual void compute_internal_bounds(CPT(
BoundingVolume) &internal_bounds,
258 int &internal_vertices,
260 Thread *current_thread)
const;
268 INLINE
void invalidate_no_measure();
269 INLINE
void invalidate_with_measure();
270 INLINE
void check_rebuild()
const;
271 INLINE
void check_measure()
const;
289 F_has_frame = 0x0001,
290 F_frame_as_margin = 0x0002,
292 F_card_as_margin = 0x0008,
293 F_has_card_texture = 0x0010,
294 F_frame_corners = 0x0020,
295 F_card_transp = 0x0040,
296 F_has_card_border = 0x0080,
297 F_needs_rebuild = 0x0100,
298 F_needs_measure = 0x0200,
299 F_has_overflow = 0x0400,
300 F_card_decal = 0x0800,
305 GeomEnums::UsageHint _usage_hint;
308 PN_stdfloat _frame_width;
309 PN_stdfloat _card_border_size;
310 PN_stdfloat _card_border_uv_portion;
316 CoordinateSystem _coordinate_system;
323 wstring _wordwrapped_wtext;
331 static void init_type() {
332 PandaNode::init_type();
333 TextProperties::init_type();
334 register_type(_type_handle,
"TextNode",
335 PandaNode::get_class_type(),
336 TextProperties::get_class_type());
339 return get_class_type();
341 virtual TypeHandle force_init_type() {init_type();
return get_class_type();}
347 #include "textNode.I" void append_wtext(const wstring &text)
Appends the indicates string to the end of the stored wide-character text.
A basic node of the scene graph or data graph.
void clear_font()
Restores the default font to the text.
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 offs...
void append_text(const string &text)
Appends the indicates string to the end of the stored text.
void set_font(TextFont *font)
Sets the font that will be used when making 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 b...
void set_align(Alignment align_type)
Specifies the alignment of the text within its margins.
This class can be used to convert text between multiple representations, e.g.
void clear_align()
Restores the default alignment of the text.
void set_glyph_scale(PN_stdfloat glyph_scale)
Specifies the factor by which to scale each letter of the text as it is placed, in addition to any sc...
void set_bin(const string &bin)
Names the CullBin that the text geometry should be assigned to.
Represents a texture object, which is typically a single 2-d image but may also represent a 1-d or 3-...
This collects together the pieces of data that are accumulated for each node while walking the scene ...
void clear_text_color()
Removes the text color specification; the text will be colored whatever it was in the source font fil...
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
void clear_text()
Removes the text from the TextEncoder.
void set_small_caps(bool small_caps)
Sets the small_caps flag.
virtual void r_prepare_scene(GraphicsStateGuardianBase *gsg, const RenderState *node_state, GeomTransformer &transformer, Thread *current_thread)
The recursive implementation of prepare_scene().
An encapsulation of a font; i.e.
This is an abstract class for any volume in any sense which can be said to define the locality of ref...
A lightweight class that represents a single element that may be timed and/or counted via stats...
void set_wordwrap(PN_stdfloat wordwrap)
Sets the text up to automatically wordwrap when it exceeds the indicated width.
This class is used by the SceneGraphReducer to maintain and accumulate the set of attributes we have ...
void append_unicode_char(int character)
Appends a single character to the end of the stored text.
This is a 4-by-4 transform matrix.
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 clear_shadow()
Specifies that a shadow will not be drawn behind the text.
void clear_bin()
Removes the effect of a previous call to set_bin().
void set_slant(PN_stdfloat slant)
Specifies the factor by which the text slants to the right.
This is the base class for all two-component vectors and points.
virtual int get_unsafe_to_apply_attribs() const
Returns the union of all attributes from SceneGraphReducer::AttribTypes that may not safely be applie...
void clear_wordwrap()
Removes the wordwrap setting from the text.
virtual PandaNode * make_copy() const
Returns a newly-allocated PandaNode that is a shallow copy of this one.
int set_draw_order(int draw_order)
Sets the drawing order of text created by the TextNode.
void set_indent(PN_stdfloat indent)
Specifies the amount of extra space that is inserted before the first character of each line...
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
This is the base class for all three-component vectors and points.
This is a base class for the GraphicsStateGuardian class, which is itself a base class for the variou...
This is a two-component vector offset.
A thread; that is, a lightweight process.
The primary interface to this module.
This defines the set of visual properties that may be assigned to the individual characters of the te...
void clear_indent()
Removes the indent setting from the text.
void clear_shadow_color()
Removes the shadow color specification.
void set_text(const string &text)
Changes the text that is stored in the encoder.
TypeHandle is the identifier used to differentiate C++ class types.
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_wtext(const wstring &wtext)
Changes the text that is stored in the encoder.
void set_tab_width(PN_stdfloat tab_width)
Sets the width of each tab stop, in screen units.
virtual bool is_renderable() const
Returns true if there is some value to visiting this particular node during the cull traversal for an...
void set_transform(const TransformState *transform, Thread *current_thread=Thread::get_current_thread())
Sets the transform that will be applied to this node and below.
This object performs a depth-first traversal of the scene graph, with optional view-frustum culling...