Cafu Engine
VarVisitors.hpp
1 /*
2 Cafu Engine, http://www.cafu.de/
3 Copyright (c) Carsten Fuchs and other contributors.
4 This project is licensed under the terms of the MIT license.
5 */
6 
7 #ifndef CAFU_VAR_VISITORS_PROPERTIES_HPP_INCLUDED
8 #define CAFU_VAR_VISITORS_PROPERTIES_HPP_INCLUDED
9 
10 #include "Variables.hpp"
11 
12 
13 namespace cf { namespace TypeSys { class TypeInfoT; } }
14 class CommandT;
15 class DocAdapterI;
16 class wxPGProperty;
17 class wxPropertyGridEvent;
18 class wxPropertyGridManager;
19 
20 
21 /// This visitor creates a wxPGProperty for the visited variable
22 /// and adds it to the given wxPropertyGridManager.
24 {
25  public:
26 
27  VarVisitorAddPropT(wxPropertyGridManager& PropMan, DocAdapterI& DocAdapter, const cf::TypeSys::TypeInfoT* TI);
28 
29  void visit(cf::TypeSys::VarT<float>& Var);
30  void visit(cf::TypeSys::VarT<double>& Var);
31  void visit(cf::TypeSys::VarT<int>& Var);
32  void visit(cf::TypeSys::VarT<unsigned int>& Var);
33  void visit(cf::TypeSys::VarT<uint16_t>& Var);
34  void visit(cf::TypeSys::VarT<uint8_t>& Var);
35  void visit(cf::TypeSys::VarT<bool>& Var);
36  void visit(cf::TypeSys::VarT<std::string>& Var);
37  void visit(cf::TypeSys::VarT<Vector2fT>& Var);
38  void visit(cf::TypeSys::VarT<Vector3fT>& Var);
39  void visit(cf::TypeSys::VarT<Vector3dT>& Var);
40  void visit(cf::TypeSys::VarT<BoundingBox3dT>& Var);
41  void visit(cf::TypeSys::VarArrayT<uint32_t>& Var);
42  void visit(cf::TypeSys::VarArrayT<uint16_t>& Var);
43  void visit(cf::TypeSys::VarArrayT<uint8_t>& Var);
44  void visit(cf::TypeSys::VarArrayT<std::string>& Var);
45 
46 
47  private:
48 
49  void SetHelpString(wxPGProperty* Prop, wxPGProperty* SourceProp = NULL) const;
50 
51  wxPropertyGridManager& m_PropMan;
52  DocAdapterI& m_DocAdapter;
53  const cf::TypeSys::TypeInfoT* m_TI;
54 };
55 
56 
57 /// This visitor updates the value of the given property `Prop` to the value of the visited variable.
59 {
60  public:
61 
62  VarVisitorUpdatePropT(wxPGProperty& Prop);
63 
64  void visit(const cf::TypeSys::VarT<float>& Var);
65  void visit(const cf::TypeSys::VarT<double>& Var);
66  void visit(const cf::TypeSys::VarT<int>& Var);
67  void visit(const cf::TypeSys::VarT<unsigned int>& Var);
68  void visit(const cf::TypeSys::VarT<uint16_t>& Var);
69  void visit(const cf::TypeSys::VarT<uint8_t>& Var);
70  void visit(const cf::TypeSys::VarT<bool>& Var);
71  void visit(const cf::TypeSys::VarT<std::string>& Var);
72  void visit(const cf::TypeSys::VarT<Vector2fT>& Var);
73  void visit(const cf::TypeSys::VarT<Vector3fT>& Var);
74  void visit(const cf::TypeSys::VarT<Vector3dT>& Var);
75  void visit(const cf::TypeSys::VarT<BoundingBox3dT>& Var);
76  void visit(const cf::TypeSys::VarArrayT<uint32_t>& Var);
77  void visit(const cf::TypeSys::VarArrayT<uint16_t>& Var);
78  void visit(const cf::TypeSys::VarArrayT<uint8_t>& Var);
79  void visit(const cf::TypeSys::VarArrayT<std::string>& Var);
80 
81 
82  private:
83 
84  wxPGProperty& m_Prop;
85 };
86 
87 
88 /// This visitor creates a command for updating the value of the visited variable according to
89 /// the given EVT_PG_CHANGING event.
91 {
92  public:
93 
94  VarVisitorHandlePropChangingEventT(wxPropertyGridEvent& Event, DocAdapterI& DocAdapter);
96 
97  CommandT* TransferCommand();
98 
99  void visit(cf::TypeSys::VarT<float>& Var);
100  void visit(cf::TypeSys::VarT<double>& Var);
101  void visit(cf::TypeSys::VarT<int>& Var);
102  void visit(cf::TypeSys::VarT<unsigned int>& Var);
103  void visit(cf::TypeSys::VarT<uint16_t>& Var);
104  void visit(cf::TypeSys::VarT<uint8_t>& Var);
105  void visit(cf::TypeSys::VarT<bool>& Var);
106  void visit(cf::TypeSys::VarT<std::string>& Var);
107  void visit(cf::TypeSys::VarT<Vector2fT>& Var);
108  void visit(cf::TypeSys::VarT<Vector3fT>& Var);
109  void visit(cf::TypeSys::VarT<Vector3dT>& Var);
110  void visit(cf::TypeSys::VarT<BoundingBox3dT>& Var);
111  void visit(cf::TypeSys::VarArrayT<uint32_t>& Var);
112  void visit(cf::TypeSys::VarArrayT<uint16_t>& Var);
113  void visit(cf::TypeSys::VarArrayT<uint8_t>& Var);
114  void visit(cf::TypeSys::VarArrayT<std::string>& Var);
115 
116 
117  private:
118 
119  wxPropertyGridEvent& m_Event;
120  DocAdapterI& m_DocAdapter;
121  CommandT* m_Command;
122 };
123 
124 
125 /// This visitor is similar to VarVisitorHandlePropChangingEventT:
126 /// It creates a command for updating the value the value of the visited variable when a *sub-property*
127 /// of the variable has changed. The given EVT_PG_CHANGING event refers to the change of the sub-property.
129 {
130  public:
131 
132  VarVisitorHandleSubChangingEventT(wxPropertyGridEvent& Event, DocAdapterI& DocAdapter);
134 
135  CommandT* TransferCommand();
136 
137  void visit(cf::TypeSys::VarT<float>& Var);
138  void visit(cf::TypeSys::VarT<double>& Var);
139  void visit(cf::TypeSys::VarT<int>& Var);
140  void visit(cf::TypeSys::VarT<unsigned int>& Var);
141  void visit(cf::TypeSys::VarT<uint16_t>& Var);
142  void visit(cf::TypeSys::VarT<uint8_t>& Var);
143  void visit(cf::TypeSys::VarT<bool>& Var);
144  void visit(cf::TypeSys::VarT<std::string>& Var);
145  void visit(cf::TypeSys::VarT<Vector2fT>& Var);
146  void visit(cf::TypeSys::VarT<Vector3fT>& Var);
147  void visit(cf::TypeSys::VarT<Vector3dT>& Var);
148  void visit(cf::TypeSys::VarT<BoundingBox3dT>& Var);
149  void visit(cf::TypeSys::VarArrayT<uint32_t>& Var);
150  void visit(cf::TypeSys::VarArrayT<uint16_t>& Var);
151  void visit(cf::TypeSys::VarArrayT<uint8_t>& Var);
152  void visit(cf::TypeSys::VarArrayT<std::string>& Var);
153 
154 
155  private:
156 
157  wxPropertyGridEvent& m_Event;
158  DocAdapterI& m_DocAdapter;
159  CommandT* m_Command;
160 };
161 
162 #endif
This is the base class for the visitors of VarTs.
Definition: Variables.hpp:266
Like VisitorT, but for const VarTs.
Definition: Variables.hpp:294
This visitor updates the value of the given property Prop to the value of the visited variable...
Definition: VarVisitors.hpp:58
This is a "wrapper" around a normal C++ variable specifically of type ArrayT<T>.
Definition: SetCompVar.hpp:16
This visitor is similar to VarVisitorHandlePropChangingEventT: It creates a command for updating the ...
Definition: VarVisitors.hpp:128
This visitor creates a command for updating the value of the visited variable according to the given ...
Definition: VarVisitors.hpp:90
This class provides a common interface to the documents of the map, GUI or model editor.
Definition: DocumentAdapter.hpp:25
This visitor creates a wxPGProperty for the visited variable and adds it to the given wxPropertyGridM...
Definition: VarVisitors.hpp:23
This class represents a general command for implementing modifications to the applications document...
Definition: CommandPattern.hpp:30
This class keeps type information (about an entity class that occurs in the game).
Definition: TypeSys.hpp:79