]>
git.saurik.com Git - wxWidgets.git/blob - src/msw/richtooltip.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/msw/richtooltip.cpp
3 // Purpose: Native MSW implementation of wxRichToolTip.
4 // Author: Vadim Zeitlin
6 // RCS-ID: $Id: wxhead.cpp,v 1.11 2010-04-22 12:44:51 zeitlin Exp $
7 // Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
11 // ============================================================================
13 // ============================================================================
15 // ----------------------------------------------------------------------------
17 // ----------------------------------------------------------------------------
19 // for compilers that support precompilation, includes "wx.h".
20 #include "wx/wxprec.h"
31 #include "wx/private/richtooltip.h"
32 #include "wx/generic/private/richtooltip.h"
33 #include "wx/msw/private.h"
34 #include "wx/msw/uxtheme.h"
36 // ============================================================================
37 // wxRichToolTipMSWImpl: the real implementation.
38 // ============================================================================
40 class wxRichToolTipMSWImpl
: public wxRichToolTipGenericImpl
43 wxRichToolTipMSWImpl(const wxString
& title
, const wxString
& message
) :
44 wxRichToolTipGenericImpl(title
, message
)
47 m_canUseNative
= true;
52 virtual void SetBackgroundColour(const wxColour
& col
,
53 const wxColour
& colEnd
)
55 // Setting background colour is not supported neither.
56 m_canUseNative
= false;
58 wxRichToolTipGenericImpl::SetBackgroundColour(col
, colEnd
);
61 virtual void SetCustomIcon(const wxIcon
& icon
)
63 // Custom icons are not supported by EM_SHOWBALLOONTIP.
64 m_canUseNative
= false;
66 wxRichToolTipGenericImpl::SetCustomIcon(icon
);
69 virtual void SetStandardIcon(int icon
)
71 wxRichToolTipGenericImpl::SetStandardIcon(icon
);
72 if ( !m_canUseNative
)
75 switch ( icon
& wxICON_MASK
)
78 m_ttiIcon
= TTI_WARNING
;
82 m_ttiIcon
= TTI_ERROR
;
85 case wxICON_INFORMATION
:
90 wxFAIL_MSG("Question icon doesn't make sense for a tooltip");
99 virtual void SetTimeout(unsigned milliseconds
)
101 // We don't support changing the timeout (maybe TTM_SETDELAYTIME could
102 // be used for this?).
103 m_canUseNative
= false;
105 wxRichToolTipGenericImpl::SetTimeout(milliseconds
);
108 virtual void SetTipKind(wxTipKind tipKind
)
110 // Setting non-default tip is not supported.
111 if ( tipKind
!= wxTipKind_Auto
)
112 m_canUseNative
= false;
114 wxRichToolTipGenericImpl::SetTipKind(tipKind
);
117 virtual void SetTitleFont(const wxFont
& font
)
119 // Setting non-default font is not supported.
120 m_canUseNative
= false;
122 wxRichToolTipGenericImpl::SetTitleFont(font
);
125 virtual void ShowFor(wxWindow
* win
)
127 // TODO: We could use native tooltip control to show native balloon
128 // tooltips for any window but right now we use the simple
129 // EM_SHOWBALLOONTIP API which can only be used with text
131 if ( m_canUseNative
)
133 wxTextCtrl
* const text
= wxDynamicCast(win
, wxTextCtrl
);
137 ebt
.cbStruct
= sizeof(EDITBALLOONTIP
);
138 ebt
.pszTitle
= m_title
.wc_str();
139 ebt
.pszText
= m_message
.wc_str();
140 ebt
.ttiIcon
= m_ttiIcon
;
141 if ( Edit_ShowBalloonTip(GetHwndOf(text
), &ebt
) )
146 // Don't set m_canUseNative to false here, we could be able to use the
147 // native tooltips if we're called for a different window the next
149 wxRichToolTipGenericImpl::ShowFor(win
);
153 // If this is false, we've been requested to do something that the native
154 // version doesn't support and so need to fall back to the generic one.
157 // One of TTI_NONE, TTI_INFO, TTI_WARNING or TTI_ERROR.
163 wxRichToolTipImpl::Create(const wxString
& title
, const wxString
& message
)
165 // EM_SHOWBALLOONTIP is only implemented by comctl32.dll v6 so don't even
166 // bother using the native implementation if we're not using themes.
167 if ( wxUxThemeEngine::GetIfActive() )
168 return new wxRichToolTipMSWImpl(title
, message
);
170 return new wxRichToolTipGenericImpl(title
, message
);
173 #endif // wxUSE_RICHTOOLTIP