void wxSTEditorTreeCtrl::OnSTEState(wxSTEditorEvent &event) { event.Skip(); if ( event.HasStateChange(STE_FILENAME | STE_MODIFIED | STE_EDITABLE) ) UpdateFromNotebook(); }
void wxStEditApp::OnSTEShellEvent(wxSTEditorEvent& event) { // handle the event and for this example we just write it back wxSTEditorShell* shell = wxDynamicCast(event.GetEventObject(), wxSTEditorShell); wxString val = event.GetString(); shell->AppendText(_("\nText Entered : '") + val + wxT("'\n")); // very simple mechanism to parse the line to do things, you may prefer // using wxPython or wxLua and running the string as is. wxString token(val.BeforeFirst(wxT(' ')).Lower()); if (val.Lower().Strip(wxString::both) == wxT("quit")) { wxCommandEvent quitEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK); event.SetEventObject(shell); shell->GetEventHandler()->ProcessEvent(quitEvent); } else if (token == wxT("setmaxhistorylines")) { wxString num = val.AfterFirst(wxT(' ')); long n = 0; if (num.ToLong(&n)) { shell->SetMaxHistoryLines(n); shell->AppendText(wxString::Format(_("The maximum number of history lines is set to %d.\n"), n)); } else shell->AppendText(_("ERR: Expected number, eg. SetMaxHistoryLines 10\n")); } else if (token == wxT("setmaxlines")) { wxString num1 = val.AfterFirst(wxT(' ')).Strip(wxString::both); wxString num2 = num1.AfterFirst(wxT(' ')).Strip(wxString::both); num1 = num1.BeforeFirst(wxT(' ')).Strip(wxString::both); long n1 = 0, n2 = 2000; if (num1.ToLong(&n1) && (num2.IsEmpty() || num2.ToLong(&n2))) { shell->SetMaxLines(n1, n2); shell->AppendText(wxString::Format(_("The maximum number of displayed lines is set to\n %d with an overflow of %d lines before deleting up to max lines.\n"), n1, n2)); } else shell->AppendText(_("ERR: Expected number, eg. SetMaxLines 10 [2000]\n")); } shell->CheckPrompt(true); }
void wxSTEditorTreeCtrl::OnSTEState(wxSTEditorEvent &event) { event.Skip(); if ( event.HasStateChange(STE_MODIFIED) && (event.GetEditor() != NULL) && (event.GetEditor()->GetTreeItemData() != NULL) && (event.GetEditor()->GetTreeItemData()->m_id)) { SetItemTextColour(event.GetEditor()->GetTreeItemData()->m_id, event.GetEditor()->IsModified() ? *wxRED : *wxBLACK); } else if ( event.HasStateChange(STE_FILENAME | STE_MODIFIED | STE_EDITABLE) ) UpdateFromNotebook(); }
void wxSTEditorNotebook::OnSTEState(wxSTEditorEvent &event) { event.Skip(true); wxSTEditor *editor = event.GetEditor(); if ( event.HasStateChange(STE_FILENAME | STE_MODIFIED) ) { if (GetOptions().HasNotebookOption(STN_UPDATE_TITLES)) { int page = FindEditorPage(editor); if (page >= 0) // if < 0 then not in notebook (or at least yet) { SetPageText(page, FileNameToTabName(editor)); SortTabs(GetOptions().GetNotebookOptions()); } } } if (event.HasStateChange(STE_FILENAME | STE_MODIFIED | STE_CANSAVE)) { UpdateAllItems(); } }
void wxSTEditorFrame::OnSTEState(wxSTEditorEvent &event) { event.Skip(); wxSTEditor *editor = event.GetEditor(); if ( event.HasStateChange(STE_FILENAME | STE_MODIFIED | STE_EDITABLE) ) { if (wxDynamicCast(editor, wxSTEditorFindResultsEditor) == NULL) { wxString title = MakeTitle(editor); if (GetTitle() != title) SetTitle(title); } if (event.HasStateChange(STE_FILENAME) && GetOptions().GetFileHistory()) { if (wxFileExists(event.GetString())) GetOptions().GetFileHistory()->AddFileToHistory( event.GetString() ); } } }
void wxSTEditorFrame::OnSTEPopupMenu(wxSTEditorEvent &event) { event.Skip(); wxSTEditor *editor = event.GetEditor(); UpdateItems(editor->GetOptions().GetEditorPopupMenu()); }