]>
Commit | Line | Data |
---|---|---|
4849f027 SC |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: wx/osx/cocoa/private.h | |
3 | // Purpose: Private declarations: as this header is only included by | |
4 | // wxWidgets itself, it may contain identifiers which don't start | |
5 | // with "wx". | |
6 | // Author: Stefan Csomor | |
7 | // Modified by: | |
8 | // Created: 1998-01-01 | |
9 | // RCS-ID: $Id: private.h 53819 2008-05-29 14:11:45Z SC $ | |
10 | // Copyright: (c) Stefan Csomor | |
11 | // Licence: wxWindows licence | |
12 | ///////////////////////////////////////////////////////////////////////////// | |
13 | ||
14 | #ifndef _WX_PRIVATE_COCOA_H_ | |
15 | #define _WX_PRIVATE_COCOA_H_ | |
16 | ||
17 | #include "wx/osx/core/private.h" | |
18 | ||
935e6c7d SC |
19 | #include "wx/defs.h" |
20 | ||
21 | #include <ApplicationServices/ApplicationServices.h> | |
22 | ||
7ac5e1c9 SC |
23 | #if wxOSX_USE_ATSU_TEXT |
24 | // we need theming and atsu | |
25 | #include <Carbon/Carbon.h> | |
0a84f928 SC |
26 | #else |
27 | // we only need theming, if we find a better include replace the following | |
28 | #include <Carbon/Carbon.h> | |
7ac5e1c9 SC |
29 | #endif |
30 | ||
4849f027 | 31 | #ifdef __OBJC__ |
4849f027 | 32 | #import <Cocoa/Cocoa.h> |
4850cc8b | 33 | #endif |
4849f027 | 34 | |
126254a8 SC |
35 | #if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5 |
36 | // available in 10.4 but not in the headers | |
37 | enum { | |
38 | kEventMouseScroll = 11 | |
39 | }; | |
40 | #endif | |
524c47aa SC |
41 | // |
42 | // shared between Cocoa and Carbon | |
43 | // | |
44 | ||
b3b17ee7 | 45 | // bring in theming types without pulling in the headers |
524c47aa | 46 | |
935e6c7d | 47 | #if wxUSE_GUI |
524c47aa | 48 | typedef SInt16 ThemeBrush; |
6da991db | 49 | CGColorRef WXDLLIMPEXP_CORE wxMacCreateCGColorFromHITheme( ThemeBrush brush ) ; |
524c47aa SC |
50 | OSStatus WXDLLIMPEXP_CORE wxMacDrawCGImage( |
51 | CGContextRef inContext, | |
52 | const CGRect * inBounds, | |
53 | CGImageRef inImage) ; | |
59d866ad | 54 | WX_NSImage WXDLLIMPEXP_CORE wxOSXGetNSImageFromCGImage( CGImageRef image ); |
267ba369 | 55 | CGImageRef WXDLLIMPEXP_CORE wxOSXCreateCGImageFromNSImage( WX_NSImage nsimage ); |
935e6c7d | 56 | #endif |
524c47aa | 57 | |
935e6c7d | 58 | long UMAGetSystemVersion() ; |
524c47aa SC |
59 | WXDLLIMPEXP_BASE void wxMacStringToPascal( const wxString&from , StringPtr to ); |
60 | WXDLLIMPEXP_BASE wxString wxMacFSRefToPath( const FSRef *fsRef , CFStringRef additionalPathComponent = NULL ); | |
61 | WXDLLIMPEXP_BASE OSStatus wxMacPathToFSRef( const wxString&path , FSRef *fsRef ); | |
62 | WXDLLIMPEXP_BASE wxString wxMacHFSUniStrToString( ConstHFSUniStr255Param uniname ); | |
63 | ||
bfa92264 KO |
64 | class WXDLLIMPEXP_FWD_CORE wxDialog; |
65 | ||
524c47aa SC |
66 | // |
67 | // | |
68 | // | |
69 | ||
4849f027 SC |
70 | #if wxUSE_GUI |
71 | ||
72 | class WXDLLIMPEXP_CORE wxWidgetCocoaImpl : public wxWidgetImpl | |
73 | { | |
74 | public : | |
03647350 VZ |
75 | wxWidgetCocoaImpl( wxWindowMac* peer , WXWidget w, bool isRootControl = false ) ; |
76 | wxWidgetCocoaImpl() ; | |
77 | ~wxWidgetCocoaImpl(); | |
78 | ||
4849f027 | 79 | void Init(); |
03647350 | 80 | |
4849f027 | 81 | virtual bool IsVisible() const ; |
524c47aa SC |
82 | virtual void SetVisibility(bool); |
83 | ||
ab9a0b84 VZ |
84 | // we provide a static function which can be reused from |
85 | // wxNonOwnedWindowCocoaImpl too | |
86 | static bool ShowViewOrWindowWithEffect(wxWindow *win, | |
87 | bool show, | |
88 | wxShowEffect effect, | |
89 | unsigned timeout); | |
90 | ||
91 | virtual bool ShowWithEffect(bool show, | |
92 | wxShowEffect effect, | |
93 | unsigned timeout); | |
94 | ||
4849f027 | 95 | virtual void Raise(); |
03647350 | 96 | |
4849f027 SC |
97 | virtual void Lower(); |
98 | ||
99 | virtual void ScrollRect( const wxRect *rect, int dx, int dy ); | |
100 | ||
101 | virtual WXWidget GetWXWidget() const { return m_osxView; } | |
102 | ||
524c47aa | 103 | virtual void SetBackgroundColour(const wxColour&); |
bc5c09a3 | 104 | virtual bool SetBackgroundStyle(wxBackgroundStyle style); |
524c47aa | 105 | |
4849f027 SC |
106 | virtual void GetContentArea( int &left , int &top , int &width , int &height ) const; |
107 | virtual void Move(int x, int y, int width, int height); | |
108 | virtual void GetPosition( int &x, int &y ) const; | |
109 | virtual void GetSize( int &width, int &height ) const; | |
524c47aa | 110 | virtual void SetControlSize( wxWindowVariant variant ); |
4849f027 SC |
111 | |
112 | virtual void SetNeedsDisplay( const wxRect* where = NULL ); | |
113 | virtual bool GetNeedsDisplay() const; | |
114 | ||
115 | virtual bool CanFocus() const; | |
116 | // return true if successful | |
117 | virtual bool SetFocus(); | |
118 | virtual bool HasFocus() const; | |
119 | ||
120 | void RemoveFromParent(); | |
121 | void Embed( wxWidgetImpl *parent ); | |
524c47aa SC |
122 | |
123 | void SetDefaultButton( bool isDefault ); | |
124 | void PerformClick(); | |
a4e32492 | 125 | virtual void SetLabel(const wxString& title, wxFontEncoding encoding); |
524c47aa | 126 | |
54f11060 SC |
127 | void SetCursor( const wxCursor & cursor ); |
128 | void CaptureMouse(); | |
129 | void ReleaseMouse(); | |
130 | ||
524c47aa SC |
131 | wxInt32 GetValue() const; |
132 | void SetValue( wxInt32 v ); | |
e5d05b90 | 133 | wxBitmap GetBitmap() const; |
524c47aa | 134 | void SetBitmap( const wxBitmap& bitmap ); |
e5d05b90 | 135 | void SetBitmapPosition( wxDirection dir ); |
524c47aa SC |
136 | void SetupTabs( const wxNotebook ¬ebook ); |
137 | void GetBestRect( wxRect *r ) const; | |
138 | bool IsEnabled() const; | |
139 | void Enable( bool enable ); | |
140 | bool ButtonClickDidStateChange() { return true ;} | |
141 | void SetMinimum( wxInt32 v ); | |
142 | void SetMaximum( wxInt32 v ); | |
19c7ac3d SC |
143 | wxInt32 GetMinimum() const; |
144 | wxInt32 GetMaximum() const; | |
524c47aa SC |
145 | void PulseGauge(); |
146 | void SetScrollThumb( wxInt32 value, wxInt32 thumbSize ); | |
147 | ||
1e181c7a | 148 | void SetFont( const wxFont & font , const wxColour& foreground , long windowStyle, bool ignoreBlack = true ); |
a7b9865d | 149 | void SetToolTip( wxToolTip* tooltip ); |
1e181c7a | 150 | |
c4825ef7 | 151 | void InstallEventHandler( WXWidget control = NULL ); |
03647350 VZ |
152 | |
153 | virtual bool DoHandleMouseEvent(NSEvent *event); | |
f0e0116e KO |
154 | virtual bool DoHandleKeyEvent(NSEvent *event); |
155 | virtual bool DoHandleCharEvent(NSEvent *event, NSString *text); | |
03647350 | 156 | virtual void DoNotifyFocusEvent(bool receivedFocus, wxWidgetImpl* otherWindow); |
030495ec | 157 | |
ddbc8ac9 SC |
158 | virtual void SetupKeyEvent(wxKeyEvent &wxevent, NSEvent * nsEvent, NSString* charString = NULL); |
159 | virtual void SetupMouseEvent(wxMouseEvent &wxevent, NSEvent * nsEvent); | |
160 | ||
4850cc8b | 161 | |
4dd9fdf8 | 162 | void SetFlipped(bool flipped); |
ee032c59 | 163 | virtual bool IsFlipped() const { return m_isFlipped; } |
96defed0 SC |
164 | |
165 | // cocoa thunk connected calls | |
4dd9fdf8 SC |
166 | |
167 | virtual unsigned int draggingEntered(void* sender, WXWidget slf, void* _cmd); | |
168 | virtual void draggingExited(void* sender, WXWidget slf, void* _cmd); | |
169 | virtual unsigned int draggingUpdated(void* sender, WXWidget slf, void* _cmd); | |
170 | virtual bool performDragOperation(void* sender, WXWidget slf, void* _cmd); | |
171 | virtual void mouseEvent(WX_NSEvent event, WXWidget slf, void* _cmd); | |
172 | virtual void keyEvent(WX_NSEvent event, WXWidget slf, void* _cmd); | |
f0e0116e | 173 | virtual void insertText(NSString* text, WXWidget slf, void* _cmd); |
4dd9fdf8 | 174 | virtual bool performKeyEquivalent(WX_NSEvent event, WXWidget slf, void* _cmd); |
09a9eb20 | 175 | virtual bool acceptsFirstResponder(WXWidget slf, void* _cmd); |
4dd9fdf8 SC |
176 | virtual bool becomeFirstResponder(WXWidget slf, void* _cmd); |
177 | virtual bool resignFirstResponder(WXWidget slf, void* _cmd); | |
178 | virtual void resetCursorRects(WXWidget slf, void* _cmd); | |
179 | virtual bool isFlipped(WXWidget slf, void* _cmd); | |
180 | virtual void drawRect(void* rect, WXWidget slf, void* _cmd); | |
03647350 | 181 | |
e32090ba SC |
182 | virtual void controlAction(WXWidget slf, void* _cmd, void* sender); |
183 | virtual void controlDoubleAction(WXWidget slf, void* _cmd, void *sender); | |
75a2c6a1 KO |
184 | |
185 | // for wxTextCtrl-derived classes, put here since they don't all derive | |
186 | // from the same pimpl class. | |
187 | virtual void controlTextDidChange(); | |
4dd9fdf8 | 188 | |
4849f027 SC |
189 | protected: |
190 | WXWidget m_osxView; | |
f0e0116e | 191 | NSEvent* m_lastKeyDownEvent; |
4dd9fdf8 | 192 | bool m_isFlipped; |
7cb2a241 | 193 | // if it the control has an editor, that editor will already send some |
03647350 | 194 | // events, don't resend them |
7cb2a241 | 195 | bool m_hasEditor; |
03647350 | 196 | |
4849f027 SC |
197 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxWidgetCocoaImpl) |
198 | }; | |
199 | ||
ffad7b0d SC |
200 | DECLARE_WXCOCOA_OBJC_CLASS( wxNSWindow ); |
201 | ||
4849f027 SC |
202 | class wxNonOwnedWindowCocoaImpl : public wxNonOwnedWindowImpl |
203 | { | |
204 | public : | |
205 | wxNonOwnedWindowCocoaImpl( wxNonOwnedWindow* nonownedwnd) ; | |
206 | wxNonOwnedWindowCocoaImpl(); | |
03647350 | 207 | |
4849f027 | 208 | virtual ~wxNonOwnedWindowCocoaImpl(); |
03647350 | 209 | |
0aaa6ace | 210 | virtual void WillBeDestroyed() ; |
4849f027 SC |
211 | void Create( wxWindow* parent, const wxPoint& pos, const wxSize& size, |
212 | long style, long extraStyle, const wxString& name ) ; | |
17e2694c | 213 | void Create( wxWindow* parent, WXWindow nativeWindow ); |
03647350 | 214 | |
4849f027 | 215 | WXWindow GetWXWindow() const; |
03647350 | 216 | void Raise(); |
4849f027 | 217 | void Lower(); |
03647350 | 218 | bool Show(bool show); |
ab9a0b84 VZ |
219 | |
220 | virtual bool ShowWithEffect(bool show, | |
221 | wxShowEffect effect, | |
222 | unsigned timeout); | |
03647350 | 223 | |
4849f027 SC |
224 | void Update(); |
225 | bool SetTransparent(wxByte alpha); | |
226 | bool SetBackgroundColour(const wxColour& col ); | |
03647350 | 227 | void SetExtraStyle( long exStyle ); |
b6dc21e7 | 228 | void SetWindowStyleFlag( long style ); |
03647350 | 229 | bool SetBackgroundStyle(wxBackgroundStyle style); |
4849f027 SC |
230 | bool CanSetTransparent(); |
231 | ||
232 | void MoveWindow(int x, int y, int width, int height); | |
233 | void GetPosition( int &x, int &y ) const; | |
234 | void GetSize( int &width, int &height ) const; | |
235 | ||
03647350 | 236 | void GetContentArea( int &left , int &top , int &width , int &height ) const; |
4849f027 | 237 | bool SetShape(const wxRegion& region); |
03647350 | 238 | |
4849f027 | 239 | virtual void SetTitle( const wxString& title, wxFontEncoding encoding ) ; |
03647350 | 240 | |
4849f027 | 241 | virtual bool IsMaximized() const; |
03647350 | 242 | |
4849f027 | 243 | virtual bool IsIconized() const; |
03647350 | 244 | |
4849f027 | 245 | virtual void Iconize( bool iconize ); |
03647350 | 246 | |
4849f027 | 247 | virtual void Maximize(bool maximize); |
03647350 | 248 | |
4849f027 | 249 | virtual bool IsFullScreen() const; |
03647350 | 250 | |
4849f027 | 251 | virtual bool ShowFullScreen(bool show, long style); |
030495ec | 252 | |
dbc7ceb9 | 253 | virtual void ShowWithoutActivating(); |
4849f027 SC |
254 | |
255 | virtual void RequestUserAttention(int flags); | |
03647350 | 256 | |
4849f027 | 257 | virtual void ScreenToWindow( int *x, int *y ); |
03647350 | 258 | |
4849f027 | 259 | virtual void WindowToScreen( int *x, int *y ); |
03647350 | 260 | |
dbc7ceb9 | 261 | virtual bool IsActive(); |
efb2fa41 KO |
262 | |
263 | virtual void SetModified(bool modified); | |
ebf7d5c4 | 264 | virtual bool IsModified() const; |
030495ec | 265 | |
4849f027 SC |
266 | wxNonOwnedWindow* GetWXPeer() { return m_wxPeer; } |
267 | protected : | |
447e2772 SC |
268 | WXWindow m_macWindow; |
269 | void * m_macFullScreenData ; | |
4849f027 | 270 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxNonOwnedWindowCocoaImpl) |
03647350 | 271 | }; |
4849f027 | 272 | |
4850cc8b SC |
273 | #ifdef __OBJC__ |
274 | ||
2acc3915 SC |
275 | WXDLLIMPEXP_CORE NSRect wxToNSRect( NSView* parent, const wxRect& r ); |
276 | WXDLLIMPEXP_CORE wxRect wxFromNSRect( NSView* parent, const NSRect& rect ); | |
277 | WXDLLIMPEXP_CORE NSPoint wxToNSPoint( NSView* parent, const wxPoint& p ); | |
278 | WXDLLIMPEXP_CORE wxPoint wxFromNSPoint( NSView* parent, const NSPoint& p ); | |
03647350 VZ |
279 | |
280 | NSRect WXDLLIMPEXP_CORE wxOSXGetFrameForControl( wxWindowMac* window , const wxPoint& pos , const wxSize &size , | |
4850cc8b | 281 | bool adjustForOrigin = true ); |
03647350 | 282 | |
b466e85a | 283 | // used for many wxControls |
03647350 | 284 | |
b466e85a SC |
285 | @interface wxNSButton : NSButton |
286 | { | |
411a1c35 | 287 | NSTrackingRectTag rectTag; |
b466e85a | 288 | } |
03647350 | 289 | |
b466e85a SC |
290 | @end |
291 | ||
292 | @interface wxNSBox : NSBox | |
293 | { | |
b466e85a SC |
294 | } |
295 | ||
b466e85a SC |
296 | @end |
297 | ||
7cb2a241 SC |
298 | @interface wxNSTextFieldEditor : NSTextView |
299 | { | |
300 | NSEvent* lastKeyDownEvent; | |
301 | } | |
302 | ||
303 | @end | |
304 | ||
c8fdb345 | 305 | @interface wxNSTextField : NSTextField wxOSX_10_6_AND_LATER(<NSTextFieldDelegate>) |
7cb2a241 SC |
306 | { |
307 | wxNSTextFieldEditor* fieldEditor; | |
308 | } | |
309 | ||
310 | - (wxNSTextFieldEditor*) fieldEditor; | |
311 | - (void) setFieldEditor:(wxNSTextFieldEditor*) fieldEditor; | |
312 | ||
313 | @end | |
314 | ||
c8fdb345 | 315 | @interface wxNSSecureTextField : NSSecureTextField wxOSX_10_6_AND_LATER(<NSTextFieldDelegate>) |
b466e85a | 316 | { |
b466e85a | 317 | } |
7cb2a241 SC |
318 | |
319 | @end | |
320 | ||
321 | ||
030495ec | 322 | @interface wxNSTextView : NSTextView wxOSX_10_6_AND_LATER(<NSTextViewDelegate>) |
7cb2a241 SC |
323 | { |
324 | } | |
030495ec | 325 | |
b9cf2753 | 326 | - (void)textDidChange:(NSNotification *)aNotification; |
030495ec | 327 | |
b466e85a SC |
328 | @end |
329 | ||
ffad7b0d SC |
330 | @interface wxNSMenu : NSMenu |
331 | { | |
332 | wxMenuImpl* impl; | |
333 | } | |
334 | ||
335 | - (void) setImplementation:(wxMenuImpl*) item; | |
336 | - (wxMenuImpl*) implementation; | |
337 | ||
03647350 | 338 | @end |
ffad7b0d SC |
339 | |
340 | @interface wxNSMenuItem : NSMenuItem | |
341 | { | |
342 | wxMenuItemImpl* impl; | |
343 | } | |
344 | ||
345 | - (void) setImplementation:(wxMenuItemImpl*) item; | |
346 | - (wxMenuItemImpl*) implementation; | |
347 | ||
348 | - (void)clickedAction:(id)sender; | |
349 | - (BOOL)validateMenuItem:(NSMenuItem *)menuItem; | |
350 | ||
03647350 VZ |
351 | @end |
352 | ||
485c6263 | 353 | void WXDLLIMPEXP_CORE wxOSXCocoaClassAddWXMethods(Class c); |
b466e85a | 354 | |
724999ee KO |
355 | /* |
356 | We need this for ShowModal, as the sheet just disables the parent window and | |
357 | returns control to the app, whereas we don't want to return from ShowModal | |
358 | until the sheet has been dismissed. | |
359 | */ | |
360 | @interface ModalDialogDelegate : NSObject | |
361 | { | |
362 | BOOL sheetFinished; | |
363 | int resultCode; | |
bfa92264 | 364 | wxDialog* impl; |
724999ee KO |
365 | } |
366 | ||
bfa92264 | 367 | - (void)setImplementation: (wxDialog *)dialog; |
724999ee KO |
368 | - (BOOL)finished; |
369 | - (int)code; | |
370 | - (void)waitForSheetToFinish; | |
371 | - (void)sheetDidEnd:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo; | |
372 | @end | |
373 | ||
374 | ||
4850cc8b SC |
375 | #endif // __OBJC__ |
376 | ||
4849f027 SC |
377 | // NSCursor |
378 | ||
379 | WX_NSCursor wxMacCocoaCreateStockCursor( int cursor_type ); | |
380 | WX_NSCursor wxMacCocoaCreateCursorFromCGImage( CGImageRef cgImageRef, float hotSpotX, float hotSpotY ); | |
381 | void wxMacCocoaSetCursor( WX_NSCursor cursor ); | |
382 | void wxMacCocoaHideCursor(); | |
383 | void wxMacCocoaShowCursor(); | |
384 | ||
385 | typedef struct tagClassicCursor | |
386 | { | |
387 | wxUint16 bits[16]; | |
388 | wxUint16 mask[16]; | |
389 | wxInt16 hotspot[2]; | |
390 | }ClassicCursor; | |
391 | ||
524c47aa SC |
392 | const short kwxCursorBullseye = 0; |
393 | const short kwxCursorBlank = 1; | |
394 | const short kwxCursorPencil = 2; | |
395 | const short kwxCursorMagnifier = 3; | |
396 | const short kwxCursorNoEntry = 4; | |
397 | const short kwxCursorPaintBrush = 5; | |
398 | const short kwxCursorPointRight = 6; | |
399 | const short kwxCursorPointLeft = 7; | |
400 | const short kwxCursorQuestionArrow = 8; | |
401 | const short kwxCursorRightArrow = 9; | |
402 | const short kwxCursorSizeNS = 10; | |
403 | const short kwxCursorSize = 11; | |
404 | const short kwxCursorSizeNESW = 12; | |
405 | const short kwxCursorSizeNWSE = 13; | |
406 | const short kwxCursorRoller = 14; | |
407 | const short kwxCursorLast = kwxCursorRoller; | |
408 | ||
409 | // exposing our fallback cursor map | |
410 | ||
411 | extern ClassicCursor gMacCursors[]; | |
412 | ||
4849f027 SC |
413 | #endif |
414 | ||
415 | #endif | |
416 | // _WX_PRIVATE_COCOA_H_ | |
417 |