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