]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/cocoa/tooltip.mm
Reflect changes in stc.cpp in stc.cpp.in from which it's generated.
[wxWidgets.git] / src / cocoa / tooltip.mm
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: src/cocoa/tooltip.mm
3// Purpose: Cocoa tooltips
4// Author: Ryan Norton
5// Modified by:
6// Created: 2004-10-03
7// Copyright: (c) Ryan Norton
8// Licence: wxWindows licence
9/////////////////////////////////////////////////////////////////////////////
10
11#include "wx/wxprec.h"
12
13// ===========================================================================
14// declarations
15// ===========================================================================
16
17// ---------------------------------------------------------------------------
18// headers
19// ---------------------------------------------------------------------------
20
21#if wxUSE_TOOLTIPS
22
23#ifndef WX_PRECOMP
24 #include "wx/window.h"
25#endif
26
27#include "wx/tooltip.h"
28
29#include "wx/cocoa/autorelease.h"
30#include "wx/cocoa/string.h"
31
32#import <AppKit/NSView.h>
33
34//
35// Private object in AppKit - exists in 10.2 at least -
36// most likely exists earlier too
37//
38@interface NSToolTipManager : NSObject
39{
40/*
41 NSWindow *toolTipWindow;
42 NSMutableArray *toolTips;
43 double toolTipDelay;
44 NSDate *timeToolTipRemovedFromScreen;
45 struct __CFRunLoopTimer *toolTipDisplayTimer;
46 NSToolTip *currentDisplayedToolTip;
47 NSToolTip *currentFadingToolTip;
48 float currentFadeValue;
49 NSTimer *fadeTimer;
50 NSWindow *lastToolTipWindow;
51*/
52}
53
54+ (id)sharedToolTipManager;
55- (int)_addTrackingRect:(struct _NSRect)fp12 andStartToolTipIfNecessary:(BOOL)fp28 view:(id)fp32 owner:(id)fp32 toolTip:(id)fp36;
56- (void)_checkToolTipDelay;
57- (void)_removeToolTip:(id)fp12 stopTimerIfNecessary:(BOOL)fp16;
58- (void)_removeTrackingRectForToolTip:(id)fp12 stopTimerIfNecessary:(BOOL)fp16;
59- (int)_setToolTip:(id)fp12 forView:(id)fp16 cell:(id)fp20 rect:(struct _NSRect)fp20 owner:(id)fp36 ownerIsDisplayDelegate:(BOOL)fp43 userData:(void *)fp44;
60- (void)_stopTimerIfRunningForToolTip:(id)fp12;
61- (void)abortToolTip;
62- (void)addTrackingRectForToolTip:(id)fp12;
63- (void)dealloc;
64- (void)displayToolTip:(id)fp12;
65- (void)fadeToolTip:(id)fp12;
66- (id)init;
67- (void)mouseEntered:(id)fp12;
68- (void)mouseEnteredToolTip:(id)fp12 inWindow:(id)fp16 withEvent:(id)fp20;
69- (void)mouseExited:(id)fp12;
70- (void)orderOutToolTip;
71- (void)orderOutToolTipImmediately:(BOOL)fp12;
72- (void)recomputeToolTipsForView:(id)fp12 remove:(BOOL)fp16 add:(BOOL)fp20;
73- (void)removeAllToolTipsForView:(id)fp12;
74- (void)removeToolTipForView:(id)fp12 tag:(int)fp16;
75- (void)setInitialToolTipDelay:(double)fp40;
76- (void)setToolTip:(id)fp12 forView:(id)fp16 cell:(id)fp20;
77- (int)setToolTipForView:(id)fp12 rect:(struct _NSRect)fp16 displayDelegate:(id)fp32 userData:(void *)fp32;
78- (int)setToolTipForView:(id)fp12 rect:(struct _NSRect)fp16 owner:(id)fp32 userData:(void *)fp32;
79- (void)setToolTipWithOwner:(id)fp12 forView:(id)fp16 cell:(id)fp20;
80- (void)startTimer:(float)fp40 userInfo:(id)fp16;
81- (void)stopTimer;
82- (id)toolTipForView:(id)fp12 cell:(id)fp16;
83- (BOOL)viewHasToolTips:(id)fp12;
84
85@end
86
87//-----------------------------------------------------------------------------
88// wxToolTip
89//-----------------------------------------------------------------------------
90
91IMPLEMENT_ABSTRACT_CLASS(wxToolTip, wxObject)
92
93wxToolTip::wxToolTip(const wxString &tip) :
94 m_text(tip), m_window(0)
95{
96}
97
98wxToolTip::~wxToolTip()
99{
100}
101
102void wxToolTip::SetTip(const wxString& tip)
103{
104 m_text = tip;
105}
106
107const wxString& wxToolTip::GetTip() const
108{
109 return m_text;
110}
111
112// the window we're associated with
113wxWindow *wxToolTip::GetWindow() const
114{
115 return m_window;
116}
117
118// enable or disable the tooltips globally
119//static
120 void wxToolTip::Enable(bool flag)
121{
122 //TODO
123 wxFAIL_MSG(wxT("Not implemented"));
124}
125
126// set the delay after which the tooltip appears
127//static
128 void wxToolTip::SetDelay(long milliseconds)
129{
130 [[NSToolTipManager sharedToolTipManager] setInitialToolTipDelay: ((double)milliseconds) / 1000.0];
131}
132
133void wxToolTip::SetWindow(wxWindow* window)
134{
135 wxAutoNSAutoreleasePool pool;
136
137 m_window = window;
138
139 //set the tooltip - empty string means remove
140 if (m_text.empty())
141 [m_window->GetNSView() setToolTip:nil];
142 else
143 [m_window->GetNSView() setToolTip:wxNSStringWithWxString(m_text)];
144}
145
146#endif //wxUSE_TOOLTIPS