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