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