]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/mac/carbon/private.h
small fixes
[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
19#ifdef __DARWIN__
20# include <Carbon/Carbon.h>
21#else
22# include <Debugging.h>
23# include <Quickdraw.h>
24# include <Appearance.h>
25# include <Folders.h>
26# include <Controls.h>
27# include <ControlDefinitions.h>
28# include <LowMem.h>
29# include <Gestalt.h>
30# include <FixMath.h>
31# include <CoreServices.h>
32#endif
33
34#if UNIVERSAL_INTERFACES_VERSION < 0x0342
35 #error "please update to Apple's latest 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#ifndef MAC_OS_X_VERSION_10_5
47 #define MAC_OS_X_VERSION_10_5 1050
48#endif
49
50#ifdef __WXMAC_CARBON__
51#include "wx/mac/corefoundation/cfstring.h"
52#include "wx/mac/corefoundation/cfdataref.h"
53#endif
54
55#ifndef FixedToInt
56// as macro in FixMath.h for 10.3
57inline Fixed IntToFixed( int inInt )
58{
59 return (((SInt32) inInt) << 16);
60}
61
62inline int FixedToInt( Fixed inFixed )
63{
64 return (((SInt32) inFixed) >> 16);
65}
66#endif
67
68#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5
69typedef UInt32 URefCon;
70typedef SInt32 SRefCon;
71#endif
72
73#if wxUSE_GUI
74
75#include "wx/listbox.h"
76
77#ifndef __LP64__
78
79class wxMacPortStateHelper
80{
81 DECLARE_NO_COPY_CLASS(wxMacPortStateHelper)
82
83public:
84 wxMacPortStateHelper( GrafPtr newport);
85 wxMacPortStateHelper();
86 ~wxMacPortStateHelper();
87
88 void Setup( GrafPtr newport );
89 void Clear();
90 bool IsCleared() { return m_clip == NULL; }
91 GrafPtr GetCurrentPort() { return m_currentPort; }
92
93private:
94 GrafPtr m_currentPort;
95 GrafPtr m_oldPort;
96 RgnHandle m_clip;
97 ThemeDrawingState m_drawingState;
98 short m_textFont;
99 short m_textSize;
100 short m_textStyle;
101 short m_textMode;
102};
103
104class WXDLLEXPORT wxMacPortSaver
105{
106 DECLARE_NO_COPY_CLASS(wxMacPortSaver)
107
108public:
109 wxMacPortSaver( GrafPtr port );
110 ~wxMacPortSaver();
111private :
112 GrafPtr m_port;
113};
114
115class WXDLLEXPORT wxMacPortSetter
116{
117 DECLARE_NO_COPY_CLASS(wxMacPortSetter)
118
119public:
120 wxMacPortSetter( const wxDC* dc );
121 ~wxMacPortSetter();
122private:
123 wxMacPortStateHelper m_ph;
124 const wxDC* m_dc;
125};
126
127/*
128 Clips to the visible region of a control within the current port
129 */
130
131class WXDLLEXPORT wxMacWindowClipper : public wxMacPortSaver
132{
133 DECLARE_NO_COPY_CLASS(wxMacWindowClipper)
134
135public:
136 wxMacWindowClipper( const wxWindow* win );
137 ~wxMacWindowClipper();
138private:
139 GrafPtr m_newPort;
140 RgnHandle m_formerClip;
141 RgnHandle m_newClip;
142};
143
144class WXDLLEXPORT wxMacWindowStateSaver : public wxMacWindowClipper
145{
146 DECLARE_NO_COPY_CLASS(wxMacWindowStateSaver)
147
148public:
149 wxMacWindowStateSaver( const wxWindow* win );
150 ~wxMacWindowStateSaver();
151private:
152 GrafPtr m_newPort;
153 ThemeDrawingState m_themeDrawingState;
154};
155#endif
156
157#if wxMAC_USE_CORE_GRAPHICS
158class WXDLLEXPORT wxMacCGContextStateSaver
159{
160 DECLARE_NO_COPY_CLASS(wxMacCGContextStateSaver)
161
162public:
163 wxMacCGContextStateSaver( CGContextRef cg )
164 {
165 m_cg = cg;
166 CGContextSaveGState( cg );
167 }
168 ~wxMacCGContextStateSaver()
169 {
170 CGContextRestoreGState( m_cg );
171 }
172private:
173 CGContextRef m_cg;
174};
175
176#endif
177/*
178class wxMacDrawingHelper
179{
180 DECLARE_NO_COPY_CLASS(wxMacDrawingHelper)
181
182public:
183 wxMacDrawingHelper( wxWindowMac * theWindow , bool clientArea = false );
184 ~wxMacDrawingHelper();
185 bool Ok() const { return IsOk(); }
186 bool IsOk() { return m_ok; }
187 void LocalToWindow( Rect *rect) { OffsetRect( rect , m_origin.h , m_origin.v ); }
188 void LocalToWindow( Point *pt ) { AddPt( m_origin , pt ); }
189 void LocalToWindow( RgnHandle rgn ) { OffsetRgn( rgn , m_origin.h , m_origin.v ); }
190 const Point& GetOrigin() { return m_origin; }
191private:
192 Point m_origin;
193 GrafPtr m_formerPort;
194 GrafPtr m_currentPort;
195 PenState m_savedPenState;
196 bool m_ok;
197};
198*/
199
200// app.h
201bool wxMacConvertEventToRecord( EventRef event , EventRecord *rec);
202
203#endif // wxUSE_GUI
204
205// filefn.h
206WXDLLIMPEXP_BASE wxString wxMacFSSpec2MacFilename( const FSSpec *spec );
207WXDLLIMPEXP_BASE void wxMacFilename2FSSpec( const wxString &path , FSSpec *spec );
208
209// utils.h
210WXDLLIMPEXP_BASE wxString wxMacFindFolderNoSeparator(short vRefNum,
211 OSType folderType,
212 Boolean createFolder);
213WXDLLIMPEXP_BASE wxString wxMacFindFolder(short vRefNum,
214 OSType folderType,
215 Boolean createFolder);
216
217template<typename T> EventParamType wxMacGetEventParamType() { wxFAIL_MSG( wxT("Unknown Param Type") ); return 0; }
218template<> inline EventParamType wxMacGetEventParamType<RgnHandle>() { return typeQDRgnHandle; }
219template<> inline EventParamType wxMacGetEventParamType<ControlRef>() { return typeControlRef; }
220template<> inline EventParamType wxMacGetEventParamType<WindowRef>() { return typeWindowRef; }
221template<> inline EventParamType wxMacGetEventParamType<MenuRef>() { return typeMenuRef; }
222template<> inline EventParamType wxMacGetEventParamType<EventRef>() { return typeEventRef; }
223template<> inline EventParamType wxMacGetEventParamType<Point>() { return typeQDPoint; }
224template<> inline EventParamType wxMacGetEventParamType<Rect>() { return typeQDRectangle; }
225template<> inline EventParamType wxMacGetEventParamType<Boolean>() { return typeBoolean; }
226template<> inline EventParamType wxMacGetEventParamType<SInt16>() { return typeSInt16; }
227template<> inline EventParamType wxMacGetEventParamType<SInt32>() { return typeSInt32; }
228template<> inline EventParamType wxMacGetEventParamType<UInt32>() { return typeUInt32; }
229template<> inline EventParamType wxMacGetEventParamType<RGBColor>() { return typeRGBColor; }
230#if TARGET_API_MAC_OSX
231template<> inline EventParamType wxMacGetEventParamType<HICommand>() { return typeHICommand; }
232template<> inline EventParamType wxMacGetEventParamType<HIPoint>() { return typeHIPoint; }
233template<> inline EventParamType wxMacGetEventParamType<HISize>() { return typeHISize; }
234template<> inline EventParamType wxMacGetEventParamType<HIRect>() { return typeHIRect; }
235template<> inline EventParamType wxMacGetEventParamType<void*>() { return typeVoidPtr; }
236#endif
237#if TARGET_API_MAC_OSX && ( MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2 )
238template<> inline EventParamType wxMacGetEventParamType<CFDictionaryRef>() { return typeCFDictionaryRef; }
239#endif
240template<> inline EventParamType wxMacGetEventParamType<Collection>() { return typeCollection; }
241template<> inline EventParamType wxMacGetEventParamType<CGContextRef>() { return typeCGContextRef; }
242/*
243 These are ambiguous
244 template<> EventParamType wxMacGetEventParamType<GrafPtr>() { return typeGrafPtr; }
245 template<> EventParamType wxMacGetEventParamType<OSStatus>() { return typeOSStatus; }
246 template<> EventParamType wxMacGetEventParamType<CFIndex>() { return typeCFIndex; }
247 template<> EventParamType wxMacGetEventParamType<GWorldPtr>() { return typeGWorldPtr; }
248 */
249
250class wxMacCarbonEvent
251{
252
253public :
254 wxMacCarbonEvent()
255 {
256 m_eventRef = 0;
257 m_release = false;
258 }
259
260 wxMacCarbonEvent( EventRef event , bool release = false )
261 {
262 m_eventRef = event;
263 m_release = release;
264 }
265
266 wxMacCarbonEvent(UInt32 inClassID,UInt32 inKind,EventTime inWhen = 0 /*now*/,EventAttributes inAttributes=kEventAttributeNone)
267 {
268 m_eventRef = NULL;
269 verify_noerr( MacCreateEvent( NULL , inClassID, inKind,inWhen,inAttributes,&m_eventRef) );
270 m_release = true;
271 }
272
273 ~wxMacCarbonEvent()
274 {
275 if ( m_release )
276 ReleaseEvent( m_eventRef );
277 }
278
279 OSStatus Create(UInt32 inClassID,UInt32 inKind,EventTime inWhen = 0 /*now*/,EventAttributes inAttributes=kEventAttributeNone)
280 {
281 verify( (m_eventRef == NULL) || m_release );
282 if ( m_eventRef && m_release )
283 {
284 ReleaseEvent( m_eventRef );
285 m_release = false;
286 m_eventRef = NULL;
287 }
288 OSStatus err = MacCreateEvent( NULL , inClassID, inKind,inWhen,inAttributes,&m_eventRef);
289 if ( err == noErr )
290 m_release = true;
291 return err;
292 }
293
294 OSStatus GetParameter( EventParamName inName, EventParamType inDesiredType, UInt32 inBufferSize, void * outData);
295
296 template <typename T> OSStatus GetParameter( EventParamName inName, EventParamType type , T *data )
297 {
298 return GetParameter( inName, type , sizeof( T ) , data );
299 }
300 template <typename T> OSStatus GetParameter( EventParamName inName, T *data )
301 {
302 return GetParameter<T>( inName, wxMacGetEventParamType<T>() , data );
303 }
304
305 template <typename T> T GetParameter( EventParamName inName )
306 {
307 T value;
308 verify_noerr( GetParameter<T>( inName, &value ) );
309 return value;
310 }
311 template <typename T> T GetParameter( EventParamName inName, EventParamType inDesiredType )
312 {
313 T value;
314 verify_noerr( GetParameter<T>( inName, inDesiredType , &value ) );
315 return value;
316 }
317
318 OSStatus SetParameter( EventParamName inName, EventParamType inType, UInt32 inSize, const void * inData);
319 template <typename T> OSStatus SetParameter( EventParamName inName, EventParamType inDesiredType , const T *data )
320 {
321 return SetParameter( inName, inDesiredType , sizeof( T ) , data );
322 }
323 template <typename T> OSStatus SetParameter( EventParamName inName, EventParamType inDesiredType , const T& data )
324 {
325 return SetParameter<T>( inName, inDesiredType , &data );
326 }
327 template <typename T> OSStatus SetParameter( EventParamName inName, const T *data )
328 {
329 return SetParameter<T>( inName, wxMacGetEventParamType<T>() , data );
330 }
331 template <typename T> OSStatus SetParameter( EventParamName inName, const T& data )
332 {
333 return SetParameter<T>( inName, wxMacGetEventParamType<T>() , &data );
334 }
335 UInt32 GetClass()
336 {
337 return ::GetEventClass( m_eventRef );
338 }
339 UInt32 GetKind()
340 {
341 return ::GetEventKind( m_eventRef );
342 }
343 EventTime GetTime()
344 {
345 return ::GetEventTime( m_eventRef );
346 }
347 UInt32 GetTicks()
348 {
349 return EventTimeToTicks( GetTime() );
350 }
351 OSStatus SetCurrentTime( )
352 {
353 return ::SetEventTime( m_eventRef , GetCurrentEventTime() );
354 }
355 OSStatus SetTime( EventTime when )
356 {
357 return ::SetEventTime( m_eventRef , when );
358 }
359 operator EventRef () { return m_eventRef; }
360
361 bool IsValid() { return m_eventRef != 0; }
362protected :
363 EventRef m_eventRef;
364 bool m_release;
365};
366
367//
368// helper class for allocating and deallocating Universal Proc Ptrs
369//
370
371template <typename procType, typename uppType , uppType (*newUPP)(procType) , void (*disposeUPP)(uppType) > class wxMacUPP
372{
373public :
374 wxMacUPP( procType WXUNUSED(proc) )
375 {
376 m_upp = NULL;
377 m_upp = (*newUPP)( NULL );
378 }
379 ~wxMacUPP()
380 {
381 if ( m_upp )
382 disposeUPP( m_upp );
383 }
384 operator uppType() { return m_upp; }
385private :
386 uppType m_upp;
387};
388
389typedef wxMacUPP<NMProcPtr,NMUPP,NewNMUPP,DisposeNMUPP> wxMacNMUPP;
390
391template <typename refType> class wxMacCFRefHolder
392{
393public :
394 wxMacCFRefHolder()
395 : m_ref(NULL) , m_release(false)
396 {
397 }
398
399 wxMacCFRefHolder( refType ref , bool release = true )
400 : m_ref(ref) , m_release(release)
401 {
402 }
403
404 ~wxMacCFRefHolder()
405 {
406 Release();
407 }
408
409 void Release()
410 {
411 if ( m_release && m_ref != NULL )
412 CFRelease( m_ref );
413 m_ref = NULL;
414 }
415
416 refType Detach()
417 {
418 refType val = m_ref;
419 m_release = false;
420 m_ref = NULL;
421 return val;
422 }
423
424 void Set( refType ref , bool release = true )
425 {
426 Release();
427 m_release = release;
428 m_ref = ref;
429 }
430
431 operator refType () const { return m_ref; }
432
433 wxMacCFRefHolder& operator=(refType r)
434 {
435 Set( r );
436 return *this;
437 }
438private :
439 refType m_ref;
440 bool m_release;
441
442 DECLARE_NO_COPY_CLASS( wxMacCFRefHolder )
443};
444
445#if wxUSE_GUI
446
447class wxMacToolTipTimer ;
448
449class wxMacToolTip
450{
451public :
452 wxMacToolTip() ;
453 ~wxMacToolTip() ;
454
455 void Setup( WindowRef window , const wxString& text , const wxPoint& localPosition ) ;
456 void Draw() ;
457 void Clear() ;
458
459 long GetMark()
460 { return m_mark ; }
461
462 bool IsShown()
463 { return m_shown ; }
464
465private :
466 wxString m_label ;
467 wxPoint m_position ;
468 Rect m_rect ;
469 WindowRef m_window ;
470 PicHandle m_backpict ;
471 bool m_shown ;
472 long m_mark ;
473#if wxUSE_TIMER
474 wxMacToolTipTimer* m_timer ;
475#endif
476#if TARGET_CARBON
477 wxMacCFStringHolder m_helpTextRef ;
478#endif
479} ;
480
481/*
482GWorldPtr wxMacCreateGWorld( int width , int height , int depth );
483void wxMacDestroyGWorld( GWorldPtr gw );
484PicHandle wxMacCreatePict( GWorldPtr gw , GWorldPtr mask = NULL );
485CIconHandle wxMacCreateCIcon(GWorldPtr image , GWorldPtr mask , short dstDepth , short iconSize );
486void wxMacSetColorTableEntry( CTabHandle newColors , int index , int red , int green , int blue );
487CTabHandle wxMacCreateColorTable( int numColors );
488*/
489void wxMacCreateBitmapButton( ControlButtonContentInfo*info , const wxBitmap& bitmap , int forceType = 0 );
490void wxMacReleaseBitmapButton( ControlButtonContentInfo*info );
491CGImageRef wxMacCreateCGImageFromBitmap( const wxBitmap& bitmap );
492
493#define MAC_WXCOLORREF(a) (*((RGBColor*)&(a)))
494#define MAC_WXHBITMAP(a) (GWorldPtr(a))
495#define MAC_WXHMETAFILE(a) (PicHandle(a))
496#define MAC_WXHICON(a) (IconRef(a))
497#define MAC_WXHCURSOR(a) (CursHandle(a))
498#define MAC_WXHRGN(a) (RgnHandle(a))
499#define MAC_WXHWND(a) (WindowPtr(a))
500#define MAC_WXRECPTR(a) ((Rect*)a)
501#define MAC_WXPOINTPTR(a) ((Point*)a)
502#define MAC_WXHMENU(a) ((MenuHandle)a)
503
504struct wxOpaqueWindowRef
505{
506 wxOpaqueWindowRef( WindowRef ref ) { m_data = ref; }
507 operator WindowRef() { return m_data; }
508private :
509 WindowRef m_data;
510};
511
512void wxMacRectToNative( const wxRect *wx , Rect *n );
513void wxMacNativeToRect( const Rect *n , wxRect* wx );
514void wxMacPointToNative( const wxPoint* wx , Point *n );
515void wxMacNativeToPoint( const Point *n , wxPoint* wx );
516
517wxWindow * wxFindControlFromMacControl(ControlRef inControl );
518wxTopLevelWindowMac* wxFindWinFromMacWindow( WindowRef inWindow );
519wxMenu* wxFindMenuFromMacMenu(MenuRef inMenuRef);
520
521int wxMacCommandToId( UInt32 macCommandId );
522UInt32 wxIdToMacCommand( int wxId );
523wxMenu* wxFindMenuFromMacCommand( const HICommand &macCommandId , wxMenuItem* &item );
524
525extern wxWindow* g_MacLastWindow;
526pascal OSStatus wxMacTopLevelMouseEventHandler( EventHandlerCallRef handler , EventRef event , void *data );
527Rect wxMacGetBoundsForControl( wxWindow* window , const wxPoint& pos , const wxSize &size , bool adjustForOrigin = true );
528
529ControlActionUPP GetwxMacLiveScrollbarActionProc();
530
531class wxMacControl : public wxObject
532{
533public :
534 wxMacControl( wxWindow* peer , bool isRootControl = false );
535 wxMacControl( wxWindow* peer , ControlRef control );
536 wxMacControl( wxWindow* peer , WXWidget control );
537 wxMacControl() ;
538 virtual ~wxMacControl();
539
540 void Init();
541
542 virtual void Dispose();
543
544 bool Ok() const { return IsOk(); }
545 bool IsOk() const { return GetControlRef() != NULL; }
546
547 void SetReferenceInNativeControl();
548 static wxMacControl* GetReferenceFromNativeControl(ControlRef control);
549
550 virtual ControlRef * GetControlRefAddr() { return &m_controlRef; }
551 virtual ControlRef GetControlRef() const { return m_controlRef; }
552
553 virtual void SetReference( URefCon data );
554 /*
555 void operator= (ControlRef c) { m_controlRef = c; }
556 operator ControlRef () { return m_controlRef; }
557 operator ControlRef * () { return &m_controlRef; }
558 */
559 // accessing data and values
560
561 virtual OSStatus SetData( ControlPartCode inPartCode , ResType inTag , Size inSize , const void * inData );
562 virtual OSStatus GetData( ControlPartCode inPartCode , ResType inTag , Size inBufferSize , void * inOutBuffer , Size * outActualSize ) const;
563 virtual OSStatus GetDataSize( ControlPartCode inPartCode , ResType inTag , Size * outActualSize ) const;
564 virtual OSStatus SendEvent( EventRef ref , OptionBits inOptions = 0 );
565 virtual OSStatus SendHICommand( HICommand &command , OptionBits inOptions = 0 );
566
567 virtual OSStatus SendHICommand( UInt32 commandID , OptionBits inOptions = 0 );
568
569 virtual SInt32 GetValue() const;
570 virtual SInt32 GetMaximum() const;
571 virtual SInt32 GetMinimum() const;
572
573 virtual void SetValue( SInt32 v );
574 virtual void SetMinimum( SInt32 v );
575 virtual void SetMaximum( SInt32 v );
576
577 virtual void SetValueAndRange( SInt32 value , SInt32 minimum , SInt32 maximum );
578 virtual void SetRange( SInt32 minimum , SInt32 maximum );
579
580 virtual OSStatus SetFocus( ControlFocusPart focusPart );
581 virtual bool HasFocus() const;
582 virtual bool NeedsFocusRect() const;
583 virtual void SetNeedsFocusRect( bool needs );
584
585 // templated helpers
586
587 Size GetDataSize( ControlPartCode inPartCode , ResType inTag ) const
588 {
589 Size sz;
590 verify_noerr( GetDataSize( inPartCode , inTag , &sz ) );
591 return sz;
592 }
593 template <typename T> OSStatus SetData( ControlPartCode inPartCode , ResType inTag , const T *data )
594 {
595 return SetData( inPartCode , inTag , sizeof( T ) , data );
596 }
597 template <typename T> OSStatus SetData( ControlPartCode inPartCode , ResType inTag , const T& data )
598 {
599 return SetData( inPartCode , inTag , sizeof( T ) , &data );
600 }
601 template <typename T> OSStatus SetData( ResType inTag , const T *data )
602 {
603 return SetData( kControlEntireControl , inTag , sizeof( T ) , data );
604 }
605 template <typename T> OSStatus SetData( ResType inTag , const T& data )
606 {
607 return SetData( kControlEntireControl , inTag , sizeof( T ) , &data );
608 }
609 template <typename T> OSStatus GetData( ControlPartCode inPartCode , ResType inTag , T *data ) const
610 {
611 Size dummy;
612 return GetData( inPartCode , inTag , sizeof( T ) , data , &dummy );
613 }
614 template <typename T> T GetData( ControlPartCode inPartCode , ResType inTag ) const
615 {
616 T value;
617 OSStatus err = GetData<T>( inPartCode , inTag , &value );
618
619 wxASSERT_MSG( err == noErr,
620 wxString::Format(wxT("GetData Failed for Part [%i] and Tag [%i]"),
621 inPartCode, (int)inTag) );
622 return value;
623 }
624 template <typename T> OSStatus GetData( ResType inTag , T *data ) const
625 {
626 Size dummy;
627 return GetData( kControlEntireControl , inTag , sizeof( T ) , data , &dummy );
628 }
629 template <typename T> T GetData( ResType inTag ) const
630 {
631 return GetData<T>( kControlEntireControl , inTag );
632 }
633
634 // Flash the control for the specified amount of time
635 virtual void Flash( ControlPartCode part , UInt32 ticks = 8 );
636
637 virtual void VisibilityChanged( bool shown );
638 virtual void SuperChangedPosition();
639
640
641 virtual void SetFont( const wxFont & font , const wxColour& foreground , long windowStyle );
642 virtual void SetBackground( const wxBrush &brush );
643 virtual ControlPartCode HandleKey( SInt16 keyCode, SInt16 charCode, EventModifiers modifiers );
644 void SetActionProc( ControlActionUPP actionProc );
645 void SetViewSize( SInt32 viewSize );
646 SInt32 GetViewSize() const;
647
648 virtual bool IsVisible() const;
649 virtual void SetVisibility( bool visible , bool redraw );
650 virtual bool IsEnabled() const;
651 virtual bool IsActive() const;
652 virtual void Enable( bool enable );
653
654 // invalidates this control and all children
655 virtual void InvalidateWithChildren();
656 virtual void SetDrawingEnabled( bool enable );
657#ifdef __WXMAC_OSX__
658 virtual bool GetNeedsDisplay() const;
659#endif
660 // where is in native window relative coordinates
661 virtual void SetNeedsDisplay( RgnHandle where );
662 // where is in native window relative coordinates
663 virtual void SetNeedsDisplay( Rect* where = NULL );
664
665 // if rect = NULL, entire view
666 virtual void ScrollRect( wxRect *rect , int dx , int dy );
667
668 // in native parent window relative coordinates
669 virtual void GetRect( Rect *r );
670
671 // in native parent window relative coordinates
672 virtual void SetRect( Rect *r );
673
674 virtual void GetRectInWindowCoords( Rect *r );
675 virtual void GetBestRect( Rect *r );
676 virtual void SetLabel( const wxString &title );
677 // converts from Toplevel-Content relative to local
678 static void Convert( wxPoint *pt , wxMacControl *convert , wxMacControl *to );
679
680 virtual void GetFeatures( UInt32 *features );
681 virtual OSStatus GetRegion( ControlPartCode partCode , RgnHandle region );
682 virtual OSStatus SetZOrder( bool above , wxMacControl* other );
683
684 bool IsRootControl() { return m_isRootControl; }
685
686 wxWindow* GetPeer() const
687 {
688 return m_peer;
689 }
690
691 // to be moved into a tab control class
692
693 virtual OSStatus SetTabEnabled( SInt16 tabNo , bool enable );
694protected :
695 ControlRef m_controlRef;
696 wxFont m_font;
697 long m_windowStyle;
698 wxWindow* m_peer;
699 bool m_needsFocusRect;
700 bool m_isRootControl;
701 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacControl)
702};
703
704// ============================================================================
705// DataBrowser Wrapper
706// ============================================================================
707//
708// basing on DataBrowserItemIDs
709//
710
711class wxMacDataBrowserControl : public wxMacControl
712{
713public :
714 wxMacDataBrowserControl( wxWindow* peer, const wxPoint& pos, const wxSize& size, long style);
715 wxMacDataBrowserControl() {}
716
717 OSStatus SetCallbacks( const DataBrowserCallbacks *callbacks );
718
719 OSStatus GetItemCount( DataBrowserItemID container,
720 Boolean recurse,
721 DataBrowserItemState state,
722 ItemCount *numItems) const;
723
724 OSStatus GetItems( DataBrowserItemID container,
725 Boolean recurse,
726 DataBrowserItemState state,
727 Handle items) const;
728
729
730 OSStatus AddColumn( DataBrowserListViewColumnDesc *columnDesc,
731 DataBrowserTableViewColumnIndex position );
732
733 OSStatus RemoveColumn( DataBrowserTableViewColumnIndex position );
734
735 OSStatus AutoSizeColumns();
736
737 OSStatus SetHasScrollBars( bool horiz, bool vert );
738 OSStatus SetHiliteStyle( DataBrowserTableViewHiliteStyle hiliteStyle );
739
740 OSStatus SetHeaderButtonHeight( UInt16 height );
741 OSStatus GetHeaderButtonHeight( UInt16 *height );
742
743 OSStatus UpdateItems( DataBrowserItemID container, UInt32 numItems,
744 const DataBrowserItemID *items,
745 DataBrowserPropertyID preSortProperty,
746 DataBrowserPropertyID propertyID ) const;
747
748 OSStatus AddItems( DataBrowserItemID container, UInt32 numItems,
749 const DataBrowserItemID *items,
750 DataBrowserPropertyID preSortProperty );
751 OSStatus RemoveItems( DataBrowserItemID container, UInt32 numItems,
752 const DataBrowserItemID *items,
753 DataBrowserPropertyID preSortProperty );
754 OSStatus RevealItem( DataBrowserItemID item,
755 DataBrowserPropertyID propertyID,
756 DataBrowserRevealOptions options ) const;
757
758 OSStatus SetSelectionFlags( DataBrowserSelectionFlags );
759 OSStatus GetSelectionAnchor( DataBrowserItemID *first, DataBrowserItemID *last ) const;
760 bool IsItemSelected( DataBrowserItemID item ) const;
761 OSStatus SetSelectedItems( UInt32 numItems,
762 const DataBrowserItemID *items,
763 DataBrowserSetOption operation );
764
765 OSStatus GetItemID( DataBrowserTableViewRowIndex row,
766 DataBrowserItemID * item ) const;
767 OSStatus GetItemRow( DataBrowserItemID item,
768 DataBrowserTableViewRowIndex * row ) const;
769
770 OSStatus SetDefaultRowHeight( UInt16 height );
771 OSStatus GetDefaultRowHeight( UInt16 * height ) const;
772
773 OSStatus SetRowHeight( DataBrowserItemID item , UInt16 height);
774 OSStatus GetRowHeight( DataBrowserItemID item , UInt16 *height) const;
775
776 OSStatus GetColumnWidth( DataBrowserPropertyID column , UInt16 *width ) const;
777 OSStatus SetColumnWidth( DataBrowserPropertyID column , UInt16 width );
778
779 OSStatus GetDefaultColumnWidth( UInt16 *width ) const;
780 OSStatus SetDefaultColumnWidth( UInt16 width );
781
782 OSStatus GetColumnCount( UInt32* numColumns) const;
783
784 OSStatus GetColumnIDFromIndex( DataBrowserTableViewColumnIndex position, DataBrowserTableViewColumnID* id );
785
786 OSStatus GetColumnPosition( DataBrowserPropertyID column, DataBrowserTableViewColumnIndex *position) const;
787 OSStatus SetColumnPosition( DataBrowserPropertyID column, DataBrowserTableViewColumnIndex position);
788
789 OSStatus GetScrollPosition( UInt32 *top , UInt32 *left ) const;
790 OSStatus SetScrollPosition( UInt32 top , UInt32 left );
791
792 OSStatus GetSortProperty( DataBrowserPropertyID *column ) const;
793 OSStatus SetSortProperty( DataBrowserPropertyID column );
794
795 OSStatus GetSortOrder( DataBrowserSortOrder *order ) const;
796 OSStatus SetSortOrder( DataBrowserSortOrder order );
797
798 OSStatus GetPropertyFlags( DataBrowserPropertyID property, DataBrowserPropertyFlags *flags ) const;
799 OSStatus SetPropertyFlags( DataBrowserPropertyID property, DataBrowserPropertyFlags flags );
800
801 OSStatus GetHeaderDesc( DataBrowserPropertyID property, DataBrowserListViewHeaderDesc *desc ) const;
802 OSStatus SetHeaderDesc( DataBrowserPropertyID property, DataBrowserListViewHeaderDesc *desc );
803
804 OSStatus SetDisclosureColumn( DataBrowserPropertyID property , Boolean expandableRows );
805protected :
806
807 static pascal void DataBrowserItemNotificationProc(
808 ControlRef browser,
809 DataBrowserItemID itemID,
810 DataBrowserItemNotification message,
811 DataBrowserItemDataRef itemData );
812
813 virtual void ItemNotification(
814 DataBrowserItemID itemID,
815 DataBrowserItemNotification message,
816 DataBrowserItemDataRef itemData) = 0;
817
818 static pascal OSStatus DataBrowserGetSetItemDataProc(
819 ControlRef browser,
820 DataBrowserItemID itemID,
821 DataBrowserPropertyID property,
822 DataBrowserItemDataRef itemData,
823 Boolean changeValue );
824
825 virtual OSStatus GetSetItemData(
826 DataBrowserItemID itemID,
827 DataBrowserPropertyID property,
828 DataBrowserItemDataRef itemData,
829 Boolean changeValue ) = 0;
830
831 static pascal Boolean DataBrowserCompareProc(
832 ControlRef browser,
833 DataBrowserItemID itemOneID,
834 DataBrowserItemID itemTwoID,
835 DataBrowserPropertyID sortProperty);
836
837 virtual Boolean CompareItems(DataBrowserItemID itemOneID,
838 DataBrowserItemID itemTwoID,
839 DataBrowserPropertyID sortProperty) = 0;
840 DECLARE_ABSTRACT_CLASS(wxMacDataBrowserControl)
841};
842
843// ============================================================================
844// Higher-level Databrowser
845// ============================================================================
846//
847// basing on data item objects
848//
849
850// forward decl
851
852class wxMacDataItemBrowserControl;
853class wxMacListBoxItem;
854
855const DataBrowserPropertyID kTextColumnId = 1024;
856const DataBrowserPropertyID kNumericOrderColumnId = 1025;
857
858// for multi-column controls, we will use this + the column ID to identify the
859// column. We don't use kTextColumnId there, and ideally the two should merge.
860const DataBrowserPropertyID kMinColumnId = 1050;
861
862// base API for high-level databrowser operations
863
864class wxMacListControl
865{
866public:
867 virtual void MacDelete( unsigned int n ) = 0;
868 virtual void MacInsert( unsigned int n, const wxArrayStringsAdapter& items, int column = -1 ) = 0;
869 // returns index of newly created line
870 virtual int MacAppend( const wxString& item ) = 0;
871 virtual void MacSetString( unsigned int n, const wxString& item ) = 0;
872 virtual void MacClear() = 0;
873 virtual void MacDeselectAll() = 0;
874 virtual void MacSetSelection( unsigned int n, bool select, bool multi ) = 0;
875 virtual int MacGetSelection() const = 0;
876 virtual int MacGetSelections( wxArrayInt& aSelections ) const = 0;
877 virtual bool MacIsSelected( unsigned int n ) const = 0;
878 virtual void MacScrollTo( unsigned int n ) = 0;
879 virtual wxString MacGetString( unsigned int n) const = 0;
880 virtual unsigned int MacGetCount() const = 0;
881
882 virtual void MacSetClientData( unsigned int n, void * data) = 0;
883 virtual void * MacGetClientData( unsigned int) const = 0;
884
885 virtual ~wxMacListControl() { }
886};
887
888// base class for databrowser items
889
890enum DataItemType {
891 DataItem_Text
892};
893
894class wxMacDataItem
895{
896public :
897 wxMacDataItem();
898 virtual ~wxMacDataItem();
899
900 virtual bool IsLessThan(wxMacDataItemBrowserControl *owner ,
901 const wxMacDataItem*,
902 DataBrowserPropertyID property) const;
903
904 // returns true if access was successful, otherwise false
905 virtual OSStatus GetSetData(wxMacDataItemBrowserControl *owner ,
906 DataBrowserPropertyID property,
907 DataBrowserItemDataRef itemData,
908 bool changeValue );
909
910 virtual void Notification(wxMacDataItemBrowserControl *owner ,
911 DataBrowserItemNotification message,
912 DataBrowserItemDataRef itemData ) const;
913
914 void SetLabel( const wxString& str);
915 const wxString& GetLabel() const;
916
917 void SetOrder( SInt32 order );
918 SInt32 GetOrder() const;
919
920 void SetData( void* data);
921 void* GetData() const;
922
923 void SetColumn( short col );
924 short GetColumn();
925
926protected :
927 wxString m_label;
928 wxMacCFStringHolder m_cfLabel;
929 void * m_data;
930 SInt32 m_order;
931 DataBrowserPropertyID m_colId;
932
933};
934
935enum ListSortOrder {
936 SortOrder_None,
937 SortOrder_Text_Ascending,
938 SortOrder_Text_Descending
939};
940
941typedef wxMacDataItem* wxMacDataItemPtr;
942const wxMacDataItemPtr wxMacDataBrowserRootContainer = NULL;
943
944WX_DEFINE_USER_EXPORTED_ARRAY_PTR(wxMacDataItemPtr, wxArrayMacDataItemPtr, class WXDLLIMPEXP_CORE);
945
946class wxMacDataItemBrowserControl : public wxMacDataBrowserControl, public wxMacListControl
947{
948public :
949 wxMacDataItemBrowserControl( wxWindow* peer , const wxPoint& pos, const wxSize& size, long style);
950 wxMacDataItemBrowserControl() {}
951 // create a list item (can be a subclass of wxMacListBoxItem)
952
953 virtual wxMacDataItem* CreateItem();
954
955 unsigned int GetItemCount(const wxMacDataItem* container, bool recurse , DataBrowserItemState state) const;
956 void GetItems(const wxMacDataItem* container, bool recurse ,
957 DataBrowserItemState state, wxArrayMacDataItemPtr &items ) const;
958
959 unsigned int GetSelectedItemCount( const wxMacDataItem* container, bool recurse ) const;
960
961 unsigned int GetLineFromItem(const wxMacDataItem *item) const;
962 wxMacDataItem * GetItemFromLine(unsigned int n) const;
963
964 void UpdateItem(const wxMacDataItem *container, const wxMacDataItem *item,
965 DataBrowserPropertyID property) const;
966 void UpdateItems(const wxMacDataItem *container, wxArrayMacDataItemPtr &items,
967 DataBrowserPropertyID property) const;
968
969 void InsertColumn(int colId, DataBrowserPropertyType colType,
970 const wxString& title, SInt16 just = teFlushDefault, int defaultWidth = -1);
971
972 int GetColumnWidth(int colId);
973 void SetColumnWidth(int colId, int width);
974
975 void AddItem(wxMacDataItem *container, wxMacDataItem *item);
976 void AddItems(wxMacDataItem *container, wxArrayMacDataItemPtr &items );
977
978 void RemoveAllItems(wxMacDataItem *container);
979 void RemoveItem(wxMacDataItem *container, wxMacDataItem* item);
980 void RemoveItems(wxMacDataItem *container, wxArrayMacDataItemPtr &items);
981
982 void SetSelectedItem( wxMacDataItem* item , DataBrowserSetOption option);
983 void SetSelectedItems( wxArrayMacDataItemPtr &items , DataBrowserSetOption option);
984 void SetSelectedAllItems( DataBrowserSetOption option);
985 Boolean IsItemSelected( const wxMacDataItem* item) const;
986
987 void RevealItem( wxMacDataItem* item, DataBrowserRevealOptions options);
988
989 void GetSelectionAnchor( wxMacDataItemPtr* first , wxMacDataItemPtr* last) const;
990
991 // item aware methods, to be used in subclasses
992
993 virtual Boolean CompareItems(const wxMacDataItem* itemOneID,
994 const wxMacDataItem* itemTwoID,
995 DataBrowserPropertyID sortProperty);
996
997 virtual OSStatus GetSetItemData(wxMacDataItem* itemID,
998 DataBrowserPropertyID property,
999 DataBrowserItemDataRef itemData,
1000 Boolean changeValue );
1001
1002 virtual void ItemNotification(
1003 const wxMacDataItem* itemID,
1004 DataBrowserItemNotification message,
1005 DataBrowserItemDataRef itemData);
1006
1007 // as we are getting the same events for human and API selection we have to suppress
1008 // events in the latter case, since this will be used from many subclasses we keep it here
1009
1010 bool IsSelectionSuppressed() const { return m_suppressSelection; }
1011 bool SuppressSelection( bool suppress );
1012
1013
1014 // wxMacListControl Methods
1015 // add and remove
1016
1017 virtual void MacDelete( unsigned int n );
1018 virtual void MacInsert( unsigned int n, const wxArrayStringsAdapter& items, int column = -1 );
1019 virtual int MacAppend( const wxString& item );
1020 virtual void MacClear();
1021
1022 // selecting
1023
1024 virtual void MacDeselectAll();
1025 virtual void MacSetSelection( unsigned int n, bool select, bool multi = false );
1026 virtual int MacGetSelection() const;
1027 virtual int MacGetSelections( wxArrayInt& aSelections ) const;
1028 virtual bool MacIsSelected( unsigned int n ) const;
1029
1030 // display
1031
1032 virtual void MacScrollTo( unsigned int n );
1033
1034 // accessing content
1035
1036 virtual void MacSetString( unsigned int n, const wxString& item );
1037 virtual void MacSetClientData( unsigned int n, void * data);
1038 virtual wxString MacGetString( unsigned int n) const;
1039 virtual void * MacGetClientData( unsigned int) const;
1040 virtual unsigned int MacGetCount() const;
1041
1042 // client data
1043
1044 virtual wxClientDataType GetClientDataType() const;
1045 virtual void SetClientDataType(wxClientDataType clientDataItemsType);
1046 //virtual ListSortOrder GetSortOrder() const;
1047 //virtual void SetSortOrder(const ListSortOrder sort);
1048
1049
1050
1051protected:
1052
1053 ListSortOrder m_sortOrder;
1054 wxClientDataType m_clientDataItemsType;
1055
1056 // ID aware base methods, should be 'final' ie not changed in subclasses
1057
1058 virtual Boolean CompareItems(DataBrowserItemID itemOneID,
1059 DataBrowserItemID itemTwoID,
1060 DataBrowserPropertyID sortProperty);
1061
1062 virtual OSStatus GetSetItemData(DataBrowserItemID itemID,
1063 DataBrowserPropertyID property,
1064 DataBrowserItemDataRef itemData,
1065 Boolean changeValue );
1066
1067 virtual void ItemNotification(
1068 DataBrowserItemID itemID,
1069 DataBrowserItemNotification message,
1070 DataBrowserItemDataRef itemData);
1071
1072
1073private :
1074
1075 bool m_suppressSelection;
1076 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacDataItemBrowserControl)
1077};
1078
1079class wxMacDataItemBrowserSelectionSuppressor
1080{
1081public :
1082 wxMacDataItemBrowserSelectionSuppressor(wxMacDataItemBrowserControl *browser);
1083 ~wxMacDataItemBrowserSelectionSuppressor();
1084
1085private :
1086
1087 bool m_former;
1088 wxMacDataItemBrowserControl* m_browser;
1089};
1090
1091// ============================================================================
1092// platform listbox implementation
1093// ============================================================================
1094
1095// exposed for reuse in wxCheckListBox
1096
1097class wxMacListBoxItem : public wxMacDataItem
1098{
1099public :
1100 wxMacListBoxItem();
1101
1102 virtual ~wxMacListBoxItem();
1103
1104 virtual void Notification(wxMacDataItemBrowserControl *owner ,
1105 DataBrowserItemNotification message,
1106 DataBrowserItemDataRef itemData ) const;
1107};
1108
1109class wxMacDataBrowserListControl : public wxMacDataItemBrowserControl
1110{
1111public:
1112 wxMacDataBrowserListControl( wxWindow *peer, const wxPoint& pos, const wxSize& size, long style );
1113 wxMacDataBrowserListControl() {}
1114 virtual ~wxMacDataBrowserListControl();
1115
1116 virtual wxMacDataItem* CreateItem();
1117
1118 // pointing back
1119
1120 wxWindow * GetPeer() const;
1121
1122 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacDataBrowserListControl)
1123};
1124
1125// ============================================================================
1126// graphics implementation
1127// ============================================================================
1128
1129// make sure we all use one class for all conversions from wx to native colour
1130
1131class wxMacCoreGraphicsColour
1132{
1133public:
1134 wxMacCoreGraphicsColour();
1135 wxMacCoreGraphicsColour(const wxBrush &brush);
1136 ~wxMacCoreGraphicsColour();
1137
1138 void Apply( CGContextRef cgContext );
1139protected:
1140 void Init();
1141 wxMacCFRefHolder<CGColorRef> m_color;
1142 wxMacCFRefHolder<CGColorSpaceRef> m_colorSpace;
1143
1144 bool m_isPattern;
1145 wxMacCFRefHolder<CGPatternRef> m_pattern;
1146 CGFloat* m_patternColorComponents;
1147} ;
1148
1149#if wxMAC_USE_CORE_GRAPHICS && !wxUSE_GRAPHICS_CONTEXT
1150
1151class WXDLLEXPORT wxMacCGPath : public wxGraphicPath
1152{
1153 DECLARE_NO_COPY_CLASS(wxMacCGPath)
1154public :
1155 wxMacCGPath();
1156 ~wxMacCGPath();
1157
1158 // Starts a new subpath at
1159 void MoveToPoint( wxCoord x1 , wxCoord y1 );
1160 void AddLineToPoint( wxCoord x1 , wxCoord y1 );
1161 void AddQuadCurveToPoint( wxCoord cx1, wxCoord cy1, wxCoord x1, wxCoord y1 );
1162 void AddRectangle( wxCoord x, wxCoord y, wxCoord w, wxCoord h );
1163 void AddCircle( wxCoord x, wxCoord y , wxCoord r );
1164
1165 // draws a an arc to two tangents connecting (current) to (x1,y1) and (x1,y1) to (x2,y2)
1166 virtual void AddArcToPoint( wxCoord x1, wxCoord y1 , wxCoord x2, wxCoord y2, wxCoord r ) ;
1167 virtual void AddArc( wxCoord x, wxCoord y, wxCoord r, double startAngle, double endAngle, bool clockwise ) ;
1168
1169 // closes the current subpath
1170 void CloseSubpath();
1171
1172 CGPathRef GetPath() const;
1173private :
1174 CGMutablePathRef m_path;
1175};
1176
1177class WXDLLEXPORT wxMacCGContext : public wxGraphicContext
1178{
1179 DECLARE_NO_COPY_CLASS(wxMacCGContext)
1180
1181public:
1182 wxMacCGContext( CGrafPtr port );
1183 wxMacCGContext( CGContextRef cgcontext );
1184 wxMacCGContext();
1185 virtual ~wxMacCGContext();
1186
1187 virtual void Clip( const wxRegion &region );
1188 virtual void StrokePath( const wxGraphicPath *p );
1189 virtual void DrawPath( const wxGraphicPath *p , int fillStyle = wxWINDING_RULE );
1190 virtual void FillPath( const wxGraphicPath *p , const wxColor &fillColor , int fillStyle = wxWINDING_RULE );
1191
1192 virtual wxGraphicPath* CreatePath();
1193 virtual void SetPen( const wxPen &pen ) ;
1194 virtual void SetBrush( const wxBrush &brush );
1195 CGContextRef GetNativeContext();
1196 void SetNativeContext( CGContextRef cg );
1197 CGPathDrawingMode GetDrawingMode() const { return m_mode; }
1198
1199 virtual void Translate( wxCoord dx , wxCoord dy );
1200 virtual void Scale( wxCoord xScale , wxCoord yScale );
1201 virtual void DrawBitmap( const wxBitmap &bmp, wxCoord x, wxCoord y, wxCoord w, wxCoord h );
1202 virtual void DrawIcon( const wxIcon &icon, wxCoord x, wxCoord y, wxCoord w, wxCoord h );
1203 virtual void PushState();
1204 virtual void PopState();
1205
1206 virtual void DrawText( const wxString &str, wxCoord x, wxCoord y, double angle ) ;
1207
1208 virtual void GetTextExtent( const wxString &str, wxCoord *width, wxCoord *height,
1209 wxCoord *descent, wxCoord *externalLeading ) const ;
1210
1211 virtual void GetPartialTextExtents(const wxString& text, wxArrayInt& widths) const ;
1212
1213 virtual void SetFont( const wxFont &font ) ;
1214
1215 virtual void SetTextColor( const wxColour &col ) ;
1216private:
1217 CGContextRef m_cgContext;
1218 CGrafPtr m_qdPort;
1219 CGPathDrawingMode m_mode;
1220 ATSUStyle m_macATSUIStyle ;
1221 wxPen m_pen;
1222 wxBrush m_brush;
1223 wxColor m_textForegroundColor ;
1224};
1225
1226#endif // wxMAC_USE_CORE_GRAPHICS
1227
1228#ifdef __WXMAC_OSX__
1229
1230CGColorSpaceRef wxMacGetGenericRGBColorSpace(void);
1231void wxMacMemoryBufferReleaseProc(void *info, const void *data, size_t size);
1232
1233#endif
1234
1235class WXDLLEXPORT wxBitmapRefData: public wxGDIRefData
1236{
1237 friend class WXDLLIMPEXP_FWD_CORE wxIcon;
1238 friend class WXDLLIMPEXP_FWD_CORE wxCursor;
1239public:
1240 wxBitmapRefData(int width , int height , int depth);
1241 wxBitmapRefData();
1242 wxBitmapRefData(const wxBitmapRefData &tocopy);
1243
1244 virtual ~wxBitmapRefData();
1245
1246 void Free();
1247 bool Ok() const { return IsOk(); }
1248 bool IsOk() const { return m_ok; }
1249 void SetOk( bool isOk) { m_ok = isOk; }
1250
1251 void SetWidth( int width ) { m_width = width; }
1252 void SetHeight( int height ) { m_height = height; }
1253 void SetDepth( int depth ) { m_depth = depth; }
1254
1255 int GetWidth() const { return m_width; }
1256 int GetHeight() const { return m_height; }
1257 int GetDepth() const { return m_depth; }
1258
1259 void *GetRawAccess() const;
1260 void *BeginRawAccess();
1261 void EndRawAccess();
1262
1263 bool HasAlpha() const { return m_hasAlpha; }
1264 void UseAlpha( bool useAlpha );
1265
1266public:
1267#if wxUSE_PALETTE
1268 wxPalette m_bitmapPalette;
1269#endif // wxUSE_PALETTE
1270
1271 wxMask * m_bitmapMask; // Optional mask
1272#ifdef __WXMAC_OSX__
1273 CGImageRef CGImageCreate() const;
1274#endif
1275
1276 // returns true if the bitmap has a size that
1277 // can be natively transferred into a true icon
1278 // if no is returned GetIconRef will still produce
1279 // an icon but it will be generated via a PICT and
1280 // rescaled to 16 x 16
1281 bool HasNativeSize();
1282
1283 // caller should increase ref count if needed longer
1284 // than the bitmap exists
1285 IconRef GetIconRef();
1286
1287 // returns a Pict from the bitmap content
1288 PicHandle GetPictHandle();
1289#if wxMAC_USE_CORE_GRAPHICS
1290 CGContextRef GetBitmapContext() const;
1291#else
1292 GWorldPtr GetHBITMAP(GWorldPtr * mask = NULL ) const;
1293 void UpdateAlphaMask() const;
1294#endif
1295 int GetBytesPerRow() const { return m_bytesPerRow; }
1296private :
1297 bool Create(int width , int height , int depth);
1298 void Init();
1299
1300 int m_width;
1301 int m_height;
1302 int m_bytesPerRow;
1303 int m_depth;
1304 bool m_hasAlpha;
1305 wxMemoryBuffer m_memBuf;
1306 int m_rawAccessCount;
1307 bool m_ok;
1308#ifdef __WXMAC_OSX__
1309 mutable CGImageRef m_cgImageRef;
1310#endif
1311 IconRef m_iconRef;
1312 PicHandle m_pictHandle;
1313#if wxMAC_USE_CORE_GRAPHICS
1314 CGContextRef m_hBitmap;
1315#else
1316 GWorldPtr m_hBitmap;
1317 GWorldPtr m_hMaskBitmap;
1318 wxMemoryBuffer m_maskMemBuf;
1319 int m_maskBytesPerRow;
1320#endif
1321};
1322
1323class WXDLLEXPORT wxIconRefData : public wxGDIRefData
1324{
1325public:
1326 wxIconRefData();
1327 wxIconRefData( WXHICON );
1328 virtual ~wxIconRefData() { Free(); }
1329
1330 void Init();
1331 virtual void Free();
1332
1333 void SetWidth( int width ) { m_width = width; }
1334 void SetHeight( int height ) { m_height = height; }
1335
1336 int GetWidth() const { return m_width; }
1337 int GetHeight() const { return m_height; }
1338
1339 WXHICON GetHICON() const { return (WXHICON) m_iconRef; }
1340private :
1341 IconRef m_iconRef;
1342 int m_width;
1343 int m_height;
1344};
1345
1346// toplevel.cpp
1347
1348class wxMacDeferredWindowDeleter : public wxObject
1349{
1350public :
1351 wxMacDeferredWindowDeleter( WindowRef windowRef );
1352 virtual ~wxMacDeferredWindowDeleter();
1353
1354protected :
1355 WindowRef m_macWindow ;
1356} ;
1357
1358ControlRef wxMacFindControlUnderMouse( wxTopLevelWindowMac* toplevelWindow, const Point& location , WindowRef window , ControlPartCode *outPart );
1359
1360#ifndef __LP64__
1361
1362#ifdef WORDS_BIGENDIAN
1363 inline Rect* wxMacGetPictureBounds( PicHandle pict , Rect* rect )
1364 {
1365 *rect = (**pict).picFrame;
1366 return rect;
1367 }
1368#else
1369 inline Rect* wxMacGetPictureBounds( PicHandle pict , Rect* rect )
1370 {
1371 return QDGetPictureBounds( pict , rect );
1372 }
1373#endif
1374
1375#endif
1376
1377#endif // wxUSE_GUI
1378
1379#define wxMAC_DEFINE_PROC_GETTER( UPP , x ) \
1380UPP Get##x() \
1381{ \
1382 static UPP sHandler = NULL; \
1383 if ( sHandler == NULL ) \
1384 sHandler = New##UPP( x ); \
1385 return sHandler; \
1386}
1387
1388//---------------------------------------------------------------------------
1389// wxMac string conversions
1390//---------------------------------------------------------------------------
1391
1392void wxMacSetupConverters();
1393void wxMacCleanupConverters();
1394
1395WXDLLIMPEXP_BASE void wxMacStringToPascal( const wxString&from , StringPtr to );
1396WXDLLIMPEXP_BASE wxString wxMacMakeStringFromPascal( ConstStringPtr from );
1397
1398// filefn.cpp
1399
1400WXDLLIMPEXP_BASE wxString wxMacFSRefToPath( const FSRef *fsRef , CFStringRef additionalPathComponent = NULL );
1401WXDLLIMPEXP_BASE OSStatus wxMacPathToFSRef( const wxString&path , FSRef *fsRef );
1402WXDLLIMPEXP_BASE wxString wxMacHFSUniStrToString( ConstHFSUniStr255Param uniname );
1403
1404#if wxUSE_GUI
1405
1406// deprecating QD
1407
1408void wxMacLocalToGlobal( WindowRef window , Point*pt );
1409void wxMacGlobalToLocal( WindowRef window , Point*pt );
1410
1411#endif
1412
1413//---------------------------------------------------------------------------
1414// cocoa bridging utilities
1415//---------------------------------------------------------------------------
1416
1417bool wxMacInitCocoa();
1418
1419class wxMacAutoreleasePool
1420{
1421public :
1422 wxMacAutoreleasePool();
1423 ~wxMacAutoreleasePool();
1424private :
1425 void* m_pool;
1426};
1427
1428// NSObject
1429
1430void wxMacCocoaRelease( void* obj );
1431void wxMacCocoaAutorelease( void* obj );
1432void wxMacCocoaRetain( void* obj );
1433
1434#if wxMAC_USE_COCOA
1435
1436// NSCursor
1437
1438WX_NSCursor wxMacCocoaCreateStockCursor( int cursor_type );
1439WX_NSCursor wxMacCocoaCreateCursorFromCGImage( CGImageRef cgImageRef, float hotSpotX, float hotSpotY );
1440void wxMacCocoaSetCursor( WX_NSCursor cursor );
1441void wxMacCocoaHideCursor();
1442void wxMacCocoaShowCursor();
1443
1444typedef struct tagClassicCursor
1445{
1446 wxUint16 bits[16];
1447 wxUint16 mask[16];
1448 wxInt16 hotspot[2];
1449}ClassicCursor;
1450
1451#else // !wxMAC_USE_COCOA
1452
1453// non Darwin
1454
1455typedef Cursor ClassicCursor;
1456
1457#endif // wxMAC_USE_COCOA
1458
1459// -------------
1460// Common to all
1461// -------------
1462
1463// Cursor support
1464
1465const short kwxCursorBullseye = 0;
1466const short kwxCursorBlank = 1;
1467const short kwxCursorPencil = 2;
1468const short kwxCursorMagnifier = 3;
1469const short kwxCursorNoEntry = 4;
1470const short kwxCursorPaintBrush = 5;
1471const short kwxCursorPointRight = 6;
1472const short kwxCursorPointLeft = 7;
1473const short kwxCursorQuestionArrow = 8;
1474const short kwxCursorRightArrow = 9;
1475const short kwxCursorSizeNS = 10;
1476const short kwxCursorSize = 11;
1477const short kwxCursorSizeNESW = 12;
1478const short kwxCursorSizeNWSE = 13;
1479const short kwxCursorRoller = 14;
1480const short kwxCursorLast = kwxCursorRoller;
1481
1482// exposing our fallback cursor map
1483
1484extern ClassicCursor gMacCursors[];
1485
1486#endif
1487 // _WX_PRIVATE_H_