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