Panda3D
 All Classes Functions Variables Enumerations
textNode.I
1 // Filename: textNode.I
2 // Created by: drose (13Mar02)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 
16 ////////////////////////////////////////////////////////////////////
17 // Function: TextNode::get_line_height
18 // Access: Published
19 // Description: Returns the number of units high each line of text
20 // is. This is based on the font. Note that it is
21 // possible for the text to include nested font change
22 // commands, in which case the value of this method is
23 // questionable.
24 ////////////////////////////////////////////////////////////////////
25 INLINE PN_stdfloat TextNode::
26 get_line_height() const {
27  TextFont *font = get_font();
28  if (font == (TextFont *)NULL) {
29  return 0.0f;
30  }
31 
32  return font->get_line_height();
33 }
34 
35 ////////////////////////////////////////////////////////////////////
36 // Function: TextNode::set_max_rows
37 // Access: Published
38 // Description: Sets the maximum number of rows that may be formatted
39 // by the TextNode. If more text than this is
40 // attempted, it will be truncated and has_overflow()
41 // will return true.
42 ////////////////////////////////////////////////////////////////////
43 INLINE void TextNode::
44 set_max_rows(int max_rows) {
45  _max_rows = max_rows;
46  invalidate_with_measure();
47 }
48 
49 ////////////////////////////////////////////////////////////////////
50 // Function: TextNode::clear_max_rows
51 // Access: Published
52 // Description: Resets the TextNode's default behavior of not
53 // limiting the number of rows of text.
54 ////////////////////////////////////////////////////////////////////
55 INLINE void TextNode::
57  _max_rows = 0;
58  invalidate_with_measure();
59 }
60 
61 ////////////////////////////////////////////////////////////////////
62 // Function: TextNode::has_max_rows
63 // Access: Published
64 // Description: Returns true if a limit on the height of the TextNode
65 // has been set via set_max_rows(), false otherwise.
66 ////////////////////////////////////////////////////////////////////
67 INLINE bool TextNode::
68 has_max_rows() const {
69  return _max_rows > 0;
70 }
71 
72 ////////////////////////////////////////////////////////////////////
73 // Function: TextNode::get_max_rows
74 // Access: Published
75 // Description: Returns the limit on the height of the TextNode
76 // specified by set_max_rows().
77 ////////////////////////////////////////////////////////////////////
78 INLINE int TextNode::
79 get_max_rows() const {
80  return _max_rows;
81 }
82 
83 ////////////////////////////////////////////////////////////////////
84 // Function: TextNode::has_overflow
85 // Access: Published
86 // Description: Returns true if the last text set on the text node
87 // exceeded the max_rows constraint, or false if it all
88 // fit.
89 ////////////////////////////////////////////////////////////////////
90 INLINE bool TextNode::
91 has_overflow() const {
92  check_measure();
93  return (_flags & F_has_overflow) != 0;
94 }
95 
96 ////////////////////////////////////////////////////////////////////
97 // Function: TextNode::set_frame_color
98 // Access: Published
99 // Description:
100 ////////////////////////////////////////////////////////////////////
101 INLINE void TextNode::
102 set_frame_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a) {
103  set_frame_color(LColor(r, g, b, a));
104 }
105 
106 ////////////////////////////////////////////////////////////////////
107 // Function: TextNode::set_frame_color
108 // Access: Published
109 // Description:
110 ////////////////////////////////////////////////////////////////////
111 INLINE void TextNode::
112 set_frame_color(const LColor &frame_color) {
113  if (_frame_color != frame_color) {
114  _frame_color = frame_color;
115  invalidate_no_measure();
116  }
117 }
118 
119 ////////////////////////////////////////////////////////////////////
120 // Function: TextNode::get_frame_color
121 // Access: Published
122 // Description:
123 ////////////////////////////////////////////////////////////////////
124 INLINE LColor TextNode::
125 get_frame_color() const {
126  return _frame_color;
127 }
128 
129 ////////////////////////////////////////////////////////////////////
130 // Function: TextNode::set_card_border
131 // Access: Published
132 // Description:
133 ////////////////////////////////////////////////////////////////////
134 INLINE void TextNode::
135 set_card_border(PN_stdfloat size, PN_stdfloat uv_portion) {
136  if (!has_card_border() || _card_border_size != size || _card_border_uv_portion != uv_portion) {
137  _flags |= F_has_card_border;
138  _card_border_size = size;
139  _card_border_uv_portion = uv_portion;
140  invalidate_no_measure();
141  }
142 }
143 
144 ////////////////////////////////////////////////////////////////////
145 // Function: TextNode::clear_card_border
146 // Access: Published
147 // Description:
148 ////////////////////////////////////////////////////////////////////
149 INLINE void TextNode::
150 clear_card_border() {
151  if (has_card_border()) {
152  _flags &= ~F_has_card_border;
153  invalidate_no_measure();
154  }
155 }
156 
157 ////////////////////////////////////////////////////////////////////
158 // Function: TextNode::get_card_border_size
159 // Access: Published
160 // Description:
161 ////////////////////////////////////////////////////////////////////
162 INLINE PN_stdfloat TextNode::
163 get_card_border_size() const {
164  return _card_border_size;
165 }
166 
167 ////////////////////////////////////////////////////////////////////
168 // Function: TextNode::get_card_border_uv_portion
169 // Access: Published
170 // Description:
171 ////////////////////////////////////////////////////////////////////
172 INLINE PN_stdfloat TextNode::
173 get_card_border_uv_portion() const {
174  return _card_border_uv_portion;
175 }
176 
177 ////////////////////////////////////////////////////////////////////
178 // Function: TextNode::has_card_border
179 // Access: Published
180 // Description:
181 ////////////////////////////////////////////////////////////////////
182 INLINE bool TextNode::
183 has_card_border() const {
184  return (_flags & F_has_card_border) != 0;
185 }
186 
187 ////////////////////////////////////////////////////////////////////
188 // Function: TextNode::set_card_color
189 // Access: Published
190 // Description:
191 ////////////////////////////////////////////////////////////////////
192 INLINE void TextNode::
193 set_card_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a) {
194  set_card_color(LColor(r, g, b, a));
195 }
196 
197 ////////////////////////////////////////////////////////////////////
198 // Function: TextNode::set_card_color
199 // Access: Published
200 // Description:
201 ////////////////////////////////////////////////////////////////////
202 INLINE void TextNode::
203 set_card_color(const LColor &card_color) {
204  if (_card_color != card_color) {
205  _card_color = card_color;
206  invalidate_no_measure();
207  }
208 }
209 
210 ////////////////////////////////////////////////////////////////////
211 // Function: TextNode::get_card_color
212 // Access: Published
213 // Description:
214 ////////////////////////////////////////////////////////////////////
215 INLINE LColor TextNode::
216 get_card_color() const {
217  return _card_color;
218 }
219 
220 ////////////////////////////////////////////////////////////////////
221 // Function: TextNode::set_card_texture
222 // Access: Published
223 // Description:
224 ////////////////////////////////////////////////////////////////////
225 INLINE void TextNode::
226 set_card_texture(Texture *card_texture) {
227  if (card_texture == (Texture *)NULL) {
228  clear_card_texture();
229  } else {
230  if (!has_card_texture() || _card_texture != card_texture) {
231  _flags |= F_has_card_texture;
232  _card_texture = card_texture;
233  invalidate_no_measure();
234  }
235  }
236 }
237 
238 ////////////////////////////////////////////////////////////////////
239 // Function: TextNode::clear_card_texture
240 // Access: Published
241 // Description:
242 ////////////////////////////////////////////////////////////////////
243 INLINE void TextNode::
244 clear_card_texture() {
245  if (has_card_texture()) {
246  _flags &= ~F_has_card_texture;
247  _card_texture = NULL;
248  invalidate_no_measure();
249  }
250 }
251 
252 ////////////////////////////////////////////////////////////////////
253 // Function: TextNode::has_card_texture
254 // Access: Published
255 // Description:
256 ////////////////////////////////////////////////////////////////////
257 INLINE bool TextNode::
258 has_card_texture() const {
259  return (_flags & F_has_card_texture) != 0;
260 }
261 
262 ////////////////////////////////////////////////////////////////////
263 // Function: TextNode::get_card_texture
264 // Access: Published
265 // Description:
266 ////////////////////////////////////////////////////////////////////
267 INLINE Texture *TextNode::
268 get_card_texture() const {
269  return _card_texture;
270 }
271 
272 ////////////////////////////////////////////////////////////////////
273 // Function: TextNode::set_frame_as_margin
274 // Access: Published
275 // Description: Specifies that a border will be drawn around the text
276 // when it is next created. The parameters are the
277 // amount of additional padding to insert between the
278 // frame and the text in each dimension, and all should
279 // generally be positive.
280 ////////////////////////////////////////////////////////////////////
281 INLINE void TextNode::
282 set_frame_as_margin(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top) {
283  _flags |= (F_has_frame | F_frame_as_margin);
284  _frame_ul.set(left, top);
285  _frame_lr.set(right, bottom);
286  invalidate_no_measure();
287 }
288 
289 ////////////////////////////////////////////////////////////////////
290 // Function: TextNode::set_frame_actual
291 // Access: Published
292 // Description: Similar to set_frame_as_margin, except the frame is
293 // specified in actual coordinate units (relative to
294 // the text's origin), irrespective of the size of the
295 // text. The left and bottom coordinates should
296 // generally be negative, while the right and top
297 // coordinates should generally be positive.
298 ////////////////////////////////////////////////////////////////////
299 INLINE void TextNode::
300 set_frame_actual(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top) {
301  _flags |= F_has_frame;
302  _flags &= ~F_frame_as_margin;
303  _frame_ul.set(left, top);
304  _frame_lr.set(right, bottom);
305  invalidate_no_measure();
306 }
307 
308 ////////////////////////////////////////////////////////////////////
309 // Function: TextNode::clear_frame
310 // Access: Published
311 // Description: Specifies that a border will not be drawn around the
312 // text.
313 ////////////////////////////////////////////////////////////////////
314 INLINE void TextNode::
316  _flags &= ~F_has_frame;
317  invalidate_no_measure();
318 }
319 
320 ////////////////////////////////////////////////////////////////////
321 // Function: TextNode::has_frame
322 // Access: Published
323 // Description:
324 ////////////////////////////////////////////////////////////////////
325 INLINE bool TextNode::
326 has_frame() const {
327  return (_flags & F_has_frame) != 0;
328 }
329 
330 ////////////////////////////////////////////////////////////////////
331 // Function: TextNode::is_frame_as_margin
332 // Access: Published
333 // Description: If this is true, the frame was set via a call to
334 // set_frame_as_margin(), and the dimension of the frame
335 // as returned by get_frame_as_set() represent a margin
336 // all around the text. If false, then the frame was
337 // set via a call to set_frame_actual(), and the
338 // dimensions of the frame as returned by
339 // get_frame_as_set() are relative to the text's origin.
340 ////////////////////////////////////////////////////////////////////
341 INLINE bool TextNode::
343  nassertr(has_frame(), false);
344  return (_flags & F_frame_as_margin) != 0;
345 }
346 
347 ////////////////////////////////////////////////////////////////////
348 // Function: TextNode::get_frame_as_set
349 // Access: Published
350 // Description: Returns the dimensions of the frame as set by
351 // set_frame_as_margin() or set_frame_actual(). Use
352 // is_frame_actual() to determine how to interpret the
353 // values returned by this function. It is an error to
354 // call this if has_frame() is false.
355 ////////////////////////////////////////////////////////////////////
356 INLINE LVecBase4 TextNode::
358  nassertr(has_frame(), LVecBase4(0.0, 0.0, 0.0, 0.0));
359  return LVecBase4(_frame_ul[0], _frame_lr[0], _frame_lr[1], _frame_ul[1]);
360 }
361 
362 ////////////////////////////////////////////////////////////////////
363 // Function: TextNode::get_frame_actual
364 // Access: Published
365 // Description: Returns the actual dimensions of the frame around the
366 // text. If the frame was set via set_frame_as_margin(),
367 // the result returned by this function reflects the
368 // size of the current text; if the frame was set via
369 // set_frame_actual(), this returns the values
370 // actually set.
371 //
372 // If the text has no frame at all, this returns the
373 // dimensions of the text itself, as if the frame were
374 // set with a margin of 0, 0, 0, 0.
375 ////////////////////////////////////////////////////////////////////
376 INLINE LVecBase4 TextNode::
378  if (!has_frame()) {
379  check_measure();
380  return LVecBase4(_text_ul[0], _text_lr[0], _text_lr[1], _text_ul[1]);
381 
382  } else if (is_frame_as_margin()) {
383  check_measure();
384  return LVecBase4(_text_ul[0] - _frame_ul[0],
385  _text_lr[0] + _frame_lr[0],
386  _text_lr[1] - _frame_lr[1],
387  _text_ul[1] + _frame_ul[1]);
388  } else {
389  return get_frame_as_set();
390  }
391 }
392 
393 ////////////////////////////////////////////////////////////////////
394 // Function: TextNode::set_frame_line_width
395 // Access: Published
396 // Description: Specifies the thickness of the lines that will be
397 // used to draw the frame.
398 ////////////////////////////////////////////////////////////////////
399 INLINE void TextNode::
400 set_frame_line_width(PN_stdfloat frame_width) {
401  _frame_width = frame_width;
402  invalidate_no_measure();
403 }
404 
405 ////////////////////////////////////////////////////////////////////
406 // Function: TextNode::get_frame_line_width
407 // Access: Published
408 // Description: Returns the thickness of the lines that will be
409 // used to draw the frame.
410 ////////////////////////////////////////////////////////////////////
411 INLINE PN_stdfloat TextNode::
413  return _frame_width;
414 }
415 
416 ////////////////////////////////////////////////////////////////////
417 // Function: TextNode::set_frame_corners
418 // Access: Published
419 // Description: Enables or disables the drawing of corners for the
420 // frame. These are extra points drawn at each of the
421 // four corners, to soften the ugly edges generated when
422 // the line width is greater than one.
423 ////////////////////////////////////////////////////////////////////
424 INLINE void TextNode::
425 set_frame_corners(bool corners) {
426  if (corners) {
427  _flags |= F_frame_corners;
428  } else {
429  _flags &= ~F_frame_corners;
430  }
431  invalidate_no_measure();
432 }
433 
434 ////////////////////////////////////////////////////////////////////
435 // Function: TextNode::get_frame_corners
436 // Access: Published
437 // Description:
438 ////////////////////////////////////////////////////////////////////
439 INLINE bool TextNode::
440 get_frame_corners() const {
441  return (_flags & F_frame_corners) != 0;
442 }
443 
444 ////////////////////////////////////////////////////////////////////
445 // Function: TextNode::set_card_as_margin
446 // Access: Published
447 // Description: Specifies that a (possibly opaque or semitransparent)
448 // card will be held behind the text when it is next
449 // created. Like set_frame_as_margin, the parameters are
450 // the amount of additional padding to insert around the
451 // text in each dimension, and all should generally be
452 // positive.
453 ////////////////////////////////////////////////////////////////////
454 INLINE void TextNode::
455 set_card_as_margin(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top) {
456  _flags |= (F_has_card | F_card_as_margin);
457  _card_ul.set(left, top);
458  _card_lr.set(right, bottom);
459  invalidate_no_measure();
460 }
461 
462 ////////////////////////////////////////////////////////////////////
463 // Function: TextNode::set_card_actual
464 // Access: Published
465 // Description: Similar to set_card_as_margin, except the card is
466 // specified in actual coordinate units (relative to
467 // the text's origin), irrespective of the size of the
468 // text. The left and bottom coordinates should
469 // generally be negative, while the right and top
470 // coordinates should generally be positive.
471 ////////////////////////////////////////////////////////////////////
472 INLINE void TextNode::
473 set_card_actual(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top) {
474  _flags |= F_has_card;
475  _flags &= ~F_card_as_margin;
476  _card_ul.set(left, top);
477  _card_lr.set(right, bottom);
478  invalidate_no_measure();
479 }
480 
481 ////////////////////////////////////////////////////////////////////
482 // Function: TextNode::set_card_decal
483 // Access: Published
484 // Description: Sets the card_decal flag. When this is true, the
485 // text is decalled onto the card, which is necessary if
486 // the TextNode is to be rendered in the 3-d world
487 // without putting it in a bin.
488 ////////////////////////////////////////////////////////////////////
489 INLINE void TextNode::
490 set_card_decal(bool card_decal) {
491  if (card_decal) {
492  _flags |= F_card_decal;
493  } else {
494  _flags &= ~F_card_decal;
495  }
496  invalidate_no_measure();
497 }
498 
499 ////////////////////////////////////////////////////////////////////
500 // Function: TextNode::clear_card
501 // Access: Published
502 // Description: Specifies that a card will not be drawn behind the
503 // text.
504 ////////////////////////////////////////////////////////////////////
505 INLINE void TextNode::
507  _flags &= ~F_has_card;
508  invalidate_no_measure();
509 }
510 
511 ////////////////////////////////////////////////////////////////////
512 // Function: TextNode::has_card
513 // Access: Published
514 // Description:
515 ////////////////////////////////////////////////////////////////////
516 INLINE bool TextNode::
517 has_card() const {
518  return (_flags & F_has_card) != 0;
519 }
520 
521 ////////////////////////////////////////////////////////////////////
522 // Function: TextNode::get_card_decal
523 // Access: Published
524 // Description: Returns the card_decal flag. See set_card_decal().
525 ////////////////////////////////////////////////////////////////////
526 INLINE bool TextNode::
527 get_card_decal() const {
528  return (_flags & F_card_decal) != 0;
529 }
530 
531 ////////////////////////////////////////////////////////////////////
532 // Function: TextNode::is_card_as_margin
533 // Access: Published
534 // Description: If this is true, the card was set via a call to
535 // set_card_as_margin(), and the dimension of the card
536 // as returned by get_card_as_set() represent a margin
537 // all around the text. If false, then the card was
538 // set via a call to set_card_actual(), and the
539 // dimensions of the card as returned by
540 // get_card_as_set() are relative to the text's origin.
541 ////////////////////////////////////////////////////////////////////
542 INLINE bool TextNode::
544  nassertr(has_card(), false);
545  return (_flags & F_card_as_margin) != 0;
546 }
547 
548 ////////////////////////////////////////////////////////////////////
549 // Function: TextNode::get_card_as_set
550 // Access: Published
551 // Description: Returns the dimensions of the card as set by
552 // set_card_as_margin() or set_card_actual(). Use
553 // is_card_actual() to determine how to interpret the
554 // values returned by this function. It is an error to
555 // call this if has_card() is false.
556 ////////////////////////////////////////////////////////////////////
557 INLINE LVecBase4 TextNode::
559  nassertr(has_card(), LVecBase4(0.0, 0.0, 0.0, 0.0));
560  return LVecBase4(_card_ul[0], _card_lr[0], _card_lr[1], _card_ul[1]);
561 }
562 
563 ////////////////////////////////////////////////////////////////////
564 // Function: TextNode::get_card_actual
565 // Access: Published
566 // Description: Returns the actual dimensions of the card around the
567 // text. If the card was set via set_card_as_margin(),
568 // the result returned by this function reflects the
569 // size of the current text; if the card was set via
570 // set_card_actual(), this returns the values
571 // actually set.
572 //
573 // If the text has no card at all, this returns the
574 // dimensions of the text itself, as if the card were
575 // set with a margin of 0, 0, 0, 0.
576 ////////////////////////////////////////////////////////////////////
577 INLINE LVecBase4 TextNode::
579  if (!has_card()) {
580  check_measure();
581  return LVecBase4(_text_ul[0], _text_lr[0], _text_lr[1], _text_ul[1]);
582 
583  } else if (is_card_as_margin()) {
584  check_measure();
585  return LVecBase4(_text_ul[0] - _card_ul[0],
586  _text_lr[0] + _card_lr[0],
587  _text_lr[1] - _card_lr[1],
588  _text_ul[1] + _card_ul[1]);
589  } else {
590  return get_card_as_set();
591  }
592 }
593 
594 ////////////////////////////////////////////////////////////////////
595 // Function: TextNode::get_card_transformed
596 // Access: Published
597 // Description: Returns the actual card dimensions, transformed by
598 // the matrix set by set_transform(). This returns the
599 // card dimensions in actual coordinates as seen by the
600 // rest of the world. Also see get_upper_left_3d() and
601 // get_lower_right_3d().
602 ////////////////////////////////////////////////////////////////////
603 INLINE LVecBase4 TextNode::
605  LVecBase4 card = get_card_actual();
606  LPoint3 ul = LPoint3(card[0], 0.0, card[3]) * _transform;
607  LPoint3 lr = LPoint3(card[1], 0.0, card[2]) * _transform;
608 
609  return LVecBase4(ul[0], lr[0], lr[2], ul[2]);
610 }
611 
612 ////////////////////////////////////////////////////////////////////
613 // Function: TextNode::set_transform
614 // Access: Published
615 // Description: Sets an additional transform that is applied to the
616 // entire text paragraph.
617 ////////////////////////////////////////////////////////////////////
618 INLINE void TextNode::
619 set_transform(const LMatrix4 &transform) {
620  _transform = transform;
621  invalidate_with_measure();
622 }
623 
624 ////////////////////////////////////////////////////////////////////
625 // Function: TextNode::get_transform
626 // Access: Published
627 // Description:
628 ////////////////////////////////////////////////////////////////////
629 INLINE LMatrix4 TextNode::
630 get_transform() const {
631  return _transform;
632 }
633 
634 ////////////////////////////////////////////////////////////////////
635 // Function: TextNode::set_coordinate_system
636 // Access: Published
637 // Description: Specifies the coordinate system in which the text
638 // will be generated.
639 ////////////////////////////////////////////////////////////////////
640 INLINE void TextNode::
641 set_coordinate_system(CoordinateSystem coordinate_system) {
642  _coordinate_system = coordinate_system;
643  invalidate_with_measure();
644 }
645 
646 ////////////////////////////////////////////////////////////////////
647 // Function: TextNode::get_coordinate_system
648 // Access: Published
649 // Description:
650 ////////////////////////////////////////////////////////////////////
651 INLINE CoordinateSystem TextNode::
652 get_coordinate_system() const {
653  return _coordinate_system;
654 }
655 
656 ////////////////////////////////////////////////////////////////////
657 // Function: TextNode::set_usage_hint
658 // Access: Published
659 // Description: Specifies the UsageHint that will be applied to
660 // generated geometry. The default is UH_static, which
661 // is probably the right setting, but if you know the
662 // TextNode's geometry will have a short lifespan, it
663 // may be better to set it to UH_stream. See
664 // geomEnums.h.
665 ////////////////////////////////////////////////////////////////////
666 INLINE void TextNode::
667 set_usage_hint(Geom::UsageHint usage_hint) {
668  _usage_hint = usage_hint;
669  invalidate_no_measure();
670 }
671 
672 ////////////////////////////////////////////////////////////////////
673 // Function: TextNode::get_usage_hint
674 // Access: Published
675 // Description: Returns the UsageHint that will be applied to
676 // generated geometry. See set_usage_hint().
677 ////////////////////////////////////////////////////////////////////
678 INLINE Geom::UsageHint TextNode::
679 get_usage_hint() const {
680  return _usage_hint;
681 }
682 
683 ////////////////////////////////////////////////////////////////////
684 // Function: TextNode::set_flatten_flags
685 // Access: Published
686 // Description: Sets the flatten flags. This should be a union of
687 // the TextNode::FlattenFlags options. This controls
688 // the degree of flattening performed on the TextNode's
689 // internal geometry (i.e. the scene graph returned by
690 // generate()) each time the text is changed. In
691 // general, more flattening means a more optimal result,
692 // but it will take more time to generate.
693 //
694 // The choice may be any of these three:
695 //
696 // FF_none - No flatten operation is called. The
697 // letters are left as independent Geoms.
698 //
699 // FF_light - A flatten_light() operation is called.
700 // The attributes are applied to the vertices, but no
701 // nodes are removed.
702 //
703 // FF_medium - A flatten_medium() operation is called.
704 // The attributes are applied to the vertices, and a few
705 // trivial nodes are removed.
706 //
707 // FF_strong - A flatten_strong() operation is called.
708 // The attributes are applied to the vertices, and the
709 // resulting nodes are aggressively combined into as few
710 // nodes as possible.
711 //
712 // In addition to the above choices, you may optionally
713 // include the following flag:
714 //
715 // FF_dynamic_merge - Copy the geoms into a single
716 // GeomVertexData as we go, instead of relying on the
717 // flatten operation at the end. This pre-flattens the
718 // text considerably, and may obviate the need for
719 // flatten altogether; it also tends to improve
720 // performance considerably even if you do call flatten.
721 // However, it is not as fast as not calling flatten at
722 // all.
723 //
724 // The default is taken from the text-flatten and
725 // text-dynamic-merge config variables.
726 ////////////////////////////////////////////////////////////////////
727 INLINE void TextNode::
728 set_flatten_flags(int flatten_flags) {
729  _flatten_flags = flatten_flags;
730 }
731 
732 ////////////////////////////////////////////////////////////////////
733 // Function: TextNode::get_flatten_flags
734 // Access: Published
735 // Description: Returns the flatten flags. See set_flatten_flags().
736 ////////////////////////////////////////////////////////////////////
737 INLINE int TextNode::
739  return _flatten_flags;
740 }
741 
742 ////////////////////////////////////////////////////////////////////
743 // Function: TextNode::set_font
744 // Access: Published
745 // Description: Sets the font that will be used when making text. If
746 // this is set to NULL, the default font will be used,
747 // which can be set via set_default_font().
748 ////////////////////////////////////////////////////////////////////
749 INLINE void TextNode::
752  invalidate_with_measure();
753 }
754 
755 ////////////////////////////////////////////////////////////////////
756 // Function: TextNode::clear_font
757 // Access: Published
758 // Description: Resets the font to the default font.
759 ////////////////////////////////////////////////////////////////////
760 INLINE void TextNode::
763  invalidate_with_measure();
764 }
765 
766 ////////////////////////////////////////////////////////////////////
767 // Function: TextNode::set_small_caps
768 // Access: Published
769 // Description: Sets the small_caps flag. When this is set,
770 // lowercase letters are generated as scaled-down
771 // versions of their uppercase equivalents. This is
772 // particularly useful to set for fonts that do not have
773 // lowercase letters.
774 //
775 // It is also a good idea to set this for a (dynamic)
776 // font that has already implemented lowercase letters
777 // as scaled-down versions of their uppercase
778 // equivalents, since without this flag the texture
779 // memory may needlessly duplicate equivalent glyphs for
780 // upper and lowercase letters. Setting this flag
781 // causes the texture memory to share the mixed-case
782 // letters.
783 //
784 // The amount by which the lowercase letters are scaled
785 // is specified by set_small_caps_scale().
786 ////////////////////////////////////////////////////////////////////
787 INLINE void TextNode::
788 set_small_caps(bool small_caps) {
789  TextProperties::set_small_caps(small_caps);
790  invalidate_with_measure();
791 }
792 
793 ////////////////////////////////////////////////////////////////////
794 // Function: TextNode::clear_small_caps
795 // Access: Published
796 // Description:
797 ////////////////////////////////////////////////////////////////////
798 INLINE void TextNode::
799 clear_small_caps() {
800  TextProperties::clear_small_caps();
801  invalidate_with_measure();
802 }
803 
804 ////////////////////////////////////////////////////////////////////
805 // Function: TextNode::set_small_caps_scale
806 // Access: Published
807 // Description: Sets the scale factor applied to lowercase letters
808 // from their uppercase equivalents, when the small_caps
809 // flag is in effect. See set_small_caps(). Normally,
810 // this will be a number less than one.
811 ////////////////////////////////////////////////////////////////////
812 INLINE void TextNode::
813 set_small_caps_scale(PN_stdfloat small_caps_scale) {
814  TextProperties::set_small_caps_scale(small_caps_scale);
815  invalidate_with_measure();
816 }
817 
818 ////////////////////////////////////////////////////////////////////
819 // Function: TextNode::clear_small_caps_scale
820 // Access: Published
821 // Description:
822 ////////////////////////////////////////////////////////////////////
823 INLINE void TextNode::
824 clear_small_caps_scale() {
825  TextProperties::clear_small_caps_scale();
826  invalidate_with_measure();
827 }
828 
829 ////////////////////////////////////////////////////////////////////
830 // Function: TextNode::set_slant
831 // Access: Published
832 // Description:
833 ////////////////////////////////////////////////////////////////////
834 INLINE void TextNode::
835 set_slant(PN_stdfloat slant) {
837  invalidate_with_measure();
838 }
839 
840 ////////////////////////////////////////////////////////////////////
841 // Function: TextNode::clear_slant
842 // Access: Published
843 // Description:
844 ////////////////////////////////////////////////////////////////////
845 INLINE void TextNode::
846 clear_slant() {
847  TextProperties::clear_slant();
848  invalidate_with_measure();
849 }
850 
851 ////////////////////////////////////////////////////////////////////
852 // Function: TextNode::set_align
853 // Access: Published
854 // Description:
855 ////////////////////////////////////////////////////////////////////
856 INLINE void TextNode::
857 set_align(TextNode::Alignment align_type) {
858  TextProperties::set_align(align_type);
859  invalidate_with_measure();
860 }
861 
862 ////////////////////////////////////////////////////////////////////
863 // Function: TextNode::clear_align
864 // Access: Published
865 // Description:
866 ////////////////////////////////////////////////////////////////////
867 INLINE void TextNode::
868 clear_align() {
870  invalidate_with_measure();
871 }
872 
873 ////////////////////////////////////////////////////////////////////
874 // Function: TextNode::set_indent
875 // Access: Published
876 // Description: Specifies the amount of extra space that is inserted
877 // before the first character of each line. This can be
878 // thought of as a left margin.
879 ////////////////////////////////////////////////////////////////////
880 INLINE void TextNode::
881 set_indent(PN_stdfloat indent) {
883  invalidate_with_measure();
884 }
885 
886 ////////////////////////////////////////////////////////////////////
887 // Function: TextNode::clear_indent
888 // Access: Published
889 // Description:
890 ////////////////////////////////////////////////////////////////////
891 INLINE void TextNode::
892 clear_indent() {
894  invalidate_with_measure();
895 }
896 
897 ////////////////////////////////////////////////////////////////////
898 // Function: TextNode::set_wordwrap
899 // Access: Published
900 // Description: Sets the text up to automatically wordwrap when it
901 // exceeds the indicated width. This can be thought of
902 // as a right margin or margin width.
903 ////////////////////////////////////////////////////////////////////
904 INLINE void TextNode::
905 set_wordwrap(PN_stdfloat wordwrap) {
907  invalidate_with_measure();
908 }
909 
910 ////////////////////////////////////////////////////////////////////
911 // Function: TextNode::clear_wordwrap
912 // Access: Published
913 // Description: Removes the wordwrap setting from the TextNode. Text
914 // will be as wide as it is.
915 ////////////////////////////////////////////////////////////////////
916 INLINE void TextNode::
919  invalidate_with_measure();
920 }
921 
922 ////////////////////////////////////////////////////////////////////
923 // Function: TextNode::set_text_color
924 // Access: Published
925 // Description:
926 ////////////////////////////////////////////////////////////////////
927 INLINE void TextNode::
928 set_text_color(const LColor &text_color) {
929  TextProperties::set_text_color(text_color);
930  invalidate_no_measure();
931 }
932 
933 ////////////////////////////////////////////////////////////////////
934 // Function: TextNode::set_text_color
935 // Access: Published
936 // Description:
937 ////////////////////////////////////////////////////////////////////
938 INLINE void TextNode::
939 set_text_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a) {
940  set_text_color(LColor(r, g, b, a));
941 }
942 
943 ////////////////////////////////////////////////////////////////////
944 // Function: TextNode::clear_text_color
945 // Access: Published
946 // Description: Removes the text color specification; the text will
947 // be colored whatever it was in the source font file.
948 ////////////////////////////////////////////////////////////////////
949 INLINE void TextNode::
952  invalidate_no_measure();
953 }
954 
955 ////////////////////////////////////////////////////////////////////
956 // Function: TextNode::set_shadow_color
957 // Access: Published
958 // Description:
959 ////////////////////////////////////////////////////////////////////
960 INLINE void TextNode::
961 set_shadow_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a) {
962  set_shadow_color(LColor(r, g, b, a));
963 }
964 
965 ////////////////////////////////////////////////////////////////////
966 // Function: TextNode::set_shadow_color
967 // Access: Published
968 // Description:
969 ////////////////////////////////////////////////////////////////////
970 INLINE void TextNode::
971 set_shadow_color(const LColor &shadow_color) {
972  TextProperties::set_shadow_color(shadow_color);
973  invalidate_no_measure();
974 }
975 
976 ////////////////////////////////////////////////////////////////////
977 // Function: TextNode::clear_shadow_color
978 // Access: Published
979 // Description:
980 ////////////////////////////////////////////////////////////////////
981 INLINE void TextNode::
982 clear_shadow_color() {
984  invalidate_with_measure();
985 }
986 
987 ////////////////////////////////////////////////////////////////////
988 // Function: TextNode::set_shadow
989 // Access: Published
990 // Description: Specifies that the text should be drawn with a
991 // shadow, by creating a second copy of the text and
992 // offsetting it slightly behind the first.
993 ////////////////////////////////////////////////////////////////////
994 INLINE void TextNode::
995 set_shadow(PN_stdfloat xoffset, PN_stdfloat yoffset) {
996  set_shadow(LVecBase2(xoffset, yoffset));
997 }
998 
999 ////////////////////////////////////////////////////////////////////
1000 // Function: TextNode::set_shadow
1001 // Access: Published
1002 // Description: Specifies that the text should be drawn with a
1003 // shadow, by creating a second copy of the text and
1004 // offsetting it slightly behind the first.
1005 ////////////////////////////////////////////////////////////////////
1006 INLINE void TextNode::
1007 set_shadow(const LVecBase2 &shadow_offset) {
1008  TextProperties::set_shadow(shadow_offset);
1009  invalidate_no_measure();
1010 }
1011 
1012 ////////////////////////////////////////////////////////////////////
1013 // Function: TextNode::clear_shadow
1014 // Access: Published
1015 // Description: Specifies that a shadow will not be drawn behind the
1016 // text.
1017 ////////////////////////////////////////////////////////////////////
1018 INLINE void TextNode::
1021  invalidate_no_measure();
1022 }
1023 
1024 ////////////////////////////////////////////////////////////////////
1025 // Function: TextNode::set_bin
1026 // Access: Published
1027 // Description: Names the GeomBin that the TextNode geometry should
1028 // be assigned to. If this is set, then a
1029 // GeomBinTransition will be created to explicitly place
1030 // each component in the named bin.
1031 //
1032 // The draw_order value will also be passed to each
1033 // GeomBinTransition as appropriate; this is
1034 // particularly useful if this names a GeomBinFixed,
1035 // e.g. "fixed".
1036 ////////////////////////////////////////////////////////////////////
1037 INLINE void TextNode::
1038 set_bin(const string &bin) {
1040  invalidate_no_measure();
1041 }
1042 
1043 ////////////////////////////////////////////////////////////////////
1044 // Function: TextNode::clear_bin
1045 // Access: Published
1046 // Description: Removes the effect of a previous call to
1047 // set_bin(). Text will be drawn in whatever bin
1048 // it would like to be drawn in, with no explicit
1049 // ordering.
1050 ////////////////////////////////////////////////////////////////////
1051 INLINE void TextNode::
1054  invalidate_no_measure();
1055 }
1056 
1057 ////////////////////////////////////////////////////////////////////
1058 // Function: TextNode::set_draw_order
1059 // Access: Published
1060 // Description: Sets the drawing order of text created by the
1061 // TextMaker. This is actually the draw order of the
1062 // card and frame. The shadow is drawn at
1063 // _draw_order+1, and the text at _draw_order+2.
1064 //
1065 // This affects the sorting order assigned to the arcs
1066 // as they are created, and also is passed to whatever
1067 // bin may be assigned via set_bin().
1068 //
1069 // The return value is the first unused draw_order
1070 // number, e.g. _draw_order + 3.
1071 ////////////////////////////////////////////////////////////////////
1072 INLINE int TextNode::
1073 set_draw_order(int draw_order) {
1074  invalidate_no_measure();
1075  return TextProperties::set_draw_order(draw_order);
1076 }
1077 
1078 ////////////////////////////////////////////////////////////////////
1079 // Function: TextNode::clear_draw_order
1080 // Access: Published
1081 // Description:
1082 ////////////////////////////////////////////////////////////////////
1083 INLINE void TextNode::
1084 clear_draw_order() {
1085  TextProperties::clear_draw_order();
1086  invalidate_with_measure();
1087 }
1088 
1089 ////////////////////////////////////////////////////////////////////
1090 // Function: TextNode::set_tab_width
1091 // Access: Published
1092 // Description: Sets the width of each tab stop, in screen units. A
1093 // tab character embedded in the text will advance the
1094 // horizontal position to the next tab stop.
1095 ////////////////////////////////////////////////////////////////////
1096 INLINE void TextNode::
1097 set_tab_width(PN_stdfloat tab_width) {
1098  TextProperties::set_tab_width(tab_width);
1099  invalidate_with_measure();
1100 }
1101 
1102 ////////////////////////////////////////////////////////////////////
1103 // Function: TextNode::clear_tab_width
1104 // Access: Published
1105 // Description:
1106 ////////////////////////////////////////////////////////////////////
1107 INLINE void TextNode::
1108 clear_tab_width() {
1109  TextProperties::clear_tab_width();
1110  invalidate_with_measure();
1111 }
1112 
1113 ////////////////////////////////////////////////////////////////////
1114 // Function: TextNode::set_glyph_scale
1115 // Access: Published
1116 // Description: Specifies the factor by which to scale each letter of
1117 // the text as it is placed. This can be used (possibly
1118 // in conjunction with set_glyph_shift()) to implement
1119 // superscripting or subscripting.
1120 ////////////////////////////////////////////////////////////////////
1121 INLINE void TextNode::
1122 set_glyph_scale(PN_stdfloat glyph_scale) {
1123  TextProperties::set_glyph_scale(glyph_scale);
1124  invalidate_with_measure();
1125 }
1126 
1127 ////////////////////////////////////////////////////////////////////
1128 // Function: TextNode::clear_glyph_scale
1129 // Access: Published
1130 // Description:
1131 ////////////////////////////////////////////////////////////////////
1132 INLINE void TextNode::
1133 clear_glyph_scale() {
1134  TextProperties::clear_glyph_scale();
1135  invalidate_with_measure();
1136 }
1137 
1138 ////////////////////////////////////////////////////////////////////
1139 // Function: TextNode::set_glyph_shift
1140 // Access: Published
1141 // Description: Specifies a vertical amount to shift each letter of
1142 // the text as it is placed. This can be used (possibly
1143 // in conjunction with set_glyph_scale()) to implement
1144 // superscripting or subscripting.
1145 ////////////////////////////////////////////////////////////////////
1146 INLINE void TextNode::
1147 set_glyph_shift(PN_stdfloat glyph_shift) {
1148  TextProperties::set_glyph_shift(glyph_shift);
1149  invalidate_with_measure();
1150 }
1151 
1152 ////////////////////////////////////////////////////////////////////
1153 // Function: TextNode::clear_glyph_shift
1154 // Access: Published
1155 // Description:
1156 ////////////////////////////////////////////////////////////////////
1157 INLINE void TextNode::
1158 clear_glyph_shift() {
1159  TextProperties::clear_glyph_shift();
1160  invalidate_with_measure();
1161 }
1162 
1163 
1164 ////////////////////////////////////////////////////////////////////
1165 // Function: TextNode::set_text
1166 // Access: Published
1167 // Description: Changes the text that is displayed under the
1168 // TextNode.
1169 ////////////////////////////////////////////////////////////////////
1170 INLINE void TextNode::
1171 set_text(const string &text) {
1172  TextEncoder::set_text(text);
1173  invalidate_with_measure();
1174 }
1175 
1176 ////////////////////////////////////////////////////////////////////
1177 // Function: TextNode::set_text
1178 // Access: Published
1179 // Description: The two-parameter version of set_text() accepts an
1180 // explicit encoding; the text is immediately decoded
1181 // and stored as a wide-character string. Subsequent
1182 // calls to get_text() will return the same text
1183 // re-encoded using whichever encoding is specified by
1184 // set_encoding().
1185 ////////////////////////////////////////////////////////////////////
1186 INLINE void TextNode::
1187 set_text(const string &text, TextNode::Encoding encoding) {
1188  TextEncoder::set_text(text, encoding);
1189  invalidate_with_measure();
1190 }
1191 
1192 ////////////////////////////////////////////////////////////////////
1193 // Function: TextNode::clear_text
1194 // Access: Published
1195 // Description: Removes the text from the TextNode.
1196 ////////////////////////////////////////////////////////////////////
1197 INLINE void TextNode::
1200  invalidate_with_measure();
1201 }
1202 
1203 ////////////////////////////////////////////////////////////////////
1204 // Function: TextNode::append_text
1205 // Access: Published
1206 // Description: Appends the indicates string to the end of the stored
1207 // text.
1208 ////////////////////////////////////////////////////////////////////
1209 INLINE void TextNode::
1210 append_text(const string &text) {
1212  invalidate_with_measure();
1213 }
1214 
1215 ////////////////////////////////////////////////////////////////////
1216 // Function: TextNode::append_unicode_char
1217 // Access: Published
1218 // Description: Appends a single character to the end of the stored
1219 // text. This may be a wide character, up to 16 bits in
1220 // Unicode.
1221 ////////////////////////////////////////////////////////////////////
1222 INLINE void TextNode::
1223 append_unicode_char(wchar_t character) {
1225  invalidate_with_measure();
1226 }
1227 
1228 ////////////////////////////////////////////////////////////////////
1229 // Function: TextNode::get_wordwrapped_text
1230 // Access: Public
1231 // Description: Returns a string that represents the contents of the
1232 // text, as it has been formatted by wordwrap rules.
1233 //
1234 // In earlier versions, this did not contain any
1235 // embedded special characters like \1 or \3; now it
1236 // does.
1237 ////////////////////////////////////////////////////////////////////
1238 INLINE string TextNode::
1241 }
1242 
1243 ////////////////////////////////////////////////////////////////////
1244 // Function: TextNode::calc_width
1245 // Access: Published
1246 // Description: Returns the width of a line of text of arbitrary
1247 // characters. The line should not include the newline
1248 // character.
1249 ////////////////////////////////////////////////////////////////////
1250 INLINE PN_stdfloat TextNode::
1251 calc_width(const string &line) const {
1252  return calc_width(decode_text(line));
1253 }
1254 
1255 ////////////////////////////////////////////////////////////////////
1256 // Function: TextNode::set_wtext
1257 // Access: Published
1258 // Description: Changes the text that is displayed under the
1259 // TextNode, with a wide text. This automatically sets
1260 // the string reported by get_text() to the 8-bit
1261 // encoded version of the same string.
1262 ////////////////////////////////////////////////////////////////////
1263 INLINE void TextNode::
1264 set_wtext(const wstring &wtext) {
1265  TextEncoder::set_wtext(wtext);
1266  invalidate_with_measure();
1267 }
1268 
1269 ////////////////////////////////////////////////////////////////////
1270 // Function: TextNode::append_wtext
1271 // Access: Published
1272 // Description: Appends the indicates string to the end of the stored
1273 // wide-character text.
1274 ////////////////////////////////////////////////////////////////////
1275 INLINE void TextNode::
1276 append_wtext(const wstring &wtext) {
1278  invalidate_with_measure();
1279 }
1280 
1281 ////////////////////////////////////////////////////////////////////
1282 // Function: TextNode::get_wordwrapped_wtext
1283 // Access: Published
1284 // Description: Returns a wstring that represents the contents of the
1285 // text, as it has been formatted by wordwrap rules.
1286 //
1287 // In earlier versions, this did not contain any
1288 // embedded special characters like \1 or \3; now it
1289 // does.
1290 ////////////////////////////////////////////////////////////////////
1291 INLINE wstring TextNode::
1293  check_measure();
1294  return _wordwrapped_wtext;
1295 }
1296 
1297 ////////////////////////////////////////////////////////////////////
1298 // Function: TextNode::get_left
1299 // Access: Published
1300 // Description: Returns the leftmost extent of the text in local 2-d
1301 // coordinates, unmodified by the set_transform()
1302 // matrix.
1303 ////////////////////////////////////////////////////////////////////
1304 INLINE PN_stdfloat TextNode::
1305 get_left() const {
1306  check_measure();
1307  return _text_ul[0];
1308 }
1309 
1310 ////////////////////////////////////////////////////////////////////
1311 // Function: TextNode::get_right
1312 // Access: Published
1313 // Description: Returns the rightmost extent of the text in local 2-d
1314 // coordinates, unmodified by the set_transform()
1315 // matrix.
1316 ////////////////////////////////////////////////////////////////////
1317 INLINE PN_stdfloat TextNode::
1318 get_right() const {
1319  check_measure();
1320  return _text_lr[0];
1321 }
1322 
1323 ////////////////////////////////////////////////////////////////////
1324 // Function: TextNode::get_bottom
1325 // Access: Published
1326 // Description: Returns the bottommost extent of the text in local
1327 // 2-d coordinates, unmodified by the set_transform()
1328 // matrix.
1329 ////////////////////////////////////////////////////////////////////
1330 INLINE PN_stdfloat TextNode::
1331 get_bottom() const {
1332  check_measure();
1333  return _text_lr[1];
1334 }
1335 
1336 ////////////////////////////////////////////////////////////////////
1337 // Function: TextNode::get_top
1338 // Access: Published
1339 // Description: Returns the topmost extent of the text in local 2-d
1340 // coordinates, unmodified by the set_transform()
1341 // matrix.
1342 ////////////////////////////////////////////////////////////////////
1343 INLINE PN_stdfloat TextNode::
1344 get_top() const {
1345  check_measure();
1346  return _text_ul[1];
1347 }
1348 
1349 ////////////////////////////////////////////////////////////////////
1350 // Function: TextNode::get_height
1351 // Access: Published
1352 // Description: Returns the net height of the text in local 2-d
1353 // coordinates.
1354 ////////////////////////////////////////////////////////////////////
1355 INLINE PN_stdfloat TextNode::
1356 get_height() const {
1357  check_measure();
1358  return _text_ul[1] - _text_lr[1];
1359 }
1360 
1361 ////////////////////////////////////////////////////////////////////
1362 // Function: TextNode::get_width
1363 // Access: Published
1364 // Description: Returns the net width of the text in local 2-d
1365 // coordinates.
1366 ////////////////////////////////////////////////////////////////////
1367 INLINE PN_stdfloat TextNode::
1368 get_width() const {
1369  check_measure();
1370  return _text_lr[0] - _text_ul[0];
1371 }
1372 
1373 ////////////////////////////////////////////////////////////////////
1374 // Function: TextNode::get_upper_left_3d
1375 // Access: Published
1376 // Description: Returns the upper-left extent of the text object,
1377 // after it has been transformed into 3-d space by
1378 // applying the set_transform() matrix.
1379 ////////////////////////////////////////////////////////////////////
1380 INLINE LPoint3 TextNode::
1382  check_measure();
1383  return _ul3d;
1384 }
1385 
1386 ////////////////////////////////////////////////////////////////////
1387 // Function: TextNode::get_lower_right_3d
1388 // Access: Published
1389 // Description: Returns the lower-right extent of the text object,
1390 // after it has been transformed into 3-d space by
1391 // applying the set_transform() matrix.
1392 ////////////////////////////////////////////////////////////////////
1393 INLINE LPoint3 TextNode::
1395  check_measure();
1396  return _lr3d;
1397 }
1398 
1399 ////////////////////////////////////////////////////////////////////
1400 // Function: TextNode::get_num_rows
1401 // Access: Published
1402 // Description: Returns the number of rows of text that were
1403 // generated. This counts word-wrapped rows as well as
1404 // rows generated due to embedded newlines.
1405 ////////////////////////////////////////////////////////////////////
1406 INLINE int TextNode::
1407 get_num_rows() const {
1408  check_measure();
1409  return _num_rows;
1410 }
1411 
1412 ////////////////////////////////////////////////////////////////////
1413 // Function: TextNode::update
1414 // Access: Published
1415 // Description: Can be called after the TextNode has been fully
1416 // configured, to force the node to recompute its text
1417 // immediately, rather than waiting for it to be drawn.
1418 // This call is optional.
1419 ////////////////////////////////////////////////////////////////////
1420 INLINE void TextNode::
1422  check_rebuild();
1423 }
1424 
1425 ////////////////////////////////////////////////////////////////////
1426 // Function: TextNode::force_update
1427 // Access: Published
1428 // Description: Forces the TextNode to recompute itself now, even if
1429 // it believes nothing has changed. Normally, this
1430 // should not need to be called, but it may be useful if
1431 // some properties change outside of the TextNode's
1432 // knowledge (for instance, within the font).
1433 ////////////////////////////////////////////////////////////////////
1434 INLINE void TextNode::
1436  invalidate_with_measure();
1437  check_rebuild();
1438 }
1439 
1440 ////////////////////////////////////////////////////////////////////
1441 // Function: TextNode::invalidate_no_measure
1442 // Access: Private
1443 // Description: Called internally whenever some state on the TextNode
1444 // changes, requiring the internal geometry to be
1445 // recomputed, but which will not result in a change in
1446 // the size or shape of the text (for instance, the text
1447 // color changes).
1448 ////////////////////////////////////////////////////////////////////
1449 INLINE void TextNode::
1450 invalidate_no_measure() {
1451  _flags |= F_needs_rebuild;
1452 }
1453 
1454 ////////////////////////////////////////////////////////////////////
1455 // Function: TextNode::invalidate_with_measure
1456 // Access: Private
1457 // Description: Called internally whenever some state on the TextNode
1458 // changes, requiring the internal geometry to be
1459 // recomputed, and which will may result in a change in
1460 // the size or shape of the text (for instance, the text
1461 // scale changes).
1462 ////////////////////////////////////////////////////////////////////
1463 INLINE void TextNode::
1464 invalidate_with_measure() {
1465  _flags |= (F_needs_rebuild | F_needs_measure);
1467 }
1468 
1469 ////////////////////////////////////////////////////////////////////
1470 // Function: TextNode::check_rebuild
1471 // Access: Private
1472 // Description: Called internally to call do_rebuild() if necessary
1473 // (that is, if the internal geometry has changed
1474 // recently).
1475 ////////////////////////////////////////////////////////////////////
1476 INLINE void TextNode::
1477 check_rebuild() const {
1478  if ((_flags & F_needs_rebuild) != 0) {
1479  ((TextNode *)this)->do_rebuild();
1480  }
1481 }
1482 
1483 ////////////////////////////////////////////////////////////////////
1484 // Function: TextNode::check_measure
1485 // Access: Private
1486 // Description: Called internally to call do_measure() if necessary;
1487 // this will remeasure the text without necessarily
1488 // rebuilding it.
1489 ////////////////////////////////////////////////////////////////////
1490 INLINE void TextNode::
1491 check_measure() const {
1492  if ((_flags & F_needs_measure) != 0) {
1493  ((TextNode *)this)->do_measure();
1494  }
1495 }
PN_stdfloat get_frame_line_width() const
Returns the thickness of the lines that will be used to draw the frame.
Definition: textNode.I:412
PN_stdfloat get_line_height() const
Returns the number of units high each line of text is.
Definition: textNode.I:26
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 a...
Definition: textNode.I:543
void clear_frame()
Specifies that a border will not be drawn around the text.
Definition: textNode.I:315
void append_wtext(const wstring &text)
Appends the indicates string to the end of the stored wide-character text.
Definition: textEncoder.I:545
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.
Definition: textEncoder.I:193
void set_wordwrap(PN_stdfloat wordwrap)
Sets the text up to automatically wordwrap when it exceeds the indicated width.
Definition: textNode.I:905
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 ap...
Definition: textNode.I:1394
void set_font(TextFont *font)
Sets the font that will be used when making text.
void clear_max_rows()
Resets the TextNode's default behavior of not limiting the number of rows of text.
Definition: textNode.I:56
PN_stdfloat get_height() const
Returns the net height of the text in local 2-d coordinates.
Definition: textNode.I:1356
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 app...
Definition: textNode.I:1381
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 t...
Definition: textNode.I:473
void set_indent(PN_stdfloat indent)
Specifies the amount of extra space that is inserted before the first character of each line...
Definition: textNode.I:881
PN_stdfloat get_right() const
Returns the rightmost extent of the text in local 2-d coordinates, unmodified by the set_transform() ...
Definition: textNode.I:1318
void set_small_caps(bool small_caps)
Sets the small_caps flag.
Definition: textNode.I:788
void set_text(const string &text)
Changes the text that is displayed under the TextNode.
Definition: textNode.I:1171
void clear_card()
Specifies that a card will not be drawn behind the text.
Definition: textNode.I:506
void set_glyph_shift(PN_stdfloat glyph_shift)
Specifies a vertical amount to shift each letter of the text as it is placed.
Definition: textNode.I:1147
void set_align(Alignment align_type)
Specifies the alignment of the text within its margins.
void clear_align()
Restores the default alignment of 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 fram...
Definition: textNode.I:342
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_frame_line_width(PN_stdfloat line_width)
Specifies the thickness of the lines that will be used to draw the frame.
Definition: textNode.I:400
void set_bin(const string &bin)
Names the CullBin that the text geometry should be assigned to.
string encode_wtext(const wstring &wtext) const
Encodes a wide-text string into a single-char string, according to the current encoding.
Definition: textEncoder.I:557
PN_stdfloat get_bottom() const
Returns the bottommost extent of the text in local 2-d coordinates, unmodified by the set_transform()...
Definition: textNode.I:1331
void set_font(TextFont *font)
Sets the font that will be used when making text.
Definition: textNode.I:750
void set_frame_corners(bool corners)
Enables or disables the drawing of corners for the frame.
Definition: textNode.I:425
Represents a texture object, which is typically a single 2-d image but may also represent a 1-d or 3-...
Definition: texture.h:75
string get_wordwrapped_text() const
Returns a string that represents the contents of the text, as it has been formatted by wordwrap rules...
Definition: textNode.I:1239
LVecBase4 get_frame_actual() const
Returns the actual dimensions of the frame around the text.
Definition: textNode.I:377
void clear_bin()
Removes the effect of a previous call to set_bin().
Definition: textNode.I:1052
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 ...
Definition: lpoint3.h:99
LVecBase4 get_card_transformed() const
Returns the actual card dimensions, transformed by the matrix set by set_transform().
Definition: textNode.I:604
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.
Definition: textNode.I:282
Geom::UsageHint get_usage_hint() const
Returns the UsageHint that will be applied to generated geometry.
Definition: textNode.I:679
void clear_text()
Removes the text from the TextEncoder.
Definition: textEncoder.I:140
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.
Definition: textNode.I:813
void set_glyph_scale(PN_stdfloat glyph_scale)
Specifies the factor by which to scale each letter of the text as it is placed.
Definition: textNode.I:1122
bool get_card_decal() const
Returns the card_decal flag.
Definition: textNode.I:527
void set_tab_width(PN_stdfloat tab_width)
Sets the width of each tab stop, in screen units.
Definition: textNode.I:1097
PN_stdfloat get_width() const
Returns the net width of the text in local 2-d coordinates.
Definition: textNode.I:1368
void set_small_caps(bool small_caps)
Sets the small_caps flag.
void clear_text()
Removes the text from the TextNode.
Definition: textNode.I:1198
An encapsulation of a font; i.e.
Definition: textFont.h:36
LVecBase4 get_card_actual() const
Returns the actual dimensions of the card around the text.
Definition: textNode.I:578
void append_text(const string &text)
Appends the indicates string to the end of the stored text.
Definition: textNode.I:1210
int get_flatten_flags() const
Returns the flatten flags.
Definition: textNode.I:738
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.
Definition: textNode.I:68
void mark_internal_bounds_stale(Thread *current_thread=Thread::get_current_thread())
Should be called by a derived class to mark the internal bounding volume stale, so that compute_inter...
Definition: pandaNode.cxx:2467
void clear_text_color()
Removes the text color specification; the text will be colored whatever it was in the source font fil...
Definition: textNode.I:950
void set_wordwrap(PN_stdfloat wordwrap)
Sets the text up to automatically wordwrap when it exceeds the indicated width.
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 ne...
Definition: textNode.I:455
void append_unicode_char(int character)
Appends a single character to the end of the stored text.
Definition: textEncoder.I:206
This is a 4-by-4 transform matrix.
Definition: lmatrix.h:451
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.
LVecBase4 get_card_as_set() const
Returns the dimensions of the card as set by set_card_as_margin() or set_card_actual().
Definition: textNode.I:558
void append_unicode_char(wchar_t character)
Appends a single character to the end of the stored text.
Definition: textNode.I:1223
void set_wtext(const wstring &wtext)
Changes the text that is displayed under the TextNode, with a wide text.
Definition: textNode.I:1264
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.
int get_num_rows() const
Returns the number of rows of text that were generated.
Definition: textNode.I:1407
This is the base class for all two-component vectors and points.
Definition: lvecBase2.h:105
void update()
Can be called after the TextNode has been fully configured, to force the node to recompute its text i...
Definition: textNode.I:1421
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.
Definition: textNode.I:91
void set_card_decal(bool card_decal)
Sets the card_decal flag.
Definition: textNode.I:490
wstring decode_text(const string &text) const
Returns the given wstring decoded to a single-byte string, via the current encoding system...
Definition: textEncoder.I:568
void clear_wordwrap()
Removes the wordwrap setting from the text.
void clear_shadow()
Specifies that a shadow will not be drawn behind the text.
Definition: textNode.I:1019
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...
int get_max_rows() const
Returns the limit on the height of the TextNode specified by set_max_rows().
Definition: textNode.I:79
This is the base class for all three-component vectors and points.
Definition: lvecBase4.h:111
TextFont * get_font() const
Returns the font currently in use, if any.
void clear_font()
Resets the font to the default font.
Definition: textNode.I:761
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...
Definition: textNode.cxx:191
int set_draw_order(int draw_order)
Sets the drawing order of text created by the TextMaker.
Definition: textNode.I:1073
The primary interface to this module.
Definition: textNode.h:52
void append_wtext(const wstring &text)
Appends the indicates string to the end of the stored wide-character text.
Definition: textNode.I:1276
void clear_indent()
Removes the indent setting from the text.
void clear_shadow_color()
Removes the shadow color specification.
wstring get_wordwrapped_wtext() const
Returns a wstring that represents the contents of the text, as it has been formatted by wordwrap rule...
Definition: textNode.I:1292
void set_bin(const string &bin)
Names the GeomBin that the TextNode geometry should be assigned to.
Definition: textNode.I:1038
void set_coordinate_system(CoordinateSystem cs)
Specifies the coordinate system in which the text will be generated.
Definition: textNode.I:641
void set_text(const string &text)
Changes the text that is stored in the encoder.
Definition: textEncoder.I:112
void clear_wordwrap()
Removes the wordwrap setting from the TextNode.
Definition: textNode.I:917
void force_update()
Forces the TextNode to recompute itself now, even if it believes nothing has changed.
Definition: textNode.I:1435
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_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...
Definition: textNode.I:300
void set_wtext(const wstring &wtext)
Changes the text that is stored in the encoder.
Definition: textEncoder.I:516
void set_tab_width(PN_stdfloat tab_width)
Sets the width of each tab stop, in screen units.
void set_flatten_flags(int flatten_flags)
Sets the flatten flags.
Definition: textNode.I:728
void set_max_rows(int max_rows)
Sets the maximum number of rows that may be formatted by the TextNode.
Definition: textNode.I:44
void set_usage_hint(Geom::UsageHint usage_hint)
Specifies the UsageHint that will be applied to generated geometry.
Definition: textNode.I:667
PN_stdfloat get_line_height() const
Returns the number of units high each line of text is.
Definition: textFont.I:45
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...
Definition: textNode.I:995
void set_transform(const LMatrix4 &transform)
Sets an additional transform that is applied to the entire text paragraph.
Definition: textNode.I:619
LVecBase4 get_frame_as_set() const
Returns the dimensions of the frame as set by set_frame_as_margin() or set_frame_actual().
Definition: textNode.I:357
PN_stdfloat get_left() const
Returns the leftmost extent of the text in local 2-d coordinates, unmodified by the set_transform() m...
Definition: textNode.I:1305
PN_stdfloat get_top() const
Returns the topmost extent of the text in local 2-d coordinates, unmodified by the set_transform() ma...
Definition: textNode.I:1344