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