]> git.saurik.com Git - wxWidgets.git/blob - include/wx/osx/cocoa/private.h
The GL library needs access to this.
[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 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 void DoNotifyFocusEvent(bool receivedFocus);
129
130 void SetFlipped(bool flipped);
131
132 virtual unsigned int draggingEntered(void* sender, WXWidget slf, void* _cmd);
133 virtual void draggingExited(void* sender, WXWidget slf, void* _cmd);
134 virtual unsigned int draggingUpdated(void* sender, WXWidget slf, void* _cmd);
135 virtual bool performDragOperation(void* sender, WXWidget slf, void* _cmd);
136 virtual void mouseEvent(WX_NSEvent event, WXWidget slf, void* _cmd);
137 virtual void keyEvent(WX_NSEvent event, WXWidget slf, void* _cmd);
138 virtual bool performKeyEquivalent(WX_NSEvent event, WXWidget slf, void* _cmd);
139 virtual bool becomeFirstResponder(WXWidget slf, void* _cmd);
140 virtual bool resignFirstResponder(WXWidget slf, void* _cmd);
141 virtual void resetCursorRects(WXWidget slf, void* _cmd);
142 virtual bool isFlipped(WXWidget slf, void* _cmd);
143 virtual void drawRect(void* rect, WXWidget slf, void* _cmd);
144
145 virtual void clickedAction(WXWidget slf, void* _cmd, void* sender);
146 virtual void doubleClickedAction(WXWidget slf, void* _cmd, void *sender);
147
148 protected:
149 WXWidget m_osxView;
150 bool m_isFlipped;
151
152 DECLARE_DYNAMIC_CLASS_NO_COPY(wxWidgetCocoaImpl)
153 };
154
155 DECLARE_WXCOCOA_OBJC_CLASS( wxNSWindow );
156
157 class wxNonOwnedWindowCocoaImpl : public wxNonOwnedWindowImpl
158 {
159 public :
160 wxNonOwnedWindowCocoaImpl( wxNonOwnedWindow* nonownedwnd) ;
161 wxNonOwnedWindowCocoaImpl();
162
163 virtual ~wxNonOwnedWindowCocoaImpl();
164
165 virtual void Destroy() ;
166 void Create( wxWindow* parent, const wxPoint& pos, const wxSize& size,
167 long style, long extraStyle, const wxString& name ) ;
168
169 WXWindow GetWXWindow() const;
170 void Raise();
171 void Lower();
172 bool Show(bool show);
173 bool ShowWithEffect(bool show, wxShowEffect effect, unsigned timeout);
174
175 void Update();
176 bool SetTransparent(wxByte alpha);
177 bool SetBackgroundColour(const wxColour& col );
178 void SetExtraStyle( long exStyle );
179 bool SetBackgroundStyle(wxBackgroundStyle style);
180 bool CanSetTransparent();
181
182 void MoveWindow(int x, int y, int width, int height);
183 void GetPosition( int &x, int &y ) const;
184 void GetSize( int &width, int &height ) const;
185
186 void GetContentArea( int &left , int &top , int &width , int &height ) const;
187 bool SetShape(const wxRegion& region);
188
189 virtual void SetTitle( const wxString& title, wxFontEncoding encoding ) ;
190
191 virtual bool IsMaximized() const;
192
193 virtual bool IsIconized() const;
194
195 virtual void Iconize( bool iconize );
196
197 virtual void Maximize(bool maximize);
198
199 virtual bool IsFullScreen() const;
200
201 virtual bool ShowFullScreen(bool show, long style);
202
203 virtual void RequestUserAttention(int flags);
204
205 virtual void ScreenToWindow( int *x, int *y );
206
207 virtual void WindowToScreen( int *x, int *y );
208
209 wxNonOwnedWindow* GetWXPeer() { return m_wxPeer; }
210 protected :
211 WX_wxNSWindow m_macWindow;
212 void * m_macFullScreenData ;
213 DECLARE_DYNAMIC_CLASS_NO_COPY(wxNonOwnedWindowCocoaImpl)
214 };
215
216 #ifdef __OBJC__
217
218 extern NSRect wxToNSRect( NSView* parent, const wxRect& r );
219 extern wxRect wxFromNSRect( NSView* parent, const NSRect& rect );
220 extern NSPoint wxToNSPoint( NSView* parent, const wxPoint& p );
221 extern wxPoint wxFromNSPoint( NSView* parent, const NSPoint& p );
222
223 NSRect WXDLLIMPEXP_CORE wxOSXGetFrameForControl( wxWindowMac* window , const wxPoint& pos , const wxSize &size ,
224 bool adjustForOrigin = true );
225
226 // used for many wxControls
227
228 @interface wxNSButton : NSButton
229 {
230 }
231
232 @end
233
234 @interface wxNSBox : NSBox
235 {
236 }
237
238 @end
239
240 @interface wxNSTextField : NSTextField
241 {
242 }
243
244 @end
245
246 @interface wxNSMenu : NSMenu
247 {
248 wxMenuImpl* impl;
249 }
250
251 - (void) setImplementation:(wxMenuImpl*) item;
252 - (wxMenuImpl*) implementation;
253
254 @end
255
256 @interface wxNSMenuItem : NSMenuItem
257 {
258 wxMenuItemImpl* impl;
259 }
260
261 - (void) setImplementation:(wxMenuItemImpl*) item;
262 - (wxMenuItemImpl*) implementation;
263
264 - (void)clickedAction:(id)sender;
265 - (BOOL)validateMenuItem:(NSMenuItem *)menuItem;
266
267 @end
268
269 void WXDLLIMPEXP_CORE wxOSXCocoaClassAddWXMethods(Class c);
270
271 #endif // __OBJC__
272
273 // NSCursor
274
275 WX_NSCursor wxMacCocoaCreateStockCursor( int cursor_type );
276 WX_NSCursor wxMacCocoaCreateCursorFromCGImage( CGImageRef cgImageRef, float hotSpotX, float hotSpotY );
277 void wxMacCocoaSetCursor( WX_NSCursor cursor );
278 void wxMacCocoaHideCursor();
279 void wxMacCocoaShowCursor();
280
281 typedef struct tagClassicCursor
282 {
283 wxUint16 bits[16];
284 wxUint16 mask[16];
285 wxInt16 hotspot[2];
286 }ClassicCursor;
287
288 const short kwxCursorBullseye = 0;
289 const short kwxCursorBlank = 1;
290 const short kwxCursorPencil = 2;
291 const short kwxCursorMagnifier = 3;
292 const short kwxCursorNoEntry = 4;
293 const short kwxCursorPaintBrush = 5;
294 const short kwxCursorPointRight = 6;
295 const short kwxCursorPointLeft = 7;
296 const short kwxCursorQuestionArrow = 8;
297 const short kwxCursorRightArrow = 9;
298 const short kwxCursorSizeNS = 10;
299 const short kwxCursorSize = 11;
300 const short kwxCursorSizeNESW = 12;
301 const short kwxCursorSizeNWSE = 13;
302 const short kwxCursorRoller = 14;
303 const short kwxCursorLast = kwxCursorRoller;
304
305 // exposing our fallback cursor map
306
307 extern ClassicCursor gMacCursors[];
308
309 #endif
310
311 #endif
312 // _WX_PRIVATE_COCOA_H_
313