]> git.saurik.com Git - wxWidgets.git/blame - include/wx/osx/cocoa/private.h
Fix wxPropertyGrid::GetPropertyRect when the last item is collapsed.
[wxWidgets.git] / include / wx / osx / cocoa / private.h
CommitLineData
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
4849f027
SC
9// Copyright: (c) Stefan Csomor
10// Licence: wxWindows licence
11/////////////////////////////////////////////////////////////////////////////
12
13#ifndef _WX_PRIVATE_COCOA_H_
14#define _WX_PRIVATE_COCOA_H_
15
935e6c7d
SC
16#include <ApplicationServices/ApplicationServices.h>
17
4849f027 18#ifdef __OBJC__
4849f027 19 #import <Cocoa/Cocoa.h>
4850cc8b 20#endif
4849f027 21
126254a8
SC
22#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5
23// available in 10.4 but not in the headers
24enum {
25 kEventMouseScroll = 11
26};
27#endif
524c47aa
SC
28//
29// shared between Cocoa and Carbon
30//
31
b3b17ee7 32// bring in theming types without pulling in the headers
524c47aa 33
935e6c7d 34#if wxUSE_GUI
524c47aa 35typedef SInt16 ThemeBrush;
6da991db 36CGColorRef WXDLLIMPEXP_CORE wxMacCreateCGColorFromHITheme( ThemeBrush brush ) ;
524c47aa
SC
37OSStatus WXDLLIMPEXP_CORE wxMacDrawCGImage(
38 CGContextRef inContext,
39 const CGRect * inBounds,
40 CGImageRef inImage) ;
c944835a
SC
41WX_NSImage WXDLLIMPEXP_CORE wxOSXGetNSImageFromCGImage( CGImageRef image, double scale = 1.0 );
42CGImageRef WXDLLIMPEXP_CORE wxOSXCreateCGImageFromNSImage( WX_NSImage nsimage, double *scale = NULL );
43CGContextRef WXDLLIMPEXP_CORE wxOSXCreateBitmapContextFromNSImage( WX_NSImage nsimage);
44
ca9eebc3 45wxBitmap WXDLLIMPEXP_CORE wxOSXCreateSystemBitmap(const wxString& id, const wxString &client, const wxSize& size);
78f21217 46WXWindow WXDLLIMPEXP_CORE wxOSXGetMainWindow();
524c47aa 47
bfa92264
KO
48class WXDLLIMPEXP_FWD_CORE wxDialog;
49
4849f027
SC
50class WXDLLIMPEXP_CORE wxWidgetCocoaImpl : public wxWidgetImpl
51{
52public :
415f4a01 53 wxWidgetCocoaImpl( wxWindowMac* peer , WXWidget w, bool isRootControl = false, bool isUserPane = false ) ;
03647350
VZ
54 wxWidgetCocoaImpl() ;
55 ~wxWidgetCocoaImpl();
56
4849f027 57 void Init();
03647350 58
4849f027 59 virtual bool IsVisible() const ;
524c47aa
SC
60 virtual void SetVisibility(bool);
61
ab9a0b84
VZ
62 // we provide a static function which can be reused from
63 // wxNonOwnedWindowCocoaImpl too
64 static bool ShowViewOrWindowWithEffect(wxWindow *win,
65 bool show,
66 wxShowEffect effect,
67 unsigned timeout);
68
69 virtual bool ShowWithEffect(bool show,
70 wxShowEffect effect,
71 unsigned timeout);
72
4849f027 73 virtual void Raise();
03647350 74
4849f027
SC
75 virtual void Lower();
76
77 virtual void ScrollRect( const wxRect *rect, int dx, int dy );
78
79 virtual WXWidget GetWXWidget() const { return m_osxView; }
80
524c47aa 81 virtual void SetBackgroundColour(const wxColour&);
bc5c09a3 82 virtual bool SetBackgroundStyle(wxBackgroundStyle style);
524c47aa 83
4849f027
SC
84 virtual void GetContentArea( int &left , int &top , int &width , int &height ) const;
85 virtual void Move(int x, int y, int width, int height);
86 virtual void GetPosition( int &x, int &y ) const;
87 virtual void GetSize( int &width, int &height ) const;
524c47aa 88 virtual void SetControlSize( wxWindowVariant variant );
4849f027
SC
89
90 virtual void SetNeedsDisplay( const wxRect* where = NULL );
91 virtual bool GetNeedsDisplay() const;
92
2ab38025
SC
93 virtual void SetDrawingEnabled(bool enabled);
94
4849f027
SC
95 virtual bool CanFocus() const;
96 // return true if successful
97 virtual bool SetFocus();
98 virtual bool HasFocus() const;
99
100 void RemoveFromParent();
101 void Embed( wxWidgetImpl *parent );
524c47aa
SC
102
103 void SetDefaultButton( bool isDefault );
104 void PerformClick();
a4e32492 105 virtual void SetLabel(const wxString& title, wxFontEncoding encoding);
524c47aa 106
54f11060
SC
107 void SetCursor( const wxCursor & cursor );
108 void CaptureMouse();
109 void ReleaseMouse();
110
14de8214
SC
111 void SetDropTarget(wxDropTarget* target);
112
524c47aa
SC
113 wxInt32 GetValue() const;
114 void SetValue( wxInt32 v );
e5d05b90 115 wxBitmap GetBitmap() const;
524c47aa 116 void SetBitmap( const wxBitmap& bitmap );
e5d05b90 117 void SetBitmapPosition( wxDirection dir );
524c47aa
SC
118 void SetupTabs( const wxNotebook &notebook );
119 void GetBestRect( wxRect *r ) const;
120 bool IsEnabled() const;
121 void Enable( bool enable );
122 bool ButtonClickDidStateChange() { return true ;}
123 void SetMinimum( wxInt32 v );
124 void SetMaximum( wxInt32 v );
19c7ac3d
SC
125 wxInt32 GetMinimum() const;
126 wxInt32 GetMaximum() const;
524c47aa
SC
127 void PulseGauge();
128 void SetScrollThumb( wxInt32 value, wxInt32 thumbSize );
129
1e181c7a 130 void SetFont( const wxFont & font , const wxColour& foreground , long windowStyle, bool ignoreBlack = true );
a7b9865d 131 void SetToolTip( wxToolTip* tooltip );
1e181c7a 132
c4825ef7 133 void InstallEventHandler( WXWidget control = NULL );
03647350
VZ
134
135 virtual bool DoHandleMouseEvent(NSEvent *event);
f0e0116e
KO
136 virtual bool DoHandleKeyEvent(NSEvent *event);
137 virtual bool DoHandleCharEvent(NSEvent *event, NSString *text);
03647350 138 virtual void DoNotifyFocusEvent(bool receivedFocus, wxWidgetImpl* otherWindow);
030495ec 139
ddbc8ac9
SC
140 virtual void SetupKeyEvent(wxKeyEvent &wxevent, NSEvent * nsEvent, NSString* charString = NULL);
141 virtual void SetupMouseEvent(wxMouseEvent &wxevent, NSEvent * nsEvent);
094fa9e9
SC
142 void SetupCoordinates(wxCoord &x, wxCoord &y, NSEvent *nsEvent);
143 virtual bool SetupCursor(NSEvent* event);
ddbc8ac9 144
4850cc8b 145
c551dc29 146#if !wxOSX_USE_NATIVE_FLIPPED
4dd9fdf8 147 void SetFlipped(bool flipped);
ee032c59 148 virtual bool IsFlipped() const { return m_isFlipped; }
c551dc29 149#endif
96defed0 150
f082dcd5
SC
151 virtual double GetContentScaleFactor() const;
152
96defed0 153 // cocoa thunk connected calls
4dd9fdf8
SC
154
155 virtual unsigned int draggingEntered(void* sender, WXWidget slf, void* _cmd);
156 virtual void draggingExited(void* sender, WXWidget slf, void* _cmd);
157 virtual unsigned int draggingUpdated(void* sender, WXWidget slf, void* _cmd);
158 virtual bool performDragOperation(void* sender, WXWidget slf, void* _cmd);
159 virtual void mouseEvent(WX_NSEvent event, WXWidget slf, void* _cmd);
3a176763 160 virtual void cursorUpdate(WX_NSEvent event, WXWidget slf, void* _cmd);
4dd9fdf8 161 virtual void keyEvent(WX_NSEvent event, WXWidget slf, void* _cmd);
f0e0116e 162 virtual void insertText(NSString* text, WXWidget slf, void* _cmd);
4dd9fdf8 163 virtual bool performKeyEquivalent(WX_NSEvent event, WXWidget slf, void* _cmd);
09a9eb20 164 virtual bool acceptsFirstResponder(WXWidget slf, void* _cmd);
4dd9fdf8
SC
165 virtual bool becomeFirstResponder(WXWidget slf, void* _cmd);
166 virtual bool resignFirstResponder(WXWidget slf, void* _cmd);
c551dc29 167#if !wxOSX_USE_NATIVE_FLIPPED
4dd9fdf8 168 virtual bool isFlipped(WXWidget slf, void* _cmd);
c551dc29 169#endif
4dd9fdf8 170 virtual void drawRect(void* rect, WXWidget slf, void* _cmd);
03647350 171
e32090ba
SC
172 virtual void controlAction(WXWidget slf, void* _cmd, void* sender);
173 virtual void controlDoubleAction(WXWidget slf, void* _cmd, void *sender);
ce00f59b 174
75a2c6a1
KO
175 // for wxTextCtrl-derived classes, put here since they don't all derive
176 // from the same pimpl class.
177 virtual void controlTextDidChange();
4dd9fdf8 178
4849f027
SC
179protected:
180 WXWidget m_osxView;
f0e0116e 181 NSEvent* m_lastKeyDownEvent;
c551dc29 182#if !wxOSX_USE_NATIVE_FLIPPED
4dd9fdf8 183 bool m_isFlipped;
c551dc29 184#endif
7cb2a241 185 // if it the control has an editor, that editor will already send some
03647350 186 // events, don't resend them
7cb2a241 187 bool m_hasEditor;
03647350 188
4849f027
SC
189 DECLARE_DYNAMIC_CLASS_NO_COPY(wxWidgetCocoaImpl)
190};
191
ffad7b0d
SC
192DECLARE_WXCOCOA_OBJC_CLASS( wxNSWindow );
193
4849f027
SC
194class wxNonOwnedWindowCocoaImpl : public wxNonOwnedWindowImpl
195{
196public :
197 wxNonOwnedWindowCocoaImpl( wxNonOwnedWindow* nonownedwnd) ;
198 wxNonOwnedWindowCocoaImpl();
03647350 199
4849f027 200 virtual ~wxNonOwnedWindowCocoaImpl();
03647350 201
0aaa6ace 202 virtual void WillBeDestroyed() ;
4849f027
SC
203 void Create( wxWindow* parent, const wxPoint& pos, const wxSize& size,
204 long style, long extraStyle, const wxString& name ) ;
17e2694c 205 void Create( wxWindow* parent, WXWindow nativeWindow );
03647350 206
4849f027 207 WXWindow GetWXWindow() const;
03647350 208 void Raise();
4849f027 209 void Lower();
03647350 210 bool Show(bool show);
ab9a0b84
VZ
211
212 virtual bool ShowWithEffect(bool show,
213 wxShowEffect effect,
214 unsigned timeout);
03647350 215
4849f027
SC
216 void Update();
217 bool SetTransparent(wxByte alpha);
218 bool SetBackgroundColour(const wxColour& col );
03647350 219 void SetExtraStyle( long exStyle );
b6dc21e7 220 void SetWindowStyleFlag( long style );
03647350 221 bool SetBackgroundStyle(wxBackgroundStyle style);
4849f027
SC
222 bool CanSetTransparent();
223
224 void MoveWindow(int x, int y, int width, int height);
225 void GetPosition( int &x, int &y ) const;
226 void GetSize( int &width, int &height ) const;
227
03647350 228 void GetContentArea( int &left , int &top , int &width , int &height ) const;
4849f027 229 bool SetShape(const wxRegion& region);
03647350 230
4849f027 231 virtual void SetTitle( const wxString& title, wxFontEncoding encoding ) ;
03647350 232
4849f027 233 virtual bool IsMaximized() const;
03647350 234
4849f027 235 virtual bool IsIconized() const;
03647350 236
4849f027 237 virtual void Iconize( bool iconize );
03647350 238
4849f027 239 virtual void Maximize(bool maximize);
03647350 240
4849f027 241 virtual bool IsFullScreen() const;
03647350 242
4849f027 243 virtual bool ShowFullScreen(bool show, long style);
030495ec 244
dbc7ceb9 245 virtual void ShowWithoutActivating();
4849f027
SC
246
247 virtual void RequestUserAttention(int flags);
03647350 248
4849f027 249 virtual void ScreenToWindow( int *x, int *y );
03647350 250
4849f027 251 virtual void WindowToScreen( int *x, int *y );
03647350 252
dbc7ceb9 253 virtual bool IsActive();
ce00f59b 254
efb2fa41 255 virtual void SetModified(bool modified);
ebf7d5c4 256 virtual bool IsModified() const;
030495ec 257
6a0e4ead
VZ
258 virtual void SetRepresentedFilename(const wxString& filename);
259
4849f027 260 wxNonOwnedWindow* GetWXPeer() { return m_wxPeer; }
9d243a47
SC
261
262 CGWindowLevel GetWindowLevel() const { return m_macWindowLevel; }
263 void RestoreWindowLevel();
60d66be3
SC
264
265 static WX_NSResponder GetNextFirstResponder() ;
4849f027 266protected :
9d243a47 267 CGWindowLevel m_macWindowLevel;
447e2772
SC
268 WXWindow m_macWindow;
269 void * m_macFullScreenData ;
4849f027 270 DECLARE_DYNAMIC_CLASS_NO_COPY(wxNonOwnedWindowCocoaImpl)
03647350 271};
4849f027 272
a1b719bc
SC
273DECLARE_WXCOCOA_OBJC_CLASS( wxNSButton );
274
275class wxButtonCocoaImpl : public wxWidgetCocoaImpl, public wxButtonImpl
276{
277public:
278 wxButtonCocoaImpl(wxWindowMac *wxpeer, wxNSButton *v);
279 virtual void SetBitmap(const wxBitmap& bitmap);
280#if wxUSE_MARKUP
281 virtual void SetLabelMarkup(const wxString& markup);
282#endif // wxUSE_MARKUP
283
284 void SetPressedBitmap( const wxBitmap& bitmap );
285 void GetLayoutInset(int &left , int &top , int &right, int &bottom) const;
2ab67385
SC
286 void SetAcceleratorFromLabel(const wxString& label);
287
a1b719bc
SC
288 NSButton *GetNSButton() const;
289};
290
4850cc8b 291#ifdef __OBJC__
13167e72
SC
292 typedef void (*wxOSX_TextEventHandlerPtr)(NSView* self, SEL _cmd, NSString *event);
293 typedef void (*wxOSX_EventHandlerPtr)(NSView* self, SEL _cmd, NSEvent *event);
294 typedef BOOL (*wxOSX_PerformKeyEventHandlerPtr)(NSView* self, SEL _cmd, NSEvent *event);
295 typedef BOOL (*wxOSX_FocusHandlerPtr)(NSView* self, SEL _cmd);
296
4850cc8b 297
5d57348e 298 WXDLLIMPEXP_CORE NSScreen* wxOSXGetMenuScreen();
2acc3915
SC
299 WXDLLIMPEXP_CORE NSRect wxToNSRect( NSView* parent, const wxRect& r );
300 WXDLLIMPEXP_CORE wxRect wxFromNSRect( NSView* parent, const NSRect& rect );
301 WXDLLIMPEXP_CORE NSPoint wxToNSPoint( NSView* parent, const wxPoint& p );
302 WXDLLIMPEXP_CORE wxPoint wxFromNSPoint( NSView* parent, const NSPoint& p );
03647350
VZ
303
304 NSRect WXDLLIMPEXP_CORE wxOSXGetFrameForControl( wxWindowMac* window , const wxPoint& pos , const wxSize &size ,
4850cc8b 305 bool adjustForOrigin = true );
03647350 306
ba0cf6af
SC
307 WXDLLIMPEXP_CORE NSView* wxOSXGetViewFromResponder( NSResponder* responder );
308
b466e85a 309 // used for many wxControls
03647350 310
b466e85a
SC
311 @interface wxNSButton : NSButton
312 {
411a1c35 313 NSTrackingRectTag rectTag;
b466e85a 314 }
03647350 315
b466e85a
SC
316 @end
317
318 @interface wxNSBox : NSBox
319 {
b466e85a
SC
320 }
321
b466e85a
SC
322 @end
323
7cb2a241
SC
324 @interface wxNSTextFieldEditor : NSTextView
325 {
326 NSEvent* lastKeyDownEvent;
327 }
328
329 @end
330
c8fdb345 331 @interface wxNSTextField : NSTextField wxOSX_10_6_AND_LATER(<NSTextFieldDelegate>)
7cb2a241
SC
332 {
333 wxNSTextFieldEditor* fieldEditor;
334 }
335
336 - (wxNSTextFieldEditor*) fieldEditor;
337 - (void) setFieldEditor:(wxNSTextFieldEditor*) fieldEditor;
338
339 @end
340
c8fdb345 341 @interface wxNSSecureTextField : NSSecureTextField wxOSX_10_6_AND_LATER(<NSTextFieldDelegate>)
b466e85a 342 {
b466e85a 343 }
7cb2a241
SC
344
345 @end
346
347
030495ec 348 @interface wxNSTextView : NSTextView wxOSX_10_6_AND_LATER(<NSTextViewDelegate>)
7cb2a241
SC
349 {
350 }
030495ec 351
b9cf2753 352 - (void)textDidChange:(NSNotification *)aNotification;
030495ec 353
b466e85a
SC
354 @end
355
d9307d00
SC
356 @interface wxNSComboBox : NSComboBox
357 {
358 wxNSTextFieldEditor* fieldEditor;
359 }
360
361 - (wxNSTextFieldEditor*) fieldEditor;
362 - (void) setFieldEditor:(wxNSTextFieldEditor*) fieldEditor;
363
364 @end
365
366
367
ffad7b0d
SC
368 @interface wxNSMenu : NSMenu
369 {
370 wxMenuImpl* impl;
371 }
372
373 - (void) setImplementation:(wxMenuImpl*) item;
374 - (wxMenuImpl*) implementation;
375
03647350 376 @end
ffad7b0d
SC
377
378 @interface wxNSMenuItem : NSMenuItem
379 {
380 wxMenuItemImpl* impl;
381 }
382
383 - (void) setImplementation:(wxMenuItemImpl*) item;
384 - (wxMenuItemImpl*) implementation;
385
386 - (void)clickedAction:(id)sender;
387 - (BOOL)validateMenuItem:(NSMenuItem *)menuItem;
388
03647350
VZ
389 @end
390
485c6263 391 void WXDLLIMPEXP_CORE wxOSXCocoaClassAddWXMethods(Class c);
b466e85a 392
724999ee
KO
393 /*
394 We need this for ShowModal, as the sheet just disables the parent window and
395 returns control to the app, whereas we don't want to return from ShowModal
396 until the sheet has been dismissed.
397 */
398 @interface ModalDialogDelegate : NSObject
399 {
400 BOOL sheetFinished;
401 int resultCode;
bfa92264 402 wxDialog* impl;
724999ee
KO
403 }
404
bfa92264 405 - (void)setImplementation: (wxDialog *)dialog;
724999ee
KO
406 - (BOOL)finished;
407 - (int)code;
408 - (void)waitForSheetToFinish;
409 - (void)sheetDidEnd:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo;
410 @end
411
040050b8
VZ
412 // This interface must be exported in shared 64 bit multilib build but
413 // using WXEXPORT with Objective C interfaces doesn't work with old (4.0.1)
414 // gcc when using 10.4 SDK. It does work with newer gcc even in 32 bit
415 // builds but seems to be unnecessary there so to avoid the expense of a
416 // configure check verifying if this does work or not with the current
417 // compiler we just only use it for 64 bit builds where this is always
418 // supported.
419 //
420 // NB: Currently this is the only place where we need to export an
421 // interface but if we need to do it elsewhere we should define a
422 // WXEXPORT_OBJC macro once and reuse it in all places it's needed
423 // instead of duplicating this preprocessor check.
424#ifdef __LP64__
425 WXEXPORT
426#endif // 64 bit builds
427 @interface wxNSAppController : NSObject wxOSX_10_6_AND_LATER(<NSApplicationDelegate>)
a5d0c88a
SC
428 {
429 }
430
431 @end
724999ee 432
4850cc8b
SC
433#endif // __OBJC__
434
4849f027
SC
435// NSCursor
436
437WX_NSCursor wxMacCocoaCreateStockCursor( int cursor_type );
438WX_NSCursor wxMacCocoaCreateCursorFromCGImage( CGImageRef cgImageRef, float hotSpotX, float hotSpotY );
439void wxMacCocoaSetCursor( WX_NSCursor cursor );
440void wxMacCocoaHideCursor();
441void wxMacCocoaShowCursor();
442
443typedef struct tagClassicCursor
444{
445 wxUint16 bits[16];
446 wxUint16 mask[16];
447 wxInt16 hotspot[2];
448}ClassicCursor;
449
524c47aa
SC
450const short kwxCursorBullseye = 0;
451const short kwxCursorBlank = 1;
452const short kwxCursorPencil = 2;
453const short kwxCursorMagnifier = 3;
454const short kwxCursorNoEntry = 4;
455const short kwxCursorPaintBrush = 5;
456const short kwxCursorPointRight = 6;
457const short kwxCursorPointLeft = 7;
458const short kwxCursorQuestionArrow = 8;
459const short kwxCursorRightArrow = 9;
460const short kwxCursorSizeNS = 10;
461const short kwxCursorSize = 11;
462const short kwxCursorSizeNESW = 12;
463const short kwxCursorSizeNWSE = 13;
464const short kwxCursorRoller = 14;
4c00ce28
SC
465const short kwxCursorWatch = 15;
466const short kwxCursorLast = kwxCursorWatch;
524c47aa
SC
467
468// exposing our fallback cursor map
469
470extern ClassicCursor gMacCursors[];
471
befe64ed
SC
472extern NSLayoutManager* gNSLayoutManager;
473
4849f027
SC
474#endif
475
476#endif
477 // _WX_PRIVATE_COCOA_H_
478