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