Panda3D
textPropertiesManager.h
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file textPropertiesManager.h
10  * @author drose
11  * @date 2004-04-07
12  */
13 
14 #ifndef TEXTPROPERTIESMANAGER_H
15 #define TEXTPROPERTIESMANAGER_H
16 
17 #include "pandabase.h"
18 
19 #include "config_text.h"
20 #include "textProperties.h"
21 #include "textGraphic.h"
22 
23 /**
24  * This defines all of the TextProperties structures that might be referenced
25  * by name from an embedded text string.
26  *
27  * A text string, as rendered by a TextNode, can contain embedded references
28  * to one of the TextProperties defined here, by enclosing the name between \1
29  * (ASCII 0x01) characters; this causes a "push" to the named state. All text
30  * following the closing \1 character will then be rendered in the new state.
31  * The next \2 (ASCII 0x02) character will then restore the previous state for
32  * subsequent text.
33  *
34  * For instance, "x\1up\1n\2 + y" indicates that the character "x" will be
35  * rendered in the normal state, the character "n" will be rendered in the
36  * "up" state, and then " + y" will be rendered in the normal state again.
37  *
38  * This can also be used to define arbitrary models that can serve as embedded
39  * graphic images in a text paragraph. This works similarly; the convention
40  * is to create a TextGraphic that describes the graphic image, and then
41  * associate it here via the set_graphic() call. Then "\5name\5" will embed
42  * the named graphic.
43  */
44 class EXPCL_PANDA_TEXT TextPropertiesManager {
45 protected:
48 
49 PUBLISHED:
50  void set_properties(const std::string &name, const TextProperties &properties);
51  TextProperties get_properties(const std::string &name);
52  bool has_properties(const std::string &name) const;
53  void clear_properties(const std::string &name);
54 
55  void set_graphic(const std::string &name, const TextGraphic &graphic);
56  void set_graphic(const std::string &name, const NodePath &model);
57  TextGraphic get_graphic(const std::string &name);
58  bool has_graphic(const std::string &name) const;
59  void clear_graphic(const std::string &name);
60 
61  void write(std::ostream &out, int indent_level = 0) const;
62 
63  static TextPropertiesManager *get_global_ptr();
64 
65 public:
66  const TextProperties *get_properties_ptr(const std::string &name);
67  const TextGraphic *get_graphic_ptr(const std::string &name);
68 
69 private:
71  Properties _properties;
72 
74  Graphics _graphics;
75 
76  static TextPropertiesManager *_global_ptr;
77 };
78 
79 #include "textPropertiesManager.I"
80 
81 #endif
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This defines the set of visual properties that may be assigned to the individual characters of the te...
This defines all of the TextProperties structures that might be referenced by name from an embedded t...
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
Definition: nodePath.h:161
This defines a special model that has been constructed for the purposes of embedding an arbitrary gra...
Definition: textGraphic.h:37
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.