X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a3a4105df6f49ff2e2d351bd76e2a42b7b4da34b..d501d4ef2a58771a495b480ea45fda5e5016211e:/src/common/textcmn.cpp?ds=sidebyside diff --git a/src/common/textcmn.cpp b/src/common/textcmn.cpp index a88d7f210b..6f53679d6b 100644 --- a/src/common/textcmn.cpp +++ b/src/common/textcmn.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////////// -// Name: common/textcmn.cpp +// Name: src/common/textcmn.cpp // Purpose: implementation of platform-independent functions of wxTextCtrl // Author: Julian Smart // Modified by: @@ -20,12 +20,17 @@ #pragma hdrstop #endif +#ifndef WX_PRECOMP + #include "wx/event.h" +#endif // WX_PRECOMP + #if wxUSE_TEXTCTRL +#include "wx/textctrl.h" + #ifndef WX_PRECOMP #include "wx/intl.h" #include "wx/log.h" - #include "wx/textctrl.h" #endif // WX_PRECOMP #include "wx/ffile.h" @@ -49,6 +54,8 @@ DEFINE_EVENT_TYPE(wxEVT_COMMAND_TEXT_ENTER) DEFINE_EVENT_TYPE(wxEVT_COMMAND_TEXT_URL) DEFINE_EVENT_TYPE(wxEVT_COMMAND_TEXT_MAXLEN) +IMPLEMENT_ABSTRACT_CLASS(wxTextCtrlBase, wxControl) + // ---------------------------------------------------------------------------- // style functions - not implemented here // ---------------------------------------------------------------------------- @@ -189,7 +196,7 @@ const wxTextAttr& wxTextCtrlBase::GetDefaultStyle() const // file IO functions // ---------------------------------------------------------------------------- -bool wxTextCtrlBase::LoadFile(const wxString& filename) +bool wxTextCtrlBase::DoLoadFile(const wxString& filename, int WXUNUSED(fileType)) { #if wxUSE_FFILE wxFFile file(filename); @@ -214,7 +221,7 @@ bool wxTextCtrlBase::LoadFile(const wxString& filename) return false; } -bool wxTextCtrlBase::SaveFile(const wxString& filename) +bool wxTextCtrlBase::SaveFile(const wxString& filename, int fileType) { wxString filenameToUse = filename.empty() ? m_filename : filename; if ( filenameToUse.empty() ) @@ -225,16 +232,21 @@ bool wxTextCtrlBase::SaveFile(const wxString& filename) return false; } + return DoSaveFile(filenameToUse, fileType); +} + +bool wxTextCtrlBase::DoSaveFile(const wxString& filename, int WXUNUSED(fileType)) +{ #if wxUSE_FFILE - wxFFile file(filenameToUse, _T("w")); + wxFFile file(filename, _T("w")); if ( file.IsOpened() && file.Write(GetValue()) ) { + // if it worked, save for future calls + m_filename = filename; + // it's not modified any longer DiscardEdits(); - // if it worked, save for future calls - m_filename = filenameToUse; - return true; } #endif // wxUSE_FFILE @@ -513,11 +525,28 @@ wxTextCtrlBase::HitTest(const wxPoint& WXUNUSED(pt), return wxTE_HT_UNKNOWN; } +// ---------------------------------------------------------------------------- +// events +// ---------------------------------------------------------------------------- + +void wxTextCtrlBase::SendTextUpdatedEvent() +{ + wxCommandEvent event(wxEVT_COMMAND_TEXT_UPDATED, GetId()); + + // do not do this as it could be very inefficient if the text control + // contains a lot of text and we're not using ref-counted wxString + // implementation -- instead, event.GetString() will query the control for + // its current text if needed + //event.SetString(GetValue()); + + event.SetEventObject(this); + GetEventHandler()->ProcessEvent(event); +} + #else // !wxUSE_TEXTCTRL // define this one even if !wxUSE_TEXTCTRL because it is also used by other // controls (wxComboBox and wxSpinCtrl) -#include "wx/event.h" DEFINE_EVENT_TYPE(wxEVT_COMMAND_TEXT_UPDATED)