Panda3D

textProperties.I

00001 // Filename: textProperties.I
00002 // Created by:  drose (06Apr04)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 
00016 ////////////////////////////////////////////////////////////////////
00017 //     Function: TextProperties::operator !=
00018 //       Access: Published
00019 //  Description:
00020 ////////////////////////////////////////////////////////////////////
00021 INLINE bool TextProperties::
00022 operator != (const TextProperties &other) const {
00023   return !operator == (other);
00024 }
00025 
00026 ////////////////////////////////////////////////////////////////////
00027 //     Function: TextProperties::is_any_specified
00028 //       Access: Published
00029 //  Description: Returns true if any properties have been specified,
00030 //               false otherwise.
00031 ////////////////////////////////////////////////////////////////////
00032 INLINE bool TextProperties::
00033 is_any_specified() const {
00034   return (_specified != 0);
00035 }
00036 
00037 ////////////////////////////////////////////////////////////////////
00038 //     Function: TextProperties::set_default_font
00039 //       Access: Published, Static
00040 //  Description: Specifies the default font to be used for any
00041 //               TextNode whose font is uninitialized or NULL.  See
00042 //               set_font().
00043 ////////////////////////////////////////////////////////////////////
00044 INLINE void TextProperties::
00045 set_default_font(TextFont *font) {
00046   // If the user overrides the default, we don't need to try to load
00047   // whatever it would have been.
00048   _loaded_default_font = true;
00049   _default_font = font;
00050 }
00051 
00052 ////////////////////////////////////////////////////////////////////
00053 //     Function: TextProperties::get_default_font
00054 //       Access: Published, Static
00055 //  Description: Specifies the default font to be used for any
00056 //               TextNode whose font is uninitialized or NULL.  See
00057 //               set_font().
00058 ////////////////////////////////////////////////////////////////////
00059 INLINE TextFont *TextProperties::
00060 get_default_font() {
00061   if (!_loaded_default_font) {
00062     load_default_font();
00063   }
00064   return _default_font;
00065 }
00066 
00067 ////////////////////////////////////////////////////////////////////
00068 //     Function: TextProperties::set_font
00069 //       Access: Published
00070 //  Description: Sets the font that will be used when making text.  If
00071 //               this is set to NULL, the default font will be used,
00072 //               which can be set via set_default_font().
00073 ////////////////////////////////////////////////////////////////////
00074 INLINE void TextProperties::
00075 set_font(TextFont *font) {
00076   _font = font;
00077   _specified |= F_has_font;
00078 }
00079 
00080 ////////////////////////////////////////////////////////////////////
00081 //     Function: TextProperties::clear_font
00082 //       Access: Published
00083 //  Description: Restores the default font to the text.
00084 ////////////////////////////////////////////////////////////////////
00085 INLINE void TextProperties::
00086 clear_font() {
00087   _font.clear();
00088   _specified &= ~F_has_font;
00089 }
00090 
00091 ////////////////////////////////////////////////////////////////////
00092 //     Function: TextProperties::has_font
00093 //       Access: Published
00094 //  Description:
00095 ////////////////////////////////////////////////////////////////////
00096 INLINE bool TextProperties::
00097 has_font() const {
00098   return (_specified & F_has_font) != 0;
00099 }
00100 
00101 ////////////////////////////////////////////////////////////////////
00102 //     Function: TextProperties::get_font
00103 //       Access: Published
00104 //  Description: Returns the font currently in use, if any.  If no
00105 //               font is in use, this returns the default font.
00106 ////////////////////////////////////////////////////////////////////
00107 INLINE TextFont *TextProperties::
00108 get_font() const {
00109   return has_font() ? _font.p() : get_default_font();
00110 }
00111 
00112 ////////////////////////////////////////////////////////////////////
00113 //     Function: TextProperties::set_small_caps
00114 //       Access: Published
00115 //  Description: Sets the small_caps flag.  When this is set,
00116 //               lowercase letters are generated as scaled-down
00117 //               versions of their uppercase equivalents.  This is
00118 //               particularly useful to set for fonts that do not have
00119 //               lowercase letters.
00120 //
00121 //               It is also a good idea to set this for a (dynamic)
00122 //               font that has already implemented lowercase letters
00123 //               as scaled-down versions of their uppercase
00124 //               equivalents, since without this flag the texture
00125 //               memory may needlessly duplicate equivalent glyphs for
00126 //               upper and lowercase letters.  Setting this flag
00127 //               causes the texture memory to share the mixed-case
00128 //               letters.
00129 //
00130 //               The amount by which the lowercase letters are scaled
00131 //               is specified by set_small_caps_scale().
00132 ////////////////////////////////////////////////////////////////////
00133 INLINE void TextProperties::
00134 set_small_caps(bool small_caps) {
00135   _small_caps = small_caps;
00136   _specified |= F_has_small_caps;
00137 }
00138 
00139 ////////////////////////////////////////////////////////////////////
00140 //     Function: TextProperties::clear_small_caps
00141 //       Access: Published
00142 //  Description:
00143 ////////////////////////////////////////////////////////////////////
00144 INLINE void TextProperties::
00145 clear_small_caps() {
00146   _small_caps = false;
00147   _specified &= ~F_has_small_caps;
00148 }
00149 
00150 ////////////////////////////////////////////////////////////////////
00151 //     Function: TextProperties::has_small_caps
00152 //       Access: Published
00153 //  Description:
00154 ////////////////////////////////////////////////////////////////////
00155 INLINE bool TextProperties::
00156 has_small_caps() const {
00157   return (_specified & F_has_small_caps) != 0;
00158 }
00159 
00160 ////////////////////////////////////////////////////////////////////
00161 //     Function: TextProperties::get_small_caps
00162 //       Access: Published
00163 //  Description: Returns the small_caps flag.  See set_small_caps().
00164 ////////////////////////////////////////////////////////////////////
00165 INLINE bool TextProperties::
00166 get_small_caps() const {
00167   return _small_caps;
00168 }
00169 
00170 ////////////////////////////////////////////////////////////////////
00171 //     Function: TextProperties::set_small_caps_scale
00172 //       Access: Published
00173 //  Description: Sets the scale factor applied to lowercase letters
00174 //               from their uppercase equivalents, when the small_caps
00175 //               flag is in effect.  See set_small_caps().  Normally,
00176 //               this will be a number less than one.
00177 ////////////////////////////////////////////////////////////////////
00178 INLINE void TextProperties::
00179 set_small_caps_scale(PN_stdfloat small_caps_scale) {
00180   _small_caps_scale = small_caps_scale;
00181 }
00182 
00183 ////////////////////////////////////////////////////////////////////
00184 //     Function: TextProperties::clear_small_caps_scale
00185 //       Access: Published
00186 //  Description:
00187 ////////////////////////////////////////////////////////////////////
00188 INLINE void TextProperties::
00189 clear_small_caps_scale() {
00190   _small_caps_scale = text_small_caps_scale;
00191   _specified &= ~F_has_small_caps_scale;
00192 }
00193 
00194 ////////////////////////////////////////////////////////////////////
00195 //     Function: TextProperties::has_small_caps_scale
00196 //       Access: Published
00197 //  Description:
00198 ////////////////////////////////////////////////////////////////////
00199 INLINE bool TextProperties::
00200 has_small_caps_scale() const {
00201   return (_specified & F_has_small_caps_scale) != 0;
00202 }
00203 
00204 ////////////////////////////////////////////////////////////////////
00205 //     Function: TextProperties::get_small_caps_scale
00206 //       Access: Published
00207 //  Description: Returns the scale factor applied to lowercase letters
00208 //               from their uppercase equivalents, when the small_caps
00209 //               flag is in effect.  See set_small_caps() and
00210 //               set_small_caps_scale().
00211 ////////////////////////////////////////////////////////////////////
00212 INLINE PN_stdfloat TextProperties::
00213 get_small_caps_scale() const {
00214   return _small_caps_scale;
00215 }
00216 
00217 ////////////////////////////////////////////////////////////////////
00218 //     Function: TextProperties::set_slant
00219 //       Access: Published
00220 //  Description: Specifies the factor by which the text slants to the
00221 //               right.
00222 ////////////////////////////////////////////////////////////////////
00223 INLINE void TextProperties::
00224 set_slant(PN_stdfloat slant) {
00225   _slant = slant;
00226   _specified |= F_has_slant;
00227 }
00228 
00229 ////////////////////////////////////////////////////////////////////
00230 //     Function: TextProperties::clear_slant
00231 //       Access: Published
00232 //  Description: 
00233 ////////////////////////////////////////////////////////////////////
00234 INLINE void TextProperties::
00235 clear_slant() {
00236   _slant = 0.0f;
00237   _specified &= ~F_has_slant;
00238 }
00239 
00240 ////////////////////////////////////////////////////////////////////
00241 //     Function: TextProperties::has_slant
00242 //       Access: Published
00243 //  Description:
00244 ////////////////////////////////////////////////////////////////////
00245 INLINE bool TextProperties::
00246 has_slant() const {
00247   return (_specified & F_has_slant) != 0;
00248 }
00249 
00250 ////////////////////////////////////////////////////////////////////
00251 //     Function: TextProperties::get_slant
00252 //       Access: Published
00253 //  Description: Returns the factor by which the text is specified to
00254 //               slant to the right.
00255 ////////////////////////////////////////////////////////////////////
00256 INLINE PN_stdfloat TextProperties::
00257 get_slant() const {
00258   return _slant;
00259 }
00260 
00261 ////////////////////////////////////////////////////////////////////
00262 //     Function: TextProperties::set_underscore
00263 //       Access: Published
00264 //  Description: Sets the underscore flag.  When this is set,
00265 //               the text is underscored with a one-pixel line the
00266 //               same color as the text foreground, drawn at the
00267 //               baseline.
00268 ////////////////////////////////////////////////////////////////////
00269 INLINE void TextProperties::
00270 set_underscore(bool underscore) {
00271   _underscore = underscore;
00272   _specified |= F_has_underscore;
00273 }
00274 
00275 ////////////////////////////////////////////////////////////////////
00276 //     Function: TextProperties::clear_underscore
00277 //       Access: Published
00278 //  Description:
00279 ////////////////////////////////////////////////////////////////////
00280 INLINE void TextProperties::
00281 clear_underscore() {
00282   _underscore = false;
00283   _specified &= ~F_has_underscore;
00284 }
00285 
00286 ////////////////////////////////////////////////////////////////////
00287 //     Function: TextProperties::has_underscore
00288 //       Access: Published
00289 //  Description:
00290 ////////////////////////////////////////////////////////////////////
00291 INLINE bool TextProperties::
00292 has_underscore() const {
00293   return (_specified & F_has_underscore) != 0;
00294 }
00295 
00296 ////////////////////////////////////////////////////////////////////
00297 //     Function: TextProperties::get_underscore
00298 //       Access: Published
00299 //  Description: Returns the underscore flag.  See set_underscore().
00300 ////////////////////////////////////////////////////////////////////
00301 INLINE bool TextProperties::
00302 get_underscore() const {
00303   return _underscore;
00304 }
00305 
00306 ////////////////////////////////////////////////////////////////////
00307 //     Function: TextProperties::set_underscore_height
00308 //       Access: Published
00309 //  Description: Specifies the vertical height of the underscore,
00310 //               relative to the text baseline.  This only has meaning
00311 //               if the underscore mode is enabled with
00312 //               set_underscore().
00313 ////////////////////////////////////////////////////////////////////
00314 INLINE void TextProperties::
00315 set_underscore_height(PN_stdfloat underscore_height) {
00316   _underscore_height = underscore_height;
00317   _specified |= F_has_underscore_height;
00318 }
00319 
00320 ////////////////////////////////////////////////////////////////////
00321 //     Function: TextProperties::clear_underscore_height
00322 //       Access: Published
00323 //  Description: 
00324 ////////////////////////////////////////////////////////////////////
00325 INLINE void TextProperties::
00326 clear_underscore_height() {
00327   _underscore_height = 0.0f;
00328   _specified &= ~F_has_underscore_height;
00329 }
00330 
00331 ////////////////////////////////////////////////////////////////////
00332 //     Function: TextProperties::has_underscore_height
00333 //       Access: Published
00334 //  Description:
00335 ////////////////////////////////////////////////////////////////////
00336 INLINE bool TextProperties::
00337 has_underscore_height() const {
00338   return (_specified & F_has_underscore_height) != 0;
00339 }
00340 
00341 ////////////////////////////////////////////////////////////////////
00342 //     Function: TextProperties::get_underscore_height
00343 //       Access: Published
00344 //  Description: Returns the vertical height of the underscore; see
00345 //               set_underscore_height().
00346 ////////////////////////////////////////////////////////////////////
00347 INLINE PN_stdfloat TextProperties::
00348 get_underscore_height() const {
00349   return has_underscore_height() ? _underscore_height : text_default_underscore_height;
00350 }
00351 
00352 ////////////////////////////////////////////////////////////////////
00353 //     Function: TextProperties::set_align
00354 //       Access: Published
00355 //  Description: Specifies the alignment of the text within its
00356 //               margins.
00357 ////////////////////////////////////////////////////////////////////
00358 INLINE void TextProperties::
00359 set_align(TextProperties::Alignment align_type) {
00360   _align = align_type;
00361   _specified |= F_has_align;
00362 }
00363 
00364 ////////////////////////////////////////////////////////////////////
00365 //     Function: TextProperties::clear_align
00366 //       Access: Published
00367 //  Description: Restores the default alignment of the text.
00368 ////////////////////////////////////////////////////////////////////
00369 INLINE void TextProperties::
00370 clear_align() {
00371   _align = A_left;
00372   _specified &= ~F_has_align;
00373 }
00374 
00375 ////////////////////////////////////////////////////////////////////
00376 //     Function: TextProperties::has_align
00377 //       Access: Published
00378 //  Description:
00379 ////////////////////////////////////////////////////////////////////
00380 INLINE bool TextProperties::
00381 has_align() const {
00382   return (_specified & F_has_align) != 0;
00383 }
00384 
00385 ////////////////////////////////////////////////////////////////////
00386 //     Function: TextProperties::get_align
00387 //       Access: Published
00388 //  Description:
00389 ////////////////////////////////////////////////////////////////////
00390 INLINE TextProperties::Alignment TextProperties::
00391 get_align() const {
00392   return _align;
00393 }
00394 
00395 ////////////////////////////////////////////////////////////////////
00396 //     Function: TextProperties::set_indent
00397 //       Access: Published
00398 //  Description: Specifies the amount of extra space that is inserted
00399 //               before the first character of each line.  This can be
00400 //               thought of as a left margin.
00401 ////////////////////////////////////////////////////////////////////
00402 INLINE void TextProperties::
00403 set_indent(PN_stdfloat indent) {
00404   _indent_width = indent;
00405   _specified |= F_has_indent;
00406 }
00407 
00408 ////////////////////////////////////////////////////////////////////
00409 //     Function: TextProperties::clear_indent
00410 //       Access: Published
00411 //  Description: Removes the indent setting from the text.  Text
00412 //               will be as wide as it is.
00413 ////////////////////////////////////////////////////////////////////
00414 INLINE void TextProperties::
00415 clear_indent() {
00416   _indent_width = 0.0f;
00417   _specified &= ~F_has_indent;
00418 }
00419 
00420 ////////////////////////////////////////////////////////////////////
00421 //     Function: TextProperties::has_indent
00422 //       Access: Published
00423 //  Description:
00424 ////////////////////////////////////////////////////////////////////
00425 INLINE bool TextProperties::
00426 has_indent() const {
00427   return (_specified & F_has_indent) != 0;
00428 }
00429 
00430 ////////////////////////////////////////////////////////////////////
00431 //     Function: TextProperties::get_indent
00432 //       Access: Published
00433 //  Description:
00434 ////////////////////////////////////////////////////////////////////
00435 INLINE PN_stdfloat TextProperties::
00436 get_indent() const {
00437   return _indent_width;
00438 }
00439 
00440 ////////////////////////////////////////////////////////////////////
00441 //     Function: TextProperties::set_wordwrap
00442 //       Access: Published
00443 //  Description: Sets the text up to automatically wordwrap when it
00444 //               exceeds the indicated width.  This can be thought of
00445 //               as a right margin or margin width.
00446 ////////////////////////////////////////////////////////////////////
00447 INLINE void TextProperties::
00448 set_wordwrap(PN_stdfloat wordwrap) {
00449   _wordwrap_width = wordwrap;
00450   _specified |= F_has_wordwrap;
00451 }
00452 
00453 ////////////////////////////////////////////////////////////////////
00454 //     Function: TextProperties::clear_wordwrap
00455 //       Access: Published
00456 //  Description: Removes the wordwrap setting from the text.  Text
00457 //               will be as wide as it is.
00458 ////////////////////////////////////////////////////////////////////
00459 INLINE void TextProperties::
00460 clear_wordwrap() {
00461   _wordwrap_width = 0.0f;
00462   _specified &= ~F_has_wordwrap;
00463 }
00464 
00465 ////////////////////////////////////////////////////////////////////
00466 //     Function: TextProperties::has_wordwrap
00467 //       Access: Published
00468 //  Description:
00469 ////////////////////////////////////////////////////////////////////
00470 INLINE bool TextProperties::
00471 has_wordwrap() const {
00472   return (_specified & F_has_wordwrap) != 0;
00473 }
00474 
00475 ////////////////////////////////////////////////////////////////////
00476 //     Function: TextProperties::get_wordwrap
00477 //       Access: Published
00478 //  Description:
00479 ////////////////////////////////////////////////////////////////////
00480 INLINE PN_stdfloat TextProperties::
00481 get_wordwrap() const {
00482   return _wordwrap_width;
00483 }
00484 
00485 ////////////////////////////////////////////////////////////////////
00486 //     Function: TextProperties::set_preserve_trailing_whitespace
00487 //       Access: Published
00488 //  Description: Sets the preserve_trailing_whitespace flag.  When
00489 //               this is set, trailing whitespace at the end of the
00490 //               line is not stripped when the text is wordwrapped (it
00491 //               is stripped by default).  Since the trailing
00492 //               whitespace is invisible, this is important primarily
00493 //               for determining the proper width of a frame or card
00494 //               behind the text.
00495 ////////////////////////////////////////////////////////////////////
00496 INLINE void TextProperties::
00497 set_preserve_trailing_whitespace(bool preserve_trailing_whitespace) {
00498   _preserve_trailing_whitespace = preserve_trailing_whitespace;
00499   _specified |= F_has_preserve_trailing_whitespace;
00500 }
00501 
00502 ////////////////////////////////////////////////////////////////////
00503 //     Function: TextProperties::clear_preserve_trailing_whitespace
00504 //       Access: Published
00505 //  Description:
00506 ////////////////////////////////////////////////////////////////////
00507 INLINE void TextProperties::
00508 clear_preserve_trailing_whitespace() {
00509   _preserve_trailing_whitespace = false;
00510   _specified &= ~F_has_preserve_trailing_whitespace;
00511 }
00512 
00513 ////////////////////////////////////////////////////////////////////
00514 //     Function: TextProperties::has_preserve_trailing_whitespace
00515 //       Access: Published
00516 //  Description:
00517 ////////////////////////////////////////////////////////////////////
00518 INLINE bool TextProperties::
00519 has_preserve_trailing_whitespace() const {
00520   return (_specified & F_has_preserve_trailing_whitespace) != 0;
00521 }
00522 
00523 ////////////////////////////////////////////////////////////////////
00524 //     Function: TextProperties::get_preserve_trailing_whitespace
00525 //       Access: Published
00526 //  Description: Returns the preserve_trailing_whitespace flag.  See
00527 //               set_preserve_trailing_whitespace().
00528 ////////////////////////////////////////////////////////////////////
00529 INLINE bool TextProperties::
00530 get_preserve_trailing_whitespace() const {
00531   return _preserve_trailing_whitespace;
00532 }
00533 
00534 ////////////////////////////////////////////////////////////////////
00535 //     Function: TextProperties::set_text_color
00536 //       Access: Published
00537 //  Description:
00538 ////////////////////////////////////////////////////////////////////
00539 INLINE void TextProperties::
00540 set_text_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a) {
00541   set_text_color(LColor(r, g, b, a));
00542 }
00543 
00544 ////////////////////////////////////////////////////////////////////
00545 //     Function: TextProperties::set_text_color
00546 //       Access: Published
00547 //  Description:
00548 ////////////////////////////////////////////////////////////////////
00549 INLINE void TextProperties::
00550 set_text_color(const LColor &text_color) {
00551   _text_color = text_color;
00552   _specified |= F_has_text_color;
00553 }
00554 
00555 ////////////////////////////////////////////////////////////////////
00556 //     Function: TextProperties::clear_text_color
00557 //       Access: Published
00558 //  Description: Removes the text color specification; the text will
00559 //               be colored whatever it was in the source font file.
00560 ////////////////////////////////////////////////////////////////////
00561 INLINE void TextProperties::
00562 clear_text_color() {
00563   _text_color.set(1.0f, 1.0f, 1.0f, 1.0f);
00564   _specified &= ~F_has_text_color;
00565 }
00566 
00567 ////////////////////////////////////////////////////////////////////
00568 //     Function: TextProperties::has_text_color
00569 //       Access: Published
00570 //  Description:
00571 ////////////////////////////////////////////////////////////////////
00572 INLINE bool TextProperties::
00573 has_text_color() const {
00574   return (_specified & F_has_text_color) != 0;
00575 }
00576 
00577 ////////////////////////////////////////////////////////////////////
00578 //     Function: TextProperties::get_text_color
00579 //       Access: Published
00580 //  Description:
00581 ////////////////////////////////////////////////////////////////////
00582 INLINE LColor TextProperties::
00583 get_text_color() const {
00584   return _text_color;
00585 }
00586 
00587 ////////////////////////////////////////////////////////////////////
00588 //     Function: TextProperties::set_shadow_color
00589 //       Access: Published
00590 //  Description:
00591 ////////////////////////////////////////////////////////////////////
00592 INLINE void TextProperties::
00593 set_shadow_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a) {
00594   set_shadow_color(LColor(r, g, b, a));
00595 }
00596 
00597 ////////////////////////////////////////////////////////////////////
00598 //     Function: TextProperties::set_shadow_color
00599 //       Access: Published
00600 //  Description:
00601 ////////////////////////////////////////////////////////////////////
00602 INLINE void TextProperties::
00603 set_shadow_color(const LColor &shadow_color) {
00604   _shadow_color = shadow_color;
00605   _specified |= F_has_shadow_color;
00606 }
00607 
00608 ////////////////////////////////////////////////////////////////////
00609 //     Function: TextProperties::clear_shadow_color
00610 //       Access: Published
00611 //  Description: Removes the shadow color specification.
00612 ////////////////////////////////////////////////////////////////////
00613 INLINE void TextProperties::
00614 clear_shadow_color() {
00615   _shadow_color.set(0.0f, 0.0f, 0.0f, 1.0f);
00616   _specified &= ~F_has_shadow_color;
00617 }
00618 
00619 ////////////////////////////////////////////////////////////////////
00620 //     Function: TextProperties::has_shadow_color
00621 //       Access: Published
00622 //  Description:
00623 ////////////////////////////////////////////////////////////////////
00624 INLINE bool TextProperties::
00625 has_shadow_color() const {
00626   return (_specified & F_has_shadow_color) != 0;
00627 }
00628 
00629 ////////////////////////////////////////////////////////////////////
00630 //     Function: TextProperties::get_shadow_color
00631 //       Access: Published
00632 //  Description:
00633 ////////////////////////////////////////////////////////////////////
00634 INLINE LColor TextProperties::
00635 get_shadow_color() const {
00636   return _shadow_color;
00637 }
00638 
00639 ////////////////////////////////////////////////////////////////////
00640 //     Function: TextProperties::set_shadow
00641 //       Access: Published
00642 //  Description: Specifies that the text should be drawn with a
00643 //               shadow, by creating a second copy of the text and
00644 //               offsetting it slightly behind the first.
00645 ////////////////////////////////////////////////////////////////////
00646 INLINE void TextProperties::
00647 set_shadow(PN_stdfloat xoffset, PN_stdfloat yoffset) {
00648   set_shadow(LVecBase2(xoffset, yoffset));
00649 }
00650 
00651 ////////////////////////////////////////////////////////////////////
00652 //     Function: TextProperties::set_shadow
00653 //       Access: Published
00654 //  Description: Specifies that the text should be drawn with a
00655 //               shadow, by creating a second copy of the text and
00656 //               offsetting it slightly behind the first.
00657 ////////////////////////////////////////////////////////////////////
00658 INLINE void TextProperties::
00659 set_shadow(const LVecBase2 &shadow_offset) {
00660   _shadow_offset = shadow_offset;
00661   _specified |= F_has_shadow;
00662 }
00663 
00664 ////////////////////////////////////////////////////////////////////
00665 //     Function: TextProperties::clear_shadow
00666 //       Access: Published
00667 //  Description: Specifies that a shadow will not be drawn behind the
00668 //               text.
00669 ////////////////////////////////////////////////////////////////////
00670 INLINE void TextProperties::
00671 clear_shadow() {
00672   _specified &= ~F_has_shadow;
00673   _shadow_offset.set(0.0f, 0.0f);
00674 }
00675 
00676 ////////////////////////////////////////////////////////////////////
00677 //     Function: TextProperties::has_shadow
00678 //       Access: Published
00679 //  Description:
00680 ////////////////////////////////////////////////////////////////////
00681 INLINE bool TextProperties::
00682 has_shadow() const {
00683   return (_specified & F_has_shadow) != 0;
00684 }
00685 
00686 ////////////////////////////////////////////////////////////////////
00687 //     Function: TextProperties::get_shadow
00688 //       Access: Published
00689 //  Description: Returns the offset of the shadow as set by
00690 //               set_shadow().  It is an error to call this if
00691 //               has_shadow() is false.
00692 ////////////////////////////////////////////////////////////////////
00693 INLINE LVector2 TextProperties::
00694 get_shadow() const {
00695   return _shadow_offset;
00696 }
00697 
00698 ////////////////////////////////////////////////////////////////////
00699 //     Function: TextProperties::set_bin
00700 //       Access: Published
00701 //  Description: Names the CullBin that the text geometry should be
00702 //               assigned to.  If this is set, then a CullBinAttrib
00703 //               will be created to explicitly place each component in
00704 //               the named bin.
00705 //
00706 //               The draw_order value will also be passed to each
00707 //               CullBinAttrib as appropriate; this is particularly
00708 //               useful if this names a CullBinFixed, e.g. "fixed".
00709 ////////////////////////////////////////////////////////////////////
00710 INLINE void TextProperties::
00711 set_bin(const string &bin) {
00712   _bin = bin;
00713   _specified |= F_has_bin;
00714 }
00715 
00716 ////////////////////////////////////////////////////////////////////
00717 //     Function: TextProperties::clear_bin
00718 //       Access: Published
00719 //  Description: Removes the effect of a previous call to
00720 //               set_bin().  Text will be drawn in whatever bin
00721 //               it would like to be drawn in, with no explicit
00722 //               ordering.
00723 ////////////////////////////////////////////////////////////////////
00724 INLINE void TextProperties::
00725 clear_bin() {
00726   _bin = string();
00727   _specified &= ~F_has_bin;
00728 }
00729 
00730 ////////////////////////////////////////////////////////////////////
00731 //     Function: TextProperties::has_bin
00732 //       Access: Published
00733 //  Description: Returns true if an explicit drawing bin has been
00734 //               set via set_bin(), false otherwise.
00735 ////////////////////////////////////////////////////////////////////
00736 INLINE bool TextProperties::
00737 has_bin() const {
00738   return (_specified & F_has_bin) != 0;
00739 }
00740 
00741 ////////////////////////////////////////////////////////////////////
00742 //     Function: TextProperties::get_bin
00743 //       Access: Published
00744 //  Description: Returns the drawing bin set with set_bin(), or empty
00745 //               string if no bin has been set.
00746 ////////////////////////////////////////////////////////////////////
00747 INLINE const string &TextProperties::
00748 get_bin() const {
00749   return _bin;
00750 }
00751 
00752 ////////////////////////////////////////////////////////////////////
00753 //     Function: TextProperties::set_draw_order
00754 //       Access: Published
00755 //  Description: Sets the drawing order of text created by the
00756 //               TextNode.  This is actually the draw order of the
00757 //               card and frame.  The shadow is drawn at
00758 //               _draw_order+1, and the text at _draw_order+2.
00759 //
00760 //               This affects the sorting order assigned to the nodes
00761 //               as they are created, and also is passed to whatever
00762 //               bin may be assigned via set_bin().
00763 //
00764 //               The return value is the first unused draw_order
00765 //               number, e.g. _draw_order + 3.
00766 ////////////////////////////////////////////////////////////////////
00767 INLINE int TextProperties::
00768 set_draw_order(int draw_order) {
00769   _draw_order = draw_order;
00770   _specified |= F_has_draw_order;
00771   return _draw_order + 3;
00772 }
00773 
00774 ////////////////////////////////////////////////////////////////////
00775 //     Function: TextProperties::clear_draw_order
00776 //       Access: Published
00777 //  Description: 
00778 ////////////////////////////////////////////////////////////////////
00779 INLINE void TextProperties::
00780 clear_draw_order() {
00781   _draw_order = 1;
00782   _specified &= ~F_has_draw_order;
00783 }
00784 
00785 ////////////////////////////////////////////////////////////////////
00786 //     Function: TextProperties::has_draw_order
00787 //       Access: Published
00788 //  Description:
00789 ////////////////////////////////////////////////////////////////////
00790 INLINE bool TextProperties::
00791 has_draw_order() const {
00792   return (_specified & F_has_draw_order) != 0;
00793 }
00794 
00795 ////////////////////////////////////////////////////////////////////
00796 //     Function: TextProperties::get_draw_order
00797 //       Access: Published
00798 //  Description: Returns the drawing order set with set_draw_order().
00799 ////////////////////////////////////////////////////////////////////
00800 INLINE int TextProperties::
00801 get_draw_order() const {
00802   return _draw_order;
00803 }
00804 
00805 ////////////////////////////////////////////////////////////////////
00806 //     Function: TextProperties::set_tab_width
00807 //       Access: Published
00808 //  Description: Sets the width of each tab stop, in screen units.  A
00809 //               tab character embedded in the text will advance the
00810 //               horizontal position to the next tab stop.
00811 ////////////////////////////////////////////////////////////////////
00812 INLINE void TextProperties::
00813 set_tab_width(PN_stdfloat tab_width) {
00814   _tab_width = tab_width;
00815   _specified |= F_has_tab_width;
00816 }
00817 
00818 ////////////////////////////////////////////////////////////////////
00819 //     Function: TextProperties::clear_tab_width
00820 //       Access: Published
00821 //  Description: 
00822 ////////////////////////////////////////////////////////////////////
00823 INLINE void TextProperties::
00824 clear_tab_width() {
00825   _tab_width = text_tab_width;
00826   _specified &= ~F_has_tab_width;
00827 }
00828 
00829 ////////////////////////////////////////////////////////////////////
00830 //     Function: TextProperties::has_tab_width
00831 //       Access: Published
00832 //  Description:
00833 ////////////////////////////////////////////////////////////////////
00834 INLINE bool TextProperties::
00835 has_tab_width() const {
00836   return (_specified & F_has_tab_width) != 0;
00837 }
00838 
00839 ////////////////////////////////////////////////////////////////////
00840 //     Function: TextProperties::get_tab_width
00841 //       Access: Published
00842 //  Description: Returns the width set via set_tab_width().
00843 ////////////////////////////////////////////////////////////////////
00844 INLINE PN_stdfloat TextProperties::
00845 get_tab_width() const {
00846   return _tab_width;
00847 }
00848 
00849 ////////////////////////////////////////////////////////////////////
00850 //     Function: TextProperties::set_glyph_scale
00851 //       Access: Published
00852 //  Description: Specifies the factor by which to scale each letter of
00853 //               the text as it is placed, in addition to any scales
00854 //               inherited from the node or from set_text_scale().
00855 //               This can be used (possibly in conjunction with
00856 //               set_glyph_shift()) to implement superscripting or
00857 //               subscripting.
00858 //
00859 //               The glyph scale is cumulative when applied to nested
00860 //               TextProperties.  It is intended primarily for
00861 //               implementing superscripts, not for scaling the text
00862 //               in general.  See also set_text_scale(), which is
00863 //               intended primarily for scaling the text in general,
00864 //               and is not cumulative.
00865 ////////////////////////////////////////////////////////////////////
00866 INLINE void TextProperties::
00867 set_glyph_scale(PN_stdfloat glyph_scale) {
00868   _glyph_scale = glyph_scale;
00869   _specified |= F_has_glyph_scale;
00870 }
00871 
00872 ////////////////////////////////////////////////////////////////////
00873 //     Function: TextProperties::clear_glyph_scale
00874 //       Access: Published
00875 //  Description: 
00876 ////////////////////////////////////////////////////////////////////
00877 INLINE void TextProperties::
00878 clear_glyph_scale() {
00879   _specified &= ~F_has_glyph_scale;
00880   _glyph_scale = 0.0f;
00881 }
00882 
00883 ////////////////////////////////////////////////////////////////////
00884 //     Function: TextProperties::has_glyph_scale
00885 //       Access: Published
00886 //  Description:
00887 ////////////////////////////////////////////////////////////////////
00888 INLINE bool TextProperties::
00889 has_glyph_scale() const {
00890   return (_specified & F_has_glyph_scale) != 0;
00891 }
00892 
00893 ////////////////////////////////////////////////////////////////////
00894 //     Function: TextProperties::get_glyph_scale
00895 //       Access: Published
00896 //  Description: Returns the scale factor of each letter as specified
00897 //               by set_glyph_scale().
00898 ////////////////////////////////////////////////////////////////////
00899 INLINE PN_stdfloat TextProperties::
00900 get_glyph_scale() const {
00901   return _glyph_scale;
00902 }
00903 
00904 ////////////////////////////////////////////////////////////////////
00905 //     Function: TextProperties::set_glyph_shift
00906 //       Access: Published
00907 //  Description: Specifies a vertical amount to shift each letter of
00908 //               the text as it is placed.  This can be used (possibly
00909 //               in conjunction with set_glyph_scale()) to implement
00910 //               superscripting or subscripting.
00911 ////////////////////////////////////////////////////////////////////
00912 INLINE void TextProperties::
00913 set_glyph_shift(PN_stdfloat glyph_shift) {
00914   _glyph_shift = glyph_shift;
00915   _specified |= F_has_glyph_shift;
00916 }
00917 
00918 ////////////////////////////////////////////////////////////////////
00919 //     Function: TextProperties::clear_glyph_shift
00920 //       Access: Published
00921 //  Description: 
00922 ////////////////////////////////////////////////////////////////////
00923 INLINE void TextProperties::
00924 clear_glyph_shift() {
00925   _specified &= ~F_has_glyph_shift;
00926   _glyph_shift = 0.0f;
00927 }
00928 
00929 ////////////////////////////////////////////////////////////////////
00930 //     Function: TextProperties::has_glyph_shift
00931 //       Access: Published
00932 //  Description:
00933 ////////////////////////////////////////////////////////////////////
00934 INLINE bool TextProperties::
00935 has_glyph_shift() const {
00936   return (_specified & F_has_glyph_shift) != 0;
00937 }
00938 
00939 ////////////////////////////////////////////////////////////////////
00940 //     Function: TextProperties::get_glyph_shift
00941 //       Access: Published
00942 //  Description: Returns the vertical shift of each letter as
00943 //               specified by set_glyph_shift().
00944 ////////////////////////////////////////////////////////////////////
00945 INLINE PN_stdfloat TextProperties::
00946 get_glyph_shift() const {
00947   return _glyph_shift;
00948 }
00949 
00950 ////////////////////////////////////////////////////////////////////
00951 //     Function: TextProperties::set_text_scale
00952 //       Access: Published
00953 //  Description: Specifies the factor by which to scale the text, in
00954 //               addition to any scalings imposed by the node, as well
00955 //               as in addition to the glyph scale.
00956 //
00957 //               The text scale is not cumulative when applied to
00958 //               nested TextProperties.  See also set_glyph_scale(),
00959 //               which is cumulative.
00960 ////////////////////////////////////////////////////////////////////
00961 INLINE void TextProperties::
00962 set_text_scale(PN_stdfloat text_scale) {
00963   _text_scale = text_scale;
00964   _specified |= F_has_text_scale;
00965 }
00966 
00967 ////////////////////////////////////////////////////////////////////
00968 //     Function: TextProperties::clear_text_scale
00969 //       Access: Published
00970 //  Description: 
00971 ////////////////////////////////////////////////////////////////////
00972 INLINE void TextProperties::
00973 clear_text_scale() {
00974   _specified &= ~F_has_text_scale;
00975   _text_scale = 0.0f;
00976 }
00977 
00978 ////////////////////////////////////////////////////////////////////
00979 //     Function: TextProperties::has_text_scale
00980 //       Access: Published
00981 //  Description:
00982 ////////////////////////////////////////////////////////////////////
00983 INLINE bool TextProperties::
00984 has_text_scale() const {
00985   return (_specified & F_has_text_scale) != 0;
00986 }
00987 
00988 ////////////////////////////////////////////////////////////////////
00989 //     Function: TextProperties::get_text_scale
00990 //       Access: Published
00991 //  Description: Returns the scale factor of the text as specified
00992 //               by set_text_scale().
00993 ////////////////////////////////////////////////////////////////////
00994 INLINE PN_stdfloat TextProperties::
00995 get_text_scale() const {
00996   return _text_scale;
00997 }
 All Classes Functions Variables Enumerations