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