]> git.saurik.com Git - wxWidgets.git/blob - include/wx/osx/cocoa/private.h
moving themeing include to private.h
[wxWidgets.git] / include / wx / osx / cocoa / private.h
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
42 typedef SInt16 ThemeBrush;
43 CGColorRef WXDLLIMPEXP_CORE wxMacCreateCGColorFromHITheme( ThemeBrush brush ) ;
44 OSStatus WXDLLIMPEXP_CORE wxMacDrawCGImage(
45 CGContextRef inContext,
46 const CGRect * inBounds,
47 CGImageRef inImage) ;
48 WX_NSImage WXDLLIMPEXP_CORE wxOSXCreateNSImageFromCGImage( CGImageRef image );
49 #endif
50
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 );
56
57 //
58 //
59 //
60
61 #if wxUSE_GUI
62
63 class WXDLLIMPEXP_CORE wxWidgetCocoaImpl : public wxWidgetImpl
64 {
65 public :
66 wxWidgetCocoaImpl( wxWindowMac* peer , WXWidget w, bool isRootControl = false ) ;
67 wxWidgetCocoaImpl() ;
68 ~wxWidgetCocoaImpl();
69
70 void Init();
71
72 virtual bool IsVisible() const ;
73 virtual void SetVisibility(bool);
74
75 virtual void Raise();
76
77 virtual void Lower();
78
79 virtual void ScrollRect( const wxRect *rect, int dx, int dy );
80
81 virtual WXWidget GetWXWidget() const { return m_osxView; }
82
83 virtual void SetBackgroundColour(const wxColour&);
84
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 );
90
91 virtual void SetNeedsDisplay( const wxRect* where = NULL );
92 virtual bool GetNeedsDisplay() const;
93
94 virtual bool CanFocus() const;
95 // return true if successful
96 virtual bool SetFocus();
97 virtual bool HasFocus() const;
98
99 void RemoveFromParent();
100 void Embed( wxWidgetImpl *parent );
101
102 void SetDefaultButton( bool isDefault );
103 void PerformClick();
104 virtual void SetLabel(const wxString& title, wxFontEncoding encoding);
105
106 void SetCursor( const wxCursor & cursor );
107 void CaptureMouse();
108 void ReleaseMouse();
109
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 &notebook );
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;
124 void PulseGauge();
125 void SetScrollThumb( wxInt32 value, wxInt32 thumbSize );
126
127 void SetFont( const wxFont & font , const wxColour& foreground , long windowStyle, bool ignoreBlack = true );
128
129 void InstallEventHandler( WXWidget control = NULL );
130
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);
135
136 void SetFlipped(bool flipped);
137 virtual bool IsFlipped() const { return m_isFlipped; }
138
139 // cocoa thunk connected calls
140
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);
155
156 virtual void controlAction(WXWidget slf, void* _cmd, void* sender);
157 virtual void controlDoubleAction(WXWidget slf, void* _cmd, void *sender);
158
159 protected:
160 WXWidget m_osxView;
161 NSEvent* m_lastKeyDownEvent;
162 bool m_isFlipped;
163 // if it the control has an editor, that editor will already send some
164 // events, don't resend them
165 bool m_hasEditor;
166
167 DECLARE_DYNAMIC_CLASS_NO_COPY(wxWidgetCocoaImpl)
168 };
169
170 DECLARE_WXCOCOA_OBJC_CLASS( wxNSWindow );
171
172 class wxNonOwnedWindowCocoaImpl : public wxNonOwnedWindowImpl
173 {
174 public :
175 wxNonOwnedWindowCocoaImpl( wxNonOwnedWindow* nonownedwnd) ;
176 wxNonOwnedWindowCocoaImpl();
177
178 virtual ~wxNonOwnedWindowCocoaImpl();
179
180 virtual void Destroy() ;
181 void Create( wxWindow* parent, const wxPoint& pos, const wxSize& size,
182 long style, long extraStyle, const wxString& name ) ;
183
184 WXWindow GetWXWindow() const;
185 void Raise();
186 void Lower();
187 bool Show(bool show);
188 bool ShowWithEffect(bool show, wxShowEffect effect, unsigned timeout);
189
190 void Update();
191 bool SetTransparent(wxByte alpha);
192 bool SetBackgroundColour(const wxColour& col );
193 void SetExtraStyle( long exStyle );
194 bool SetBackgroundStyle(wxBackgroundStyle style);
195 bool CanSetTransparent();
196
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;
200
201 void GetContentArea( int &left , int &top , int &width , int &height ) const;
202 bool SetShape(const wxRegion& region);
203
204 virtual void SetTitle( const wxString& title, wxFontEncoding encoding ) ;
205
206 virtual bool IsMaximized() const;
207
208 virtual bool IsIconized() const;
209
210 virtual void Iconize( bool iconize );
211
212 virtual void Maximize(bool maximize);
213
214 virtual bool IsFullScreen() const;
215
216 virtual bool ShowFullScreen(bool show, long style);
217
218 virtual void RequestUserAttention(int flags);
219
220 virtual void ScreenToWindow( int *x, int *y );
221
222 virtual void WindowToScreen( int *x, int *y );
223
224 wxNonOwnedWindow* GetWXPeer() { return m_wxPeer; }
225 protected :
226 WX_wxNSWindow m_macWindow;
227 void * m_macFullScreenData ;
228 DECLARE_DYNAMIC_CLASS_NO_COPY(wxNonOwnedWindowCocoaImpl)
229 };
230
231 #ifdef __OBJC__
232
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 );
237
238 NSRect WXDLLIMPEXP_CORE wxOSXGetFrameForControl( wxWindowMac* window , const wxPoint& pos , const wxSize &size ,
239 bool adjustForOrigin = true );
240
241 // used for many wxControls
242
243 @interface wxNSButton : NSButton
244 {
245 }
246
247 @end
248
249 @interface wxNSBox : NSBox
250 {
251 }
252
253 @end
254
255 @interface wxNSTextFieldEditor : NSTextView
256 {
257 NSEvent* lastKeyDownEvent;
258 }
259
260 @end
261
262 @interface wxNSTextField : NSTextField
263 {
264 wxNSTextFieldEditor* fieldEditor;
265 }
266
267 - (wxNSTextFieldEditor*) fieldEditor;
268 - (void) setFieldEditor:(wxNSTextFieldEditor*) fieldEditor;
269
270 @end
271
272 @interface wxNSSecureTextField : NSSecureTextField
273 {
274 }
275
276 @end
277
278
279 @interface wxNSTextView : NSTextView
280 {
281 }
282
283 @end
284
285 @interface wxNSMenu : NSMenu
286 {
287 wxMenuImpl* impl;
288 }
289
290 - (void) setImplementation:(wxMenuImpl*) item;
291 - (wxMenuImpl*) implementation;
292
293 @end
294
295 @interface wxNSMenuItem : NSMenuItem
296 {
297 wxMenuItemImpl* impl;
298 }
299
300 - (void) setImplementation:(wxMenuItemImpl*) item;
301 - (wxMenuItemImpl*) implementation;
302
303 - (void)clickedAction:(id)sender;
304 - (BOOL)validateMenuItem:(NSMenuItem *)menuItem;
305
306 @end
307
308 void WXDLLIMPEXP_CORE wxOSXCocoaClassAddWXMethods(Class c);
309
310 /*
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.
314 */
315 @interface ModalDialogDelegate : NSObject
316 {
317 BOOL sheetFinished;
318 int resultCode;
319 }
320
321 - (BOOL)finished;
322 - (int)code;
323 - (void)waitForSheetToFinish;
324 - (void)sheetDidEnd:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo;
325 @end
326
327
328 #endif // __OBJC__
329
330 // NSCursor
331
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();
337
338 typedef struct tagClassicCursor
339 {
340 wxUint16 bits[16];
341 wxUint16 mask[16];
342 wxInt16 hotspot[2];
343 }ClassicCursor;
344
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;
361
362 // exposing our fallback cursor map
363
364 extern ClassicCursor gMacCursors[];
365
366 #endif
367
368 #endif
369 // _WX_PRIVATE_COCOA_H_
370