]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/mac/carbon/private.h
Finalize wxJoystick on mac. Note change. Pretty up joystick sample a bit. Don...
[wxWidgets.git] / include / wx / mac / carbon / private.h
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: 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#include "wx/app.h"
19
20#ifdef __DARWIN__
21# include <Carbon/Carbon.h>
22#else
23# include <Debugging.h>
24# include <Quickdraw.h>
25# include <Appearance.h>
26# include <Folders.h>
27# include <Controls.h>
28# include <ControlDefinitions.h>
29# include <LowMem.h>
30# include <Gestalt.h>
31# include <FixMath.h>
32#endif
33
34#if UNIVERSAL_INTERFACES_VERSION < 0x0340
35 #error "please update to Apple's lastest 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#ifdef __WXMAC_CARBON__
43#include "wx/mac/corefoundation/cfstring.h"
44#endif
45
46#ifndef FixedToInt
47// as macro in FixMath.h for 10.3
48inline Fixed IntToFixed( int inInt )
49{
50 return (((SInt32) inInt) << 16);
51}
52
53inline int FixedToInt( Fixed inFixed )
54{
55 return (((SInt32) inFixed) >> 16);
56}
57#endif
58
59#if wxUSE_GUI
60
61#include "wx/dc.h"
62#include "wx/window.h"
63
64class wxMacPortStateHelper
65{
66 DECLARE_NO_COPY_CLASS(wxMacPortStateHelper)
67
68public:
69 wxMacPortStateHelper( GrafPtr newport) ;
70 wxMacPortStateHelper() ;
71 ~wxMacPortStateHelper() ;
72
73 void Setup( GrafPtr newport ) ;
74 void Clear() ;
75 bool IsCleared() { return m_clip == NULL ; }
76 GrafPtr GetCurrentPort() { return m_currentPort ; }
77
78private:
79 GrafPtr m_currentPort ;
80 GrafPtr m_oldPort ;
81 RgnHandle m_clip ;
82 ThemeDrawingState m_drawingState ;
83 short m_textFont ;
84 short m_textSize ;
85 short m_textStyle ;
86 short m_textMode ;
87} ;
88
89class WXDLLEXPORT wxMacPortSaver
90{
91 DECLARE_NO_COPY_CLASS(wxMacPortSaver)
92
93public:
94 wxMacPortSaver( GrafPtr port )
95 {
96 ::GetPort( &m_port ) ;
97 ::SetPort( port ) ;
98 }
99 ~wxMacPortSaver()
100 {
101 ::SetPort( m_port ) ;
102 }
103private :
104 GrafPtr m_port ;
105} ;
106
107class WXDLLEXPORT wxMacPortSetter
108{
109 DECLARE_NO_COPY_CLASS(wxMacPortSetter)
110
111public:
112 wxMacPortSetter( const wxDC* dc ) ;
113 ~wxMacPortSetter() ;
114private:
115 wxMacPortStateHelper m_ph ;
116 const wxDC* m_dc ;
117} ;
118
119/*
120 Clips to the visible region of a control within the current port
121 */
122
123class WXDLLEXPORT wxMacWindowClipper : public wxMacPortSaver
124{
125 DECLARE_NO_COPY_CLASS(wxMacWindowClipper)
126
127public:
128 wxMacWindowClipper( const wxWindow* win ) ;
129 ~wxMacWindowClipper() ;
130private:
131 GrafPtr m_newPort ;
132 RgnHandle m_formerClip ;
133 RgnHandle m_newClip ;
134} ;
135
136class WXDLLEXPORT wxMacWindowStateSaver : public wxMacWindowClipper
137{
138 DECLARE_NO_COPY_CLASS(wxMacWindowStateSaver)
139
140public:
141 wxMacWindowStateSaver( const wxWindow* win ) ;
142 ~wxMacWindowStateSaver() ;
143private:
144 GrafPtr m_newPort ;
145 ThemeDrawingState m_themeDrawingState ;
146} ;
147
148/*
149class wxMacDrawingHelper
150{
151 DECLARE_NO_COPY_CLASS(wxMacDrawingHelper)
152
153public:
154 wxMacDrawingHelper( wxWindowMac * theWindow , bool clientArea = false ) ;
155 ~wxMacDrawingHelper() ;
156 bool Ok() { return m_ok ; }
157 void LocalToWindow( Rect *rect) { OffsetRect( rect , m_origin.h , m_origin.v ) ; }
158 void LocalToWindow( Point *pt ) { AddPt( m_origin , pt ) ; }
159 void LocalToWindow( RgnHandle rgn ) { OffsetRgn( rgn , m_origin.h , m_origin.v ) ; }
160 const Point& GetOrigin() { return m_origin ; }
161private:
162 Point m_origin ;
163 GrafPtr m_formerPort ;
164 GrafPtr m_currentPort ;
165 PenState m_savedPenState ;
166 bool m_ok ;
167} ;
168*/
169
170// app.h
171bool wxMacConvertEventToRecord( EventRef event , EventRecord *rec) ;
172
173#endif // wxUSE_GUI
174
175// filefn.h
176WXDLLEXPORT wxString wxMacFSSpec2MacFilename( const FSSpec *spec ) ;
177WXDLLEXPORT void wxMacFilename2FSSpec( const wxString &path , FSSpec *spec ) ;
178
179// utils.h
180WXDLLEXPORT wxString wxMacFindFolder(short vRefNum,
181 OSType folderType,
182 Boolean createFolder);
183
184template<typename T> EventParamType wxMacGetEventParamType() { wxFAIL_MSG( wxT("Unknown Param Type") ) ; return 0 ; }
185template<> inline EventParamType wxMacGetEventParamType<RgnHandle>() { return typeQDRgnHandle ; }
186template<> inline EventParamType wxMacGetEventParamType<ControlRef>() { return typeControlRef ; }
187template<> inline EventParamType wxMacGetEventParamType<WindowRef>() { return typeWindowRef ; }
188template<> inline EventParamType wxMacGetEventParamType<MenuRef>() { return typeMenuRef ; }
189template<> inline EventParamType wxMacGetEventParamType<EventRef>() { return typeEventRef ; }
190template<> inline EventParamType wxMacGetEventParamType<Point>() { return typeQDPoint ; }
191template<> inline EventParamType wxMacGetEventParamType<Rect>() { return typeQDRectangle ; }
192template<> inline EventParamType wxMacGetEventParamType<Boolean>() { return typeBoolean ; }
193#if TARGET_API_MAC_OSX
194template<> inline EventParamType wxMacGetEventParamType<HICommand>() { return typeHICommand ; }
195template<> inline EventParamType wxMacGetEventParamType<HIPoint>() { return typeHIPoint ; }
196template<> inline EventParamType wxMacGetEventParamType<HISize>() { return typeHISize ; }
197template<> inline EventParamType wxMacGetEventParamType<HIRect>() { return typeHIRect ; }
198template<> inline EventParamType wxMacGetEventParamType<void*>() { return typeVoidPtr ; }
199#endif
200template<> inline EventParamType wxMacGetEventParamType<Collection>() { return typeCollection ; }
201template<> inline EventParamType wxMacGetEventParamType<CGContextRef>() { return typeCGContextRef ; }
202/*
203 These are ambiguous
204 template<> EventParamType wxMacGetEventParamType<GrafPtr>() { return typeGrafPtr ; }
205 template<> EventParamType wxMacGetEventParamType<OSStatus>() { return typeOSStatus ; }
206 template<> EventParamType wxMacGetEventParamType<CFIndex>() { return typeCFIndex ; }
207 template<> EventParamType wxMacGetEventParamType<GWorldPtr>() { return typeGWorldPtr ; }
208 */
209
210class wxMacCarbonEvent
211{
212
213public :
214 wxMacCarbonEvent()
215 {
216 m_eventRef = 0 ;
217 m_release = false ;
218 }
219
220 wxMacCarbonEvent( EventRef event , bool release = false )
221 {
222 m_eventRef = event ;
223 m_release = release ;
224 }
225
226 wxMacCarbonEvent(UInt32 inClassID,UInt32 inKind,EventTime inWhen = 0 /*now*/,EventAttributes inAttributes=kEventAttributeNone)
227 {
228 m_eventRef = NULL ;
229 verify_noerr( MacCreateEvent( NULL , inClassID, inKind,inWhen,inAttributes,&m_eventRef) ) ;
230 m_release = true ;
231 }
232
233 ~wxMacCarbonEvent()
234 {
235 if ( m_release )
236 ReleaseEvent( m_eventRef ) ;
237 }
238
239 OSStatus Create(UInt32 inClassID,UInt32 inKind,EventTime inWhen = 0 /*now*/,EventAttributes inAttributes=kEventAttributeNone)
240 {
241 verify( (m_eventRef == NULL) || m_release ) ;
242 if ( m_eventRef && m_release )
243 {
244 ReleaseEvent( m_eventRef ) ;
245 m_release = false ;
246 m_eventRef = NULL ;
247
248 }
249 OSStatus err = MacCreateEvent( NULL , inClassID, inKind,inWhen,inAttributes,&m_eventRef) ;
250 if ( err == noErr )
251 m_release = true ;
252 return err ;
253 }
254
255 OSStatus GetParameter( EventParamName inName, EventParamType inDesiredType, UInt32 inBufferSize, void * outData) ;
256
257 template <typename T> OSStatus GetParameter( EventParamName inName, EventParamType type , T *data )
258 {
259 return GetParameter( inName, type , sizeof( T ) , data ) ;
260 }
261 template <typename T> OSStatus GetParameter( EventParamName inName, T *data )
262 {
263 return GetParameter<T>( inName, wxMacGetEventParamType<T>() , data ) ;
264 }
265
266 template <typename T> T GetParameter( EventParamName inName )
267 {
268 T value ;
269 verify_noerr( GetParameter<T>( inName, &value ) ) ;
270 return value ;
271 }
272 template <typename T> T GetParameter( EventParamName inName, EventParamType inDesiredType )
273 {
274 T value ;
275 verify_noerr( GetParameter<T>( inName, inDesiredType , &value ) ) ;
276 return value ;
277 }
278
279 OSStatus SetParameter( EventParamName inName, EventParamType inType, UInt32 inSize, const void * inData) ;
280 template <typename T> OSStatus SetParameter( EventParamName inName, EventParamType inDesiredType , const T *data )
281 {
282 return SetParameter( inName, inDesiredType , sizeof( T ) , data ) ;
283 }
284 template <typename T> OSStatus SetParameter( EventParamName inName, EventParamType inDesiredType , const T& data )
285 {
286 return SetParameter<T>( inName, inDesiredType , &data ) ;
287 }
288 template <typename T> OSStatus SetParameter( EventParamName inName, const T *data )
289 {
290 return SetParameter<T>( inName, wxMacGetEventParamType<T>() , data ) ;
291 }
292 template <typename T> OSStatus SetParameter( EventParamName inName, const T& data )
293 {
294 return SetParameter<T>( inName, wxMacGetEventParamType<T>() , &data ) ;
295 }
296 UInt32 GetClass()
297 {
298 return ::GetEventClass( m_eventRef ) ;
299 }
300 UInt32 GetKind()
301 {
302 return ::GetEventKind( m_eventRef ) ;
303 }
304 EventTime GetTime()
305 {
306 return ::GetEventTime( m_eventRef ) ;
307 }
308 UInt32 GetTicks()
309 {
310 return EventTimeToTicks( GetTime() ) ;
311 }
312 OSStatus SetTime( EventTime inWhen = 0 /*now*/ )
313 {
314 return ::SetEventTime( m_eventRef , inWhen ? inWhen : GetCurrentEventTime() ) ;
315 }
316 operator EventRef () { return m_eventRef; }
317
318 bool IsValid() { return m_eventRef != 0 ; }
319protected :
320 EventRef m_eventRef ;
321 bool m_release ;
322} ;
323
324//
325// helper class for allocating and deallocating Universal Proc Ptrs
326//
327
328template <typename procType, typename uppType , uppType (*newUPP)(procType) , void (*disposeUPP)(uppType) > class wxMacUPP
329{
330public :
331 wxMacUPP( procType proc )
332 {
333 m_upp = NULL ;
334 m_upp = (*newUPP)( NULL ) ;
335 }
336 ~wxMacUPP()
337 {
338 if ( m_upp )
339 disposeUPP( m_upp ) ;
340 }
341 operator uppType() { return m_upp ; }
342private :
343 uppType m_upp ;
344} ;
345
346typedef wxMacUPP<NMProcPtr,NMUPP,NewNMUPP,DisposeNMUPP> wxMacNMUPP ;
347
348#if wxUSE_GUI
349/*
350GWorldPtr wxMacCreateGWorld( int width , int height , int depth ) ;
351void wxMacDestroyGWorld( GWorldPtr gw ) ;
352PicHandle wxMacCreatePict( GWorldPtr gw , GWorldPtr mask = NULL ) ;
353CIconHandle wxMacCreateCIcon(GWorldPtr image , GWorldPtr mask , short dstDepth , short iconSize ) ;
354void wxMacSetColorTableEntry( CTabHandle newColors , int index , int red , int green , int blue ) ;
355CTabHandle wxMacCreateColorTable( int numColors ) ;
356*/
357PicHandle wxMacCreatePicHandle( const wxBitmap &bmp ) ;
358IconRef wxMacCreateIconRef(const wxBitmap& bmp) ;
359void wxMacCreateBitmapButton( ControlButtonContentInfo*info , const wxBitmap& bitmap , int forceType = 0 ) ;
360void wxMacReleaseBitmapButton( ControlButtonContentInfo*info ) ;
361
362#define MAC_WXCOLORREF(a) (*((RGBColor*)&(a)))
363#define MAC_WXHBITMAP(a) (GWorldPtr(a))
364#define MAC_WXHMETAFILE(a) (PicHandle(a))
365#define MAC_WXHICON(a) (IconRef(a))
366#define MAC_WXHCURSOR(a) (CursHandle(a))
367#define MAC_WXHRGN(a) (RgnHandle(a))
368#define MAC_WXHWND(a) (WindowPtr(a))
369#define MAC_WXRECPTR(a) ((Rect*)a)
370#define MAC_WXPOINTPTR(a) ((Point*)a)
371#define MAC_WXHMENU(a) ((MenuHandle)a)
372
373struct wxOpaqueWindowRef
374{
375 wxOpaqueWindowRef( WindowRef ref ) { m_data = ref ; }
376 operator WindowRef() { return m_data ; }
377private :
378 WindowRef m_data ;
379} ;
380
381wxWindow * wxFindControlFromMacControl(ControlRef inControl ) ;
382wxTopLevelWindowMac* wxFindWinFromMacWindow( WindowRef inWindow ) ;
383wxMenu* wxFindMenuFromMacMenu(MenuRef inMenuRef) ;
384
385extern wxWindow* g_MacLastWindow ;
386pascal OSStatus wxMacTopLevelMouseEventHandler( EventHandlerCallRef handler , EventRef event , void *data ) ;
387Rect wxMacGetBoundsForControl( wxWindow* window , const wxPoint& pos , const wxSize &size , bool adjustForOrigin = true ) ;
388
389class wxMacControl
390{
391public :
392 wxMacControl()
393 {
394 m_controlRef = NULL ;
395 }
396
397 wxMacControl( ControlRef control )
398 {
399 m_controlRef = control ;
400 }
401 wxMacControl( WXWidget control )
402 {
403 m_controlRef = (ControlRef) control ;
404 }
405 virtual ~wxMacControl()
406 {
407 }
408
409 virtual void Dispose() ;
410
411 bool Ok() const { return GetControlRef() != NULL ; }
412
413 virtual ControlRef * GetControlRefAddr() { return &m_controlRef; }
414 virtual ControlRef GetControlRef() const { return m_controlRef ; }
415
416 virtual void SetReference( SInt32 data ) ;
417 /*
418 void operator= (ControlRef c) { m_controlRef = c ; }
419 operator ControlRef () { return m_controlRef; }
420 operator ControlRef * () { return &m_controlRef; }
421 */
422 // accessing data and values
423
424 virtual OSStatus SetData( ControlPartCode inPartCode , ResType inTag , Size inSize , const void * inData ) ;
425 virtual OSStatus GetData( ControlPartCode inPartCode , ResType inTag , Size inBufferSize , void * inOutBuffer , Size * outActualSize ) const ;
426 virtual OSStatus GetDataSize( ControlPartCode inPartCode , ResType inTag , Size * outActualSize ) const ;
427 virtual OSStatus SendEvent( EventRef ref , OptionBits inOptions = 0 ) ;
428 virtual OSStatus SendHICommand( HICommand &command , OptionBits inOptions = 0 ) ;
429
430 virtual OSStatus SendHICommand( UInt32 commandID , OptionBits inOptions = 0 ) ;
431
432 virtual SInt32 GetValue() const ;
433 virtual SInt32 GetMaximum() const ;
434 virtual SInt32 GetMinimum() const ;
435
436 virtual void SetValue( SInt32 v ) ;
437 virtual void SetMinimum( SInt32 v ) ;
438 virtual void SetMaximum( SInt32 v ) ;
439
440 virtual void SetValueAndRange( SInt32 value , SInt32 minimum , SInt32 maximum ) ;
441 virtual void SetRange( SInt32 minimum , SInt32 maximum ) ;
442
443 virtual OSStatus SetFocus( ControlFocusPart focusPart ) ;
444 virtual bool HasFocus() const ;
445 virtual bool NeedsFocusRect() const ;
446
447 // templated helpers
448
449 Size GetDataSize( ControlPartCode inPartCode , ResType inTag ) const
450 {
451 Size sz ;
452 verify_noerr( GetDataSize( inPartCode , inTag , &sz ) ) ;
453 return sz ;
454 }
455 template <typename T> OSStatus SetData( ControlPartCode inPartCode , ResType inTag , const T *data )
456 {
457 return SetData( inPartCode , inTag , sizeof( T ) , data ) ;
458 }
459 template <typename T> OSStatus SetData( ControlPartCode inPartCode , ResType inTag , const T& data )
460 {
461 return SetData( inPartCode , inTag , sizeof( T ) , &data ) ;
462 }
463 template <typename T> OSStatus GetData( ControlPartCode inPartCode , ResType inTag , T *data ) const
464 {
465 Size dummy ;
466 return GetData( inPartCode , inTag , sizeof( T ) , data , &dummy ) ;
467 }
468 template <typename T> T GetData( ControlPartCode inPartCode , ResType inTag ) const
469 {
470 T value ;
471 verify_noerr( GetData<T>( inPartCode , inTag , &value ) ) ;
472 return value ;
473 }
474
475 // Flash the control for the specified amount of time
476 virtual void Flash( ControlPartCode part , UInt32 ticks = 8 ) ;
477 virtual void VisibilityChanged( bool shown ) ;
478 virtual void SetFont( const wxFont & font , const wxColour& foreground , long windowStyle ) ;
479 virtual void SetBackground( const wxBrush &brush ) ;
480 virtual ControlPartCode HandleKey( SInt16 keyCode, SInt16 charCode, EventModifiers modifiers ) ;
481 void SetActionProc( ControlActionUPP actionProc ) ;
482 void SetViewSize( SInt32 viewSize ) ;
483 SInt32 GetViewSize() const ;
484
485 virtual bool IsVisible() const ;
486 virtual void SetVisibility( bool visible , bool redraw ) ;
487 virtual bool IsEnabled() const ;
488 virtual bool IsActive() const ;
489 virtual void Enable( bool enable ) ;
490
491 // invalidates this control and all children
492 virtual void InvalidateWithChildren() ;
493 virtual void SetDrawingEnabled( bool enable ) ;
494 virtual bool GetNeedsDisplay() const ;
495 virtual void SetNeedsDisplay( bool needsDisplay , RgnHandle where = NULL ) ;
496
497 virtual void ScrollRect( const wxRect &rect , int dx , int dy ) ;
498
499 virtual void GetRect( Rect *r ) ;
500 virtual void SetRect( Rect *r ) ;
501 virtual void GetRectInWindowCoords( Rect *r ) ;
502 virtual void GetBestRect( Rect *r ) ;
503 virtual void SetTitle( const wxString &title ) ;
504 // converts from Toplevel-Content relative to local
505 static void Convert( wxPoint *pt , wxMacControl *convert , wxMacControl *to ) ;
506
507 virtual void GetFeatures( UInt32 *features ) ;
508 virtual OSStatus GetRegion( ControlPartCode partCode , RgnHandle region ) ;
509 virtual OSStatus SetZOrder( bool above , wxMacControl* other ) ;
510 // to be moved into a databrowser subclass
511
512 virtual OSStatus SetSelectionFlags( DataBrowserSelectionFlags ) ;
513 virtual OSStatus AddListViewColumn( DataBrowserListViewColumnDesc *columnDesc,
514 DataBrowserTableViewColumnIndex position ) ;
515 virtual OSStatus AutoSizeListViewColumns() ;
516 virtual OSStatus SetHasScrollBars( bool horiz , bool vert ) ;
517 virtual OSStatus SetTableViewHiliteStyle( DataBrowserTableViewHiliteStyle hiliteStyle ) ;
518 virtual OSStatus SetListViewHeaderBtnHeight(UInt16 height) ;
519 virtual OSStatus SetCallbacks(const DataBrowserCallbacks * callbacks) ;
520 virtual OSStatus UpdateItems( DataBrowserItemID container, UInt32 numItems,
521 const DataBrowserItemID* items,
522 DataBrowserPropertyID preSortProperty,
523 DataBrowserPropertyID propertyID ) ;
524 virtual OSStatus AddItems( DataBrowserItemID container, UInt32 numItems,
525 const DataBrowserItemID* items,
526 DataBrowserPropertyID preSortProperty ) ;
527 virtual OSStatus RemoveItems( DataBrowserItemID container, UInt32 numItems,
528 const DataBrowserItemID* items,
529 DataBrowserPropertyID preSortProperty ) ;
530 virtual OSStatus RevealItem( DataBrowserItemID item,
531 DataBrowserPropertyID propertyID,
532 DataBrowserRevealOptions options ) ;
533 virtual OSStatus GetSelectionAnchor( DataBrowserItemID * first, DataBrowserItemID * last ) ;
534 virtual bool IsItemSelected( DataBrowserItemID item ) ;
535 virtual OSStatus SetSelectedItems(UInt32 numItems,
536 const DataBrowserItemID * items,
537 DataBrowserSetOption operation ) ;
538
539 // to be moved into a tab control class
540
541 virtual OSStatus SetTabEnabled( SInt16 tabNo , bool enable ) ;
542protected :
543 ControlRef m_controlRef ;
544 wxFont m_font ;
545 long m_windowStyle ;
546} ;
547
548#if wxMAC_USE_CORE_GRAPHICS
549
550class WXDLLEXPORT wxMacCGPath : public wxGraphicPath
551{
552 DECLARE_NO_COPY_CLASS(wxMacCGPath)
553public :
554 wxMacCGPath() ;
555 ~wxMacCGPath() ;
556
557 // Starts a new subpath at
558 void MoveToPoint( wxCoord x1 , wxCoord y1 ) ;
559 void AddLineToPoint( wxCoord x1 , wxCoord y1 ) ;
560 void AddRectangle( wxCoord x, wxCoord y, wxCoord w, wxCoord h ) ;
561 void AddCircle( wxCoord x, wxCoord y , wxCoord r ) ;
562
563 // closes the current subpath
564 void CloseSubpath() ;
565
566 CGPathRef GetPath() const ;
567private :
568 CGMutablePathRef m_path ;
569} ;
570
571class WXDLLEXPORT wxMacCGContext : public wxGraphicContext
572{
573 DECLARE_NO_COPY_CLASS(wxMacCGContext)
574
575public:
576 wxMacCGContext( CGrafPtr port ) ;
577 wxMacCGContext( CGContextRef cgcontext ) ;
578 wxMacCGContext() ;
579 ~wxMacCGContext() ;
580
581 virtual void Clip( const wxRegion &region ) ;
582 virtual void StrokePath( const wxGraphicPath *p ) ;
583 virtual void DrawPath( const wxGraphicPath *p , int fillStyle = wxWINDING_RULE ) ;
584 virtual void FillPath( const wxGraphicPath *p , const wxColor &fillColor , int fillStyle = wxWINDING_RULE ) ;
585
586 virtual wxGraphicPath* CreatePath() ;
587 virtual void SetPen( const wxPen &pen ) ;
588 virtual void SetBrush( const wxBrush &brush ) ;
589 CGContextRef GetNativeContext() ;
590 void SetNativeContext( CGContextRef cg ) ;
591 CGPathDrawingMode GetDrawingMode() const { return m_mode ; }
592private:
593 CGContextRef m_cgContext ;
594 CGrafPtr m_qdPort ;
595 CGPathDrawingMode m_mode ;
596 wxPen m_pen ;
597 wxBrush m_brush ;
598} ;
599
600CGColorSpaceRef wxMacGetGenericRGBColorSpace(void) ;
601void wxMacMemoryBufferReleaseProc(void *info, const void *data, size_t size) ;
602
603#endif // wxMAC_USE_CORE_GRAPHICS
604
605class WXDLLEXPORT wxBitmapRefData: public wxGDIRefData
606{
607 DECLARE_NO_COPY_CLASS(wxBitmapRefData)
608
609 friend class WXDLLEXPORT wxIcon;
610 friend class WXDLLEXPORT wxCursor;
611public:
612 wxBitmapRefData(int width , int height , int depth);
613 wxBitmapRefData();
614 ~wxBitmapRefData();
615
616 void Free() ;
617 bool Ok() const { return m_ok ; }
618 void SetOk( bool isOk) { m_ok = isOk ; }
619
620 void SetWidth( int width ) { m_width = width ; }
621 void SetHeight( int height ) { m_height = height ; }
622 void SetDepth( int depth ) { m_depth = depth ; }
623
624 int GetWidth() const { return m_width ; }
625 int GetHeight() const { return m_height ; }
626 int GetDepth() const { return m_depth ; }
627
628 void *GetRawAccess() const ;
629 void *BeginRawAccess() ;
630 void EndRawAccess() ;
631
632 bool HasAlpha() const { return m_hasAlpha ; }
633 void UseAlpha( bool useAlpha ) ;
634
635public:
636#if wxUSE_PALETTE
637 wxPalette m_bitmapPalette;
638#endif // wxUSE_PALETTE
639
640 wxMask * m_bitmapMask; // Optional mask
641#if wxMAC_USE_CORE_GRAPHICS
642 CGImageRef CGImageCreate() const ;
643#endif
644 GWorldPtr GetHBITMAP(GWorldPtr * mask = NULL ) const ;
645 void UpdateAlphaMask() const ;
646
647private :
648 bool Create(int width , int height , int depth) ;
649 void Init() ;
650
651 int m_width;
652 int m_height;
653 int m_bytesPerRow ;
654 int m_depth;
655 bool m_hasAlpha;
656 wxMemoryBuffer m_memBuf ;
657 int m_rawAccessCount ;
658 bool m_ok;
659#if wxMAC_USE_CORE_GRAPHICS
660 mutable CGImageRef m_cgImageRef ;
661#endif
662 GWorldPtr m_hBitmap;
663 GWorldPtr m_hMaskBitmap ;
664 wxMemoryBuffer m_maskMemBuf ;
665 int m_maskBytesPerRow ;
666};
667
668#define M_BITMAPDATA ((wxBitmapRefData *)m_refData)
669
670class WXDLLEXPORT wxIconRefData : public wxGDIRefData
671{
672public:
673 wxIconRefData() ;
674 wxIconRefData( WXHICON ) ;
675 virtual ~wxIconRefData() { Free(); }
676
677 void Init() ;
678 virtual void Free();
679 WXHICON GetHICON() const { return (WXHICON) m_iconRef ; }
680private :
681 IconRef m_iconRef ;
682};
683
684#endif // wxUSE_GUI
685
686//---------------------------------------------------------------------------
687// wxMac string conversions
688//---------------------------------------------------------------------------
689
690void wxMacSetupConverters() ;
691void wxMacCleanupConverters() ;
692
693void wxMacStringToPascal( const wxString&from , StringPtr to ) ;
694wxString wxMacMakeStringFromPascal( ConstStringPtr from ) ;
695
696// toplevel.cpp
697
698ControlRef wxMacFindControlUnderMouse( Point location , WindowRef window , ControlPartCode *outPart ) ;
699
700// filefn.cpp
701
702wxString wxMacFSRefToPath( const FSRef *fsRef , CFStringRef additionalPathComponent = NULL ) ;
703OSStatus wxMacPathToFSRef( const wxString&path , FSRef *fsRef ) ;
704wxString wxMacHFSUniStrToString( ConstHFSUniStr255Param uniname ) ;
705
706#endif
707 // _WX_PRIVATE_H_