]> git.saurik.com Git - wxWidgets.git/blob - include/wx/mac/carbon/private.h
added assert to verify that operands are initialized in compatibility_iterator::opera...
[wxWidgets.git] / include / wx / mac / carbon / private.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/mac/carbon/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 template<> inline EventParamType wxMacGetEventParamType<SInt16>() { return typeSInt16 ; }
220 template<> inline EventParamType wxMacGetEventParamType<SInt32>() { return typeSInt32 ; }
221 template<> inline EventParamType wxMacGetEventParamType<UInt32>() { return typeUInt32 ; }
222 template<> inline EventParamType wxMacGetEventParamType<RGBColor>() { return typeRGBColor ; }
223 #if TARGET_API_MAC_OSX
224 template<> inline EventParamType wxMacGetEventParamType<HICommand>() { return typeHICommand ; }
225 template<> inline EventParamType wxMacGetEventParamType<HIPoint>() { return typeHIPoint ; }
226 template<> inline EventParamType wxMacGetEventParamType<HISize>() { return typeHISize ; }
227 template<> inline EventParamType wxMacGetEventParamType<HIRect>() { return typeHIRect ; }
228 template<> inline EventParamType wxMacGetEventParamType<void*>() { return typeVoidPtr ; }
229 #endif
230 template<> inline EventParamType wxMacGetEventParamType<CFDictionaryRef>() { return typeCFDictionaryRef ; }
231 template<> inline EventParamType wxMacGetEventParamType<Collection>() { return typeCollection ; }
232 template<> inline EventParamType wxMacGetEventParamType<CGContextRef>() { return typeCGContextRef ; }
233 /*
234 These are ambiguous
235 template<> EventParamType wxMacGetEventParamType<GrafPtr>() { return typeGrafPtr ; }
236 template<> EventParamType wxMacGetEventParamType<OSStatus>() { return typeOSStatus ; }
237 template<> EventParamType wxMacGetEventParamType<CFIndex>() { return typeCFIndex ; }
238 template<> EventParamType wxMacGetEventParamType<GWorldPtr>() { return typeGWorldPtr ; }
239 */
240
241 class wxMacCarbonEvent
242 {
243
244 public :
245 wxMacCarbonEvent()
246 {
247 m_eventRef = 0 ;
248 m_release = false ;
249 }
250
251 wxMacCarbonEvent( EventRef event , bool release = false )
252 {
253 m_eventRef = event ;
254 m_release = release ;
255 }
256
257 wxMacCarbonEvent(UInt32 inClassID,UInt32 inKind,EventTime inWhen = 0 /*now*/,EventAttributes inAttributes=kEventAttributeNone)
258 {
259 m_eventRef = NULL ;
260 verify_noerr( MacCreateEvent( NULL , inClassID, inKind,inWhen,inAttributes,&m_eventRef) ) ;
261 m_release = true ;
262 }
263
264 ~wxMacCarbonEvent()
265 {
266 if ( m_release )
267 ReleaseEvent( m_eventRef ) ;
268 }
269
270 OSStatus Create(UInt32 inClassID,UInt32 inKind,EventTime inWhen = 0 /*now*/,EventAttributes inAttributes=kEventAttributeNone)
271 {
272 verify( (m_eventRef == NULL) || m_release ) ;
273 if ( m_eventRef && m_release )
274 {
275 ReleaseEvent( m_eventRef ) ;
276 m_release = false ;
277 m_eventRef = NULL ;
278 }
279 OSStatus err = MacCreateEvent( NULL , inClassID, inKind,inWhen,inAttributes,&m_eventRef) ;
280 if ( err == noErr )
281 m_release = true ;
282 return err ;
283 }
284
285 OSStatus GetParameter( EventParamName inName, EventParamType inDesiredType, UInt32 inBufferSize, void * outData) ;
286
287 template <typename T> OSStatus GetParameter( EventParamName inName, EventParamType type , T *data )
288 {
289 return GetParameter( inName, type , sizeof( T ) , data ) ;
290 }
291 template <typename T> OSStatus GetParameter( EventParamName inName, T *data )
292 {
293 return GetParameter<T>( inName, wxMacGetEventParamType<T>() , data ) ;
294 }
295
296 template <typename T> T GetParameter( EventParamName inName )
297 {
298 T value ;
299 verify_noerr( GetParameter<T>( inName, &value ) ) ;
300 return value ;
301 }
302 template <typename T> T GetParameter( EventParamName inName, EventParamType inDesiredType )
303 {
304 T value ;
305 verify_noerr( GetParameter<T>( inName, inDesiredType , &value ) ) ;
306 return value ;
307 }
308
309 OSStatus SetParameter( EventParamName inName, EventParamType inType, UInt32 inSize, const void * inData) ;
310 template <typename T> OSStatus SetParameter( EventParamName inName, EventParamType inDesiredType , const T *data )
311 {
312 return SetParameter( inName, inDesiredType , sizeof( T ) , data ) ;
313 }
314 template <typename T> OSStatus SetParameter( EventParamName inName, EventParamType inDesiredType , const T& data )
315 {
316 return SetParameter<T>( inName, inDesiredType , &data ) ;
317 }
318 template <typename T> OSStatus SetParameter( EventParamName inName, const T *data )
319 {
320 return SetParameter<T>( inName, wxMacGetEventParamType<T>() , data ) ;
321 }
322 template <typename T> OSStatus SetParameter( EventParamName inName, const T& data )
323 {
324 return SetParameter<T>( inName, wxMacGetEventParamType<T>() , &data ) ;
325 }
326 UInt32 GetClass()
327 {
328 return ::GetEventClass( m_eventRef ) ;
329 }
330 UInt32 GetKind()
331 {
332 return ::GetEventKind( m_eventRef ) ;
333 }
334 EventTime GetTime()
335 {
336 return ::GetEventTime( m_eventRef ) ;
337 }
338 UInt32 GetTicks()
339 {
340 return EventTimeToTicks( GetTime() ) ;
341 }
342 OSStatus SetCurrentTime( )
343 {
344 return ::SetEventTime( m_eventRef , GetCurrentEventTime() ) ;
345 }
346 OSStatus SetTime( EventTime when )
347 {
348 return ::SetEventTime( m_eventRef , when ) ;
349 }
350 operator EventRef () { return m_eventRef; }
351
352 bool IsValid() { return m_eventRef != 0 ; }
353 protected :
354 EventRef m_eventRef ;
355 bool m_release ;
356 } ;
357
358 //
359 // helper class for allocating and deallocating Universal Proc Ptrs
360 //
361
362 template <typename procType, typename uppType , uppType (*newUPP)(procType) , void (*disposeUPP)(uppType) > class wxMacUPP
363 {
364 public :
365 wxMacUPP( procType proc )
366 {
367 m_upp = NULL ;
368 m_upp = (*newUPP)( NULL ) ;
369 }
370 ~wxMacUPP()
371 {
372 if ( m_upp )
373 disposeUPP( m_upp ) ;
374 }
375 operator uppType() { return m_upp ; }
376 private :
377 uppType m_upp ;
378 } ;
379
380 typedef wxMacUPP<NMProcPtr,NMUPP,NewNMUPP,DisposeNMUPP> wxMacNMUPP ;
381
382 template <typename refType> class wxMacCFRefHolder
383 {
384 public :
385 wxMacCFRefHolder()
386 : m_ref(NULL) , m_release(false)
387 {
388 }
389
390 wxMacCFRefHolder( refType ref , bool release = true )
391 : m_ref(ref) , m_release(release)
392 {
393 }
394
395 ~wxMacCFRefHolder()
396 {
397 CFRelease( m_ref ) ;
398 }
399
400 void Release()
401 {
402 if ( m_release && m_ref != NULL )
403 CFRelease( m_ref ) ;
404 m_ref = NULL ;
405 }
406
407 refType Detach()
408 {
409 refType val = m_ref ;
410 m_release = false ;
411 m_ref = NULL ;
412 return val ;
413 }
414
415 void Set( refType ref , bool release = true )
416 {
417 Release() ;
418 m_release = release ;
419 m_ref = ref ;
420 }
421
422 operator refType () const { return m_ref; }
423
424 private :
425 refType m_ref ;
426 bool m_release ;
427
428 DECLARE_NO_COPY_CLASS( wxMacCFRefHolder )
429 } ;
430
431 #if wxUSE_GUI
432 /*
433 GWorldPtr wxMacCreateGWorld( int width , int height , int depth ) ;
434 void wxMacDestroyGWorld( GWorldPtr gw ) ;
435 PicHandle wxMacCreatePict( GWorldPtr gw , GWorldPtr mask = NULL ) ;
436 CIconHandle wxMacCreateCIcon(GWorldPtr image , GWorldPtr mask , short dstDepth , short iconSize ) ;
437 void wxMacSetColorTableEntry( CTabHandle newColors , int index , int red , int green , int blue ) ;
438 CTabHandle wxMacCreateColorTable( int numColors ) ;
439 */
440 void wxMacCreateBitmapButton( ControlButtonContentInfo*info , const wxBitmap& bitmap , int forceType = 0 ) ;
441 void wxMacReleaseBitmapButton( ControlButtonContentInfo*info ) ;
442
443 #define MAC_WXCOLORREF(a) (*((RGBColor*)&(a)))
444 #define MAC_WXHBITMAP(a) (GWorldPtr(a))
445 #define MAC_WXHMETAFILE(a) (PicHandle(a))
446 #define MAC_WXHICON(a) (IconRef(a))
447 #define MAC_WXHCURSOR(a) (CursHandle(a))
448 #define MAC_WXHRGN(a) (RgnHandle(a))
449 #define MAC_WXHWND(a) (WindowPtr(a))
450 #define MAC_WXRECPTR(a) ((Rect*)a)
451 #define MAC_WXPOINTPTR(a) ((Point*)a)
452 #define MAC_WXHMENU(a) ((MenuHandle)a)
453
454 struct wxOpaqueWindowRef
455 {
456 wxOpaqueWindowRef( WindowRef ref ) { m_data = ref ; }
457 operator WindowRef() { return m_data ; }
458 private :
459 WindowRef m_data ;
460 } ;
461
462 void wxMacRectToNative( const wxRect *wx , Rect *n ) ;
463 void wxMacNativeToRect( const Rect *n , wxRect* wx ) ;
464 void wxMacPointToNative( const wxPoint* wx , Point *n ) ;
465 void wxMacNativeToPoint( const Point *n , wxPoint* wx ) ;
466
467 wxWindow * wxFindControlFromMacControl(ControlRef inControl ) ;
468 wxTopLevelWindowMac* wxFindWinFromMacWindow( WindowRef inWindow ) ;
469 wxMenu* wxFindMenuFromMacMenu(MenuRef inMenuRef) ;
470
471 int wxMacCommandToId( UInt32 macCommandId ) ;
472 UInt32 wxIdToMacCommand( int wxId ) ;
473 wxMenu* wxFindMenuFromMacCommand( const HICommand &macCommandId , wxMenuItem* &item ) ;
474
475 extern wxWindow* g_MacLastWindow ;
476 pascal OSStatus wxMacTopLevelMouseEventHandler( EventHandlerCallRef handler , EventRef event , void *data ) ;
477 Rect wxMacGetBoundsForControl( wxWindow* window , const wxPoint& pos , const wxSize &size , bool adjustForOrigin = true ) ;
478
479 ControlActionUPP GetwxMacLiveScrollbarActionProc() ;
480
481 class wxMacControl
482 {
483 public :
484 wxMacControl( wxWindow* peer , bool isRootControl = false ) ;
485 wxMacControl( wxWindow* peer , ControlRef control ) ;
486 wxMacControl( wxWindow* peer , WXWidget control ) ;
487 virtual ~wxMacControl() ;
488
489 void Init() ;
490
491 virtual void Dispose() ;
492
493 bool Ok() const { return GetControlRef() != NULL ; }
494
495 virtual ControlRef * GetControlRefAddr() { return &m_controlRef; }
496 virtual ControlRef GetControlRef() const { return m_controlRef ; }
497
498 virtual void SetReference( SInt32 data ) ;
499 /*
500 void operator= (ControlRef c) { m_controlRef = c ; }
501 operator ControlRef () { return m_controlRef; }
502 operator ControlRef * () { return &m_controlRef; }
503 */
504 // accessing data and values
505
506 virtual OSStatus SetData( ControlPartCode inPartCode , ResType inTag , Size inSize , const void * inData ) ;
507 virtual OSStatus GetData( ControlPartCode inPartCode , ResType inTag , Size inBufferSize , void * inOutBuffer , Size * outActualSize ) const ;
508 virtual OSStatus GetDataSize( ControlPartCode inPartCode , ResType inTag , Size * outActualSize ) const ;
509 virtual OSStatus SendEvent( EventRef ref , OptionBits inOptions = 0 ) ;
510 virtual OSStatus SendHICommand( HICommand &command , OptionBits inOptions = 0 ) ;
511
512 virtual OSStatus SendHICommand( UInt32 commandID , OptionBits inOptions = 0 ) ;
513
514 virtual SInt32 GetValue() const ;
515 virtual SInt32 GetMaximum() const ;
516 virtual SInt32 GetMinimum() const ;
517
518 virtual void SetValue( SInt32 v ) ;
519 virtual void SetMinimum( SInt32 v ) ;
520 virtual void SetMaximum( SInt32 v ) ;
521
522 virtual void SetValueAndRange( SInt32 value , SInt32 minimum , SInt32 maximum ) ;
523 virtual void SetRange( SInt32 minimum , SInt32 maximum ) ;
524
525 virtual OSStatus SetFocus( ControlFocusPart focusPart ) ;
526 virtual bool HasFocus() const ;
527 virtual bool NeedsFocusRect() const ;
528 virtual void SetNeedsFocusRect( bool needs ) ;
529
530 // templated helpers
531
532 Size GetDataSize( ControlPartCode inPartCode , ResType inTag ) const
533 {
534 Size sz ;
535 verify_noerr( GetDataSize( inPartCode , inTag , &sz ) ) ;
536 return sz ;
537 }
538 template <typename T> OSStatus SetData( ControlPartCode inPartCode , ResType inTag , const T *data )
539 {
540 return SetData( inPartCode , inTag , sizeof( T ) , data ) ;
541 }
542 template <typename T> OSStatus SetData( ControlPartCode inPartCode , ResType inTag , const T& data )
543 {
544 return SetData( inPartCode , inTag , sizeof( T ) , &data ) ;
545 }
546 template <typename T> OSStatus GetData( ControlPartCode inPartCode , ResType inTag , T *data ) const
547 {
548 Size dummy ;
549 return GetData( inPartCode , inTag , sizeof( T ) , data , &dummy ) ;
550 }
551 template <typename T> T GetData( ControlPartCode inPartCode , ResType inTag ) const
552 {
553 T value ;
554 verify_noerr( GetData<T>( inPartCode , inTag , &value ) ) ;
555 return value ;
556 }
557
558 // Flash the control for the specified amount of time
559 virtual void Flash( ControlPartCode part , UInt32 ticks = 8 ) ;
560
561 virtual void VisibilityChanged( bool shown ) ;
562 virtual void SuperChangedPosition() ;
563
564
565 virtual void SetFont( const wxFont & font , const wxColour& foreground , long windowStyle ) ;
566 virtual void SetBackground( const wxBrush &brush ) ;
567 virtual ControlPartCode HandleKey( SInt16 keyCode, SInt16 charCode, EventModifiers modifiers ) ;
568 void SetActionProc( ControlActionUPP actionProc ) ;
569 void SetViewSize( SInt32 viewSize ) ;
570 SInt32 GetViewSize() const ;
571
572 virtual bool IsVisible() const ;
573 virtual void SetVisibility( bool visible , bool redraw ) ;
574 virtual bool IsEnabled() const ;
575 virtual bool IsActive() const ;
576 virtual void Enable( bool enable ) ;
577
578 // invalidates this control and all children
579 virtual void InvalidateWithChildren() ;
580 virtual void SetDrawingEnabled( bool enable ) ;
581 #ifdef __WXMAC_OSX__
582 virtual bool GetNeedsDisplay() const ;
583 #endif
584 // where is in native window relative coordinates
585 virtual void SetNeedsDisplay( RgnHandle where ) ;
586 // where is in native window relative coordinates
587 virtual void SetNeedsDisplay( Rect* where = NULL ) ;
588
589 // if rect = NULL, entire view
590 virtual void ScrollRect( wxRect *rect , int dx , int dy ) ;
591
592 // in native parent window relative coordinates
593 virtual void GetRect( Rect *r ) ;
594
595 // in native parent window relative coordinates
596 virtual void SetRect( Rect *r ) ;
597
598 virtual void GetRectInWindowCoords( Rect *r ) ;
599 virtual void GetBestRect( Rect *r ) ;
600 virtual void SetLabel( const wxString &title ) ;
601 // converts from Toplevel-Content relative to local
602 static void Convert( wxPoint *pt , wxMacControl *convert , wxMacControl *to ) ;
603
604 virtual void GetFeatures( UInt32 *features ) ;
605 virtual OSStatus GetRegion( ControlPartCode partCode , RgnHandle region ) ;
606 virtual OSStatus SetZOrder( bool above , wxMacControl* other ) ;
607 // to be moved into a databrowser subclass
608
609 virtual OSStatus SetSelectionFlags( DataBrowserSelectionFlags ) ;
610 virtual OSStatus AddListViewColumn( DataBrowserListViewColumnDesc *columnDesc,
611 DataBrowserTableViewColumnIndex position ) ;
612 virtual OSStatus AutoSizeListViewColumns() ;
613 virtual OSStatus SetHasScrollBars( bool horiz , bool vert ) ;
614 virtual OSStatus SetTableViewHiliteStyle( DataBrowserTableViewHiliteStyle hiliteStyle ) ;
615 virtual OSStatus SetListViewHeaderBtnHeight(UInt16 height) ;
616 virtual OSStatus SetCallbacks(const DataBrowserCallbacks * callbacks) ;
617 virtual OSStatus UpdateItems( DataBrowserItemID container, UInt32 numItems,
618 const DataBrowserItemID* items,
619 DataBrowserPropertyID preSortProperty,
620 DataBrowserPropertyID propertyID ) ;
621 virtual OSStatus AddItems( DataBrowserItemID container, UInt32 numItems,
622 const DataBrowserItemID* items,
623 DataBrowserPropertyID preSortProperty ) ;
624 virtual OSStatus RemoveItems( DataBrowserItemID container, UInt32 numItems,
625 const DataBrowserItemID* items,
626 DataBrowserPropertyID preSortProperty ) ;
627 virtual OSStatus RevealItem( DataBrowserItemID item,
628 DataBrowserPropertyID propertyID,
629 DataBrowserRevealOptions options ) ;
630 virtual OSStatus GetSelectionAnchor( DataBrowserItemID * first, DataBrowserItemID * last ) ;
631 virtual bool IsItemSelected( DataBrowserItemID item ) ;
632 virtual OSStatus SetSelectedItems(UInt32 numItems,
633 const DataBrowserItemID * items,
634 DataBrowserSetOption operation ) ;
635
636 // to be moved into a tab control class
637
638 virtual OSStatus SetTabEnabled( SInt16 tabNo , bool enable ) ;
639 bool IsCompositing() { return m_isCompositing ; }
640 bool IsRootControl() { return m_isRootControl ; }
641 protected :
642 ControlRef m_controlRef ;
643 wxFont m_font ;
644 long m_windowStyle ;
645 wxWindow* m_peer ;
646 bool m_needsFocusRect ;
647 bool m_isCompositing ;
648 bool m_isRootControl ;
649 } ;
650
651 #if wxMAC_USE_CORE_GRAPHICS
652
653 class WXDLLEXPORT wxMacCGPath : public wxGraphicPath
654 {
655 DECLARE_NO_COPY_CLASS(wxMacCGPath)
656 public :
657 wxMacCGPath() ;
658 ~wxMacCGPath() ;
659
660 // Starts a new subpath at
661 void MoveToPoint( wxCoord x1 , wxCoord y1 ) ;
662 void AddLineToPoint( wxCoord x1 , wxCoord y1 ) ;
663 void AddQuadCurveToPoint( wxCoord cx1, wxCoord cy1, wxCoord x1, wxCoord y1 ) ;
664 void AddRectangle( wxCoord x, wxCoord y, wxCoord w, wxCoord h ) ;
665 void AddCircle( wxCoord x, wxCoord y , wxCoord r ) ;
666
667 // closes the current subpath
668 void CloseSubpath() ;
669
670 CGPathRef GetPath() const ;
671 private :
672 CGMutablePathRef m_path ;
673 } ;
674
675 class WXDLLEXPORT wxMacCGContext : public wxGraphicContext
676 {
677 DECLARE_NO_COPY_CLASS(wxMacCGContext)
678
679 public:
680 wxMacCGContext( CGrafPtr port ) ;
681 wxMacCGContext( CGContextRef cgcontext ) ;
682 wxMacCGContext() ;
683 ~wxMacCGContext() ;
684
685 virtual void Clip( const wxRegion &region ) ;
686 virtual void StrokePath( const wxGraphicPath *p ) ;
687 virtual void DrawPath( const wxGraphicPath *p , int fillStyle = wxWINDING_RULE ) ;
688 virtual void FillPath( const wxGraphicPath *p , const wxColor &fillColor , int fillStyle = wxWINDING_RULE ) ;
689
690 virtual wxGraphicPath* CreatePath() ;
691 virtual void SetPen( const wxPen &pen ) ;
692 virtual void SetBrush( const wxBrush &brush ) ;
693 CGContextRef GetNativeContext() ;
694 void SetNativeContext( CGContextRef cg ) ;
695 CGPathDrawingMode GetDrawingMode() const { return m_mode ; }
696 private:
697 CGContextRef m_cgContext ;
698 CGrafPtr m_qdPort ;
699 CGPathDrawingMode m_mode ;
700 wxPen m_pen ;
701 wxBrush m_brush ;
702 } ;
703
704 #endif // wxMAC_USE_CORE_GRAPHICS
705
706 #ifdef __WXMAC_OSX__
707
708 CGColorSpaceRef wxMacGetGenericRGBColorSpace(void) ;
709 void wxMacMemoryBufferReleaseProc(void *info, const void *data, size_t size) ;
710
711 #endif
712
713 class WXDLLEXPORT wxBitmapRefData: public wxGDIRefData
714 {
715 DECLARE_NO_COPY_CLASS(wxBitmapRefData)
716
717 friend class WXDLLEXPORT wxIcon;
718 friend class WXDLLEXPORT wxCursor;
719 public:
720 wxBitmapRefData(int width , int height , int depth);
721 wxBitmapRefData();
722 ~wxBitmapRefData();
723
724 void Free() ;
725 bool Ok() const { return m_ok ; }
726 void SetOk( bool isOk) { m_ok = isOk ; }
727
728 void SetWidth( int width ) { m_width = width ; }
729 void SetHeight( int height ) { m_height = height ; }
730 void SetDepth( int depth ) { m_depth = depth ; }
731
732 int GetWidth() const { return m_width ; }
733 int GetHeight() const { return m_height ; }
734 int GetDepth() const { return m_depth ; }
735
736 void *GetRawAccess() const ;
737 void *BeginRawAccess() ;
738 void EndRawAccess() ;
739
740 bool HasAlpha() const { return m_hasAlpha ; }
741 void UseAlpha( bool useAlpha ) ;
742
743 public:
744 #if wxUSE_PALETTE
745 wxPalette m_bitmapPalette;
746 #endif // wxUSE_PALETTE
747
748 wxMask * m_bitmapMask; // Optional mask
749 #ifdef __WXMAC_OSX__
750 CGImageRef CGImageCreate() const ;
751 #endif
752
753 // returns true if the bitmap has a size that
754 // can be natively transferred into a true icon
755 // if no is returned GetIconRef will still produce
756 // an icon but it will be generated via a PICT and
757 // rescaled to 16 x 16
758 bool HasNativeSize() ;
759
760 // caller should increase ref count if needed longer
761 // than the bitmap exists
762 IconRef GetIconRef() ;
763
764 // returns a Pict from the bitmap content
765 PicHandle GetPictHandle() ;
766 GWorldPtr GetHBITMAP(GWorldPtr * mask = NULL ) const ;
767 void UpdateAlphaMask() const ;
768
769 private :
770 bool Create(int width , int height , int depth) ;
771 void Init() ;
772
773 int m_width;
774 int m_height;
775 int m_bytesPerRow ;
776 int m_depth;
777 bool m_hasAlpha;
778 wxMemoryBuffer m_memBuf ;
779 int m_rawAccessCount ;
780 bool m_ok;
781 #ifdef __WXMAC_OSX__
782 mutable CGImageRef m_cgImageRef ;
783 #endif
784 IconRef m_iconRef ;
785 PicHandle m_pictHandle ;
786 GWorldPtr m_hBitmap;
787 GWorldPtr m_hMaskBitmap ;
788 wxMemoryBuffer m_maskMemBuf ;
789 int m_maskBytesPerRow ;
790 };
791
792 class WXDLLEXPORT wxIconRefData : public wxGDIRefData
793 {
794 public:
795 wxIconRefData() ;
796 wxIconRefData( WXHICON ) ;
797 virtual ~wxIconRefData() { Free(); }
798
799 void Init() ;
800 virtual void Free();
801
802 void SetWidth( int width ) { m_width = width ; }
803 void SetHeight( int height ) { m_height = height ; }
804
805 int GetWidth() const { return m_width ; }
806 int GetHeight() const { return m_height ; }
807
808 WXHICON GetHICON() const { return (WXHICON) m_iconRef ; }
809 private :
810 IconRef m_iconRef ;
811 int m_width ;
812 int m_height ;
813 };
814
815 // toplevel.cpp
816
817 ControlRef wxMacFindControlUnderMouse( wxTopLevelWindowMac* toplevelWindow, const Point& location , WindowRef window , ControlPartCode *outPart ) ;
818
819 #if WORDS_BIGENDIAN
820 inline Rect* wxMacGetPictureBounds( PicHandle pict , Rect* rect )
821 {
822 *rect = (**pict).picFrame ;
823 return rect ;
824 }
825 #else
826 inline Rect* wxMacGetPictureBounds( PicHandle pict , Rect* rect )
827 {
828 return QDGetPictureBounds( pict , rect ) ;
829 }
830 #endif
831
832 #endif // wxUSE_GUI
833
834 #define wxMAC_DEFINE_PROC_GETTER( UPP , x ) \
835 UPP Get##x() \
836 { \
837 static UPP sHandler = NULL; \
838 if ( sHandler == NULL ) \
839 sHandler = New##UPP( x ); \
840 return sHandler; \
841 }
842
843 //---------------------------------------------------------------------------
844 // wxMac string conversions
845 //---------------------------------------------------------------------------
846
847 void wxMacSetupConverters() ;
848 void wxMacCleanupConverters() ;
849
850 void wxMacStringToPascal( const wxString&from , StringPtr to ) ;
851 wxString wxMacMakeStringFromPascal( ConstStringPtr from ) ;
852
853 // filefn.cpp
854
855 wxString wxMacFSRefToPath( const FSRef *fsRef , CFStringRef additionalPathComponent = NULL ) ;
856 OSStatus wxMacPathToFSRef( const wxString&path , FSRef *fsRef ) ;
857 wxString wxMacHFSUniStrToString( ConstHFSUniStr255Param uniname ) ;
858
859 #endif
860 // _WX_PRIVATE_H_