]> git.saurik.com Git - wxWidgets.git/blob - include/wx/mac/carbon/private.h
cleanup
[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 #include <Carbon/Carbon.h>
20
21 #include "wx/mac/corefoundation/cfstring.h"
22 #include "wx/mac/corefoundation/cfdataref.h"
23
24 #if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5
25 typedef UInt32 URefCon;
26 typedef SInt32 SRefCon;
27 #endif
28
29 #if wxUSE_GUI
30
31 #include "wx/listbox.h"
32
33 #ifndef __LP64__
34
35 class wxMacPortStateHelper
36 {
37 DECLARE_NO_COPY_CLASS(wxMacPortStateHelper)
38
39 public:
40 wxMacPortStateHelper( GrafPtr newport);
41 wxMacPortStateHelper();
42 ~wxMacPortStateHelper();
43
44 void Setup( GrafPtr newport );
45 void Clear();
46 bool IsCleared() { return m_clip == NULL; }
47 GrafPtr GetCurrentPort() { return m_currentPort; }
48
49 private:
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 };
59
60 class WXDLLEXPORT wxMacPortSaver
61 {
62 DECLARE_NO_COPY_CLASS(wxMacPortSaver)
63
64 public:
65 wxMacPortSaver( GrafPtr port );
66 ~wxMacPortSaver();
67 private :
68 GrafPtr m_port;
69 };
70
71 class WXDLLEXPORT wxMacPortSetter
72 {
73 DECLARE_NO_COPY_CLASS(wxMacPortSetter)
74
75 public:
76 wxMacPortSetter( const wxDC* dc );
77 ~wxMacPortSetter();
78 private:
79 wxMacPortStateHelper m_ph;
80 const wxDC* m_dc;
81 };
82
83 /*
84 Clips to the visible region of a control within the current port
85 */
86
87 class WXDLLEXPORT wxMacWindowClipper : public wxMacPortSaver
88 {
89 DECLARE_NO_COPY_CLASS(wxMacWindowClipper)
90
91 public:
92 wxMacWindowClipper( const wxWindow* win );
93 ~wxMacWindowClipper();
94 private:
95 GrafPtr m_newPort;
96 RgnHandle m_formerClip;
97 RgnHandle m_newClip;
98 };
99
100 class WXDLLEXPORT wxMacWindowStateSaver : public wxMacWindowClipper
101 {
102 DECLARE_NO_COPY_CLASS(wxMacWindowStateSaver)
103
104 public:
105 wxMacWindowStateSaver( const wxWindow* win );
106 ~wxMacWindowStateSaver();
107 private:
108 GrafPtr m_newPort;
109 ThemeDrawingState m_themeDrawingState;
110 };
111 #endif
112
113 #if wxMAC_USE_CORE_GRAPHICS
114 class WXDLLEXPORT wxMacCGContextStateSaver
115 {
116 DECLARE_NO_COPY_CLASS(wxMacCGContextStateSaver)
117
118 public:
119 wxMacCGContextStateSaver( CGContextRef cg )
120 {
121 m_cg = cg;
122 CGContextSaveGState( cg );
123 }
124 ~wxMacCGContextStateSaver()
125 {
126 CGContextRestoreGState( m_cg );
127 }
128 private:
129 CGContextRef m_cg;
130 };
131
132 #endif
133 /*
134 class wxMacDrawingHelper
135 {
136 DECLARE_NO_COPY_CLASS(wxMacDrawingHelper)
137
138 public:
139 wxMacDrawingHelper( wxWindowMac * theWindow , bool clientArea = false );
140 ~wxMacDrawingHelper();
141 bool Ok() const { return IsOk(); }
142 bool IsOk() { return m_ok; }
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; }
147 private:
148 Point m_origin;
149 GrafPtr m_formerPort;
150 GrafPtr m_currentPort;
151 PenState m_savedPenState;
152 bool m_ok;
153 };
154 */
155
156 // app.h
157 bool wxMacConvertEventToRecord( EventRef event , EventRecord *rec);
158
159 #endif // wxUSE_GUI
160
161 // filefn.h
162 WXDLLIMPEXP_BASE wxString wxMacFSSpec2MacFilename( const FSSpec *spec );
163 WXDLLIMPEXP_BASE void wxMacFilename2FSSpec( const wxString &path , FSSpec *spec );
164
165 // utils.h
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);
172
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; }
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; }
191 template<> inline EventParamType wxMacGetEventParamType<CFDictionaryRef>() { return typeCFDictionaryRef; }
192 template<> inline EventParamType wxMacGetEventParamType<Collection>() { return typeCollection; }
193 template<> inline EventParamType wxMacGetEventParamType<CGContextRef>() { return typeCGContextRef; }
194 /*
195 These are ambiguous
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; }
200 */
201
202 class wxMacCarbonEvent
203 {
204
205 public :
206 wxMacCarbonEvent()
207 {
208 m_eventRef = 0;
209 m_release = false;
210 }
211
212 wxMacCarbonEvent( EventRef event , bool release = false )
213 {
214 m_eventRef = event;
215 m_release = release;
216 }
217
218 wxMacCarbonEvent(UInt32 inClassID,UInt32 inKind,EventTime inWhen = 0 /*now*/,EventAttributes inAttributes=kEventAttributeNone)
219 {
220 m_eventRef = NULL;
221 verify_noerr( MacCreateEvent( NULL , inClassID, inKind,inWhen,inAttributes,&m_eventRef) );
222 m_release = true;
223 }
224
225 ~wxMacCarbonEvent()
226 {
227 if ( m_release )
228 ReleaseEvent( m_eventRef );
229 }
230
231 OSStatus Create(UInt32 inClassID,UInt32 inKind,EventTime inWhen = 0 /*now*/,EventAttributes inAttributes=kEventAttributeNone)
232 {
233 verify( (m_eventRef == NULL) || m_release );
234 if ( m_eventRef && m_release )
235 {
236 ReleaseEvent( m_eventRef );
237 m_release = false;
238 m_eventRef = NULL;
239 }
240 OSStatus err = MacCreateEvent( NULL , inClassID, inKind,inWhen,inAttributes,&m_eventRef);
241 if ( err == noErr )
242 m_release = true;
243 return err;
244 }
245
246 OSStatus GetParameter( EventParamName inName, EventParamType inDesiredType, UInt32 inBufferSize, void * outData);
247
248 template <typename T> OSStatus GetParameter( EventParamName inName, EventParamType type , T *data )
249 {
250 return GetParameter( inName, type , sizeof( T ) , data );
251 }
252 template <typename T> OSStatus GetParameter( EventParamName inName, T *data )
253 {
254 return GetParameter<T>( inName, wxMacGetEventParamType<T>() , data );
255 }
256
257 template <typename T> T GetParameter( EventParamName inName )
258 {
259 T value;
260 verify_noerr( GetParameter<T>( inName, &value ) );
261 return value;
262 }
263 template <typename T> T GetParameter( EventParamName inName, EventParamType inDesiredType )
264 {
265 T value;
266 verify_noerr( GetParameter<T>( inName, inDesiredType , &value ) );
267 return value;
268 }
269
270 OSStatus SetParameter( EventParamName inName, EventParamType inType, UInt32 inSize, const void * inData);
271 template <typename T> OSStatus SetParameter( EventParamName inName, EventParamType inDesiredType , const T *data )
272 {
273 return SetParameter( inName, inDesiredType , sizeof( T ) , data );
274 }
275 template <typename T> OSStatus SetParameter( EventParamName inName, EventParamType inDesiredType , const T& data )
276 {
277 return SetParameter<T>( inName, inDesiredType , &data );
278 }
279 template <typename T> OSStatus SetParameter( EventParamName inName, const T *data )
280 {
281 return SetParameter<T>( inName, wxMacGetEventParamType<T>() , data );
282 }
283 template <typename T> OSStatus SetParameter( EventParamName inName, const T& data )
284 {
285 return SetParameter<T>( inName, wxMacGetEventParamType<T>() , &data );
286 }
287 UInt32 GetClass()
288 {
289 return ::GetEventClass( m_eventRef );
290 }
291 UInt32 GetKind()
292 {
293 return ::GetEventKind( m_eventRef );
294 }
295 EventTime GetTime()
296 {
297 return ::GetEventTime( m_eventRef );
298 }
299 UInt32 GetTicks()
300 {
301 return EventTimeToTicks( GetTime() );
302 }
303 OSStatus SetCurrentTime( )
304 {
305 return ::SetEventTime( m_eventRef , GetCurrentEventTime() );
306 }
307 OSStatus SetTime( EventTime when )
308 {
309 return ::SetEventTime( m_eventRef , when );
310 }
311 operator EventRef () { return m_eventRef; }
312
313 bool IsValid() { return m_eventRef != 0; }
314 protected :
315 EventRef m_eventRef;
316 bool m_release;
317 };
318
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 :
326 wxMacUPP( procType WXUNUSED(proc) )
327 {
328 m_upp = NULL;
329 m_upp = (*newUPP)( NULL );
330 }
331 ~wxMacUPP()
332 {
333 if ( m_upp )
334 disposeUPP( m_upp );
335 }
336 operator uppType() { return m_upp; }
337 private :
338 uppType m_upp;
339 };
340
341 typedef wxMacUPP<NMProcPtr,NMUPP,NewNMUPP,DisposeNMUPP> wxMacNMUPP;
342
343 template <typename refType> class wxMacCFRefHolder
344 {
345 public :
346 wxMacCFRefHolder()
347 : m_ref(NULL) , m_release(false)
348 {
349 }
350
351 wxMacCFRefHolder( refType ref , bool release = true )
352 : m_ref(ref) , m_release(release)
353 {
354 }
355
356 ~wxMacCFRefHolder()
357 {
358 Release();
359 }
360
361 void Release()
362 {
363 if ( m_release && m_ref != NULL )
364 CFRelease( m_ref );
365 m_ref = NULL;
366 }
367
368 refType Detach()
369 {
370 refType val = m_ref;
371 m_release = false;
372 m_ref = NULL;
373 return val;
374 }
375
376 void Set( refType ref , bool release = true )
377 {
378 Release();
379 m_release = release;
380 m_ref = ref;
381 }
382
383 operator refType () const { return m_ref; }
384
385 wxMacCFRefHolder& operator=(refType r)
386 {
387 Set( r );
388 return *this;
389 }
390 private :
391 refType m_ref;
392 bool m_release;
393
394 DECLARE_NO_COPY_CLASS( wxMacCFRefHolder )
395 };
396
397 #if wxUSE_GUI
398
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
428 wxMacCFStringHolder m_helpTextRef ;
429 } ;
430
431 /*
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 );
438 */
439 void wxMacCreateBitmapButton( ControlButtonContentInfo*info , const wxBitmap& bitmap , int forceType = 0 );
440 void wxMacReleaseBitmapButton( ControlButtonContentInfo*info );
441 CGImageRef wxMacCreateCGImageFromBitmap( const wxBitmap& bitmap );
442
443 #define MAC_WXCOLORREF(a) (*((RGBColor*)&(a)))
444 #define MAC_WXHBITMAP(a) (GWorldPtr(a))
445 #define MAC_WXHMETAFILE(a) (PicHandle(a))
446 #define MAC_WXHICON(a) (IconRef(a))
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 {
456 wxOpaqueWindowRef( WindowRef ref ) { m_data = ref; }
457 operator WindowRef() { return m_data; }
458 private :
459 WindowRef m_data;
460 };
461
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 );
466
467 WXDLLIMPEXP_CORE wxWindow * wxFindControlFromMacControl(ControlRef inControl );
468 WXDLLIMPEXP_CORE wxTopLevelWindowMac* wxFindWinFromMacWindow( WindowRef inWindow );
469 WXDLLIMPEXP_CORE wxMenu* wxFindMenuFromMacMenu(MenuRef inMenuRef);
470
471 WXDLLIMPEXP_CORE int wxMacCommandToId( UInt32 macCommandId );
472 WXDLLIMPEXP_CORE UInt32 wxIdToMacCommand( int wxId );
473 WXDLLIMPEXP_CORE wxMenu* wxFindMenuFromMacCommand( const HICommand &macCommandId , wxMenuItem* &item );
474
475 extern wxWindow* g_MacLastWindow;
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 );
478
479 ControlActionUPP GetwxMacLiveScrollbarActionProc();
480
481 class wxMacControl : public wxObject
482 {
483 public :
484 wxMacControl( wxWindow* peer , bool isRootControl = false );
485 wxMacControl( wxWindow* peer , ControlRef control );
486 wxMacControl( wxWindow* peer , WXWidget control );
487 wxMacControl() ;
488 virtual ~wxMacControl();
489
490 void Init();
491
492 virtual void Dispose();
493
494 bool Ok() const { return IsOk(); }
495 bool IsOk() const { return GetControlRef() != NULL; }
496
497 void SetReferenceInNativeControl();
498 static wxMacControl* GetReferenceFromNativeControl(ControlRef control);
499
500 virtual ControlRef * GetControlRefAddr() { return &m_controlRef; }
501 virtual ControlRef GetControlRef() const { return m_controlRef; }
502
503 virtual void SetReference( URefCon data );
504 /*
505 void operator= (ControlRef c) { m_controlRef = c; }
506 operator ControlRef () { return m_controlRef; }
507 operator ControlRef * () { return &m_controlRef; }
508 */
509 // accessing data and values
510
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 );
516
517 virtual OSStatus SendHICommand( UInt32 commandID , OptionBits inOptions = 0 );
518
519 virtual SInt32 GetValue() const;
520 virtual SInt32 GetMaximum() const;
521 virtual SInt32 GetMinimum() const;
522
523 virtual void SetValue( SInt32 v );
524 virtual void SetMinimum( SInt32 v );
525 virtual void SetMaximum( SInt32 v );
526
527 virtual void SetValueAndRange( SInt32 value , SInt32 minimum , SInt32 maximum );
528 virtual void SetRange( SInt32 minimum , SInt32 maximum );
529
530 virtual OSStatus SetFocus( ControlFocusPart focusPart );
531 virtual bool HasFocus() const;
532 virtual bool NeedsFocusRect() const;
533 virtual void SetNeedsFocusRect( bool needs );
534
535 // templated helpers
536
537 Size GetDataSize( ControlPartCode inPartCode , ResType inTag ) const
538 {
539 Size sz;
540 verify_noerr( GetDataSize( inPartCode , inTag , &sz ) );
541 return sz;
542 }
543 template <typename T> OSStatus SetData( ControlPartCode inPartCode , ResType inTag , const T *data )
544 {
545 return SetData( inPartCode , inTag , sizeof( T ) , data );
546 }
547 template <typename T> OSStatus SetData( ControlPartCode inPartCode , ResType inTag , const T& data )
548 {
549 return SetData( inPartCode , inTag , sizeof( T ) , &data );
550 }
551 template <typename T> OSStatus SetData( ResType inTag , const T *data )
552 {
553 return SetData( kControlEntireControl , inTag , sizeof( T ) , data );
554 }
555 template <typename T> OSStatus SetData( ResType inTag , const T& data )
556 {
557 return SetData( kControlEntireControl , inTag , sizeof( T ) , &data );
558 }
559 template <typename T> OSStatus GetData( ControlPartCode inPartCode , ResType inTag , T *data ) const
560 {
561 Size dummy;
562 return GetData( inPartCode , inTag , sizeof( T ) , data , &dummy );
563 }
564 template <typename T> T GetData( ControlPartCode inPartCode , ResType inTag ) const
565 {
566 T value;
567 OSStatus err = GetData<T>( inPartCode , inTag , &value );
568
569 wxASSERT_MSG( err == noErr,
570 wxString::Format(wxT("GetData Failed for Part [%i] and Tag [%i]"),
571 inPartCode, (int)inTag) );
572 return value;
573 }
574 template <typename T> OSStatus GetData( ResType inTag , T *data ) const
575 {
576 Size dummy;
577 return GetData( kControlEntireControl , inTag , sizeof( T ) , data , &dummy );
578 }
579 template <typename T> T GetData( ResType inTag ) const
580 {
581 return GetData<T>( kControlEntireControl , inTag );
582 }
583
584 // Flash the control for the specified amount of time
585 virtual void Flash( ControlPartCode part , UInt32 ticks = 8 );
586
587 virtual void VisibilityChanged( bool shown );
588 virtual void SuperChangedPosition();
589
590
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;
597
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 );
603
604 // invalidates this control and all children
605 virtual void InvalidateWithChildren();
606 virtual void SetDrawingEnabled( bool enable );
607 virtual bool GetNeedsDisplay() const;
608
609 // where is in native window relative coordinates
610 virtual void SetNeedsDisplay( RgnHandle where );
611 // where is in native window relative coordinates
612 virtual void SetNeedsDisplay( Rect* where = NULL );
613
614 // if rect = NULL, entire view
615 virtual void ScrollRect( wxRect *rect , int dx , int dy );
616
617 // in native parent window relative coordinates
618 virtual void GetRect( Rect *r );
619
620 // in native parent window relative coordinates
621 virtual void SetRect( Rect *r );
622
623 virtual void GetRectInWindowCoords( Rect *r );
624 virtual void GetBestRect( Rect *r );
625 virtual void SetLabel( const wxString &title );
626 // converts from Toplevel-Content relative to local
627 static void Convert( wxPoint *pt , wxMacControl *convert , wxMacControl *to );
628
629 virtual void GetFeatures( UInt32 *features );
630 virtual OSStatus GetRegion( ControlPartCode partCode , RgnHandle region );
631 virtual OSStatus SetZOrder( bool above , wxMacControl* other );
632
633 bool IsRootControl() { return m_isRootControl; }
634
635 wxWindow* GetPeer() const
636 {
637 return m_peer;
638 }
639
640 // to be moved into a tab control class
641
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;
649 bool m_isRootControl;
650 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacControl)
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);
664 wxMacDataBrowserControl() {}
665
666 OSStatus SetCallbacks( const DataBrowserCallbacks *callbacks );
667
668 OSStatus GetItemCount( DataBrowserItemID container,
669 Boolean recurse,
670 DataBrowserItemState state,
671 ItemCount *numItems) const;
672
673 OSStatus GetItems( DataBrowserItemID container,
674 Boolean recurse,
675 DataBrowserItemState state,
676 Handle items) const;
677
678
679 OSStatus AddColumn( DataBrowserListViewColumnDesc *columnDesc,
680 DataBrowserTableViewColumnIndex position );
681
682 OSStatus RemoveColumn( DataBrowserTableViewColumnIndex position );
683
684 OSStatus AutoSizeColumns();
685
686 OSStatus SetHasScrollBars( bool horiz, bool vert );
687 OSStatus SetHiliteStyle( DataBrowserTableViewHiliteStyle hiliteStyle );
688
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;
696
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
714 OSStatus GetItemID( DataBrowserTableViewRowIndex row,
715 DataBrowserItemID * item ) const;
716 OSStatus GetItemRow( DataBrowserItemID item,
717 DataBrowserTableViewRowIndex * row ) const;
718
719 OSStatus SetDefaultRowHeight( UInt16 height );
720 OSStatus GetDefaultRowHeight( UInt16 * height ) const;
721
722 OSStatus SetRowHeight( DataBrowserItemID item , UInt16 height);
723 OSStatus GetRowHeight( DataBrowserItemID item , UInt16 *height) const;
724
725 OSStatus GetColumnWidth( DataBrowserPropertyID column , UInt16 *width ) const;
726 OSStatus SetColumnWidth( DataBrowserPropertyID column , UInt16 width );
727
728 OSStatus GetDefaultColumnWidth( UInt16 *width ) const;
729 OSStatus SetDefaultColumnWidth( UInt16 width );
730
731 OSStatus GetColumnCount( UInt32* numColumns) const;
732
733 OSStatus GetColumnIDFromIndex( DataBrowserTableViewColumnIndex position, DataBrowserTableViewColumnID* id );
734
735 OSStatus GetColumnPosition( DataBrowserPropertyID column, DataBrowserTableViewColumnIndex *position) const;
736 OSStatus SetColumnPosition( DataBrowserPropertyID column, DataBrowserTableViewColumnIndex position);
737
738 OSStatus GetScrollPosition( UInt32 *top , UInt32 *left ) const;
739 OSStatus SetScrollPosition( UInt32 top , UInt32 left );
740
741 OSStatus GetSortProperty( DataBrowserPropertyID *column ) const;
742 OSStatus SetSortProperty( DataBrowserPropertyID column );
743
744 OSStatus GetSortOrder( DataBrowserSortOrder *order ) const;
745 OSStatus SetSortOrder( DataBrowserSortOrder order );
746
747 OSStatus GetPropertyFlags( DataBrowserPropertyID property, DataBrowserPropertyFlags *flags ) const;
748 OSStatus SetPropertyFlags( DataBrowserPropertyID property, DataBrowserPropertyFlags flags );
749
750 OSStatus GetHeaderDesc( DataBrowserPropertyID property, DataBrowserListViewHeaderDesc *desc ) const;
751 OSStatus SetHeaderDesc( DataBrowserPropertyID property, DataBrowserListViewHeaderDesc *desc );
752
753 OSStatus SetDisclosureColumn( DataBrowserPropertyID property , Boolean expandableRows );
754 protected :
755
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(
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;
789 DECLARE_ABSTRACT_CLASS(wxMacDataBrowserControl)
790 };
791
792 // ============================================================================
793 // Higher-level Databrowser
794 // ============================================================================
795 //
796 // basing on data item objects
797 //
798
799 // forward decl
800
801 class wxMacDataItemBrowserControl;
802 class wxMacListBoxItem;
803
804 const DataBrowserPropertyID kTextColumnId = 1024;
805 const DataBrowserPropertyID kNumericOrderColumnId = 1025;
806
807 // for multi-column controls, we will use this + the column ID to identify the
808 // column. We don't use kTextColumnId there, and ideally the two should merge.
809 const DataBrowserPropertyID kMinColumnId = 1050;
810
811 // base API for high-level databrowser operations
812
813 class wxMacListControl
814 {
815 public:
816 virtual void MacDelete( unsigned int n ) = 0;
817 virtual void MacInsert( unsigned int n, const wxArrayStringsAdapter& items, int column = -1 ) = 0;
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() { }
835 };
836
837 // base class for databrowser items
838
839 enum DataItemType {
840 DataItem_Text
841 };
842
843 class wxMacDataItem
844 {
845 public :
846 wxMacDataItem();
847 virtual ~wxMacDataItem();
848
849 virtual bool IsLessThan(wxMacDataItemBrowserControl *owner ,
850 const wxMacDataItem*,
851 DataBrowserPropertyID property) const;
852
853 // returns true if access was successful, otherwise false
854 virtual OSStatus GetSetData(wxMacDataItemBrowserControl *owner ,
855 DataBrowserPropertyID property,
856 DataBrowserItemDataRef itemData,
857 bool changeValue );
858
859 virtual void Notification(wxMacDataItemBrowserControl *owner ,
860 DataBrowserItemNotification message,
861 DataBrowserItemDataRef itemData ) const;
862
863 void SetLabel( const wxString& str);
864 const wxString& GetLabel() const;
865
866 void SetOrder( SInt32 order );
867 SInt32 GetOrder() const;
868
869 void SetData( void* data);
870 void* GetData() const;
871
872 void SetColumn( short col );
873 short GetColumn();
874
875 protected :
876 wxString m_label;
877 wxMacCFStringHolder m_cfLabel;
878 void * m_data;
879 SInt32 m_order;
880 DataBrowserPropertyID m_colId;
881
882 };
883
884 enum ListSortOrder {
885 SortOrder_None,
886 SortOrder_Text_Ascending,
887 SortOrder_Text_Descending
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
895 class wxMacDataItemBrowserControl : public wxMacDataBrowserControl, public wxMacListControl
896 {
897 public :
898 wxMacDataItemBrowserControl( wxWindow* peer , const wxPoint& pos, const wxSize& size, long style);
899 wxMacDataItemBrowserControl() {}
900 // create a list item (can be a subclass of wxMacListBoxItem)
901
902 virtual wxMacDataItem* CreateItem();
903
904 unsigned int GetItemCount(const wxMacDataItem* container, bool recurse , DataBrowserItemState state) const;
905 void GetItems(const wxMacDataItem* container, bool recurse ,
906 DataBrowserItemState state, wxArrayMacDataItemPtr &items ) const;
907
908 unsigned int GetSelectedItemCount( const wxMacDataItem* container, bool recurse ) const;
909
910 unsigned int GetLineFromItem(const wxMacDataItem *item) const;
911 wxMacDataItem * GetItemFromLine(unsigned int n) const;
912
913 void UpdateItem(const wxMacDataItem *container, const wxMacDataItem *item,
914 DataBrowserPropertyID property) const;
915 void UpdateItems(const wxMacDataItem *container, wxArrayMacDataItemPtr &items,
916 DataBrowserPropertyID property) const;
917
918 void InsertColumn(int colId, DataBrowserPropertyType colType,
919 const wxString& title, SInt16 just = teFlushDefault, int defaultWidth = -1);
920
921 int GetColumnWidth(int colId);
922 void SetColumnWidth(int colId, int width);
923
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);
930
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;
935
936 void RevealItem( wxMacDataItem* item, DataBrowserRevealOptions options);
937
938 void GetSelectionAnchor( wxMacDataItemPtr* first , wxMacDataItemPtr* last) const;
939
940 // item aware methods, to be used in subclasses
941
942 virtual Boolean CompareItems(const wxMacDataItem* itemOneID,
943 const wxMacDataItem* itemTwoID,
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);
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 );
961
962
963 // wxMacListControl Methods
964 // add and remove
965
966 virtual void MacDelete( unsigned int n );
967 virtual void MacInsert( unsigned int n, const wxArrayStringsAdapter& items, int column = -1 );
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);
995 //virtual ListSortOrder GetSortOrder() const;
996 //virtual void SetSortOrder(const ListSortOrder sort);
997
998
999
1000 protected:
1001
1002 ListSortOrder m_sortOrder;
1003 wxClientDataType m_clientDataItemsType;
1004
1005 // ID aware base methods, should be 'final' ie not changed in subclasses
1006
1007 virtual Boolean CompareItems(DataBrowserItemID itemOneID,
1008 DataBrowserItemID itemTwoID,
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
1021
1022 private :
1023
1024 bool m_suppressSelection;
1025 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacDataItemBrowserControl)
1026 };
1027
1028 class wxMacDataItemBrowserSelectionSuppressor
1029 {
1030 public :
1031 wxMacDataItemBrowserSelectionSuppressor(wxMacDataItemBrowserControl *browser);
1032 ~wxMacDataItemBrowserSelectionSuppressor();
1033
1034 private :
1035
1036 bool m_former;
1037 wxMacDataItemBrowserControl* m_browser;
1038 };
1039
1040 // ============================================================================
1041 // platform listbox implementation
1042 // ============================================================================
1043
1044 // exposed for reuse in wxCheckListBox
1045
1046 class wxMacListBoxItem : public wxMacDataItem
1047 {
1048 public :
1049 wxMacListBoxItem();
1050
1051 virtual ~wxMacListBoxItem();
1052
1053 virtual void Notification(wxMacDataItemBrowserControl *owner ,
1054 DataBrowserItemNotification message,
1055 DataBrowserItemDataRef itemData ) const;
1056 };
1057
1058 class wxMacDataBrowserListControl : public wxMacDataItemBrowserControl
1059 {
1060 public:
1061 wxMacDataBrowserListControl( wxWindow *peer, const wxPoint& pos, const wxSize& size, long style );
1062 wxMacDataBrowserListControl() {}
1063 virtual ~wxMacDataBrowserListControl();
1064
1065 virtual wxMacDataItem* CreateItem();
1066
1067 // pointing back
1068
1069 wxWindow * GetPeer() const;
1070
1071 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacDataBrowserListControl)
1072 };
1073
1074 // ============================================================================
1075 // graphics implementation
1076 // ============================================================================
1077
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
1098 #if wxMAC_USE_CORE_GRAPHICS && !wxUSE_GRAPHICS_CONTEXT
1099
1100 class WXDLLEXPORT wxMacCGPath : public wxGraphicPath
1101 {
1102 DECLARE_NO_COPY_CLASS(wxMacCGPath)
1103 public :
1104 wxMacCGPath();
1105 ~wxMacCGPath();
1106
1107 // Starts a new subpath at
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 );
1113
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
1118 // closes the current subpath
1119 void CloseSubpath();
1120
1121 CGPathRef GetPath() const;
1122 private :
1123 CGMutablePathRef m_path;
1124 };
1125
1126 class WXDLLEXPORT wxMacCGContext : public wxGraphicContext
1127 {
1128 DECLARE_NO_COPY_CLASS(wxMacCGContext)
1129
1130 public:
1131 wxMacCGContext( CGrafPtr port );
1132 wxMacCGContext( CGContextRef cgcontext );
1133 wxMacCGContext();
1134 virtual ~wxMacCGContext();
1135
1136 virtual void Clip( const wxRegion &region );
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; }
1147
1148 virtual void Translate( wxCoord dx , wxCoord dy );
1149 virtual void Scale( wxCoord xScale , wxCoord yScale );
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 );
1152 virtual void PushState();
1153 virtual void PopState();
1154
1155 virtual void DrawText( const wxString &str, wxCoord x, wxCoord y, double angle ) ;
1156
1157 virtual void GetTextExtent( const wxString &str, wxCoord *width, wxCoord *height,
1158 wxCoord *descent, wxCoord *externalLeading ) const ;
1159
1160 virtual void GetPartialTextExtents(const wxString& text, wxArrayInt& widths) const ;
1161
1162 virtual void SetFont( const wxFont &font ) ;
1163
1164 virtual void SetTextColor( const wxColour &col ) ;
1165 private:
1166 CGContextRef m_cgContext;
1167 CGrafPtr m_qdPort;
1168 CGPathDrawingMode m_mode;
1169 ATSUStyle m_macATSUIStyle ;
1170 wxPen m_pen;
1171 wxBrush m_brush;
1172 wxColor m_textForegroundColor ;
1173 };
1174
1175 #endif // wxMAC_USE_CORE_GRAPHICS
1176
1177 CGColorSpaceRef wxMacGetGenericRGBColorSpace(void);
1178 void wxMacMemoryBufferReleaseProc(void *info, const void *data, size_t size);
1179
1180 class WXDLLEXPORT wxBitmapRefData: public wxGDIRefData
1181 {
1182 friend class WXDLLIMPEXP_FWD_CORE wxIcon;
1183 friend class WXDLLIMPEXP_FWD_CORE wxCursor;
1184 public:
1185 wxBitmapRefData(int width , int height , int depth);
1186 wxBitmapRefData();
1187 wxBitmapRefData(const wxBitmapRefData &tocopy);
1188
1189 virtual ~wxBitmapRefData();
1190
1191 void Free();
1192 bool Ok() const { return IsOk(); }
1193 bool IsOk() const { return m_ok; }
1194 void SetOk( bool isOk) { m_ok = isOk; }
1195
1196 void SetWidth( int width ) { m_width = width; }
1197 void SetHeight( int height ) { m_height = height; }
1198 void SetDepth( int depth ) { m_depth = depth; }
1199
1200 int GetWidth() const { return m_width; }
1201 int GetHeight() const { return m_height; }
1202 int GetDepth() const { return m_depth; }
1203
1204 void *GetRawAccess() const;
1205 void *BeginRawAccess();
1206 void EndRawAccess();
1207
1208 bool HasAlpha() const { return m_hasAlpha; }
1209 void UseAlpha( bool useAlpha );
1210
1211 public:
1212 #if wxUSE_PALETTE
1213 wxPalette m_bitmapPalette;
1214 #endif // wxUSE_PALETTE
1215
1216 wxMask * m_bitmapMask; // Optional mask
1217 CGImageRef CGImageCreate() const;
1218
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
1223 // rescaled to 16 x 16
1224 bool HasNativeSize();
1225
1226 // caller should increase ref count if needed longer
1227 // than the bitmap exists
1228 IconRef GetIconRef();
1229
1230 // returns a Pict from the bitmap content
1231 PicHandle GetPictHandle();
1232 #if wxMAC_USE_CORE_GRAPHICS
1233 CGContextRef GetBitmapContext() const;
1234 #else
1235 GWorldPtr GetHBITMAP(GWorldPtr * mask = NULL ) const;
1236 void UpdateAlphaMask() const;
1237 #endif
1238 int GetBytesPerRow() const { return m_bytesPerRow; }
1239 private :
1240 bool Create(int width , int height , int depth);
1241 void Init();
1242
1243 int m_width;
1244 int m_height;
1245 int m_bytesPerRow;
1246 int m_depth;
1247 bool m_hasAlpha;
1248 wxMemoryBuffer m_memBuf;
1249 int m_rawAccessCount;
1250 bool m_ok;
1251 mutable CGImageRef m_cgImageRef;
1252
1253 IconRef m_iconRef;
1254 PicHandle m_pictHandle;
1255 #if wxMAC_USE_CORE_GRAPHICS
1256 CGContextRef m_hBitmap;
1257 #else
1258 GWorldPtr m_hBitmap;
1259 GWorldPtr m_hMaskBitmap;
1260 wxMemoryBuffer m_maskMemBuf;
1261 int m_maskBytesPerRow;
1262 #endif
1263 };
1264
1265 class WXDLLEXPORT wxIconRefData : public wxGDIRefData
1266 {
1267 public:
1268 wxIconRefData();
1269 wxIconRefData( WXHICON );
1270 virtual ~wxIconRefData() { Free(); }
1271
1272 void Init();
1273 virtual void Free();
1274
1275 void SetWidth( int width ) { m_width = width; }
1276 void SetHeight( int height ) { m_height = height; }
1277
1278 int GetWidth() const { return m_width; }
1279 int GetHeight() const { return m_height; }
1280
1281 WXHICON GetHICON() const { return (WXHICON) m_iconRef; }
1282 private :
1283 IconRef m_iconRef;
1284 int m_width;
1285 int m_height;
1286 };
1287
1288 // toplevel.cpp
1289
1290 class wxMacDeferredWindowDeleter : public wxObject
1291 {
1292 public :
1293 wxMacDeferredWindowDeleter( WindowRef windowRef );
1294 virtual ~wxMacDeferredWindowDeleter();
1295
1296 protected :
1297 WindowRef m_macWindow ;
1298 } ;
1299
1300 #ifndef __LP64__
1301
1302 #ifdef WORDS_BIGENDIAN
1303 inline Rect* wxMacGetPictureBounds( PicHandle pict , Rect* rect )
1304 {
1305 *rect = (**pict).picFrame;
1306 return rect;
1307 }
1308 #else
1309 inline Rect* wxMacGetPictureBounds( PicHandle pict , Rect* rect )
1310 {
1311 return QDGetPictureBounds( pict , rect );
1312 }
1313 #endif
1314
1315 #endif
1316
1317 #endif // wxUSE_GUI
1318
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
1328 //---------------------------------------------------------------------------
1329 // wxMac string conversions
1330 //---------------------------------------------------------------------------
1331
1332 void wxMacSetupConverters();
1333 void wxMacCleanupConverters();
1334
1335 WXDLLIMPEXP_BASE void wxMacStringToPascal( const wxString&from , StringPtr to );
1336 WXDLLIMPEXP_BASE wxString wxMacMakeStringFromPascal( ConstStringPtr from );
1337
1338 // filefn.cpp
1339
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 );
1343
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
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
1426 #endif
1427 // _WX_PRIVATE_H_