]> git.saurik.com Git - wxWidgets.git/commitdiff
Fix setting tooltips for generic wxSpinCtrl.
authorVadim Zeitlin <vadim@wxwidgets.org>
Tue, 15 Mar 2011 11:10:38 +0000 (11:10 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Tue, 15 Mar 2011 11:10:38 +0000 (11:10 +0000)
Forward the tooltip set for the control to its subcontrols.

Closes #9817.

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

docs/changes.txt
include/wx/generic/spinctlg.h
src/generic/spinctlg.cpp

index 407b501d3b8d0e7ddeed73c243922b81bd921824..6d61b9b16f15f12e0a271a6458b17912a4d78183 100644 (file)
@@ -489,6 +489,7 @@ All (GUI):
 - Added wxFont::Underlined() and MakeUnderlined() methods.
 - Added wxFont::SetSymbolicSize() and related methods.
 - Fix SVG files generation in locales using decimal comma (snowleopard).
+- Fix setting tooltips for generic wxSpinCtrl (Catalin Raceanu).
 
 GTK:
 
index aa44dc989af392454cfdb77c69a5ae5796f62857..56eda17f9fb225908f2e25aa197470b083850b09 100644 (file)
@@ -82,6 +82,9 @@ public:
     virtual bool Enable(bool enable = true);
     virtual bool Show(bool show = true);
     virtual bool Reparent(wxWindowBase *newParent);
+#if wxUSE_TOOLTIPS
+    virtual void DoSetToolTip(wxToolTip *tip);
+#endif // wxUSE_TOOLTIPS
 
     // get the subcontrols
     wxTextCtrl   *GetText() const       { return m_textCtrl; }
index 796f89efb584df931bf6755adff014c32ea464ef..ca2a1bb465fed7b156ce7d94307cbf7f316ca870 100644 (file)
@@ -29,6 +29,7 @@
 #endif //WX_PRECOMP
 
 #include "wx/spinctrl.h"
+#include "wx/tooltip.h"
 
 #if wxUSE_SPINCTRL
 
@@ -192,6 +193,10 @@ bool wxSpinCtrlGenericBase::Create(wxWindow *parent,
 
     m_textCtrl   = new wxSpinCtrlTextGeneric(this, value, style);
     m_spinButton = new wxSpinCtrlButtonGeneric(this, style);
+#if wxUSE_TOOLTIPS
+    m_textCtrl->SetToolTip(GetToolTipText());
+    m_spinButton->SetToolTip(GetToolTipText());
+#endif // wxUSE_TOOLTIPS
 
     m_spin_value = m_spinButton->GetValue();
 
@@ -321,6 +326,33 @@ bool wxSpinCtrlGenericBase::Reparent(wxWindowBase *newParent)
     return true;
 }
 
+#if wxUSE_TOOLTIPS
+void wxSpinCtrlGenericBase::DoSetToolTip(wxToolTip *tip)
+{
+    // Notice that we must check for the subcontrols not being NULL (as they
+    // could be if we were created with the default ctor and this is called
+    // before Create() for some reason) and that we can't call SetToolTip(tip)
+    // because this would take ownership of the wxToolTip object (twice).
+    if ( m_textCtrl )
+    {
+        if ( tip )
+            m_textCtrl->SetToolTip(tip->GetTip());
+        else
+            m_textCtrl->SetToolTip(NULL);
+    }
+
+    if ( m_spinButton )
+    {
+        if( tip )
+            m_spinButton->SetToolTip(tip->GetTip());
+        else
+            m_spinButton->SetToolTip(NULL);
+    }
+
+    wxWindowBase::DoSetToolTip(tip);
+}
+#endif // wxUSE_TOOLTIPS
+
 // ----------------------------------------------------------------------------
 // Handle sub controls events
 // ----------------------------------------------------------------------------