]>
Commit | Line | Data |
---|---|---|
8cf73271 | 1 | ///////////////////////////////////////////////////////////////////////////// |
fb5246be | 2 | // Name: wx/mac/carbon/private.h |
8cf73271 | 3 | // Purpose: Private declarations: as this header is only included by |
77ffb593 | 4 | // wxWidgets itself, it may contain identifiers which don't start |
8cf73271 SC |
5 | // with "wx". |
6 | // Author: Stefan Csomor | |
7 | // Modified by: | |
8 | // Created: 1998-01-01 | |
9 | // RCS-ID: $Id$ | |
10 | // Copyright: (c) Stefan Csomor | |
65571936 | 11 | // Licence: wxWindows licence |
8cf73271 SC |
12 | ///////////////////////////////////////////////////////////////////////////// |
13 | ||
14 | #ifndef _WX_PRIVATE_H_ | |
15 | #define _WX_PRIVATE_H_ | |
16 | ||
17 | #include "wx/defs.h" | |
8cf73271 SC |
18 | |
19 | #ifdef __DARWIN__ | |
20 | # include <Carbon/Carbon.h> | |
21 | #else | |
4f305456 | 22 | # include <Debugging.h> |
8cf73271 SC |
23 | # include <Quickdraw.h> |
24 | # include <Appearance.h> | |
25 | # include <Folders.h> | |
26 | # include <Controls.h> | |
27 | # include <ControlDefinitions.h> | |
28 | # include <LowMem.h> | |
29 | # include <Gestalt.h> | |
d9af087c | 30 | # include <FixMath.h> |
a6140a4c | 31 | # include <CoreServices.h> |
8cf73271 SC |
32 | #endif |
33 | ||
a6140a4c | 34 | #if UNIVERSAL_INTERFACES_VERSION < 0x0342 |
dd0d56f5 | 35 | #error "please update to Apple's latest universal headers from http://developer.apple.com/sdk/" |
8cf73271 SC |
36 | #endif |
37 | ||
c3a404b0 SC |
38 | #ifndef MAC_OS_X_VERSION_10_3 |
39 | #define MAC_OS_X_VERSION_10_3 1030 | |
40 | #endif | |
41 | ||
ddb08e02 SC |
42 | #ifndef MAC_OS_X_VERSION_10_4 |
43 | #define MAC_OS_X_VERSION_10_4 1040 | |
44 | #endif | |
45 | ||
fe63cfad SC |
46 | #ifndef MAC_OS_X_VERSION_10_5 |
47 | #define MAC_OS_X_VERSION_10_5 1050 | |
48 | #endif | |
49 | ||
5185263f DE |
50 | #ifdef __WXMAC_CARBON__ |
51 | #include "wx/mac/corefoundation/cfstring.h" | |
ebf2a1ec | 52 | #include "wx/mac/corefoundation/cfdataref.h" |
5185263f DE |
53 | #endif |
54 | ||
3d639707 SC |
55 | #ifndef FixedToInt |
56 | // as macro in FixMath.h for 10.3 | |
57 | inline Fixed IntToFixed( int inInt ) | |
58 | { | |
59 | return (((SInt32) inInt) << 16); | |
60 | } | |
61 | ||
62 | inline int FixedToInt( Fixed inFixed ) | |
63 | { | |
64 | return (((SInt32) inFixed) >> 16); | |
65 | } | |
66 | #endif | |
67 | ||
fc964c0d | 68 | #if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5 |
fe63cfad SC |
69 | typedef UInt32 URefCon; |
70 | typedef SInt32 SRefCon; | |
71 | #endif | |
72 | ||
8cf73271 SC |
73 | #if wxUSE_GUI |
74 | ||
dd0d56f5 | 75 | #include "wx/listbox.h" |
8cf73271 | 76 | |
eb89f88a SC |
77 | #ifndef __LP64__ |
78 | ||
fb5246be | 79 | class wxMacPortStateHelper |
8cf73271 SC |
80 | { |
81 | DECLARE_NO_COPY_CLASS(wxMacPortStateHelper) | |
fb5246be | 82 | |
8cf73271 | 83 | public: |
6cce68ea SC |
84 | wxMacPortStateHelper( GrafPtr newport); |
85 | wxMacPortStateHelper(); | |
86 | ~wxMacPortStateHelper(); | |
8cf73271 | 87 | |
6cce68ea SC |
88 | void Setup( GrafPtr newport ); |
89 | void Clear(); | |
90 | bool IsCleared() { return m_clip == NULL; } | |
91 | GrafPtr GetCurrentPort() { return m_currentPort; } | |
8cf73271 SC |
92 | |
93 | private: | |
6cce68ea SC |
94 | GrafPtr m_currentPort; |
95 | GrafPtr m_oldPort; | |
96 | RgnHandle m_clip; | |
97 | ThemeDrawingState m_drawingState; | |
98 | short m_textFont; | |
99 | short m_textSize; | |
100 | short m_textStyle; | |
101 | short m_textMode; | |
102 | }; | |
8cf73271 | 103 | |
4f305456 SC |
104 | class WXDLLEXPORT wxMacPortSaver |
105 | { | |
106 | DECLARE_NO_COPY_CLASS(wxMacPortSaver) | |
fb5246be | 107 | |
4f305456 | 108 | public: |
54ce9ebb JS |
109 | wxMacPortSaver( GrafPtr port ); |
110 | ~wxMacPortSaver(); | |
4f305456 | 111 | private : |
6cce68ea SC |
112 | GrafPtr m_port; |
113 | }; | |
4f305456 | 114 | |
8cf73271 SC |
115 | class WXDLLEXPORT wxMacPortSetter |
116 | { | |
117 | DECLARE_NO_COPY_CLASS(wxMacPortSetter) | |
fb5246be | 118 | |
8cf73271 | 119 | public: |
6cce68ea SC |
120 | wxMacPortSetter( const wxDC* dc ); |
121 | ~wxMacPortSetter(); | |
8cf73271 | 122 | private: |
6cce68ea SC |
123 | wxMacPortStateHelper m_ph; |
124 | const wxDC* m_dc; | |
125 | }; | |
8cf73271 | 126 | |
4f305456 SC |
127 | /* |
128 | Clips to the visible region of a control within the current port | |
129 | */ | |
fb5246be | 130 | |
4f305456 | 131 | class WXDLLEXPORT wxMacWindowClipper : public wxMacPortSaver |
8cf73271 SC |
132 | { |
133 | DECLARE_NO_COPY_CLASS(wxMacWindowClipper) | |
fb5246be | 134 | |
8cf73271 | 135 | public: |
6cce68ea SC |
136 | wxMacWindowClipper( const wxWindow* win ); |
137 | ~wxMacWindowClipper(); | |
8cf73271 | 138 | private: |
6cce68ea SC |
139 | GrafPtr m_newPort; |
140 | RgnHandle m_formerClip; | |
141 | RgnHandle m_newClip; | |
142 | }; | |
8cf73271 | 143 | |
01299d56 SC |
144 | class WXDLLEXPORT wxMacWindowStateSaver : public wxMacWindowClipper |
145 | { | |
146 | DECLARE_NO_COPY_CLASS(wxMacWindowStateSaver) | |
fb5246be | 147 | |
01299d56 | 148 | public: |
6cce68ea SC |
149 | wxMacWindowStateSaver( const wxWindow* win ); |
150 | ~wxMacWindowStateSaver(); | |
01299d56 | 151 | private: |
6cce68ea SC |
152 | GrafPtr m_newPort; |
153 | ThemeDrawingState m_themeDrawingState; | |
154 | }; | |
eb89f88a | 155 | #endif |
01299d56 | 156 | |
ddb08e02 | 157 | #if wxMAC_USE_CORE_GRAPHICS |
fb5246be | 158 | class WXDLLEXPORT wxMacCGContextStateSaver |
ddb08e02 SC |
159 | { |
160 | DECLARE_NO_COPY_CLASS(wxMacCGContextStateSaver) | |
fb5246be | 161 | |
ddb08e02 | 162 | public: |
fb5246be | 163 | wxMacCGContextStateSaver( CGContextRef cg ) |
ddb08e02 | 164 | { |
6cce68ea SC |
165 | m_cg = cg; |
166 | CGContextSaveGState( cg ); | |
ddb08e02 | 167 | } |
fb5246be | 168 | ~wxMacCGContextStateSaver() |
ddb08e02 | 169 | { |
6cce68ea | 170 | CGContextRestoreGState( m_cg ); |
ddb08e02 SC |
171 | } |
172 | private: | |
6cce68ea SC |
173 | CGContextRef m_cg; |
174 | }; | |
ddb08e02 SC |
175 | |
176 | #endif | |
4f305456 | 177 | /* |
8cf73271 SC |
178 | class wxMacDrawingHelper |
179 | { | |
180 | DECLARE_NO_COPY_CLASS(wxMacDrawingHelper) | |
fb5246be | 181 | |
8cf73271 | 182 | public: |
6cce68ea SC |
183 | wxMacDrawingHelper( wxWindowMac * theWindow , bool clientArea = false ); |
184 | ~wxMacDrawingHelper(); | |
b7cacb43 VZ |
185 | bool Ok() const { return IsOk(); } |
186 | bool IsOk() { return m_ok; } | |
6cce68ea SC |
187 | void LocalToWindow( Rect *rect) { OffsetRect( rect , m_origin.h , m_origin.v ); } |
188 | void LocalToWindow( Point *pt ) { AddPt( m_origin , pt ); } | |
189 | void LocalToWindow( RgnHandle rgn ) { OffsetRgn( rgn , m_origin.h , m_origin.v ); } | |
190 | const Point& GetOrigin() { return m_origin; } | |
8cf73271 | 191 | private: |
6cce68ea SC |
192 | Point m_origin; |
193 | GrafPtr m_formerPort; | |
194 | GrafPtr m_currentPort; | |
195 | PenState m_savedPenState; | |
196 | bool m_ok; | |
197 | }; | |
4f305456 | 198 | */ |
8cf73271 SC |
199 | |
200 | // app.h | |
6cce68ea | 201 | bool wxMacConvertEventToRecord( EventRef event , EventRecord *rec); |
8cf73271 SC |
202 | |
203 | #endif // wxUSE_GUI | |
204 | ||
205 | // filefn.h | |
e17206f7 VS |
206 | WXDLLIMPEXP_BASE wxString wxMacFSSpec2MacFilename( const FSSpec *spec ); |
207 | WXDLLIMPEXP_BASE void wxMacFilename2FSSpec( const wxString &path , FSSpec *spec ); | |
8cf73271 SC |
208 | |
209 | // utils.h | |
e17206f7 VS |
210 | WXDLLIMPEXP_BASE wxString wxMacFindFolderNoSeparator(short vRefNum, |
211 | OSType folderType, | |
212 | Boolean createFolder); | |
213 | WXDLLIMPEXP_BASE wxString wxMacFindFolder(short vRefNum, | |
214 | OSType folderType, | |
215 | Boolean createFolder); | |
8cf73271 | 216 | |
6cce68ea SC |
217 | template<typename T> EventParamType wxMacGetEventParamType() { wxFAIL_MSG( wxT("Unknown Param Type") ); return 0; } |
218 | template<> inline EventParamType wxMacGetEventParamType<RgnHandle>() { return typeQDRgnHandle; } | |
219 | template<> inline EventParamType wxMacGetEventParamType<ControlRef>() { return typeControlRef; } | |
220 | template<> inline EventParamType wxMacGetEventParamType<WindowRef>() { return typeWindowRef; } | |
221 | template<> inline EventParamType wxMacGetEventParamType<MenuRef>() { return typeMenuRef; } | |
222 | template<> inline EventParamType wxMacGetEventParamType<EventRef>() { return typeEventRef; } | |
223 | template<> inline EventParamType wxMacGetEventParamType<Point>() { return typeQDPoint; } | |
224 | template<> inline EventParamType wxMacGetEventParamType<Rect>() { return typeQDRectangle; } | |
225 | template<> inline EventParamType wxMacGetEventParamType<Boolean>() { return typeBoolean; } | |
226 | template<> inline EventParamType wxMacGetEventParamType<SInt16>() { return typeSInt16; } | |
227 | template<> inline EventParamType wxMacGetEventParamType<SInt32>() { return typeSInt32; } | |
228 | template<> inline EventParamType wxMacGetEventParamType<UInt32>() { return typeUInt32; } | |
229 | template<> inline EventParamType wxMacGetEventParamType<RGBColor>() { return typeRGBColor; } | |
4f305456 | 230 | #if TARGET_API_MAC_OSX |
6cce68ea SC |
231 | template<> inline EventParamType wxMacGetEventParamType<HICommand>() { return typeHICommand; } |
232 | template<> inline EventParamType wxMacGetEventParamType<HIPoint>() { return typeHIPoint; } | |
233 | template<> inline EventParamType wxMacGetEventParamType<HISize>() { return typeHISize; } | |
234 | template<> inline EventParamType wxMacGetEventParamType<HIRect>() { return typeHIRect; } | |
235 | template<> inline EventParamType wxMacGetEventParamType<void*>() { return typeVoidPtr; } | |
4f305456 | 236 | #endif |
b1fd3bad | 237 | #if TARGET_API_MAC_OSX && ( MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2 ) |
6cce68ea | 238 | template<> inline EventParamType wxMacGetEventParamType<CFDictionaryRef>() { return typeCFDictionaryRef; } |
b1fd3bad | 239 | #endif |
6cce68ea SC |
240 | template<> inline EventParamType wxMacGetEventParamType<Collection>() { return typeCollection; } |
241 | template<> inline EventParamType wxMacGetEventParamType<CGContextRef>() { return typeCGContextRef; } | |
4f305456 | 242 | /* |
885fb02f | 243 | These are ambiguous |
6cce68ea SC |
244 | template<> EventParamType wxMacGetEventParamType<GrafPtr>() { return typeGrafPtr; } |
245 | template<> EventParamType wxMacGetEventParamType<OSStatus>() { return typeOSStatus; } | |
246 | template<> EventParamType wxMacGetEventParamType<CFIndex>() { return typeCFIndex; } | |
247 | template<> EventParamType wxMacGetEventParamType<GWorldPtr>() { return typeGWorldPtr; } | |
885fb02f | 248 | */ |
4f305456 SC |
249 | |
250 | class wxMacCarbonEvent | |
251 | { | |
fb5246be | 252 | |
4f305456 | 253 | public : |
a4848597 SC |
254 | wxMacCarbonEvent() |
255 | { | |
6cce68ea SC |
256 | m_eventRef = 0; |
257 | m_release = false; | |
a4848597 | 258 | } |
fb5246be WS |
259 | |
260 | wxMacCarbonEvent( EventRef event , bool release = false ) | |
4f305456 | 261 | { |
6cce68ea SC |
262 | m_eventRef = event; |
263 | m_release = release; | |
6d4c54a7 | 264 | } |
fb5246be WS |
265 | |
266 | wxMacCarbonEvent(UInt32 inClassID,UInt32 inKind,EventTime inWhen = 0 /*now*/,EventAttributes inAttributes=kEventAttributeNone) | |
6d4c54a7 | 267 | { |
6cce68ea SC |
268 | m_eventRef = NULL; |
269 | verify_noerr( MacCreateEvent( NULL , inClassID, inKind,inWhen,inAttributes,&m_eventRef) ); | |
270 | m_release = true; | |
6d4c54a7 | 271 | } |
fb5246be | 272 | |
6d4c54a7 SC |
273 | ~wxMacCarbonEvent() |
274 | { | |
275 | if ( m_release ) | |
6cce68ea | 276 | ReleaseEvent( m_eventRef ); |
4f305456 | 277 | } |
fb5246be WS |
278 | |
279 | OSStatus Create(UInt32 inClassID,UInt32 inKind,EventTime inWhen = 0 /*now*/,EventAttributes inAttributes=kEventAttributeNone) | |
a4848597 | 280 | { |
6cce68ea | 281 | verify( (m_eventRef == NULL) || m_release ); |
a4848597 SC |
282 | if ( m_eventRef && m_release ) |
283 | { | |
6cce68ea SC |
284 | ReleaseEvent( m_eventRef ); |
285 | m_release = false; | |
286 | m_eventRef = NULL; | |
a4848597 | 287 | } |
6cce68ea | 288 | OSStatus err = MacCreateEvent( NULL , inClassID, inKind,inWhen,inAttributes,&m_eventRef); |
a4848597 | 289 | if ( err == noErr ) |
6cce68ea SC |
290 | m_release = true; |
291 | return err; | |
a4848597 | 292 | } |
fb5246be | 293 | |
6cce68ea | 294 | OSStatus GetParameter( EventParamName inName, EventParamType inDesiredType, UInt32 inBufferSize, void * outData); |
fb5246be | 295 | |
4f305456 SC |
296 | template <typename T> OSStatus GetParameter( EventParamName inName, EventParamType type , T *data ) |
297 | { | |
6cce68ea | 298 | return GetParameter( inName, type , sizeof( T ) , data ); |
4f305456 SC |
299 | } |
300 | template <typename T> OSStatus GetParameter( EventParamName inName, T *data ) | |
301 | { | |
6cce68ea | 302 | return GetParameter<T>( inName, wxMacGetEventParamType<T>() , data ); |
4f305456 | 303 | } |
fb5246be | 304 | |
4f305456 SC |
305 | template <typename T> T GetParameter( EventParamName inName ) |
306 | { | |
6cce68ea SC |
307 | T value; |
308 | verify_noerr( GetParameter<T>( inName, &value ) ); | |
309 | return value; | |
4f305456 SC |
310 | } |
311 | template <typename T> T GetParameter( EventParamName inName, EventParamType inDesiredType ) | |
312 | { | |
6cce68ea SC |
313 | T value; |
314 | verify_noerr( GetParameter<T>( inName, inDesiredType , &value ) ); | |
315 | return value; | |
4f305456 | 316 | } |
fb5246be | 317 | |
6cce68ea | 318 | OSStatus SetParameter( EventParamName inName, EventParamType inType, UInt32 inSize, const void * inData); |
6d4c54a7 | 319 | template <typename T> OSStatus SetParameter( EventParamName inName, EventParamType inDesiredType , const T *data ) |
4f305456 | 320 | { |
6cce68ea | 321 | return SetParameter( inName, inDesiredType , sizeof( T ) , data ); |
2aefa0ef | 322 | } |
6d4c54a7 | 323 | template <typename T> OSStatus SetParameter( EventParamName inName, EventParamType inDesiredType , const T& data ) |
2aefa0ef | 324 | { |
6cce68ea | 325 | return SetParameter<T>( inName, inDesiredType , &data ); |
4f305456 | 326 | } |
6d4c54a7 | 327 | template <typename T> OSStatus SetParameter( EventParamName inName, const T *data ) |
4f305456 | 328 | { |
6cce68ea | 329 | return SetParameter<T>( inName, wxMacGetEventParamType<T>() , data ); |
4f305456 | 330 | } |
6d4c54a7 | 331 | template <typename T> OSStatus SetParameter( EventParamName inName, const T& data ) |
2aefa0ef | 332 | { |
6cce68ea | 333 | return SetParameter<T>( inName, wxMacGetEventParamType<T>() , &data ); |
2aefa0ef | 334 | } |
86d8b744 SC |
335 | UInt32 GetClass() |
336 | { | |
6cce68ea | 337 | return ::GetEventClass( m_eventRef ); |
86d8b744 | 338 | } |
41b53169 | 339 | UInt32 GetKind() |
4f305456 | 340 | { |
6cce68ea | 341 | return ::GetEventKind( m_eventRef ); |
4f305456 SC |
342 | } |
343 | EventTime GetTime() | |
344 | { | |
6cce68ea | 345 | return ::GetEventTime( m_eventRef ); |
4f305456 SC |
346 | } |
347 | UInt32 GetTicks() | |
348 | { | |
6cce68ea | 349 | return EventTimeToTicks( GetTime() ); |
4f305456 | 350 | } |
2c01d335 | 351 | OSStatus SetCurrentTime( ) |
a4848597 | 352 | { |
6cce68ea | 353 | return ::SetEventTime( m_eventRef , GetCurrentEventTime() ); |
2c01d335 | 354 | } |
fb5246be | 355 | OSStatus SetTime( EventTime when ) |
2c01d335 | 356 | { |
6cce68ea | 357 | return ::SetEventTime( m_eventRef , when ); |
a4848597 SC |
358 | } |
359 | operator EventRef () { return m_eventRef; } | |
fb5246be | 360 | |
6cce68ea | 361 | bool IsValid() { return m_eventRef != 0; } |
4f305456 | 362 | protected : |
6cce68ea SC |
363 | EventRef m_eventRef; |
364 | bool m_release; | |
365 | }; | |
4f305456 | 366 | |
3feeb1e1 SC |
367 | // |
368 | // helper class for allocating and deallocating Universal Proc Ptrs | |
369 | // | |
370 | ||
371 | template <typename procType, typename uppType , uppType (*newUPP)(procType) , void (*disposeUPP)(uppType) > class wxMacUPP | |
372 | { | |
373 | public : | |
89954433 | 374 | wxMacUPP( procType WXUNUSED(proc) ) |
3feeb1e1 | 375 | { |
6cce68ea SC |
376 | m_upp = NULL; |
377 | m_upp = (*newUPP)( NULL ); | |
3feeb1e1 SC |
378 | } |
379 | ~wxMacUPP() | |
380 | { | |
381 | if ( m_upp ) | |
6cce68ea | 382 | disposeUPP( m_upp ); |
3feeb1e1 | 383 | } |
6cce68ea | 384 | operator uppType() { return m_upp; } |
3feeb1e1 | 385 | private : |
6cce68ea SC |
386 | uppType m_upp; |
387 | }; | |
3feeb1e1 | 388 | |
6cce68ea | 389 | typedef wxMacUPP<NMProcPtr,NMUPP,NewNMUPP,DisposeNMUPP> wxMacNMUPP; |
3feeb1e1 | 390 | |
18b94824 SC |
391 | template <typename refType> class wxMacCFRefHolder |
392 | { | |
393 | public : | |
394 | wxMacCFRefHolder() | |
fb5246be | 395 | : m_ref(NULL) , m_release(false) |
18b94824 SC |
396 | { |
397 | } | |
fb5246be WS |
398 | |
399 | wxMacCFRefHolder( refType ref , bool release = true ) | |
18b94824 SC |
400 | : m_ref(ref) , m_release(release) |
401 | { | |
402 | } | |
fb5246be | 403 | |
18b94824 SC |
404 | ~wxMacCFRefHolder() |
405 | { | |
6cce68ea | 406 | Release(); |
18b94824 | 407 | } |
fb5246be | 408 | |
18b94824 SC |
409 | void Release() |
410 | { | |
411 | if ( m_release && m_ref != NULL ) | |
6cce68ea SC |
412 | CFRelease( m_ref ); |
413 | m_ref = NULL; | |
18b94824 | 414 | } |
fb5246be | 415 | |
18b94824 SC |
416 | refType Detach() |
417 | { | |
6cce68ea SC |
418 | refType val = m_ref; |
419 | m_release = false; | |
420 | m_ref = NULL; | |
421 | return val; | |
18b94824 | 422 | } |
fb5246be | 423 | |
18b94824 SC |
424 | void Set( refType ref , bool release = true ) |
425 | { | |
6cce68ea SC |
426 | Release(); |
427 | m_release = release; | |
428 | m_ref = ref; | |
18b94824 | 429 | } |
fb5246be | 430 | |
18b94824 | 431 | operator refType () const { return m_ref; } |
fb5246be | 432 | |
ebf2a1ec SC |
433 | wxMacCFRefHolder& operator=(refType r) |
434 | { | |
435 | Set( r ); | |
436 | return *this; | |
437 | } | |
18b94824 | 438 | private : |
6cce68ea SC |
439 | refType m_ref; |
440 | bool m_release; | |
fb5246be | 441 | |
18b94824 | 442 | DECLARE_NO_COPY_CLASS( wxMacCFRefHolder ) |
6cce68ea | 443 | }; |
18b94824 | 444 | |
885fb02f | 445 | #if wxUSE_GUI |
6cce68ea | 446 | |
ebf2a1ec SC |
447 | class wxMacToolTipTimer ; |
448 | ||
449 | class wxMacToolTip | |
450 | { | |
451 | public : | |
452 | wxMacToolTip() ; | |
453 | ~wxMacToolTip() ; | |
454 | ||
455 | void Setup( WindowRef window , const wxString& text , const wxPoint& localPosition ) ; | |
456 | void Draw() ; | |
457 | void Clear() ; | |
458 | ||
459 | long GetMark() | |
460 | { return m_mark ; } | |
461 | ||
462 | bool IsShown() | |
463 | { return m_shown ; } | |
464 | ||
465 | private : | |
466 | wxString m_label ; | |
467 | wxPoint m_position ; | |
468 | Rect m_rect ; | |
469 | WindowRef m_window ; | |
470 | PicHandle m_backpict ; | |
471 | bool m_shown ; | |
472 | long m_mark ; | |
473 | #if wxUSE_TIMER | |
474 | wxMacToolTipTimer* m_timer ; | |
475 | #endif | |
476 | #if TARGET_CARBON | |
477 | wxMacCFStringHolder m_helpTextRef ; | |
478 | #endif | |
479 | } ; | |
480 | ||
20b69855 | 481 | /* |
6cce68ea SC |
482 | GWorldPtr wxMacCreateGWorld( int width , int height , int depth ); |
483 | void wxMacDestroyGWorld( GWorldPtr gw ); | |
484 | PicHandle wxMacCreatePict( GWorldPtr gw , GWorldPtr mask = NULL ); | |
485 | CIconHandle wxMacCreateCIcon(GWorldPtr image , GWorldPtr mask , short dstDepth , short iconSize ); | |
486 | void wxMacSetColorTableEntry( CTabHandle newColors , int index , int red , int green , int blue ); | |
487 | CTabHandle wxMacCreateColorTable( int numColors ); | |
20b69855 | 488 | */ |
6cce68ea SC |
489 | void wxMacCreateBitmapButton( ControlButtonContentInfo*info , const wxBitmap& bitmap , int forceType = 0 ); |
490 | void wxMacReleaseBitmapButton( ControlButtonContentInfo*info ); | |
ebf2a1ec | 491 | CGImageRef wxMacCreateCGImageFromBitmap( const wxBitmap& bitmap ); |
885fb02f SC |
492 | |
493 | #define MAC_WXCOLORREF(a) (*((RGBColor*)&(a))) | |
494 | #define MAC_WXHBITMAP(a) (GWorldPtr(a)) | |
495 | #define MAC_WXHMETAFILE(a) (PicHandle(a)) | |
20b69855 | 496 | #define MAC_WXHICON(a) (IconRef(a)) |
885fb02f SC |
497 | #define MAC_WXHCURSOR(a) (CursHandle(a)) |
498 | #define MAC_WXHRGN(a) (RgnHandle(a)) | |
499 | #define MAC_WXHWND(a) (WindowPtr(a)) | |
500 | #define MAC_WXRECPTR(a) ((Rect*)a) | |
501 | #define MAC_WXPOINTPTR(a) ((Point*)a) | |
502 | #define MAC_WXHMENU(a) ((MenuHandle)a) | |
503 | ||
504 | struct wxOpaqueWindowRef | |
505 | { | |
6cce68ea SC |
506 | wxOpaqueWindowRef( WindowRef ref ) { m_data = ref; } |
507 | operator WindowRef() { return m_data; } | |
885fb02f | 508 | private : |
6cce68ea SC |
509 | WindowRef m_data; |
510 | }; | |
885fb02f | 511 | |
6cce68ea SC |
512 | void wxMacRectToNative( const wxRect *wx , Rect *n ); |
513 | void wxMacNativeToRect( const Rect *n , wxRect* wx ); | |
514 | void wxMacPointToNative( const wxPoint* wx , Point *n ); | |
515 | void wxMacNativeToPoint( const Point *n , wxPoint* wx ); | |
285b5ce0 | 516 | |
6cce68ea SC |
517 | wxWindow * wxFindControlFromMacControl(ControlRef inControl ); |
518 | wxTopLevelWindowMac* wxFindWinFromMacWindow( WindowRef inWindow ); | |
519 | wxMenu* wxFindMenuFromMacMenu(MenuRef inMenuRef); | |
885fb02f | 520 | |
6cce68ea SC |
521 | int wxMacCommandToId( UInt32 macCommandId ); |
522 | UInt32 wxIdToMacCommand( int wxId ); | |
523 | wxMenu* wxFindMenuFromMacCommand( const HICommand &macCommandId , wxMenuItem* &item ); | |
1628261e | 524 | |
6cce68ea SC |
525 | extern wxWindow* g_MacLastWindow; |
526 | pascal OSStatus wxMacTopLevelMouseEventHandler( EventHandlerCallRef handler , EventRef event , void *data ); | |
527 | Rect wxMacGetBoundsForControl( wxWindow* window , const wxPoint& pos , const wxSize &size , bool adjustForOrigin = true ); | |
885fb02f | 528 | |
6cce68ea | 529 | ControlActionUPP GetwxMacLiveScrollbarActionProc(); |
285b5ce0 | 530 | |
bf9a1615 | 531 | class wxMacControl : public wxObject |
86d8b744 SC |
532 | { |
533 | public : | |
6cce68ea SC |
534 | wxMacControl( wxWindow* peer , bool isRootControl = false ); |
535 | wxMacControl( wxWindow* peer , ControlRef control ); | |
536 | wxMacControl( wxWindow* peer , WXWidget control ); | |
bf9a1615 | 537 | wxMacControl() ; |
6cce68ea SC |
538 | virtual ~wxMacControl(); |
539 | ||
540 | void Init(); | |
fb5246be | 541 | |
6cce68ea | 542 | virtual void Dispose(); |
fb5246be | 543 | |
b7cacb43 VZ |
544 | bool Ok() const { return IsOk(); } |
545 | bool IsOk() const { return GetControlRef() != NULL; } | |
5ca0d812 | 546 | |
6cce68ea SC |
547 | void SetReferenceInNativeControl(); |
548 | static wxMacControl* GetReferenceFromNativeControl(ControlRef control); | |
5ca0d812 | 549 | |
fb5246be | 550 | virtual ControlRef * GetControlRefAddr() { return &m_controlRef; } |
6cce68ea | 551 | virtual ControlRef GetControlRef() const { return m_controlRef; } |
fb5246be | 552 | |
eb89f88a | 553 | virtual void SetReference( URefCon data ); |
5ca0d812 | 554 | /* |
6cce68ea | 555 | void operator= (ControlRef c) { m_controlRef = c; } |
fb5246be WS |
556 | operator ControlRef () { return m_controlRef; } |
557 | operator ControlRef * () { return &m_controlRef; } | |
5ca0d812 | 558 | */ |
2837271a SC |
559 | // accessing data and values |
560 | ||
6cce68ea SC |
561 | virtual OSStatus SetData( ControlPartCode inPartCode , ResType inTag , Size inSize , const void * inData ); |
562 | virtual OSStatus GetData( ControlPartCode inPartCode , ResType inTag , Size inBufferSize , void * inOutBuffer , Size * outActualSize ) const; | |
563 | virtual OSStatus GetDataSize( ControlPartCode inPartCode , ResType inTag , Size * outActualSize ) const; | |
564 | virtual OSStatus SendEvent( EventRef ref , OptionBits inOptions = 0 ); | |
565 | virtual OSStatus SendHICommand( HICommand &command , OptionBits inOptions = 0 ); | |
2837271a | 566 | |
6cce68ea | 567 | virtual OSStatus SendHICommand( UInt32 commandID , OptionBits inOptions = 0 ); |
2837271a | 568 | |
6cce68ea SC |
569 | virtual SInt32 GetValue() const; |
570 | virtual SInt32 GetMaximum() const; | |
571 | virtual SInt32 GetMinimum() const; | |
fb5246be | 572 | |
6cce68ea SC |
573 | virtual void SetValue( SInt32 v ); |
574 | virtual void SetMinimum( SInt32 v ); | |
575 | virtual void SetMaximum( SInt32 v ); | |
2837271a | 576 | |
6cce68ea SC |
577 | virtual void SetValueAndRange( SInt32 value , SInt32 minimum , SInt32 maximum ); |
578 | virtual void SetRange( SInt32 minimum , SInt32 maximum ); | |
fb5246be | 579 | |
6cce68ea SC |
580 | virtual OSStatus SetFocus( ControlFocusPart focusPart ); |
581 | virtual bool HasFocus() const; | |
582 | virtual bool NeedsFocusRect() const; | |
583 | virtual void SetNeedsFocusRect( bool needs ); | |
fb5246be | 584 | |
2837271a SC |
585 | // templated helpers |
586 | ||
0fc3bc3b | 587 | Size GetDataSize( ControlPartCode inPartCode , ResType inTag ) const |
86d8b744 | 588 | { |
6cce68ea SC |
589 | Size sz; |
590 | verify_noerr( GetDataSize( inPartCode , inTag , &sz ) ); | |
591 | return sz; | |
86d8b744 | 592 | } |
6d4c54a7 | 593 | template <typename T> OSStatus SetData( ControlPartCode inPartCode , ResType inTag , const T *data ) |
86d8b744 | 594 | { |
6cce68ea | 595 | return SetData( inPartCode , inTag , sizeof( T ) , data ); |
86d8b744 | 596 | } |
6d4c54a7 | 597 | template <typename T> OSStatus SetData( ControlPartCode inPartCode , ResType inTag , const T& data ) |
86d8b744 | 598 | { |
6cce68ea | 599 | return SetData( inPartCode , inTag , sizeof( T ) , &data ); |
86d8b744 | 600 | } |
fbb7ee81 SC |
601 | template <typename T> OSStatus SetData( ResType inTag , const T *data ) |
602 | { | |
6cce68ea | 603 | return SetData( kControlEntireControl , inTag , sizeof( T ) , data ); |
fbb7ee81 SC |
604 | } |
605 | template <typename T> OSStatus SetData( ResType inTag , const T& data ) | |
606 | { | |
6cce68ea | 607 | return SetData( kControlEntireControl , inTag , sizeof( T ) , &data ); |
fbb7ee81 | 608 | } |
0fc3bc3b | 609 | template <typename T> OSStatus GetData( ControlPartCode inPartCode , ResType inTag , T *data ) const |
86d8b744 | 610 | { |
6cce68ea SC |
611 | Size dummy; |
612 | return GetData( inPartCode , inTag , sizeof( T ) , data , &dummy ); | |
86d8b744 | 613 | } |
0fc3bc3b | 614 | template <typename T> T GetData( ControlPartCode inPartCode , ResType inTag ) const |
86d8b744 | 615 | { |
6cce68ea SC |
616 | T value; |
617 | OSStatus err = GetData<T>( inPartCode , inTag , &value ); | |
725566ca VZ |
618 | |
619 | wxASSERT_MSG( err == noErr, | |
620 | wxString::Format(wxT("GetData Failed for Part [%i] and Tag [%i]"), | |
621 | inPartCode, (int)inTag) ); | |
6cce68ea | 622 | return value; |
86d8b744 | 623 | } |
fbb7ee81 SC |
624 | template <typename T> OSStatus GetData( ResType inTag , T *data ) const |
625 | { | |
6cce68ea SC |
626 | Size dummy; |
627 | return GetData( kControlEntireControl , inTag , sizeof( T ) , data , &dummy ); | |
fbb7ee81 SC |
628 | } |
629 | template <typename T> T GetData( ResType inTag ) const | |
630 | { | |
6cce68ea | 631 | return GetData<T>( kControlEntireControl , inTag ); |
fbb7ee81 | 632 | } |
725566ca | 633 | |
6d4c54a7 | 634 | // Flash the control for the specified amount of time |
6cce68ea | 635 | virtual void Flash( ControlPartCode part , UInt32 ticks = 8 ); |
89a66f11 | 636 | |
6cce68ea SC |
637 | virtual void VisibilityChanged( bool shown ); |
638 | virtual void SuperChangedPosition(); | |
89a66f11 SC |
639 | |
640 | ||
6cce68ea SC |
641 | virtual void SetFont( const wxFont & font , const wxColour& foreground , long windowStyle ); |
642 | virtual void SetBackground( const wxBrush &brush ); | |
643 | virtual ControlPartCode HandleKey( SInt16 keyCode, SInt16 charCode, EventModifiers modifiers ); | |
644 | void SetActionProc( ControlActionUPP actionProc ); | |
645 | void SetViewSize( SInt32 viewSize ); | |
646 | SInt32 GetViewSize() const; | |
fb5246be | 647 | |
6cce68ea SC |
648 | virtual bool IsVisible() const; |
649 | virtual void SetVisibility( bool visible , bool redraw ); | |
650 | virtual bool IsEnabled() const; | |
651 | virtual bool IsActive() const; | |
652 | virtual void Enable( bool enable ); | |
fb5246be | 653 | |
5ca0d812 | 654 | // invalidates this control and all children |
6cce68ea SC |
655 | virtual void InvalidateWithChildren(); |
656 | virtual void SetDrawingEnabled( bool enable ); | |
b905d6cc | 657 | #ifdef __WXMAC_OSX__ |
6cce68ea | 658 | virtual bool GetNeedsDisplay() const; |
b905d6cc | 659 | #endif |
285b5ce0 | 660 | // where is in native window relative coordinates |
6cce68ea | 661 | virtual void SetNeedsDisplay( RgnHandle where ); |
285b5ce0 | 662 | // where is in native window relative coordinates |
6cce68ea | 663 | virtual void SetNeedsDisplay( Rect* where = NULL ); |
285b5ce0 | 664 | |
fb5246be | 665 | // if rect = NULL, entire view |
6cce68ea | 666 | virtual void ScrollRect( wxRect *rect , int dx , int dy ); |
5ca0d812 | 667 | |
285b5ce0 | 668 | // in native parent window relative coordinates |
6cce68ea | 669 | virtual void GetRect( Rect *r ); |
285b5ce0 SC |
670 | |
671 | // in native parent window relative coordinates | |
6cce68ea | 672 | virtual void SetRect( Rect *r ); |
285b5ce0 | 673 | |
6cce68ea SC |
674 | virtual void GetRectInWindowCoords( Rect *r ); |
675 | virtual void GetBestRect( Rect *r ); | |
676 | virtual void SetLabel( const wxString &title ); | |
5ca0d812 | 677 | // converts from Toplevel-Content relative to local |
6cce68ea | 678 | static void Convert( wxPoint *pt , wxMacControl *convert , wxMacControl *to ); |
fb5246be | 679 | |
6cce68ea SC |
680 | virtual void GetFeatures( UInt32 *features ); |
681 | virtual OSStatus GetRegion( ControlPartCode partCode , RgnHandle region ); | |
682 | virtual OSStatus SetZOrder( bool above , wxMacControl* other ); | |
725566ca | 683 | |
6cce68ea | 684 | bool IsRootControl() { return m_isRootControl; } |
725566ca | 685 | |
6cce68ea SC |
686 | wxWindow* GetPeer() const |
687 | { | |
688 | return m_peer; | |
689 | } | |
ba5b8a68 SC |
690 | |
691 | // to be moved into a tab control class | |
692 | ||
6cce68ea SC |
693 | virtual OSStatus SetTabEnabled( SInt16 tabNo , bool enable ); |
694 | protected : | |
695 | ControlRef m_controlRef; | |
696 | wxFont m_font; | |
697 | long m_windowStyle; | |
698 | wxWindow* m_peer; | |
699 | bool m_needsFocusRect; | |
6cce68ea | 700 | bool m_isRootControl; |
bf9a1615 | 701 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacControl) |
6cce68ea SC |
702 | }; |
703 | ||
704 | // ============================================================================ | |
705 | // DataBrowser Wrapper | |
706 | // ============================================================================ | |
707 | // | |
708 | // basing on DataBrowserItemIDs | |
709 | // | |
710 | ||
711 | class wxMacDataBrowserControl : public wxMacControl | |
712 | { | |
713 | public : | |
714 | wxMacDataBrowserControl( wxWindow* peer, const wxPoint& pos, const wxSize& size, long style); | |
bf9a1615 | 715 | wxMacDataBrowserControl() {} |
6cce68ea SC |
716 | |
717 | OSStatus SetCallbacks( const DataBrowserCallbacks *callbacks ); | |
725566ca | 718 | |
6cce68ea SC |
719 | OSStatus GetItemCount( DataBrowserItemID container, |
720 | Boolean recurse, | |
721 | DataBrowserItemState state, | |
eb89f88a | 722 | ItemCount *numItems) const; |
725566ca | 723 | |
6cce68ea SC |
724 | OSStatus GetItems( DataBrowserItemID container, |
725 | Boolean recurse, | |
726 | DataBrowserItemState state, | |
727 | Handle items) const; | |
725566ca | 728 | |
6cce68ea SC |
729 | |
730 | OSStatus AddColumn( DataBrowserListViewColumnDesc *columnDesc, | |
731 | DataBrowserTableViewColumnIndex position ); | |
7b514b3b | 732 | |
e2bc1d69 | 733 | OSStatus RemoveColumn( DataBrowserTableViewColumnIndex position ); |
725566ca | 734 | |
6cce68ea | 735 | OSStatus AutoSizeColumns(); |
725566ca | 736 | |
6cce68ea SC |
737 | OSStatus SetHasScrollBars( bool horiz, bool vert ); |
738 | OSStatus SetHiliteStyle( DataBrowserTableViewHiliteStyle hiliteStyle ); | |
725566ca | 739 | |
6cce68ea SC |
740 | OSStatus SetHeaderButtonHeight( UInt16 height ); |
741 | OSStatus GetHeaderButtonHeight( UInt16 *height ); | |
742 | ||
743 | OSStatus UpdateItems( DataBrowserItemID container, UInt32 numItems, | |
744 | const DataBrowserItemID *items, | |
745 | DataBrowserPropertyID preSortProperty, | |
746 | DataBrowserPropertyID propertyID ) const; | |
725566ca | 747 | |
6cce68ea SC |
748 | OSStatus AddItems( DataBrowserItemID container, UInt32 numItems, |
749 | const DataBrowserItemID *items, | |
750 | DataBrowserPropertyID preSortProperty ); | |
751 | OSStatus RemoveItems( DataBrowserItemID container, UInt32 numItems, | |
752 | const DataBrowserItemID *items, | |
753 | DataBrowserPropertyID preSortProperty ); | |
754 | OSStatus RevealItem( DataBrowserItemID item, | |
755 | DataBrowserPropertyID propertyID, | |
756 | DataBrowserRevealOptions options ) const; | |
757 | ||
758 | OSStatus SetSelectionFlags( DataBrowserSelectionFlags ); | |
759 | OSStatus GetSelectionAnchor( DataBrowserItemID *first, DataBrowserItemID *last ) const; | |
760 | bool IsItemSelected( DataBrowserItemID item ) const; | |
761 | OSStatus SetSelectedItems( UInt32 numItems, | |
762 | const DataBrowserItemID *items, | |
763 | DataBrowserSetOption operation ); | |
764 | ||
725566ca | 765 | OSStatus GetItemID( DataBrowserTableViewRowIndex row, |
6cce68ea | 766 | DataBrowserItemID * item ) const; |
725566ca | 767 | OSStatus GetItemRow( DataBrowserItemID item, |
6cce68ea | 768 | DataBrowserTableViewRowIndex * row ) const; |
725566ca | 769 | |
6cce68ea SC |
770 | OSStatus SetDefaultRowHeight( UInt16 height ); |
771 | OSStatus GetDefaultRowHeight( UInt16 * height ) const; | |
725566ca | 772 | |
6cce68ea SC |
773 | OSStatus SetRowHeight( DataBrowserItemID item , UInt16 height); |
774 | OSStatus GetRowHeight( DataBrowserItemID item , UInt16 *height) const; | |
725566ca | 775 | |
6cce68ea SC |
776 | OSStatus GetColumnWidth( DataBrowserPropertyID column , UInt16 *width ) const; |
777 | OSStatus SetColumnWidth( DataBrowserPropertyID column , UInt16 width ); | |
725566ca | 778 | |
6cce68ea SC |
779 | OSStatus GetDefaultColumnWidth( UInt16 *width ) const; |
780 | OSStatus SetDefaultColumnWidth( UInt16 width ); | |
725566ca | 781 | |
6cce68ea SC |
782 | OSStatus GetColumnCount( UInt32* numColumns) const; |
783 | ||
e2bc1d69 KO |
784 | OSStatus GetColumnIDFromIndex( DataBrowserTableViewColumnIndex position, DataBrowserTableViewColumnID* id ); |
785 | ||
eb89f88a SC |
786 | OSStatus GetColumnPosition( DataBrowserPropertyID column, DataBrowserTableViewColumnIndex *position) const; |
787 | OSStatus SetColumnPosition( DataBrowserPropertyID column, DataBrowserTableViewColumnIndex position); | |
725566ca | 788 | |
6cce68ea SC |
789 | OSStatus GetScrollPosition( UInt32 *top , UInt32 *left ) const; |
790 | OSStatus SetScrollPosition( UInt32 top , UInt32 left ); | |
725566ca | 791 | |
6cce68ea SC |
792 | OSStatus GetSortProperty( DataBrowserPropertyID *column ) const; |
793 | OSStatus SetSortProperty( DataBrowserPropertyID column ); | |
725566ca | 794 | |
6cce68ea SC |
795 | OSStatus GetSortOrder( DataBrowserSortOrder *order ) const; |
796 | OSStatus SetSortOrder( DataBrowserSortOrder order ); | |
725566ca | 797 | |
6cce68ea SC |
798 | OSStatus GetPropertyFlags( DataBrowserPropertyID property, DataBrowserPropertyFlags *flags ) const; |
799 | OSStatus SetPropertyFlags( DataBrowserPropertyID property, DataBrowserPropertyFlags flags ); | |
725566ca | 800 | |
6cce68ea SC |
801 | OSStatus GetHeaderDesc( DataBrowserPropertyID property, DataBrowserListViewHeaderDesc *desc ) const; |
802 | OSStatus SetHeaderDesc( DataBrowserPropertyID property, DataBrowserListViewHeaderDesc *desc ); | |
725566ca | 803 | |
6cce68ea | 804 | OSStatus SetDisclosureColumn( DataBrowserPropertyID property , Boolean expandableRows ); |
86d8b744 | 805 | protected : |
725566ca | 806 | |
6cce68ea SC |
807 | static pascal void DataBrowserItemNotificationProc( |
808 | ControlRef browser, | |
809 | DataBrowserItemID itemID, | |
810 | DataBrowserItemNotification message, | |
811 | DataBrowserItemDataRef itemData ); | |
812 | ||
813 | virtual void ItemNotification( | |
814 | DataBrowserItemID itemID, | |
815 | DataBrowserItemNotification message, | |
816 | DataBrowserItemDataRef itemData) = 0; | |
817 | ||
818 | static pascal OSStatus DataBrowserGetSetItemDataProc( | |
819 | ControlRef browser, | |
820 | DataBrowserItemID itemID, | |
821 | DataBrowserPropertyID property, | |
822 | DataBrowserItemDataRef itemData, | |
823 | Boolean changeValue ); | |
824 | ||
825 | virtual OSStatus GetSetItemData( | |
826 | DataBrowserItemID itemID, | |
827 | DataBrowserPropertyID property, | |
828 | DataBrowserItemDataRef itemData, | |
829 | Boolean changeValue ) = 0; | |
830 | ||
831 | static pascal Boolean DataBrowserCompareProc( | |
1b88201f WS |
832 | ControlRef browser, |
833 | DataBrowserItemID itemOneID, | |
834 | DataBrowserItemID itemTwoID, | |
835 | DataBrowserPropertyID sortProperty); | |
836 | ||
837 | virtual Boolean CompareItems(DataBrowserItemID itemOneID, | |
838 | DataBrowserItemID itemTwoID, | |
839 | DataBrowserPropertyID sortProperty) = 0; | |
bf9a1615 | 840 | DECLARE_ABSTRACT_CLASS(wxMacDataBrowserControl) |
6cce68ea SC |
841 | }; |
842 | ||
843 | // ============================================================================ | |
725566ca | 844 | // Higher-level Databrowser |
6cce68ea SC |
845 | // ============================================================================ |
846 | // | |
847 | // basing on data item objects | |
848 | // | |
849 | ||
850 | // forward decl | |
851 | ||
852 | class wxMacDataItemBrowserControl; | |
e2bc1d69 KO |
853 | class wxMacListBoxItem; |
854 | ||
e362c2b9 SC |
855 | const DataBrowserPropertyID kTextColumnId = 1024; |
856 | const DataBrowserPropertyID kNumericOrderColumnId = 1025; | |
e2bc1d69 | 857 | |
7b514b3b | 858 | // for multi-column controls, we will use this + the column ID to identify the |
e2bc1d69 | 859 | // column. We don't use kTextColumnId there, and ideally the two should merge. |
e362c2b9 | 860 | const DataBrowserPropertyID kMinColumnId = 1050; |
e2bc1d69 KO |
861 | |
862 | // base API for high-level databrowser operations | |
863 | ||
864 | class wxMacListControl | |
865 | { | |
866 | public: | |
867 | virtual void MacDelete( unsigned int n ) = 0; | |
a236aa20 | 868 | virtual void MacInsert( unsigned int n, const wxArrayStringsAdapter& items, int column = -1 ) = 0; |
e2bc1d69 KO |
869 | // returns index of newly created line |
870 | virtual int MacAppend( const wxString& item ) = 0; | |
871 | virtual void MacSetString( unsigned int n, const wxString& item ) = 0; | |
872 | virtual void MacClear() = 0; | |
873 | virtual void MacDeselectAll() = 0; | |
874 | virtual void MacSetSelection( unsigned int n, bool select, bool multi ) = 0; | |
875 | virtual int MacGetSelection() const = 0; | |
876 | virtual int MacGetSelections( wxArrayInt& aSelections ) const = 0; | |
877 | virtual bool MacIsSelected( unsigned int n ) const = 0; | |
878 | virtual void MacScrollTo( unsigned int n ) = 0; | |
879 | virtual wxString MacGetString( unsigned int n) const = 0; | |
880 | virtual unsigned int MacGetCount() const = 0; | |
881 | ||
882 | virtual void MacSetClientData( unsigned int n, void * data) = 0; | |
883 | virtual void * MacGetClientData( unsigned int) const = 0; | |
884 | ||
885 | virtual ~wxMacListControl() { } | |
7b514b3b | 886 | }; |
6cce68ea SC |
887 | |
888 | // base class for databrowser items | |
889 | ||
e2bc1d69 KO |
890 | enum DataItemType { |
891 | DataItem_Text | |
892 | }; | |
893 | ||
6cce68ea SC |
894 | class wxMacDataItem |
895 | { | |
896 | public : | |
897 | wxMacDataItem(); | |
898 | virtual ~wxMacDataItem(); | |
725566ca VZ |
899 | |
900 | virtual bool IsLessThan(wxMacDataItemBrowserControl *owner , | |
901 | const wxMacDataItem*, | |
6cce68ea | 902 | DataBrowserPropertyID property) const; |
725566ca | 903 | |
6cce68ea | 904 | // returns true if access was successful, otherwise false |
725566ca | 905 | virtual OSStatus GetSetData(wxMacDataItemBrowserControl *owner , |
6cce68ea SC |
906 | DataBrowserPropertyID property, |
907 | DataBrowserItemDataRef itemData, | |
908 | bool changeValue ); | |
909 | ||
725566ca | 910 | virtual void Notification(wxMacDataItemBrowserControl *owner , |
6cce68ea SC |
911 | DataBrowserItemNotification message, |
912 | DataBrowserItemDataRef itemData ) const; | |
7b514b3b | 913 | |
e2bc1d69 | 914 | void SetLabel( const wxString& str); |
7b514b3b | 915 | const wxString& GetLabel() const; |
e2bc1d69 KO |
916 | |
917 | void SetOrder( SInt32 order ); | |
918 | SInt32 GetOrder() const; | |
919 | ||
920 | void SetData( void* data); | |
921 | void* GetData() const; | |
7b514b3b | 922 | |
e2bc1d69 | 923 | void SetColumn( short col ); |
7b514b3b VZ |
924 | short GetColumn(); |
925 | ||
e2bc1d69 KO |
926 | protected : |
927 | wxString m_label; | |
928 | wxMacCFStringHolder m_cfLabel; | |
929 | void * m_data; | |
930 | SInt32 m_order; | |
7b514b3b VZ |
931 | DataBrowserPropertyID m_colId; |
932 | ||
e2bc1d69 KO |
933 | }; |
934 | ||
935 | enum ListSortOrder { | |
936 | SortOrder_None, | |
937 | SortOrder_Text_Ascending, | |
938 | SortOrder_Text_Descending | |
6cce68ea SC |
939 | }; |
940 | ||
941 | typedef wxMacDataItem* wxMacDataItemPtr; | |
942 | const wxMacDataItemPtr wxMacDataBrowserRootContainer = NULL; | |
943 | ||
944 | WX_DEFINE_USER_EXPORTED_ARRAY_PTR(wxMacDataItemPtr, wxArrayMacDataItemPtr, class WXDLLIMPEXP_CORE); | |
945 | ||
e2bc1d69 | 946 | class wxMacDataItemBrowserControl : public wxMacDataBrowserControl, public wxMacListControl |
6cce68ea SC |
947 | { |
948 | public : | |
949 | wxMacDataItemBrowserControl( wxWindow* peer , const wxPoint& pos, const wxSize& size, long style); | |
bf9a1615 | 950 | wxMacDataItemBrowserControl() {} |
e2bc1d69 KO |
951 | // create a list item (can be a subclass of wxMacListBoxItem) |
952 | ||
953 | virtual wxMacDataItem* CreateItem(); | |
954 | ||
6cce68ea | 955 | unsigned int GetItemCount(const wxMacDataItem* container, bool recurse , DataBrowserItemState state) const; |
725566ca | 956 | void GetItems(const wxMacDataItem* container, bool recurse , |
6cce68ea | 957 | DataBrowserItemState state, wxArrayMacDataItemPtr &items ) const; |
7b514b3b | 958 | |
e2bc1d69 | 959 | unsigned int GetSelectedItemCount( const wxMacDataItem* container, bool recurse ) const; |
725566ca | 960 | |
6cce68ea SC |
961 | unsigned int GetLineFromItem(const wxMacDataItem *item) const; |
962 | wxMacDataItem * GetItemFromLine(unsigned int n) const; | |
725566ca VZ |
963 | |
964 | void UpdateItem(const wxMacDataItem *container, const wxMacDataItem *item, | |
6cce68ea | 965 | DataBrowserPropertyID property) const; |
725566ca | 966 | void UpdateItems(const wxMacDataItem *container, wxArrayMacDataItemPtr &items, |
6cce68ea | 967 | DataBrowserPropertyID property) const; |
725566ca | 968 | |
3ef4e126 SC |
969 | void InsertColumn(int colId, DataBrowserPropertyType colType, |
970 | const wxString& title, SInt16 just = teFlushDefault, int defaultWidth = -1); | |
7b514b3b | 971 | |
e2bc1d69 KO |
972 | int GetColumnWidth(int colId); |
973 | void SetColumnWidth(int colId, int width); | |
974 | ||
6cce68ea SC |
975 | void AddItem(wxMacDataItem *container, wxMacDataItem *item); |
976 | void AddItems(wxMacDataItem *container, wxArrayMacDataItemPtr &items ); | |
977 | ||
978 | void RemoveAllItems(wxMacDataItem *container); | |
979 | void RemoveItem(wxMacDataItem *container, wxMacDataItem* item); | |
980 | void RemoveItems(wxMacDataItem *container, wxArrayMacDataItemPtr &items); | |
725566ca | 981 | |
6cce68ea SC |
982 | void SetSelectedItem( wxMacDataItem* item , DataBrowserSetOption option); |
983 | void SetSelectedItems( wxArrayMacDataItemPtr &items , DataBrowserSetOption option); | |
984 | void SetSelectedAllItems( DataBrowserSetOption option); | |
985 | Boolean IsItemSelected( const wxMacDataItem* item) const; | |
725566ca | 986 | |
6cce68ea | 987 | void RevealItem( wxMacDataItem* item, DataBrowserRevealOptions options); |
725566ca | 988 | |
6cce68ea | 989 | void GetSelectionAnchor( wxMacDataItemPtr* first , wxMacDataItemPtr* last) const; |
725566ca | 990 | |
6cce68ea | 991 | // item aware methods, to be used in subclasses |
725566ca VZ |
992 | |
993 | virtual Boolean CompareItems(const wxMacDataItem* itemOneID, | |
994 | const wxMacDataItem* itemTwoID, | |
6cce68ea SC |
995 | DataBrowserPropertyID sortProperty); |
996 | ||
997 | virtual OSStatus GetSetItemData(wxMacDataItem* itemID, | |
998 | DataBrowserPropertyID property, | |
999 | DataBrowserItemDataRef itemData, | |
1000 | Boolean changeValue ); | |
1001 | ||
1002 | virtual void ItemNotification( | |
1003 | const wxMacDataItem* itemID, | |
1004 | DataBrowserItemNotification message, | |
1005 | DataBrowserItemDataRef itemData); | |
8b64a7e2 PC |
1006 | |
1007 | // as we are getting the same events for human and API selection we have to suppress | |
1008 | // events in the latter case, since this will be used from many subclasses we keep it here | |
1009 | ||
1010 | bool IsSelectionSuppressed() const { return m_suppressSelection; } | |
1011 | bool SuppressSelection( bool suppress ); | |
7b514b3b VZ |
1012 | |
1013 | ||
e2bc1d69 KO |
1014 | // wxMacListControl Methods |
1015 | // add and remove | |
1016 | ||
1017 | virtual void MacDelete( unsigned int n ); | |
a236aa20 | 1018 | virtual void MacInsert( unsigned int n, const wxArrayStringsAdapter& items, int column = -1 ); |
e2bc1d69 KO |
1019 | virtual int MacAppend( const wxString& item ); |
1020 | virtual void MacClear(); | |
1021 | ||
1022 | // selecting | |
1023 | ||
1024 | virtual void MacDeselectAll(); | |
1025 | virtual void MacSetSelection( unsigned int n, bool select, bool multi = false ); | |
1026 | virtual int MacGetSelection() const; | |
1027 | virtual int MacGetSelections( wxArrayInt& aSelections ) const; | |
1028 | virtual bool MacIsSelected( unsigned int n ) const; | |
1029 | ||
1030 | // display | |
1031 | ||
1032 | virtual void MacScrollTo( unsigned int n ); | |
1033 | ||
1034 | // accessing content | |
1035 | ||
1036 | virtual void MacSetString( unsigned int n, const wxString& item ); | |
1037 | virtual void MacSetClientData( unsigned int n, void * data); | |
1038 | virtual wxString MacGetString( unsigned int n) const; | |
1039 | virtual void * MacGetClientData( unsigned int) const; | |
1040 | virtual unsigned int MacGetCount() const; | |
1041 | ||
1042 | // client data | |
1043 | ||
1044 | virtual wxClientDataType GetClientDataType() const; | |
1045 | virtual void SetClientDataType(wxClientDataType clientDataItemsType); | |
67650ea0 KO |
1046 | //virtual ListSortOrder GetSortOrder() const; |
1047 | //virtual void SetSortOrder(const ListSortOrder sort); | |
e2bc1d69 | 1048 | |
7b514b3b | 1049 | |
8b64a7e2 PC |
1050 | |
1051 | protected: | |
e2bc1d69 KO |
1052 | |
1053 | ListSortOrder m_sortOrder; | |
1054 | wxClientDataType m_clientDataItemsType; | |
1055 | ||
6cce68ea | 1056 | // ID aware base methods, should be 'final' ie not changed in subclasses |
725566ca VZ |
1057 | |
1058 | virtual Boolean CompareItems(DataBrowserItemID itemOneID, | |
1059 | DataBrowserItemID itemTwoID, | |
6cce68ea SC |
1060 | DataBrowserPropertyID sortProperty); |
1061 | ||
1062 | virtual OSStatus GetSetItemData(DataBrowserItemID itemID, | |
1063 | DataBrowserPropertyID property, | |
1064 | DataBrowserItemDataRef itemData, | |
1065 | Boolean changeValue ); | |
1066 | ||
1067 | virtual void ItemNotification( | |
1068 | DataBrowserItemID itemID, | |
1069 | DataBrowserItemNotification message, | |
1070 | DataBrowserItemDataRef itemData); | |
1071 | ||
e2bc1d69 | 1072 | |
6cce68ea SC |
1073 | private : |
1074 | ||
1075 | bool m_suppressSelection; | |
bf9a1615 | 1076 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacDataItemBrowserControl) |
6cce68ea SC |
1077 | }; |
1078 | ||
1079 | class wxMacDataItemBrowserSelectionSuppressor | |
1080 | { | |
1081 | public : | |
1082 | wxMacDataItemBrowserSelectionSuppressor(wxMacDataItemBrowserControl *browser); | |
1083 | ~wxMacDataItemBrowserSelectionSuppressor(); | |
725566ca | 1084 | |
6cce68ea SC |
1085 | private : |
1086 | ||
1087 | bool m_former; | |
1088 | wxMacDataItemBrowserControl* m_browser; | |
1089 | }; | |
1090 | ||
1091 | // ============================================================================ | |
1092 | // platform listbox implementation | |
1093 | // ============================================================================ | |
e2bc1d69 | 1094 | |
6cce68ea SC |
1095 | // exposed for reuse in wxCheckListBox |
1096 | ||
1097 | class wxMacListBoxItem : public wxMacDataItem | |
1098 | { | |
1099 | public : | |
1100 | wxMacListBoxItem(); | |
725566ca | 1101 | |
6cce68ea | 1102 | virtual ~wxMacListBoxItem(); |
725566ca | 1103 | |
725566ca | 1104 | virtual void Notification(wxMacDataItemBrowserControl *owner , |
6cce68ea SC |
1105 | DataBrowserItemNotification message, |
1106 | DataBrowserItemDataRef itemData ) const; | |
6cce68ea SC |
1107 | }; |
1108 | ||
e2bc1d69 | 1109 | class wxMacDataBrowserListControl : public wxMacDataItemBrowserControl |
6cce68ea SC |
1110 | { |
1111 | public: | |
e2bc1d69 | 1112 | wxMacDataBrowserListControl( wxWindow *peer, const wxPoint& pos, const wxSize& size, long style ); |
bf9a1615 | 1113 | wxMacDataBrowserListControl() {} |
d3c7fc99 | 1114 | virtual ~wxMacDataBrowserListControl(); |
6cce68ea | 1115 | |
e6fd62dd RD |
1116 | virtual wxMacDataItem* CreateItem(); |
1117 | ||
6cce68ea SC |
1118 | // pointing back |
1119 | ||
e2bc1d69 KO |
1120 | wxWindow * GetPeer() const; |
1121 | ||
bf9a1615 | 1122 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacDataBrowserListControl) |
6cce68ea SC |
1123 | }; |
1124 | ||
1125 | // ============================================================================ | |
1126 | // graphics implementation | |
1127 | // ============================================================================ | |
86d8b744 | 1128 | |
ebf2a1ec SC |
1129 | // make sure we all use one class for all conversions from wx to native colour |
1130 | ||
1131 | class wxMacCoreGraphicsColour | |
1132 | { | |
1133 | public: | |
1134 | wxMacCoreGraphicsColour(); | |
1135 | wxMacCoreGraphicsColour(const wxBrush &brush); | |
1136 | ~wxMacCoreGraphicsColour(); | |
1137 | ||
1138 | void Apply( CGContextRef cgContext ); | |
1139 | protected: | |
1140 | void Init(); | |
1141 | wxMacCFRefHolder<CGColorRef> m_color; | |
1142 | wxMacCFRefHolder<CGColorSpaceRef> m_colorSpace; | |
1143 | ||
1144 | bool m_isPattern; | |
1145 | wxMacCFRefHolder<CGPatternRef> m_pattern; | |
1146 | CGFloat* m_patternColorComponents; | |
1147 | } ; | |
1148 | ||
cd7d36c0 | 1149 | #if wxMAC_USE_CORE_GRAPHICS && !wxUSE_GRAPHICS_CONTEXT |
20b69855 | 1150 | |
fb5246be | 1151 | class WXDLLEXPORT wxMacCGPath : public wxGraphicPath |
20b69855 SC |
1152 | { |
1153 | DECLARE_NO_COPY_CLASS(wxMacCGPath) | |
1154 | public : | |
6cce68ea SC |
1155 | wxMacCGPath(); |
1156 | ~wxMacCGPath(); | |
fb5246be | 1157 | |
20b69855 | 1158 | // Starts a new subpath at |
6cce68ea SC |
1159 | void MoveToPoint( wxCoord x1 , wxCoord y1 ); |
1160 | void AddLineToPoint( wxCoord x1 , wxCoord y1 ); | |
1161 | void AddQuadCurveToPoint( wxCoord cx1, wxCoord cy1, wxCoord x1, wxCoord y1 ); | |
1162 | void AddRectangle( wxCoord x, wxCoord y, wxCoord w, wxCoord h ); | |
1163 | void AddCircle( wxCoord x, wxCoord y , wxCoord r ); | |
fb5246be | 1164 | |
a85ff267 SC |
1165 | // draws a an arc to two tangents connecting (current) to (x1,y1) and (x1,y1) to (x2,y2) |
1166 | virtual void AddArcToPoint( wxCoord x1, wxCoord y1 , wxCoord x2, wxCoord y2, wxCoord r ) ; | |
1167 | virtual void AddArc( wxCoord x, wxCoord y, wxCoord r, double startAngle, double endAngle, bool clockwise ) ; | |
1168 | ||
20b69855 | 1169 | // closes the current subpath |
6cce68ea | 1170 | void CloseSubpath(); |
fb5246be | 1171 | |
6cce68ea | 1172 | CGPathRef GetPath() const; |
20b69855 | 1173 | private : |
6cce68ea SC |
1174 | CGMutablePathRef m_path; |
1175 | }; | |
20b69855 SC |
1176 | |
1177 | class WXDLLEXPORT wxMacCGContext : public wxGraphicContext | |
1178 | { | |
1179 | DECLARE_NO_COPY_CLASS(wxMacCGContext) | |
fb5246be | 1180 | |
20b69855 | 1181 | public: |
6cce68ea SC |
1182 | wxMacCGContext( CGrafPtr port ); |
1183 | wxMacCGContext( CGContextRef cgcontext ); | |
1184 | wxMacCGContext(); | |
d3c7fc99 | 1185 | virtual ~wxMacCGContext(); |
6cce68ea SC |
1186 | |
1187 | virtual void Clip( const wxRegion ®ion ); | |
1188 | virtual void StrokePath( const wxGraphicPath *p ); | |
1189 | virtual void DrawPath( const wxGraphicPath *p , int fillStyle = wxWINDING_RULE ); | |
1190 | virtual void FillPath( const wxGraphicPath *p , const wxColor &fillColor , int fillStyle = wxWINDING_RULE ); | |
1191 | ||
1192 | virtual wxGraphicPath* CreatePath(); | |
1193 | virtual void SetPen( const wxPen &pen ) ; | |
1194 | virtual void SetBrush( const wxBrush &brush ); | |
1195 | CGContextRef GetNativeContext(); | |
1196 | void SetNativeContext( CGContextRef cg ); | |
1197 | CGPathDrawingMode GetDrawingMode() const { return m_mode; } | |
a85ff267 | 1198 | |
7b514b3b VZ |
1199 | virtual void Translate( wxCoord dx , wxCoord dy ); |
1200 | virtual void Scale( wxCoord xScale , wxCoord yScale ); | |
a85ff267 SC |
1201 | virtual void DrawBitmap( const wxBitmap &bmp, wxCoord x, wxCoord y, wxCoord w, wxCoord h ); |
1202 | virtual void DrawIcon( const wxIcon &icon, wxCoord x, wxCoord y, wxCoord w, wxCoord h ); | |
7b514b3b | 1203 | virtual void PushState(); |
a85ff267 | 1204 | virtual void PopState(); |
7b514b3b | 1205 | |
a85ff267 | 1206 | virtual void DrawText( const wxString &str, wxCoord x, wxCoord y, double angle ) ; |
7b514b3b | 1207 | |
a85ff267 SC |
1208 | virtual void GetTextExtent( const wxString &str, wxCoord *width, wxCoord *height, |
1209 | wxCoord *descent, wxCoord *externalLeading ) const ; | |
7b514b3b | 1210 | |
a85ff267 | 1211 | virtual void GetPartialTextExtents(const wxString& text, wxArrayInt& widths) const ; |
7b514b3b | 1212 | |
a85ff267 SC |
1213 | virtual void SetFont( const wxFont &font ) ; |
1214 | ||
7b514b3b | 1215 | virtual void SetTextColor( const wxColour &col ) ; |
20b69855 | 1216 | private: |
6cce68ea SC |
1217 | CGContextRef m_cgContext; |
1218 | CGrafPtr m_qdPort; | |
1219 | CGPathDrawingMode m_mode; | |
a85ff267 | 1220 | ATSUStyle m_macATSUIStyle ; |
6cce68ea SC |
1221 | wxPen m_pen; |
1222 | wxBrush m_brush; | |
a85ff267 | 1223 | wxColor m_textForegroundColor ; |
6cce68ea | 1224 | }; |
20b69855 | 1225 | |
30e77b5c SC |
1226 | #endif // wxMAC_USE_CORE_GRAPHICS |
1227 | ||
1228 | #ifdef __WXMAC_OSX__ | |
1229 | ||
6cce68ea SC |
1230 | CGColorSpaceRef wxMacGetGenericRGBColorSpace(void); |
1231 | void wxMacMemoryBufferReleaseProc(void *info, const void *data, size_t size); | |
20b69855 | 1232 | |
30e77b5c | 1233 | #endif |
20b69855 SC |
1234 | |
1235 | class WXDLLEXPORT wxBitmapRefData: public wxGDIRefData | |
1236 | { | |
b5dbe15d VS |
1237 | friend class WXDLLIMPEXP_FWD_CORE wxIcon; |
1238 | friend class WXDLLIMPEXP_FWD_CORE wxCursor; | |
20b69855 SC |
1239 | public: |
1240 | wxBitmapRefData(int width , int height , int depth); | |
1241 | wxBitmapRefData(); | |
2bf8f4c0 RD |
1242 | wxBitmapRefData(const wxBitmapRefData &tocopy); |
1243 | ||
d3c7fc99 | 1244 | virtual ~wxBitmapRefData(); |
20b69855 | 1245 | |
6cce68ea | 1246 | void Free(); |
b7cacb43 VZ |
1247 | bool Ok() const { return IsOk(); } |
1248 | bool IsOk() const { return m_ok; } | |
6cce68ea | 1249 | void SetOk( bool isOk) { m_ok = isOk; } |
fb5246be | 1250 | |
6cce68ea SC |
1251 | void SetWidth( int width ) { m_width = width; } |
1252 | void SetHeight( int height ) { m_height = height; } | |
1253 | void SetDepth( int depth ) { m_depth = depth; } | |
20b69855 | 1254 | |
6cce68ea SC |
1255 | int GetWidth() const { return m_width; } |
1256 | int GetHeight() const { return m_height; } | |
1257 | int GetDepth() const { return m_depth; } | |
fb5246be | 1258 | |
6cce68ea SC |
1259 | void *GetRawAccess() const; |
1260 | void *BeginRawAccess(); | |
1261 | void EndRawAccess(); | |
20b69855 | 1262 | |
6cce68ea SC |
1263 | bool HasAlpha() const { return m_hasAlpha; } |
1264 | void UseAlpha( bool useAlpha ); | |
20b69855 SC |
1265 | |
1266 | public: | |
1267 | #if wxUSE_PALETTE | |
1268 | wxPalette m_bitmapPalette; | |
1269 | #endif // wxUSE_PALETTE | |
fb5246be | 1270 | |
20b69855 | 1271 | wxMask * m_bitmapMask; // Optional mask |
30e77b5c | 1272 | #ifdef __WXMAC_OSX__ |
6cce68ea | 1273 | CGImageRef CGImageCreate() const; |
71cc158e | 1274 | #endif |
fb5246be | 1275 | |
6d2c830a SC |
1276 | // returns true if the bitmap has a size that |
1277 | // can be natively transferred into a true icon | |
1278 | // if no is returned GetIconRef will still produce | |
1279 | // an icon but it will be generated via a PICT and | |
fb5246be | 1280 | // rescaled to 16 x 16 |
6cce68ea | 1281 | bool HasNativeSize(); |
fb5246be | 1282 | |
6d2c830a SC |
1283 | // caller should increase ref count if needed longer |
1284 | // than the bitmap exists | |
6cce68ea | 1285 | IconRef GetIconRef(); |
fb5246be | 1286 | |
6d2c830a | 1287 | // returns a Pict from the bitmap content |
6cce68ea | 1288 | PicHandle GetPictHandle(); |
ebf2a1ec SC |
1289 | #if wxMAC_USE_CORE_GRAPHICS |
1290 | CGContextRef GetBitmapContext() const; | |
1291 | #else | |
6cce68ea SC |
1292 | GWorldPtr GetHBITMAP(GWorldPtr * mask = NULL ) const; |
1293 | void UpdateAlphaMask() const; | |
ebf2a1ec SC |
1294 | #endif |
1295 | int GetBytesPerRow() const { return m_bytesPerRow; } | |
20b69855 | 1296 | private : |
6cce68ea SC |
1297 | bool Create(int width , int height , int depth); |
1298 | void Init(); | |
20b69855 SC |
1299 | |
1300 | int m_width; | |
1301 | int m_height; | |
6cce68ea | 1302 | int m_bytesPerRow; |
20b69855 SC |
1303 | int m_depth; |
1304 | bool m_hasAlpha; | |
6cce68ea SC |
1305 | wxMemoryBuffer m_memBuf; |
1306 | int m_rawAccessCount; | |
20b69855 | 1307 | bool m_ok; |
30e77b5c | 1308 | #ifdef __WXMAC_OSX__ |
6cce68ea | 1309 | mutable CGImageRef m_cgImageRef; |
71cc158e | 1310 | #endif |
6cce68ea SC |
1311 | IconRef m_iconRef; |
1312 | PicHandle m_pictHandle; | |
ebf2a1ec SC |
1313 | #if wxMAC_USE_CORE_GRAPHICS |
1314 | CGContextRef m_hBitmap; | |
1315 | #else | |
20b69855 | 1316 | GWorldPtr m_hBitmap; |
6cce68ea SC |
1317 | GWorldPtr m_hMaskBitmap; |
1318 | wxMemoryBuffer m_maskMemBuf; | |
1319 | int m_maskBytesPerRow; | |
ebf2a1ec | 1320 | #endif |
20b69855 SC |
1321 | }; |
1322 | ||
20b69855 SC |
1323 | class WXDLLEXPORT wxIconRefData : public wxGDIRefData |
1324 | { | |
1325 | public: | |
6cce68ea SC |
1326 | wxIconRefData(); |
1327 | wxIconRefData( WXHICON ); | |
20b69855 SC |
1328 | virtual ~wxIconRefData() { Free(); } |
1329 | ||
6cce68ea | 1330 | void Init(); |
20b69855 | 1331 | virtual void Free(); |
ddb08e02 | 1332 | |
6cce68ea SC |
1333 | void SetWidth( int width ) { m_width = width; } |
1334 | void SetHeight( int height ) { m_height = height; } | |
ddb08e02 | 1335 | |
6cce68ea SC |
1336 | int GetWidth() const { return m_width; } |
1337 | int GetHeight() const { return m_height; } | |
ddb08e02 | 1338 | |
6cce68ea | 1339 | WXHICON GetHICON() const { return (WXHICON) m_iconRef; } |
20b69855 | 1340 | private : |
6cce68ea SC |
1341 | IconRef m_iconRef; |
1342 | int m_width; | |
1343 | int m_height; | |
20b69855 SC |
1344 | }; |
1345 | ||
285b5ce0 SC |
1346 | // toplevel.cpp |
1347 | ||
ebf2a1ec SC |
1348 | class wxMacDeferredWindowDeleter : public wxObject |
1349 | { | |
1350 | public : | |
1351 | wxMacDeferredWindowDeleter( WindowRef windowRef ); | |
1352 | virtual ~wxMacDeferredWindowDeleter(); | |
1353 | ||
1354 | protected : | |
1355 | WindowRef m_macWindow ; | |
1356 | } ; | |
1357 | ||
6cce68ea | 1358 | ControlRef wxMacFindControlUnderMouse( wxTopLevelWindowMac* toplevelWindow, const Point& location , WindowRef window , ControlPartCode *outPart ); |
285b5ce0 | 1359 | |
eb89f88a SC |
1360 | #ifndef __LP64__ |
1361 | ||
ecf418ad | 1362 | #ifdef WORDS_BIGENDIAN |
725566ca VZ |
1363 | inline Rect* wxMacGetPictureBounds( PicHandle pict , Rect* rect ) |
1364 | { | |
1365 | *rect = (**pict).picFrame; | |
6cce68ea | 1366 | return rect; |
7358f907 SC |
1367 | } |
1368 | #else | |
725566ca VZ |
1369 | inline Rect* wxMacGetPictureBounds( PicHandle pict , Rect* rect ) |
1370 | { | |
6cce68ea | 1371 | return QDGetPictureBounds( pict , rect ); |
7358f907 SC |
1372 | } |
1373 | #endif | |
1374 | ||
eb89f88a SC |
1375 | #endif |
1376 | ||
8cf73271 SC |
1377 | #endif // wxUSE_GUI |
1378 | ||
285b5ce0 SC |
1379 | #define wxMAC_DEFINE_PROC_GETTER( UPP , x ) \ |
1380 | UPP Get##x() \ | |
1381 | { \ | |
1382 | static UPP sHandler = NULL; \ | |
1383 | if ( sHandler == NULL ) \ | |
1384 | sHandler = New##UPP( x ); \ | |
1385 | return sHandler; \ | |
1386 | } | |
1387 | ||
8cf73271 SC |
1388 | //--------------------------------------------------------------------------- |
1389 | // wxMac string conversions | |
1390 | //--------------------------------------------------------------------------- | |
1391 | ||
6cce68ea SC |
1392 | void wxMacSetupConverters(); |
1393 | void wxMacCleanupConverters(); | |
8cf73271 | 1394 | |
e17206f7 VS |
1395 | WXDLLIMPEXP_BASE void wxMacStringToPascal( const wxString&from , StringPtr to ); |
1396 | WXDLLIMPEXP_BASE wxString wxMacMakeStringFromPascal( ConstStringPtr from ); | |
8cf73271 | 1397 | |
a2b77260 SC |
1398 | // filefn.cpp |
1399 | ||
e17206f7 VS |
1400 | WXDLLIMPEXP_BASE wxString wxMacFSRefToPath( const FSRef *fsRef , CFStringRef additionalPathComponent = NULL ); |
1401 | WXDLLIMPEXP_BASE OSStatus wxMacPathToFSRef( const wxString&path , FSRef *fsRef ); | |
1402 | WXDLLIMPEXP_BASE wxString wxMacHFSUniStrToString( ConstHFSUniStr255Param uniname ); | |
aa0cc8a1 | 1403 | |
eb89f88a SC |
1404 | #if wxUSE_GUI |
1405 | ||
1406 | // deprecating QD | |
1407 | ||
1408 | void wxMacLocalToGlobal( WindowRef window , Point*pt ); | |
1409 | void wxMacGlobalToLocal( WindowRef window , Point*pt ); | |
1410 | ||
1411 | #endif | |
1412 | ||
ebf2a1ec SC |
1413 | //--------------------------------------------------------------------------- |
1414 | // cocoa bridging utilities | |
1415 | //--------------------------------------------------------------------------- | |
1416 | ||
1417 | bool wxMacInitCocoa(); | |
1418 | ||
1419 | class wxMacAutoreleasePool | |
1420 | { | |
1421 | public : | |
1422 | wxMacAutoreleasePool(); | |
1423 | ~wxMacAutoreleasePool(); | |
1424 | private : | |
1425 | void* m_pool; | |
1426 | }; | |
1427 | ||
1428 | // NSObject | |
1429 | ||
1430 | void wxMacCocoaRelease( void* obj ); | |
1431 | void wxMacCocoaAutorelease( void* obj ); | |
1432 | void wxMacCocoaRetain( void* obj ); | |
1433 | ||
1434 | #if wxMAC_USE_COCOA | |
1435 | ||
1436 | // NSCursor | |
1437 | ||
1438 | WX_NSCursor wxMacCocoaCreateStockCursor( int cursor_type ); | |
1439 | WX_NSCursor wxMacCocoaCreateCursorFromCGImage( CGImageRef cgImageRef, float hotSpotX, float hotSpotY ); | |
1440 | void wxMacCocoaSetCursor( WX_NSCursor cursor ); | |
1441 | void wxMacCocoaHideCursor(); | |
1442 | void wxMacCocoaShowCursor(); | |
1443 | ||
1444 | typedef struct tagClassicCursor | |
1445 | { | |
1446 | wxUint16 bits[16]; | |
1447 | wxUint16 mask[16]; | |
1448 | wxInt16 hotspot[2]; | |
1449 | }ClassicCursor; | |
1450 | ||
1451 | #else // !wxMAC_USE_COCOA | |
1452 | ||
1453 | // non Darwin | |
1454 | ||
1455 | typedef Cursor ClassicCursor; | |
1456 | ||
1457 | #endif // wxMAC_USE_COCOA | |
1458 | ||
1459 | // ------------- | |
1460 | // Common to all | |
1461 | // ------------- | |
1462 | ||
1463 | // Cursor support | |
1464 | ||
1465 | const short kwxCursorBullseye = 0; | |
1466 | const short kwxCursorBlank = 1; | |
1467 | const short kwxCursorPencil = 2; | |
1468 | const short kwxCursorMagnifier = 3; | |
1469 | const short kwxCursorNoEntry = 4; | |
1470 | const short kwxCursorPaintBrush = 5; | |
1471 | const short kwxCursorPointRight = 6; | |
1472 | const short kwxCursorPointLeft = 7; | |
1473 | const short kwxCursorQuestionArrow = 8; | |
1474 | const short kwxCursorRightArrow = 9; | |
1475 | const short kwxCursorSizeNS = 10; | |
1476 | const short kwxCursorSize = 11; | |
1477 | const short kwxCursorSizeNESW = 12; | |
1478 | const short kwxCursorSizeNWSE = 13; | |
1479 | const short kwxCursorRoller = 14; | |
1480 | const short kwxCursorLast = kwxCursorRoller; | |
1481 | ||
1482 | // exposing our fallback cursor map | |
1483 | ||
1484 | extern ClassicCursor gMacCursors[]; | |
1485 | ||
8cf73271 SC |
1486 | #endif |
1487 | // _WX_PRIVATE_H_ |