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