]> git.saurik.com Git - wxWidgets.git/blob - include/wx/osx/cocoa/private.h
add watch cursor to osx_cocoa
[wxWidgets.git] / include / wx / osx / cocoa / private.h
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 <ApplicationServices/ApplicationServices.h>
18
19 #ifdef __OBJC__
20 #import <Cocoa/Cocoa.h>
21 #endif
22
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
29 //
30 // shared between Cocoa and Carbon
31 //
32
33 // bring in theming types without pulling in the headers
34
35 #if wxUSE_GUI
36 typedef SInt16 ThemeBrush;
37 CGColorRef WXDLLIMPEXP_CORE wxMacCreateCGColorFromHITheme( ThemeBrush brush ) ;
38 OSStatus WXDLLIMPEXP_CORE wxMacDrawCGImage(
39 CGContextRef inContext,
40 const CGRect * inBounds,
41 CGImageRef inImage) ;
42 WX_NSImage WXDLLIMPEXP_CORE wxOSXGetNSImageFromCGImage( CGImageRef image );
43 CGImageRef WXDLLIMPEXP_CORE wxOSXCreateCGImageFromNSImage( WX_NSImage nsimage );
44 wxBitmap WXDLLIMPEXP_CORE wxOSXCreateSystemBitmap(const wxString& id, const wxString &client, const wxSize& size);
45
46 class WXDLLIMPEXP_FWD_CORE wxDialog;
47
48 class WXDLLIMPEXP_CORE wxWidgetCocoaImpl : public wxWidgetImpl
49 {
50 public :
51 wxWidgetCocoaImpl( wxWindowMac* peer , WXWidget w, bool isRootControl = false ) ;
52 wxWidgetCocoaImpl() ;
53 ~wxWidgetCocoaImpl();
54
55 void Init();
56
57 virtual bool IsVisible() const ;
58 virtual void SetVisibility(bool);
59
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
71 virtual void Raise();
72
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
79 virtual void SetBackgroundColour(const wxColour&);
80 virtual bool SetBackgroundStyle(wxBackgroundStyle style);
81
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;
86 virtual void SetControlSize( wxWindowVariant variant );
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 );
98
99 void SetDefaultButton( bool isDefault );
100 void PerformClick();
101 virtual void SetLabel(const wxString& title, wxFontEncoding encoding);
102
103 void SetCursor( const wxCursor & cursor );
104 void CaptureMouse();
105 void ReleaseMouse();
106
107 wxInt32 GetValue() const;
108 void SetValue( wxInt32 v );
109 wxBitmap GetBitmap() const;
110 void SetBitmap( const wxBitmap& bitmap );
111 void SetBitmapPosition( wxDirection dir );
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 );
119 wxInt32 GetMinimum() const;
120 wxInt32 GetMaximum() const;
121 void PulseGauge();
122 void SetScrollThumb( wxInt32 value, wxInt32 thumbSize );
123
124 void SetFont( const wxFont & font , const wxColour& foreground , long windowStyle, bool ignoreBlack = true );
125 void SetToolTip( wxToolTip* tooltip );
126
127 void InstallEventHandler( WXWidget control = NULL );
128
129 virtual bool DoHandleMouseEvent(NSEvent *event);
130 virtual bool DoHandleKeyEvent(NSEvent *event);
131 virtual bool DoHandleCharEvent(NSEvent *event, NSString *text);
132 virtual void DoNotifyFocusEvent(bool receivedFocus, wxWidgetImpl* otherWindow);
133
134 virtual void SetupKeyEvent(wxKeyEvent &wxevent, NSEvent * nsEvent, NSString* charString = NULL);
135 virtual void SetupMouseEvent(wxMouseEvent &wxevent, NSEvent * nsEvent);
136
137
138 void SetFlipped(bool flipped);
139 virtual bool IsFlipped() const { return m_isFlipped; }
140
141 // cocoa thunk connected calls
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);
149 virtual void insertText(NSString* text, WXWidget slf, void* _cmd);
150 virtual bool performKeyEquivalent(WX_NSEvent event, WXWidget slf, void* _cmd);
151 virtual bool acceptsFirstResponder(WXWidget slf, void* _cmd);
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);
157
158 virtual void controlAction(WXWidget slf, void* _cmd, void* sender);
159 virtual void controlDoubleAction(WXWidget slf, void* _cmd, void *sender);
160
161 // for wxTextCtrl-derived classes, put here since they don't all derive
162 // from the same pimpl class.
163 virtual void controlTextDidChange();
164
165 protected:
166 WXWidget m_osxView;
167 NSEvent* m_lastKeyDownEvent;
168 bool m_isFlipped;
169 // if it the control has an editor, that editor will already send some
170 // events, don't resend them
171 bool m_hasEditor;
172
173 DECLARE_DYNAMIC_CLASS_NO_COPY(wxWidgetCocoaImpl)
174 };
175
176 DECLARE_WXCOCOA_OBJC_CLASS( wxNSWindow );
177
178 class wxNonOwnedWindowCocoaImpl : public wxNonOwnedWindowImpl
179 {
180 public :
181 wxNonOwnedWindowCocoaImpl( wxNonOwnedWindow* nonownedwnd) ;
182 wxNonOwnedWindowCocoaImpl();
183
184 virtual ~wxNonOwnedWindowCocoaImpl();
185
186 virtual void WillBeDestroyed() ;
187 void Create( wxWindow* parent, const wxPoint& pos, const wxSize& size,
188 long style, long extraStyle, const wxString& name ) ;
189 void Create( wxWindow* parent, WXWindow nativeWindow );
190
191 WXWindow GetWXWindow() const;
192 void Raise();
193 void Lower();
194 bool Show(bool show);
195
196 virtual bool ShowWithEffect(bool show,
197 wxShowEffect effect,
198 unsigned timeout);
199
200 void Update();
201 bool SetTransparent(wxByte alpha);
202 bool SetBackgroundColour(const wxColour& col );
203 void SetExtraStyle( long exStyle );
204 void SetWindowStyleFlag( long style );
205 bool SetBackgroundStyle(wxBackgroundStyle style);
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
212 void GetContentArea( int &left , int &top , int &width , int &height ) const;
213 bool SetShape(const wxRegion& region);
214
215 virtual void SetTitle( const wxString& title, wxFontEncoding encoding ) ;
216
217 virtual bool IsMaximized() const;
218
219 virtual bool IsIconized() const;
220
221 virtual void Iconize( bool iconize );
222
223 virtual void Maximize(bool maximize);
224
225 virtual bool IsFullScreen() const;
226
227 virtual bool ShowFullScreen(bool show, long style);
228
229 virtual void ShowWithoutActivating();
230
231 virtual void RequestUserAttention(int flags);
232
233 virtual void ScreenToWindow( int *x, int *y );
234
235 virtual void WindowToScreen( int *x, int *y );
236
237 virtual bool IsActive();
238
239 virtual void SetModified(bool modified);
240 virtual bool IsModified() const;
241
242 wxNonOwnedWindow* GetWXPeer() { return m_wxPeer; }
243 protected :
244 WXWindow m_macWindow;
245 void * m_macFullScreenData ;
246 DECLARE_DYNAMIC_CLASS_NO_COPY(wxNonOwnedWindowCocoaImpl)
247 };
248
249 #ifdef __OBJC__
250
251 WXDLLIMPEXP_CORE NSScreen* wxOSXGetMenuScreen();
252 WXDLLIMPEXP_CORE NSRect wxToNSRect( NSView* parent, const wxRect& r );
253 WXDLLIMPEXP_CORE wxRect wxFromNSRect( NSView* parent, const NSRect& rect );
254 WXDLLIMPEXP_CORE NSPoint wxToNSPoint( NSView* parent, const wxPoint& p );
255 WXDLLIMPEXP_CORE wxPoint wxFromNSPoint( NSView* parent, const NSPoint& p );
256
257 NSRect WXDLLIMPEXP_CORE wxOSXGetFrameForControl( wxWindowMac* window , const wxPoint& pos , const wxSize &size ,
258 bool adjustForOrigin = true );
259
260 // used for many wxControls
261
262 @interface wxNSButton : NSButton
263 {
264 NSTrackingRectTag rectTag;
265 }
266
267 @end
268
269 @interface wxNSBox : NSBox
270 {
271 }
272
273 @end
274
275 @interface wxNSTextFieldEditor : NSTextView
276 {
277 NSEvent* lastKeyDownEvent;
278 }
279
280 @end
281
282 @interface wxNSTextField : NSTextField wxOSX_10_6_AND_LATER(<NSTextFieldDelegate>)
283 {
284 wxNSTextFieldEditor* fieldEditor;
285 }
286
287 - (wxNSTextFieldEditor*) fieldEditor;
288 - (void) setFieldEditor:(wxNSTextFieldEditor*) fieldEditor;
289
290 @end
291
292 @interface wxNSSecureTextField : NSSecureTextField wxOSX_10_6_AND_LATER(<NSTextFieldDelegate>)
293 {
294 }
295
296 @end
297
298
299 @interface wxNSTextView : NSTextView wxOSX_10_6_AND_LATER(<NSTextViewDelegate>)
300 {
301 }
302
303 - (void)textDidChange:(NSNotification *)aNotification;
304
305 @end
306
307 @interface wxNSMenu : NSMenu
308 {
309 wxMenuImpl* impl;
310 }
311
312 - (void) setImplementation:(wxMenuImpl*) item;
313 - (wxMenuImpl*) implementation;
314
315 @end
316
317 @interface wxNSMenuItem : NSMenuItem
318 {
319 wxMenuItemImpl* impl;
320 }
321
322 - (void) setImplementation:(wxMenuItemImpl*) item;
323 - (wxMenuItemImpl*) implementation;
324
325 - (void)clickedAction:(id)sender;
326 - (BOOL)validateMenuItem:(NSMenuItem *)menuItem;
327
328 @end
329
330 void WXDLLIMPEXP_CORE wxOSXCocoaClassAddWXMethods(Class c);
331
332 /*
333 We need this for ShowModal, as the sheet just disables the parent window and
334 returns control to the app, whereas we don't want to return from ShowModal
335 until the sheet has been dismissed.
336 */
337 @interface ModalDialogDelegate : NSObject
338 {
339 BOOL sheetFinished;
340 int resultCode;
341 wxDialog* impl;
342 }
343
344 - (void)setImplementation: (wxDialog *)dialog;
345 - (BOOL)finished;
346 - (int)code;
347 - (void)waitForSheetToFinish;
348 - (void)sheetDidEnd:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo;
349 @end
350
351 @interface wxNSAppController : NSObject wxOSX_10_6_AND_LATER(<NSApplicationDelegate>)
352 {
353 }
354
355 @end
356
357 #endif // __OBJC__
358
359 // NSCursor
360
361 WX_NSCursor wxMacCocoaCreateStockCursor( int cursor_type );
362 WX_NSCursor wxMacCocoaCreateCursorFromCGImage( CGImageRef cgImageRef, float hotSpotX, float hotSpotY );
363 void wxMacCocoaSetCursor( WX_NSCursor cursor );
364 void wxMacCocoaHideCursor();
365 void wxMacCocoaShowCursor();
366
367 typedef struct tagClassicCursor
368 {
369 wxUint16 bits[16];
370 wxUint16 mask[16];
371 wxInt16 hotspot[2];
372 }ClassicCursor;
373
374 const short kwxCursorBullseye = 0;
375 const short kwxCursorBlank = 1;
376 const short kwxCursorPencil = 2;
377 const short kwxCursorMagnifier = 3;
378 const short kwxCursorNoEntry = 4;
379 const short kwxCursorPaintBrush = 5;
380 const short kwxCursorPointRight = 6;
381 const short kwxCursorPointLeft = 7;
382 const short kwxCursorQuestionArrow = 8;
383 const short kwxCursorRightArrow = 9;
384 const short kwxCursorSizeNS = 10;
385 const short kwxCursorSize = 11;
386 const short kwxCursorSizeNESW = 12;
387 const short kwxCursorSizeNWSE = 13;
388 const short kwxCursorRoller = 14;
389 const short kwxCursorWatch = 15;
390 const short kwxCursorLast = kwxCursorWatch;
391
392 // exposing our fallback cursor map
393
394 extern ClassicCursor gMacCursors[];
395
396 #endif
397
398 #endif
399 // _WX_PRIVATE_COCOA_H_
400