]>
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> | |
26 | #endif | |
27 | ||
4849f027 | 28 | #ifdef __OBJC__ |
4849f027 | 29 | #import <Cocoa/Cocoa.h> |
4850cc8b | 30 | #endif |
4849f027 | 31 | |
524c47aa SC |
32 | // |
33 | // shared between Cocoa and Carbon | |
34 | // | |
35 | ||
36 | // bring in themeing types without pulling in the headers | |
37 | ||
935e6c7d | 38 | #if wxUSE_GUI |
524c47aa | 39 | typedef SInt16 ThemeBrush; |
6da991db | 40 | CGColorRef WXDLLIMPEXP_CORE wxMacCreateCGColorFromHITheme( ThemeBrush brush ) ; |
524c47aa SC |
41 | OSStatus WXDLLIMPEXP_CORE wxMacDrawCGImage( |
42 | CGContextRef inContext, | |
43 | const CGRect * inBounds, | |
44 | CGImageRef inImage) ; | |
6da991db | 45 | WX_NSImage WXDLLIMPEXP_CORE wxOSXCreateNSImageFromCGImage( CGImageRef image ); |
935e6c7d | 46 | #endif |
524c47aa | 47 | |
935e6c7d | 48 | long UMAGetSystemVersion() ; |
524c47aa SC |
49 | WXDLLIMPEXP_BASE void wxMacStringToPascal( const wxString&from , StringPtr to ); |
50 | WXDLLIMPEXP_BASE wxString wxMacFSRefToPath( const FSRef *fsRef , CFStringRef additionalPathComponent = NULL ); | |
51 | WXDLLIMPEXP_BASE OSStatus wxMacPathToFSRef( const wxString&path , FSRef *fsRef ); | |
52 | WXDLLIMPEXP_BASE wxString wxMacHFSUniStrToString( ConstHFSUniStr255Param uniname ); | |
53 | ||
54 | // | |
55 | // | |
56 | // | |
57 | ||
4849f027 SC |
58 | #if wxUSE_GUI |
59 | ||
60 | class WXDLLIMPEXP_CORE wxWidgetCocoaImpl : public wxWidgetImpl | |
61 | { | |
62 | public : | |
63 | wxWidgetCocoaImpl( wxWindowMac* peer , WXWidget w, bool isRootControl = false ) ; | |
64 | wxWidgetCocoaImpl() ; | |
65 | ~wxWidgetCocoaImpl(); | |
66 | ||
67 | void Init(); | |
68 | ||
69 | virtual bool IsVisible() const ; | |
524c47aa SC |
70 | virtual void SetVisibility(bool); |
71 | ||
4849f027 SC |
72 | virtual void Raise(); |
73 | ||
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 SC |
80 | virtual void SetBackgroundColour(const wxColour&); |
81 | ||
4849f027 SC |
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; | |
524c47aa | 86 | virtual void SetControlSize( wxWindowVariant variant ); |
4849f027 SC |
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 ); | |
524c47aa SC |
98 | |
99 | void SetDefaultButton( bool isDefault ); | |
100 | void PerformClick(); | |
101 | void SetLabel(const wxString& title, wxFontEncoding encoding); | |
102 | ||
103 | wxInt32 GetValue() const; | |
104 | void SetValue( wxInt32 v ); | |
105 | void SetBitmap( const wxBitmap& bitmap ); | |
106 | void SetupTabs( const wxNotebook ¬ebook ); | |
107 | void GetBestRect( wxRect *r ) const; | |
108 | bool IsEnabled() const; | |
109 | void Enable( bool enable ); | |
110 | bool ButtonClickDidStateChange() { return true ;} | |
111 | void SetMinimum( wxInt32 v ); | |
112 | void SetMaximum( wxInt32 v ); | |
113 | void PulseGauge(); | |
114 | void SetScrollThumb( wxInt32 value, wxInt32 thumbSize ); | |
115 | ||
1e181c7a SC |
116 | void SetFont( const wxFont & font , const wxColour& foreground , long windowStyle, bool ignoreBlack = true ); |
117 | ||
c4825ef7 | 118 | void InstallEventHandler( WXWidget control = NULL ); |
4850cc8b | 119 | |
b466e85a | 120 | virtual bool DoHandleMouseEvent(NSEvent *event); |
ffad7b0d | 121 | virtual bool DoHandleKeyEvent(NSEvent *event); |
0c530e5a | 122 | virtual void DoNotifyFocusEvent(bool receivedFocus); |
4850cc8b | 123 | |
4849f027 SC |
124 | protected: |
125 | WXWidget m_osxView; | |
126 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxWidgetCocoaImpl) | |
127 | }; | |
128 | ||
ffad7b0d SC |
129 | DECLARE_WXCOCOA_OBJC_CLASS( wxNSWindow ); |
130 | ||
4849f027 SC |
131 | class wxNonOwnedWindowCocoaImpl : public wxNonOwnedWindowImpl |
132 | { | |
133 | public : | |
134 | wxNonOwnedWindowCocoaImpl( wxNonOwnedWindow* nonownedwnd) ; | |
135 | wxNonOwnedWindowCocoaImpl(); | |
136 | ||
137 | virtual ~wxNonOwnedWindowCocoaImpl(); | |
138 | ||
139 | virtual void Destroy() ; | |
140 | void Create( wxWindow* parent, const wxPoint& pos, const wxSize& size, | |
141 | long style, long extraStyle, const wxString& name ) ; | |
142 | ||
143 | WXWindow GetWXWindow() const; | |
144 | void Raise(); | |
145 | void Lower(); | |
146 | bool Show(bool show); | |
147 | bool ShowWithEffect(bool show, wxShowEffect effect, unsigned timeout); | |
148 | ||
149 | void Update(); | |
150 | bool SetTransparent(wxByte alpha); | |
151 | bool SetBackgroundColour(const wxColour& col ); | |
152 | void SetExtraStyle( long exStyle ); | |
153 | bool SetBackgroundStyle(wxBackgroundStyle style); | |
154 | bool CanSetTransparent(); | |
155 | ||
156 | void MoveWindow(int x, int y, int width, int height); | |
157 | void GetPosition( int &x, int &y ) const; | |
158 | void GetSize( int &width, int &height ) const; | |
159 | ||
160 | void GetContentArea( int &left , int &top , int &width , int &height ) const; | |
161 | bool SetShape(const wxRegion& region); | |
162 | ||
163 | virtual void SetTitle( const wxString& title, wxFontEncoding encoding ) ; | |
164 | ||
165 | virtual bool IsMaximized() const; | |
166 | ||
167 | virtual bool IsIconized() const; | |
168 | ||
169 | virtual void Iconize( bool iconize ); | |
170 | ||
171 | virtual void Maximize(bool maximize); | |
172 | ||
173 | virtual bool IsFullScreen() const; | |
174 | ||
175 | virtual bool ShowFullScreen(bool show, long style); | |
176 | ||
177 | virtual void RequestUserAttention(int flags); | |
178 | ||
179 | virtual void ScreenToWindow( int *x, int *y ); | |
180 | ||
181 | virtual void WindowToScreen( int *x, int *y ); | |
182 | ||
183 | wxNonOwnedWindow* GetWXPeer() { return m_wxPeer; } | |
184 | protected : | |
ffad7b0d | 185 | WX_wxNSWindow m_macWindow; |
4849f027 SC |
186 | void * m_macFullScreenData ; |
187 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxNonOwnedWindowCocoaImpl) | |
188 | }; | |
189 | ||
4850cc8b SC |
190 | #ifdef __OBJC__ |
191 | ||
192 | extern NSRect wxToNSRect( NSView* parent, const wxRect& r ); | |
193 | extern wxRect wxFromNSRect( NSView* parent, const NSRect& rect ); | |
194 | extern NSPoint wxToNSPoint( NSView* parent, const wxPoint& p ); | |
195 | extern wxPoint wxFromNSPoint( NSView* parent, const NSPoint& p ); | |
196 | ||
4850cc8b SC |
197 | NSRect WXDLLIMPEXP_CORE wxOSXGetFrameForControl( wxWindowMac* window , const wxPoint& pos , const wxSize &size , |
198 | bool adjustForOrigin = true ); | |
199 | ||
200 | // common code snippets for cocoa implementations | |
201 | // later to be done using injection in method table | |
202 | ||
0c530e5a | 203 | #define WXCOCOAIMPL_COMMON_EVENTS_INTERFACE -(void)mouseDown:(NSEvent *)event ;\ |
4850cc8b SC |
204 | -(void)rightMouseDown:(NSEvent *)event ;\ |
205 | -(void)otherMouseDown:(NSEvent *)event ;\ | |
206 | -(void)mouseUp:(NSEvent *)event ;\ | |
207 | -(void)rightMouseUp:(NSEvent *)event ;\ | |
208 | -(void)otherMouseUp:(NSEvent *)event ;\ | |
ffad7b0d SC |
209 | - (void)keyDown:(NSEvent *)event;\ |
210 | - (void)keyUp:(NSEvent *)event;\ | |
211 | - (void)flagsChanged:(NSEvent *)event;\ | |
0c530e5a SC |
212 | - (BOOL) becomeFirstResponder;\ |
213 | - (BOOL) resignFirstResponder; | |
4850cc8b | 214 | |
0c530e5a | 215 | #define WXCOCOAIMPL_COMMON_EVENTS_IMPLEMENTATION -(void)mouseDown:(NSEvent *)event \ |
4850cc8b | 216 | {\ |
b466e85a SC |
217 | if ( !impl->DoHandleMouseEvent(event) )\ |
218 | [super mouseDown:event];\ | |
4850cc8b SC |
219 | }\ |
220 | -(void)rightMouseDown:(NSEvent *)event\ | |
221 | {\ | |
b466e85a SC |
222 | if ( !impl->DoHandleMouseEvent(event) )\ |
223 | [super rightMouseDown:event];\ | |
4850cc8b SC |
224 | }\ |
225 | -(void)otherMouseDown:(NSEvent *)event\ | |
226 | {\ | |
b466e85a SC |
227 | if ( !impl->DoHandleMouseEvent(event) )\ |
228 | [super otherMouseDown:event];\ | |
4850cc8b SC |
229 | }\ |
230 | -(void)mouseUp:(NSEvent *)event\ | |
231 | {\ | |
b466e85a SC |
232 | if ( !impl->DoHandleMouseEvent(event) )\ |
233 | [super mouseUp:event];\ | |
4850cc8b SC |
234 | }\ |
235 | -(void)rightMouseUp:(NSEvent *)event\ | |
236 | {\ | |
b466e85a SC |
237 | if ( !impl->DoHandleMouseEvent(event) )\ |
238 | [super rightMouseUp:event];\ | |
4850cc8b SC |
239 | }\ |
240 | -(void)otherMouseUp:(NSEvent *)event\ | |
241 | {\ | |
b466e85a SC |
242 | if ( !impl->DoHandleMouseEvent(event) )\ |
243 | [super otherMouseUp:event];\ | |
ffad7b0d SC |
244 | }\ |
245 | -(void)keyDown:(NSEvent *)event\ | |
246 | {\ | |
247 | if ( !impl->DoHandleKeyEvent(event) )\ | |
248 | [super keyDown:event];\ | |
249 | }\ | |
250 | -(void)keyUp:(NSEvent *)event\ | |
251 | {\ | |
252 | if ( !impl->DoHandleKeyEvent(event) )\ | |
253 | [super keyUp:event];\ | |
254 | }\ | |
255 | -(void)flagsChanged:(NSEvent *)event\ | |
256 | {\ | |
257 | if ( !impl->DoHandleKeyEvent(event) )\ | |
258 | [super flagsChanged:event];\ | |
0c530e5a SC |
259 | }\ |
260 | - (BOOL) becomeFirstResponder\ | |
261 | {\ | |
262 | BOOL r = [super becomeFirstResponder];\ | |
263 | if ( r )\ | |
264 | impl->DoNotifyFocusEvent( true );\ | |
265 | return r;\ | |
266 | }\ | |
267 | - (BOOL) resignFirstResponder\ | |
268 | {\ | |
269 | BOOL r = [super resignFirstResponder];\ | |
270 | if ( r )\ | |
271 | impl->DoNotifyFocusEvent( false );\ | |
272 | return r;\ | |
4850cc8b SC |
273 | } |
274 | ||
b466e85a SC |
275 | #define WXCOCOAIMPL_COMMON_MEMBERS wxWidgetCocoaImpl* impl; |
276 | ||
277 | #define WXCOCOAIMPL_COMMON_INTERFACE \ | |
278 | - (void)setImplementation: (wxWidgetCocoaImpl *) theImplementation;\ | |
279 | - (wxWidgetCocoaImpl*) implementation;\ | |
280 | - (BOOL) isFlipped;\ | |
0c530e5a | 281 | WXCOCOAIMPL_COMMON_EVENTS_INTERFACE |
b466e85a | 282 | |
0c530e5a | 283 | #define WXCOCOAIMPL_COMMON_IMPLEMENTATION WXCOCOAIMPL_COMMON_EVENTS_IMPLEMENTATION \ |
b466e85a SC |
284 | - (void)setImplementation: (wxWidgetCocoaImpl *) theImplementation\ |
285 | {\ | |
286 | impl = theImplementation;\ | |
287 | }\ | |
288 | - (wxWidgetCocoaImpl*) implementation\ | |
289 | {\ | |
290 | return impl;\ | |
291 | }\ | |
292 | - (BOOL) isFlipped\ | |
293 | {\ | |
294 | return YES;\ | |
295 | }\ | |
0c530e5a SC |
296 | |
297 | #define WXCOCOAIMPL_COMMON_IMPLEMENTATION_NOT_FLIPPED WXCOCOAIMPL_COMMON_EVENTS_IMPLEMENTATION \ | |
298 | - (void)setImplementation: (wxWidgetCocoaImpl *) theImplementation\ | |
299 | {\ | |
300 | impl = theImplementation;\ | |
301 | }\ | |
302 | - (wxWidgetCocoaImpl*) implementation\ | |
303 | {\ | |
304 | return impl;\ | |
305 | }\ | |
306 | - (BOOL) isFlipped\ | |
307 | {\ | |
308 | return NO;\ | |
309 | }\ | |
b466e85a SC |
310 | |
311 | // used for many wxControls | |
312 | ||
313 | @interface wxNSButton : NSButton | |
314 | { | |
315 | WXCOCOAIMPL_COMMON_MEMBERS | |
316 | } | |
317 | ||
318 | WXCOCOAIMPL_COMMON_INTERFACE | |
319 | - (void) clickedAction: (id) sender; | |
320 | ||
321 | @end | |
322 | ||
323 | @interface wxNSBox : NSBox | |
324 | { | |
325 | WXCOCOAIMPL_COMMON_MEMBERS | |
326 | } | |
327 | ||
328 | WXCOCOAIMPL_COMMON_INTERFACE | |
329 | ||
330 | @end | |
331 | ||
332 | @interface wxNSTextField : NSTextField | |
333 | { | |
334 | WXCOCOAIMPL_COMMON_MEMBERS | |
335 | } | |
336 | ||
337 | WXCOCOAIMPL_COMMON_INTERFACE | |
338 | ||
339 | @end | |
340 | ||
ffad7b0d SC |
341 | @interface wxNSMenu : NSMenu |
342 | { | |
343 | wxMenuImpl* impl; | |
344 | } | |
345 | ||
346 | - (void) setImplementation:(wxMenuImpl*) item; | |
347 | - (wxMenuImpl*) implementation; | |
348 | ||
349 | @end | |
350 | ||
351 | @interface wxNSMenuItem : NSMenuItem | |
352 | { | |
353 | wxMenuItemImpl* impl; | |
354 | } | |
355 | ||
356 | - (void) setImplementation:(wxMenuItemImpl*) item; | |
357 | - (wxMenuItemImpl*) implementation; | |
358 | ||
359 | - (void)clickedAction:(id)sender; | |
360 | - (BOOL)validateMenuItem:(NSMenuItem *)menuItem; | |
361 | ||
362 | @end | |
b466e85a | 363 | |
4850cc8b SC |
364 | #endif // __OBJC__ |
365 | ||
4849f027 SC |
366 | // NSCursor |
367 | ||
368 | WX_NSCursor wxMacCocoaCreateStockCursor( int cursor_type ); | |
369 | WX_NSCursor wxMacCocoaCreateCursorFromCGImage( CGImageRef cgImageRef, float hotSpotX, float hotSpotY ); | |
370 | void wxMacCocoaSetCursor( WX_NSCursor cursor ); | |
371 | void wxMacCocoaHideCursor(); | |
372 | void wxMacCocoaShowCursor(); | |
373 | ||
374 | typedef struct tagClassicCursor | |
375 | { | |
376 | wxUint16 bits[16]; | |
377 | wxUint16 mask[16]; | |
378 | wxInt16 hotspot[2]; | |
379 | }ClassicCursor; | |
380 | ||
524c47aa SC |
381 | const short kwxCursorBullseye = 0; |
382 | const short kwxCursorBlank = 1; | |
383 | const short kwxCursorPencil = 2; | |
384 | const short kwxCursorMagnifier = 3; | |
385 | const short kwxCursorNoEntry = 4; | |
386 | const short kwxCursorPaintBrush = 5; | |
387 | const short kwxCursorPointRight = 6; | |
388 | const short kwxCursorPointLeft = 7; | |
389 | const short kwxCursorQuestionArrow = 8; | |
390 | const short kwxCursorRightArrow = 9; | |
391 | const short kwxCursorSizeNS = 10; | |
392 | const short kwxCursorSize = 11; | |
393 | const short kwxCursorSizeNESW = 12; | |
394 | const short kwxCursorSizeNWSE = 13; | |
395 | const short kwxCursorRoller = 14; | |
396 | const short kwxCursorLast = kwxCursorRoller; | |
397 | ||
398 | // exposing our fallback cursor map | |
399 | ||
400 | extern ClassicCursor gMacCursors[]; | |
401 | ||
4849f027 SC |
402 | #endif |
403 | ||
404 | #endif | |
405 | // _WX_PRIVATE_COCOA_H_ | |
406 |