Changeset 378
- Timestamp:
- 09/12/11 10:03:34 (8 months ago)
- Location:
- cafu/trunk/CaWE/GuiEditor
- Files:
-
- 1 modified
- 2 moved
-
Commands/SetWinProp.cpp (moved) (moved from cafu/trunk/CaWE/GuiEditor/Commands/SetStrings.cpp) (3 diffs)
-
Commands/SetWinProp.hpp (moved) (moved from cafu/trunk/CaWE/GuiEditor/Commands/SetStrings.hpp) (3 diffs)
-
Windows/EditorChoiceWindow.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
cafu/trunk/CaWE/GuiEditor/Commands/SetWinProp.cpp
r374 r378 20 20 */ 21 21 22 #include "Set Strings.hpp"22 #include "SetWinProp.hpp" 23 23 #include "../GuiDocument.hpp" 24 24 … … 27 27 28 28 29 CommandSetStringsT::CommandSetStringsT(GuiDocumentT* GuiDoc, const EditorWindowT* Win, const wxString& PropertyName, 30 ArrayT<std::string>& Strings, const ArrayT<std::string>& NewStrings)29 template<class T> 30 CommandSetWinPropT<T>::CommandSetWinPropT(GuiDocumentT* GuiDoc, const EditorWindowT* Win, const wxString& PropName, T& Value, const T& NewValue) 31 31 : m_GuiDoc(GuiDoc), 32 32 m_Win(Win), 33 m_Prop ertyName(PropertyName),34 m_ Strings(Strings),35 m_New Strings(NewStrings),36 m_Old Strings(Strings)33 m_PropName(PropName), 34 m_Value(Value), 35 m_NewValue(NewValue), 36 m_OldValue(Value) 37 37 { 38 38 } 39 39 40 40 41 bool CommandSetStringsT::Do() 41 template<class T> 42 bool CommandSetWinPropT<T>::Do() 42 43 { 43 44 wxASSERT(!m_Done); 44 45 if (m_Done) return false; 45 46 46 // If the ne xt sequence didn't really change, don't put this command into the command history.47 // if (m_New Next==m_OldNext) return false;47 // If the new value isn't different from the old, don't put this command into the command history. 48 // if (m_NewValue==m_OldValue) return false; 48 49 49 m_ Strings=m_NewStrings;50 m_Value=m_NewValue; 50 51 51 m_GuiDoc->UpdateAllObservers_Modified(m_Win, m_Prop ertyName);52 m_GuiDoc->UpdateAllObservers_Modified(m_Win, m_PropName); 52 53 m_Done=true; 53 54 return true; … … 55 56 56 57 57 void CommandSetStringsT::Undo() 58 template<class T> 59 void CommandSetWinPropT<T>::Undo() 58 60 { 59 61 wxASSERT(m_Done); 60 62 if (!m_Done) return; 61 63 62 m_ Strings=m_OldStrings;64 m_Value=m_OldValue; 63 65 64 m_GuiDoc->UpdateAllObservers_Modified(m_Win, m_Prop ertyName);66 m_GuiDoc->UpdateAllObservers_Modified(m_Win, m_PropName); 65 67 m_Done=false; 66 68 } 67 69 68 70 69 wxString CommandSetStringsT::GetName() const 71 template<class T> 72 wxString CommandSetWinPropT<T>::GetName() const 70 73 { 71 return "Set strings for " + m_PropertyName;74 return "Set " + m_PropName; 72 75 } 76 77 78 template class CommandSetWinPropT< ArrayT<std::string> >; -
cafu/trunk/CaWE/GuiEditor/Commands/SetWinProp.hpp
r374 r378 20 20 */ 21 21 22 #ifndef _GUIEDITOR_SET_ STRINGS_HPP_23 #define _GUIEDITOR_SET_ STRINGS_HPP_22 #ifndef _GUIEDITOR_SET_WINDOW_PROPERTY_HPP_ 23 #define _GUIEDITOR_SET_WINDOW_PROPERTY_HPP_ 24 24 25 25 #include "../../CommandPattern.hpp" … … 31 31 class EditorWindowT; 32 32 33 class CommandSetStringsT : public CommandT 33 template<class T> 34 class CommandSetWinPropT : public CommandT 34 35 { 35 36 public: 36 37 37 CommandSetStringsT(GuiDocumentT* GuiDoc, const EditorWindowT* Win, const wxString& PropertyName, 38 ArrayT<std::string>& Strings, const ArrayT<std::string>& NewStrings); 38 CommandSetWinPropT(GuiDocumentT* GuiDoc, const EditorWindowT* Win, const wxString& PropName, T& Value, const T& NewValue); 39 39 40 40 // CommandT implementation. … … 46 46 private: 47 47 48 GuiDocumentT* m_GuiDoc;49 const EditorWindowT* m_Win;50 const wxString m_PropertyName;51 ArrayT<std::string>& m_Strings;52 const ArrayT<std::string> m_NewStrings;53 const ArrayT<std::string> m_OldStrings;48 GuiDocumentT* m_GuiDoc; 49 const EditorWindowT* m_Win; 50 const wxString m_PropName; 51 T& m_Value; 52 const T m_NewValue; 53 const T m_OldValue; 54 54 }; 55 55 } -
cafu/trunk/CaWE/GuiEditor/Windows/EditorChoiceWindow.cpp
r374 r378 24 24 #include "../GuiDocument.hpp" 25 25 #include "../Commands/ModifyWindow.hpp" 26 #include "../Commands/Set Strings.hpp"26 #include "../Commands/SetWinProp.hpp" 27 27 28 28 #include "GuiSys/WindowChoice.hpp" … … 104 104 NewStrings.PushBack(std::string(Tokenizer.GetNextToken())); 105 105 106 ChildFrame->SubmitCommand(new CommandSet StringsT(m_GuiDoc, this, PropName, m_Choice->m_Choices, NewStrings));106 ChildFrame->SubmitCommand(new CommandSetWinPropT< ArrayT<std::string> >(m_GuiDoc, this, PropName, m_Choice->m_Choices, NewStrings)); 107 107 return true; 108 108 }
