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