void wxExSampleFrame::OnUpdateUI(wxUpdateUIEvent& event) { switch (event.GetId()) { case wxID_PREVIEW: case wxID_PRINT: event.Enable( (GetListView() != NULL && GetListView()->GetItemCount() > 0) || (GetSTC() != NULL && GetSTC()->GetLength() > 0)); break; } }
void wxExFrame::StatusBarClicked(const wxString& pane) { if (pane == "PaneInfo") { wxExSTC* stc = GetSTC(); if (stc != NULL) { stc->GotoDialog(); } else { wxExListView* lv = GetListView(); if (lv != NULL) lv->GotoDialog(); } } else if (pane == "PaneLexer") { wxExSTC* stc = GetSTC(); if (stc != NULL && wxExLexers::Get()->GetCount() > 0) { wxString lexer = stc->GetLexer().GetDisplayLexer(); if (wxExLexers::Get()->ShowDialog(stc, lexer)) { if (lexer.empty()) { stc->ResetLexer(); } else { stc->SetLexer(lexer); } } } } else if (pane == "PaneFileType") { wxExSTC* stc = GetSTC(); if (stc != NULL) stc->FileTypeMenu(); } else { // Clicking on another field, do nothing. } }
int wxExFrameWithHistory::FindInFilesDialog( int id, bool add_in_files) { if (GetSTC() != NULL) { GetSTC()->GetFindString(); } std::vector<wxExConfigItem> v; v.push_back(wxExConfigItem( wxExFindReplaceData::Get()->GetTextFindWhat(), CONFIG_COMBOBOX, wxEmptyString, true)); if (add_in_files) { v.push_back(wxExConfigItem( m_TextInFiles, CONFIG_COMBOBOX, wxEmptyString, true)); } if (id == ID_TOOL_REPORT_REPLACE) { v.push_back(wxExConfigItem( wxExFindReplaceData::Get()->GetTextReplaceWith(), CONFIG_COMBOBOX)); } v.push_back(wxExConfigItem(wxExFindReplaceData::Get()->GetInfo())); if (wxExConfigDialog(this, v, GetFindInCaption(id)).ShowModal() == wxID_CANCEL) { return wxID_CANCEL; } wxLogStatus( wxExFindReplaceData::Get()->GetFindReplaceInfoText( id == ID_TOOL_REPORT_REPLACE)); return wxID_OK; }
void wxExFrame::OnUpdateUI(wxUpdateUIEvent& event) { switch (event.GetId()) { #if wxUSE_STATUSBAR case ID_UPDATE_STATUS_BAR: { wxExSTC* stc = GetSTC(); if (stc != NULL && stc->HasFocus()) { UpdateStatusBar(stc, "PaneInfo"); UpdateStatusBar(stc, "PaneLexer"); UpdateStatusBar(stc, "PaneFileType"); } else { wxExListView* lv = GetListView(); if (lv != NULL && lv->HasFocus()) { UpdateStatusBar(lv); } } } break; #endif case ID_VIEW_MENUBAR: if (GetMenuBar() != NULL) { event.Check(GetMenuBar()->IsShown()); } else { event.Check(false); } break; #if wxUSE_STATUSBAR case ID_VIEW_STATUSBAR: if (GetStatusBar() != NULL) { event.Check(GetStatusBar()->IsShown()); } else { event.Check(false); } break; #endif default: wxFAIL; break; } }
void wxExFrameWithHistory::OnIdle(wxIdleEvent& event) { event.Skip(); const wxString title(GetTitle()); if (title.empty()) { return; } #ifdef wxExUSE_CPP0X auto* stc = GetSTC(); auto* project = GetProject(); #else wxExSTC* stc = GetSTC(); wxExListViewFile* project = GetProject(); #endif const wxUniChar indicator('*'); if ((project != NULL && project->GetContentsChanged()) || // using GetContentsChanged gives assert in vcs dialog (stc != NULL && stc->GetModify() && stc->AllowChangeIndicator())) { // Project or editor changed, add indicator if not yet done. if (title.Last() != indicator) { SetTitle(title + " " + indicator); } } else { // Project or editor not changed, remove indicator if not yet done. if (title.Last() == indicator && title.size() > 2) { SetTitle(title.substr(0, title.length() - 2)); } } }
bool wxExFrame::OpenFile( const wxExFileName& filename, int line_number, const wxString& match, int col_number, long flags) { wxExSTC* stc = GetSTC(); if (stc != NULL) { return stc->Open(filename, line_number, match, col_number, flags); } return false; }
bool wxExFrame::OpenFile( const wxString& filename, const wxString& text, long flags) { wxExSTC* stc = GetSTC(); if (stc != NULL) { stc->SetText(text); } else { wxLogMessage(text); } return true; }
bool wxExFrame::OpenFile( const wxExFileName& filename, const wxExVCSEntry& vcs, long flags) { wxExSTC* stc = GetSTC(); if (stc != NULL) { stc->SetText(vcs.GetOutput()); wxExVCSCommandOnSTC( vcs.GetCommand(), filename.GetLexer(), stc); } else { wxLogMessage(vcs.GetOutput()); } return true; }
void wxExSampleFrame::OnCommand(wxCommandEvent& event) { m_Statistics.Inc(wxString::Format("%d", event.GetId())); auto* editor = GetSTC(); auto* grid = GetGrid(); auto* listview = GetListView(); if ( (event.GetId() == wxID_UNDO || event.GetId() == wxID_REDO || event.GetId() == wxID_DELETE || event.GetId() == wxID_SELECTALL || event.GetId() == wxID_JUMP_TO) || (event.GetId() >= wxID_CUT && event.GetId() <= wxID_CLEAR)) { if (editor != NULL) { wxPostEvent(editor, event); } else if (grid != NULL) { wxPostEvent(grid, event); } else if (listview != NULL) { wxPostEvent(listview, event); } } else { switch (event.GetId()) { case wxID_ABOUT: { wxAboutDialogInfo info; info.SetIcon(GetIcon()); info.SetVersion(wxExGetVersionInfo().GetVersionOnlyString()); info.SetCopyright(wxExGetVersionInfo().GetCopyright()); wxAboutBox(info); } break; case wxID_EXIT: Close(true); break; case wxID_OPEN: { wxExFileDialog dlg(this, &m_STC->GetFile()); if (dlg.ShowModalIfChanged(true) == wxID_CANCEL) return; wxStopWatch sw; m_STC->Open(dlg.GetPath(), 0, wxEmptyString, m_FlagsSTC); const auto stop = sw.Time(); wxLogStatus(wxString::Format( "wxExSTC::Open:%ld milliseconds, %d bytes", stop, m_STC->GetTextLength())); } break; case wxID_PREVIEW: m_ListView->PrintPreview(); break; case wxID_PRINT: m_ListView->Print(); break; case wxID_PRINT_SETUP: wxExPrinting::Get()->GetHtmlPrinter()->PageSetup(); break; case wxID_SAVE: m_STC->GetFile().FileSave(); if (m_STC->GetFileName().GetFullPath() == wxExLexers::Get()->GetFileName().GetFullPath()) { wxExLexers::Get()->Read(); wxLogMessage("File contains: %d lexers", wxExLexers::Get()->GetCount()); // As the lexer might have changed, update status bar field as well. #if wxUSE_STATUSBAR UpdateStatusBar(m_STC, "PaneLexer"); #endif } break; case ID_CONFIG_DLG: ShowConfigItems(); break; case ID_CONFIG_DLG_READONLY: { std::vector<wxExConfigItem> v; v.push_back(wxExConfigItem("File Picker", CONFIG_FILEPICKERCTRL)); for (size_t j = 1; j <= 10; j++) { v.push_back(wxExConfigItem(wxString::Format("Integer%d", j), CONFIG_INT)); } wxExConfigDialog* dlg = new wxExConfigDialog( this, v, "Config Dialog Readonly", 0, 1, wxCANCEL); dlg->Show(); } break; case ID_PROCESS_SELECT: wxExProcess::ConfigDialog(this); break; case ID_PROCESS_RUN: m_Process.Execute(wxEmptyString); break; case ID_SHELL_COMMAND: m_STCShell->Prompt("\nHello '" + event.GetString() + "' from the shell"); break; case ID_SHOW_VCS: { wxFileDialog openFileDialog(this, _("Open File"), "", "", "All files (*.*)|*.*", wxFD_OPEN|wxFD_FILE_MUST_EXIST); if (openFileDialog.ShowModal() == wxID_CANCEL) return; // the user changed idea... wxArrayString ar; ar.Add(openFileDialog.GetPath()); wxExVCS vcs(ar); wxLogMessage(vcs.GetName()); if (vcs.GetEntry().SupportKeywordExpansion()) { wxLogMessage("supports keyword expansion"); } } break; case ID_STATISTICS_SHOW: m_Notebook->AddPage(m_Statistics.Show(m_Notebook), "Statistics"); break; case ID_STC_CONFIG_DLG: wxExSTC::ConfigDialog( this, "Editor Options", wxExSTC::STC_CONFIG_MODELESS | wxExSTC::STC_CONFIG_WITH_APPLY); break; case ID_STC_ENTRY_DLG: { wxString text; for (auto i = 0; i < 100; i++) { text += wxString::Format("Hello from line: %d\n", i); } wxExSTCEntryDialog dlg( this, "Hello world", text, "Greetings from " + wxTheApp->GetAppDisplayName()); dlg.ShowModal(); } break; case ID_STC_FLAGS: { long value = wxGetNumberFromUser( "Input:", wxEmptyString, "STC Open Flag", m_FlagsSTC, 0, 0xFFFF); if (value != -1) { m_FlagsSTC = value; } } break; case ID_STC_SPLIT: { wxExSTC* stc = new wxExSTC(*m_STC); m_Notebook->AddPage( stc, wxString::Format("stc%d", stc->GetId()), m_STC->GetFileName().GetFullName()); stc->SetDocPointer(m_STC->GetDocPointer()); } break; default: wxFAIL; break; } } }
void wxExFrame::OnCommand(wxCommandEvent& command) { m_IsCommand = true; switch (command.GetId()) { case wxID_FIND: { if (m_FindReplaceDialog != NULL) { m_FindReplaceDialog->Destroy(); } m_FindFocus = wxWindow::FindFocus(); // If stc text is selected, copy to find replace data. wxExSTC* stc = GetSTC(); if (stc != NULL) { stc->GetFindString(); } m_FindReplaceDialog = new wxFindReplaceDialog( this, wxExFindReplaceData::Get(), _("Find")); m_FindReplaceDialog->Show(); } break; case wxID_REPLACE: { if (m_FindReplaceDialog != NULL) { m_FindReplaceDialog->Destroy(); } m_FindFocus = wxWindow::FindFocus(); // If stc text is selected, copy to find replace data. wxExSTC* stc = GetSTC(); if (stc != NULL) { stc->GetFindString(); } m_FindReplaceDialog = new wxFindReplaceDialog( this, wxExFindReplaceData::Get(), _("Replace"), wxFR_REPLACEDIALOG); m_FindReplaceDialog->Show(); } break; case wxID_OPEN: if (!command.GetString().empty()) { wxExSTC* stc = GetSTC(); if (stc != NULL) { wxSetWorkingDirectory(stc->GetFileName().GetPath()); } wxArrayString files; wxStringTokenizer tkz(command.GetString()); while (tkz.HasMoreTokens()) { files.Add(tkz.GetNextToken()); } wxExOpenFiles(this, files); } else { wxExOpenFilesDialog(this); } break; case ID_VIEW_MENUBAR: if (GetMenuBar() != NULL) { SetMenuBar(NULL); } else { SetMenuBar(m_MenuBar); } break; case ID_VIEW_STATUSBAR: #if wxUSE_STATUSBAR if (GetStatusBar() != NULL) { GetStatusBar()->Show(!GetStatusBar()->IsShown()); SendSizeEvent(); } #endif break; case ID_VIEW_TITLEBAR: if (!(GetWindowStyleFlag() & wxCAPTION)) { SetWindowStyleFlag(wxDEFAULT_FRAME_STYLE); Refresh(); } else { SetWindowStyleFlag(GetWindowStyleFlag() & ~wxCAPTION); Refresh(); } break; default: wxFAIL; break; } }
// Copyright: (c) 2015 Anton van Wezenbeek //////////////////////////////////////////////////////////////////////////////// #include <wx/wxprec.h> #ifndef WX_PRECOMP #include <wx/wx.h> #endif #include <wx/xml/xml.h> #include <wx/extension/variable.h> #include <wx/extension/managedframe.h> #include <wx/extension/stc.h> #include "test.h" TEST_CASE("wxExVariable", "[stc][vi]") { wxExEx* ex = new wxExEx(GetSTC()); for (auto it : std::vector<std::pair<char*, int>> { {"Created", wxExVariable::VARIABLE_BUILTIN}, #ifdef __UNIX__ {"HOME", wxExVariable::VARIABLE_ENVIRONMENT}, #endif {"aa", wxExVariable::VARIABLE_READ}, // {"template", wxExVariable::VARIABLE_TEMPLATE}, {"cc", wxExVariable::VARIABLE_INPUT}, {"dd", wxExVariable::VARIABLE_INPUT_ONCE}, {"ee", wxExVariable::VARIABLE_INPUT_SAVE}}) { wxExVariable v(it.first, "cht.txt", "zzz", it.second, false); INFO( it.first); REQUIRE( v.Expand(ex));
void wxExFrameWithHistory::OnCommand(wxCommandEvent& event) { if (event.GetId() >= wxID_FILE1 && event.GetId() <= wxID_FILE1 + NUMBER_RECENT_FILES) { DoRecent(m_FileHistory, event.GetId() - wxID_FILE1); } else if (event.GetId() >= ID_RECENT_PROJECT_LOWEST && event.GetId() <= ID_RECENT_PROJECT_LOWEST + NUMBER_RECENT_PROJECTS) { DoRecent(m_ProjectHistory, event.GetId() - ID_RECENT_PROJECT_LOWEST, WIN_IS_PROJECT); } else { switch (event.GetId()) { case ID_CLEAR: ClearFileHistory(); break; case ID_FIND_IN_FILES: if (m_FiFDialog == NULL) { CreateDialogs(); } if (GetSTC() != NULL) { if (!GetSTC()->GetFindString().empty()) { m_FiFDialog->Reload(); } } m_FiFDialog->Show(); break; case ID_REPLACE_IN_FILES: if (m_RiFDialog == NULL) { CreateDialogs(); } if (GetSTC() != NULL) { if (!GetSTC()->GetFindString().empty()) { m_RiFDialog->Reload(); } } m_RiFDialog->Show(); break; case ID_PROJECT_SAVE: { wxExListViewFile* project = GetProject(); if (project != NULL) { project->FileSave(); } } break; case ID_TERMINATED_PROCESS: wxBell(); break; default: wxFAIL; } } }