]> git.saurik.com Git - wxWidgets.git/commitdiff
Forbid setting hints for multi-line text controls.
authorVadim Zeitlin <vadim@wxwidgets.org>
Tue, 10 Jul 2012 23:52:10 +0000 (23:52 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Tue, 10 Jul 2012 23:52:10 +0000 (23:52 +0000)
This doesn't work anyhow, so make it explicit by asserting if an attempt to do
it is made. And document this.

Also add a test of SetHint() to the text sample to verify it still works.

Closes #14456.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72010 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/textctrl.h
interface/wx/textentry.h
samples/text/text.cpp
src/common/textcmn.cpp

index f8a344d01eebec65ee5fd76f0540d38512bad74a..57dfeb79b43d0468369f9cb4288d775ce9cd3763 100644 (file)
@@ -734,6 +734,9 @@ public:
        wxTextEntry::SetValue(value);
     }
 
        wxTextEntry::SetValue(value);
     }
 
+    // wxTextEntry overrides
+    virtual bool SetHint(const wxString& hint);
+
     // wxWindow overrides
     virtual wxVisualAttributes GetDefaultAttributes() const
     {
     // wxWindow overrides
     virtual wxVisualAttributes GetDefaultAttributes() const
     {
index 0a5a5e22307f5c381b5ec177a236f8054ced2eae..790f08242f8e38a2fcadb4061298bce48566a5e7 100644 (file)
@@ -456,6 +456,10 @@ public:
             currently you should avoid calling methods such as WriteText() or
             Replace() when using hints and the text control is empty.
 
             currently you should avoid calling methods such as WriteText() or
             Replace() when using hints and the text control is empty.
 
+        @remarks Hints can only be used for single line text controls,
+            native multi-line text controls don't support hints under any
+            platform and hence wxWidgets doesn't provide them neither.
+
         @since 2.9.0
      */
     virtual bool SetHint(const wxString& hint);
         @since 2.9.0
      */
     virtual bool SetHint(const wxString& hint);
index 12662153bd1e9cc1a8eb453b57e7668803dd1cff..094bcc3e6b905857059de6db4f14086ee004fc70 100644 (file)
@@ -1077,8 +1077,9 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h )
     m_readonly = new MyTextCtrl( this, wxID_ANY, wxT("Read only"),
       wxPoint(10,90), wxSize(140,wxDefaultCoord), wxTE_READONLY );
 
     m_readonly = new MyTextCtrl( this, wxID_ANY, wxT("Read only"),
       wxPoint(10,90), wxSize(140,wxDefaultCoord), wxTE_READONLY );
 
-    m_limited = new MyTextCtrl(this, wxID_ANY, wxT("Max 8 ch"),
+    m_limited = new MyTextCtrl(this, wxID_ANY, "",
                               wxPoint(10, 130), wxSize(140, wxDefaultCoord));
                               wxPoint(10, 130), wxSize(140, wxDefaultCoord));
+    m_limited->SetHint("Max 8 ch");
     m_limited->SetMaxLength(8);
 
     // multi line text controls
     m_limited->SetMaxLength(8);
 
     // multi line text controls
index 541f996a32375a1a175579c6f73cf15e6f89387b..dd84b8855676fdd3c1a6a30427868742c83930c3 100644 (file)
@@ -1139,6 +1139,18 @@ bool wxTextCtrlBase::EmulateKeyPress(const wxKeyEvent& event)
     return handled;
 }
 
     return handled;
 }
 
+// ----------------------------------------------------------------------------
+// Other miscellaneous stuff
+// ----------------------------------------------------------------------------
+
+bool wxTextCtrlBase::SetHint(const wxString& hint)
+{
+    wxCHECK_MSG( IsSingleLine(), false,
+                 wxS("Hints can only be set for single line text controls") );
+
+    return wxTextEntry::SetHint(hint);
+}
+
 // do the window-specific processing after processing the update event
 void wxTextCtrlBase::DoUpdateWindowUI(wxUpdateUIEvent& event)
 {
 // do the window-specific processing after processing the update event
 void wxTextCtrlBase::DoUpdateWindowUI(wxUpdateUIEvent& event)
 {