]> git.saurik.com Git - wxWidgets.git/commitdiff
moved DoSetValue() to wxTextCtrlBase instead of having it in almost, but not quite...
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 8 Oct 2006 22:40:14 +0000 (22:40 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 8 Oct 2006 22:40:14 +0000 (22:40 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41754 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

19 files changed:
include/wx/cocoa/textctrl.h
include/wx/gtk/textctrl.h
include/wx/gtk1/textctrl.h
include/wx/mac/carbon/textctrl.h
include/wx/motif/textctrl.h
include/wx/msw/textctrl.h
include/wx/os2/textctrl.h
include/wx/palmos/textctrl.h
include/wx/textctrl.h
include/wx/univ/textctrl.h
include/wx/x11/textctrl.h
src/cocoa/textctrl.mm
src/common/textcmn.cpp
src/gtk/textctrl.cpp
src/mac/carbon/textctrl.cpp
src/motif/textctrl.cpp
src/palmos/textctrl.cpp
src/univ/textctrl.cpp
src/x11/textctrl.cpp

index f6ea42dd6e2bb02dbd9fed91e839e756bfaed52a..79d49c74de8e310ef1cc99be85cd633aa1cfd245 100644 (file)
@@ -55,9 +55,6 @@ protected:
 // ------------------------------------------------------------------------
 public:
     virtual wxString GetValue() const;
-    virtual void SetValue(const wxString& value);
-
-    virtual void ChangeValue(const wxString &value);
 
     virtual int GetLineLength(long lineNo) const;
     virtual wxString GetLineText(long lineNo) const;
@@ -118,6 +115,8 @@ public:
 
 protected:
     virtual wxSize DoGetBestSize() const;
+
+    virtual void DoSetValue(const wxString& value, int flags = 0);
 };
 
 #endif // __WX_COCOA_TEXTCTRL_H__
index 017116609f8a3e85057132d63bc880e53913b6ee..8cf1c6957083b4359b7153c62201f4f78c9828d7 100644 (file)
@@ -44,8 +44,6 @@ public:
 
     virtual wxString GetValue() const;
     virtual bool IsEmpty() const;
-    virtual void SetValue(const wxString& value) { DoSetValue(value, SetValue_SendEvent); }
-    virtual void ChangeValue(const wxString& value) { DoSetValue(value); }
 
     virtual int GetLineLength(long lineNo) const;
     virtual wxString GetLineText(long lineNo) const;
@@ -191,7 +189,7 @@ protected:
     // has the control been frozen by Freeze()?
     bool IsFrozen() const { return m_frozenness > 0; }
 
-    void DoSetValue(const wxString &value, int flags = 0);
+    virtual void DoSetValue(const wxString &value, int flags = 0);
 
 private:
     // change the font for everything in this control
index 8c8f3dec0702e211e31ca62b1bbfbbd4ae4f1d39..f42b1b8193ab740096b3203466e2d92edea84118 100644 (file)
@@ -43,9 +43,6 @@ public:
     // ----------------------------------
 
     virtual wxString GetValue() const;
-    virtual void SetValue(const wxString& value) { DoSetValue(value, SetValue_SendEvent); }
-
-    virtual void ChangeValue(const wxString &value) { DoSetValue(value); }
 
     virtual int GetLineLength(long lineNo) const;
     virtual wxString GetLineText(long lineNo) const;
@@ -184,7 +181,7 @@ protected:
     // override this and return true.
     virtual bool UseGTKStyleBase() const { return true; }
 
-    void DoSetValue(const wxString &value, int flags = 0);
+    virtual void DoSetValue(const wxString &value, int flags = 0);
 
 private:
     // change the font for everything in this control
index f77e41423a1ddfc0f269c42626e89f32bf6333d1..1818f2d602a97883587a7196d2f8781168ac464f 100644 (file)
@@ -61,9 +61,6 @@ public:
     // accessors
     // ---------
     virtual wxString GetValue() const;
-    virtual void SetValue(const wxString& value);
-
-    virtual void ChangeValue(const wxString &value);
 
     virtual int GetLineLength(long lineNo) const;
     virtual wxString GetLineText(long lineNo) const;
@@ -187,13 +184,15 @@ public:
 
     wxMacTextControl * GetPeer() const
     { return (wxMacTextControl*) m_peer; }
-    
+
 protected:
     // common part of all ctors
     void Init();
 
     virtual wxSize DoGetBestSize() const;
 
+    virtual void DoSetValue(const wxString& value, int flags = 0);
+
     bool  m_editable;
 
     // flag is set to true when the user edits the controls contents
@@ -201,17 +200,17 @@ protected:
 
   // need to make this public because of the current implementation via callbacks
     unsigned long  m_maxLength;
-    
-    bool GetTriggerOnSetValue() const 
-    { 
-        return m_triggerOnSetValue; 
+
+    bool GetTriggerOnSetValue() const
+    {
+        return m_triggerOnSetValue;
     }
-    
-    void SetTriggerOnSetValue(bool trigger) 
-    { 
-        m_triggerOnSetValue = trigger; 
+
+    void SetTriggerOnSetValue(bool trigger)
+    {
+        m_triggerOnSetValue = trigger;
     }
-    
+
     bool m_triggerOnSetValue ;
 
 private :
index 3fdfa7ee3164019db5fbf2cc55cd39b9d24fe19b..22b8f50eebc7985b7137ad0f26fb497dfe9a92e1 100644 (file)
@@ -43,10 +43,6 @@ public:
     // accessors
     // ---------
     virtual wxString GetValue() const;
-    virtual void SetValue(const wxString& value)
-        { ChangeValue(value); SendTextUpdatedEvent(); }
-
-    virtual void ChangeValue(const wxString &value);
 
     virtual int GetLineLength(long lineNo) const;
     virtual wxString GetLineText(long lineNo) const;
@@ -130,6 +126,9 @@ protected:
     wxString  m_fileName;
 
     virtual wxSize DoGetBestSize() const;
+
+    virtual void DoSetValue(const wxString& value, int flags = 0);
+
 public:
     // Motif-specific
     void*     m_tempCallbackStruct;
index 8649f1491e05f20879c628026cd48a9e6e59ec21..028032725d76cadd59244c7e75e7395754e0ffa5 100644 (file)
@@ -46,8 +46,6 @@ public:
 
     virtual wxString GetValue() const;
     virtual bool IsEmpty() const;
-    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;
 
@@ -209,7 +207,7 @@ protected:
     // common part of all ctors
     void Init();
 
-    void DoSetValue(const wxString &value, int flags = 0);
+    virtual void DoSetValue(const wxString &value, int flags = 0);
 
     // return true if this control has a user-set limit on amount of text (i.e.
     // the limit is due to a previous call to SetMaxLength() and not built in)
index e6197dd8fd74afe182829cdb0c3f2e80334d9544..c868ddc7ae41a05192bb09badb7283468a4aaf5d 100644 (file)
@@ -47,9 +47,6 @@ public:
     // ----------------------------------
     //
     virtual      wxString GetValue(void) const;
-    virtual void SetValue(const wxString& value) { DoSetValue(value, SetValue_SendEvent); }
-
-    virtual void ChangeValue(const wxString &value) { DoSetValue(value); }
 
     virtual int      GetLineLength(long nLineNo) const;
     virtual wxString GetLineText(long nLineNo) const;
@@ -183,7 +180,7 @@ protected:
                                 ,WXDWORD* dwExstyle
                                ) const;
 
-    void DoSetValue(const wxString &value, int flags = 0);
+    virtual void DoSetValue(const wxString &value, int flags = 0);
 
     bool m_bSkipUpdate;
 
index bfb5c9b663bfae7dbc85f7616b3214274254cd89..98d73a6be238a198e5394c31f0c36647baea5977 100644 (file)
@@ -45,9 +45,6 @@ public:
     // ----------------------------------
 
     virtual wxString GetValue() const;
-    virtual void SetValue(const wxString& value);
-
-    virtual void ChangeValue(const wxString &value);
 
     virtual int GetLineLength(long lineNo) const;
     virtual wxString GetLineText(long lineNo) const;
@@ -181,6 +178,9 @@ protected:
     // common part of all ctors
     void Init();
 
+    virtual void DoSetValue(const wxString& value, int flags = 0);
+
+
     // intercept WM_GETDLGCODE
     virtual WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
 
index 39908a03bf3fb287002d3d9d7f9a8bff5e8f31ad..fd6ad893171f9f91e4b3572c7ae854c93853505c 100644 (file)
@@ -298,11 +298,12 @@ public:
     // ---------
 
     virtual wxString GetValue() const = 0;
-    virtual void SetValue(const wxString& value) = 0;
-
     virtual bool IsEmpty() const { return GetValue().empty(); }
 
-    virtual void ChangeValue(const wxString &value) = 0;
+    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;
 
@@ -422,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);
 
@@ -433,17 +437,16 @@ protected:
     int overflow(int i);
 #endif // wxHAS_TEXT_WINDOW_STREAM
 
-    // typically, wxTextCtrl classes will use a DoSetValue() function to
-    // implement both SetValue() and ChangeValue() functions and these
-    // flags are meant to be passed to such DoSetValue()
+    // flags for DoSetValue(): common part of SetValue() and ChangeValue() and
+    // also used to implement WriteText() in wxMSW
     enum
     {
         SetValue_SendEvent = 1,
         SetValue_SelectionOnly = 2
     };
 
-    // generate the wxEVT_COMMAND_TEXT_UPDATED event
-    void SendTextUpdatedEvent();
+    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
index 2ec12ca172a505c7ae8e04f986291fe7fd872bb9..44cfaa4b46130e7c8614c3ecf00b759060bfaf6d 100644 (file)
@@ -105,9 +105,6 @@ public:
     // ----------------------------------
 
     virtual wxString GetValue() const;
-    virtual void SetValue(const wxString& value);
-
-    virtual void ChangeValue(const wxString &value);
 
     virtual int GetLineLength(wxTextCoord lineNo) const;
     virtual wxString GetLineText(wxTextCoord lineNo) const;
@@ -262,6 +259,9 @@ protected:
     // calc the size from the text extent
     virtual wxSize DoGetBestClientSize() const;
 
+    // implements Set/ChangeValue()
+    virtual void DoSetValue(const wxString& value, int flags = 0);
+
     // common part of all ctors
     void Init();
 
index f201439b0721fbecb0de6e15d76f3042d100dad4..97cbf589717f8df8da8ba921c5b9d630d8c4b355 100644 (file)
@@ -116,10 +116,6 @@ public:
     // implement base class pure virtuals
     // ----------------------------------
 
-    virtual wxString GetValue() const;
-    virtual void SetValue(const wxString& value)
-        { ChangeValue(value); SendTextUpdatedEvent(); }
-
     virtual void ChangeValue(const wxString &value);
 
     virtual int GetLineLength(long lineNo) const;
@@ -132,10 +128,6 @@ public:
     // more readable flag testing methods
     // ----------------------------------
 
-#if 0
-    // it seems now in wxTextCtrlBase
-    bool IsSingleLine() const { return !(GetWindowStyle() & wxTE_MULTILINE); }
-#endif
     bool IsPassword() const { return (GetWindowStyle() & wxTE_PASSWORD) != 0; }
     bool WrapLines() const { return false; }
 
@@ -274,6 +266,8 @@ protected:
 
     virtual wxSize DoGetBestSize() const;
 
+    virtual void DoSetValue(const wxString& value, int flags = 0);
+
     friend class wxSourceUndoStep;
 
     wxSourceLineArray  m_lines;
index ba2bc6060de3214e847898a7a1b771f51aeacb83..d755334440dc98d2d1744b34a50c3e8cc6e77e49 100644 (file)
@@ -135,10 +135,13 @@ void wxTextCtrl::Replace(long, long, wxString const&)
 {
 }
 
-void wxTextCtrl::SetValue(wxString const& value)
+void wxTextCtrl::DoSetValue(wxString const& value, int flags)
 {
     wxAutoNSAutoreleasePool pool;
     [GetNSTextField() setStringValue: wxNSStringWithWxString(value)];
+
+    if ( flags & SetValue_SendEvent )
+        SendTextUpdatedEvent();
 }
 
 void wxTextCtrl::WriteText(wxString const&)
index 8722f3ba0c774de2cf40923a98f43e00fbb9fff3..6f53679d6b3377592efe2ec47bd48be70028d362 100644 (file)
@@ -243,7 +243,7 @@ bool wxTextCtrlBase::DoSaveFile(const wxString& filename, int WXUNUSED(fileType)
     {
         // if it worked, save for future calls
         m_filename = filename;
-        
+
         // it's not modified any longer
         DiscardEdits();
 
@@ -525,6 +525,24 @@ 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
index a16a86876f9cedcb79dfee0c984bae52c9cfdeba..0638f5c1fa9885d1451cfc716e2d6a0235d06ff0 100644 (file)
@@ -448,9 +448,7 @@ gtk_text_changed_callback( GtkWidget *widget, wxTextCtrl *win )
     if ( win->MarkDirtyOnChange() )
         win->MarkDirty();
 
-    wxCommandEvent event( wxEVT_COMMAND_TEXT_UPDATED, win->GetId() );
-    event.SetEventObject( win );
-    win->GetEventHandler()->ProcessEvent( event );
+    win->SendTextUpdatedEvent();
 }
 }
 
index bd001090857696b0a464774509bbd69a599d18dc..30e828c6318982dfa247d7d13454812bc5cbcdc6 100644 (file)
@@ -547,32 +547,20 @@ void wxTextCtrl::GetSelection(long* from, long* to) const
     GetPeer()->GetSelection( from , to ) ;
 }
 
-void wxTextCtrl::SetValue(const wxString& str)
+void wxTextCtrl::DoSetValue(const wxString& str, int flags)
 {
     // optimize redraws
     if ( GetValue() == str )
-        return ;
+        return;
 
     GetPeer()->SetStringValue( str ) ;
 
-    if ( m_triggerOnSetValue )
+    if ( (flags & SetValue_SendEvent) && m_triggerOnSetValue )
     {
-        wxCommandEvent event( wxEVT_COMMAND_TEXT_UPDATED, m_windowId );
-        event.SetString( GetValue() );
-        event.SetEventObject( this );
-        GetEventHandler()->ProcessEvent( event );
+        SendTextUpdatedEvent();
     }
 }
 
-void wxTextCtrl::ChangeValue(const wxString& str)
-{
-    // optimize redraws
-    if ( GetValue() == str )
-        return ;
-
-    GetPeer()->SetStringValue( str ) ;
-}
-
 void wxTextCtrl::SetMaxLength(unsigned long len)
 {
     m_maxLength = len ;
index d09a620465113dc20b3dbd411483cff6da523458..8213b6b8cdaf4134a9cab96fee6fde91cbfb67be 100644 (file)
@@ -240,7 +240,7 @@ wxString wxTextCtrl::GetValue() const
     return str;
 }
 
-void wxTextCtrl::ChangeValue(const wxString& text)
+void wxTextCtrl::DoSetValue(const wxString& text, int flags)
 {
     m_inSetValue = true;
 
@@ -254,6 +254,9 @@ void wxTextCtrl::ChangeValue(const wxString& text)
     m_modified = true;
 
     m_inSetValue = false;
+
+    if ( flags & SetValue_SendEvent )
+        SendTextUpdatedEvent();
 }
 
 // Clipboard operations
index 7302a7fe63fb5da64ec5e5dbe8179c9f1e7da965..e925b130c63d501a170c25de55b6db3aa93adb79 100644 (file)
@@ -229,66 +229,10 @@ wxString wxTextCtrl::GetValue() const
     return res;
 }
 
-void wxTextCtrl::SetValue(const wxString& value)
+void wxTextCtrl::DoSetValue(const wxString& value, int flags)
 {
 }
 
-void wxTextCtrl::ChangeValue(const wxString& value)
-{
-}
-
-#if wxUSE_RICHEDIT && (!wxUSE_UNICODE || wxUSE_UNICODE_MSLU)
-
-// TODO: using memcpy() would improve performance a lot for big amounts of text
-
-DWORD CALLBACK
-wxRichEditStreamIn(DWORD dwCookie, BYTE *buf, LONG cb, LONG *pcb)
-{
-    return 0;
-}
-
-// helper struct used to pass parameters from wxTextCtrl to wxRichEditStreamOut
-struct wxStreamOutData
-{
-    wchar_t *wpc;
-    size_t len;
-};
-
-DWORD CALLBACK
-wxRichEditStreamOut(DWORD_PTR dwCookie, BYTE *buf, LONG cb, LONG *pcb)
-{
-    return 0;
-}
-
-
-#if wxUSE_UNICODE_MSLU
-    #define UNUSED_IF_MSLU(param)
-#else
-    #define UNUSED_IF_MSLU(param) param
-#endif
-
-bool
-wxTextCtrl::StreamIn(const wxString& value,
-                     wxFontEncoding UNUSED_IF_MSLU(encoding),
-                     bool selectionOnly)
-{
-    return false;
-}
-
-#if !wxUSE_UNICODE_MSLU
-
-wxString
-wxTextCtrl::StreamOut(wxFontEncoding encoding, bool selectionOnly) const
-{
-    wxString out;
-
-    return out;
-}
-
-#endif // !wxUSE_UNICODE_MSLU
-
-#endif // wxUSE_RICHEDIT
-
 void wxTextCtrl::WriteText(const wxString& value)
 {
 }
index 17ed256745af3b68c26d4d8c5664439a096d0d4d..5b1c204822080ef4c658bf2f1f6c0d388327f817 100644 (file)
@@ -778,7 +778,7 @@ wxTextCtrl::~wxTextCtrl()
 // set/get the value
 // ----------------------------------------------------------------------------
 
-void wxTextCtrl::ChangeValue(const wxString& value)
+void wxTextCtrl::DoSetValue(const wxString& value, int flags)
 {
     if ( IsSingleLine() && (value == GetValue()) )
     {
@@ -792,12 +792,9 @@ void wxTextCtrl::ChangeValue(const wxString& value)
     {
         SetInsertionPoint(0);
     }
-}
 
-void wxTextCtrl::SetValue(const wxString& value)
-{
-    ChangeValue(value);
-    SendTextUpdatedEvent();
+    if ( flags & SetValue_SendEvent )
+        SendTextUpdatedEvent();
 }
 
 const wxArrayString& wxTextCtrl::GetLines() const
index 8f8aa99e48e6a81f777192f3772b8bc1e5065773..02692fea0fbd8b0e5c93b95a6ae9cf45b289bbcf 100644 (file)
@@ -277,7 +277,7 @@ wxString wxTextCtrl::GetValue() const
     return ret;
 }
 
-void wxTextCtrl::ChangeValue(const wxString& value)
+void wxTextCtrl::DoSetValue(const wxString& value, int flags)
 {
     m_modified = false;
 
@@ -343,6 +343,9 @@ void wxTextCtrl::ChangeValue(const wxString& value)
     MyAdjustScrollbars();
 
     Refresh();
+
+    if ( flags & SetValue_SendEvent )
+        SendTextUpdatedEvent();
 }
 
 int wxTextCtrl::GetLineLength(long lineNo) const