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