Changeset 123
- Timestamp:
- 08/19/10 23:35:41 (18 months ago)
- Location:
- cafu/trunk/CaWE/GuiEditor
- Files:
-
- 4 modified
-
ChildFrame.cpp (modified) (4 diffs)
-
Commands/Delete.cpp (modified) (7 diffs)
-
Commands/Delete.hpp (modified) (2 diffs)
-
WindowTree.cpp (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
cafu/trunk/CaWE/GuiEditor/ChildFrame.cpp
r94 r123 497 497 { 498 498 SubmitCommand(new CommandDeleteT(m_GuiDocument, m_GuiDocument->GetSelection())); 499 SubmitCommand(CommandSelectT::Clear(m_GuiDocument));500 499 } 501 500 … … 519 518 void GuiEditor::ChildFrameT::OnUpdateEditCutCopyDelete(wxUpdateUIEvent& UE) 520 519 { 521 if (m_GuiDocument->GetSelection().Size()>0) UE.Enable(true); 522 else UE.Enable(false); 520 UE.Enable(m_GuiDocument->GetSelection().Size()>0); 523 521 } 524 522 … … 526 524 void GuiEditor::ChildFrameT::OnUpdateEditPaste(wxUpdateUIEvent& UE) 527 525 { 528 if (ClipBoard.Size()>0 && m_GuiDocument->GetSelection().Size()==1) UE.Enable(true); 529 else UE.Enable(false); 526 UE.Enable(ClipBoard.Size()>0 && m_GuiDocument->GetSelection().Size()==1); 530 527 } 531 528 … … 702 699 case ID_TOOLBAR_WINDOW_DELETE: 703 700 SubmitCommand(new CommandDeleteT(m_GuiDocument, m_GuiDocument->GetSelection())); 704 SubmitCommand(CommandSelectT::Clear(m_GuiDocument));705 701 break; 706 702 -
cafu/trunk/CaWE/GuiEditor/Commands/Delete.cpp
r36 r123 23 23 24 24 #include "Delete.hpp" 25 25 #include "Select.hpp" 26 26 #include "../GuiDocument.hpp" 27 28 27 #include "GuiSys/Window.hpp" 29 28 … … 33 32 34 33 CommandDeleteT::CommandDeleteT(GuiDocumentT* GuiDocument, cf::GuiSys::WindowT* Window) 35 : m_GuiDocument(GuiDocument) 34 : m_GuiDocument(GuiDocument), 35 m_CommandSelect(NULL) 36 36 { 37 if (Window!=Window->GetRoot()) // Root window can never be deleted. 37 wxASSERT(Window->Parent->Children.Find(Window)>=0); 38 39 // The root window cannot be deleted. 40 if (Window!=Window->GetRoot()) 38 41 { 39 m_DeleteWindows.PushBack(Window); 40 m_Parents.PushBack(Window->Parent); 41 m_Indexes.PushBack(Window->Parent->Children.Find(Window)); 42 m_Windows.PushBack(Window); 43 m_Indices.PushBack(-1); 42 44 } 45 46 m_CommandSelect=CommandSelectT::Remove(m_GuiDocument, m_Windows); 43 47 } 44 48 … … 46 50 CommandDeleteT::CommandDeleteT(GuiDocumentT* GuiDocument, const ArrayT<cf::GuiSys::WindowT*>& Windows) 47 51 : m_GuiDocument(GuiDocument), 48 m_ DeleteWindows(Windows)52 m_CommandSelect(NULL) 49 53 { 50 for (unsigned long WinNr=0; WinNr< m_DeleteWindows.Size(); WinNr++)54 for (unsigned long WinNr=0; WinNr<Windows.Size(); WinNr++) 51 55 { 52 // Root window can never be deleted. 53 if (m_DeleteWindows[WinNr]==m_DeleteWindows[WinNr]->GetRoot()) 56 cf::GuiSys::WindowT* Window=Windows[WinNr]; 57 58 wxASSERT(Window->Parent->Children.Find(Window)>=0); 59 60 // The root window cannot be deleted. 61 if (Window!=Window->GetRoot()) 54 62 { 55 m_DeleteWindows.RemoveAtAndKeepOrder(WinNr); 56 WinNr--; 57 continue; 63 m_Windows.PushBack(Window); 64 m_Indices.PushBack(-1); 58 65 } 66 } 59 67 60 m_Parents.PushBack(m_DeleteWindows[WinNr]->Parent); 61 m_Indexes.PushBack(m_DeleteWindows[WinNr]->Parent->Children.Find(m_DeleteWindows[WinNr])); 62 } 68 m_CommandSelect=CommandSelectT::Remove(m_GuiDocument, m_Windows); 63 69 } 64 70 … … 66 72 CommandDeleteT::~CommandDeleteT() 67 73 { 74 delete m_CommandSelect; 75 68 76 if (m_Done) 69 for (unsigned long WinNr=0; WinNr<m_ DeleteWindows.Size(); WinNr++)70 delete m_ DeleteWindows[WinNr];77 for (unsigned long WinNr=0; WinNr<m_Windows.Size(); WinNr++) 78 delete m_Windows[WinNr]; 71 79 } 72 80 … … 75 83 { 76 84 wxASSERT(!m_Done); 77 78 85 if (m_Done) return false; 79 86 80 for (unsigned long WinNr=0; WinNr<m_DeleteWindows.Size(); WinNr++)81 m_Parents[WinNr]->Children.RemoveAtAndKeepOrder(m_Indexes[WinNr]);87 // Deselect any affected windows that are selected. 88 m_CommandSelect->Do(); 82 89 83 m_GuiDocument->UpdateAllObservers_Deleted(m_DeleteWindows); 90 for (unsigned long WinNr=0; WinNr<m_Windows.Size(); WinNr++) 91 { 92 cf::GuiSys::WindowT* Window=m_Windows[WinNr]; 93 94 m_Indices[WinNr]=Window->Parent->Children.Find(Window); 95 Window->Parent->Children.RemoveAtAndKeepOrder(m_Indices[WinNr]); 96 } 97 98 m_GuiDocument->UpdateAllObservers_Deleted(m_Windows); 84 99 85 100 m_Done=true; 86 87 101 return true; 88 102 } … … 92 106 { 93 107 wxASSERT(m_Done); 94 95 108 if (!m_Done) return; 96 109 97 for (unsigned long WinNr=0; WinNr<m_DeleteWindows.Size(); WinNr++) 98 m_Parents[WinNr]->Children.InsertAt(m_Indexes[WinNr], m_DeleteWindows[WinNr]); 110 for (unsigned long RevNr=0; RevNr<m_Windows.Size(); RevNr++) 111 { 112 const unsigned long WinNr =m_Windows.Size()-RevNr-1; 113 cf::GuiSys::WindowT* Window=m_Windows[WinNr]; 99 114 100 m_GuiDocument->UpdateAllObservers_Created(m_DeleteWindows); 115 Window->Parent->Children.InsertAt(m_Indices[WinNr], Window); 116 } 117 118 m_GuiDocument->UpdateAllObservers_Created(m_Windows); 119 120 // Select the previously selected windows again. 121 m_CommandSelect->Undo(); 101 122 102 123 m_Done=false; … … 106 127 wxString CommandDeleteT::GetName() const 107 128 { 108 return "Delete windows";129 return (m_Windows.Size()==1) ? "Delete 1 window" : wxString::Format("Delete %lu windows", m_Windows.Size()); 109 130 } -
cafu/trunk/CaWE/GuiEditor/Commands/Delete.hpp
r36 r123 33 33 namespace GuiEditor 34 34 { 35 class CommandSelectT; 35 36 class GuiDocumentT; 37 36 38 37 39 class CommandDeleteT : public CommandT … … 53 55 GuiDocumentT* m_GuiDocument; 54 56 55 ArrayT<cf::GuiSys::WindowT*> m_ Parents;56 ArrayT<unsigned long > m_Indexes;57 ArrayT<cf::GuiSys::WindowT*> m_DeleteWindows;57 ArrayT<cf::GuiSys::WindowT*> m_Windows; 58 ArrayT<unsigned long> m_Indices; 59 CommandSelectT* m_CommandSelect; ///< The command that unselects all windows before they are deleted. 58 60 }; 59 61 } -
cafu/trunk/CaWE/GuiEditor/WindowTree.cpp
r36 r123 281 281 wxASSERT(Windows.Size()==1); // Can't set the name property for more windows since it must always be unique. 282 282 283 wxTreeItemId TreeItem=FindTreeItem(GetRootItem(), Windows[0]);284 285 283 SetItemText(FindTreeItem(GetRootItem(), Windows[0]), Windows[0]->Name); 286 284 } … … 290 288 for (unsigned long WindowNr=0; WindowNr<Windows.Size(); WindowNr++) 291 289 { 292 int ImageNr=0; 293 294 if (!Windows[WindowNr]->ShowWindow) ImageNr=1; 295 296 SetItemImage(FindTreeItem(GetRootItem(), Windows[WindowNr]), ImageNr); 290 SetItemImage(FindTreeItem(GetRootItem(), Windows[WindowNr]), Windows[WindowNr]->ShowWindow ? 0 : 1); 297 291 } 298 292 } … … 307 301 ArrayT<wxTreeItemId> TreeItems; 308 302 ArrayT<cf::GuiSys::WindowT*> ExpandedWindows; 303 304 // Note that this may well produce TreeItems whose windows have been deleted from the document already. 309 305 GetTreeItems(GetRootItem(), TreeItems); 310 306 … … 344 340 345 341 // Make sure parents are also expanded. 346 while (GetItemParent(Result).IsOk())342 while (GetItemParent(Result).IsOk()) 347 343 { 348 344 Result=GetItemParent(Result); … … 356 352 // Expand all previously expanded items. 357 353 for (unsigned long ExWinNr=0; ExWinNr<ExpandedWindows.Size(); ExWinNr++) 358 Expand(FindTreeItem(GetRootItem(), ExpandedWindows[ExWinNr])); 354 { 355 wxTreeItemId Result=FindTreeItem(GetRootItem(), ExpandedWindows[ExWinNr]); 356 357 if (Result.IsOk()) 358 Expand(Result); 359 } 359 360 360 361 Thaw();
