// Name: src/cocoa/tooltip.mm
// Purpose: Cocoa tooltips
// Author: Ryan Norton
-// Modified by:
+// Modified by:
// Created: 2004-10-03
-// RCS-ID: $Id$
// Copyright: (c) Ryan Norton
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
+#include "wx/wxprec.h"
+
// ===========================================================================
// declarations
// ===========================================================================
// headers
// ---------------------------------------------------------------------------
-#include "wx/defs.h"
-
#if wxUSE_TOOLTIPS
-#include "wx/window.h"
+#ifndef WX_PRECOMP
+ #include "wx/window.h"
+#endif
+
#include "wx/tooltip.h"
#include "wx/cocoa/autorelease.h"
#import <AppKit/NSView.h>
+//
+// Private object in AppKit - exists in 10.2 at least -
+// most likely exists earlier too
+//
@interface NSToolTipManager : NSObject
{
/*
IMPLEMENT_ABSTRACT_CLASS(wxToolTip, wxObject)
-wxToolTip::wxToolTip(const wxString &tip) :
- m_text(tip), m_window(0)
+wxToolTip::wxToolTip(const wxString &tip) :
+ m_text(tip), m_window(0)
{
}
-wxToolTip::~wxToolTip()
+wxToolTip::~wxToolTip()
{
}
void wxToolTip::SetTip(const wxString& tip)
-{
- m_text = tip;
+{
+ m_text = tip;
}
-const wxString& wxToolTip::GetTip() const
-{
- return m_text;
+const wxString& wxToolTip::GetTip() const
+{
+ return m_text;
}
// the window we're associated with
-wxWindow *wxToolTip::GetWindow() const
-{
- return m_window;
+wxWindow *wxToolTip::GetWindow() const
+{
+ return m_window;
}
// enable or disable the tooltips globally
-//static
- void wxToolTip::Enable(bool flag)
+//static
+ void wxToolTip::Enable(bool flag)
{
//TODO
wxFAIL_MSG(wxT("Not implemented"));
// set the delay after which the tooltip appears
//static
- void wxToolTip::SetDelay(long milliseconds)
+ void wxToolTip::SetDelay(long milliseconds)
{
[[NSToolTipManager sharedToolTipManager] setInitialToolTipDelay: ((double)milliseconds) / 1000.0];
}
-void wxToolTip::SetWindow(wxWindow* window)
+void wxToolTip::SetWindow(wxWindow* window)
{
wxAutoNSAutoreleasePool pool;
m_window = window;
-
+
//set the tooltip - empty string means remove
- if (m_text.IsEmpty())
- [m_window->GetNSView() setToolTip:nil];
+ if (m_text.empty())
+ [m_window->GetNSView() setToolTip:nil];
else
- [m_window->GetNSView() setToolTip:wxNSStringWithWxString(m_text)];
+ [m_window->GetNSView() setToolTip:wxNSStringWithWxString(m_text)];
}
#endif //wxUSE_TOOLTIPS