]>
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 | ||
935e6c7d SC |
17 | #include <ApplicationServices/ApplicationServices.h> |
18 | ||
4849f027 | 19 | #ifdef __OBJC__ |
4849f027 | 20 | #import <Cocoa/Cocoa.h> |
4850cc8b | 21 | #endif |
4849f027 | 22 | |
126254a8 SC |
23 | #if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5 |
24 | // available in 10.4 but not in the headers | |
25 | enum { | |
26 | kEventMouseScroll = 11 | |
27 | }; | |
28 | #endif | |
524c47aa SC |
29 | // |
30 | // shared between Cocoa and Carbon | |
31 | // | |
32 | ||
b3b17ee7 | 33 | // bring in theming types without pulling in the headers |
524c47aa | 34 | |
935e6c7d | 35 | #if wxUSE_GUI |
524c47aa | 36 | typedef SInt16 ThemeBrush; |
6da991db | 37 | CGColorRef WXDLLIMPEXP_CORE wxMacCreateCGColorFromHITheme( ThemeBrush brush ) ; |
524c47aa SC |
38 | OSStatus WXDLLIMPEXP_CORE wxMacDrawCGImage( |
39 | CGContextRef inContext, | |
40 | const CGRect * inBounds, | |
41 | CGImageRef inImage) ; | |
59d866ad | 42 | WX_NSImage WXDLLIMPEXP_CORE wxOSXGetNSImageFromCGImage( CGImageRef image ); |
267ba369 | 43 | CGImageRef WXDLLIMPEXP_CORE wxOSXCreateCGImageFromNSImage( WX_NSImage nsimage ); |
524c47aa | 44 | |
bfa92264 KO |
45 | class WXDLLIMPEXP_FWD_CORE wxDialog; |
46 | ||
4849f027 SC |
47 | class WXDLLIMPEXP_CORE wxWidgetCocoaImpl : public wxWidgetImpl |
48 | { | |
49 | public : | |
03647350 VZ |
50 | wxWidgetCocoaImpl( wxWindowMac* peer , WXWidget w, bool isRootControl = false ) ; |
51 | wxWidgetCocoaImpl() ; | |
52 | ~wxWidgetCocoaImpl(); | |
53 | ||
4849f027 | 54 | void Init(); |
03647350 | 55 | |
4849f027 | 56 | virtual bool IsVisible() const ; |
524c47aa SC |
57 | virtual void SetVisibility(bool); |
58 | ||
ab9a0b84 VZ |
59 | // we provide a static function which can be reused from |
60 | // wxNonOwnedWindowCocoaImpl too | |
61 | static bool ShowViewOrWindowWithEffect(wxWindow *win, | |
62 | bool show, | |
63 | wxShowEffect effect, | |
64 | unsigned timeout); | |
65 | ||
66 | virtual bool ShowWithEffect(bool show, | |
67 | wxShowEffect effect, | |
68 | unsigned timeout); | |
69 | ||
4849f027 | 70 | virtual void Raise(); |
03647350 | 71 | |
4849f027 SC |
72 | virtual void Lower(); |
73 | ||
74 | virtual void ScrollRect( const wxRect *rect, int dx, int dy ); | |
75 | ||
76 | virtual WXWidget GetWXWidget() const { return m_osxView; } | |
77 | ||
524c47aa | 78 | virtual void SetBackgroundColour(const wxColour&); |
bc5c09a3 | 79 | virtual bool SetBackgroundStyle(wxBackgroundStyle style); |
524c47aa | 80 | |
4849f027 SC |
81 | virtual void GetContentArea( int &left , int &top , int &width , int &height ) const; |
82 | virtual void Move(int x, int y, int width, int height); | |
83 | virtual void GetPosition( int &x, int &y ) const; | |
84 | virtual void GetSize( int &width, int &height ) const; | |
524c47aa | 85 | virtual void SetControlSize( wxWindowVariant variant ); |
4849f027 SC |
86 | |
87 | virtual void SetNeedsDisplay( const wxRect* where = NULL ); | |
88 | virtual bool GetNeedsDisplay() const; | |
89 | ||
90 | virtual bool CanFocus() const; | |
91 | // return true if successful | |
92 | virtual bool SetFocus(); | |
93 | virtual bool HasFocus() const; | |
94 | ||
95 | void RemoveFromParent(); | |
96 | void Embed( wxWidgetImpl *parent ); | |
524c47aa SC |
97 | |
98 | void SetDefaultButton( bool isDefault ); | |
99 | void PerformClick(); | |
a4e32492 | 100 | virtual void SetLabel(const wxString& title, wxFontEncoding encoding); |
524c47aa | 101 | |
54f11060 SC |
102 | void SetCursor( const wxCursor & cursor ); |
103 | void CaptureMouse(); | |
104 | void ReleaseMouse(); | |
105 | ||
524c47aa SC |
106 | wxInt32 GetValue() const; |
107 | void SetValue( wxInt32 v ); | |
e5d05b90 | 108 | wxBitmap GetBitmap() const; |
524c47aa | 109 | void SetBitmap( const wxBitmap& bitmap ); |
e5d05b90 | 110 | void SetBitmapPosition( wxDirection dir ); |
524c47aa SC |
111 | void SetupTabs( const wxNotebook ¬ebook ); |
112 | void GetBestRect( wxRect *r ) const; | |
113 | bool IsEnabled() const; | |
114 | void Enable( bool enable ); | |
115 | bool ButtonClickDidStateChange() { return true ;} | |
116 | void SetMinimum( wxInt32 v ); | |
117 | void SetMaximum( wxInt32 v ); | |
19c7ac3d SC |
118 | wxInt32 GetMinimum() const; |
119 | wxInt32 GetMaximum() const; | |
524c47aa SC |
120 | void PulseGauge(); |
121 | void SetScrollThumb( wxInt32 value, wxInt32 thumbSize ); | |
122 | ||
1e181c7a | 123 | void SetFont( const wxFont & font , const wxColour& foreground , long windowStyle, bool ignoreBlack = true ); |
a7b9865d | 124 | void SetToolTip( wxToolTip* tooltip ); |
1e181c7a | 125 | |
c4825ef7 | 126 | void InstallEventHandler( WXWidget control = NULL ); |
03647350 VZ |
127 | |
128 | virtual bool DoHandleMouseEvent(NSEvent *event); | |
f0e0116e KO |
129 | virtual bool DoHandleKeyEvent(NSEvent *event); |
130 | virtual bool DoHandleCharEvent(NSEvent *event, NSString *text); | |
03647350 | 131 | virtual void DoNotifyFocusEvent(bool receivedFocus, wxWidgetImpl* otherWindow); |
030495ec | 132 | |
ddbc8ac9 SC |
133 | virtual void SetupKeyEvent(wxKeyEvent &wxevent, NSEvent * nsEvent, NSString* charString = NULL); |
134 | virtual void SetupMouseEvent(wxMouseEvent &wxevent, NSEvent * nsEvent); | |
135 | ||
4850cc8b | 136 | |
4dd9fdf8 | 137 | void SetFlipped(bool flipped); |
ee032c59 | 138 | virtual bool IsFlipped() const { return m_isFlipped; } |
96defed0 SC |
139 | |
140 | // cocoa thunk connected calls | |
4dd9fdf8 SC |
141 | |
142 | virtual unsigned int draggingEntered(void* sender, WXWidget slf, void* _cmd); | |
143 | virtual void draggingExited(void* sender, WXWidget slf, void* _cmd); | |
144 | virtual unsigned int draggingUpdated(void* sender, WXWidget slf, void* _cmd); | |
145 | virtual bool performDragOperation(void* sender, WXWidget slf, void* _cmd); | |
146 | virtual void mouseEvent(WX_NSEvent event, WXWidget slf, void* _cmd); | |
147 | virtual void keyEvent(WX_NSEvent event, WXWidget slf, void* _cmd); | |
f0e0116e | 148 | virtual void insertText(NSString* text, WXWidget slf, void* _cmd); |
4dd9fdf8 | 149 | virtual bool performKeyEquivalent(WX_NSEvent event, WXWidget slf, void* _cmd); |
09a9eb20 | 150 | virtual bool acceptsFirstResponder(WXWidget slf, void* _cmd); |
4dd9fdf8 SC |
151 | virtual bool becomeFirstResponder(WXWidget slf, void* _cmd); |
152 | virtual bool resignFirstResponder(WXWidget slf, void* _cmd); | |
153 | virtual void resetCursorRects(WXWidget slf, void* _cmd); | |
154 | virtual bool isFlipped(WXWidget slf, void* _cmd); | |
155 | virtual void drawRect(void* rect, WXWidget slf, void* _cmd); | |
03647350 | 156 | |
e32090ba SC |
157 | virtual void controlAction(WXWidget slf, void* _cmd, void* sender); |
158 | virtual void controlDoubleAction(WXWidget slf, void* _cmd, void *sender); | |
ce00f59b | 159 | |
75a2c6a1 KO |
160 | // for wxTextCtrl-derived classes, put here since they don't all derive |
161 | // from the same pimpl class. | |
162 | virtual void controlTextDidChange(); | |
4dd9fdf8 | 163 | |
4849f027 SC |
164 | protected: |
165 | WXWidget m_osxView; | |
f0e0116e | 166 | NSEvent* m_lastKeyDownEvent; |
4dd9fdf8 | 167 | bool m_isFlipped; |
7cb2a241 | 168 | // if it the control has an editor, that editor will already send some |
03647350 | 169 | // events, don't resend them |
7cb2a241 | 170 | bool m_hasEditor; |
03647350 | 171 | |
4849f027 SC |
172 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxWidgetCocoaImpl) |
173 | }; | |
174 | ||
ffad7b0d SC |
175 | DECLARE_WXCOCOA_OBJC_CLASS( wxNSWindow ); |
176 | ||
4849f027 SC |
177 | class wxNonOwnedWindowCocoaImpl : public wxNonOwnedWindowImpl |
178 | { | |
179 | public : | |
180 | wxNonOwnedWindowCocoaImpl( wxNonOwnedWindow* nonownedwnd) ; | |
181 | wxNonOwnedWindowCocoaImpl(); | |
03647350 | 182 | |
4849f027 | 183 | virtual ~wxNonOwnedWindowCocoaImpl(); |
03647350 | 184 | |
0aaa6ace | 185 | virtual void WillBeDestroyed() ; |
4849f027 SC |
186 | void Create( wxWindow* parent, const wxPoint& pos, const wxSize& size, |
187 | long style, long extraStyle, const wxString& name ) ; | |
17e2694c | 188 | void Create( wxWindow* parent, WXWindow nativeWindow ); |
03647350 | 189 | |
4849f027 | 190 | WXWindow GetWXWindow() const; |
03647350 | 191 | void Raise(); |
4849f027 | 192 | void Lower(); |
03647350 | 193 | bool Show(bool show); |
ab9a0b84 VZ |
194 | |
195 | virtual bool ShowWithEffect(bool show, | |
196 | wxShowEffect effect, | |
197 | unsigned timeout); | |
03647350 | 198 | |
4849f027 SC |
199 | void Update(); |
200 | bool SetTransparent(wxByte alpha); | |
201 | bool SetBackgroundColour(const wxColour& col ); | |
03647350 | 202 | void SetExtraStyle( long exStyle ); |
b6dc21e7 | 203 | void SetWindowStyleFlag( long style ); |
03647350 | 204 | bool SetBackgroundStyle(wxBackgroundStyle style); |
4849f027 SC |
205 | bool CanSetTransparent(); |
206 | ||
207 | void MoveWindow(int x, int y, int width, int height); | |
208 | void GetPosition( int &x, int &y ) const; | |
209 | void GetSize( int &width, int &height ) const; | |
210 | ||
03647350 | 211 | void GetContentArea( int &left , int &top , int &width , int &height ) const; |
4849f027 | 212 | bool SetShape(const wxRegion& region); |
03647350 | 213 | |
4849f027 | 214 | virtual void SetTitle( const wxString& title, wxFontEncoding encoding ) ; |
03647350 | 215 | |
4849f027 | 216 | virtual bool IsMaximized() const; |
03647350 | 217 | |
4849f027 | 218 | virtual bool IsIconized() const; |
03647350 | 219 | |
4849f027 | 220 | virtual void Iconize( bool iconize ); |
03647350 | 221 | |
4849f027 | 222 | virtual void Maximize(bool maximize); |
03647350 | 223 | |
4849f027 | 224 | virtual bool IsFullScreen() const; |
03647350 | 225 | |
4849f027 | 226 | virtual bool ShowFullScreen(bool show, long style); |
030495ec | 227 | |
dbc7ceb9 | 228 | virtual void ShowWithoutActivating(); |
4849f027 SC |
229 | |
230 | virtual void RequestUserAttention(int flags); | |
03647350 | 231 | |
4849f027 | 232 | virtual void ScreenToWindow( int *x, int *y ); |
03647350 | 233 | |
4849f027 | 234 | virtual void WindowToScreen( int *x, int *y ); |
03647350 | 235 | |
dbc7ceb9 | 236 | virtual bool IsActive(); |
ce00f59b | 237 | |
efb2fa41 | 238 | virtual void SetModified(bool modified); |
ebf7d5c4 | 239 | virtual bool IsModified() const; |
030495ec | 240 | |
4849f027 SC |
241 | wxNonOwnedWindow* GetWXPeer() { return m_wxPeer; } |
242 | protected : | |
447e2772 SC |
243 | WXWindow m_macWindow; |
244 | void * m_macFullScreenData ; | |
4849f027 | 245 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxNonOwnedWindowCocoaImpl) |
03647350 | 246 | }; |
4849f027 | 247 | |
4850cc8b SC |
248 | #ifdef __OBJC__ |
249 | ||
5d57348e | 250 | WXDLLIMPEXP_CORE NSScreen* wxOSXGetMenuScreen(); |
2acc3915 SC |
251 | WXDLLIMPEXP_CORE NSRect wxToNSRect( NSView* parent, const wxRect& r ); |
252 | WXDLLIMPEXP_CORE wxRect wxFromNSRect( NSView* parent, const NSRect& rect ); | |
253 | WXDLLIMPEXP_CORE NSPoint wxToNSPoint( NSView* parent, const wxPoint& p ); | |
254 | WXDLLIMPEXP_CORE wxPoint wxFromNSPoint( NSView* parent, const NSPoint& p ); | |
03647350 VZ |
255 | |
256 | NSRect WXDLLIMPEXP_CORE wxOSXGetFrameForControl( wxWindowMac* window , const wxPoint& pos , const wxSize &size , | |
4850cc8b | 257 | bool adjustForOrigin = true ); |
03647350 | 258 | |
b466e85a | 259 | // used for many wxControls |
03647350 | 260 | |
b466e85a SC |
261 | @interface wxNSButton : NSButton |
262 | { | |
411a1c35 | 263 | NSTrackingRectTag rectTag; |
b466e85a | 264 | } |
03647350 | 265 | |
b466e85a SC |
266 | @end |
267 | ||
268 | @interface wxNSBox : NSBox | |
269 | { | |
b466e85a SC |
270 | } |
271 | ||
b466e85a SC |
272 | @end |
273 | ||
7cb2a241 SC |
274 | @interface wxNSTextFieldEditor : NSTextView |
275 | { | |
276 | NSEvent* lastKeyDownEvent; | |
277 | } | |
278 | ||
279 | @end | |
280 | ||
c8fdb345 | 281 | @interface wxNSTextField : NSTextField wxOSX_10_6_AND_LATER(<NSTextFieldDelegate>) |
7cb2a241 SC |
282 | { |
283 | wxNSTextFieldEditor* fieldEditor; | |
284 | } | |
285 | ||
286 | - (wxNSTextFieldEditor*) fieldEditor; | |
287 | - (void) setFieldEditor:(wxNSTextFieldEditor*) fieldEditor; | |
288 | ||
289 | @end | |
290 | ||
c8fdb345 | 291 | @interface wxNSSecureTextField : NSSecureTextField wxOSX_10_6_AND_LATER(<NSTextFieldDelegate>) |
b466e85a | 292 | { |
b466e85a | 293 | } |
7cb2a241 SC |
294 | |
295 | @end | |
296 | ||
297 | ||
030495ec | 298 | @interface wxNSTextView : NSTextView wxOSX_10_6_AND_LATER(<NSTextViewDelegate>) |
7cb2a241 SC |
299 | { |
300 | } | |
030495ec | 301 | |
b9cf2753 | 302 | - (void)textDidChange:(NSNotification *)aNotification; |
030495ec | 303 | |
b466e85a SC |
304 | @end |
305 | ||
ffad7b0d SC |
306 | @interface wxNSMenu : NSMenu |
307 | { | |
308 | wxMenuImpl* impl; | |
309 | } | |
310 | ||
311 | - (void) setImplementation:(wxMenuImpl*) item; | |
312 | - (wxMenuImpl*) implementation; | |
313 | ||
03647350 | 314 | @end |
ffad7b0d SC |
315 | |
316 | @interface wxNSMenuItem : NSMenuItem | |
317 | { | |
318 | wxMenuItemImpl* impl; | |
319 | } | |
320 | ||
321 | - (void) setImplementation:(wxMenuItemImpl*) item; | |
322 | - (wxMenuItemImpl*) implementation; | |
323 | ||
324 | - (void)clickedAction:(id)sender; | |
325 | - (BOOL)validateMenuItem:(NSMenuItem *)menuItem; | |
326 | ||
03647350 VZ |
327 | @end |
328 | ||
485c6263 | 329 | void WXDLLIMPEXP_CORE wxOSXCocoaClassAddWXMethods(Class c); |
b466e85a | 330 | |
724999ee KO |
331 | /* |
332 | We need this for ShowModal, as the sheet just disables the parent window and | |
333 | returns control to the app, whereas we don't want to return from ShowModal | |
334 | until the sheet has been dismissed. | |
335 | */ | |
336 | @interface ModalDialogDelegate : NSObject | |
337 | { | |
338 | BOOL sheetFinished; | |
339 | int resultCode; | |
bfa92264 | 340 | wxDialog* impl; |
724999ee KO |
341 | } |
342 | ||
bfa92264 | 343 | - (void)setImplementation: (wxDialog *)dialog; |
724999ee KO |
344 | - (BOOL)finished; |
345 | - (int)code; | |
346 | - (void)waitForSheetToFinish; | |
347 | - (void)sheetDidEnd:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo; | |
348 | @end | |
349 | ||
350 | ||
4850cc8b SC |
351 | #endif // __OBJC__ |
352 | ||
4849f027 SC |
353 | // NSCursor |
354 | ||
355 | WX_NSCursor wxMacCocoaCreateStockCursor( int cursor_type ); | |
356 | WX_NSCursor wxMacCocoaCreateCursorFromCGImage( CGImageRef cgImageRef, float hotSpotX, float hotSpotY ); | |
357 | void wxMacCocoaSetCursor( WX_NSCursor cursor ); | |
358 | void wxMacCocoaHideCursor(); | |
359 | void wxMacCocoaShowCursor(); | |
360 | ||
361 | typedef struct tagClassicCursor | |
362 | { | |
363 | wxUint16 bits[16]; | |
364 | wxUint16 mask[16]; | |
365 | wxInt16 hotspot[2]; | |
366 | }ClassicCursor; | |
367 | ||
524c47aa SC |
368 | const short kwxCursorBullseye = 0; |
369 | const short kwxCursorBlank = 1; | |
370 | const short kwxCursorPencil = 2; | |
371 | const short kwxCursorMagnifier = 3; | |
372 | const short kwxCursorNoEntry = 4; | |
373 | const short kwxCursorPaintBrush = 5; | |
374 | const short kwxCursorPointRight = 6; | |
375 | const short kwxCursorPointLeft = 7; | |
376 | const short kwxCursorQuestionArrow = 8; | |
377 | const short kwxCursorRightArrow = 9; | |
378 | const short kwxCursorSizeNS = 10; | |
379 | const short kwxCursorSize = 11; | |
380 | const short kwxCursorSizeNESW = 12; | |
381 | const short kwxCursorSizeNWSE = 13; | |
382 | const short kwxCursorRoller = 14; | |
383 | const short kwxCursorLast = kwxCursorRoller; | |
384 | ||
385 | // exposing our fallback cursor map | |
386 | ||
387 | extern ClassicCursor gMacCursors[]; | |
388 | ||
4849f027 SC |
389 | #endif |
390 | ||
391 | #endif | |
392 | // _WX_PRIVATE_COCOA_H_ | |
393 |