X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/93cf77c076b699e8e0b3b0049bd4f80de15997dd..80a24267cbc17d85e278e1f10cdfdaea12199639:/src/stubs/textctrl.cpp diff --git a/src/stubs/textctrl.cpp b/src/stubs/textctrl.cpp index fb522df053..cb3d68aad0 100644 --- a/src/stubs/textctrl.cpp +++ b/src/stubs/textctrl.cpp @@ -19,6 +19,8 @@ #include "wx/textctrl.h" #include "wx/settings.h" +#include "wx/filefn.h" +#include "wx/utils.h" #if defined(__BORLANDC__) && !defined(__WIN32__) #include @@ -28,15 +30,22 @@ #endif #endif -#if !USE_SHARED_LIBRARY IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl, wxControl) BEGIN_EVENT_TABLE(wxTextCtrl, wxControl) - EVT_CHAR(wxTextCtrl::OnChar) EVT_DROP_FILES(wxTextCtrl::OnDropFiles) - EVT_ERASE_BACKGROUND(wxTextCtrl::OnEraseBackground) + 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 // Text item wxTextCtrl::wxTextCtrl() @@ -132,7 +141,6 @@ long wxTextCtrl::GetLastPosition() const void wxTextCtrl::Replace(long from, long to, const wxString& value) { // TODO - return 0; } void wxTextCtrl::Remove(long from, long to) @@ -212,6 +220,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 @@ -263,10 +276,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()); @@ -337,7 +405,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; } @@ -391,7 +459,7 @@ int wxTextCtrl::underflow() wxTextCtrl& wxTextCtrl::operator<<(const wxString& s) { - WriteText(s); + AppendText(s); return *this; } @@ -399,7 +467,7 @@ wxTextCtrl& wxTextCtrl::operator<<(float f) { wxString str; str.Printf("%.2f", f); - WriteText(str); + AppendText(str); return *this; } @@ -407,7 +475,7 @@ wxTextCtrl& wxTextCtrl::operator<<(double d) { wxString str; str.Printf("%.2f", d); - WriteText(str); + AppendText(str); return *this; } @@ -415,7 +483,7 @@ wxTextCtrl& wxTextCtrl::operator<<(int i) { wxString str; str.Printf("%d", i); - WriteText(str); + AppendText(str); return *this; } @@ -423,7 +491,7 @@ wxTextCtrl& wxTextCtrl::operator<<(long i) { wxString str; str.Printf("%ld", i); - WriteText(str); + AppendText(str); return *this; } @@ -433,7 +501,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() ); +}