X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/13c21be5eb535c82e53bc64f3a65da1477bbf47a..e5f741e5d467b1ce7105be96e9f3dcb553e8b89d:/src/stubs/textctrl.cpp diff --git a/src/stubs/textctrl.cpp b/src/stubs/textctrl.cpp index a9ede8a5a4..cb3d68aad0 100644 --- a/src/stubs/textctrl.cpp +++ b/src/stubs/textctrl.cpp @@ -30,13 +30,22 @@ #endif #endif -#if !USE_SHARED_LIBRARY 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 // Text item wxTextCtrl::wxTextCtrl() @@ -267,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()); @@ -441,3 +505,52 @@ wxTextCtrl& wxTextCtrl::operator<<(const char c) 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() ); +}