Cafu Engine
Group_SetProp.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_COMMAND_GROUP_SET_PROPERTY_HPP_INCLUDED
8 #define CAFU_COMMAND_GROUP_SET_PROPERTY_HPP_INCLUDED
9 
10 #include "../../CommandPattern.hpp"
11 
12 
13 class GroupT;
14 class MapDocumentT;
15 
16 
17 /// This class implements a command for setting the properties (other than the visibility) of a group.
19 {
20  public:
21 
22  enum PropT { PROP_NAME, PROP_COLOR, PROP_CANSELECT, PROP_SELECTASGROUP };
23 
24  /// The constructor for setting a new name.
25  /// @param MapDoc The map document the group is in.
26  /// @param Group The group whose property is set.
27  /// @param NewName The new name for the group.
28  CommandGroupSetPropT(MapDocumentT& MapDoc, GroupT* Group, const wxString& NewName);
29 
30  /// The constructor for setting a new color.
31  /// @param MapDoc The map document the group is in.
32  /// @param Group The group whose property is set.
33  /// @param NewColor The new color for the group. If Group->IsVisible is already NewVis, Do() will fail.
34  CommandGroupSetPropT(MapDocumentT& MapDoc, GroupT* Group, const wxColor& NewColor);
35 
36  /// The constructor for setting a new value for CanSelect or SelectAsGroup.
37  /// @param MapDoc The map document the group is in.
38  /// @param Group The group whose property is set.
39  /// @param Prop The boolean property that is newly set. Must be either PROP_CANSELECT or PROP_SELECTASGROUP.
40  /// @param NewFlag The new value for the above specified boolean properly.
41  CommandGroupSetPropT(MapDocumentT& MapDoc, GroupT* Group, PropT Prop, bool NewFlag);
42 
43  /// Returns the group whose property is set.
44  const GroupT* GetGroup() const { return m_Group; }
45 
46  /// Returns which property is set.
47  PropT GetProp() const { return m_Prop; }
48 
49  // Implementation of the CommandT interface.
50  bool Do();
51  void Undo();
52  wxString GetName() const;
53 
54 
55  private:
56 
57  MapDocumentT& m_MapDoc;
58  GroupT* m_Group;
59  const PropT m_Prop;
60 
61  const wxString m_OldName;
62  const wxColor m_OldColor;
63  const bool m_OldFlag;
64 
65  const wxString m_NewName;
66  const wxColor m_NewColor;
67  const bool m_NewFlag;
68 };
69 
70 #endif
This class represents a CaWE "map" document.
Definition: MapDocument.hpp:45
This class implements a command for setting the properties (other than the visibility) of a group...
Definition: Group_SetProp.hpp:18
void Undo()
This method un-does the command.
Definition: Group_SetProp.cpp:98
const GroupT * GetGroup() const
Returns the group whose property is set.
Definition: Group_SetProp.hpp:44
bool Do()
This method executes the command.
Definition: Group_SetProp.cpp:67
This class represents groups.
Definition: Group.hpp:20
CommandGroupSetPropT(MapDocumentT &MapDoc, GroupT *Group, const wxString &NewName)
The constructor for setting a new name.
Definition: Group_SetProp.cpp:13
PropT GetProp() const
Returns which property is set.
Definition: Group_SetProp.hpp:47
wxString GetName() const
Returns the name (a description) of the command.
Definition: Group_SetProp.cpp:128
This class represents a general command for implementing modifications to the applications document...
Definition: CommandPattern.hpp:30