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