]>
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 | ||
5185263f DE |
46 | #ifdef __WXMAC_CARBON__ |
47 | #include "wx/mac/corefoundation/cfstring.h" | |
48 | #endif | |
49 | ||
3d639707 SC |
50 | #ifndef FixedToInt |
51 | // as macro in FixMath.h for 10.3 | |
52 | inline Fixed IntToFixed( int inInt ) | |
53 | { | |
54 | return (((SInt32) inInt) << 16); | |
55 | } | |
56 | ||
57 | inline int FixedToInt( Fixed inFixed ) | |
58 | { | |
59 | return (((SInt32) inFixed) >> 16); | |
60 | } | |
61 | #endif | |
62 | ||
8cf73271 SC |
63 | #if wxUSE_GUI |
64 | ||
dd0d56f5 | 65 | #include "wx/listbox.h" |
8cf73271 | 66 | |
fb5246be | 67 | class wxMacPortStateHelper |
8cf73271 SC |
68 | { |
69 | DECLARE_NO_COPY_CLASS(wxMacPortStateHelper) | |
fb5246be | 70 | |
8cf73271 | 71 | public: |
6cce68ea SC |
72 | wxMacPortStateHelper( GrafPtr newport); |
73 | wxMacPortStateHelper(); | |
74 | ~wxMacPortStateHelper(); | |
8cf73271 | 75 | |
6cce68ea SC |
76 | void Setup( GrafPtr newport ); |
77 | void Clear(); | |
78 | bool IsCleared() { return m_clip == NULL; } | |
79 | GrafPtr GetCurrentPort() { return m_currentPort; } | |
8cf73271 SC |
80 | |
81 | private: | |
6cce68ea SC |
82 | GrafPtr m_currentPort; |
83 | GrafPtr m_oldPort; | |
84 | RgnHandle m_clip; | |
85 | ThemeDrawingState m_drawingState; | |
86 | short m_textFont; | |
87 | short m_textSize; | |
88 | short m_textStyle; | |
89 | short m_textMode; | |
90 | }; | |
8cf73271 | 91 | |
4f305456 SC |
92 | class WXDLLEXPORT wxMacPortSaver |
93 | { | |
94 | DECLARE_NO_COPY_CLASS(wxMacPortSaver) | |
fb5246be | 95 | |
4f305456 | 96 | public: |
54ce9ebb JS |
97 | wxMacPortSaver( GrafPtr port ); |
98 | ~wxMacPortSaver(); | |
4f305456 | 99 | private : |
6cce68ea SC |
100 | GrafPtr m_port; |
101 | }; | |
4f305456 | 102 | |
8cf73271 SC |
103 | class WXDLLEXPORT wxMacPortSetter |
104 | { | |
105 | DECLARE_NO_COPY_CLASS(wxMacPortSetter) | |
fb5246be | 106 | |
8cf73271 | 107 | public: |
6cce68ea SC |
108 | wxMacPortSetter( const wxDC* dc ); |
109 | ~wxMacPortSetter(); | |
8cf73271 | 110 | private: |
6cce68ea SC |
111 | wxMacPortStateHelper m_ph; |
112 | const wxDC* m_dc; | |
113 | }; | |
8cf73271 | 114 | |
4f305456 SC |
115 | /* |
116 | Clips to the visible region of a control within the current port | |
117 | */ | |
fb5246be | 118 | |
4f305456 | 119 | class WXDLLEXPORT wxMacWindowClipper : public wxMacPortSaver |
8cf73271 SC |
120 | { |
121 | DECLARE_NO_COPY_CLASS(wxMacWindowClipper) | |
fb5246be | 122 | |
8cf73271 | 123 | public: |
6cce68ea SC |
124 | wxMacWindowClipper( const wxWindow* win ); |
125 | ~wxMacWindowClipper(); | |
8cf73271 | 126 | private: |
6cce68ea SC |
127 | GrafPtr m_newPort; |
128 | RgnHandle m_formerClip; | |
129 | RgnHandle m_newClip; | |
130 | }; | |
8cf73271 | 131 | |
01299d56 SC |
132 | class WXDLLEXPORT wxMacWindowStateSaver : public wxMacWindowClipper |
133 | { | |
134 | DECLARE_NO_COPY_CLASS(wxMacWindowStateSaver) | |
fb5246be | 135 | |
01299d56 | 136 | public: |
6cce68ea SC |
137 | wxMacWindowStateSaver( const wxWindow* win ); |
138 | ~wxMacWindowStateSaver(); | |
01299d56 | 139 | private: |
6cce68ea SC |
140 | GrafPtr m_newPort; |
141 | ThemeDrawingState m_themeDrawingState; | |
142 | }; | |
01299d56 | 143 | |
ddb08e02 | 144 | #if wxMAC_USE_CORE_GRAPHICS |
fb5246be | 145 | class WXDLLEXPORT wxMacCGContextStateSaver |
ddb08e02 SC |
146 | { |
147 | DECLARE_NO_COPY_CLASS(wxMacCGContextStateSaver) | |
fb5246be | 148 | |
ddb08e02 | 149 | public: |
fb5246be | 150 | wxMacCGContextStateSaver( CGContextRef cg ) |
ddb08e02 | 151 | { |
6cce68ea SC |
152 | m_cg = cg; |
153 | CGContextSaveGState( cg ); | |
ddb08e02 | 154 | } |
fb5246be | 155 | ~wxMacCGContextStateSaver() |
ddb08e02 | 156 | { |
6cce68ea | 157 | CGContextRestoreGState( m_cg ); |
ddb08e02 SC |
158 | } |
159 | private: | |
6cce68ea SC |
160 | CGContextRef m_cg; |
161 | }; | |
ddb08e02 SC |
162 | |
163 | #endif | |
4f305456 | 164 | /* |
8cf73271 SC |
165 | class wxMacDrawingHelper |
166 | { | |
167 | DECLARE_NO_COPY_CLASS(wxMacDrawingHelper) | |
fb5246be | 168 | |
8cf73271 | 169 | public: |
6cce68ea SC |
170 | wxMacDrawingHelper( wxWindowMac * theWindow , bool clientArea = false ); |
171 | ~wxMacDrawingHelper(); | |
172 | bool Ok() { return m_ok; } | |
173 | void LocalToWindow( Rect *rect) { OffsetRect( rect , m_origin.h , m_origin.v ); } | |
174 | void LocalToWindow( Point *pt ) { AddPt( m_origin , pt ); } | |
175 | void LocalToWindow( RgnHandle rgn ) { OffsetRgn( rgn , m_origin.h , m_origin.v ); } | |
176 | const Point& GetOrigin() { return m_origin; } | |
8cf73271 | 177 | private: |
6cce68ea SC |
178 | Point m_origin; |
179 | GrafPtr m_formerPort; | |
180 | GrafPtr m_currentPort; | |
181 | PenState m_savedPenState; | |
182 | bool m_ok; | |
183 | }; | |
4f305456 | 184 | */ |
8cf73271 SC |
185 | |
186 | // app.h | |
6cce68ea | 187 | bool wxMacConvertEventToRecord( EventRef event , EventRecord *rec); |
8cf73271 SC |
188 | |
189 | #endif // wxUSE_GUI | |
190 | ||
191 | // filefn.h | |
6cce68ea SC |
192 | WXDLLEXPORT wxString wxMacFSSpec2MacFilename( const FSSpec *spec ); |
193 | WXDLLEXPORT void wxMacFilename2FSSpec( const wxString &path , FSSpec *spec ); | |
8cf73271 SC |
194 | |
195 | // utils.h | |
17af82fb VZ |
196 | WXDLLEXPORT wxString wxMacFindFolderNoSeparator(short vRefNum, |
197 | OSType folderType, | |
198 | Boolean createFolder); | |
8cf73271 SC |
199 | WXDLLEXPORT wxString wxMacFindFolder(short vRefNum, |
200 | OSType folderType, | |
201 | Boolean createFolder); | |
202 | ||
6cce68ea SC |
203 | template<typename T> EventParamType wxMacGetEventParamType() { wxFAIL_MSG( wxT("Unknown Param Type") ); return 0; } |
204 | template<> inline EventParamType wxMacGetEventParamType<RgnHandle>() { return typeQDRgnHandle; } | |
205 | template<> inline EventParamType wxMacGetEventParamType<ControlRef>() { return typeControlRef; } | |
206 | template<> inline EventParamType wxMacGetEventParamType<WindowRef>() { return typeWindowRef; } | |
207 | template<> inline EventParamType wxMacGetEventParamType<MenuRef>() { return typeMenuRef; } | |
208 | template<> inline EventParamType wxMacGetEventParamType<EventRef>() { return typeEventRef; } | |
209 | template<> inline EventParamType wxMacGetEventParamType<Point>() { return typeQDPoint; } | |
210 | template<> inline EventParamType wxMacGetEventParamType<Rect>() { return typeQDRectangle; } | |
211 | template<> inline EventParamType wxMacGetEventParamType<Boolean>() { return typeBoolean; } | |
212 | template<> inline EventParamType wxMacGetEventParamType<SInt16>() { return typeSInt16; } | |
213 | template<> inline EventParamType wxMacGetEventParamType<SInt32>() { return typeSInt32; } | |
214 | template<> inline EventParamType wxMacGetEventParamType<UInt32>() { return typeUInt32; } | |
215 | template<> inline EventParamType wxMacGetEventParamType<RGBColor>() { return typeRGBColor; } | |
4f305456 | 216 | #if TARGET_API_MAC_OSX |
6cce68ea SC |
217 | template<> inline EventParamType wxMacGetEventParamType<HICommand>() { return typeHICommand; } |
218 | template<> inline EventParamType wxMacGetEventParamType<HIPoint>() { return typeHIPoint; } | |
219 | template<> inline EventParamType wxMacGetEventParamType<HISize>() { return typeHISize; } | |
220 | template<> inline EventParamType wxMacGetEventParamType<HIRect>() { return typeHIRect; } | |
221 | template<> inline EventParamType wxMacGetEventParamType<void*>() { return typeVoidPtr; } | |
4f305456 | 222 | #endif |
b1fd3bad | 223 | #if TARGET_API_MAC_OSX && ( MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2 ) |
6cce68ea | 224 | template<> inline EventParamType wxMacGetEventParamType<CFDictionaryRef>() { return typeCFDictionaryRef; } |
b1fd3bad | 225 | #endif |
6cce68ea SC |
226 | template<> inline EventParamType wxMacGetEventParamType<Collection>() { return typeCollection; } |
227 | template<> inline EventParamType wxMacGetEventParamType<CGContextRef>() { return typeCGContextRef; } | |
4f305456 | 228 | /* |
885fb02f | 229 | These are ambiguous |
6cce68ea SC |
230 | template<> EventParamType wxMacGetEventParamType<GrafPtr>() { return typeGrafPtr; } |
231 | template<> EventParamType wxMacGetEventParamType<OSStatus>() { return typeOSStatus; } | |
232 | template<> EventParamType wxMacGetEventParamType<CFIndex>() { return typeCFIndex; } | |
233 | template<> EventParamType wxMacGetEventParamType<GWorldPtr>() { return typeGWorldPtr; } | |
885fb02f | 234 | */ |
4f305456 SC |
235 | |
236 | class wxMacCarbonEvent | |
237 | { | |
fb5246be | 238 | |
4f305456 | 239 | public : |
a4848597 SC |
240 | wxMacCarbonEvent() |
241 | { | |
6cce68ea SC |
242 | m_eventRef = 0; |
243 | m_release = false; | |
a4848597 | 244 | } |
fb5246be WS |
245 | |
246 | wxMacCarbonEvent( EventRef event , bool release = false ) | |
4f305456 | 247 | { |
6cce68ea SC |
248 | m_eventRef = event; |
249 | m_release = release; | |
6d4c54a7 | 250 | } |
fb5246be WS |
251 | |
252 | wxMacCarbonEvent(UInt32 inClassID,UInt32 inKind,EventTime inWhen = 0 /*now*/,EventAttributes inAttributes=kEventAttributeNone) | |
6d4c54a7 | 253 | { |
6cce68ea SC |
254 | m_eventRef = NULL; |
255 | verify_noerr( MacCreateEvent( NULL , inClassID, inKind,inWhen,inAttributes,&m_eventRef) ); | |
256 | m_release = true; | |
6d4c54a7 | 257 | } |
fb5246be | 258 | |
6d4c54a7 SC |
259 | ~wxMacCarbonEvent() |
260 | { | |
261 | if ( m_release ) | |
6cce68ea | 262 | ReleaseEvent( m_eventRef ); |
4f305456 | 263 | } |
fb5246be WS |
264 | |
265 | OSStatus Create(UInt32 inClassID,UInt32 inKind,EventTime inWhen = 0 /*now*/,EventAttributes inAttributes=kEventAttributeNone) | |
a4848597 | 266 | { |
6cce68ea | 267 | verify( (m_eventRef == NULL) || m_release ); |
a4848597 SC |
268 | if ( m_eventRef && m_release ) |
269 | { | |
6cce68ea SC |
270 | ReleaseEvent( m_eventRef ); |
271 | m_release = false; | |
272 | m_eventRef = NULL; | |
a4848597 | 273 | } |
6cce68ea | 274 | OSStatus err = MacCreateEvent( NULL , inClassID, inKind,inWhen,inAttributes,&m_eventRef); |
a4848597 | 275 | if ( err == noErr ) |
6cce68ea SC |
276 | m_release = true; |
277 | return err; | |
a4848597 | 278 | } |
fb5246be | 279 | |
6cce68ea | 280 | OSStatus GetParameter( EventParamName inName, EventParamType inDesiredType, UInt32 inBufferSize, void * outData); |
fb5246be | 281 | |
4f305456 SC |
282 | template <typename T> OSStatus GetParameter( EventParamName inName, EventParamType type , T *data ) |
283 | { | |
6cce68ea | 284 | return GetParameter( inName, type , sizeof( T ) , data ); |
4f305456 SC |
285 | } |
286 | template <typename T> OSStatus GetParameter( EventParamName inName, T *data ) | |
287 | { | |
6cce68ea | 288 | return GetParameter<T>( inName, wxMacGetEventParamType<T>() , data ); |
4f305456 | 289 | } |
fb5246be | 290 | |
4f305456 SC |
291 | template <typename T> T GetParameter( EventParamName inName ) |
292 | { | |
6cce68ea SC |
293 | T value; |
294 | verify_noerr( GetParameter<T>( inName, &value ) ); | |
295 | return value; | |
4f305456 SC |
296 | } |
297 | template <typename T> T GetParameter( EventParamName inName, EventParamType inDesiredType ) | |
298 | { | |
6cce68ea SC |
299 | T value; |
300 | verify_noerr( GetParameter<T>( inName, inDesiredType , &value ) ); | |
301 | return value; | |
4f305456 | 302 | } |
fb5246be | 303 | |
6cce68ea | 304 | OSStatus SetParameter( EventParamName inName, EventParamType inType, UInt32 inSize, const void * inData); |
6d4c54a7 | 305 | template <typename T> OSStatus SetParameter( EventParamName inName, EventParamType inDesiredType , const T *data ) |
4f305456 | 306 | { |
6cce68ea | 307 | return SetParameter( inName, inDesiredType , sizeof( T ) , data ); |
2aefa0ef | 308 | } |
6d4c54a7 | 309 | template <typename T> OSStatus SetParameter( EventParamName inName, EventParamType inDesiredType , const T& data ) |
2aefa0ef | 310 | { |
6cce68ea | 311 | return SetParameter<T>( inName, inDesiredType , &data ); |
4f305456 | 312 | } |
6d4c54a7 | 313 | template <typename T> OSStatus SetParameter( EventParamName inName, const T *data ) |
4f305456 | 314 | { |
6cce68ea | 315 | return SetParameter<T>( inName, wxMacGetEventParamType<T>() , data ); |
4f305456 | 316 | } |
6d4c54a7 | 317 | template <typename T> OSStatus SetParameter( EventParamName inName, const T& data ) |
2aefa0ef | 318 | { |
6cce68ea | 319 | return SetParameter<T>( inName, wxMacGetEventParamType<T>() , &data ); |
2aefa0ef | 320 | } |
86d8b744 SC |
321 | UInt32 GetClass() |
322 | { | |
6cce68ea | 323 | return ::GetEventClass( m_eventRef ); |
86d8b744 | 324 | } |
41b53169 | 325 | UInt32 GetKind() |
4f305456 | 326 | { |
6cce68ea | 327 | return ::GetEventKind( m_eventRef ); |
4f305456 SC |
328 | } |
329 | EventTime GetTime() | |
330 | { | |
6cce68ea | 331 | return ::GetEventTime( m_eventRef ); |
4f305456 SC |
332 | } |
333 | UInt32 GetTicks() | |
334 | { | |
6cce68ea | 335 | return EventTimeToTicks( GetTime() ); |
4f305456 | 336 | } |
2c01d335 | 337 | OSStatus SetCurrentTime( ) |
a4848597 | 338 | { |
6cce68ea | 339 | return ::SetEventTime( m_eventRef , GetCurrentEventTime() ); |
2c01d335 | 340 | } |
fb5246be | 341 | OSStatus SetTime( EventTime when ) |
2c01d335 | 342 | { |
6cce68ea | 343 | return ::SetEventTime( m_eventRef , when ); |
a4848597 SC |
344 | } |
345 | operator EventRef () { return m_eventRef; } | |
fb5246be | 346 | |
6cce68ea | 347 | bool IsValid() { return m_eventRef != 0; } |
4f305456 | 348 | protected : |
6cce68ea SC |
349 | EventRef m_eventRef; |
350 | bool m_release; | |
351 | }; | |
4f305456 | 352 | |
3feeb1e1 SC |
353 | // |
354 | // helper class for allocating and deallocating Universal Proc Ptrs | |
355 | // | |
356 | ||
357 | template <typename procType, typename uppType , uppType (*newUPP)(procType) , void (*disposeUPP)(uppType) > class wxMacUPP | |
358 | { | |
359 | public : | |
360 | wxMacUPP( procType proc ) | |
361 | { | |
6cce68ea SC |
362 | m_upp = NULL; |
363 | m_upp = (*newUPP)( NULL ); | |
3feeb1e1 SC |
364 | } |
365 | ~wxMacUPP() | |
366 | { | |
367 | if ( m_upp ) | |
6cce68ea | 368 | disposeUPP( m_upp ); |
3feeb1e1 | 369 | } |
6cce68ea | 370 | operator uppType() { return m_upp; } |
3feeb1e1 | 371 | private : |
6cce68ea SC |
372 | uppType m_upp; |
373 | }; | |
3feeb1e1 | 374 | |
6cce68ea | 375 | typedef wxMacUPP<NMProcPtr,NMUPP,NewNMUPP,DisposeNMUPP> wxMacNMUPP; |
3feeb1e1 | 376 | |
18b94824 SC |
377 | template <typename refType> class wxMacCFRefHolder |
378 | { | |
379 | public : | |
380 | wxMacCFRefHolder() | |
fb5246be | 381 | : m_ref(NULL) , m_release(false) |
18b94824 SC |
382 | { |
383 | } | |
fb5246be WS |
384 | |
385 | wxMacCFRefHolder( refType ref , bool release = true ) | |
18b94824 SC |
386 | : m_ref(ref) , m_release(release) |
387 | { | |
388 | } | |
fb5246be | 389 | |
18b94824 SC |
390 | ~wxMacCFRefHolder() |
391 | { | |
6cce68ea | 392 | Release(); |
18b94824 | 393 | } |
fb5246be | 394 | |
18b94824 SC |
395 | void Release() |
396 | { | |
397 | if ( m_release && m_ref != NULL ) | |
6cce68ea SC |
398 | CFRelease( m_ref ); |
399 | m_ref = NULL; | |
18b94824 | 400 | } |
fb5246be | 401 | |
18b94824 SC |
402 | refType Detach() |
403 | { | |
6cce68ea SC |
404 | refType val = m_ref; |
405 | m_release = false; | |
406 | m_ref = NULL; | |
407 | return val; | |
18b94824 | 408 | } |
fb5246be | 409 | |
18b94824 SC |
410 | void Set( refType ref , bool release = true ) |
411 | { | |
6cce68ea SC |
412 | Release(); |
413 | m_release = release; | |
414 | m_ref = ref; | |
18b94824 | 415 | } |
fb5246be | 416 | |
18b94824 | 417 | operator refType () const { return m_ref; } |
fb5246be | 418 | |
18b94824 | 419 | private : |
6cce68ea SC |
420 | refType m_ref; |
421 | bool m_release; | |
fb5246be | 422 | |
18b94824 | 423 | DECLARE_NO_COPY_CLASS( wxMacCFRefHolder ) |
6cce68ea | 424 | }; |
18b94824 | 425 | |
885fb02f | 426 | #if wxUSE_GUI |
6cce68ea | 427 | |
20b69855 | 428 | /* |
6cce68ea SC |
429 | GWorldPtr wxMacCreateGWorld( int width , int height , int depth ); |
430 | void wxMacDestroyGWorld( GWorldPtr gw ); | |
431 | PicHandle wxMacCreatePict( GWorldPtr gw , GWorldPtr mask = NULL ); | |
432 | CIconHandle wxMacCreateCIcon(GWorldPtr image , GWorldPtr mask , short dstDepth , short iconSize ); | |
433 | void wxMacSetColorTableEntry( CTabHandle newColors , int index , int red , int green , int blue ); | |
434 | CTabHandle wxMacCreateColorTable( int numColors ); | |
20b69855 | 435 | */ |
6cce68ea SC |
436 | void wxMacCreateBitmapButton( ControlButtonContentInfo*info , const wxBitmap& bitmap , int forceType = 0 ); |
437 | void wxMacReleaseBitmapButton( ControlButtonContentInfo*info ); | |
885fb02f SC |
438 | |
439 | #define MAC_WXCOLORREF(a) (*((RGBColor*)&(a))) | |
440 | #define MAC_WXHBITMAP(a) (GWorldPtr(a)) | |
441 | #define MAC_WXHMETAFILE(a) (PicHandle(a)) | |
20b69855 | 442 | #define MAC_WXHICON(a) (IconRef(a)) |
885fb02f SC |
443 | #define MAC_WXHCURSOR(a) (CursHandle(a)) |
444 | #define MAC_WXHRGN(a) (RgnHandle(a)) | |
445 | #define MAC_WXHWND(a) (WindowPtr(a)) | |
446 | #define MAC_WXRECPTR(a) ((Rect*)a) | |
447 | #define MAC_WXPOINTPTR(a) ((Point*)a) | |
448 | #define MAC_WXHMENU(a) ((MenuHandle)a) | |
449 | ||
450 | struct wxOpaqueWindowRef | |
451 | { | |
6cce68ea SC |
452 | wxOpaqueWindowRef( WindowRef ref ) { m_data = ref; } |
453 | operator WindowRef() { return m_data; } | |
885fb02f | 454 | private : |
6cce68ea SC |
455 | WindowRef m_data; |
456 | }; | |
885fb02f | 457 | |
6cce68ea SC |
458 | void wxMacRectToNative( const wxRect *wx , Rect *n ); |
459 | void wxMacNativeToRect( const Rect *n , wxRect* wx ); | |
460 | void wxMacPointToNative( const wxPoint* wx , Point *n ); | |
461 | void wxMacNativeToPoint( const Point *n , wxPoint* wx ); | |
285b5ce0 | 462 | |
6cce68ea SC |
463 | wxWindow * wxFindControlFromMacControl(ControlRef inControl ); |
464 | wxTopLevelWindowMac* wxFindWinFromMacWindow( WindowRef inWindow ); | |
465 | wxMenu* wxFindMenuFromMacMenu(MenuRef inMenuRef); | |
885fb02f | 466 | |
6cce68ea SC |
467 | int wxMacCommandToId( UInt32 macCommandId ); |
468 | UInt32 wxIdToMacCommand( int wxId ); | |
469 | wxMenu* wxFindMenuFromMacCommand( const HICommand &macCommandId , wxMenuItem* &item ); | |
1628261e | 470 | |
6cce68ea SC |
471 | extern wxWindow* g_MacLastWindow; |
472 | pascal OSStatus wxMacTopLevelMouseEventHandler( EventHandlerCallRef handler , EventRef event , void *data ); | |
473 | Rect wxMacGetBoundsForControl( wxWindow* window , const wxPoint& pos , const wxSize &size , bool adjustForOrigin = true ); | |
885fb02f | 474 | |
6cce68ea | 475 | ControlActionUPP GetwxMacLiveScrollbarActionProc(); |
285b5ce0 | 476 | |
86d8b744 SC |
477 | class wxMacControl |
478 | { | |
479 | public : | |
6cce68ea SC |
480 | wxMacControl( wxWindow* peer , bool isRootControl = false ); |
481 | wxMacControl( wxWindow* peer , ControlRef control ); | |
482 | wxMacControl( wxWindow* peer , WXWidget control ); | |
483 | virtual ~wxMacControl(); | |
484 | ||
485 | void Init(); | |
fb5246be | 486 | |
6cce68ea | 487 | virtual void Dispose(); |
fb5246be | 488 | |
6cce68ea | 489 | bool Ok() const { return GetControlRef() != NULL; } |
5ca0d812 | 490 | |
6cce68ea SC |
491 | void SetReferenceInNativeControl(); |
492 | static wxMacControl* GetReferenceFromNativeControl(ControlRef control); | |
5ca0d812 | 493 | |
fb5246be | 494 | virtual ControlRef * GetControlRefAddr() { return &m_controlRef; } |
6cce68ea | 495 | virtual ControlRef GetControlRef() const { return m_controlRef; } |
fb5246be | 496 | |
6cce68ea | 497 | virtual void SetReference( SInt32 data ); |
5ca0d812 | 498 | /* |
6cce68ea | 499 | void operator= (ControlRef c) { m_controlRef = c; } |
fb5246be WS |
500 | operator ControlRef () { return m_controlRef; } |
501 | operator ControlRef * () { return &m_controlRef; } | |
5ca0d812 | 502 | */ |
2837271a SC |
503 | // accessing data and values |
504 | ||
6cce68ea SC |
505 | virtual OSStatus SetData( ControlPartCode inPartCode , ResType inTag , Size inSize , const void * inData ); |
506 | virtual OSStatus GetData( ControlPartCode inPartCode , ResType inTag , Size inBufferSize , void * inOutBuffer , Size * outActualSize ) const; | |
507 | virtual OSStatus GetDataSize( ControlPartCode inPartCode , ResType inTag , Size * outActualSize ) const; | |
508 | virtual OSStatus SendEvent( EventRef ref , OptionBits inOptions = 0 ); | |
509 | virtual OSStatus SendHICommand( HICommand &command , OptionBits inOptions = 0 ); | |
2837271a | 510 | |
6cce68ea | 511 | virtual OSStatus SendHICommand( UInt32 commandID , OptionBits inOptions = 0 ); |
2837271a | 512 | |
6cce68ea SC |
513 | virtual SInt32 GetValue() const; |
514 | virtual SInt32 GetMaximum() const; | |
515 | virtual SInt32 GetMinimum() const; | |
fb5246be | 516 | |
6cce68ea SC |
517 | virtual void SetValue( SInt32 v ); |
518 | virtual void SetMinimum( SInt32 v ); | |
519 | virtual void SetMaximum( SInt32 v ); | |
2837271a | 520 | |
6cce68ea SC |
521 | virtual void SetValueAndRange( SInt32 value , SInt32 minimum , SInt32 maximum ); |
522 | virtual void SetRange( SInt32 minimum , SInt32 maximum ); | |
fb5246be | 523 | |
6cce68ea SC |
524 | virtual OSStatus SetFocus( ControlFocusPart focusPart ); |
525 | virtual bool HasFocus() const; | |
526 | virtual bool NeedsFocusRect() const; | |
527 | virtual void SetNeedsFocusRect( bool needs ); | |
fb5246be | 528 | |
2837271a SC |
529 | // templated helpers |
530 | ||
0fc3bc3b | 531 | Size GetDataSize( ControlPartCode inPartCode , ResType inTag ) const |
86d8b744 | 532 | { |
6cce68ea SC |
533 | Size sz; |
534 | verify_noerr( GetDataSize( inPartCode , inTag , &sz ) ); | |
535 | return sz; | |
86d8b744 | 536 | } |
6d4c54a7 | 537 | template <typename T> OSStatus SetData( ControlPartCode inPartCode , ResType inTag , const T *data ) |
86d8b744 | 538 | { |
6cce68ea | 539 | return SetData( inPartCode , inTag , sizeof( T ) , data ); |
86d8b744 | 540 | } |
6d4c54a7 | 541 | template <typename T> OSStatus SetData( ControlPartCode inPartCode , ResType inTag , const T& data ) |
86d8b744 | 542 | { |
6cce68ea | 543 | return SetData( inPartCode , inTag , sizeof( T ) , &data ); |
86d8b744 | 544 | } |
fbb7ee81 SC |
545 | template <typename T> OSStatus SetData( ResType inTag , const T *data ) |
546 | { | |
6cce68ea | 547 | return SetData( kControlEntireControl , inTag , sizeof( T ) , data ); |
fbb7ee81 SC |
548 | } |
549 | template <typename T> OSStatus SetData( ResType inTag , const T& data ) | |
550 | { | |
6cce68ea | 551 | return SetData( kControlEntireControl , inTag , sizeof( T ) , &data ); |
fbb7ee81 | 552 | } |
0fc3bc3b | 553 | template <typename T> OSStatus GetData( ControlPartCode inPartCode , ResType inTag , T *data ) const |
86d8b744 | 554 | { |
6cce68ea SC |
555 | Size dummy; |
556 | return GetData( inPartCode , inTag , sizeof( T ) , data , &dummy ); | |
86d8b744 | 557 | } |
0fc3bc3b | 558 | template <typename T> T GetData( ControlPartCode inPartCode , ResType inTag ) const |
86d8b744 | 559 | { |
6cce68ea SC |
560 | T value; |
561 | OSStatus err = GetData<T>( inPartCode , inTag , &value ); | |
725566ca VZ |
562 | |
563 | wxASSERT_MSG( err == noErr, | |
564 | wxString::Format(wxT("GetData Failed for Part [%i] and Tag [%i]"), | |
565 | inPartCode, (int)inTag) ); | |
6cce68ea | 566 | return value; |
86d8b744 | 567 | } |
fbb7ee81 SC |
568 | template <typename T> OSStatus GetData( ResType inTag , T *data ) const |
569 | { | |
6cce68ea SC |
570 | Size dummy; |
571 | return GetData( kControlEntireControl , inTag , sizeof( T ) , data , &dummy ); | |
fbb7ee81 SC |
572 | } |
573 | template <typename T> T GetData( ResType inTag ) const | |
574 | { | |
6cce68ea | 575 | return GetData<T>( kControlEntireControl , inTag ); |
fbb7ee81 | 576 | } |
725566ca | 577 | |
6d4c54a7 | 578 | // Flash the control for the specified amount of time |
6cce68ea | 579 | virtual void Flash( ControlPartCode part , UInt32 ticks = 8 ); |
89a66f11 | 580 | |
6cce68ea SC |
581 | virtual void VisibilityChanged( bool shown ); |
582 | virtual void SuperChangedPosition(); | |
89a66f11 SC |
583 | |
584 | ||
6cce68ea SC |
585 | virtual void SetFont( const wxFont & font , const wxColour& foreground , long windowStyle ); |
586 | virtual void SetBackground( const wxBrush &brush ); | |
587 | virtual ControlPartCode HandleKey( SInt16 keyCode, SInt16 charCode, EventModifiers modifiers ); | |
588 | void SetActionProc( ControlActionUPP actionProc ); | |
589 | void SetViewSize( SInt32 viewSize ); | |
590 | SInt32 GetViewSize() const; | |
fb5246be | 591 | |
6cce68ea SC |
592 | virtual bool IsVisible() const; |
593 | virtual void SetVisibility( bool visible , bool redraw ); | |
594 | virtual bool IsEnabled() const; | |
595 | virtual bool IsActive() const; | |
596 | virtual void Enable( bool enable ); | |
fb5246be | 597 | |
5ca0d812 | 598 | // invalidates this control and all children |
6cce68ea SC |
599 | virtual void InvalidateWithChildren(); |
600 | virtual void SetDrawingEnabled( bool enable ); | |
b905d6cc | 601 | #ifdef __WXMAC_OSX__ |
6cce68ea | 602 | virtual bool GetNeedsDisplay() const; |
b905d6cc | 603 | #endif |
285b5ce0 | 604 | // where is in native window relative coordinates |
6cce68ea | 605 | virtual void SetNeedsDisplay( RgnHandle where ); |
285b5ce0 | 606 | // where is in native window relative coordinates |
6cce68ea | 607 | virtual void SetNeedsDisplay( Rect* where = NULL ); |
285b5ce0 | 608 | |
fb5246be | 609 | // if rect = NULL, entire view |
6cce68ea | 610 | virtual void ScrollRect( wxRect *rect , int dx , int dy ); |
5ca0d812 | 611 | |
285b5ce0 | 612 | // in native parent window relative coordinates |
6cce68ea | 613 | virtual void GetRect( Rect *r ); |
285b5ce0 SC |
614 | |
615 | // in native parent window relative coordinates | |
6cce68ea | 616 | virtual void SetRect( Rect *r ); |
285b5ce0 | 617 | |
6cce68ea SC |
618 | virtual void GetRectInWindowCoords( Rect *r ); |
619 | virtual void GetBestRect( Rect *r ); | |
620 | virtual void SetLabel( const wxString &title ); | |
5ca0d812 | 621 | // converts from Toplevel-Content relative to local |
6cce68ea | 622 | static void Convert( wxPoint *pt , wxMacControl *convert , wxMacControl *to ); |
fb5246be | 623 | |
6cce68ea SC |
624 | virtual void GetFeatures( UInt32 *features ); |
625 | virtual OSStatus GetRegion( ControlPartCode partCode , RgnHandle region ); | |
626 | virtual OSStatus SetZOrder( bool above , wxMacControl* other ); | |
725566ca | 627 | |
6cce68ea SC |
628 | bool IsCompositing() { return m_isCompositing; } |
629 | bool IsRootControl() { return m_isRootControl; } | |
725566ca | 630 | |
6cce68ea SC |
631 | wxWindow* GetPeer() const |
632 | { | |
633 | return m_peer; | |
634 | } | |
ba5b8a68 SC |
635 | |
636 | // to be moved into a tab control class | |
637 | ||
6cce68ea SC |
638 | virtual OSStatus SetTabEnabled( SInt16 tabNo , bool enable ); |
639 | protected : | |
640 | ControlRef m_controlRef; | |
641 | wxFont m_font; | |
642 | long m_windowStyle; | |
643 | wxWindow* m_peer; | |
644 | bool m_needsFocusRect; | |
645 | bool m_isCompositing; | |
646 | bool m_isRootControl; | |
647 | }; | |
648 | ||
649 | // ============================================================================ | |
650 | // DataBrowser Wrapper | |
651 | // ============================================================================ | |
652 | // | |
653 | // basing on DataBrowserItemIDs | |
654 | // | |
655 | ||
656 | class wxMacDataBrowserControl : public wxMacControl | |
657 | { | |
658 | public : | |
659 | wxMacDataBrowserControl( wxWindow* peer, const wxPoint& pos, const wxSize& size, long style); | |
660 | ||
661 | OSStatus SetCallbacks( const DataBrowserCallbacks *callbacks ); | |
725566ca | 662 | |
6cce68ea SC |
663 | OSStatus GetItemCount( DataBrowserItemID container, |
664 | Boolean recurse, | |
665 | DataBrowserItemState state, | |
666 | UInt32 *numItems) const; | |
725566ca | 667 | |
6cce68ea SC |
668 | OSStatus GetItems( DataBrowserItemID container, |
669 | Boolean recurse, | |
670 | DataBrowserItemState state, | |
671 | Handle items) const; | |
725566ca | 672 | |
6cce68ea SC |
673 | |
674 | OSStatus AddColumn( DataBrowserListViewColumnDesc *columnDesc, | |
675 | DataBrowserTableViewColumnIndex position ); | |
725566ca | 676 | |
6cce68ea | 677 | OSStatus AutoSizeColumns(); |
725566ca | 678 | |
6cce68ea SC |
679 | OSStatus SetHasScrollBars( bool horiz, bool vert ); |
680 | OSStatus SetHiliteStyle( DataBrowserTableViewHiliteStyle hiliteStyle ); | |
725566ca | 681 | |
6cce68ea SC |
682 | OSStatus SetHeaderButtonHeight( UInt16 height ); |
683 | OSStatus GetHeaderButtonHeight( UInt16 *height ); | |
684 | ||
685 | OSStatus UpdateItems( DataBrowserItemID container, UInt32 numItems, | |
686 | const DataBrowserItemID *items, | |
687 | DataBrowserPropertyID preSortProperty, | |
688 | DataBrowserPropertyID propertyID ) const; | |
725566ca | 689 | |
6cce68ea SC |
690 | OSStatus AddItems( DataBrowserItemID container, UInt32 numItems, |
691 | const DataBrowserItemID *items, | |
692 | DataBrowserPropertyID preSortProperty ); | |
693 | OSStatus RemoveItems( DataBrowserItemID container, UInt32 numItems, | |
694 | const DataBrowserItemID *items, | |
695 | DataBrowserPropertyID preSortProperty ); | |
696 | OSStatus RevealItem( DataBrowserItemID item, | |
697 | DataBrowserPropertyID propertyID, | |
698 | DataBrowserRevealOptions options ) const; | |
699 | ||
700 | OSStatus SetSelectionFlags( DataBrowserSelectionFlags ); | |
701 | OSStatus GetSelectionAnchor( DataBrowserItemID *first, DataBrowserItemID *last ) const; | |
702 | bool IsItemSelected( DataBrowserItemID item ) const; | |
703 | OSStatus SetSelectedItems( UInt32 numItems, | |
704 | const DataBrowserItemID *items, | |
705 | DataBrowserSetOption operation ); | |
706 | ||
725566ca | 707 | OSStatus GetItemID( DataBrowserTableViewRowIndex row, |
6cce68ea | 708 | DataBrowserItemID * item ) const; |
725566ca | 709 | OSStatus GetItemRow( DataBrowserItemID item, |
6cce68ea | 710 | DataBrowserTableViewRowIndex * row ) const; |
725566ca | 711 | |
6cce68ea SC |
712 | OSStatus SetDefaultRowHeight( UInt16 height ); |
713 | OSStatus GetDefaultRowHeight( UInt16 * height ) const; | |
725566ca | 714 | |
6cce68ea SC |
715 | OSStatus SetRowHeight( DataBrowserItemID item , UInt16 height); |
716 | OSStatus GetRowHeight( DataBrowserItemID item , UInt16 *height) const; | |
725566ca | 717 | |
6cce68ea SC |
718 | OSStatus GetColumnWidth( DataBrowserPropertyID column , UInt16 *width ) const; |
719 | OSStatus SetColumnWidth( DataBrowserPropertyID column , UInt16 width ); | |
725566ca | 720 | |
6cce68ea SC |
721 | OSStatus GetDefaultColumnWidth( UInt16 *width ) const; |
722 | OSStatus SetDefaultColumnWidth( UInt16 width ); | |
725566ca | 723 | |
6cce68ea SC |
724 | OSStatus GetColumnCount( UInt32* numColumns) const; |
725 | ||
726 | OSStatus GetColumnPosition( DataBrowserPropertyID column, UInt32 *position) const; | |
727 | OSStatus SetColumnPosition( DataBrowserPropertyID column, UInt32 position); | |
725566ca | 728 | |
6cce68ea SC |
729 | OSStatus GetScrollPosition( UInt32 *top , UInt32 *left ) const; |
730 | OSStatus SetScrollPosition( UInt32 top , UInt32 left ); | |
725566ca | 731 | |
6cce68ea SC |
732 | OSStatus GetSortProperty( DataBrowserPropertyID *column ) const; |
733 | OSStatus SetSortProperty( DataBrowserPropertyID column ); | |
725566ca | 734 | |
6cce68ea SC |
735 | OSStatus GetSortOrder( DataBrowserSortOrder *order ) const; |
736 | OSStatus SetSortOrder( DataBrowserSortOrder order ); | |
725566ca | 737 | |
6cce68ea SC |
738 | OSStatus GetPropertyFlags( DataBrowserPropertyID property, DataBrowserPropertyFlags *flags ) const; |
739 | OSStatus SetPropertyFlags( DataBrowserPropertyID property, DataBrowserPropertyFlags flags ); | |
725566ca | 740 | |
6cce68ea SC |
741 | OSStatus GetHeaderDesc( DataBrowserPropertyID property, DataBrowserListViewHeaderDesc *desc ) const; |
742 | OSStatus SetHeaderDesc( DataBrowserPropertyID property, DataBrowserListViewHeaderDesc *desc ); | |
725566ca | 743 | |
6cce68ea | 744 | OSStatus SetDisclosureColumn( DataBrowserPropertyID property , Boolean expandableRows ); |
86d8b744 | 745 | protected : |
725566ca | 746 | |
6cce68ea SC |
747 | static pascal void DataBrowserItemNotificationProc( |
748 | ControlRef browser, | |
749 | DataBrowserItemID itemID, | |
750 | DataBrowserItemNotification message, | |
751 | DataBrowserItemDataRef itemData ); | |
752 | ||
753 | virtual void ItemNotification( | |
754 | DataBrowserItemID itemID, | |
755 | DataBrowserItemNotification message, | |
756 | DataBrowserItemDataRef itemData) = 0; | |
757 | ||
758 | static pascal OSStatus DataBrowserGetSetItemDataProc( | |
759 | ControlRef browser, | |
760 | DataBrowserItemID itemID, | |
761 | DataBrowserPropertyID property, | |
762 | DataBrowserItemDataRef itemData, | |
763 | Boolean changeValue ); | |
764 | ||
765 | virtual OSStatus GetSetItemData( | |
766 | DataBrowserItemID itemID, | |
767 | DataBrowserPropertyID property, | |
768 | DataBrowserItemDataRef itemData, | |
769 | Boolean changeValue ) = 0; | |
770 | ||
771 | static pascal Boolean DataBrowserCompareProc( | |
725566ca VZ |
772 | ControlRef browser, |
773 | DataBrowserItemID itemOneID, | |
774 | DataBrowserItemID itemTwoID, | |
6cce68ea | 775 | DataBrowserPropertyID sortProperty); |
725566ca VZ |
776 | |
777 | virtual Boolean CompareItems(DataBrowserItemID itemOneID, | |
778 | DataBrowserItemID itemTwoID, | |
6cce68ea SC |
779 | DataBrowserPropertyID sortProperty) = 0; |
780 | }; | |
781 | ||
782 | // ============================================================================ | |
725566ca | 783 | // Higher-level Databrowser |
6cce68ea SC |
784 | // ============================================================================ |
785 | // | |
786 | // basing on data item objects | |
787 | // | |
788 | ||
789 | // forward decl | |
790 | ||
791 | class wxMacDataItemBrowserControl; | |
792 | ||
793 | // base class for databrowser items | |
794 | ||
795 | class wxMacDataItem | |
796 | { | |
797 | public : | |
798 | wxMacDataItem(); | |
799 | virtual ~wxMacDataItem(); | |
725566ca VZ |
800 | |
801 | virtual bool IsLessThan(wxMacDataItemBrowserControl *owner , | |
802 | const wxMacDataItem*, | |
6cce68ea | 803 | DataBrowserPropertyID property) const; |
725566ca | 804 | |
6cce68ea | 805 | // returns true if access was successful, otherwise false |
725566ca | 806 | virtual OSStatus GetSetData(wxMacDataItemBrowserControl *owner , |
6cce68ea SC |
807 | DataBrowserPropertyID property, |
808 | DataBrowserItemDataRef itemData, | |
809 | bool changeValue ); | |
810 | ||
725566ca | 811 | virtual void Notification(wxMacDataItemBrowserControl *owner , |
6cce68ea SC |
812 | DataBrowserItemNotification message, |
813 | DataBrowserItemDataRef itemData ) const; | |
814 | }; | |
815 | ||
816 | typedef wxMacDataItem* wxMacDataItemPtr; | |
817 | const wxMacDataItemPtr wxMacDataBrowserRootContainer = NULL; | |
818 | ||
819 | WX_DEFINE_USER_EXPORTED_ARRAY_PTR(wxMacDataItemPtr, wxArrayMacDataItemPtr, class WXDLLIMPEXP_CORE); | |
820 | ||
821 | class wxMacDataItemBrowserControl : public wxMacDataBrowserControl | |
822 | { | |
823 | public : | |
824 | wxMacDataItemBrowserControl( wxWindow* peer , const wxPoint& pos, const wxSize& size, long style); | |
725566ca | 825 | |
6cce68ea | 826 | unsigned int GetItemCount(const wxMacDataItem* container, bool recurse , DataBrowserItemState state) const; |
725566ca | 827 | void GetItems(const wxMacDataItem* container, bool recurse , |
6cce68ea | 828 | DataBrowserItemState state, wxArrayMacDataItemPtr &items ) const; |
725566ca | 829 | |
6cce68ea SC |
830 | unsigned int GetLineFromItem(const wxMacDataItem *item) const; |
831 | wxMacDataItem * GetItemFromLine(unsigned int n) const; | |
725566ca VZ |
832 | |
833 | void UpdateItem(const wxMacDataItem *container, const wxMacDataItem *item, | |
6cce68ea | 834 | DataBrowserPropertyID property) const; |
725566ca | 835 | void UpdateItems(const wxMacDataItem *container, wxArrayMacDataItemPtr &items, |
6cce68ea | 836 | DataBrowserPropertyID property) const; |
725566ca | 837 | |
6cce68ea SC |
838 | void AddItem(wxMacDataItem *container, wxMacDataItem *item); |
839 | void AddItems(wxMacDataItem *container, wxArrayMacDataItemPtr &items ); | |
840 | ||
841 | void RemoveAllItems(wxMacDataItem *container); | |
842 | void RemoveItem(wxMacDataItem *container, wxMacDataItem* item); | |
843 | void RemoveItems(wxMacDataItem *container, wxArrayMacDataItemPtr &items); | |
725566ca | 844 | |
6cce68ea SC |
845 | void SetSelectedItem( wxMacDataItem* item , DataBrowserSetOption option); |
846 | void SetSelectedItems( wxArrayMacDataItemPtr &items , DataBrowserSetOption option); | |
847 | void SetSelectedAllItems( DataBrowserSetOption option); | |
848 | Boolean IsItemSelected( const wxMacDataItem* item) const; | |
725566ca | 849 | |
6cce68ea | 850 | void RevealItem( wxMacDataItem* item, DataBrowserRevealOptions options); |
725566ca | 851 | |
6cce68ea | 852 | void GetSelectionAnchor( wxMacDataItemPtr* first , wxMacDataItemPtr* last) const; |
725566ca | 853 | |
6cce68ea | 854 | // item aware methods, to be used in subclasses |
725566ca VZ |
855 | |
856 | virtual Boolean CompareItems(const wxMacDataItem* itemOneID, | |
857 | const wxMacDataItem* itemTwoID, | |
6cce68ea SC |
858 | DataBrowserPropertyID sortProperty); |
859 | ||
860 | virtual OSStatus GetSetItemData(wxMacDataItem* itemID, | |
861 | DataBrowserPropertyID property, | |
862 | DataBrowserItemDataRef itemData, | |
863 | Boolean changeValue ); | |
864 | ||
865 | virtual void ItemNotification( | |
866 | const wxMacDataItem* itemID, | |
867 | DataBrowserItemNotification message, | |
868 | DataBrowserItemDataRef itemData); | |
8b64a7e2 PC |
869 | |
870 | // as we are getting the same events for human and API selection we have to suppress | |
871 | // events in the latter case, since this will be used from many subclasses we keep it here | |
872 | ||
873 | bool IsSelectionSuppressed() const { return m_suppressSelection; } | |
874 | bool SuppressSelection( bool suppress ); | |
875 | ||
876 | protected: | |
6cce68ea | 877 | // ID aware base methods, should be 'final' ie not changed in subclasses |
725566ca VZ |
878 | |
879 | virtual Boolean CompareItems(DataBrowserItemID itemOneID, | |
880 | DataBrowserItemID itemTwoID, | |
6cce68ea SC |
881 | DataBrowserPropertyID sortProperty); |
882 | ||
883 | virtual OSStatus GetSetItemData(DataBrowserItemID itemID, | |
884 | DataBrowserPropertyID property, | |
885 | DataBrowserItemDataRef itemData, | |
886 | Boolean changeValue ); | |
887 | ||
888 | virtual void ItemNotification( | |
889 | DataBrowserItemID itemID, | |
890 | DataBrowserItemNotification message, | |
891 | DataBrowserItemDataRef itemData); | |
892 | ||
6cce68ea SC |
893 | private : |
894 | ||
895 | bool m_suppressSelection; | |
896 | }; | |
897 | ||
898 | class wxMacDataItemBrowserSelectionSuppressor | |
899 | { | |
900 | public : | |
901 | wxMacDataItemBrowserSelectionSuppressor(wxMacDataItemBrowserControl *browser); | |
902 | ~wxMacDataItemBrowserSelectionSuppressor(); | |
725566ca | 903 | |
6cce68ea SC |
904 | private : |
905 | ||
906 | bool m_former; | |
907 | wxMacDataItemBrowserControl* m_browser; | |
908 | }; | |
909 | ||
910 | // ============================================================================ | |
911 | // platform listbox implementation | |
912 | // ============================================================================ | |
913 | // | |
914 | // exposed for reuse in wxCheckListBox | |
915 | ||
916 | class wxMacListBoxItem : public wxMacDataItem | |
917 | { | |
918 | public : | |
919 | wxMacListBoxItem(); | |
725566ca | 920 | |
6cce68ea | 921 | virtual ~wxMacListBoxItem(); |
725566ca | 922 | |
6cce68ea SC |
923 | void SetLabel( const wxString& str); |
924 | const wxString& GetLabel() const; | |
725566ca VZ |
925 | |
926 | virtual bool IsLessThan(wxMacDataItemBrowserControl *owner , | |
927 | const wxMacDataItem* rhs, | |
6cce68ea SC |
928 | DataBrowserPropertyID sortProperty) const; |
929 | ||
930 | virtual OSStatus GetSetData( wxMacDataItemBrowserControl *owner , | |
931 | DataBrowserPropertyID property, | |
932 | DataBrowserItemDataRef itemData, | |
933 | bool changeValue ); | |
934 | ||
725566ca | 935 | virtual void Notification(wxMacDataItemBrowserControl *owner , |
6cce68ea SC |
936 | DataBrowserItemNotification message, |
937 | DataBrowserItemDataRef itemData ) const; | |
725566ca | 938 | |
6cce68ea SC |
939 | void SetOrder( SInt32 order ); |
940 | SInt32 GetOrder() const; | |
725566ca | 941 | |
6cce68ea SC |
942 | void SetData( void* data); |
943 | void* GetData() const; | |
944 | ||
945 | private : | |
946 | wxString m_label; | |
947 | wxMacCFStringHolder m_cfLabel; | |
948 | void * m_data; | |
949 | SInt32 m_order; | |
950 | }; | |
951 | ||
952 | class wxMacDataBrowserListControl : public wxMacDataItemBrowserControl , public wxMacListControl | |
953 | { | |
954 | public: | |
955 | wxMacDataBrowserListControl( wxListBox *peer, const wxPoint& pos, const wxSize& size, long style ); | |
956 | ~wxMacDataBrowserListControl(); | |
957 | ||
958 | // create a list item (can be a subclass of wxMacListBoxItem) | |
959 | ||
960 | virtual wxMacListBoxItem* CreateItem(); | |
961 | ||
962 | // add and remove | |
725566ca | 963 | |
6cce68ea SC |
964 | void MacDelete( unsigned int n ); |
965 | void MacInsert( unsigned int n, const wxString& item ); | |
966 | void MacInsert( unsigned int n, const wxArrayString& items ); | |
967 | int MacAppend( const wxString& item ); | |
968 | void MacClear(); | |
969 | ||
970 | // selecting | |
725566ca | 971 | |
6cce68ea SC |
972 | void MacDeselectAll(); |
973 | void MacSetSelection( unsigned int n, bool select ); | |
974 | int MacGetSelection() const; | |
975 | int MacGetSelections( wxArrayInt& aSelections ) const; | |
976 | bool MacIsSelected( unsigned int n ) const; | |
977 | ||
978 | // display | |
979 | ||
980 | void MacScrollTo( unsigned int n ); | |
981 | ||
982 | // accessing content | |
725566ca | 983 | |
6cce68ea SC |
984 | void MacSetString( unsigned int n, const wxString& item ); |
985 | void MacSetClientData( unsigned int n, void * data); | |
986 | wxString MacGetString( unsigned int n) const; | |
987 | void * MacGetClientData( unsigned int) const; | |
988 | unsigned int MacGetCount() const; | |
989 | ||
990 | // client data | |
991 | ||
992 | wxClientDataType GetClientDataType() const; | |
993 | void SetClientDataType(wxClientDataType clientDataItemsType); | |
994 | ||
995 | // pointing back | |
996 | ||
997 | wxListBox * GetPeer() const; | |
998 | private : | |
999 | bool m_stringSorted; | |
1000 | wxClientDataType m_clientDataItemsType; | |
1001 | }; | |
1002 | ||
1003 | // ============================================================================ | |
1004 | // graphics implementation | |
1005 | // ============================================================================ | |
86d8b744 | 1006 | |
20b69855 SC |
1007 | #if wxMAC_USE_CORE_GRAPHICS |
1008 | ||
fb5246be | 1009 | class WXDLLEXPORT wxMacCGPath : public wxGraphicPath |
20b69855 SC |
1010 | { |
1011 | DECLARE_NO_COPY_CLASS(wxMacCGPath) | |
1012 | public : | |
6cce68ea SC |
1013 | wxMacCGPath(); |
1014 | ~wxMacCGPath(); | |
fb5246be | 1015 | |
20b69855 | 1016 | // Starts a new subpath at |
6cce68ea SC |
1017 | void MoveToPoint( wxCoord x1 , wxCoord y1 ); |
1018 | void AddLineToPoint( wxCoord x1 , wxCoord y1 ); | |
1019 | void AddQuadCurveToPoint( wxCoord cx1, wxCoord cy1, wxCoord x1, wxCoord y1 ); | |
1020 | void AddRectangle( wxCoord x, wxCoord y, wxCoord w, wxCoord h ); | |
1021 | void AddCircle( wxCoord x, wxCoord y , wxCoord r ); | |
fb5246be | 1022 | |
20b69855 | 1023 | // closes the current subpath |
6cce68ea | 1024 | void CloseSubpath(); |
fb5246be | 1025 | |
6cce68ea | 1026 | CGPathRef GetPath() const; |
20b69855 | 1027 | private : |
6cce68ea SC |
1028 | CGMutablePathRef m_path; |
1029 | }; | |
20b69855 SC |
1030 | |
1031 | class WXDLLEXPORT wxMacCGContext : public wxGraphicContext | |
1032 | { | |
1033 | DECLARE_NO_COPY_CLASS(wxMacCGContext) | |
fb5246be | 1034 | |
20b69855 | 1035 | public: |
6cce68ea SC |
1036 | wxMacCGContext( CGrafPtr port ); |
1037 | wxMacCGContext( CGContextRef cgcontext ); | |
1038 | wxMacCGContext(); | |
1039 | ~wxMacCGContext(); | |
1040 | ||
1041 | virtual void Clip( const wxRegion ®ion ); | |
1042 | virtual void StrokePath( const wxGraphicPath *p ); | |
1043 | virtual void DrawPath( const wxGraphicPath *p , int fillStyle = wxWINDING_RULE ); | |
1044 | virtual void FillPath( const wxGraphicPath *p , const wxColor &fillColor , int fillStyle = wxWINDING_RULE ); | |
1045 | ||
1046 | virtual wxGraphicPath* CreatePath(); | |
1047 | virtual void SetPen( const wxPen &pen ) ; | |
1048 | virtual void SetBrush( const wxBrush &brush ); | |
1049 | CGContextRef GetNativeContext(); | |
1050 | void SetNativeContext( CGContextRef cg ); | |
1051 | CGPathDrawingMode GetDrawingMode() const { return m_mode; } | |
20b69855 | 1052 | private: |
6cce68ea SC |
1053 | CGContextRef m_cgContext; |
1054 | CGrafPtr m_qdPort; | |
1055 | CGPathDrawingMode m_mode; | |
1056 | wxPen m_pen; | |
1057 | wxBrush m_brush; | |
1058 | }; | |
20b69855 | 1059 | |
30e77b5c SC |
1060 | #endif // wxMAC_USE_CORE_GRAPHICS |
1061 | ||
1062 | #ifdef __WXMAC_OSX__ | |
1063 | ||
6cce68ea SC |
1064 | CGColorSpaceRef wxMacGetGenericRGBColorSpace(void); |
1065 | void wxMacMemoryBufferReleaseProc(void *info, const void *data, size_t size); | |
20b69855 | 1066 | |
30e77b5c | 1067 | #endif |
20b69855 SC |
1068 | |
1069 | class WXDLLEXPORT wxBitmapRefData: public wxGDIRefData | |
1070 | { | |
1071 | DECLARE_NO_COPY_CLASS(wxBitmapRefData) | |
fb5246be | 1072 | |
20b69855 SC |
1073 | friend class WXDLLEXPORT wxIcon; |
1074 | friend class WXDLLEXPORT wxCursor; | |
1075 | public: | |
1076 | wxBitmapRefData(int width , int height , int depth); | |
1077 | wxBitmapRefData(); | |
1078 | ~wxBitmapRefData(); | |
1079 | ||
6cce68ea SC |
1080 | void Free(); |
1081 | bool Ok() const { return m_ok; } | |
1082 | void SetOk( bool isOk) { m_ok = isOk; } | |
fb5246be | 1083 | |
6cce68ea SC |
1084 | void SetWidth( int width ) { m_width = width; } |
1085 | void SetHeight( int height ) { m_height = height; } | |
1086 | void SetDepth( int depth ) { m_depth = depth; } | |
20b69855 | 1087 | |
6cce68ea SC |
1088 | int GetWidth() const { return m_width; } |
1089 | int GetHeight() const { return m_height; } | |
1090 | int GetDepth() const { return m_depth; } | |
fb5246be | 1091 | |
6cce68ea SC |
1092 | void *GetRawAccess() const; |
1093 | void *BeginRawAccess(); | |
1094 | void EndRawAccess(); | |
20b69855 | 1095 | |
6cce68ea SC |
1096 | bool HasAlpha() const { return m_hasAlpha; } |
1097 | void UseAlpha( bool useAlpha ); | |
20b69855 SC |
1098 | |
1099 | public: | |
1100 | #if wxUSE_PALETTE | |
1101 | wxPalette m_bitmapPalette; | |
1102 | #endif // wxUSE_PALETTE | |
fb5246be | 1103 | |
20b69855 | 1104 | wxMask * m_bitmapMask; // Optional mask |
30e77b5c | 1105 | #ifdef __WXMAC_OSX__ |
6cce68ea | 1106 | CGImageRef CGImageCreate() const; |
71cc158e | 1107 | #endif |
fb5246be | 1108 | |
6d2c830a SC |
1109 | // returns true if the bitmap has a size that |
1110 | // can be natively transferred into a true icon | |
1111 | // if no is returned GetIconRef will still produce | |
1112 | // an icon but it will be generated via a PICT and | |
fb5246be | 1113 | // rescaled to 16 x 16 |
6cce68ea | 1114 | bool HasNativeSize(); |
fb5246be | 1115 | |
6d2c830a SC |
1116 | // caller should increase ref count if needed longer |
1117 | // than the bitmap exists | |
6cce68ea | 1118 | IconRef GetIconRef(); |
fb5246be | 1119 | |
6d2c830a | 1120 | // returns a Pict from the bitmap content |
6cce68ea SC |
1121 | PicHandle GetPictHandle(); |
1122 | GWorldPtr GetHBITMAP(GWorldPtr * mask = NULL ) const; | |
1123 | void UpdateAlphaMask() const; | |
71cc158e | 1124 | |
20b69855 | 1125 | private : |
6cce68ea SC |
1126 | bool Create(int width , int height , int depth); |
1127 | void Init(); | |
20b69855 SC |
1128 | |
1129 | int m_width; | |
1130 | int m_height; | |
6cce68ea | 1131 | int m_bytesPerRow; |
20b69855 SC |
1132 | int m_depth; |
1133 | bool m_hasAlpha; | |
6cce68ea SC |
1134 | wxMemoryBuffer m_memBuf; |
1135 | int m_rawAccessCount; | |
20b69855 | 1136 | bool m_ok; |
30e77b5c | 1137 | #ifdef __WXMAC_OSX__ |
6cce68ea | 1138 | mutable CGImageRef m_cgImageRef; |
71cc158e | 1139 | #endif |
6cce68ea SC |
1140 | IconRef m_iconRef; |
1141 | PicHandle m_pictHandle; | |
20b69855 | 1142 | GWorldPtr m_hBitmap; |
6cce68ea SC |
1143 | GWorldPtr m_hMaskBitmap; |
1144 | wxMemoryBuffer m_maskMemBuf; | |
1145 | int m_maskBytesPerRow; | |
20b69855 SC |
1146 | }; |
1147 | ||
20b69855 SC |
1148 | class WXDLLEXPORT wxIconRefData : public wxGDIRefData |
1149 | { | |
1150 | public: | |
6cce68ea SC |
1151 | wxIconRefData(); |
1152 | wxIconRefData( WXHICON ); | |
20b69855 SC |
1153 | virtual ~wxIconRefData() { Free(); } |
1154 | ||
6cce68ea | 1155 | void Init(); |
20b69855 | 1156 | virtual void Free(); |
ddb08e02 | 1157 | |
6cce68ea SC |
1158 | void SetWidth( int width ) { m_width = width; } |
1159 | void SetHeight( int height ) { m_height = height; } | |
ddb08e02 | 1160 | |
6cce68ea SC |
1161 | int GetWidth() const { return m_width; } |
1162 | int GetHeight() const { return m_height; } | |
ddb08e02 | 1163 | |
6cce68ea | 1164 | WXHICON GetHICON() const { return (WXHICON) m_iconRef; } |
20b69855 | 1165 | private : |
6cce68ea SC |
1166 | IconRef m_iconRef; |
1167 | int m_width; | |
1168 | int m_height; | |
20b69855 SC |
1169 | }; |
1170 | ||
285b5ce0 SC |
1171 | // toplevel.cpp |
1172 | ||
6cce68ea | 1173 | ControlRef wxMacFindControlUnderMouse( wxTopLevelWindowMac* toplevelWindow, const Point& location , WindowRef window , ControlPartCode *outPart ); |
285b5ce0 | 1174 | |
ecf418ad | 1175 | #ifdef WORDS_BIGENDIAN |
725566ca VZ |
1176 | inline Rect* wxMacGetPictureBounds( PicHandle pict , Rect* rect ) |
1177 | { | |
1178 | *rect = (**pict).picFrame; | |
6cce68ea | 1179 | return rect; |
7358f907 SC |
1180 | } |
1181 | #else | |
725566ca VZ |
1182 | inline Rect* wxMacGetPictureBounds( PicHandle pict , Rect* rect ) |
1183 | { | |
6cce68ea | 1184 | return QDGetPictureBounds( pict , rect ); |
7358f907 SC |
1185 | } |
1186 | #endif | |
1187 | ||
8cf73271 SC |
1188 | #endif // wxUSE_GUI |
1189 | ||
285b5ce0 SC |
1190 | #define wxMAC_DEFINE_PROC_GETTER( UPP , x ) \ |
1191 | UPP Get##x() \ | |
1192 | { \ | |
1193 | static UPP sHandler = NULL; \ | |
1194 | if ( sHandler == NULL ) \ | |
1195 | sHandler = New##UPP( x ); \ | |
1196 | return sHandler; \ | |
1197 | } | |
1198 | ||
8cf73271 SC |
1199 | //--------------------------------------------------------------------------- |
1200 | // wxMac string conversions | |
1201 | //--------------------------------------------------------------------------- | |
1202 | ||
6cce68ea SC |
1203 | void wxMacSetupConverters(); |
1204 | void wxMacCleanupConverters(); | |
8cf73271 | 1205 | |
6cce68ea SC |
1206 | void wxMacStringToPascal( const wxString&from , StringPtr to ); |
1207 | wxString wxMacMakeStringFromPascal( ConstStringPtr from ); | |
8cf73271 | 1208 | |
a2b77260 SC |
1209 | // filefn.cpp |
1210 | ||
6cce68ea SC |
1211 | wxString wxMacFSRefToPath( const FSRef *fsRef , CFStringRef additionalPathComponent = NULL ); |
1212 | OSStatus wxMacPathToFSRef( const wxString&path , FSRef *fsRef ); | |
1213 | wxString wxMacHFSUniStrToString( ConstHFSUniStr255Param uniname ); | |
aa0cc8a1 | 1214 | |
8cf73271 SC |
1215 | #endif |
1216 | // _WX_PRIVATE_H_ |