]> git.saurik.com Git - wxWidgets.git/blob - include/wx/mac/carbon/private.h
Mac Core Graphics Implementation
[wxWidgets.git] / include / wx / mac / carbon / private.h
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
48 inline Fixed IntToFixed( int inInt )
49 {
50 return (((SInt32) inInt) << 16);
51 }
52
53 inline 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
64 class wxMacPortStateHelper
65 {
66 DECLARE_NO_COPY_CLASS(wxMacPortStateHelper)
67
68 public:
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
78 private:
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
89 class WXDLLEXPORT wxMacPortSaver
90 {
91 DECLARE_NO_COPY_CLASS(wxMacPortSaver)
92
93 public:
94 wxMacPortSaver( GrafPtr port )
95 {
96 ::GetPort( &m_port ) ;
97 ::SetPort( port ) ;
98 }
99 ~wxMacPortSaver()
100 {
101 ::SetPort( m_port ) ;
102 }
103 private :
104 GrafPtr m_port ;
105 } ;
106
107 class WXDLLEXPORT wxMacPortSetter
108 {
109 DECLARE_NO_COPY_CLASS(wxMacPortSetter)
110
111 public:
112 wxMacPortSetter( const wxDC* dc ) ;
113 ~wxMacPortSetter() ;
114 private:
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
123 class WXDLLEXPORT wxMacWindowClipper : public wxMacPortSaver
124 {
125 DECLARE_NO_COPY_CLASS(wxMacWindowClipper)
126
127 public:
128 wxMacWindowClipper( const wxWindow* win ) ;
129 ~wxMacWindowClipper() ;
130 private:
131 GrafPtr m_newPort ;
132 RgnHandle m_formerClip ;
133 RgnHandle m_newClip ;
134 } ;
135
136 class WXDLLEXPORT wxMacWindowStateSaver : public wxMacWindowClipper
137 {
138 DECLARE_NO_COPY_CLASS(wxMacWindowStateSaver)
139
140 public:
141 wxMacWindowStateSaver( const wxWindow* win ) ;
142 ~wxMacWindowStateSaver() ;
143 private:
144 GrafPtr m_newPort ;
145 ThemeDrawingState m_themeDrawingState ;
146 } ;
147
148 /*
149 class wxMacDrawingHelper
150 {
151 DECLARE_NO_COPY_CLASS(wxMacDrawingHelper)
152
153 public:
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 ; }
161 private:
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
171 bool wxMacConvertEventToRecord( EventRef event , EventRecord *rec) ;
172
173 #endif // wxUSE_GUI
174
175 // filefn.h
176 WXDLLEXPORT wxString wxMacFSSpec2MacFilename( const FSSpec *spec ) ;
177 WXDLLEXPORT void wxMacFilename2FSSpec( const wxString &path , FSSpec *spec ) ;
178
179 // utils.h
180 WXDLLEXPORT wxString wxMacFindFolder(short vRefNum,
181 OSType folderType,
182 Boolean createFolder);
183
184 template<typename T> EventParamType wxMacGetEventParamType() { wxFAIL_MSG( wxT("Unknown Param Type") ) ; return 0 ; }
185 template<> inline EventParamType wxMacGetEventParamType<RgnHandle>() { return typeQDRgnHandle ; }
186 template<> inline EventParamType wxMacGetEventParamType<ControlRef>() { return typeControlRef ; }
187 template<> inline EventParamType wxMacGetEventParamType<WindowRef>() { return typeWindowRef ; }
188 template<> inline EventParamType wxMacGetEventParamType<MenuRef>() { return typeMenuRef ; }
189 template<> inline EventParamType wxMacGetEventParamType<EventRef>() { return typeEventRef ; }
190 template<> inline EventParamType wxMacGetEventParamType<Point>() { return typeQDPoint ; }
191 template<> inline EventParamType wxMacGetEventParamType<Rect>() { return typeQDRectangle ; }
192 template<> inline EventParamType wxMacGetEventParamType<Boolean>() { return typeBoolean ; }
193 #if TARGET_API_MAC_OSX
194 template<> inline EventParamType wxMacGetEventParamType<HICommand>() { return typeHICommand ; }
195 template<> inline EventParamType wxMacGetEventParamType<HIPoint>() { return typeHIPoint ; }
196 template<> inline EventParamType wxMacGetEventParamType<HISize>() { return typeHISize ; }
197 template<> inline EventParamType wxMacGetEventParamType<HIRect>() { return typeHIRect ; }
198 template<> inline EventParamType wxMacGetEventParamType<void*>() { return typeVoidPtr ; }
199 #endif
200 template<> inline EventParamType wxMacGetEventParamType<Collection>() { return typeCollection ; }
201 template<> 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
210 class wxMacCarbonEvent
211 {
212
213 public :
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 ; }
319 protected :
320 EventRef m_eventRef ;
321 bool m_release ;
322 } ;
323
324 //
325 // helper class for allocating and deallocating Universal Proc Ptrs
326 //
327
328 template <typename procType, typename uppType , uppType (*newUPP)(procType) , void (*disposeUPP)(uppType) > class wxMacUPP
329 {
330 public :
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 ; }
342 private :
343 uppType m_upp ;
344 } ;
345
346 typedef wxMacUPP<NMProcPtr,NMUPP,NewNMUPP,DisposeNMUPP> wxMacNMUPP ;
347
348 #if wxUSE_GUI
349 /*
350 GWorldPtr wxMacCreateGWorld( int width , int height , int depth ) ;
351 void wxMacDestroyGWorld( GWorldPtr gw ) ;
352 PicHandle wxMacCreatePict( GWorldPtr gw , GWorldPtr mask = NULL ) ;
353 CIconHandle wxMacCreateCIcon(GWorldPtr image , GWorldPtr mask , short dstDepth , short iconSize ) ;
354 void wxMacSetColorTableEntry( CTabHandle newColors , int index , int red , int green , int blue ) ;
355 CTabHandle wxMacCreateColorTable( int numColors ) ;
356 */
357 IconRef wxMacCreateIconRef(const wxBitmap& bmp) ;
358 void wxMacCreateBitmapButton( ControlButtonContentInfo*info , const wxBitmap& bitmap , int forceType = 0 ) ;
359 void wxMacReleaseBitmapButton( ControlButtonContentInfo*info ) ;
360
361 #define MAC_WXCOLORREF(a) (*((RGBColor*)&(a)))
362 #define MAC_WXHBITMAP(a) (GWorldPtr(a))
363 #define MAC_WXHMETAFILE(a) (PicHandle(a))
364 #define MAC_WXHICON(a) (IconRef(a))
365 #define MAC_WXHCURSOR(a) (CursHandle(a))
366 #define MAC_WXHRGN(a) (RgnHandle(a))
367 #define MAC_WXHWND(a) (WindowPtr(a))
368 #define MAC_WXRECPTR(a) ((Rect*)a)
369 #define MAC_WXPOINTPTR(a) ((Point*)a)
370 #define MAC_WXHMENU(a) ((MenuHandle)a)
371
372 struct wxOpaqueWindowRef
373 {
374 wxOpaqueWindowRef( WindowRef ref ) { m_data = ref ; }
375 operator WindowRef() { return m_data ; }
376 private :
377 WindowRef m_data ;
378 } ;
379
380 wxWindow * wxFindControlFromMacControl(ControlRef inControl ) ;
381 wxTopLevelWindowMac* wxFindWinFromMacWindow( WindowRef inWindow ) ;
382 wxMenu* wxFindMenuFromMacMenu(MenuRef inMenuRef) ;
383
384 extern wxWindow* g_MacLastWindow ;
385 pascal OSStatus wxMacTopLevelMouseEventHandler( EventHandlerCallRef handler , EventRef event , void *data ) ;
386 Rect wxMacGetBoundsForControl( wxWindow* window , const wxPoint& pos , const wxSize &size , bool adjustForOrigin = true ) ;
387
388 class wxMacControl
389 {
390 public :
391 wxMacControl()
392 {
393 m_controlRef = NULL ;
394 }
395
396 wxMacControl( ControlRef control )
397 {
398 m_controlRef = control ;
399 }
400 wxMacControl( WXWidget control )
401 {
402 m_controlRef = (ControlRef) control ;
403 }
404 virtual ~wxMacControl()
405 {
406 }
407
408 virtual void Dispose() ;
409
410 bool Ok() const { return GetControlRef() != NULL ; }
411
412 virtual ControlRef * GetControlRefAddr() { return &m_controlRef; }
413 virtual ControlRef GetControlRef() const { return m_controlRef ; }
414
415 virtual void SetReference( SInt32 data ) ;
416 /*
417 void operator= (ControlRef c) { m_controlRef = c ; }
418 operator ControlRef () { return m_controlRef; }
419 operator ControlRef * () { return &m_controlRef; }
420 */
421 // accessing data and values
422
423 virtual OSStatus SetData( ControlPartCode inPartCode , ResType inTag , Size inSize , const void * inData ) ;
424 virtual OSStatus GetData( ControlPartCode inPartCode , ResType inTag , Size inBufferSize , void * inOutBuffer , Size * outActualSize ) const ;
425 virtual OSStatus GetDataSize( ControlPartCode inPartCode , ResType inTag , Size * outActualSize ) const ;
426 virtual OSStatus SendEvent( EventRef ref , OptionBits inOptions = 0 ) ;
427 virtual OSStatus SendHICommand( HICommand &command , OptionBits inOptions = 0 ) ;
428
429 virtual OSStatus SendHICommand( UInt32 commandID , OptionBits inOptions = 0 ) ;
430
431 virtual SInt32 GetValue() const ;
432 virtual SInt32 GetMaximum() const ;
433 virtual SInt32 GetMinimum() const ;
434
435 virtual void SetValue( SInt32 v ) ;
436 virtual void SetMinimum( SInt32 v ) ;
437 virtual void SetMaximum( SInt32 v ) ;
438
439 virtual void SetValueAndRange( SInt32 value , SInt32 minimum , SInt32 maximum ) ;
440 virtual void SetRange( SInt32 minimum , SInt32 maximum ) ;
441
442 virtual OSStatus SetFocus( ControlFocusPart focusPart ) ;
443 virtual bool HasFocus() const ;
444 virtual bool NeedsFocusRect() const ;
445
446 // templated helpers
447
448 Size GetDataSize( ControlPartCode inPartCode , ResType inTag ) const
449 {
450 Size sz ;
451 verify_noerr( GetDataSize( inPartCode , inTag , &sz ) ) ;
452 return sz ;
453 }
454 template <typename T> OSStatus SetData( ControlPartCode inPartCode , ResType inTag , const T *data )
455 {
456 return SetData( inPartCode , inTag , sizeof( T ) , data ) ;
457 }
458 template <typename T> OSStatus SetData( ControlPartCode inPartCode , ResType inTag , const T& data )
459 {
460 return SetData( inPartCode , inTag , sizeof( T ) , &data ) ;
461 }
462 template <typename T> OSStatus GetData( ControlPartCode inPartCode , ResType inTag , T *data ) const
463 {
464 Size dummy ;
465 return GetData( inPartCode , inTag , sizeof( T ) , data , &dummy ) ;
466 }
467 template <typename T> T GetData( ControlPartCode inPartCode , ResType inTag ) const
468 {
469 T value ;
470 verify_noerr( GetData<T>( inPartCode , inTag , &value ) ) ;
471 return value ;
472 }
473
474 // Flash the control for the specified amount of time
475 virtual void Flash( ControlPartCode part , UInt32 ticks = 8 ) ;
476 virtual void VisibilityChanged( bool shown ) ;
477 virtual void SetFont( const wxFont & font , const wxColour& foreground , long windowStyle ) ;
478 virtual void SetBackground( const wxBrush &brush ) ;
479 virtual ControlPartCode HandleKey( SInt16 keyCode, SInt16 charCode, EventModifiers modifiers ) ;
480 void SetActionProc( ControlActionUPP actionProc ) ;
481 void SetViewSize( SInt32 viewSize ) ;
482 SInt32 GetViewSize() const ;
483
484 virtual bool IsVisible() const ;
485 virtual void SetVisibility( bool visible , bool redraw ) ;
486 virtual bool IsEnabled() const ;
487 virtual bool IsActive() const ;
488 virtual void Enable( bool enable ) ;
489
490 // invalidates this control and all children
491 virtual void InvalidateWithChildren() ;
492 virtual void SetDrawingEnabled( bool enable ) ;
493 virtual bool GetNeedsDisplay() const ;
494 virtual void SetNeedsDisplay( bool needsDisplay , RgnHandle where = NULL ) ;
495
496 virtual void ScrollRect( const wxRect &rect , int dx , int dy ) ;
497
498 virtual void GetRect( Rect *r ) ;
499 virtual void SetRect( Rect *r ) ;
500 virtual void GetRectInWindowCoords( Rect *r ) ;
501 virtual void GetBestRect( Rect *r ) ;
502 virtual void SetTitle( const wxString &title ) ;
503 // converts from Toplevel-Content relative to local
504 static void Convert( wxPoint *pt , wxMacControl *convert , wxMacControl *to ) ;
505
506 virtual void GetFeatures( UInt32 *features ) ;
507 virtual OSStatus GetRegion( ControlPartCode partCode , RgnHandle region ) ;
508 virtual OSStatus SetZOrder( bool above , wxMacControl* other ) ;
509 // to be moved into a databrowser subclass
510
511 virtual OSStatus SetSelectionFlags( DataBrowserSelectionFlags ) ;
512 virtual OSStatus AddListViewColumn( DataBrowserListViewColumnDesc *columnDesc,
513 DataBrowserTableViewColumnIndex position ) ;
514 virtual OSStatus AutoSizeListViewColumns() ;
515 virtual OSStatus SetHasScrollBars( bool horiz , bool vert ) ;
516 virtual OSStatus SetTableViewHiliteStyle( DataBrowserTableViewHiliteStyle hiliteStyle ) ;
517 virtual OSStatus SetListViewHeaderBtnHeight(UInt16 height) ;
518 virtual OSStatus SetCallbacks(const DataBrowserCallbacks * callbacks) ;
519 virtual OSStatus UpdateItems( DataBrowserItemID container, UInt32 numItems,
520 const DataBrowserItemID* items,
521 DataBrowserPropertyID preSortProperty,
522 DataBrowserPropertyID propertyID ) ;
523 virtual OSStatus AddItems( DataBrowserItemID container, UInt32 numItems,
524 const DataBrowserItemID* items,
525 DataBrowserPropertyID preSortProperty ) ;
526 virtual OSStatus RemoveItems( DataBrowserItemID container, UInt32 numItems,
527 const DataBrowserItemID* items,
528 DataBrowserPropertyID preSortProperty ) ;
529 virtual OSStatus RevealItem( DataBrowserItemID item,
530 DataBrowserPropertyID propertyID,
531 DataBrowserRevealOptions options ) ;
532 virtual OSStatus GetSelectionAnchor( DataBrowserItemID * first, DataBrowserItemID * last ) ;
533 virtual bool IsItemSelected( DataBrowserItemID item ) ;
534 virtual OSStatus SetSelectedItems(UInt32 numItems,
535 const DataBrowserItemID * items,
536 DataBrowserSetOption operation ) ;
537
538 // to be moved into a tab control class
539
540 virtual OSStatus SetTabEnabled( SInt16 tabNo , bool enable ) ;
541 protected :
542 ControlRef m_controlRef ;
543 wxFont m_font ;
544 long m_windowStyle ;
545 } ;
546
547 #if wxMAC_USE_CORE_GRAPHICS
548
549 class WXDLLEXPORT wxMacCGPath : public wxGraphicPath
550 {
551 DECLARE_NO_COPY_CLASS(wxMacCGPath)
552 public :
553 wxMacCGPath() ;
554 ~wxMacCGPath() ;
555
556 // Starts a new subpath at
557 void MoveToPoint( wxCoord x1 , wxCoord y1 ) ;
558 void AddLineToPoint( wxCoord x1 , wxCoord y1 ) ;
559 void AddRectangle( wxCoord x, wxCoord y, wxCoord w, wxCoord h ) ;
560 void AddCircle( wxCoord x, wxCoord y , wxCoord r ) ;
561
562 // closes the current subpath
563 void CloseSubpath() ;
564
565 CGPathRef GetPath() const ;
566 private :
567 CGMutablePathRef m_path ;
568 } ;
569
570 class WXDLLEXPORT wxMacCGContext : public wxGraphicContext
571 {
572 DECLARE_NO_COPY_CLASS(wxMacCGContext)
573
574 public:
575 wxMacCGContext( CGrafPtr port ) ;
576 wxMacCGContext( CGContextRef cgcontext ) ;
577 wxMacCGContext() ;
578 ~wxMacCGContext() ;
579
580 virtual void Clip( const wxRegion &region ) ;
581 virtual void StrokePath( const wxGraphicPath *p ) ;
582 virtual void DrawPath( const wxGraphicPath *p , int fillStyle = wxWINDING_RULE ) ;
583 virtual void FillPath( const wxGraphicPath *p , const wxColor &fillColor , int fillStyle = wxWINDING_RULE ) ;
584
585 virtual wxGraphicPath* CreatePath() ;
586 virtual void SetPen( const wxPen &pen ) ;
587 virtual void SetBrush( const wxBrush &brush ) ;
588 CGContextRef GetNativeContext() ;
589 void SetNativeContext( CGContextRef cg ) ;
590 CGPathDrawingMode GetDrawingMode() const { return m_mode ; }
591 private:
592 CGContextRef m_cgContext ;
593 CGrafPtr m_qdPort ;
594 CGPathDrawingMode m_mode ;
595 wxPen m_pen ;
596 wxBrush m_brush ;
597 } ;
598
599 CGColorSpaceRef wxMacGetGenericRGBColorSpace(void) ;
600
601 #endif // wxMAC_USE_CORE_GRAPHICS
602
603 class WXDLLEXPORT wxBitmapRefData: public wxGDIRefData
604 {
605 DECLARE_NO_COPY_CLASS(wxBitmapRefData)
606
607 friend class WXDLLEXPORT wxIcon;
608 friend class WXDLLEXPORT wxCursor;
609 public:
610 wxBitmapRefData(int width , int height , int depth);
611 wxBitmapRefData();
612 ~wxBitmapRefData();
613
614 void Free() ;
615 bool Ok() const { return m_ok ; }
616 void SetOk( bool isOk) { m_ok = isOk ; }
617
618 void SetWidth( int width ) { m_width = width ; }
619 void SetHeight( int height ) { m_height = height ; }
620 void SetDepth( int depth ) { m_depth = depth ; }
621
622 int GetWidth() const { return m_width ; }
623 int GetHeight() const { return m_height ; }
624 int GetDepth() const { return m_depth ; }
625
626 void *GetRawAccess() const ;
627 void *BeginRawAccess() ;
628 void EndRawAccess() ;
629
630 bool HasAlpha() const { return m_hasAlpha ; }
631 void UseAlpha( bool useAlpha ) ;
632
633 public:
634 #if wxUSE_PALETTE
635 wxPalette m_bitmapPalette;
636 #endif // wxUSE_PALETTE
637
638 wxMask * m_bitmapMask; // Optional mask
639 #if wxMAC_USE_CORE_GRAPHICS
640 CGImageRef CGImageCreate() const ;
641 #else
642 GWorldPtr GetHBITMAP(GWorldPtr * mask = NULL ) const ;
643 void UpdateAlphaMask() const ;
644 #endif
645 private :
646 bool Create(int width , int height , int depth) ;
647 void Init() ;
648
649 int m_width;
650 int m_height;
651 int m_bytesPerRow ;
652 int m_depth;
653 bool m_hasAlpha;
654 wxMemoryBuffer m_memBuf ;
655 int m_rawAccessCount ;
656 bool m_ok;
657 #if wxMAC_USE_CORE_GRAPHICS
658 mutable CGImageRef m_cgImageRef ;
659 #else
660 GWorldPtr m_hBitmap;
661 GWorldPtr m_hMaskBitmap ;
662 wxMemoryBuffer m_maskMemBuf ;
663 int m_maskBytesPerRow ;
664 #endif
665 };
666
667 #define M_BITMAPDATA ((wxBitmapRefData *)m_refData)
668
669 class WXDLLEXPORT wxIconRefData : public wxGDIRefData
670 {
671 public:
672 wxIconRefData() ;
673 wxIconRefData( WXHICON ) ;
674 virtual ~wxIconRefData() { Free(); }
675
676 void Init() ;
677 virtual void Free();
678 WXHICON GetHICON() const { return (WXHICON) m_iconRef ; }
679 private :
680 IconRef m_iconRef ;
681 };
682
683 #endif // wxUSE_GUI
684
685 //---------------------------------------------------------------------------
686 // wxMac string conversions
687 //---------------------------------------------------------------------------
688
689 void wxMacSetupConverters() ;
690 void wxMacCleanupConverters() ;
691
692 void wxMacStringToPascal( const wxString&from , StringPtr to ) ;
693 wxString wxMacMakeStringFromPascal( ConstStringPtr from ) ;
694
695 // toplevel.cpp
696
697 ControlRef wxMacFindControlUnderMouse( Point location , WindowRef window , ControlPartCode *outPart ) ;
698
699 // filefn.cpp
700
701 wxString wxMacFSRefToPath( const FSRef *fsRef , CFStringRef additionalPathComponent = NULL ) ;
702 OSStatus wxMacPathToFSRef( const wxString&path , FSRef *fsRef ) ;
703 wxString wxMacHFSUniStrToString( ConstHFSUniStr255Param uniname ) ;
704
705 #endif
706 // _WX_PRIVATE_H_