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>
27 // we only need theming, if we find a better include replace the following
28 #include <Carbon/Carbon.h>
32 #import <Cocoa/Cocoa.h>
36 // shared between Cocoa and Carbon
39 // bring in theming types without pulling in the headers
42 typedef SInt16 ThemeBrush
;
43 CGColorRef WXDLLIMPEXP_CORE
wxMacCreateCGColorFromHITheme( ThemeBrush brush
) ;
44 OSStatus WXDLLIMPEXP_CORE
wxMacDrawCGImage(
45 CGContextRef inContext
,
46 const CGRect
* inBounds
,
48 WX_NSImage WXDLLIMPEXP_CORE
wxOSXCreateNSImageFromCGImage( CGImageRef image
);
51 long UMAGetSystemVersion() ;
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
);
63 class WXDLLIMPEXP_CORE wxWidgetCocoaImpl
: public wxWidgetImpl
66 wxWidgetCocoaImpl( wxWindowMac
* peer
, WXWidget w
, bool isRootControl
= false ) ;
72 virtual bool IsVisible() const ;
73 virtual void SetVisibility(bool);
79 virtual void ScrollRect( const wxRect
*rect
, int dx
, int dy
);
81 virtual WXWidget
GetWXWidget() const { return m_osxView
; }
83 virtual void SetBackgroundColour(const wxColour
&);
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;
89 virtual void SetControlSize( wxWindowVariant variant
);
91 virtual void SetNeedsDisplay( const wxRect
* where
= NULL
);
92 virtual bool GetNeedsDisplay() const;
94 virtual bool CanFocus() const;
95 // return true if successful
96 virtual bool SetFocus();
97 virtual bool HasFocus() const;
99 void RemoveFromParent();
100 void Embed( wxWidgetImpl
*parent
);
102 void SetDefaultButton( bool isDefault
);
104 virtual void SetLabel(const wxString
& title
, wxFontEncoding encoding
);
106 void SetCursor( const wxCursor
& cursor
);
110 wxInt32
GetValue() const;
111 void SetValue( wxInt32 v
);
112 wxBitmap
GetBitmap() const;
113 void SetBitmap( const wxBitmap
& bitmap
);
114 void SetBitmapPosition( wxDirection dir
);
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
);
122 wxInt32
GetMinimum() const;
123 wxInt32
GetMaximum() const;
125 void SetScrollThumb( wxInt32 value
, wxInt32 thumbSize
);
127 void SetFont( const wxFont
& font
, const wxColour
& foreground
, long windowStyle
, bool ignoreBlack
= true );
129 void InstallEventHandler( WXWidget control
= NULL
);
131 virtual bool DoHandleMouseEvent(NSEvent
*event
);
132 virtual bool DoHandleKeyEvent(NSEvent
*event
);
133 virtual bool DoHandleCharEvent(NSEvent
*event
, NSString
*text
);
134 virtual void DoNotifyFocusEvent(bool receivedFocus
, wxWidgetImpl
* otherWindow
);
136 void SetFlipped(bool flipped
);
137 virtual bool IsFlipped() const { return m_isFlipped
; }
139 // cocoa thunk connected calls
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
);
147 virtual void insertText(NSString
* text
, WXWidget slf
, void* _cmd
);
148 virtual bool performKeyEquivalent(WX_NSEvent event
, WXWidget slf
, void* _cmd
);
149 virtual bool acceptsFirstResponder(WXWidget slf
, void* _cmd
);
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
);
156 virtual void controlAction(WXWidget slf
, void* _cmd
, void* sender
);
157 virtual void controlDoubleAction(WXWidget slf
, void* _cmd
, void *sender
);
161 NSEvent
* m_lastKeyDownEvent
;
163 // if it the control has an editor, that editor will already send some
164 // events, don't resend them
167 DECLARE_DYNAMIC_CLASS_NO_COPY(wxWidgetCocoaImpl
)
170 DECLARE_WXCOCOA_OBJC_CLASS( wxNSWindow
);
172 class wxNonOwnedWindowCocoaImpl
: public wxNonOwnedWindowImpl
175 wxNonOwnedWindowCocoaImpl( wxNonOwnedWindow
* nonownedwnd
) ;
176 wxNonOwnedWindowCocoaImpl();
178 virtual ~wxNonOwnedWindowCocoaImpl();
180 virtual void Destroy() ;
181 void Create( wxWindow
* parent
, const wxPoint
& pos
, const wxSize
& size
,
182 long style
, long extraStyle
, const wxString
& name
) ;
184 WXWindow
GetWXWindow() const;
187 bool Show(bool show
);
188 bool ShowWithEffect(bool show
, wxShowEffect effect
, unsigned timeout
);
191 bool SetTransparent(wxByte alpha
);
192 bool SetBackgroundColour(const wxColour
& col
);
193 void SetExtraStyle( long exStyle
);
194 bool SetBackgroundStyle(wxBackgroundStyle style
);
195 bool CanSetTransparent();
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;
201 void GetContentArea( int &left
, int &top
, int &width
, int &height
) const;
202 bool SetShape(const wxRegion
& region
);
204 virtual void SetTitle( const wxString
& title
, wxFontEncoding encoding
) ;
206 virtual bool IsMaximized() const;
208 virtual bool IsIconized() const;
210 virtual void Iconize( bool iconize
);
212 virtual void Maximize(bool maximize
);
214 virtual bool IsFullScreen() const;
216 virtual bool ShowFullScreen(bool show
, long style
);
218 virtual void RequestUserAttention(int flags
);
220 virtual void ScreenToWindow( int *x
, int *y
);
222 virtual void WindowToScreen( int *x
, int *y
);
224 wxNonOwnedWindow
* GetWXPeer() { return m_wxPeer
; }
226 WX_wxNSWindow m_macWindow
;
227 void * m_macFullScreenData
;
228 DECLARE_DYNAMIC_CLASS_NO_COPY(wxNonOwnedWindowCocoaImpl
)
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
);
238 NSRect WXDLLIMPEXP_CORE
wxOSXGetFrameForControl( wxWindowMac
* window
, const wxPoint
& pos
, const wxSize
&size
,
239 bool adjustForOrigin
= true );
241 // used for many wxControls
243 @interface wxNSButton
: NSButton
249 @interface wxNSBox
: NSBox
255 @interface wxNSTextFieldEditor
: NSTextView
257 NSEvent
* lastKeyDownEvent
;
262 @interface wxNSTextField
: NSTextField
264 wxNSTextFieldEditor
* fieldEditor
;
267 - (wxNSTextFieldEditor
*) fieldEditor
;
268 - (void) setFieldEditor
:(wxNSTextFieldEditor
*) fieldEditor
;
272 @interface wxNSSecureTextField
: NSSecureTextField
279 @interface wxNSTextView
: NSTextView
285 @interface wxNSMenu
: NSMenu
290 - (void) setImplementation
:(wxMenuImpl
*) item
;
291 - (wxMenuImpl
*) implementation
;
295 @interface wxNSMenuItem
: NSMenuItem
297 wxMenuItemImpl
* impl
;
300 - (void) setImplementation
:(wxMenuItemImpl
*) item
;
301 - (wxMenuItemImpl
*) implementation
;
303 - (void)clickedAction
:(id
)sender
;
304 - (BOOL
)validateMenuItem
:(NSMenuItem
*)menuItem
;
308 void WXDLLIMPEXP_CORE
wxOSXCocoaClassAddWXMethods(Class c
);
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.
315 @interface ModalDialogDelegate
: NSObject
323 - (void)waitForSheetToFinish
;
324 - (void)sheetDidEnd
:(NSWindow
*)sheet returnCode
:(int)returnCode contextInfo
:(void *)contextInfo
;
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();
338 typedef struct tagClassicCursor
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
;
362 // exposing our fallback cursor map
364 extern ClassicCursor gMacCursors
[];
369 // _WX_PRIVATE_COCOA_H_