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