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
6 // Author: Stefan Csomor
9 // RCS-ID: $Id: private.h 53819 2008-05-29 14:11:45Z SC $
10 // Copyright: (c) Stefan Csomor
11 // Licence: wxWindows licence
12 /////////////////////////////////////////////////////////////////////////////
14 #ifndef _WX_PRIVATE_COCOA_H_
15 #define _WX_PRIVATE_COCOA_H_
17 #include "wx/osx/core/private.h"
21 #include <ApplicationServices/ApplicationServices.h>
23 #if wxOSX_USE_ATSU_TEXT
24 // we need theming and atsu
25 #include <Carbon/Carbon.h>
29 #import <Cocoa/Cocoa.h>
33 // shared between Cocoa and Carbon
36 // bring in themeing types without pulling in the headers
39 typedef SInt16 ThemeBrush
;
40 CGColorRef WXDLLIMPEXP_CORE
wxMacCreateCGColorFromHITheme( ThemeBrush brush
) ;
41 OSStatus WXDLLIMPEXP_CORE
wxMacDrawCGImage(
42 CGContextRef inContext
,
43 const CGRect
* inBounds
,
45 WX_NSImage WXDLLIMPEXP_CORE
wxOSXCreateNSImageFromCGImage( CGImageRef image
);
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
);
60 class WXDLLIMPEXP_CORE wxWidgetCocoaImpl
: public wxWidgetImpl
63 wxWidgetCocoaImpl( wxWindowMac
* peer
, WXWidget w
, bool isRootControl
= false ) ;
69 virtual bool IsVisible() const ;
70 virtual void SetVisibility(bool);
76 virtual void ScrollRect( const wxRect
*rect
, int dx
, int dy
);
78 virtual WXWidget
GetWXWidget() const { return m_osxView
; }
80 virtual void SetBackgroundColour(const wxColour
&);
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
);
88 virtual void SetNeedsDisplay( const wxRect
* where
= NULL
);
89 virtual bool GetNeedsDisplay() const;
91 virtual bool CanFocus() const;
92 // return true if successful
93 virtual bool SetFocus();
94 virtual bool HasFocus() const;
96 void RemoveFromParent();
97 void Embed( wxWidgetImpl
*parent
);
99 void SetDefaultButton( bool isDefault
);
101 virtual void SetLabel(const wxString
& title
, wxFontEncoding encoding
);
103 void SetCursor( const wxCursor
& cursor
);
107 wxInt32
GetValue() const;
108 void SetValue( wxInt32 v
);
109 void SetBitmap( const wxBitmap
& bitmap
);
110 void SetupTabs( const wxNotebook
¬ebook
);
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;
120 void SetScrollThumb( wxInt32 value
, wxInt32 thumbSize
);
122 void SetFont( const wxFont
& font
, const wxColour
& foreground
, long windowStyle
, bool ignoreBlack
= true );
124 void InstallEventHandler( WXWidget control
= NULL
);
126 virtual bool DoHandleMouseEvent(NSEvent
*event
);
127 virtual bool DoHandleKeyEvent(NSEvent
*event
);
128 virtual bool DoHandleCharEvent(NSEvent
*event
, NSString
*text
);
129 virtual void DoNotifyFocusEvent(bool receivedFocus
, wxWidgetImpl
* otherWindow
);
131 void SetFlipped(bool flipped
);
132 virtual bool IsFlipped() const { return m_isFlipped
; }
134 // cocoa thunk connected calls
136 virtual unsigned int draggingEntered(void* sender
, WXWidget slf
, void* _cmd
);
137 virtual void draggingExited(void* sender
, WXWidget slf
, void* _cmd
);
138 virtual unsigned int draggingUpdated(void* sender
, WXWidget slf
, void* _cmd
);
139 virtual bool performDragOperation(void* sender
, WXWidget slf
, void* _cmd
);
140 virtual void mouseEvent(WX_NSEvent event
, WXWidget slf
, void* _cmd
);
141 virtual void keyEvent(WX_NSEvent event
, WXWidget slf
, void* _cmd
);
142 virtual void insertText(NSString
* text
, WXWidget slf
, void* _cmd
);
143 virtual bool performKeyEquivalent(WX_NSEvent event
, WXWidget slf
, void* _cmd
);
144 virtual bool acceptsFirstResponder(WXWidget slf
, void* _cmd
);
145 virtual bool becomeFirstResponder(WXWidget slf
, void* _cmd
);
146 virtual bool resignFirstResponder(WXWidget slf
, void* _cmd
);
147 virtual void resetCursorRects(WXWidget slf
, void* _cmd
);
148 virtual bool isFlipped(WXWidget slf
, void* _cmd
);
149 virtual void drawRect(void* rect
, WXWidget slf
, void* _cmd
);
151 virtual void controlAction(WXWidget slf
, void* _cmd
, void* sender
);
152 virtual void controlDoubleAction(WXWidget slf
, void* _cmd
, void *sender
);
156 NSEvent
* m_lastKeyDownEvent
;
158 // if it the control has an editor, that editor will already send some
159 // events, don't resend them
162 DECLARE_DYNAMIC_CLASS_NO_COPY(wxWidgetCocoaImpl
)
165 DECLARE_WXCOCOA_OBJC_CLASS( wxNSWindow
);
167 class wxNonOwnedWindowCocoaImpl
: public wxNonOwnedWindowImpl
170 wxNonOwnedWindowCocoaImpl( wxNonOwnedWindow
* nonownedwnd
) ;
171 wxNonOwnedWindowCocoaImpl();
173 virtual ~wxNonOwnedWindowCocoaImpl();
175 virtual void Destroy() ;
176 void Create( wxWindow
* parent
, const wxPoint
& pos
, const wxSize
& size
,
177 long style
, long extraStyle
, const wxString
& name
) ;
179 WXWindow
GetWXWindow() const;
182 bool Show(bool show
);
183 bool ShowWithEffect(bool show
, wxShowEffect effect
, unsigned timeout
);
186 bool SetTransparent(wxByte alpha
);
187 bool SetBackgroundColour(const wxColour
& col
);
188 void SetExtraStyle( long exStyle
);
189 bool SetBackgroundStyle(wxBackgroundStyle style
);
190 bool CanSetTransparent();
192 void MoveWindow(int x
, int y
, int width
, int height
);
193 void GetPosition( int &x
, int &y
) const;
194 void GetSize( int &width
, int &height
) const;
196 void GetContentArea( int &left
, int &top
, int &width
, int &height
) const;
197 bool SetShape(const wxRegion
& region
);
199 virtual void SetTitle( const wxString
& title
, wxFontEncoding encoding
) ;
201 virtual bool IsMaximized() const;
203 virtual bool IsIconized() const;
205 virtual void Iconize( bool iconize
);
207 virtual void Maximize(bool maximize
);
209 virtual bool IsFullScreen() const;
211 virtual bool ShowFullScreen(bool show
, long style
);
213 virtual void RequestUserAttention(int flags
);
215 virtual void ScreenToWindow( int *x
, int *y
);
217 virtual void WindowToScreen( int *x
, int *y
);
219 wxNonOwnedWindow
* GetWXPeer() { return m_wxPeer
; }
221 WX_wxNSWindow m_macWindow
;
222 void * m_macFullScreenData
;
223 DECLARE_DYNAMIC_CLASS_NO_COPY(wxNonOwnedWindowCocoaImpl
)
228 WXDLLIMPEXP_CORE NSRect
wxToNSRect( NSView
* parent
, const wxRect
& r
);
229 WXDLLIMPEXP_CORE wxRect
wxFromNSRect( NSView
* parent
, const NSRect
& rect
);
230 WXDLLIMPEXP_CORE NSPoint
wxToNSPoint( NSView
* parent
, const wxPoint
& p
);
231 WXDLLIMPEXP_CORE wxPoint
wxFromNSPoint( NSView
* parent
, const NSPoint
& p
);
233 NSRect WXDLLIMPEXP_CORE
wxOSXGetFrameForControl( wxWindowMac
* window
, const wxPoint
& pos
, const wxSize
&size
,
234 bool adjustForOrigin
= true );
236 // used for many wxControls
238 @interface wxNSButton
: NSButton
244 @interface wxNSBox
: NSBox
250 @interface wxNSTextFieldEditor
: NSTextView
252 NSEvent
* lastKeyDownEvent
;
257 @interface wxNSTextField
: NSTextField
259 wxNSTextFieldEditor
* fieldEditor
;
262 - (wxNSTextFieldEditor
*) fieldEditor
;
263 - (void) setFieldEditor
:(wxNSTextFieldEditor
*) fieldEditor
;
267 @interface wxNSSecureTextField
: NSSecureTextField
274 @interface wxNSTextView
: NSTextView
280 @interface wxNSMenu
: NSMenu
285 - (void) setImplementation
:(wxMenuImpl
*) item
;
286 - (wxMenuImpl
*) implementation
;
290 @interface wxNSMenuItem
: NSMenuItem
292 wxMenuItemImpl
* impl
;
295 - (void) setImplementation
:(wxMenuItemImpl
*) item
;
296 - (wxMenuItemImpl
*) implementation
;
298 - (void)clickedAction
:(id
)sender
;
299 - (BOOL
)validateMenuItem
:(NSMenuItem
*)menuItem
;
303 void WXDLLIMPEXP_CORE
wxOSXCocoaClassAddWXMethods(Class c
);
306 We need this for ShowModal, as the sheet just disables the parent window and
307 returns control to the app, whereas we don't want to return from ShowModal
308 until the sheet has been dismissed.
310 @interface ModalDialogDelegate
: NSObject
318 - (void)waitForSheetToFinish
;
319 - (void)sheetDidEnd
:(NSWindow
*)sheet returnCode
:(int)returnCode contextInfo
:(void *)contextInfo
;
327 WX_NSCursor
wxMacCocoaCreateStockCursor( int cursor_type
);
328 WX_NSCursor
wxMacCocoaCreateCursorFromCGImage( CGImageRef cgImageRef
, float hotSpotX
, float hotSpotY
);
329 void wxMacCocoaSetCursor( WX_NSCursor cursor
);
330 void wxMacCocoaHideCursor();
331 void wxMacCocoaShowCursor();
333 typedef struct tagClassicCursor
340 const short kwxCursorBullseye
= 0;
341 const short kwxCursorBlank
= 1;
342 const short kwxCursorPencil
= 2;
343 const short kwxCursorMagnifier
= 3;
344 const short kwxCursorNoEntry
= 4;
345 const short kwxCursorPaintBrush
= 5;
346 const short kwxCursorPointRight
= 6;
347 const short kwxCursorPointLeft
= 7;
348 const short kwxCursorQuestionArrow
= 8;
349 const short kwxCursorRightArrow
= 9;
350 const short kwxCursorSizeNS
= 10;
351 const short kwxCursorSize
= 11;
352 const short kwxCursorSizeNESW
= 12;
353 const short kwxCursorSizeNWSE
= 13;
354 const short kwxCursorRoller
= 14;
355 const short kwxCursorLast
= kwxCursorRoller
;
357 // exposing our fallback cursor map
359 extern ClassicCursor gMacCursors
[];
364 // _WX_PRIVATE_COCOA_H_