X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/53ee60908a7b7dcd6d5e6bd4fa3cf606b60ea20c..bc07ab17bf5370f452e899128bf89cc7ca7b98f0:/include/wx/textctrl.h diff --git a/include/wx/textctrl.h b/include/wx/textctrl.h index 5a0d79ce65..fd6ad89317 100644 --- a/include/wx/textctrl.h +++ b/include/wx/textctrl.h @@ -73,10 +73,6 @@ const wxTextCoord wxInvalidTextCoord = -2; // wxTextCtrl style flags // ---------------------------------------------------------------------------- -// the flag bit 0x0001 s free but should be used only for the things which -// don't make sense for a text control used by wxTextEntryDialog because they -// would otherwise conflict with wxOK, wxCANCEL, wxCENTRE - #define wxTE_NO_VSCROLL 0x0002 #define wxTE_AUTO_SCROLL 0x0008 @@ -132,6 +128,12 @@ const wxTextCoord wxInvalidTextCoord = -2; #define wxTE_CAPITALIZE 0 #endif +// ---------------------------------------------------------------------------- +// wxTextCtrl file types +// ---------------------------------------------------------------------------- + +#define wxTEXT_TYPE_ANY 0 + // ---------------------------------------------------------------------------- // wxTextCtrl::HitTest return values // ---------------------------------------------------------------------------- @@ -290,13 +292,18 @@ public: // -------- wxTextCtrlBase(){} - ~wxTextCtrlBase(){} + virtual ~wxTextCtrlBase(){} // accessors // --------- virtual wxString GetValue() const = 0; - virtual void SetValue(const wxString& value) = 0; + virtual bool IsEmpty() const { return GetValue().empty(); } + + virtual void SetValue(const wxString& value) + { DoSetValue(value, SetValue_SendEvent); } + virtual void ChangeValue(const wxString& value) + { DoSetValue(value); } virtual wxString GetRange(long from, long to) const; @@ -324,13 +331,24 @@ public: virtual void Replace(long from, long to, const wxString& value) = 0; virtual void Remove(long from, long to) = 0; - // load/save the controls contents from/to the file - virtual bool LoadFile(const wxString& file); - virtual bool SaveFile(const wxString& file = wxEmptyString); + // load/save the control's contents from/to a file + bool LoadFile(const wxString& file, int fileType = wxTEXT_TYPE_ANY) { return DoLoadFile(file, fileType); } + bool SaveFile(const wxString& file = wxEmptyString, int fileType = wxTEXT_TYPE_ANY); + + // implementation for loading/saving + virtual bool DoLoadFile(const wxString& file, int fileType); + virtual bool DoSaveFile(const wxString& file, int fileType); // sets/clears the dirty flag virtual void MarkDirty() = 0; virtual void DiscardEdits() = 0; + void SetModified(bool modified) + { + if ( modified ) + MarkDirty(); + else + DiscardEdits(); + } // set the max number of characters which may be entered in a single line // text control @@ -405,6 +423,9 @@ public: wxTextCtrl& operator<<(double d); wxTextCtrl& operator<<(const wxChar c); + // generate the wxEVT_COMMAND_TEXT_UPDATED event, like SetValue() does + void SendTextUpdatedEvent(); + // do the window-specific processing after processing the update event virtual void DoUpdateWindowUI(wxUpdateUIEvent& event); @@ -416,6 +437,17 @@ protected: int overflow(int i); #endif // wxHAS_TEXT_WINDOW_STREAM + // flags for DoSetValue(): common part of SetValue() and ChangeValue() and + // also used to implement WriteText() in wxMSW + enum + { + SetValue_SendEvent = 1, + SetValue_SelectionOnly = 2 + }; + + virtual void DoSetValue(const wxString& value, int flags = 0) = 0; + + // the name of the last file loaded with LoadFile() which will be used by // SaveFile() by default wxString m_filename; @@ -424,6 +456,7 @@ protected: wxTextAttr m_defaultStyle; DECLARE_NO_COPY_CLASS(wxTextCtrlBase) + DECLARE_ABSTRACT_CLASS(wxTextCtrlBase) }; // ----------------------------------------------------------------------------