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