]>
Commit | Line | Data |
---|---|---|
5c6eb3a8 | 1 | ///////////////////////////////////////////////////////////////////////////// |
eefe52da | 2 | // Name: wx/osx/core/private.h |
5c6eb3a8 SC |
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 | |
a9a4f229 | 9 | // RCS-ID: $Id$ |
5c6eb3a8 SC |
10 | // Copyright: (c) Stefan Csomor |
11 | // Licence: wxWindows licence | |
12 | ///////////////////////////////////////////////////////////////////////////// | |
13 | ||
eefe52da SC |
14 | #ifndef _WX_PRIVATE_CORE_H_ |
15 | #define _WX_PRIVATE_CORE_H_ | |
5c6eb3a8 SC |
16 | |
17 | #include "wx/defs.h" | |
18 | ||
19 | #include <CoreFoundation/CoreFoundation.h> | |
20 | ||
ef0e9220 SC |
21 | #include "wx/osx/core/cfstring.h" |
22 | #include "wx/osx/core/cfdataref.h" | |
5c6eb3a8 | 23 | |
030495ec VZ |
24 | // Define helper macros allowing to insert small snippets of code to be |
25 | // compiled for high enough OS X version only: this shouldn't be abused for | |
26 | // anything big but it's handy for e.g. specifying OS X 10.6-only protocols in | |
27 | // the Objective C classes declarations when they're not supported under the | |
28 | // previous versions | |
29 | #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 | |
30 | #define wxOSX_10_6_AND_LATER(x) x | |
31 | #else | |
32 | #define wxOSX_10_6_AND_LATER(x) | |
33 | #endif | |
34 | ||
d20028be | 35 | // platform specific Clang analyzer support |
cc510e13 | 36 | #ifndef NS_RETURNS_RETAINED |
d20028be SC |
37 | # if WX_HAS_CLANG_FEATURE(attribute_ns_returns_retained) |
38 | # define NS_RETURNS_RETAINED __attribute__((ns_returns_retained)) | |
39 | # else | |
40 | # define NS_RETURNS_RETAINED | |
41 | # endif | |
cc510e13 SC |
42 | #endif |
43 | ||
44 | #ifndef CF_RETURNS_RETAINED | |
d20028be SC |
45 | # if WX_HAS_CLANG_FEATURE(attribute_cf_returns_retained) |
46 | # define CF_RETURNS_RETAINED __attribute__((cf_returns_retained)) | |
47 | # else | |
48 | # define CF_RETURNS_RETAINED | |
49 | # endif | |
cc510e13 SC |
50 | #endif |
51 | ||
26632ccd | 52 | #if ( !wxUSE_GUI && !wxOSX_USE_IPHONE ) || wxOSX_USE_COCOA_OR_CARBON |
382c4ade VZ |
53 | |
54 | // Carbon functions are currently still used in wxOSX/Cocoa too (including | |
55 | // wxBase part of it). | |
56 | #include <Carbon/Carbon.h> | |
1e181c7a | 57 | |
524c47aa | 58 | WXDLLIMPEXP_BASE long UMAGetSystemVersion() ; |
1e181c7a SC |
59 | |
60 | void WXDLLIMPEXP_CORE wxMacStringToPascal( const wxString&from , unsigned char * to ); | |
61 | wxString WXDLLIMPEXP_CORE wxMacMakeStringFromPascal( const unsigned char * from ); | |
62 | ||
382c4ade VZ |
63 | WXDLLIMPEXP_BASE wxString wxMacFSRefToPath( const FSRef *fsRef , CFStringRef additionalPathComponent = NULL ); |
64 | WXDLLIMPEXP_BASE OSStatus wxMacPathToFSRef( const wxString&path , FSRef *fsRef ); | |
65 | WXDLLIMPEXP_BASE wxString wxMacHFSUniStrToString( ConstHFSUniStr255Param uniname ); | |
66 | ||
c1313b54 SC |
67 | // keycode utils from app.cpp |
68 | ||
69 | WXDLLIMPEXP_BASE CGKeyCode wxCharCodeWXToOSX(wxKeyCode code); | |
70 | WXDLLIMPEXP_BASE long wxMacTranslateKey(unsigned char key, unsigned char code); | |
71 | ||
524c47aa SC |
72 | #endif |
73 | ||
5c6eb3a8 SC |
74 | #if wxUSE_GUI |
75 | ||
eefe52da | 76 | #if wxOSX_USE_IPHONE |
5c6eb3a8 | 77 | #include <CoreGraphics/CoreGraphics.h> |
eefe52da | 78 | #else |
09f0f2cf | 79 | #include <ApplicationServices/ApplicationServices.h> |
eefe52da SC |
80 | #endif |
81 | ||
82 | #include "wx/bitmap.h" | |
83 | #include "wx/window.h" | |
5c6eb3a8 SC |
84 | |
85 | class WXDLLIMPEXP_CORE wxMacCGContextStateSaver | |
86 | { | |
c0c133e1 | 87 | wxDECLARE_NO_COPY_CLASS(wxMacCGContextStateSaver); |
5c6eb3a8 SC |
88 | |
89 | public: | |
90 | wxMacCGContextStateSaver( CGContextRef cg ) | |
91 | { | |
92 | m_cg = cg; | |
93 | CGContextSaveGState( cg ); | |
94 | } | |
95 | ~wxMacCGContextStateSaver() | |
96 | { | |
97 | CGContextRestoreGState( m_cg ); | |
98 | } | |
99 | private: | |
100 | CGContextRef m_cg; | |
101 | }; | |
102 | ||
eefe52da SC |
103 | class WXDLLIMPEXP_CORE wxDeferredObjectDeleter : public wxObject |
104 | { | |
105 | public : | |
03647350 | 106 | wxDeferredObjectDeleter( wxObject* obj ) : m_obj(obj) |
eefe52da SC |
107 | { |
108 | } | |
109 | virtual ~wxDeferredObjectDeleter() | |
110 | { | |
111 | delete m_obj; | |
112 | } | |
113 | protected : | |
114 | wxObject* m_obj ; | |
115 | } ; | |
5c6eb3a8 SC |
116 | |
117 | // Quartz | |
118 | ||
119 | WXDLLIMPEXP_CORE CGImageRef wxMacCreateCGImageFromBitmap( const wxBitmap& bitmap ); | |
120 | ||
121 | WXDLLIMPEXP_CORE CGDataProviderRef wxMacCGDataProviderCreateWithCFData( CFDataRef data ); | |
122 | WXDLLIMPEXP_CORE CGDataConsumerRef wxMacCGDataConsumerCreateWithCFData( CFMutableDataRef data ); | |
123 | WXDLLIMPEXP_CORE CGDataProviderRef wxMacCGDataProviderCreateWithMemoryBuffer( const wxMemoryBuffer& buf ); | |
124 | ||
125 | CGColorSpaceRef WXDLLIMPEXP_CORE wxMacGetGenericRGBColorSpace(void); | |
126 | ||
eefe52da SC |
127 | class wxWindowMac; |
128 | // to | |
129 | extern wxWindow* g_MacLastWindow; | |
130 | class wxNonOwnedWindow; | |
131 | ||
524c47aa SC |
132 | // temporary typedef so that no additional casts are necessary within carbon code at the moment |
133 | ||
134 | class wxMacControl; | |
135 | class wxWidgetImpl; | |
c072b9ec | 136 | class wxComboBox; |
524c47aa | 137 | class wxNotebook; |
de24bdf2 | 138 | class wxTextCtrl; |
11f87a38 | 139 | class wxSearchCtrl; |
524c47aa | 140 | |
8fa9ac5e SC |
141 | WXDLLIMPEXP_CORE wxWindowMac * wxFindWindowFromWXWidget(WXWidget inControl ); |
142 | ||
524c47aa SC |
143 | #if wxOSX_USE_CARBON |
144 | typedef wxMacControl wxWidgetImplType; | |
145 | #else | |
146 | typedef wxWidgetImpl wxWidgetImplType; | |
147 | #endif | |
148 | ||
6c1f25cc | 149 | #if wxUSE_MENUS |
03647350 | 150 | class wxMenuItemImpl : public wxObject |
524c47aa SC |
151 | { |
152 | public : | |
153 | wxMenuItemImpl( wxMenuItem* peer ) : m_peer(peer) | |
154 | { | |
155 | } | |
03647350 | 156 | |
524c47aa SC |
157 | virtual ~wxMenuItemImpl() ; |
158 | virtual void SetBitmap( const wxBitmap& bitmap ) = 0; | |
159 | virtual void Enable( bool enable ) = 0; | |
160 | virtual void Check( bool check ) = 0; | |
161 | virtual void SetLabel( const wxString& text, wxAcceleratorEntry *entry ) = 0; | |
162 | virtual void Hide( bool hide = true ) = 0; | |
03647350 | 163 | |
524c47aa SC |
164 | virtual void * GetHMenuItem() = 0; |
165 | ||
166 | wxMenuItem* GetWXPeer() { return m_peer ; } | |
167 | ||
168 | static wxMenuItemImpl* Create( wxMenuItem* peer, wxMenu *pParentMenu, | |
169 | int id, | |
170 | const wxString& text, | |
171 | wxAcceleratorEntry *entry, | |
172 | const wxString& strHelp, | |
173 | wxItemKind kind, | |
174 | wxMenu *pSubMenu ); | |
c46d0503 SC |
175 | |
176 | // handle OS specific menu items if they weren't handled during normal processing | |
8915e40c | 177 | virtual bool DoDefault() { return false; } |
524c47aa SC |
178 | protected : |
179 | wxMenuItem* m_peer; | |
03647350 | 180 | |
69cc4323 | 181 | DECLARE_ABSTRACT_CLASS(wxMenuItemImpl) |
524c47aa SC |
182 | } ; |
183 | ||
03647350 | 184 | class wxMenuImpl : public wxObject |
524c47aa SC |
185 | { |
186 | public : | |
187 | wxMenuImpl( wxMenu* peer ) : m_peer(peer) | |
188 | { | |
189 | } | |
03647350 VZ |
190 | |
191 | virtual ~wxMenuImpl() ; | |
192 | virtual void InsertOrAppend(wxMenuItem *pItem, size_t pos) = 0; | |
524c47aa | 193 | virtual void Remove( wxMenuItem *pItem ) = 0; |
03647350 | 194 | |
524c47aa SC |
195 | virtual void MakeRoot() = 0; |
196 | ||
197 | virtual void SetTitle( const wxString& text ) = 0; | |
198 | ||
199 | virtual WXHMENU GetHMenu() = 0; | |
03647350 | 200 | |
524c47aa SC |
201 | wxMenu* GetWXPeer() { return m_peer ; } |
202 | ||
2cb5d2d2 SC |
203 | virtual void PopUp( wxWindow *win, int x, int y ) = 0; |
204 | ||
524c47aa SC |
205 | static wxMenuImpl* Create( wxMenu* peer, const wxString& title ); |
206 | static wxMenuImpl* CreateRootMenu( wxMenu* peer ); | |
207 | protected : | |
208 | wxMenu* m_peer; | |
03647350 | 209 | |
69cc4323 | 210 | DECLARE_ABSTRACT_CLASS(wxMenuItemImpl) |
524c47aa | 211 | } ; |
6c1f25cc | 212 | #endif |
524c47aa SC |
213 | |
214 | ||
eefe52da SC |
215 | class WXDLLIMPEXP_CORE wxWidgetImpl : public wxObject |
216 | { | |
217 | public : | |
415f4a01 | 218 | wxWidgetImpl( wxWindowMac* peer , bool isRootControl = false, bool isUserPane = false ); |
eefe52da SC |
219 | wxWidgetImpl(); |
220 | virtual ~wxWidgetImpl(); | |
221 | ||
222 | void Init(); | |
223 | ||
eefe52da | 224 | bool IsRootControl() const { return m_isRootControl; } |
415f4a01 SC |
225 | |
226 | bool IsUserPane() const { return m_isUserPane; } | |
eefe52da SC |
227 | |
228 | wxWindowMac* GetWXPeer() const { return m_wxPeer; } | |
03647350 | 229 | |
eefe52da SC |
230 | bool IsOk() const { return GetWXWidget() != NULL; } |
231 | ||
232 | // not only the control itself, but also all its parents must be visible | |
233 | // in order for this function to return true | |
234 | virtual bool IsVisible() const = 0; | |
235 | // set the visibility of this widget (maybe latent) | |
236 | virtual void SetVisibility( bool visible ) = 0; | |
237 | ||
ab9a0b84 VZ |
238 | virtual bool ShowWithEffect(bool WXUNUSED(show), |
239 | wxShowEffect WXUNUSED(effect), | |
240 | unsigned WXUNUSED(timeout)) | |
241 | { | |
242 | return false; | |
243 | } | |
244 | ||
eefe52da | 245 | virtual void Raise() = 0; |
03647350 | 246 | |
eefe52da SC |
247 | virtual void Lower() = 0; |
248 | ||
249 | virtual void ScrollRect( const wxRect *rect, int dx, int dy ) = 0; | |
250 | ||
251 | virtual WXWidget GetWXWidget() const = 0; | |
03647350 | 252 | |
eefe52da | 253 | virtual void SetBackgroundColour( const wxColour& col ) = 0; |
bc5c09a3 | 254 | virtual bool SetBackgroundStyle(wxBackgroundStyle style) = 0; |
eefe52da SC |
255 | |
256 | // all coordinates in native parent widget relative coordinates | |
257 | virtual void GetContentArea( int &left , int &top , int &width , int &height ) const = 0; | |
258 | virtual void Move(int x, int y, int width, int height) = 0; | |
259 | virtual void GetPosition( int &x, int &y ) const = 0; | |
260 | virtual void GetSize( int &width, int &height ) const = 0; | |
524c47aa | 261 | virtual void SetControlSize( wxWindowVariant variant ) = 0; |
f18b5ee7 SC |
262 | virtual float GetContentScaleFactor() const |
263 | { | |
264 | return 1.0; | |
265 | } | |
54ea2834 SC |
266 | |
267 | // the native coordinates may have an 'aura' for shadows etc, if this is the case the layout | |
268 | // inset indicates on which insets the real control is drawn | |
269 | virtual void GetLayoutInset(int &left , int &top , int &right, int &bottom) const | |
270 | { | |
271 | left = top = right = bottom = 0; | |
272 | } | |
eefe52da | 273 | |
ee032c59 SC |
274 | // native view coordinates are topleft to bottom right (flipped regarding CoreGraphics origin) |
275 | virtual bool IsFlipped() const { return true; } | |
276 | ||
eefe52da SC |
277 | virtual void SetNeedsDisplay( const wxRect* where = NULL ) = 0; |
278 | virtual bool GetNeedsDisplay() const = 0; | |
279 | ||
280 | virtual bool NeedsFocusRect() const; | |
281 | virtual void SetNeedsFocusRect( bool needs ); | |
282 | ||
f2f6030e SC |
283 | virtual bool NeedsFrame() const; |
284 | virtual void SetNeedsFrame( bool needs ); | |
2ab38025 SC |
285 | |
286 | virtual void SetDrawingEnabled(bool enabled); | |
f2f6030e | 287 | |
eefe52da SC |
288 | virtual bool CanFocus() const = 0; |
289 | // return true if successful | |
290 | virtual bool SetFocus() = 0; | |
291 | virtual bool HasFocus() const = 0; | |
03647350 | 292 | |
eefe52da SC |
293 | virtual void RemoveFromParent() = 0; |
294 | virtual void Embed( wxWidgetImpl *parent ) = 0; | |
03647350 | 295 | |
524c47aa SC |
296 | virtual void SetDefaultButton( bool isDefault ) = 0; |
297 | virtual void PerformClick() = 0; | |
298 | virtual void SetLabel( const wxString& title, wxFontEncoding encoding ) = 0; | |
6a219e34 | 299 | #if wxUSE_MARKUP && wxOSX_USE_COCOA |
f672c969 VZ |
300 | virtual void SetLabelMarkup( const wxString& WXUNUSED(markup) ) { } |
301 | #endif | |
524c47aa | 302 | |
54f11060 SC |
303 | virtual void SetCursor( const wxCursor & cursor ) = 0; |
304 | virtual void CaptureMouse() = 0; | |
305 | virtual void ReleaseMouse() = 0; | |
5ce7b0b5 | 306 | |
87762892 | 307 | virtual void SetDropTarget( wxDropTarget * WXUNUSED(dropTarget) ) {} |
54f11060 | 308 | |
524c47aa SC |
309 | virtual wxInt32 GetValue() const = 0; |
310 | virtual void SetValue( wxInt32 v ) = 0; | |
e5d05b90 | 311 | virtual wxBitmap GetBitmap() const = 0; |
524c47aa | 312 | virtual void SetBitmap( const wxBitmap& bitmap ) = 0; |
e5d05b90 | 313 | virtual void SetBitmapPosition( wxDirection dir ) = 0; |
524c47aa SC |
314 | virtual void SetupTabs( const wxNotebook ¬ebook ) =0; |
315 | virtual void GetBestRect( wxRect *r ) const = 0; | |
316 | virtual bool IsEnabled() const = 0; | |
317 | virtual void Enable( bool enable ) = 0; | |
318 | virtual void SetMinimum( wxInt32 v ) = 0; | |
319 | virtual void SetMaximum( wxInt32 v ) = 0; | |
19c7ac3d SC |
320 | virtual wxInt32 GetMinimum() const = 0; |
321 | virtual wxInt32 GetMaximum() const = 0; | |
524c47aa SC |
322 | virtual void PulseGauge() = 0; |
323 | virtual void SetScrollThumb( wxInt32 value, wxInt32 thumbSize ) = 0; | |
324 | ||
1e181c7a | 325 | virtual void SetFont( const wxFont & font , const wxColour& foreground , long windowStyle, bool ignoreBlack = true ) = 0; |
ce00f59b | 326 | |
a7b9865d | 327 | virtual void SetToolTip(wxToolTip* WXUNUSED(tooltip)) { } |
1e181c7a | 328 | |
524c47aa SC |
329 | // is the clicked event sent AFTER the state already changed, so no additional |
330 | // state changing logic is required from the outside | |
331 | virtual bool ButtonClickDidStateChange() = 0; | |
03647350 | 332 | |
c4825ef7 | 333 | virtual void InstallEventHandler( WXWidget control = NULL ) = 0; |
ce00f59b | 334 | |
809020fc KO |
335 | // Mechanism used to keep track of whether a change should send an event |
336 | // Do SendEvents(false) when starting actions that would trigger programmatic events | |
337 | // and SendEvents(true) at the end of the block. | |
338 | virtual void SendEvents(bool shouldSendEvents) { m_shouldSendEvents = shouldSendEvents; } | |
339 | virtual bool ShouldSendEvents() { return m_shouldSendEvents; } | |
eefe52da | 340 | |
f55d9f74 SC |
341 | // static methods for associating native controls and their implementations |
342 | ||
03647350 | 343 | static wxWidgetImpl* |
f55d9f74 | 344 | FindFromWXWidget(WXWidget control); |
03647350 | 345 | |
f55d9f74 | 346 | static void RemoveAssociations( wxWidgetImpl* impl); |
03647350 | 347 | |
f55d9f74 | 348 | static void Associate( WXWidget control, wxWidgetImpl *impl ); |
03647350 | 349 | |
f06e0fea | 350 | static WXWidget FindFocus(); |
03647350 | 351 | |
eefe52da | 352 | // static creation methods, must be implemented by all toolkits |
03647350 VZ |
353 | |
354 | static wxWidgetImplType* CreateUserPane( wxWindowMac* wxpeer, | |
355 | wxWindowMac* parent, | |
356 | wxWindowID id, | |
357 | const wxPoint& pos, | |
524c47aa | 358 | const wxSize& size, |
03647350 | 359 | long style, |
524c47aa SC |
360 | long extraStyle) ; |
361 | static wxWidgetImplType* CreateContentView( wxNonOwnedWindow* now ) ; | |
362 | ||
03647350 VZ |
363 | static wxWidgetImplType* CreateButton( wxWindowMac* wxpeer, |
364 | wxWindowMac* parent, | |
365 | wxWindowID id, | |
524c47aa | 366 | const wxString& label, |
03647350 | 367 | const wxPoint& pos, |
524c47aa | 368 | const wxSize& size, |
03647350 | 369 | long style, |
524c47aa SC |
370 | long extraStyle) ; |
371 | ||
03647350 VZ |
372 | static wxWidgetImplType* CreateDisclosureTriangle( wxWindowMac* wxpeer, |
373 | wxWindowMac* parent, | |
374 | wxWindowID id, | |
524c47aa | 375 | const wxString& label, |
03647350 | 376 | const wxPoint& pos, |
524c47aa | 377 | const wxSize& size, |
03647350 | 378 | long style, |
524c47aa | 379 | long extraStyle) ; |
03647350 VZ |
380 | |
381 | static wxWidgetImplType* CreateStaticLine( wxWindowMac* wxpeer, | |
382 | wxWindowMac* parent, | |
383 | wxWindowID id, | |
384 | const wxPoint& pos, | |
524c47aa | 385 | const wxSize& size, |
03647350 | 386 | long style, |
524c47aa SC |
387 | long extraStyle) ; |
388 | ||
03647350 VZ |
389 | static wxWidgetImplType* CreateGroupBox( wxWindowMac* wxpeer, |
390 | wxWindowMac* parent, | |
391 | wxWindowID id, | |
524c47aa | 392 | const wxString& label, |
03647350 | 393 | const wxPoint& pos, |
524c47aa | 394 | const wxSize& size, |
03647350 | 395 | long style, |
524c47aa SC |
396 | long extraStyle) ; |
397 | ||
03647350 VZ |
398 | static wxWidgetImplType* CreateStaticText( wxWindowMac* wxpeer, |
399 | wxWindowMac* parent, | |
400 | wxWindowID id, | |
524c47aa | 401 | const wxString& label, |
03647350 | 402 | const wxPoint& pos, |
524c47aa | 403 | const wxSize& size, |
03647350 | 404 | long style, |
524c47aa SC |
405 | long extraStyle) ; |
406 | ||
03647350 VZ |
407 | static wxWidgetImplType* CreateTextControl( wxTextCtrl* wxpeer, |
408 | wxWindowMac* parent, | |
409 | wxWindowID id, | |
524c47aa | 410 | const wxString& content, |
03647350 | 411 | const wxPoint& pos, |
524c47aa | 412 | const wxSize& size, |
03647350 | 413 | long style, |
524c47aa SC |
414 | long extraStyle) ; |
415 | ||
11f87a38 | 416 | static wxWidgetImplType* CreateSearchControl( wxSearchCtrl* wxpeer, |
03647350 VZ |
417 | wxWindowMac* parent, |
418 | wxWindowID id, | |
1e181c7a | 419 | const wxString& content, |
03647350 | 420 | const wxPoint& pos, |
1e181c7a | 421 | const wxSize& size, |
03647350 | 422 | long style, |
1e181c7a SC |
423 | long extraStyle) ; |
424 | ||
03647350 VZ |
425 | static wxWidgetImplType* CreateCheckBox( wxWindowMac* wxpeer, |
426 | wxWindowMac* parent, | |
427 | wxWindowID id, | |
524c47aa | 428 | const wxString& label, |
03647350 | 429 | const wxPoint& pos, |
524c47aa | 430 | const wxSize& size, |
03647350 | 431 | long style, |
524c47aa | 432 | long extraStyle); |
03647350 VZ |
433 | |
434 | static wxWidgetImplType* CreateRadioButton( wxWindowMac* wxpeer, | |
435 | wxWindowMac* parent, | |
436 | wxWindowID id, | |
524c47aa | 437 | const wxString& label, |
03647350 | 438 | const wxPoint& pos, |
524c47aa | 439 | const wxSize& size, |
03647350 | 440 | long style, |
524c47aa SC |
441 | long extraStyle); |
442 | ||
03647350 VZ |
443 | static wxWidgetImplType* CreateToggleButton( wxWindowMac* wxpeer, |
444 | wxWindowMac* parent, | |
445 | wxWindowID id, | |
524c47aa | 446 | const wxString& label, |
03647350 | 447 | const wxPoint& pos, |
524c47aa | 448 | const wxSize& size, |
03647350 | 449 | long style, |
524c47aa SC |
450 | long extraStyle); |
451 | ||
03647350 VZ |
452 | static wxWidgetImplType* CreateBitmapToggleButton( wxWindowMac* wxpeer, |
453 | wxWindowMac* parent, | |
454 | wxWindowID id, | |
524c47aa | 455 | const wxBitmap& bitmap, |
03647350 | 456 | const wxPoint& pos, |
524c47aa | 457 | const wxSize& size, |
03647350 | 458 | long style, |
524c47aa SC |
459 | long extraStyle); |
460 | ||
03647350 VZ |
461 | static wxWidgetImplType* CreateBitmapButton( wxWindowMac* wxpeer, |
462 | wxWindowMac* parent, | |
463 | wxWindowID id, | |
524c47aa | 464 | const wxBitmap& bitmap, |
03647350 | 465 | const wxPoint& pos, |
524c47aa | 466 | const wxSize& size, |
03647350 | 467 | long style, |
524c47aa SC |
468 | long extraStyle); |
469 | ||
03647350 VZ |
470 | static wxWidgetImplType* CreateTabView( wxWindowMac* wxpeer, |
471 | wxWindowMac* parent, | |
472 | wxWindowID id, | |
473 | const wxPoint& pos, | |
524c47aa | 474 | const wxSize& size, |
03647350 | 475 | long style, |
524c47aa SC |
476 | long extraStyle); |
477 | ||
03647350 VZ |
478 | static wxWidgetImplType* CreateGauge( wxWindowMac* wxpeer, |
479 | wxWindowMac* parent, | |
480 | wxWindowID id, | |
524c47aa SC |
481 | wxInt32 value, |
482 | wxInt32 minimum, | |
483 | wxInt32 maximum, | |
03647350 | 484 | const wxPoint& pos, |
524c47aa | 485 | const wxSize& size, |
03647350 | 486 | long style, |
524c47aa SC |
487 | long extraStyle); |
488 | ||
03647350 VZ |
489 | static wxWidgetImplType* CreateSlider( wxWindowMac* wxpeer, |
490 | wxWindowMac* parent, | |
491 | wxWindowID id, | |
524c47aa SC |
492 | wxInt32 value, |
493 | wxInt32 minimum, | |
494 | wxInt32 maximum, | |
03647350 | 495 | const wxPoint& pos, |
524c47aa | 496 | const wxSize& size, |
03647350 | 497 | long style, |
524c47aa SC |
498 | long extraStyle); |
499 | ||
03647350 VZ |
500 | static wxWidgetImplType* CreateSpinButton( wxWindowMac* wxpeer, |
501 | wxWindowMac* parent, | |
502 | wxWindowID id, | |
524c47aa SC |
503 | wxInt32 value, |
504 | wxInt32 minimum, | |
505 | wxInt32 maximum, | |
03647350 | 506 | const wxPoint& pos, |
524c47aa | 507 | const wxSize& size, |
03647350 | 508 | long style, |
524c47aa SC |
509 | long extraStyle); |
510 | ||
03647350 VZ |
511 | static wxWidgetImplType* CreateScrollBar( wxWindowMac* wxpeer, |
512 | wxWindowMac* parent, | |
513 | wxWindowID id, | |
514 | const wxPoint& pos, | |
524c47aa | 515 | const wxSize& size, |
03647350 | 516 | long style, |
524c47aa SC |
517 | long extraStyle); |
518 | ||
03647350 VZ |
519 | static wxWidgetImplType* CreateChoice( wxWindowMac* wxpeer, |
520 | wxWindowMac* parent, | |
521 | wxWindowID id, | |
524c47aa | 522 | wxMenu* menu, |
03647350 | 523 | const wxPoint& pos, |
524c47aa | 524 | const wxSize& size, |
03647350 | 525 | long style, |
524c47aa SC |
526 | long extraStyle); |
527 | ||
03647350 VZ |
528 | static wxWidgetImplType* CreateListBox( wxWindowMac* wxpeer, |
529 | wxWindowMac* parent, | |
530 | wxWindowID id, | |
531 | const wxPoint& pos, | |
524c47aa | 532 | const wxSize& size, |
03647350 | 533 | long style, |
524c47aa | 534 | long extraStyle); |
eefe52da | 535 | |
c84030e0 | 536 | #if wxOSX_USE_COCOA |
ce00f59b VZ |
537 | static wxWidgetImplType* CreateComboBox( wxComboBox* wxpeer, |
538 | wxWindowMac* parent, | |
539 | wxWindowID id, | |
f941a30b | 540 | wxMenu* menu, |
ce00f59b | 541 | const wxPoint& pos, |
f941a30b | 542 | const wxSize& size, |
ce00f59b | 543 | long style, |
f941a30b KO |
544 | long extraStyle); |
545 | #endif | |
546 | ||
eefe52da SC |
547 | // converts from Toplevel-Content relative to local |
548 | static void Convert( wxPoint *pt , wxWidgetImpl *from , wxWidgetImpl *to ); | |
549 | protected : | |
550 | bool m_isRootControl; | |
415f4a01 | 551 | bool m_isUserPane; |
eefe52da SC |
552 | wxWindowMac* m_wxPeer; |
553 | bool m_needsFocusRect; | |
f2f6030e | 554 | bool m_needsFrame; |
809020fc | 555 | bool m_shouldSendEvents; |
eefe52da SC |
556 | |
557 | DECLARE_ABSTRACT_CLASS(wxWidgetImpl) | |
558 | }; | |
559 | ||
524c47aa SC |
560 | // |
561 | // the interface to be implemented eg by a listbox | |
562 | // | |
563 | ||
03647350 | 564 | class WXDLLIMPEXP_CORE wxListWidgetColumn |
524c47aa SC |
565 | { |
566 | public : | |
567 | virtual ~wxListWidgetColumn() {} | |
568 | } ; | |
569 | ||
570 | class WXDLLIMPEXP_CORE wxListWidgetCellValue | |
571 | { | |
572 | public : | |
573 | wxListWidgetCellValue() {} | |
574 | virtual ~wxListWidgetCellValue() {} | |
03647350 | 575 | |
524c47aa SC |
576 | virtual void Set( CFStringRef value ) = 0; |
577 | virtual void Set( const wxString& value ) = 0; | |
578 | virtual void Set( int value ) = 0; | |
60ebcb8a | 579 | virtual void Check( bool check ); |
03647350 | 580 | |
60ebcb8a | 581 | virtual bool IsChecked() const; |
524c47aa SC |
582 | virtual int GetIntValue() const = 0; |
583 | virtual wxString GetStringValue() const = 0; | |
584 | } ; | |
585 | ||
586 | class WXDLLIMPEXP_CORE wxListWidgetImpl | |
587 | { | |
588 | public: | |
589 | wxListWidgetImpl() {} | |
590 | virtual ~wxListWidgetImpl() { } | |
03647350 VZ |
591 | |
592 | virtual wxListWidgetColumn* InsertTextColumn( unsigned pos, const wxString& title, bool editable = false, | |
524c47aa | 593 | wxAlignment just = wxALIGN_LEFT , int defaultWidth = -1) = 0 ; |
03647350 | 594 | virtual wxListWidgetColumn* InsertCheckColumn( unsigned pos , const wxString& title, bool editable = false, |
524c47aa | 595 | wxAlignment just = wxALIGN_LEFT , int defaultWidth = -1) = 0 ; |
03647350 | 596 | |
524c47aa SC |
597 | // add and remove |
598 | ||
599 | // TODO will be replaced | |
600 | virtual void ListDelete( unsigned int n ) = 0; | |
601 | virtual void ListInsert( unsigned int n ) = 0; | |
602 | virtual void ListClear() = 0; | |
603 | ||
604 | // selecting | |
605 | ||
606 | virtual void ListDeselectAll() = 0; | |
607 | virtual void ListSetSelection( unsigned int n, bool select, bool multi ) = 0; | |
608 | virtual int ListGetSelection() const = 0; | |
609 | virtual int ListGetSelections( wxArrayInt& aSelections ) const = 0; | |
610 | virtual bool ListIsSelected( unsigned int n ) const = 0; | |
03647350 | 611 | |
524c47aa SC |
612 | // display |
613 | ||
614 | virtual void ListScrollTo( unsigned int n ) = 0; | |
615 | virtual void UpdateLine( unsigned int n, wxListWidgetColumn* col = NULL ) = 0; | |
616 | virtual void UpdateLineToEnd( unsigned int n) = 0; | |
617 | ||
618 | // accessing content | |
619 | ||
620 | virtual unsigned int ListGetCount() const = 0; | |
ce00f59b | 621 | |
20196e15 | 622 | virtual int DoListHitTest( const wxPoint& inpoint ) const = 0; |
524c47aa SC |
623 | }; |
624 | ||
1e181c7a SC |
625 | // |
626 | // interface to be implemented by a textcontrol | |
627 | // | |
628 | ||
21a9d326 | 629 | class WXDLLIMPEXP_FWD_CORE wxTextAttr; |
c072b9ec | 630 | class WXDLLIMPEXP_FWD_CORE wxTextEntry; |
21a9d326 | 631 | |
1e181c7a SC |
632 | // common interface for all implementations |
633 | class WXDLLIMPEXP_CORE wxTextWidgetImpl | |
634 | ||
635 | { | |
636 | public : | |
c072b9ec VZ |
637 | // Any widgets implementing this interface must be associated with a |
638 | // wxTextEntry so instead of requiring the derived classes to implement | |
639 | // another (pure) virtual function, just take the pointer to this entry in | |
640 | // our ctor and implement GetTextEntry() ourselves. | |
641 | wxTextWidgetImpl(wxTextEntry *entry) : m_entry(entry) {} | |
1e181c7a SC |
642 | |
643 | virtual ~wxTextWidgetImpl() {} | |
644 | ||
c072b9ec VZ |
645 | wxTextEntry *GetTextEntry() const { return m_entry; } |
646 | ||
1e181c7a SC |
647 | virtual bool CanFocus() const { return true; } |
648 | ||
649 | virtual wxString GetStringValue() const = 0 ; | |
650 | virtual void SetStringValue( const wxString &val ) = 0 ; | |
651 | virtual void SetSelection( long from, long to ) = 0 ; | |
652 | virtual void GetSelection( long* from, long* to ) const = 0 ; | |
653 | virtual void WriteText( const wxString& str ) = 0 ; | |
654 | ||
4386db06 SC |
655 | virtual bool CanClipMaxLength() const { return false; } |
656 | virtual void SetMaxLength(unsigned long WXUNUSED(len)) {} | |
657 | ||
16671f22 | 658 | virtual bool GetStyle( long position, wxTextAttr& style); |
1e181c7a SC |
659 | virtual void SetStyle( long start, long end, const wxTextAttr& style ) ; |
660 | virtual void Copy() ; | |
661 | virtual void Cut() ; | |
662 | virtual void Paste() ; | |
663 | virtual bool CanPaste() const ; | |
664 | virtual void SetEditable( bool editable ) ; | |
0b6a49c2 | 665 | virtual long GetLastPosition() const ; |
1e181c7a SC |
666 | virtual void Replace( long from, long to, const wxString &str ) ; |
667 | virtual void Remove( long from, long to ) ; | |
668 | ||
669 | ||
670 | virtual bool HasOwnContextMenu() const | |
671 | { return false ; } | |
672 | ||
673 | virtual bool SetupCursor( const wxPoint& WXUNUSED(pt) ) | |
674 | { return false ; } | |
675 | ||
676 | virtual void Clear() ; | |
677 | virtual bool CanUndo() const; | |
678 | virtual void Undo() ; | |
679 | virtual bool CanRedo() const; | |
680 | virtual void Redo() ; | |
681 | virtual int GetNumberOfLines() const ; | |
682 | virtual long XYToPosition(long x, long y) const; | |
683 | virtual bool PositionToXY(long pos, long *x, long *y) const ; | |
684 | virtual void ShowPosition(long WXUNUSED(pos)) ; | |
685 | virtual int GetLineLength(long lineNo) const ; | |
686 | virtual wxString GetLineText(long lineNo) const ; | |
687 | virtual void CheckSpelling(bool WXUNUSED(check)) { } | |
ce00f59b | 688 | |
9ab7ff53 | 689 | virtual wxSize GetBestSize() const { return wxDefaultSize; } |
c072b9ec | 690 | |
99eb484a | 691 | virtual bool SetHint(const wxString& WXUNUSED(hint)) { return false; } |
c072b9ec VZ |
692 | private: |
693 | wxTextEntry * const m_entry; | |
694 | ||
695 | wxDECLARE_NO_COPY_CLASS(wxTextWidgetImpl); | |
1e181c7a SC |
696 | }; |
697 | ||
c84030e0 KO |
698 | // common interface for all implementations |
699 | class WXDLLIMPEXP_CORE wxComboWidgetImpl | |
700 | ||
701 | { | |
702 | public : | |
703 | wxComboWidgetImpl() {} | |
704 | ||
705 | virtual ~wxComboWidgetImpl() {} | |
ce00f59b | 706 | |
6dd0883d SN |
707 | virtual int GetSelectedItem() const { return -1; } |
708 | virtual void SetSelectedItem(int WXUNUSED(item)) {} | |
ce00f59b | 709 | |
6dd0883d | 710 | virtual int GetNumberOfItems() const { return -1; } |
ce00f59b | 711 | |
c84030e0 | 712 | virtual void InsertItem(int WXUNUSED(pos), const wxString& WXUNUSED(item)) {} |
ce00f59b | 713 | |
c84030e0 | 714 | virtual void RemoveItem(int WXUNUSED(pos)) {} |
ce00f59b | 715 | |
c84030e0 | 716 | virtual void Clear() {} |
ff8cb900 VZ |
717 | virtual void Popup() {} |
718 | virtual void Dismiss() {} | |
ce00f59b | 719 | |
c84030e0 | 720 | virtual wxString GetStringAtIndex(int WXUNUSED(pos)) const { return wxEmptyString; } |
ce00f59b | 721 | |
c84030e0 KO |
722 | virtual int FindString(const wxString& WXUNUSED(text)) const { return -1; } |
723 | }; | |
724 | ||
411a1c35 | 725 | // |
b38dc31f | 726 | // common interface for buttons |
411a1c35 SC |
727 | // |
728 | ||
b38dc31f | 729 | class wxButtonImpl |
411a1c35 SC |
730 | { |
731 | public : | |
b38dc31f SC |
732 | wxButtonImpl(){} |
733 | virtual ~wxButtonImpl(){} | |
ce00f59b | 734 | |
411a1c35 SC |
735 | virtual void SetPressedBitmap( const wxBitmap& bitmap ) = 0; |
736 | } ; | |
737 | ||
1e181c7a SC |
738 | // |
739 | // common interface for search controls | |
740 | // | |
741 | ||
742 | class wxSearchWidgetImpl | |
743 | { | |
744 | public : | |
745 | wxSearchWidgetImpl(){} | |
746 | virtual ~wxSearchWidgetImpl(){} | |
747 | ||
748 | // search field options | |
749 | virtual void ShowSearchButton( bool show ) = 0; | |
750 | virtual bool IsSearchButtonVisible() const = 0; | |
751 | ||
752 | virtual void ShowCancelButton( bool show ) = 0; | |
753 | virtual bool IsCancelButtonVisible() const = 0; | |
754 | ||
755 | virtual void SetSearchMenu( wxMenu* menu ) = 0; | |
756 | ||
757 | virtual void SetDescriptiveText(const wxString& text) = 0; | |
758 | } ; | |
759 | ||
524c47aa SC |
760 | // |
761 | // toplevel window implementation class | |
762 | // | |
763 | ||
eefe52da SC |
764 | class wxNonOwnedWindowImpl : public wxObject |
765 | { | |
766 | public : | |
767 | wxNonOwnedWindowImpl( wxNonOwnedWindow* nonownedwnd) : m_wxPeer(nonownedwnd) | |
768 | { | |
769 | } | |
770 | wxNonOwnedWindowImpl() | |
771 | { | |
772 | } | |
773 | virtual ~wxNonOwnedWindowImpl() | |
774 | { | |
775 | } | |
03647350 | 776 | |
0aaa6ace | 777 | virtual void WillBeDestroyed() |
eefe52da SC |
778 | { |
779 | } | |
780 | ||
781 | virtual void Create( wxWindow* parent, const wxPoint& pos, const wxSize& size, | |
782 | long style, long extraStyle, const wxString& name ) = 0; | |
03647350 VZ |
783 | |
784 | ||
eefe52da | 785 | virtual WXWindow GetWXWindow() const = 0; |
03647350 | 786 | |
eefe52da SC |
787 | virtual void Raise() |
788 | { | |
789 | } | |
03647350 | 790 | |
eefe52da SC |
791 | virtual void Lower() |
792 | { | |
793 | } | |
794 | ||
1aec1f8b | 795 | virtual bool Show(bool WXUNUSED(show)) |
eefe52da SC |
796 | { |
797 | return false; | |
798 | } | |
03647350 | 799 | |
1aec1f8b | 800 | virtual bool ShowWithEffect(bool show, wxShowEffect WXUNUSED(effect), unsigned WXUNUSED(timeout)) |
eefe52da SC |
801 | { |
802 | return Show(show); | |
803 | } | |
03647350 | 804 | |
eefe52da SC |
805 | virtual void Update() |
806 | { | |
807 | } | |
808 | ||
1aec1f8b | 809 | virtual bool SetTransparent(wxByte WXUNUSED(alpha)) |
eefe52da SC |
810 | { |
811 | return false; | |
812 | } | |
813 | ||
1aec1f8b | 814 | virtual bool SetBackgroundColour(const wxColour& WXUNUSED(col) ) |
eefe52da SC |
815 | { |
816 | return false; | |
817 | } | |
818 | ||
1aec1f8b | 819 | virtual void SetExtraStyle( long WXUNUSED(exStyle) ) |
eefe52da SC |
820 | { |
821 | } | |
ce00f59b | 822 | |
b6dc21e7 KO |
823 | virtual void SetWindowStyleFlag( long WXUNUSED(style) ) |
824 | { | |
825 | } | |
ce00f59b | 826 | |
1aec1f8b | 827 | virtual bool SetBackgroundStyle(wxBackgroundStyle WXUNUSED(style)) |
03647350 | 828 | { |
eefe52da SC |
829 | return false ; |
830 | } | |
03647350 | 831 | |
6f5778a6 | 832 | virtual bool CanSetTransparent() |
eefe52da SC |
833 | { |
834 | return false; | |
835 | } | |
836 | ||
03647350 | 837 | virtual void GetContentArea( int &left , int &top , int &width , int &height ) const = 0; |
eefe52da SC |
838 | virtual void MoveWindow(int x, int y, int width, int height) = 0; |
839 | virtual void GetPosition( int &x, int &y ) const = 0; | |
840 | virtual void GetSize( int &width, int &height ) const = 0; | |
841 | ||
1aec1f8b | 842 | virtual bool SetShape(const wxRegion& WXUNUSED(region)) |
eefe52da SC |
843 | { |
844 | return false; | |
845 | } | |
03647350 | 846 | |
eefe52da | 847 | virtual void SetTitle( const wxString& title, wxFontEncoding encoding ) = 0; |
03647350 | 848 | |
eefe52da | 849 | virtual bool IsMaximized() const = 0; |
03647350 | 850 | |
eefe52da | 851 | virtual bool IsIconized() const= 0; |
03647350 | 852 | |
eefe52da | 853 | virtual void Iconize( bool iconize )= 0; |
03647350 | 854 | |
eefe52da | 855 | virtual void Maximize(bool maximize) = 0; |
03647350 | 856 | |
eefe52da | 857 | virtual bool IsFullScreen() const= 0; |
03647350 | 858 | |
dbc7ceb9 | 859 | virtual void ShowWithoutActivating() { Show(true); } |
ce00f59b | 860 | |
eefe52da SC |
861 | virtual bool ShowFullScreen(bool show, long style)= 0; |
862 | ||
863 | virtual void RequestUserAttention(int flags) = 0; | |
03647350 VZ |
864 | |
865 | virtual void ScreenToWindow( int *x, int *y ) = 0; | |
866 | ||
eefe52da | 867 | virtual void WindowToScreen( int *x, int *y ) = 0; |
03647350 | 868 | |
dbc7ceb9 | 869 | virtual bool IsActive() = 0; |
ce00f59b | 870 | |
eefe52da | 871 | wxNonOwnedWindow* GetWXPeer() { return m_wxPeer; } |
03647350 | 872 | |
075e3553 SC |
873 | static wxNonOwnedWindowImpl* |
874 | FindFromWXWindow(WXWindow window); | |
ce00f59b | 875 | |
075e3553 | 876 | static void RemoveAssociations( wxNonOwnedWindowImpl* impl); |
ce00f59b | 877 | |
075e3553 | 878 | static void Associate( WXWindow window, wxNonOwnedWindowImpl *impl ); |
ce00f59b | 879 | |
524c47aa | 880 | // static creation methods, must be implemented by all toolkits |
03647350 | 881 | |
17e2694c | 882 | static wxNonOwnedWindowImpl* CreateNonOwnedWindow( wxNonOwnedWindow* wxpeer, wxWindow* parent, WXWindow native) ; |
ce00f59b | 883 | |
524c47aa SC |
884 | static wxNonOwnedWindowImpl* CreateNonOwnedWindow( wxNonOwnedWindow* wxpeer, wxWindow* parent, const wxPoint& pos, const wxSize& size, |
885 | long style, long extraStyle, const wxString& name ) ; | |
ce00f59b | 886 | |
efb2fa41 | 887 | virtual void SetModified(bool WXUNUSED(modified)) { } |
ebf7d5c4 | 888 | virtual bool IsModified() const { return false; } |
524c47aa | 889 | |
6a0e4ead VZ |
890 | virtual void SetRepresentedFilename(const wxString& WXUNUSED(filename)) { } |
891 | ||
31c659e8 SC |
892 | #if wxOSX_USE_IPHONE |
893 | virtual CGFloat GetWindowLevel() const { return 0.0; } | |
894 | #else | |
9d243a47 | 895 | virtual CGWindowLevel GetWindowLevel() const { return kCGNormalWindowLevel; } |
31c659e8 | 896 | #endif |
9d243a47 | 897 | virtual void RestoreWindowLevel() {} |
eefe52da SC |
898 | protected : |
899 | wxNonOwnedWindow* m_wxPeer; | |
900 | DECLARE_ABSTRACT_CLASS(wxNonOwnedWindowImpl) | |
901 | }; | |
902 | ||
5c6eb3a8 SC |
903 | #endif // wxUSE_GUI |
904 | ||
905 | //--------------------------------------------------------------------------- | |
906 | // cocoa bridging utilities | |
907 | //--------------------------------------------------------------------------- | |
908 | ||
909 | bool wxMacInitCocoa(); | |
910 | ||
911 | class WXDLLIMPEXP_CORE wxMacAutoreleasePool | |
912 | { | |
913 | public : | |
914 | wxMacAutoreleasePool(); | |
915 | ~wxMacAutoreleasePool(); | |
916 | private : | |
917 | void* m_pool; | |
918 | }; | |
919 | ||
920 | // NSObject | |
921 | ||
922 | void wxMacCocoaRelease( void* obj ); | |
923 | void wxMacCocoaAutorelease( void* obj ); | |
f1c40652 | 924 | void* wxMacCocoaRetain( void* obj ); |
5c6eb3a8 SC |
925 | |
926 | ||
927 | #endif | |
eefe52da | 928 | // _WX_PRIVATE_CORE_H_ |