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