Basic support for tooltips under OS X Cocoa.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63477 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Kevin Ollivier
2010-02-13 06:30:06 +00:00
parent 06b76f7e8b
commit a7b9865d30
5 changed files with 24 additions and 0 deletions

View File

@@ -145,6 +145,7 @@ public :
void SetScrollThumb( wxInt32 value, wxInt32 thumbSize ); void SetScrollThumb( wxInt32 value, wxInt32 thumbSize );
void SetFont( const wxFont & font , const wxColour& foreground , long windowStyle, bool ignoreBlack = true ); void SetFont( const wxFont & font , const wxColour& foreground , long windowStyle, bool ignoreBlack = true );
void SetToolTip( wxToolTip* tooltip );
void InstallEventHandler( WXWidget control = NULL ); void InstallEventHandler( WXWidget control = NULL );

View File

@@ -268,6 +268,8 @@ public :
virtual void SetScrollThumb( wxInt32 value, wxInt32 thumbSize ) = 0; virtual void SetScrollThumb( wxInt32 value, wxInt32 thumbSize ) = 0;
virtual void SetFont( const wxFont & font , const wxColour& foreground , long windowStyle, bool ignoreBlack = true ) = 0; virtual void SetFont( const wxFont & font , const wxColour& foreground , long windowStyle, bool ignoreBlack = true ) = 0;
virtual void SetToolTip(wxToolTip* WXUNUSED(tooltip)) { }
// is the clicked event sent AFTER the state already changed, so no additional // is the clicked event sent AFTER the state already changed, so no additional
// state changing logic is required from the outside // state changing logic is required from the outside

View File

@@ -47,6 +47,8 @@ wxToolTip::~wxToolTip()
void wxToolTip::SetTip( const wxString &tip ) void wxToolTip::SetTip( const wxString &tip )
{ {
m_text = tip; m_text = tip;
if (m_window)
m_window->SetToolTip(this);
} }
void wxToolTip::SetWindow( wxWindow *win ) void wxToolTip::SetWindow( wxWindow *win )

View File

@@ -32,6 +32,10 @@
#include "wx/dnd.h" #include "wx/dnd.h"
#endif #endif
#if wxUSE_TOOLTIPS
#include "wx/tooltip.h"
#endif
#include <objc/objc-runtime.h> #include <objc/objc-runtime.h>
// Get the window with the focus // Get the window with the focus
@@ -1890,6 +1894,18 @@ void wxWidgetCocoaImpl::SetFont(wxFont const& font, wxColour const&, long, bool)
[m_osxView setFont: font.OSXGetNSFont()]; [m_osxView setFont: font.OSXGetNSFont()];
} }
void wxWidgetCocoaImpl::SetToolTip(wxToolTip* tooltip)
{
if (tooltip)
{
wxCFStringRef cf( tooltip->GetTip() , m_wxPeer->GetFont().GetEncoding() );
[m_osxView setToolTip: cf.AsNSString()];
}
else
[m_osxView setToolTip: nil];
}
void wxWidgetCocoaImpl::InstallEventHandler( WXWidget control ) void wxWidgetCocoaImpl::InstallEventHandler( WXWidget control )
{ {
WXWidget c = control ? control : (WXWidget) m_osxView; WXWidget c = control ? control : (WXWidget) m_osxView;

View File

@@ -752,6 +752,9 @@ void wxWindowMac::DoSetToolTip(wxToolTip *tooltip)
if ( m_tooltip ) if ( m_tooltip )
m_tooltip->SetWindow(this); m_tooltip->SetWindow(this);
if (m_peer)
m_peer->SetToolTip(tooltip);
} }
#endif #endif