]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/osx/cocoa/private.h
Added wxRendererNative::DrawTitleBarBitmap().
[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//
36// shared between Cocoa and Carbon
37//
38
39// bring in theming types without pulling in the headers
40
41#if wxUSE_GUI
42typedef SInt16 ThemeBrush;
43CGColorRef WXDLLIMPEXP_CORE wxMacCreateCGColorFromHITheme( ThemeBrush brush ) ;
44OSStatus WXDLLIMPEXP_CORE wxMacDrawCGImage(
45 CGContextRef inContext,
46 const CGRect * inBounds,
47 CGImageRef inImage) ;
48WX_NSImage WXDLLIMPEXP_CORE wxOSXCreateNSImageFromCGImage( CGImageRef image );
49CGImageRef WXDLLIMPEXP_CORE wxOSXCreateCGImageFromNSImage( WX_NSImage nsimage );
50#endif
51
52long UMAGetSystemVersion() ;
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
62#if wxUSE_GUI
63
64class WXDLLIMPEXP_CORE wxWidgetCocoaImpl : public wxWidgetImpl
65{
66public :
67 wxWidgetCocoaImpl( wxWindowMac* peer , WXWidget w, bool isRootControl = false ) ;
68 wxWidgetCocoaImpl() ;
69 ~wxWidgetCocoaImpl();
70
71 void Init();
72
73 virtual bool IsVisible() const ;
74 virtual void SetVisibility(bool);
75
76 virtual void Raise();
77
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
84 virtual void SetBackgroundColour(const wxColour&);
85
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;
90 virtual void SetControlSize( wxWindowVariant variant );
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 );
102
103 void SetDefaultButton( bool isDefault );
104 void PerformClick();
105 virtual void SetLabel(const wxString& title, wxFontEncoding encoding);
106
107 void SetCursor( const wxCursor & cursor );
108 void CaptureMouse();
109 void ReleaseMouse();
110
111 wxInt32 GetValue() const;
112 void SetValue( wxInt32 v );
113 wxBitmap GetBitmap() const;
114 void SetBitmap( const wxBitmap& bitmap );
115 void SetBitmapPosition( wxDirection dir );
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 );
123 wxInt32 GetMinimum() const;
124 wxInt32 GetMaximum() const;
125 void PulseGauge();
126 void SetScrollThumb( wxInt32 value, wxInt32 thumbSize );
127
128 void SetFont( const wxFont & font , const wxColour& foreground , long windowStyle, bool ignoreBlack = true );
129
130 void InstallEventHandler( WXWidget control = NULL );
131
132 virtual bool DoHandleMouseEvent(NSEvent *event);
133 virtual bool DoHandleKeyEvent(NSEvent *event);
134 virtual bool DoHandleCharEvent(NSEvent *event, NSString *text);
135 virtual void DoNotifyFocusEvent(bool receivedFocus, wxWidgetImpl* otherWindow);
136
137 virtual void SetupKeyEvent(wxKeyEvent &wxevent, NSEvent * nsEvent, NSString* charString = NULL);
138 virtual void SetupMouseEvent(wxMouseEvent &wxevent, NSEvent * nsEvent);
139
140
141 void SetFlipped(bool flipped);
142 virtual bool IsFlipped() const { return m_isFlipped; }
143
144 // cocoa thunk connected calls
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);
152 virtual void insertText(NSString* text, WXWidget slf, void* _cmd);
153 virtual bool performKeyEquivalent(WX_NSEvent event, WXWidget slf, void* _cmd);
154 virtual bool acceptsFirstResponder(WXWidget slf, void* _cmd);
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);
160
161 virtual void controlAction(WXWidget slf, void* _cmd, void* sender);
162 virtual void controlDoubleAction(WXWidget slf, void* _cmd, void *sender);
163
164protected:
165 WXWidget m_osxView;
166 NSEvent* m_lastKeyDownEvent;
167 bool m_isFlipped;
168 // if it the control has an editor, that editor will already send some
169 // events, don't resend them
170 bool m_hasEditor;
171
172 DECLARE_DYNAMIC_CLASS_NO_COPY(wxWidgetCocoaImpl)
173};
174
175DECLARE_WXCOCOA_OBJC_CLASS( wxNSWindow );
176
177class wxNonOwnedWindowCocoaImpl : public wxNonOwnedWindowImpl
178{
179public :
180 wxNonOwnedWindowCocoaImpl( wxNonOwnedWindow* nonownedwnd) ;
181 wxNonOwnedWindowCocoaImpl();
182
183 virtual ~wxNonOwnedWindowCocoaImpl();
184
185 virtual void Destroy() ;
186 void Create( wxWindow* parent, const wxPoint& pos, const wxSize& size,
187 long style, long extraStyle, const wxString& name ) ;
188
189 WXWindow GetWXWindow() const;
190 void Raise();
191 void Lower();
192 bool Show(bool show);
193 bool ShowWithEffect(bool show, wxShowEffect effect, unsigned timeout);
194
195 void Update();
196 bool SetTransparent(wxByte alpha);
197 bool SetBackgroundColour(const wxColour& col );
198 void SetExtraStyle( long exStyle );
199 bool SetBackgroundStyle(wxBackgroundStyle style);
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
206 void GetContentArea( int &left , int &top , int &width , int &height ) const;
207 bool SetShape(const wxRegion& region);
208
209 virtual void SetTitle( const wxString& title, wxFontEncoding encoding ) ;
210
211 virtual bool IsMaximized() const;
212
213 virtual bool IsIconized() const;
214
215 virtual void Iconize( bool iconize );
216
217 virtual void Maximize(bool maximize);
218
219 virtual bool IsFullScreen() const;
220
221 virtual bool ShowFullScreen(bool show, long style);
222
223 virtual void RequestUserAttention(int flags);
224
225 virtual void ScreenToWindow( int *x, int *y );
226
227 virtual void WindowToScreen( int *x, int *y );
228
229 wxNonOwnedWindow* GetWXPeer() { return m_wxPeer; }
230protected :
231 WX_wxNSWindow m_macWindow;
232 void * m_macFullScreenData ;
233 DECLARE_DYNAMIC_CLASS_NO_COPY(wxNonOwnedWindowCocoaImpl)
234};
235
236#ifdef __OBJC__
237
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 );
242
243 NSRect WXDLLIMPEXP_CORE wxOSXGetFrameForControl( wxWindowMac* window , const wxPoint& pos , const wxSize &size ,
244 bool adjustForOrigin = true );
245
246 // used for many wxControls
247
248 @interface wxNSButton : NSButton
249 {
250 }
251
252 @end
253
254 @interface wxNSBox : NSBox
255 {
256 }
257
258 @end
259
260 @interface wxNSTextFieldEditor : NSTextView
261 {
262 NSEvent* lastKeyDownEvent;
263 }
264
265 @end
266
267 @interface wxNSTextField : NSTextField
268 {
269 wxNSTextFieldEditor* fieldEditor;
270 }
271
272 - (wxNSTextFieldEditor*) fieldEditor;
273 - (void) setFieldEditor:(wxNSTextFieldEditor*) fieldEditor;
274
275 @end
276
277 @interface wxNSSecureTextField : NSSecureTextField
278 {
279 }
280
281 @end
282
283
284 @interface wxNSTextView : NSTextView
285 {
286 }
287
288 @end
289
290 @interface wxNSMenu : NSMenu
291 {
292 wxMenuImpl* impl;
293 }
294
295 - (void) setImplementation:(wxMenuImpl*) item;
296 - (wxMenuImpl*) implementation;
297
298 @end
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
311 @end
312
313 void WXDLLIMPEXP_CORE wxOSXCocoaClassAddWXMethods(Class c);
314
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
333#endif // __OBJC__
334
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
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
371#endif
372
373#endif
374 // _WX_PRIVATE_COCOA_H_
375