]> git.saurik.com Git - wxWidgets.git/blob - src/cocoa/tooltip.mm
added possibility to throw different objects and crash directly from the main frame...
[wxWidgets.git] / src / cocoa / tooltip.mm
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/cocoa/tooltip.mm
3 // Purpose: Cocoa tooltips
4 // Author: Ryan Norton
5 // Modified by:
6 // Created: 2004-10-03
7 // RCS-ID: $Id$
8 // Copyright: (c) Ryan Norton
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 // ===========================================================================
13 // declarations
14 // ===========================================================================
15
16 // ---------------------------------------------------------------------------
17 // headers
18 // ---------------------------------------------------------------------------
19
20 #include "wx/defs.h"
21
22 #if wxUSE_TOOLTIPS
23
24 #include "wx/window.h"
25 #include "wx/tooltip.h"
26
27 #include "wx/cocoa/autorelease.h"
28 #include "wx/cocoa/string.h"
29
30 #import <AppKit/NSView.h>
31
32 //-----------------------------------------------------------------------------
33 // wxToolTip
34 //-----------------------------------------------------------------------------
35
36 IMPLEMENT_ABSTRACT_CLASS(wxToolTip, wxObject)
37
38 wxToolTip::wxToolTip(const wxString &tip) :
39 m_text(tip), m_window(0)
40 {
41 }
42
43 wxToolTip::~wxToolTip()
44 {
45 }
46
47 void wxToolTip::SetTip(const wxString& tip)
48 {
49 m_text = tip;
50 }
51
52 const wxString& wxToolTip::GetTip() const
53 {
54 return m_text;
55 }
56
57 // the window we're associated with
58 wxWindow *wxToolTip::GetWindow() const
59 {
60 return m_window;
61 }
62
63 // enable or disable the tooltips globally
64 //static
65 void wxToolTip::Enable(bool flag)
66 {
67 //TODO
68 wxFAIL_MSG(wxT("Not implemented"));
69 }
70
71 // set the delay after which the tooltip appears
72 //static
73 void wxToolTip::SetDelay(long milliseconds)
74 {
75 //TODO
76 wxFAIL_MSG(wxT("Not implemented"));
77 }
78
79 void wxToolTip::SetWindow(wxWindow* window)
80 {
81 wxAutoNSAutoreleasePool pool;
82
83 m_window = window;
84
85 //set the tooltip - empty string means remove
86 if (m_text.IsEmpty())
87 [m_window->GetNSView() setToolTip:nil];
88 else
89 [m_window->GetNSView() setToolTip:wxNSStringWithWxString(m_text)];
90 }
91
92 #endif //wxUSE_TOOLTIPS