Panda3D
textProperties.I
1 // Filename: textProperties.I
2 // Created by: drose (06Apr04)
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: TextProperties::operator !=
18 // Access: Published
19 // Description:
20 ////////////////////////////////////////////////////////////////////
21 INLINE bool TextProperties::
22 operator != (const TextProperties &other) const {
23  return !operator == (other);
24 }
25 
26 ////////////////////////////////////////////////////////////////////
27 // Function: TextProperties::is_any_specified
28 // Access: Published
29 // Description: Returns true if any properties have been specified,
30 // false otherwise.
31 ////////////////////////////////////////////////////////////////////
32 INLINE bool TextProperties::
34  return (_specified != 0);
35 }
36 
37 ////////////////////////////////////////////////////////////////////
38 // Function: TextProperties::set_default_font
39 // Access: Published, Static
40 // Description: Specifies the default font to be used for any
41 // TextNode whose font is uninitialized or NULL. See
42 // set_font().
43 ////////////////////////////////////////////////////////////////////
44 INLINE void TextProperties::
46  // If the user overrides the default, we don't need to try to load
47  // whatever it would have been.
48  _loaded_default_font = true;
49  _default_font = font;
50 }
51 
52 ////////////////////////////////////////////////////////////////////
53 // Function: TextProperties::get_default_font
54 // Access: Published, Static
55 // Description: Specifies the default font to be used for any
56 // TextNode whose font is uninitialized or NULL. See
57 // set_font().
58 ////////////////////////////////////////////////////////////////////
61  if (!_loaded_default_font) {
62  load_default_font();
63  }
64  return _default_font;
65 }
66 
67 ////////////////////////////////////////////////////////////////////
68 // Function: TextProperties::set_font
69 // Access: Published
70 // Description: Sets the font that will be used when making text. If
71 // this is set to NULL, the default font will be used,
72 // which can be set via set_default_font().
73 ////////////////////////////////////////////////////////////////////
74 INLINE void TextProperties::
76  _font = font;
77  _specified |= F_has_font;
78 }
79 
80 ////////////////////////////////////////////////////////////////////
81 // Function: TextProperties::clear_font
82 // Access: Published
83 // Description: Restores the default font to the text.
84 ////////////////////////////////////////////////////////////////////
85 INLINE void TextProperties::
87  _font.clear();
88  _specified &= ~F_has_font;
89 }
90 
91 ////////////////////////////////////////////////////////////////////
92 // Function: TextProperties::has_font
93 // Access: Published
94 // Description:
95 ////////////////////////////////////////////////////////////////////
96 INLINE bool TextProperties::
97 has_font() const {
98  return (_specified & F_has_font) != 0;
99 }
100 
101 ////////////////////////////////////////////////////////////////////
102 // Function: TextProperties::get_font
103 // Access: Published
104 // Description: Returns the font currently in use, if any. If no
105 // font is in use, this returns the default font.
106 ////////////////////////////////////////////////////////////////////
108 get_font() const {
109  return has_font() ? _font.p() : get_default_font();
110 }
111 
112 ////////////////////////////////////////////////////////////////////
113 // Function: TextProperties::set_small_caps
114 // Access: Published
115 // Description: Sets the small_caps flag. When this is set,
116 // lowercase letters are generated as scaled-down
117 // versions of their uppercase equivalents. This is
118 // particularly useful to set for fonts that do not have
119 // lowercase letters.
120 //
121 // It is also a good idea to set this for a (dynamic)
122 // font that has already implemented lowercase letters
123 // as scaled-down versions of their uppercase
124 // equivalents, since without this flag the texture
125 // memory may needlessly duplicate equivalent glyphs for
126 // upper and lowercase letters. Setting this flag
127 // causes the texture memory to share the mixed-case
128 // letters.
129 //
130 // The amount by which the lowercase letters are scaled
131 // is specified by set_small_caps_scale().
132 ////////////////////////////////////////////////////////////////////
133 INLINE void TextProperties::
134 set_small_caps(bool small_caps) {
135  _small_caps = small_caps;
136  _specified |= F_has_small_caps;
137 }
138 
139 ////////////////////////////////////////////////////////////////////
140 // Function: TextProperties::clear_small_caps
141 // Access: Published
142 // Description:
143 ////////////////////////////////////////////////////////////////////
144 INLINE void TextProperties::
145 clear_small_caps() {
146  _small_caps = false;
147  _specified &= ~F_has_small_caps;
148 }
149 
150 ////////////////////////////////////////////////////////////////////
151 // Function: TextProperties::has_small_caps
152 // Access: Published
153 // Description:
154 ////////////////////////////////////////////////////////////////////
155 INLINE bool TextProperties::
156 has_small_caps() const {
157  return (_specified & F_has_small_caps) != 0;
158 }
159 
160 ////////////////////////////////////////////////////////////////////
161 // Function: TextProperties::get_small_caps
162 // Access: Published
163 // Description: Returns the small_caps flag. See set_small_caps().
164 ////////////////////////////////////////////////////////////////////
165 INLINE bool TextProperties::
166 get_small_caps() const {
167  return _small_caps;
168 }
169 
170 ////////////////////////////////////////////////////////////////////
171 // Function: TextProperties::set_small_caps_scale
172 // Access: Published
173 // Description: Sets the scale factor applied to lowercase letters
174 // from their uppercase equivalents, when the small_caps
175 // flag is in effect. See set_small_caps(). Normally,
176 // this will be a number less than one.
177 ////////////////////////////////////////////////////////////////////
178 INLINE void TextProperties::
179 set_small_caps_scale(PN_stdfloat small_caps_scale) {
180  _small_caps_scale = small_caps_scale;
181 }
182 
183 ////////////////////////////////////////////////////////////////////
184 // Function: TextProperties::clear_small_caps_scale
185 // Access: Published
186 // Description:
187 ////////////////////////////////////////////////////////////////////
188 INLINE void TextProperties::
189 clear_small_caps_scale() {
190  _small_caps_scale = text_small_caps_scale;
191  _specified &= ~F_has_small_caps_scale;
192 }
193 
194 ////////////////////////////////////////////////////////////////////
195 // Function: TextProperties::has_small_caps_scale
196 // Access: Published
197 // Description:
198 ////////////////////////////////////////////////////////////////////
199 INLINE bool TextProperties::
200 has_small_caps_scale() const {
201  return (_specified & F_has_small_caps_scale) != 0;
202 }
203 
204 ////////////////////////////////////////////////////////////////////
205 // Function: TextProperties::get_small_caps_scale
206 // Access: Published
207 // Description: Returns the scale factor applied to lowercase letters
208 // from their uppercase equivalents, when the small_caps
209 // flag is in effect. See set_small_caps() and
210 // set_small_caps_scale().
211 ////////////////////////////////////////////////////////////////////
212 INLINE PN_stdfloat TextProperties::
214  return _small_caps_scale;
215 }
216 
217 ////////////////////////////////////////////////////////////////////
218 // Function: TextProperties::set_slant
219 // Access: Published
220 // Description: Specifies the factor by which the text slants to the
221 // right.
222 ////////////////////////////////////////////////////////////////////
223 INLINE void TextProperties::
224 set_slant(PN_stdfloat slant) {
225  _slant = slant;
226  _specified |= F_has_slant;
227 }
228 
229 ////////////////////////////////////////////////////////////////////
230 // Function: TextProperties::clear_slant
231 // Access: Published
232 // Description:
233 ////////////////////////////////////////////////////////////////////
234 INLINE void TextProperties::
235 clear_slant() {
236  _slant = 0.0f;
237  _specified &= ~F_has_slant;
238 }
239 
240 ////////////////////////////////////////////////////////////////////
241 // Function: TextProperties::has_slant
242 // Access: Published
243 // Description:
244 ////////////////////////////////////////////////////////////////////
245 INLINE bool TextProperties::
246 has_slant() const {
247  return (_specified & F_has_slant) != 0;
248 }
249 
250 ////////////////////////////////////////////////////////////////////
251 // Function: TextProperties::get_slant
252 // Access: Published
253 // Description: Returns the factor by which the text is specified to
254 // slant to the right.
255 ////////////////////////////////////////////////////////////////////
256 INLINE PN_stdfloat TextProperties::
257 get_slant() const {
258  return _slant;
259 }
260 
261 ////////////////////////////////////////////////////////////////////
262 // Function: TextProperties::set_underscore
263 // Access: Published
264 // Description: Sets the underscore flag. When this is set,
265 // the text is underscored with a one-pixel line the
266 // same color as the text foreground, drawn at the
267 // baseline.
268 ////////////////////////////////////////////////////////////////////
269 INLINE void TextProperties::
270 set_underscore(bool underscore) {
271  _underscore = underscore;
272  _specified |= F_has_underscore;
273 }
274 
275 ////////////////////////////////////////////////////////////////////
276 // Function: TextProperties::clear_underscore
277 // Access: Published
278 // Description:
279 ////////////////////////////////////////////////////////////////////
280 INLINE void TextProperties::
281 clear_underscore() {
282  _underscore = false;
283  _specified &= ~F_has_underscore;
284 }
285 
286 ////////////////////////////////////////////////////////////////////
287 // Function: TextProperties::has_underscore
288 // Access: Published
289 // Description:
290 ////////////////////////////////////////////////////////////////////
291 INLINE bool TextProperties::
292 has_underscore() const {
293  return (_specified & F_has_underscore) != 0;
294 }
295 
296 ////////////////////////////////////////////////////////////////////
297 // Function: TextProperties::get_underscore
298 // Access: Published
299 // Description: Returns the underscore flag. See set_underscore().
300 ////////////////////////////////////////////////////////////////////
301 INLINE bool TextProperties::
302 get_underscore() const {
303  return _underscore;
304 }
305 
306 ////////////////////////////////////////////////////////////////////
307 // Function: TextProperties::set_underscore_height
308 // Access: Published
309 // Description: Specifies the vertical height of the underscore,
310 // relative to the text baseline. This only has meaning
311 // if the underscore mode is enabled with
312 // set_underscore().
313 ////////////////////////////////////////////////////////////////////
314 INLINE void TextProperties::
315 set_underscore_height(PN_stdfloat underscore_height) {
316  _underscore_height = underscore_height;
317  _specified |= F_has_underscore_height;
318 }
319 
320 ////////////////////////////////////////////////////////////////////
321 // Function: TextProperties::clear_underscore_height
322 // Access: Published
323 // Description:
324 ////////////////////////////////////////////////////////////////////
325 INLINE void TextProperties::
326 clear_underscore_height() {
327  _underscore_height = 0.0f;
328  _specified &= ~F_has_underscore_height;
329 }
330 
331 ////////////////////////////////////////////////////////////////////
332 // Function: TextProperties::has_underscore_height
333 // Access: Published
334 // Description:
335 ////////////////////////////////////////////////////////////////////
336 INLINE bool TextProperties::
337 has_underscore_height() const {
338  return (_specified & F_has_underscore_height) != 0;
339 }
340 
341 ////////////////////////////////////////////////////////////////////
342 // Function: TextProperties::get_underscore_height
343 // Access: Published
344 // Description: Returns the vertical height of the underscore; see
345 // set_underscore_height().
346 ////////////////////////////////////////////////////////////////////
347 INLINE PN_stdfloat TextProperties::
349  return has_underscore_height() ? _underscore_height : text_default_underscore_height;
350 }
351 
352 ////////////////////////////////////////////////////////////////////
353 // Function: TextProperties::set_align
354 // Access: Published
355 // Description: Specifies the alignment of the text within its
356 // margins.
357 ////////////////////////////////////////////////////////////////////
358 INLINE void TextProperties::
359 set_align(TextProperties::Alignment align_type) {
360  _align = align_type;
361  _specified |= F_has_align;
362 }
363 
364 ////////////////////////////////////////////////////////////////////
365 // Function: TextProperties::clear_align
366 // Access: Published
367 // Description: Restores the default alignment of the text.
368 ////////////////////////////////////////////////////////////////////
369 INLINE void TextProperties::
371  _align = A_left;
372  _specified &= ~F_has_align;
373 }
374 
375 ////////////////////////////////////////////////////////////////////
376 // Function: TextProperties::has_align
377 // Access: Published
378 // Description:
379 ////////////////////////////////////////////////////////////////////
380 INLINE bool TextProperties::
381 has_align() const {
382  return (_specified & F_has_align) != 0;
383 }
384 
385 ////////////////////////////////////////////////////////////////////
386 // Function: TextProperties::get_align
387 // Access: Published
388 // Description:
389 ////////////////////////////////////////////////////////////////////
390 INLINE TextProperties::Alignment TextProperties::
391 get_align() const {
392  return _align;
393 }
394 
395 ////////////////////////////////////////////////////////////////////
396 // Function: TextProperties::set_indent
397 // Access: Published
398 // Description: Specifies the amount of extra space that is inserted
399 // before the first character of each line. This can be
400 // thought of as a left margin.
401 ////////////////////////////////////////////////////////////////////
402 INLINE void TextProperties::
403 set_indent(PN_stdfloat indent) {
404  _indent_width = indent;
405  _specified |= F_has_indent;
406 }
407 
408 ////////////////////////////////////////////////////////////////////
409 // Function: TextProperties::clear_indent
410 // Access: Published
411 // Description: Removes the indent setting from the text. Text
412 // will be as wide as it is.
413 ////////////////////////////////////////////////////////////////////
414 INLINE void TextProperties::
416  _indent_width = 0.0f;
417  _specified &= ~F_has_indent;
418 }
419 
420 ////////////////////////////////////////////////////////////////////
421 // Function: TextProperties::has_indent
422 // Access: Published
423 // Description:
424 ////////////////////////////////////////////////////////////////////
425 INLINE bool TextProperties::
426 has_indent() const {
427  return (_specified & F_has_indent) != 0;
428 }
429 
430 ////////////////////////////////////////////////////////////////////
431 // Function: TextProperties::get_indent
432 // Access: Published
433 // Description:
434 ////////////////////////////////////////////////////////////////////
435 INLINE PN_stdfloat TextProperties::
436 get_indent() const {
437  return _indent_width;
438 }
439 
440 ////////////////////////////////////////////////////////////////////
441 // Function: TextProperties::set_wordwrap
442 // Access: Published
443 // Description: Sets the text up to automatically wordwrap when it
444 // exceeds the indicated width. This can be thought of
445 // as a right margin or margin width.
446 ////////////////////////////////////////////////////////////////////
447 INLINE void TextProperties::
448 set_wordwrap(PN_stdfloat wordwrap) {
449  _wordwrap_width = wordwrap;
450  _specified |= F_has_wordwrap;
451 }
452 
453 ////////////////////////////////////////////////////////////////////
454 // Function: TextProperties::clear_wordwrap
455 // Access: Published
456 // Description: Removes the wordwrap setting from the text. Text
457 // will be as wide as it is.
458 ////////////////////////////////////////////////////////////////////
459 INLINE void TextProperties::
461  _wordwrap_width = 0.0f;
462  _specified &= ~F_has_wordwrap;
463 }
464 
465 ////////////////////////////////////////////////////////////////////
466 // Function: TextProperties::has_wordwrap
467 // Access: Published
468 // Description:
469 ////////////////////////////////////////////////////////////////////
470 INLINE bool TextProperties::
471 has_wordwrap() const {
472  return (_specified & F_has_wordwrap) != 0;
473 }
474 
475 ////////////////////////////////////////////////////////////////////
476 // Function: TextProperties::get_wordwrap
477 // Access: Published
478 // Description:
479 ////////////////////////////////////////////////////////////////////
480 INLINE PN_stdfloat TextProperties::
481 get_wordwrap() const {
482  return _wordwrap_width;
483 }
484 
485 ////////////////////////////////////////////////////////////////////
486 // Function: TextProperties::set_preserve_trailing_whitespace
487 // Access: Published
488 // Description: Sets the preserve_trailing_whitespace flag. When
489 // this is set, trailing whitespace at the end of the
490 // line is not stripped when the text is wordwrapped (it
491 // is stripped by default). Since the trailing
492 // whitespace is invisible, this is important primarily
493 // for determining the proper width of a frame or card
494 // behind the text.
495 ////////////////////////////////////////////////////////////////////
496 INLINE void TextProperties::
497 set_preserve_trailing_whitespace(bool preserve_trailing_whitespace) {
498  _preserve_trailing_whitespace = preserve_trailing_whitespace;
499  _specified |= F_has_preserve_trailing_whitespace;
500 }
501 
502 ////////////////////////////////////////////////////////////////////
503 // Function: TextProperties::clear_preserve_trailing_whitespace
504 // Access: Published
505 // Description:
506 ////////////////////////////////////////////////////////////////////
507 INLINE void TextProperties::
508 clear_preserve_trailing_whitespace() {
509  _preserve_trailing_whitespace = false;
510  _specified &= ~F_has_preserve_trailing_whitespace;
511 }
512 
513 ////////////////////////////////////////////////////////////////////
514 // Function: TextProperties::has_preserve_trailing_whitespace
515 // Access: Published
516 // Description:
517 ////////////////////////////////////////////////////////////////////
518 INLINE bool TextProperties::
519 has_preserve_trailing_whitespace() const {
520  return (_specified & F_has_preserve_trailing_whitespace) != 0;
521 }
522 
523 ////////////////////////////////////////////////////////////////////
524 // Function: TextProperties::get_preserve_trailing_whitespace
525 // Access: Published
526 // Description: Returns the preserve_trailing_whitespace flag. See
527 // set_preserve_trailing_whitespace().
528 ////////////////////////////////////////////////////////////////////
529 INLINE bool TextProperties::
531  return _preserve_trailing_whitespace;
532 }
533 
534 ////////////////////////////////////////////////////////////////////
535 // Function: TextProperties::set_text_color
536 // Access: Published
537 // Description:
538 ////////////////////////////////////////////////////////////////////
539 INLINE void TextProperties::
540 set_text_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a) {
541  set_text_color(LColor(r, g, b, a));
542 }
543 
544 ////////////////////////////////////////////////////////////////////
545 // Function: TextProperties::set_text_color
546 // Access: Published
547 // Description:
548 ////////////////////////////////////////////////////////////////////
549 INLINE void TextProperties::
550 set_text_color(const LColor &text_color) {
551  _text_color = text_color;
552  _specified |= F_has_text_color;
553 }
554 
555 ////////////////////////////////////////////////////////////////////
556 // Function: TextProperties::clear_text_color
557 // Access: Published
558 // Description: Removes the text color specification; the text will
559 // be colored whatever it was in the source font file.
560 ////////////////////////////////////////////////////////////////////
561 INLINE void TextProperties::
563  _text_color.set(1.0f, 1.0f, 1.0f, 1.0f);
564  _specified &= ~F_has_text_color;
565 }
566 
567 ////////////////////////////////////////////////////////////////////
568 // Function: TextProperties::has_text_color
569 // Access: Published
570 // Description:
571 ////////////////////////////////////////////////////////////////////
572 INLINE bool TextProperties::
573 has_text_color() const {
574  return (_specified & F_has_text_color) != 0;
575 }
576 
577 ////////////////////////////////////////////////////////////////////
578 // Function: TextProperties::get_text_color
579 // Access: Published
580 // Description:
581 ////////////////////////////////////////////////////////////////////
582 INLINE LColor TextProperties::
583 get_text_color() const {
584  return _text_color;
585 }
586 
587 ////////////////////////////////////////////////////////////////////
588 // Function: TextProperties::set_shadow_color
589 // Access: Published
590 // Description:
591 ////////////////////////////////////////////////////////////////////
592 INLINE void TextProperties::
593 set_shadow_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a) {
594  set_shadow_color(LColor(r, g, b, a));
595 }
596 
597 ////////////////////////////////////////////////////////////////////
598 // Function: TextProperties::set_shadow_color
599 // Access: Published
600 // Description:
601 ////////////////////////////////////////////////////////////////////
602 INLINE void TextProperties::
603 set_shadow_color(const LColor &shadow_color) {
604  _shadow_color = shadow_color;
605  _specified |= F_has_shadow_color;
606 }
607 
608 ////////////////////////////////////////////////////////////////////
609 // Function: TextProperties::clear_shadow_color
610 // Access: Published
611 // Description: Removes the shadow color specification.
612 ////////////////////////////////////////////////////////////////////
613 INLINE void TextProperties::
615  _shadow_color.set(0.0f, 0.0f, 0.0f, 1.0f);
616  _specified &= ~F_has_shadow_color;
617 }
618 
619 ////////////////////////////////////////////////////////////////////
620 // Function: TextProperties::has_shadow_color
621 // Access: Published
622 // Description:
623 ////////////////////////////////////////////////////////////////////
624 INLINE bool TextProperties::
625 has_shadow_color() const {
626  return (_specified & F_has_shadow_color) != 0;
627 }
628 
629 ////////////////////////////////////////////////////////////////////
630 // Function: TextProperties::get_shadow_color
631 // Access: Published
632 // Description:
633 ////////////////////////////////////////////////////////////////////
634 INLINE LColor TextProperties::
635 get_shadow_color() const {
636  return _shadow_color;
637 }
638 
639 ////////////////////////////////////////////////////////////////////
640 // Function: TextProperties::set_shadow
641 // Access: Published
642 // Description: Specifies that the text should be drawn with a
643 // shadow, by creating a second copy of the text and
644 // offsetting it slightly behind the first.
645 ////////////////////////////////////////////////////////////////////
646 INLINE void TextProperties::
647 set_shadow(PN_stdfloat xoffset, PN_stdfloat yoffset) {
648  set_shadow(LVecBase2(xoffset, yoffset));
649 }
650 
651 ////////////////////////////////////////////////////////////////////
652 // Function: TextProperties::set_shadow
653 // Access: Published
654 // Description: Specifies that the text should be drawn with a
655 // shadow, by creating a second copy of the text and
656 // offsetting it slightly behind the first.
657 ////////////////////////////////////////////////////////////////////
658 INLINE void TextProperties::
659 set_shadow(const LVecBase2 &shadow_offset) {
660  _shadow_offset = shadow_offset;
661  _specified |= F_has_shadow;
662 }
663 
664 ////////////////////////////////////////////////////////////////////
665 // Function: TextProperties::clear_shadow
666 // Access: Published
667 // Description: Specifies that a shadow will not be drawn behind the
668 // text.
669 ////////////////////////////////////////////////////////////////////
670 INLINE void TextProperties::
672  _specified &= ~F_has_shadow;
673  _shadow_offset.set(0.0f, 0.0f);
674 }
675 
676 ////////////////////////////////////////////////////////////////////
677 // Function: TextProperties::has_shadow
678 // Access: Published
679 // Description:
680 ////////////////////////////////////////////////////////////////////
681 INLINE bool TextProperties::
682 has_shadow() const {
683  return (_specified & F_has_shadow) != 0;
684 }
685 
686 ////////////////////////////////////////////////////////////////////
687 // Function: TextProperties::get_shadow
688 // Access: Published
689 // Description: Returns the offset of the shadow as set by
690 // set_shadow(). It is an error to call this if
691 // has_shadow() is false.
692 ////////////////////////////////////////////////////////////////////
694 get_shadow() const {
695  return _shadow_offset;
696 }
697 
698 ////////////////////////////////////////////////////////////////////
699 // Function: TextProperties::set_bin
700 // Access: Published
701 // Description: Names the CullBin that the text geometry should be
702 // assigned to. If this is set, then a CullBinAttrib
703 // will be created to explicitly place each component in
704 // the named bin.
705 //
706 // The draw_order value will also be passed to each
707 // CullBinAttrib as appropriate; this is particularly
708 // useful if this names a CullBinFixed, e.g. "fixed".
709 ////////////////////////////////////////////////////////////////////
710 INLINE void TextProperties::
711 set_bin(const string &bin) {
712  _bin = bin;
713  _specified |= F_has_bin;
714 }
715 
716 ////////////////////////////////////////////////////////////////////
717 // Function: TextProperties::clear_bin
718 // Access: Published
719 // Description: Removes the effect of a previous call to
720 // set_bin(). Text will be drawn in whatever bin
721 // it would like to be drawn in, with no explicit
722 // ordering.
723 ////////////////////////////////////////////////////////////////////
724 INLINE void TextProperties::
726  _bin = string();
727  _specified &= ~F_has_bin;
728 }
729 
730 ////////////////////////////////////////////////////////////////////
731 // Function: TextProperties::has_bin
732 // Access: Published
733 // Description: Returns true if an explicit drawing bin has been
734 // set via set_bin(), false otherwise.
735 ////////////////////////////////////////////////////////////////////
736 INLINE bool TextProperties::
737 has_bin() const {
738  return (_specified & F_has_bin) != 0;
739 }
740 
741 ////////////////////////////////////////////////////////////////////
742 // Function: TextProperties::get_bin
743 // Access: Published
744 // Description: Returns the drawing bin set with set_bin(), or empty
745 // string if no bin has been set.
746 ////////////////////////////////////////////////////////////////////
747 INLINE const string &TextProperties::
748 get_bin() const {
749  return _bin;
750 }
751 
752 ////////////////////////////////////////////////////////////////////
753 // Function: TextProperties::set_draw_order
754 // Access: Published
755 // Description: Sets the drawing order of text created by the
756 // TextNode. This is actually the draw order of the
757 // card and frame. The shadow is drawn at
758 // _draw_order+1, and the text at _draw_order+2.
759 //
760 // This affects the sorting order assigned to the nodes
761 // as they are created, and also is passed to whatever
762 // bin may be assigned via set_bin().
763 //
764 // The return value is the first unused draw_order
765 // number, e.g. _draw_order + 3.
766 ////////////////////////////////////////////////////////////////////
767 INLINE int TextProperties::
768 set_draw_order(int draw_order) {
769  _draw_order = draw_order;
770  _specified |= F_has_draw_order;
771  return _draw_order + 3;
772 }
773 
774 ////////////////////////////////////////////////////////////////////
775 // Function: TextProperties::clear_draw_order
776 // Access: Published
777 // Description:
778 ////////////////////////////////////////////////////////////////////
779 INLINE void TextProperties::
780 clear_draw_order() {
781  _draw_order = 1;
782  _specified &= ~F_has_draw_order;
783 }
784 
785 ////////////////////////////////////////////////////////////////////
786 // Function: TextProperties::has_draw_order
787 // Access: Published
788 // Description:
789 ////////////////////////////////////////////////////////////////////
790 INLINE bool TextProperties::
791 has_draw_order() const {
792  return (_specified & F_has_draw_order) != 0;
793 }
794 
795 ////////////////////////////////////////////////////////////////////
796 // Function: TextProperties::get_draw_order
797 // Access: Published
798 // Description: Returns the drawing order set with set_draw_order().
799 ////////////////////////////////////////////////////////////////////
800 INLINE int TextProperties::
801 get_draw_order() const {
802  return _draw_order;
803 }
804 
805 ////////////////////////////////////////////////////////////////////
806 // Function: TextProperties::set_tab_width
807 // Access: Published
808 // Description: Sets the width of each tab stop, in screen units. A
809 // tab character embedded in the text will advance the
810 // horizontal position to the next tab stop.
811 ////////////////////////////////////////////////////////////////////
812 INLINE void TextProperties::
813 set_tab_width(PN_stdfloat tab_width) {
814  _tab_width = tab_width;
815  _specified |= F_has_tab_width;
816 }
817 
818 ////////////////////////////////////////////////////////////////////
819 // Function: TextProperties::clear_tab_width
820 // Access: Published
821 // Description:
822 ////////////////////////////////////////////////////////////////////
823 INLINE void TextProperties::
824 clear_tab_width() {
825  _tab_width = text_tab_width;
826  _specified &= ~F_has_tab_width;
827 }
828 
829 ////////////////////////////////////////////////////////////////////
830 // Function: TextProperties::has_tab_width
831 // Access: Published
832 // Description:
833 ////////////////////////////////////////////////////////////////////
834 INLINE bool TextProperties::
835 has_tab_width() const {
836  return (_specified & F_has_tab_width) != 0;
837 }
838 
839 ////////////////////////////////////////////////////////////////////
840 // Function: TextProperties::get_tab_width
841 // Access: Published
842 // Description: Returns the width set via set_tab_width().
843 ////////////////////////////////////////////////////////////////////
844 INLINE PN_stdfloat TextProperties::
845 get_tab_width() const {
846  return _tab_width;
847 }
848 
849 ////////////////////////////////////////////////////////////////////
850 // Function: TextProperties::set_glyph_scale
851 // Access: Published
852 // Description: Specifies the factor by which to scale each letter of
853 // the text as it is placed, in addition to any scales
854 // inherited from the node or from set_text_scale().
855 // This can be used (possibly in conjunction with
856 // set_glyph_shift()) to implement superscripting or
857 // subscripting.
858 //
859 // The glyph scale is cumulative when applied to nested
860 // TextProperties. It is intended primarily for
861 // implementing superscripts, not for scaling the text
862 // in general. See also set_text_scale(), which is
863 // intended primarily for scaling the text in general,
864 // and is not cumulative.
865 ////////////////////////////////////////////////////////////////////
866 INLINE void TextProperties::
867 set_glyph_scale(PN_stdfloat glyph_scale) {
868  _glyph_scale = glyph_scale;
869  _specified |= F_has_glyph_scale;
870 }
871 
872 ////////////////////////////////////////////////////////////////////
873 // Function: TextProperties::clear_glyph_scale
874 // Access: Published
875 // Description:
876 ////////////////////////////////////////////////////////////////////
877 INLINE void TextProperties::
878 clear_glyph_scale() {
879  _specified &= ~F_has_glyph_scale;
880  _glyph_scale = 0.0f;
881 }
882 
883 ////////////////////////////////////////////////////////////////////
884 // Function: TextProperties::has_glyph_scale
885 // Access: Published
886 // Description:
887 ////////////////////////////////////////////////////////////////////
888 INLINE bool TextProperties::
889 has_glyph_scale() const {
890  return (_specified & F_has_glyph_scale) != 0;
891 }
892 
893 ////////////////////////////////////////////////////////////////////
894 // Function: TextProperties::get_glyph_scale
895 // Access: Published
896 // Description: Returns the scale factor of each letter as specified
897 // by set_glyph_scale().
898 ////////////////////////////////////////////////////////////////////
899 INLINE PN_stdfloat TextProperties::
901  return _glyph_scale;
902 }
903 
904 ////////////////////////////////////////////////////////////////////
905 // Function: TextProperties::set_glyph_shift
906 // Access: Published
907 // Description: Specifies a vertical amount to shift each letter of
908 // the text as it is placed. This can be used (possibly
909 // in conjunction with set_glyph_scale()) to implement
910 // superscripting or subscripting.
911 ////////////////////////////////////////////////////////////////////
912 INLINE void TextProperties::
913 set_glyph_shift(PN_stdfloat glyph_shift) {
914  _glyph_shift = glyph_shift;
915  _specified |= F_has_glyph_shift;
916 }
917 
918 ////////////////////////////////////////////////////////////////////
919 // Function: TextProperties::clear_glyph_shift
920 // Access: Published
921 // Description:
922 ////////////////////////////////////////////////////////////////////
923 INLINE void TextProperties::
924 clear_glyph_shift() {
925  _specified &= ~F_has_glyph_shift;
926  _glyph_shift = 0.0f;
927 }
928 
929 ////////////////////////////////////////////////////////////////////
930 // Function: TextProperties::has_glyph_shift
931 // Access: Published
932 // Description:
933 ////////////////////////////////////////////////////////////////////
934 INLINE bool TextProperties::
935 has_glyph_shift() const {
936  return (_specified & F_has_glyph_shift) != 0;
937 }
938 
939 ////////////////////////////////////////////////////////////////////
940 // Function: TextProperties::get_glyph_shift
941 // Access: Published
942 // Description: Returns the vertical shift of each letter as
943 // specified by set_glyph_shift().
944 ////////////////////////////////////////////////////////////////////
945 INLINE PN_stdfloat TextProperties::
947  return _glyph_shift;
948 }
949 
950 ////////////////////////////////////////////////////////////////////
951 // Function: TextProperties::set_text_scale
952 // Access: Published
953 // Description: Specifies the factor by which to scale the text, in
954 // addition to any scalings imposed by the node, as well
955 // as in addition to the glyph scale.
956 //
957 // The text scale is not cumulative when applied to
958 // nested TextProperties. See also set_glyph_scale(),
959 // which is cumulative.
960 ////////////////////////////////////////////////////////////////////
961 INLINE void TextProperties::
962 set_text_scale(PN_stdfloat text_scale) {
963  _text_scale = text_scale;
964  _specified |= F_has_text_scale;
965 }
966 
967 ////////////////////////////////////////////////////////////////////
968 // Function: TextProperties::clear_text_scale
969 // Access: Published
970 // Description:
971 ////////////////////////////////////////////////////////////////////
972 INLINE void TextProperties::
973 clear_text_scale() {
974  _specified &= ~F_has_text_scale;
975  _text_scale = 0.0f;
976 }
977 
978 ////////////////////////////////////////////////////////////////////
979 // Function: TextProperties::has_text_scale
980 // Access: Published
981 // Description:
982 ////////////////////////////////////////////////////////////////////
983 INLINE bool TextProperties::
984 has_text_scale() const {
985  return (_specified & F_has_text_scale) != 0;
986 }
987 
988 ////////////////////////////////////////////////////////////////////
989 // Function: TextProperties::get_text_scale
990 // Access: Published
991 // Description: Returns the scale factor of the text as specified
992 // by set_text_scale().
993 ////////////////////////////////////////////////////////////////////
994 INLINE PN_stdfloat TextProperties::
995 get_text_scale() const {
996  return _text_scale;
997 }
bool is_any_specified() const
Returns true if any properties have been specified, false otherwise.
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...
PN_stdfloat get_underscore_height() const
Returns the vertical height of the underscore; see set_underscore_height().
void set_font(TextFont *font)
Sets the font that will be used when making text.
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.
void set_underscore_height(PN_stdfloat underscore_height)
Specifies the vertical height of the underscore, relative to the text baseline.
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...
TextFont * get_font() const
Returns the font currently in use, if any.
PN_stdfloat get_slant() const
Returns the factor by which the text is specified to slant to the right.
void set_bin(const string &bin)
Names the CullBin that the text geometry should be assigned to.
static TextFont * get_default_font()
Specifies the default font to be used for any TextNode whose font is uninitialized or NULL...
PN_stdfloat get_tab_width() const
Returns the width set via set_tab_width().
bool get_small_caps() const
Returns the small_caps flag.
bool get_underscore() const
Returns the underscore flag.
void set_text_scale(PN_stdfloat text_scale)
Specifies the factor by which to scale the text, in addition to any scalings imposed by the node...
void clear_text_color()
Removes the text color specification; the text will be colored whatever it was in the source font fil...
void set_small_caps(bool small_caps)
Sets the small_caps flag.
An encapsulation of a font; i.e.
Definition: textFont.h:36
PN_stdfloat get_glyph_scale() const
Returns the scale factor of each letter as specified by set_glyph_scale().
void set_wordwrap(PN_stdfloat wordwrap)
Sets the text up to automatically wordwrap when it exceeds the indicated width.
static void set_default_font(TextFont *)
Specifies the default font to be used for any TextNode whose font is uninitialized or NULL...
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.
bool get_preserve_trailing_whitespace() const
Returns the preserve_trailing_whitespace flag.
int get_draw_order() const
Returns the drawing order set with set_draw_order().
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.
Definition: lvecBase2.h:105
void clear_wordwrap()
Removes the wordwrap setting from the text.
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...
void set_underscore(bool underscore)
Sets the underscore flag.
This is the base class for all three-component vectors and points.
Definition: lvecBase4.h:111
This is a two-component vector offset.
Definition: lvector2.h:91
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.
const string & get_bin() const
Returns the drawing bin set with set_bin(), or empty string if no bin has been set.
PN_stdfloat get_glyph_shift() const
Returns the vertical shift of each letter as specified by set_glyph_shift().
PN_stdfloat get_small_caps_scale() const
Returns the scale factor applied to lowercase letters from their uppercase equivalents, when the small_caps flag is in effect.
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_tab_width(PN_stdfloat tab_width)
Sets the width of each tab stop, in screen units.
void set_preserve_trailing_whitespace(bool preserve_trailing_whitespace)
Sets the preserve_trailing_whitespace flag.
bool has_bin() const
Returns true if an explicit drawing bin has been set via set_bin(), false otherwise.
PN_stdfloat get_text_scale() const
Returns the scale factor of the text as specified by set_text_scale().
LVector2 get_shadow() const
Returns the offset of the shadow as set by set_shadow().