void wxSTEditorTreeCtrl::SetSTENotebook(wxSTEditorNotebook* notebook) { if (m_steNotebook != NULL) { m_steNotebook->Disconnect(wxID_ANY, wxEVT_DESTROY, wxWindowDestroyEventHandler(wxSTEditorTreeCtrl::OnWindowDestroy), NULL, this); m_steNotebook->Disconnect(wxID_ANY, wxEVT_STNOTEBOOK_PAGE_CHANGED, wxNotebookEventHandler(wxSTEditorTreeCtrl::OnNotebookPageChanged), NULL, this); m_steNotebook->Disconnect(wxID_ANY, wxEVT_STEDITOR_STATE_CHANGED, wxSTEditorEventHandler(wxSTEditorTreeCtrl::OnSTEState), NULL, this); } m_steNotebook = notebook; DeleteAllItems(); m_windowToSTETreeItemDataMap.clear(); if (m_steNotebook != NULL) { UpdateFromNotebook(); m_steNotebook->Connect(wxID_ANY, wxEVT_DESTROY, wxWindowDestroyEventHandler(wxSTEditorTreeCtrl::OnWindowDestroy), NULL, this); m_steNotebook->Connect(wxID_ANY, wxEVT_STNOTEBOOK_PAGE_CHANGED, wxNotebookEventHandler(wxSTEditorTreeCtrl::OnNotebookPageChanged), NULL, this); m_steNotebook->Connect(wxID_ANY, wxEVT_STEDITOR_STATE_CHANGED, wxSTEditorEventHandler(wxSTEditorTreeCtrl::OnSTEState), NULL, this); } }
void wxStEditApp::CreateShell() { wxDialog dialog(m_frame, wxID_ANY, wxT("wxSTEditorShell"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE_RESIZE); wxSTEditorShell* shell = new wxSTEditorShell(&dialog, wxID_ANY); // Set the styles and langs to those of the frame (not necessary, but nice) // The prefs aren't shared since we want to control the look and feel. wxSTEditorPrefs prefs(true); prefs.SetPrefInt(STE_PREF_INDENT_GUIDES, 0); prefs.SetPrefInt(STE_PREF_EDGE_MODE, wxSTC_EDGE_NONE); prefs.SetPrefInt(STE_PREF_VIEW_LINEMARGIN, 0); prefs.SetPrefInt(STE_PREF_VIEW_MARKERMARGIN, 1); prefs.SetPrefInt(STE_PREF_VIEW_FOLDMARGIN, 0); shell->RegisterPrefs(prefs); shell->RegisterStyles(m_frame->GetOptions().GetEditorStyles()); shell->RegisterLangs(m_frame->GetOptions().GetEditorLangs()); shell->SetLanguage(STE_LANG_PYTHON); // arbitrarily set to python shell->BeginWriteable(); shell->AppendText(_("Welcome to a test of the wxSTEditorShell.\n\n")); shell->AppendText(_("This simple test merely responds to the wxEVT_STESHELL_ENTER\n")); shell->AppendText(_("events and prints the contents of the line when you press enter.\n\n")); shell->AppendText(_("For demo purposes, the shell understands these simple commands.\n")); shell->AppendText(_(" SetMaxHistoryLines num : set the number of lines in history buffer\n")); shell->AppendText(_(" SetMaxLines num [overflow=2000] : set the number of lines displayed\n")); shell->AppendText(_(" and optionally the number of lines to overflow before deleting\n")); shell->AppendText(_(" Quit : quit the wxSTEditorShell demo\n")); shell->CheckPrompt(true); // add prompt shell->EndWriteable(); shell->Connect(wxID_ANY, wxEVT_STESHELL_ENTER, wxSTEditorEventHandler(wxStEditApp::OnSTEShellEvent), NULL, this); int width = shell->TextWidth(wxSTC_STYLE_DEFAULT, wxT(" SetMaxHistoryLines num : set the number of lines in history buffer ")); dialog.SetSize(width + 30, wxDefaultCoord); wxBoxSizer *topSizer = new wxBoxSizer( wxVERTICAL ); topSizer->Add(shell, 1, wxEXPAND); dialog.SetSizer(topSizer); dialog.ShowModal(); }