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