X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/7f555861b7e50f335c7b929bb76be38e9ebd69c5..6a2f3103580e9cb1ba3288d6d22982ab546ac7bc:/src/stubs/textctrl.cpp diff --git a/src/stubs/textctrl.cpp b/src/stubs/textctrl.cpp index 6083ace113..720e6082be 100644 --- a/src/stubs/textctrl.cpp +++ b/src/stubs/textctrl.cpp @@ -35,6 +35,17 @@ IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl, wxControl) BEGIN_EVENT_TABLE(wxTextCtrl, wxControl) EVT_DROP_FILES(wxTextCtrl::OnDropFiles) + EVT_MENU(wxID_CUT, wxTextCtrl::OnCut) + EVT_MENU(wxID_COPY, wxTextCtrl::OnCopy) + EVT_MENU(wxID_PASTE, wxTextCtrl::OnPaste) + EVT_MENU(wxID_UNDO, wxTextCtrl::OnUndo) + EVT_MENU(wxID_REDO, wxTextCtrl::OnRedo) + + EVT_UPDATE_UI(wxID_CUT, wxTextCtrl::OnUpdateCut) + EVT_UPDATE_UI(wxID_COPY, wxTextCtrl::OnUpdateCopy) + EVT_UPDATE_UI(wxID_PASTE, wxTextCtrl::OnUpdatePaste) + EVT_UPDATE_UI(wxID_UNDO, wxTextCtrl::OnUpdateUndo) + EVT_UPDATE_UI(wxID_REDO, wxTextCtrl::OnUpdateRedo) END_EVENT_TABLE() #endif @@ -211,6 +222,11 @@ void wxTextCtrl::WriteText(const wxString& text) // TODO write text to control } +void wxTextCtrl::AppendText(const wxString& text) +{ + // TODO append text to control +} + void wxTextCtrl::Clear() { // TODO @@ -262,10 +278,65 @@ wxString wxTextCtrl::GetLineText(long lineNo) const return wxString(""); } -/* - * Text item - */ - +bool wxTextCtrl::CanCopy() const +{ + // Can copy if there's a selection + long from, to; + GetSelection(& from, & to); + return (from != to) ; +} + +bool wxTextCtrl::CanCut() const +{ + // Can cut if there's a selection + long from, to; + GetSelection(& from, & to); + return (from != to) ; +} + +bool wxTextCtrl::CanPaste() const +{ + return IsEditable() ; +} + +// Undo/redo +void wxTextCtrl::Undo() +{ + // TODO +} + +void wxTextCtrl::Redo() +{ + // TODO +} + +bool wxTextCtrl::CanUndo() const +{ + // TODO + return FALSE; +} + +bool wxTextCtrl::CanRedo() const +{ + // TODO + return FALSE; +} + +// If the return values from and to are the same, there is no +// selection. +void wxTextCtrl::GetSelection(long* from, long* to) const +{ + // TODO + *from = 0; + *to = 0; +} + +bool wxTextCtrl::IsEditable() const +{ + // TODO + return FALSE; +} + void wxTextCtrl::Command(wxCommandEvent & event) { SetValue (event.GetString()); @@ -336,7 +407,7 @@ int wxTextCtrl::overflow(int c) txt[plen] = (char)c; // append c txt[plen+xtra] = '\0'; // append '\0' or overwrite c // If the put area already contained \0, output will be truncated there - WriteText(txt); + AppendText(txt); delete[] txt; } @@ -390,7 +461,7 @@ int wxTextCtrl::underflow() wxTextCtrl& wxTextCtrl::operator<<(const wxString& s) { - WriteText(s); + AppendText(s); return *this; } @@ -398,7 +469,7 @@ wxTextCtrl& wxTextCtrl::operator<<(float f) { wxString str; str.Printf("%.2f", f); - WriteText(str); + AppendText(str); return *this; } @@ -406,7 +477,7 @@ wxTextCtrl& wxTextCtrl::operator<<(double d) { wxString str; str.Printf("%.2f", d); - WriteText(str); + AppendText(str); return *this; } @@ -414,7 +485,7 @@ wxTextCtrl& wxTextCtrl::operator<<(int i) { wxString str; str.Printf("%d", i); - WriteText(str); + AppendText(str); return *this; } @@ -422,7 +493,7 @@ wxTextCtrl& wxTextCtrl::operator<<(long i) { wxString str; str.Printf("%ld", i); - WriteText(str); + AppendText(str); return *this; } @@ -432,7 +503,56 @@ wxTextCtrl& wxTextCtrl::operator<<(const char c) buf[0] = c; buf[1] = 0; - WriteText(buf); + AppendText(buf); return *this; } +void wxTextCtrl::OnCut(wxCommandEvent& event) +{ + Cut(); +} + +void wxTextCtrl::OnCopy(wxCommandEvent& event) +{ + Copy(); +} + +void wxTextCtrl::OnPaste(wxCommandEvent& event) +{ + Paste(); +} + +void wxTextCtrl::OnUndo(wxCommandEvent& event) +{ + Undo(); +} + +void wxTextCtrl::OnRedo(wxCommandEvent& event) +{ + Redo(); +} + +void wxTextCtrl::OnUpdateCut(wxUpdateUIEvent& event) +{ + event.Enable( CanCut() ); +} + +void wxTextCtrl::OnUpdateCopy(wxUpdateUIEvent& event) +{ + event.Enable( CanCopy() ); +} + +void wxTextCtrl::OnUpdatePaste(wxUpdateUIEvent& event) +{ + event.Enable( CanPaste() ); +} + +void wxTextCtrl::OnUpdateUndo(wxUpdateUIEvent& event) +{ + event.Enable( CanUndo() ); +} + +void wxTextCtrl::OnUpdateRedo(wxUpdateUIEvent& event) +{ + event.Enable( CanRedo() ); +}