virtual void HandleGameMenuClick(const wxString& key, wxAuiManager& manager, wxMenuItem* item) { wxASSERT(swSettings == key); wxASSERT(NULL != item); if(true == item->IsChecked()) { wxSettingsPane* pane = new wxSettingsPane(GetMainFrame(), item->GetId()); // Add it as a popup window. manager.AddPane(pane, wxAuiPaneInfo().Caption(stSettings) .CloseButton(true).MaximizeButton(false).DestroyOnClose() .Float().Dockable(false).Name(swSettings)); } else { wxAuiPaneInfo& pane = manager.GetPane(swSettings); manager.ClosePane(pane); } manager.Update(); }
/** * Moves all of the code notebooks from the hidden notebooks into the * first visible notebook * * @param auiManager the AUI manager of the main frame * @param ctrls all of the opened code controls */ static void RedistributeCodeControls(wxAuiManager& auiManager, std::vector<t4p::CodeControlClass*> ctrls) { std::vector<t4p::NotebookClass*> visible = t4p::AuiVisibleCodeNotebooks(auiManager); std::vector<t4p::NotebookClass*> all = t4p::AuiAllCodeNotebooks(auiManager); std::vector<t4p::NotebookClass*> hidden; for (size_t i = 0; i < all.size(); i++) { t4p::NotebookClass* notebook = all[i]; if (!auiManager.GetPane(notebook).IsShown()) { hidden.push_back(notebook); } } // go through the hidden notebooks and move code controls // from the hidden notebook into a visible notebook for (size_t i = 0; i < hidden.size(); i++) { t4p::NotebookClass* notebook = hidden[i]; // if a notebook is no longer shown we want to move the code controls // that it had to another notebook (one that is shown). // in the rare case that there are no shown notebooks, just remove them // (closing will trigger a save prompt if needed) while (notebook->GetPageCount() > 0) { t4p::CodeControlClass* code = notebook->GetCodeControl(0); if (!visible.empty()) { visible[0]->Adopt(code, notebook); } else { notebook->ClosePage(0); } } } // special case: if there are N visible code controls // and we have N visible notebooks, put 1 code control // in each notebook. if (ctrls.size() == visible.size()) { for (size_t i = 0; i < ctrls.size(); i++) { t4p::CodeControlClass* ctrl = ctrls[i]; bool moved = false; for (size_t a = 0; !moved && a < all.size(); a++) { t4p::NotebookClass* ctrlNotebook = all[a]; int index = ctrlNotebook->GetPageIndex(ctrl); if (index != wxNOT_FOUND && visible[i] != ctrlNotebook) { visible[i]->Adopt(ctrl, ctrlNotebook); moved = true; break; } else if (visible[i] == ctrlNotebook) { // the code control is already at a visible notebook. // move on to the next code control moved = true; break; } } } } // in case that a notebook does not have any code controls // add an empty file, this is for asthetic purposes for (size_t i = 0; i < visible.size(); i++) { t4p::NotebookClass* notebook = visible[i]; if (notebook->GetPageCount() == 0) { notebook->AddTriumphPage(t4p::FILE_TYPE_PHP); } } }