void CMakePlugin::UnPlug() { wxASSERT(m_mgr); Notebook* notebook = m_mgr->GetWorkspacePaneNotebook(); wxASSERT(notebook); int pos = notebook->GetPageIndex("CMake Help"); if(pos != wxNOT_FOUND) { CMakeHelpTab* helpTab = dynamic_cast<CMakeHelpTab*>(notebook->GetPage(pos)); if(helpTab) { helpTab->Stop(); } notebook->RemovePage(pos); } // Unbind events wxTheApp->Unbind(wxEVT_COMMAND_MENU_SELECTED, &CMakePlugin::OnSettings, this, XRCID("cmake_settings")); EventNotifier::Get()->Unbind(wxEVT_SHOW_WORKSPACE_TAB, &CMakePlugin::OnToggleHelpTab, this); EventNotifier::Get()->Unbind(wxEVT_CONTEXT_MENU_PROJECT, &CMakePlugin::OnProjectContextMenu, this); EventNotifier::Get()->Unbind(wxEVT_CONTEXT_MENU_WORKSPACE, &CMakePlugin::OnWorkspaceContextMenu, this); EventNotifier::Get()->Unbind(wxEVT_PROJ_FILE_ADDED, &CMakePlugin::OnFileAdded, this); EventNotifier::Get()->Unbind(wxEVT_PROJ_FILE_REMOVED, &CMakePlugin::OnFileRemoved, this); Unbind(wxEVT_ASYNC_PROCESS_OUTPUT, &CMakePlugin::OnCMakeOutput, this); Unbind(wxEVT_ASYNC_PROCESS_TERMINATED, &CMakePlugin::OnCMakeTerminated, this); }
void PluginManager::ToggleOutputPane(const wxString& selectedWindow) { if(ManagerST::Get()->IsPaneVisible(wxT("Output View"))) { if(!selectedWindow.IsEmpty()) { wxString selectedTabName; Notebook* book = clMainFrame::Get()->GetOutputPane()->GetNotebook(); int where = book->GetSelection(); if(where != wxNOT_FOUND) { selectedTabName = book->GetPageText(where); } if(selectedTabName == selectedWindow) { // The requested tab is already selected, just hide the pane ManagerST::Get()->HidePane("Output View"); } else { // The output pane is visible, but the selected tab is not the one we wanted // Select it ManagerST::Get()->ShowOutputPane(selectedWindow); } } else { // The output pane is visible and the selected tab is the one we requested // So just hide it ManagerST::Get()->HidePane("Output View"); } } else { // The output pane is hidden, show it and select the requested tab ManagerST::Get()->ShowOutputPane(selectedWindow); } }
void clMultiBook::SetPageBitmap(size_t index, const wxBitmap& bmp) { Notebook* book; size_t bookIndex; size_t modIndex; if(GetBookByPageIndex(index, &book, bookIndex, modIndex)) { book->SetPageBitmap(modIndex, bmp); } }
TreeNotebookItem::TreeNotebookItem(Notebook& notebook) : QObject(), QTreeWidgetItem(QTreeWidgetItem::Type), notebook(notebook) { this->setText(0, QObject::tr("Notebook")); // TODO: Notebook::getTitle() for (const QString& sectionName : notebook.getSectionNames()) { QTreeWidgetItem* sectionItem = new QTreeWidgetItem(SECTION_TREE_TYPE); sectionItem->setText(0, sectionName); this->addChild(sectionItem); for (NotebookPage* page : notebook.getPages(sectionName)) { Q_ASSERT(page); this->addPageToSectionItem(*sectionItem, *page); } } connect(&this->notebook, SIGNAL(pageMoved(NotebookPage*,QString,int)), SLOT(updatePageItem(NotebookPage*,QString,int)) ); connect(&this->notebook, SIGNAL(pageRemoved(QString,NotebookPage*)), SLOT(removePageItem(QString,NotebookPage*)) ); connect(&this->notebook, SIGNAL(sectionRenamed(QString,QString)), SLOT(renameSection(QString,QString)) ); }
wxWindow* clMultiBook::GetCurrentPage() const { Notebook* book; size_t bookIndex; if(GetActiveBook(&book, bookIndex)) { return book->GetCurrentPage(); } return nullptr; }
void ZoomNavigator::DoInitialize() { znConfigItem data; if ( m_config->ReadItem( &data ) ) { m_enabled = data.IsEnabled(); } // create tab (possibly detached) Notebook *book = m_mgr->GetWorkspacePaneNotebook(); if( IsZoomPaneDetached() ) { // Make the window child of the main panel (which is the grand parent of the notebook) DockablePane *cp = new DockablePane(book->GetParent()->GetParent(), book, ZOOM_PANE_TITLE, wxNullBitmap, wxSize(200, 200)); zoompane = new wxPanel( cp ); cp->SetChildNoReparent(zoompane); } else { zoompane = new wxPanel( book ); book->AddPage( zoompane, ZOOM_PANE_TITLE, false); } m_text = new ZoomText( zoompane ); m_text->Connect(wxEVT_LEFT_DOWN, wxMouseEventHandler(ZoomNavigator::OnPreviewClicked), NULL, this); m_text->Connect(wxEVT_LEFT_DCLICK, wxMouseEventHandler(ZoomNavigator::OnPreviewClicked), NULL, this); m_text->SetCursor(wxCURSOR_POINT_LEFT); wxBoxSizer* bs = new wxBoxSizer( wxVERTICAL ); bs->Add( m_text, 1, wxEXPAND, 0 ); wxCheckBox* cbEnablePlugin = new wxCheckBox(zoompane, wxID_ANY, _("Enable plugin")); cbEnablePlugin->SetValue( data.IsEnabled() ); bs->Add( cbEnablePlugin, 0, wxEXPAND); cbEnablePlugin->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(ZoomNavigator::OnEnablePlugin), NULL, this); zoompane->SetSizer( bs ); }
void CMakePlugin::UnPlug() { wxASSERT(m_mgr); Notebook* notebook = m_mgr->GetWorkspacePaneNotebook(); wxASSERT(notebook); size_t pos = notebook->GetPageIndex("CMake Help"); if (pos != Notebook::npos) { CMakeHelpTab* helpTab = dynamic_cast<CMakeHelpTab*>( notebook->GetPage(pos) ); if ( helpTab ) { helpTab->Stop(); } notebook->RemovePage(pos); } // Unbind events wxTheApp->Unbind(wxEVT_COMMAND_MENU_SELECTED, &CMakePlugin::OnSettings, this, XRCID("cmake_settings")); EventNotifier::Get()->Unbind(wxEVT_CMD_PROJ_SETTINGS_SAVED, wxCommandEventHandler(CMakePlugin::OnSaveConfig), this); EventNotifier::Get()->Unbind(wxEVT_GET_PROJECT_BUILD_CMD, clBuildEventHandler(CMakePlugin::OnGetBuildCommand), this); EventNotifier::Get()->Unbind(wxEVT_GET_PROJECT_CLEAN_CMD, clBuildEventHandler(CMakePlugin::OnGetCleanCommand), this); EventNotifier::Get()->Unbind(wxEVT_GET_IS_PLUGIN_MAKEFILE, clBuildEventHandler(CMakePlugin::OnGetIsPluginMakefile), this); EventNotifier::Get()->Unbind(wxEVT_PLUGIN_EXPORT_MAKEFILE, clBuildEventHandler(CMakePlugin::OnExportMakefile), this); EventNotifier::Get()->Unbind(wxEVT_WORKSPACE_LOADED, wxCommandEventHandler(CMakePlugin::OnWorkspaceLoaded), this); }
void clMultiBook::OnFocus(wxFocusEvent& e) { e.Skip(); wxWindow* focusedWindow = wxWindow::FindFocus(); CHECK_PTR_RET(focusedWindow); wxWindow* parent = focusedWindow->GetParent(); while(parent) { Notebook* book = dynamic_cast<Notebook*>(parent); if(book && IsOurNotebook(book)) { // This book is one of ours... int index = book->GetSelection(); if(index != wxNOT_FOUND) { int oldSelection = m_selection; m_selection = BookIndexToGlobalIndex(book, index); if((m_selection != wxNOT_FOUND) && (m_selection != oldSelection)) { // Selection has changed, notify about this wxBookCtrlEvent event(wxEVT_BOOK_PAGE_CHANGED); event.SetEventObject(this); event.SetSelection(m_selection); event.SetOldSelection(oldSelection); GetEventHandler()->ProcessEvent(event); } } break; } parent = parent->GetParent(); } }
SymbolViewPlugin::SymbolViewPlugin(IManager* manager) : IPlugin(manager) { m_longName = _("Outline Plugin"); m_shortName = wxT("Outline"); OutlineSettings os; os.Load(); Notebook* book = m_mgr->GetWorkspacePaneNotebook(); if(IsPaneDetached()) { // Make the window child of the main panel (which is the grand parent of the notebook) DockablePane* cp = new DockablePane(book->GetParent()->GetParent(), book, _("Outline"), false, wxNullBitmap, wxSize(200, 200)); m_view = new OutlineTab(cp, m_mgr); cp->SetChildNoReparent(m_view); m_view->m_isEnabled = true; // Enabled when detached } else { m_view = new OutlineTab(book, m_mgr); book->AddPage(m_view, _("Outline"), false); } EventNotifier::Get()->Bind(wxEVT_SHOW_WORKSPACE_TAB, &SymbolViewPlugin::OnToggleTab, this); m_mgr->AddWorkspaceTab(_("Outline")); m_mgr->GetWorkspacePaneNotebook()->Bind(wxEVT_BOOK_PAGE_CHANGED, &SymbolViewPlugin::OnPageChanged, this); }
wxString clMultiBook::GetPageText(size_t page) const { Notebook* book; size_t bookIndex; size_t modIndex; if(GetBookByPageIndex(page, &book, bookIndex, modIndex)) { return book->GetPageText(modIndex); } return wxEmptyString; }
bool clMultiBook::SetPageText(size_t page, const wxString& text) { Notebook* book; size_t bookIndex; size_t modIndex; if(GetBookByPageIndex(page, &book, bookIndex, modIndex)) { return book->SetPageText(modIndex, text); } return false; }
wxWindow* clMultiBook::GetPage(size_t index) const { Notebook* book; size_t modIndex; size_t bookIndex; if(!GetBookByPageIndex(index, &book, bookIndex, modIndex)) { return nullptr; } return book->GetPage(modIndex); }
wxBitmap clMultiBook::GetPageBitmap(size_t page) const { Notebook* book; size_t bookIndex; size_t modIndex; if(GetBookByPageIndex(page, &book, bookIndex, modIndex)) { return book->GetPageBitmap(modIndex); } return wxNullBitmap; }
void OutputTabWindow::OnToggleHoldOpen(wxCommandEvent& e) { int sel = wxNOT_FOUND; Notebook* book = clMainFrame::Get()->GetOutputPane()->GetNotebook(); if(book && (sel = book->GetSelection()) != wxNOT_FOUND) { EditorConfigST::Get()->SetPaneStickiness(book->GetPageText(sel), e.IsChecked()); } }
Style const &Item::style() const { ASSERT(d); Notebook *n = d->book(); if (n) return n->style(); qDebug() << "Item" << this << "not connected to notebook"; // This appears to happens during item deletion. horrible, but true. return Style::defaultStyle(); }
bool EntryData::isWritable() const { Notebook *b = book(); if (!b || b->isReadOnly()) return false; if (isUnlocked()) return true; if (isEmpty()) return true; return isRecent() && App::instance()->cui()->match(cui_); }
Notebook* clMultiBook::CreateNotebook(wxWindow* parent) { Notebook* book = new Notebook(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_style); book->SetStyle(m_style); book->Bind(wxEVT_BOOK_PAGE_CLOSING, &clMultiBook::OnEventProxy, this); book->Bind(wxEVT_BOOK_PAGE_CLOSED, &clMultiBook::OnEventProxy, this); book->Bind(wxEVT_BOOK_PAGE_CHANGED, &clMultiBook::OnEventProxy, this); book->Bind(wxEVT_BOOK_PAGE_CHANGING, &clMultiBook::OnEventProxy, this); book->Bind(wxEVT_BOOK_PAGE_CLOSE_BUTTON, &clMultiBook::OnEventProxy, this); book->Bind(wxEVT_BOOK_TABAREA_DCLICKED, &clMultiBook::OnEventProxy, this); book->Bind(wxEVT_BOOK_TAB_DCLICKED, &clMultiBook::OnEventProxy, this); book->Bind(wxEVT_BOOK_TAB_CONTEXT_MENU, &clMultiBook::OnEventProxy, this); return book; }
bool clMultiBook::InsertPage(size_t index, wxWindow* page, const wxString& label, bool selected, const wxBitmap& bmp) { Notebook* b; size_t modindex; size_t bookindex; if(GetBookByPageIndex(index, &b, bookindex, modindex)) { bool res = b->InsertPage(modindex, page, label, selected, bmp); if(res) { m_history->Push(page); } return res; } else { AddPage(page, label, selected, bmp); return true; } }
void Edit::OnModified(wxStyledTextEvent& WXUNUSED(event)) { if (m_modified) { return; } Notebook* notebook = static_cast<Notebook*>(GetParent()); const int page_index = notebook->GetPageIndex(this); if (page_index > -1) { wxString page_text = notebook->GetPageText(page_index); page_text += wxT('*'); notebook->SetPageText(page_index, page_text); m_modified = true; } }
bool clMultiBook::GetBookByPageIndex(size_t pageIndex, Notebook** book, size_t& bookIndex, size_t& modPageIndex) const { std::vector<Notebook*> books = { m_leftBook, m_rightBook }; for(size_t i = 0; i < books.size(); ++i) { Notebook* b = books[i]; if(pageIndex < b->GetPageCount()) { *book = b; bookIndex = i; modPageIndex = pageIndex; return b; } pageIndex -= b->GetPageCount(); } return false; }
int clMultiBook::SetSelection(size_t tabIdx) { Notebook* book; size_t bookIndex; size_t modIndex; if(GetBookByPageIndex(tabIdx, &book, bookIndex, modIndex)) { // Update the current selection bool pageChanged = (m_selection != (int)tabIdx); // Grab a pointer of the page we want to make active wxWindow* focusedPage = book->GetPage(modIndex); // And perform the actual selection change int oldSelection = book->GetSelection(); if(oldSelection != (int)modIndex) { m_selection = tabIdx; m_history->Pop(focusedPage); m_history->Push(focusedPage); return book->SetSelection(modIndex); } else { // There is no point on calling Notebook::SetSelection since it is already selected // However, in the term of 'multi book' control, we might need to generate the events ourselves here // But only if we actually modified the selection if(pageChanged) { wxBookCtrlEvent changingEvent(wxEVT_BOOK_PAGE_CHANGING); changingEvent.SetEventObject(this); changingEvent.SetOldSelection(m_selection); changingEvent.SetSelection(tabIdx); GetEventHandler()->ProcessEvent(changingEvent); if(!changingEvent.IsAllowed()) { return wxNOT_FOUND; } // User vetoed // Update the history m_history->Pop(focusedPage); m_history->Push(focusedPage); // Update the selection before we fire the event again // Or we might end up with stackoverflow... m_selection = tabIdx; wxBookCtrlEvent changedEvent(wxEVT_BOOK_PAGE_CHANGED); changedEvent.SetEventObject(this); changedEvent.SetOldSelection(m_selection); changedEvent.SetSelection(tabIdx); GetEventHandler()->ProcessEvent(changedEvent); } } } return wxNOT_FOUND; }
bool clMultiBook::DeletePage(size_t page, bool notify) { Notebook* book; size_t modIndex; size_t bookIndex; if(!GetBookByPageIndex(page, &book, bookIndex, modIndex)) { return false; } // Update the history wxWindow* pageToDelete = book->GetPage(modIndex); m_history->Pop(pageToDelete); // Delete the page bool res = book->DeletePage(modIndex, notify); UpdateView(); return res; }
void SvnConsole::EnsureVisible() { // Ensure that the Output View is displayed wxAuiPaneInfo& pi = m_plugin->GetManager()->GetDockingManager()->GetPane("Output View"); if ( pi.IsOk() && !pi.IsShown() ) { pi.Show( true ); m_plugin->GetManager()->GetDockingManager()->Update(); } Notebook* book = m_plugin->GetManager()->GetOutputPaneNotebook(); for(size_t i=0; i<book->GetPageCount(); i++) { if(this == book->GetPage(i)) { book->SetSelection(i); break; } } }
DatabaseExplorer::DatabaseExplorer(IManager* manager) : IPlugin(manager) { // create tab (possibly detached) Notebook* book = m_mgr->GetWorkspacePaneNotebook(); wxWindow* editorBook = m_mgr->GetEditorPaneNotebook(); EventNotifier::Get()->Connect(wxEVT_TREE_ITEM_FILE_ACTIVATED, clCommandEventHandler(DatabaseExplorer::OnOpenWithDBE), NULL, this); EventNotifier::Get()->Bind(wxEVT_SHOW_WORKSPACE_TAB, &DatabaseExplorer::OnToggleTab, this); if(IsDbViewDetached()) { DockablePane* cp = new DockablePane(book->GetParent()->GetParent(), book, _("DbExplorer"), false, wxNullBitmap, wxSize(200, 200)); m_dbViewerPanel = new DbViewerPanel(cp, editorBook, m_mgr); cp->SetChildNoReparent(m_dbViewerPanel); } else { m_dbViewerPanel = new DbViewerPanel(book, editorBook, m_mgr); // size_t index = GetSettings().GetSvnTabIndex(); // if(index == Notebook::npos) book->AddPage(m_dbViewerPanel, _("DbExplorer"), false); // else // book->InsertPage(index, m_dbViewerPanel, svnCONSOLE_TEXT, false); } m_mgr->AddWorkspaceTab(_("DbExplorer")); // configure autolayout algorithns wxSFAutoLayout layout; wxSFLayoutHorizontalTree* pHTreeAlg = wxDynamicCast(layout.GetAlgorithm(wxT("Horizontal Tree")), wxSFLayoutHorizontalTree); if(pHTreeAlg) pHTreeAlg->SetHSpace(200); wxSFLayoutVerticalTree* pVTreeAlg = wxDynamicCast(layout.GetAlgorithm(wxT("Vertical Tree")), wxSFLayoutVerticalTree); if(pVTreeAlg) pVTreeAlg->SetVSpace(75); m_longName = _("DatabaseExplorer for CodeLite"); m_shortName = wxT("DatabaseExplorer"); clKeyboardManager::Get()->AddGlobalAccelerator("wxEVT_EXECUTE_SQL", "Ctrl-J", _("Execute SQL")); wxTheApp->Bind(wxEVT_MENU, &DatabaseExplorer::OnExecuteSQL, this, XRCID("wxEVT_EXECUTE_SQL")); }
void WorkspaceTab::OnActiveEditorChanged(wxCommandEvent& e) { e.Skip(); if(m_isLinkedToEditor) { MainBook* mainbook = clMainFrame::Get()->GetMainBook(); LEditor* editor = mainbook->GetActiveEditor(); if(editor && !editor->GetProject().IsEmpty()) { m_fileView->ExpandToPath(editor->GetProject(), editor->GetFileName()); } Notebook* book = clMainFrame::Get()->GetWorkspacePane()->GetNotebook(); if(book) { size_t index = book->GetPageIndex("wxCrafter"); if(index == (size_t)book->GetSelection()) { book->SetSelection(0); // The most likely to be wanted } } } }
bool Edit::SaveFile(const wxString &filename) { // return if no change if (!Modified()) return true; if (m_modified) { Notebook* notebook = static_cast<Notebook*>(GetParent()); const int page_index = notebook->GetPageIndex(this); if (page_index > -1) { wxString page_text = notebook->GetPageText(page_index); if (page_text.EndsWith(wxT('*'))) { page_text.RemoveLast(); notebook->SetPageText(page_index, page_text); } m_modified = false; } } return wxStyledTextCtrl::SaveFile(filename); }
CMakePlugin::CMakePlugin(IManager* manager) : IPlugin(manager) , m_configuration(NULL) , m_cmake(NULL) , m_settingsManager(new CMakeSettingsManager(this)) , m_panel(NULL) { m_longName = _("CMake integration with CodeLite"); m_shortName = "CMakePlugin"; // Create CMake configuration file m_configuration.reset(new CMakeConfiguration(clStandardPaths::Get().GetUserDataDir() + wxFileName::GetPathSeparator() + "config/cmake.ini")); // Create cmake application m_cmake.reset(new CMake(m_configuration->GetProgramPath())); Notebook* book = m_mgr->GetWorkspacePaneNotebook(); cmakeImages images; const wxBitmap& bmp = images.Bitmap("cmake_16"); if(IsPaneDetached()) { DockablePane* cp = new DockablePane(book->GetParent()->GetParent(), book, HELP_TAB_NAME, bmp, wxSize(200, 200)); m_helpTab = new CMakeHelpTab(cp, this); cp->SetChildNoReparent(m_helpTab); } else { m_helpTab = new CMakeHelpTab(book, this); book->AddPage(m_helpTab, HELP_TAB_NAME, false, bmp); m_mgr->AddWorkspaceTab(HELP_TAB_NAME); } // Bind events EventNotifier::Get()->Bind( wxEVT_CMD_PROJ_SETTINGS_SAVED, clProjectSettingsEventHandler(CMakePlugin::OnSaveConfig), this); EventNotifier::Get()->Bind(wxEVT_GET_PROJECT_BUILD_CMD, clBuildEventHandler(CMakePlugin::OnGetBuildCommand), this); EventNotifier::Get()->Bind(wxEVT_GET_PROJECT_CLEAN_CMD, clBuildEventHandler(CMakePlugin::OnGetCleanCommand), this); EventNotifier::Get()->Bind( wxEVT_GET_IS_PLUGIN_MAKEFILE, clBuildEventHandler(CMakePlugin::OnGetIsPluginMakefile), this); EventNotifier::Get()->Bind(wxEVT_PLUGIN_EXPORT_MAKEFILE, clBuildEventHandler(CMakePlugin::OnExportMakefile), this); EventNotifier::Get()->Bind(wxEVT_WORKSPACE_LOADED, wxCommandEventHandler(CMakePlugin::OnWorkspaceLoaded), this); EventNotifier::Get()->Bind(wxEVT_SHOW_WORKSPACE_TAB, &CMakePlugin::OnToggleHelpTab, this); }
SymbolViewPlugin::SymbolViewPlugin(IManager *manager) : IPlugin(manager) { m_longName = _("Outline Plugin"); m_shortName = wxT("Outline"); OutlineSettings os; os.Load(); Notebook *book = m_mgr->GetWorkspacePaneNotebook(); if( IsPaneDetached() ) { // Make the window child of the main panel (which is the grand parent of the notebook) DockablePane *cp = new DockablePane(book->GetParent()->GetParent(), book, _("Outline"), wxNullBitmap, wxSize(200, 200)); m_view = new OutlineTab(cp, m_mgr); cp->SetChildNoReparent(m_view); } else { m_view = new OutlineTab(book, m_mgr); book->AddPage(m_view, _("Outline"), false); } }
bool clMultiBook::RemovePage(size_t page, bool notify) { Notebook* book; size_t bookIndex; size_t modIndex; if(GetBookByPageIndex(page, &book, bookIndex, modIndex)) { // Make sure that after we remove the page from its notebook // it has a valid parent (UpdateView() below might destory its parent // Notebook control) wxWindow* removedPage = book->GetPage(modIndex); // Update the history m_history->Pop(removedPage); removedPage->Reparent(this); bool res = book->RemovePage(modIndex, notify); UpdateView(); return res; } return false; }
/** * Ensure that the CppCheck tab is visible */ void CppCheckPlugin::SetTabVisible(bool clearContent) { // Make sure that the Output pane is visible wxAuiManager *aui = m_mgr->GetDockingManager(); if (aui) { wxAuiPaneInfo &info = aui->GetPane(wxT("Output View")); if (info.IsOk() && !info.IsShown()) { info.Show(); aui->Update(); } } // Set the focus to the CppCheck tab Notebook *book = m_mgr->GetOutputPaneNotebook(); if (book->GetPageText((size_t)book->GetSelection()) != wxT("CppCheck")) { for (size_t i=0; i<book->GetPageCount(); i++) { if (book->GetPageText(i) == wxT("CppCheck")) { book->SetSelection(i); break; } } } // clear the view contents if ( clearContent ) { m_view->Clear(); m_fileCount = m_filelist.GetCount(); m_fileProcessed = 1; } }