]> git.saurik.com Git - wxWidgets.git/blob - include/wx/osx/cocoa/private.h
291a549dc43abbb3c32cf7592308a5c71822b7e9
[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 "wx/osx/core/private.h"
18
19 #include "wx/defs.h"
20
21 #include <ApplicationServices/ApplicationServices.h>
22
23 #if wxOSX_USE_ATSU_TEXT
24 // we need theming and atsu
25 #include <Carbon/Carbon.h>
26 #else
27 // we only need theming, if we find a better include replace the following
28 #include <Carbon/Carbon.h>
29 #endif
30
31 #ifdef __OBJC__
32 #import <Cocoa/Cocoa.h>
33 #endif
34
35 //
36 // shared between Cocoa and Carbon
37 //
38
39 // bring in theming types without pulling in the headers
40
41 #if wxUSE_GUI
42 typedef SInt16 ThemeBrush;
43 CGColorRef WXDLLIMPEXP_CORE wxMacCreateCGColorFromHITheme( ThemeBrush brush ) ;
44 OSStatus WXDLLIMPEXP_CORE wxMacDrawCGImage(
45 CGContextRef inContext,
46 const CGRect * inBounds,
47 CGImageRef inImage) ;
48 WX_NSImage WXDLLIMPEXP_CORE wxOSXCreateNSImageFromCGImage( CGImageRef image );
49 #endif
50
51 long UMAGetSystemVersion() ;
52 WXDLLIMPEXP_BASE void wxMacStringToPascal( const wxString&from , StringPtr to );
53 WXDLLIMPEXP_BASE wxString wxMacFSRefToPath( const FSRef *fsRef , CFStringRef additionalPathComponent = NULL );
54 WXDLLIMPEXP_BASE OSStatus wxMacPathToFSRef( const wxString&path , FSRef *fsRef );
55 WXDLLIMPEXP_BASE wxString wxMacHFSUniStrToString( ConstHFSUniStr255Param uniname );
56
57 //
58 //
59 //
60
61 #if wxUSE_GUI
62
63 class WXDLLIMPEXP_CORE wxWidgetCocoaImpl : public wxWidgetImpl
64 {
65 public :
66 wxWidgetCocoaImpl( wxWindowMac* peer , WXWidget w, bool isRootControl = false ) ;
67 wxWidgetCocoaImpl() ;
68 ~wxWidgetCocoaImpl();
69
70 void Init();
71
72 virtual bool IsVisible() const ;
73 virtual void SetVisibility(bool);
74
75 virtual void Raise();
76
77 virtual void Lower();
78
79 virtual void ScrollRect( const wxRect *rect, int dx, int dy );
80
81 virtual WXWidget GetWXWidget() const { return m_osxView; }
82
83 virtual void SetBackgroundColour(const wxColour&);
84
85 virtual void GetContentArea( int &left , int &top , int &width , int &height ) const;
86 virtual void Move(int x, int y, int width, int height);
87 virtual void GetPosition( int &x, int &y ) const;
88 virtual void GetSize( int &width, int &height ) const;
89 virtual void SetControlSize( wxWindowVariant variant );
90
91 virtual void SetNeedsDisplay( const wxRect* where = NULL );
92 virtual bool GetNeedsDisplay() const;
93
94 virtual bool CanFocus() const;
95 // return true if successful
96 virtual bool SetFocus();
97 virtual bool HasFocus() const;
98
99 void RemoveFromParent();
100 void Embed( wxWidgetImpl *parent );
101
102 void SetDefaultButton( bool isDefault );
103 void PerformClick();
104 virtual void SetLabel(const wxString& title, wxFontEncoding encoding);
105
106 void SetCursor( const wxCursor & cursor );
107 void CaptureMouse();
108 void ReleaseMouse();
109
110 wxInt32 GetValue() const;
111 void SetValue( wxInt32 v );
112 wxBitmap GetBitmap() const;
113 void SetBitmap( const wxBitmap& bitmap );
114 void SetBitmapPosition( wxDirection dir );
115 void SetupTabs( const wxNotebook &notebook );
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 );
122 wxInt32 GetMinimum() const;
123 wxInt32 GetMaximum() const;
124 void PulseGauge();
125 void SetScrollThumb( wxInt32 value, wxInt32 thumbSize );
126
127 void SetFont( const wxFont & font , const wxColour& foreground , long windowStyle, bool ignoreBlack = true );
128
129 void InstallEventHandler( WXWidget control = NULL );
130
131 virtual bool DoHandleMouseEvent(NSEvent *event);
132 virtual bool DoHandleKeyEvent(NSEvent *event);
133 virtual bool DoHandleCharEvent(NSEvent *event, NSString *text);
134 virtual void DoNotifyFocusEvent(bool receivedFocus, wxWidgetImpl* otherWindow);
135
136 virtual void SetupKeyEvent(wxKeyEvent &wxevent, NSEvent * nsEvent, NSString* charString = NULL);
137 virtual void SetupMouseEvent(wxMouseEvent &wxevent, NSEvent * nsEvent);
138
139
140 void SetFlipped(bool flipped);
141 virtual bool IsFlipped() const { return m_isFlipped; }
142
143 // cocoa thunk connected calls
144
145 virtual unsigned int draggingEntered(void* sender, WXWidget slf, void* _cmd);
146 virtual void draggingExited(void* sender, WXWidget slf, void* _cmd);
147 virtual unsigned int draggingUpdated(void* sender, WXWidget slf, void* _cmd);
148 virtual bool performDragOperation(void* sender, WXWidget slf, void* _cmd);
149 virtual void mouseEvent(WX_NSEvent event, WXWidget slf, void* _cmd);
150 virtual void keyEvent(WX_NSEvent event, WXWidget slf, void* _cmd);
151 virtual void insertText(NSString* text, WXWidget slf, void* _cmd);
152 virtual bool performKeyEquivalent(WX_NSEvent event, WXWidget slf, void* _cmd);
153 virtual bool acceptsFirstResponder(WXWidget slf, void* _cmd);
154 virtual bool becomeFirstResponder(WXWidget slf, void* _cmd);
155 virtual bool resignFirstResponder(WXWidget slf, void* _cmd);
156 virtual void resetCursorRects(WXWidget slf, void* _cmd);
157 virtual bool isFlipped(WXWidget slf, void* _cmd);
158 virtual void drawRect(void* rect, WXWidget slf, void* _cmd);
159
160 virtual void controlAction(WXWidget slf, void* _cmd, void* sender);
161 virtual void controlDoubleAction(WXWidget slf, void* _cmd, void *sender);
162
163 protected:
164 WXWidget m_osxView;
165 NSEvent* m_lastKeyDownEvent;
166 bool m_isFlipped;
167 // if it the control has an editor, that editor will already send some
168 // events, don't resend them
169 bool m_hasEditor;
170
171 DECLARE_DYNAMIC_CLASS_NO_COPY(wxWidgetCocoaImpl)
172 };
173
174 DECLARE_WXCOCOA_OBJC_CLASS( wxNSWindow );
175
176 class wxNonOwnedWindowCocoaImpl : public wxNonOwnedWindowImpl
177 {
178 public :
179 wxNonOwnedWindowCocoaImpl( wxNonOwnedWindow* nonownedwnd) ;
180 wxNonOwnedWindowCocoaImpl();
181
182 virtual ~wxNonOwnedWindowCocoaImpl();
183
184 virtual void Destroy() ;
185 void Create( wxWindow* parent, const wxPoint& pos, const wxSize& size,
186 long style, long extraStyle, const wxString& name ) ;
187
188 WXWindow GetWXWindow() const;
189 void Raise();
190 void Lower();
191 bool Show(bool show);
192 bool ShowWithEffect(bool show, wxShowEffect effect, unsigned timeout);
193
194 void Update();
195 bool SetTransparent(wxByte alpha);
196 bool SetBackgroundColour(const wxColour& col );
197 void SetExtraStyle( long exStyle );
198 bool SetBackgroundStyle(wxBackgroundStyle style);
199 bool CanSetTransparent();
200
201 void MoveWindow(int x, int y, int width, int height);
202 void GetPosition( int &x, int &y ) const;
203 void GetSize( int &width, int &height ) const;
204
205 void GetContentArea( int &left , int &top , int &width , int &height ) const;
206 bool SetShape(const wxRegion& region);
207
208 virtual void SetTitle( const wxString& title, wxFontEncoding encoding ) ;
209
210 virtual bool IsMaximized() const;
211
212 virtual bool IsIconized() const;
213
214 virtual void Iconize( bool iconize );
215
216 virtual void Maximize(bool maximize);
217
218 virtual bool IsFullScreen() const;
219
220 virtual bool ShowFullScreen(bool show, long style);
221
222 virtual void RequestUserAttention(int flags);
223
224 virtual void ScreenToWindow( int *x, int *y );
225
226 virtual void WindowToScreen( int *x, int *y );
227
228 wxNonOwnedWindow* GetWXPeer() { return m_wxPeer; }
229 protected :
230 WX_wxNSWindow m_macWindow;
231 void * m_macFullScreenData ;
232 DECLARE_DYNAMIC_CLASS_NO_COPY(wxNonOwnedWindowCocoaImpl)
233 };
234
235 #ifdef __OBJC__
236
237 WXDLLIMPEXP_CORE NSRect wxToNSRect( NSView* parent, const wxRect& r );
238 WXDLLIMPEXP_CORE wxRect wxFromNSRect( NSView* parent, const NSRect& rect );
239 WXDLLIMPEXP_CORE NSPoint wxToNSPoint( NSView* parent, const wxPoint& p );
240 WXDLLIMPEXP_CORE wxPoint wxFromNSPoint( NSView* parent, const NSPoint& p );
241
242 NSRect WXDLLIMPEXP_CORE wxOSXGetFrameForControl( wxWindowMac* window , const wxPoint& pos , const wxSize &size ,
243 bool adjustForOrigin = true );
244
245 // used for many wxControls
246
247 @interface wxNSButton : NSButton
248 {
249 }
250
251 @end
252
253 @interface wxNSBox : NSBox
254 {
255 }
256
257 @end
258
259 @interface wxNSTextFieldEditor : NSTextView
260 {
261 NSEvent* lastKeyDownEvent;
262 }
263
264 @end
265
266 @interface wxNSTextField : NSTextField
267 {
268 wxNSTextFieldEditor* fieldEditor;
269 }
270
271 - (wxNSTextFieldEditor*) fieldEditor;
272 - (void) setFieldEditor:(wxNSTextFieldEditor*) fieldEditor;
273
274 @end
275
276 @interface wxNSSecureTextField : NSSecureTextField
277 {
278 }
279
280 @end
281
282
283 @interface wxNSTextView : NSTextView
284 {
285 }
286
287 @end
288
289 @interface wxNSMenu : NSMenu
290 {
291 wxMenuImpl* impl;
292 }
293
294 - (void) setImplementation:(wxMenuImpl*) item;
295 - (wxMenuImpl*) implementation;
296
297 @end
298
299 @interface wxNSMenuItem : NSMenuItem
300 {
301 wxMenuItemImpl* impl;
302 }
303
304 - (void) setImplementation:(wxMenuItemImpl*) item;
305 - (wxMenuItemImpl*) implementation;
306
307 - (void)clickedAction:(id)sender;
308 - (BOOL)validateMenuItem:(NSMenuItem *)menuItem;
309
310 @end
311
312 void WXDLLIMPEXP_CORE wxOSXCocoaClassAddWXMethods(Class c);
313
314 /*
315 We need this for ShowModal, as the sheet just disables the parent window and
316 returns control to the app, whereas we don't want to return from ShowModal
317 until the sheet has been dismissed.
318 */
319 @interface ModalDialogDelegate : NSObject
320 {
321 BOOL sheetFinished;
322 int resultCode;
323 }
324
325 - (BOOL)finished;
326 - (int)code;
327 - (void)waitForSheetToFinish;
328 - (void)sheetDidEnd:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo;
329 @end
330
331
332 #endif // __OBJC__
333
334 // NSCursor
335
336 WX_NSCursor wxMacCocoaCreateStockCursor( int cursor_type );
337 WX_NSCursor wxMacCocoaCreateCursorFromCGImage( CGImageRef cgImageRef, float hotSpotX, float hotSpotY );
338 void wxMacCocoaSetCursor( WX_NSCursor cursor );
339 void wxMacCocoaHideCursor();
340 void wxMacCocoaShowCursor();
341
342 typedef struct tagClassicCursor
343 {
344 wxUint16 bits[16];
345 wxUint16 mask[16];
346 wxInt16 hotspot[2];
347 }ClassicCursor;
348
349 const short kwxCursorBullseye = 0;
350 const short kwxCursorBlank = 1;
351 const short kwxCursorPencil = 2;
352 const short kwxCursorMagnifier = 3;
353 const short kwxCursorNoEntry = 4;
354 const short kwxCursorPaintBrush = 5;
355 const short kwxCursorPointRight = 6;
356 const short kwxCursorPointLeft = 7;
357 const short kwxCursorQuestionArrow = 8;
358 const short kwxCursorRightArrow = 9;
359 const short kwxCursorSizeNS = 10;
360 const short kwxCursorSize = 11;
361 const short kwxCursorSizeNESW = 12;
362 const short kwxCursorSizeNWSE = 13;
363 const short kwxCursorRoller = 14;
364 const short kwxCursorLast = kwxCursorRoller;
365
366 // exposing our fallback cursor map
367
368 extern ClassicCursor gMacCursors[];
369
370 #endif
371
372 #endif
373 // _WX_PRIVATE_COCOA_H_
374