]> git.saurik.com Git - wxWidgets.git/blob - include/wx/osx/cocoa/private.h
hiding the impl type more again
[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 #endif
27
28 #ifdef __OBJC__
29 #import <Cocoa/Cocoa.h>
30 #endif
31
32 //
33 // shared between Cocoa and Carbon
34 //
35
36 // bring in themeing types without pulling in the headers
37
38 #if wxUSE_GUI
39 typedef SInt16 ThemeBrush;
40 CGColorRef WXDLLIMPEXP_CORE wxMacCreateCGColorFromHITheme( ThemeBrush brush ) ;
41 OSStatus WXDLLIMPEXP_CORE wxMacDrawCGImage(
42 CGContextRef inContext,
43 const CGRect * inBounds,
44 CGImageRef inImage) ;
45 WX_NSImage WXDLLIMPEXP_CORE wxOSXCreateNSImageFromCGImage( CGImageRef image );
46 #endif
47
48 long UMAGetSystemVersion() ;
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
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 ;
70 virtual void SetVisibility(bool);
71
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
80 virtual void SetBackgroundColour(const wxColour&);
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 void SetBitmap( const wxBitmap& bitmap );
110 void SetupTabs( const wxNotebook &notebook );
111 void GetBestRect( wxRect *r ) const;
112 bool IsEnabled() const;
113 void Enable( bool enable );
114 bool ButtonClickDidStateChange() { return true ;}
115 void SetMinimum( wxInt32 v );
116 void SetMaximum( wxInt32 v );
117 wxInt32 GetMinimum() const;
118 wxInt32 GetMaximum() const;
119 void PulseGauge();
120 void SetScrollThumb( wxInt32 value, wxInt32 thumbSize );
121
122 void SetFont( const wxFont & font , const wxColour& foreground , long windowStyle, bool ignoreBlack = true );
123
124 void InstallEventHandler( WXWidget control = NULL );
125
126 virtual bool DoHandleMouseEvent(NSEvent *event);
127 virtual bool DoHandleKeyEvent(NSEvent *event);
128 virtual bool DoHandleCharEvent(NSEvent *event, NSString *text);
129 virtual void DoNotifyFocusEvent(bool receivedFocus, wxWidgetImpl* otherWindow);
130
131 void SetFlipped(bool flipped);
132 virtual bool IsFlipped() const { return m_isFlipped; }
133
134 // cocoa thunk connected calls
135
136 virtual unsigned int draggingEntered(void* sender, WXWidget slf, void* _cmd);
137 virtual void draggingExited(void* sender, WXWidget slf, void* _cmd);
138 virtual unsigned int draggingUpdated(void* sender, WXWidget slf, void* _cmd);
139 virtual bool performDragOperation(void* sender, WXWidget slf, void* _cmd);
140 virtual void mouseEvent(WX_NSEvent event, WXWidget slf, void* _cmd);
141 virtual void keyEvent(WX_NSEvent event, WXWidget slf, void* _cmd);
142 virtual void insertText(NSString* text, WXWidget slf, void* _cmd);
143 virtual bool performKeyEquivalent(WX_NSEvent event, WXWidget slf, void* _cmd);
144 virtual bool acceptsFirstResponder(WXWidget slf, void* _cmd);
145 virtual bool becomeFirstResponder(WXWidget slf, void* _cmd);
146 virtual bool resignFirstResponder(WXWidget slf, void* _cmd);
147 virtual void resetCursorRects(WXWidget slf, void* _cmd);
148 virtual bool isFlipped(WXWidget slf, void* _cmd);
149 virtual void drawRect(void* rect, WXWidget slf, void* _cmd);
150
151 virtual void controlAction(WXWidget slf, void* _cmd, void* sender);
152 virtual void controlDoubleAction(WXWidget slf, void* _cmd, void *sender);
153
154 protected:
155 WXWidget m_osxView;
156 NSEvent* m_lastKeyDownEvent;
157 bool m_isFlipped;
158
159 DECLARE_DYNAMIC_CLASS_NO_COPY(wxWidgetCocoaImpl)
160 };
161
162 DECLARE_WXCOCOA_OBJC_CLASS( wxNSWindow );
163
164 class wxNonOwnedWindowCocoaImpl : public wxNonOwnedWindowImpl
165 {
166 public :
167 wxNonOwnedWindowCocoaImpl( wxNonOwnedWindow* nonownedwnd) ;
168 wxNonOwnedWindowCocoaImpl();
169
170 virtual ~wxNonOwnedWindowCocoaImpl();
171
172 virtual void Destroy() ;
173 void Create( wxWindow* parent, const wxPoint& pos, const wxSize& size,
174 long style, long extraStyle, const wxString& name ) ;
175
176 WXWindow GetWXWindow() const;
177 void Raise();
178 void Lower();
179 bool Show(bool show);
180 bool ShowWithEffect(bool show, wxShowEffect effect, unsigned timeout);
181
182 void Update();
183 bool SetTransparent(wxByte alpha);
184 bool SetBackgroundColour(const wxColour& col );
185 void SetExtraStyle( long exStyle );
186 bool SetBackgroundStyle(wxBackgroundStyle style);
187 bool CanSetTransparent();
188
189 void MoveWindow(int x, int y, int width, int height);
190 void GetPosition( int &x, int &y ) const;
191 void GetSize( int &width, int &height ) const;
192
193 void GetContentArea( int &left , int &top , int &width , int &height ) const;
194 bool SetShape(const wxRegion& region);
195
196 virtual void SetTitle( const wxString& title, wxFontEncoding encoding ) ;
197
198 virtual bool IsMaximized() const;
199
200 virtual bool IsIconized() const;
201
202 virtual void Iconize( bool iconize );
203
204 virtual void Maximize(bool maximize);
205
206 virtual bool IsFullScreen() const;
207
208 virtual bool ShowFullScreen(bool show, long style);
209
210 virtual void RequestUserAttention(int flags);
211
212 virtual void ScreenToWindow( int *x, int *y );
213
214 virtual void WindowToScreen( int *x, int *y );
215
216 wxNonOwnedWindow* GetWXPeer() { return m_wxPeer; }
217 protected :
218 WX_wxNSWindow m_macWindow;
219 void * m_macFullScreenData ;
220 DECLARE_DYNAMIC_CLASS_NO_COPY(wxNonOwnedWindowCocoaImpl)
221 };
222
223 #ifdef __OBJC__
224
225 extern NSRect wxToNSRect( NSView* parent, const wxRect& r );
226 extern wxRect wxFromNSRect( NSView* parent, const NSRect& rect );
227 extern NSPoint wxToNSPoint( NSView* parent, const wxPoint& p );
228 extern wxPoint wxFromNSPoint( NSView* parent, const NSPoint& p );
229
230 NSRect WXDLLIMPEXP_CORE wxOSXGetFrameForControl( wxWindowMac* window , const wxPoint& pos , const wxSize &size ,
231 bool adjustForOrigin = true );
232
233 // used for many wxControls
234
235 @interface wxNSButton : NSButton
236 {
237 }
238
239 @end
240
241 @interface wxNSBox : NSBox
242 {
243 }
244
245 @end
246
247 @interface wxNSTextField : NSTextField
248 {
249 }
250 @end
251
252 @interface wxNSMenu : NSMenu
253 {
254 wxMenuImpl* impl;
255 }
256
257 - (void) setImplementation:(wxMenuImpl*) item;
258 - (wxMenuImpl*) implementation;
259
260 @end
261
262 @interface wxNSMenuItem : NSMenuItem
263 {
264 wxMenuItemImpl* impl;
265 }
266
267 - (void) setImplementation:(wxMenuItemImpl*) item;
268 - (wxMenuItemImpl*) implementation;
269
270 - (void)clickedAction:(id)sender;
271 - (BOOL)validateMenuItem:(NSMenuItem *)menuItem;
272
273 @end
274
275 void WXDLLIMPEXP_CORE wxOSXCocoaClassAddWXMethods(Class c);
276
277 /*
278 We need this for ShowModal, as the sheet just disables the parent window and
279 returns control to the app, whereas we don't want to return from ShowModal
280 until the sheet has been dismissed.
281 */
282 @interface ModalDialogDelegate : NSObject
283 {
284 BOOL sheetFinished;
285 int resultCode;
286 }
287
288 - (BOOL)finished;
289 - (int)code;
290 - (void)waitForSheetToFinish;
291 - (void)sheetDidEnd:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo;
292 @end
293
294
295 #endif // __OBJC__
296
297 // NSCursor
298
299 WX_NSCursor wxMacCocoaCreateStockCursor( int cursor_type );
300 WX_NSCursor wxMacCocoaCreateCursorFromCGImage( CGImageRef cgImageRef, float hotSpotX, float hotSpotY );
301 void wxMacCocoaSetCursor( WX_NSCursor cursor );
302 void wxMacCocoaHideCursor();
303 void wxMacCocoaShowCursor();
304
305 typedef struct tagClassicCursor
306 {
307 wxUint16 bits[16];
308 wxUint16 mask[16];
309 wxInt16 hotspot[2];
310 }ClassicCursor;
311
312 const short kwxCursorBullseye = 0;
313 const short kwxCursorBlank = 1;
314 const short kwxCursorPencil = 2;
315 const short kwxCursorMagnifier = 3;
316 const short kwxCursorNoEntry = 4;
317 const short kwxCursorPaintBrush = 5;
318 const short kwxCursorPointRight = 6;
319 const short kwxCursorPointLeft = 7;
320 const short kwxCursorQuestionArrow = 8;
321 const short kwxCursorRightArrow = 9;
322 const short kwxCursorSizeNS = 10;
323 const short kwxCursorSize = 11;
324 const short kwxCursorSizeNESW = 12;
325 const short kwxCursorSizeNWSE = 13;
326 const short kwxCursorRoller = 14;
327 const short kwxCursorLast = kwxCursorRoller;
328
329 // exposing our fallback cursor map
330
331 extern ClassicCursor gMacCursors[];
332
333 #endif
334
335 #endif
336 // _WX_PRIVATE_COCOA_H_
337