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