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