]> git.saurik.com Git - wxWidgets.git/blob - src/cocoa/tooltip.mm
check default library directories in WX_PATH_FIND_LIBRARIES; do *not* add default...
[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 // Private object in AppKit - exists in 10.2 at least -
34 // most likely exists earlier too
35 //
36 @interface NSToolTipManager : NSObject
37 {
38 /*
39 NSWindow *toolTipWindow;
40 NSMutableArray *toolTips;
41 double toolTipDelay;
42 NSDate *timeToolTipRemovedFromScreen;
43 struct __CFRunLoopTimer *toolTipDisplayTimer;
44 NSToolTip *currentDisplayedToolTip;
45 NSToolTip *currentFadingToolTip;
46 float currentFadeValue;
47 NSTimer *fadeTimer;
48 NSWindow *lastToolTipWindow;
49 */
50 }
51
52 + (id)sharedToolTipManager;
53 - (int)_addTrackingRect:(struct _NSRect)fp12 andStartToolTipIfNecessary:(BOOL)fp28 view:(id)fp32 owner:(id)fp32 toolTip:(id)fp36;
54 - (void)_checkToolTipDelay;
55 - (void)_removeToolTip:(id)fp12 stopTimerIfNecessary:(BOOL)fp16;
56 - (void)_removeTrackingRectForToolTip:(id)fp12 stopTimerIfNecessary:(BOOL)fp16;
57 - (int)_setToolTip:(id)fp12 forView:(id)fp16 cell:(id)fp20 rect:(struct _NSRect)fp20 owner:(id)fp36 ownerIsDisplayDelegate:(BOOL)fp43 userData:(void *)fp44;
58 - (void)_stopTimerIfRunningForToolTip:(id)fp12;
59 - (void)abortToolTip;
60 - (void)addTrackingRectForToolTip:(id)fp12;
61 - (void)dealloc;
62 - (void)displayToolTip:(id)fp12;
63 - (void)fadeToolTip:(id)fp12;
64 - (id)init;
65 - (void)mouseEntered:(id)fp12;
66 - (void)mouseEnteredToolTip:(id)fp12 inWindow:(id)fp16 withEvent:(id)fp20;
67 - (void)mouseExited:(id)fp12;
68 - (void)orderOutToolTip;
69 - (void)orderOutToolTipImmediately:(BOOL)fp12;
70 - (void)recomputeToolTipsForView:(id)fp12 remove:(BOOL)fp16 add:(BOOL)fp20;
71 - (void)removeAllToolTipsForView:(id)fp12;
72 - (void)removeToolTipForView:(id)fp12 tag:(int)fp16;
73 - (void)setInitialToolTipDelay:(double)fp40;
74 - (void)setToolTip:(id)fp12 forView:(id)fp16 cell:(id)fp20;
75 - (int)setToolTipForView:(id)fp12 rect:(struct _NSRect)fp16 displayDelegate:(id)fp32 userData:(void *)fp32;
76 - (int)setToolTipForView:(id)fp12 rect:(struct _NSRect)fp16 owner:(id)fp32 userData:(void *)fp32;
77 - (void)setToolTipWithOwner:(id)fp12 forView:(id)fp16 cell:(id)fp20;
78 - (void)startTimer:(float)fp40 userInfo:(id)fp16;
79 - (void)stopTimer;
80 - (id)toolTipForView:(id)fp12 cell:(id)fp16;
81 - (BOOL)viewHasToolTips:(id)fp12;
82
83 @end
84
85 //-----------------------------------------------------------------------------
86 // wxToolTip
87 //-----------------------------------------------------------------------------
88
89 IMPLEMENT_ABSTRACT_CLASS(wxToolTip, wxObject)
90
91 wxToolTip::wxToolTip(const wxString &tip) :
92 m_text(tip), m_window(0)
93 {
94 }
95
96 wxToolTip::~wxToolTip()
97 {
98 }
99
100 void wxToolTip::SetTip(const wxString& tip)
101 {
102 m_text = tip;
103 }
104
105 const wxString& wxToolTip::GetTip() const
106 {
107 return m_text;
108 }
109
110 // the window we're associated with
111 wxWindow *wxToolTip::GetWindow() const
112 {
113 return m_window;
114 }
115
116 // enable or disable the tooltips globally
117 //static
118 void wxToolTip::Enable(bool flag)
119 {
120 //TODO
121 wxFAIL_MSG(wxT("Not implemented"));
122 }
123
124 // set the delay after which the tooltip appears
125 //static
126 void wxToolTip::SetDelay(long milliseconds)
127 {
128 [[NSToolTipManager sharedToolTipManager] setInitialToolTipDelay: ((double)milliseconds) / 1000.0];
129 }
130
131 void wxToolTip::SetWindow(wxWindow* window)
132 {
133 wxAutoNSAutoreleasePool pool;
134
135 m_window = window;
136
137 //set the tooltip - empty string means remove
138 if (m_text.IsEmpty())
139 [m_window->GetNSView() setToolTip:nil];
140 else
141 [m_window->GetNSView() setToolTip:wxNSStringWithWxString(m_text)];
142 }
143
144 #endif //wxUSE_TOOLTIPS