void EditorManager::OnPageClosed(wxAuiNotebookEvent& event) { int index = event.GetSelection(); Editor* editor = NULL; EditorIndexMap::iterator it; for(it = mEditorIndexMap.begin(); it != mEditorIndexMap.end(); ++it) { if(it->second == index) { editor = it->first; editor->deactivate(); mEditorIndexMap.erase(it); break; } } if(editor != NULL) { if(editor == mActiveEditor) mActiveEditor = NULL; EditorList::iterator lit; for(lit = mEditors.begin(); lit != mEditors.end(); ++lit) { if((*lit) == editor) { mEditors.erase(lit); break; } } } fireEvent(EditorClosed, EditorEventArgs(editor)); // Is this handled by OnPageChanged? int selIndex = event.GetSelection(); for(it = mEditorIndexMap.begin(); it != mEditorIndexMap.end(); ++it) { if(it->second == index) { setActiveEditor(it->first); break; } } }
void EditorManager::closeEditor(Editor* editor) { assert(mEditorNotebook != NULL); if(mEditorIndexMap.find(editor) != mEditorIndexMap.end()) { if(mActiveEditor == editor) { mActiveEditor->deactivate(); mActiveEditor = NULL; } int index = mEditorIndexMap[editor]; mEditorNotebook->RemovePage(index); fireEvent(EditorClosed, EditorEventArgs(editor)); } }
void EditorManager::setActiveEditor(EditorBase* editor) { if(mActiveEditor == editor) return; if(mActiveEditor != NULL) mActiveEditor->deactivate(); mActiveEditor = editor; if(mActiveEditor != NULL) { mActiveEditor->activate(); if(mEditorNotebook != NULL && (mEditorIndexMap.find(mActiveEditor) != mEditorIndexMap.end())) { mEditorNotebook->SetSelection(mEditorIndexMap[mActiveEditor]); } } fireEvent(ActiveEditorChanged, EditorEventArgs(mActiveEditor)); }
void Editor::setName(const wxString& name) { mName = name; fireEvent(NameChanged, EditorEventArgs(this)); }