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