Panda3D
 All Classes Functions Variables Enumerations
textPropertiesManager.h
1 // Filename: textPropertiesManager.h
2 // Created by: drose (07Apr04)
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 #ifndef TEXTPROPERTIESMANAGER_H
16 #define TEXTPROPERTIESMANAGER_H
17 
18 #include "pandabase.h"
19 
20 #include "config_text.h"
21 #include "textProperties.h"
22 #include "textGraphic.h"
23 
24 ////////////////////////////////////////////////////////////////////
25 // Class : TextPropertiesManager
26 // Description : This defines all of the TextProperties structures
27 // that might be referenced by name from an embedded
28 // text string.
29 //
30 // A text string, as rendered by a TextNode, can contain
31 // embedded references to one of the TextProperties
32 // defined here, by enclosing the name between \1 (ASCII
33 // 0x01) characters; this causes a "push" to the named
34 // state. All text following the closing \1 character
35 // will then be rendered in the new state. The next \2
36 // (ASCII 0x02) character will then restore the previous
37 // state for subsequent text.
38 //
39 // For instance, "x\1up\1n\2 + y" indicates that the
40 // character "x" will be rendered in the normal state,
41 // the character "n" will be rendered in the "up" state,
42 // and then " + y" will be rendered in the normal state
43 // again.
44 //
45 // This can also be used to define arbitrary models that
46 // can serve as embedded graphic images in a text
47 // paragraph. This works similarly; the convention is
48 // to create a TextGraphic that describes the graphic
49 // image, and then associate it here via the
50 // set_graphic() call. Then "\5name\5" will embed the
51 // named graphic.
52 ////////////////////////////////////////////////////////////////////
53 class EXPCL_PANDA_TEXT TextPropertiesManager {
54 protected:
57 
58 PUBLISHED:
59  void set_properties(const string &name, const TextProperties &properties);
60  TextProperties get_properties(const string &name);
61  bool has_properties(const string &name) const;
62  void clear_properties(const string &name);
63 
64  void set_graphic(const string &name, const TextGraphic &graphic);
65  void set_graphic(const string &name, const NodePath &model);
66  TextGraphic get_graphic(const string &name);
67  bool has_graphic(const string &name) const;
68  void clear_graphic(const string &name);
69 
70  void write(ostream &out, int indent_level = 0) const;
71 
72  static TextPropertiesManager *get_global_ptr();
73 
74 public:
75  const TextProperties *get_properties_ptr(const string &name);
76  const TextGraphic *get_graphic_ptr(const string &name);
77 
78 private:
80  Properties _properties;
81 
83  Graphics _graphics;
84 
85  static TextPropertiesManager *_global_ptr;
86 };
87 
88 #include "textPropertiesManager.I"
89 
90 #endif
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:165
This defines a special model that has been constructed for the purposes of embedding an arbitrary gra...
Definition: textGraphic.h:43