]> git.saurik.com Git - wxWidgets.git/blame - include/wx/mac/carbon/private.h
added virtual dtor to wxMacListControl to silence gcc warnings
[wxWidgets.git] / include / wx / mac / carbon / private.h
CommitLineData
8cf73271 1/////////////////////////////////////////////////////////////////////////////
fb5246be 2// Name: wx/mac/carbon/private.h
8cf73271 3// Purpose: Private declarations: as this header is only included by
77ffb593 4// wxWidgets itself, it may contain identifiers which don't start
8cf73271
SC
5// with "wx".
6// Author: Stefan Csomor
7// Modified by:
8// Created: 1998-01-01
9// RCS-ID: $Id$
10// Copyright: (c) Stefan Csomor
65571936 11// Licence: wxWindows licence
8cf73271
SC
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
4f305456 23# include <Debugging.h>
8cf73271
SC
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>
d9af087c 31# include <FixMath.h>
a6140a4c 32# include <CoreServices.h>
8cf73271
SC
33#endif
34
a6140a4c 35#if UNIVERSAL_INTERFACES_VERSION < 0x0342
8cf73271
SC
36 #error "please update to Apple's lastest universal headers from http://developer.apple.com/sdk/"
37#endif
38
c3a404b0
SC
39#ifndef MAC_OS_X_VERSION_10_3
40 #define MAC_OS_X_VERSION_10_3 1030
41#endif
42
ddb08e02
SC
43#ifndef MAC_OS_X_VERSION_10_4
44 #define MAC_OS_X_VERSION_10_4 1040
45#endif
46
5185263f
DE
47#ifdef __WXMAC_CARBON__
48#include "wx/mac/corefoundation/cfstring.h"
49#endif
50
3d639707
SC
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
8cf73271
SC
64#if wxUSE_GUI
65
20b69855 66#include "wx/dc.h"
8cf73271 67#include "wx/window.h"
285b5ce0 68#include "wx/toplevel.h"
8cf73271 69
fb5246be 70class wxMacPortStateHelper
8cf73271
SC
71{
72 DECLARE_NO_COPY_CLASS(wxMacPortStateHelper)
fb5246be 73
8cf73271 74public:
6cce68ea
SC
75 wxMacPortStateHelper( GrafPtr newport);
76 wxMacPortStateHelper();
77 ~wxMacPortStateHelper();
8cf73271 78
6cce68ea
SC
79 void Setup( GrafPtr newport );
80 void Clear();
81 bool IsCleared() { return m_clip == NULL; }
82 GrafPtr GetCurrentPort() { return m_currentPort; }
8cf73271
SC
83
84private:
6cce68ea
SC
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};
8cf73271 94
4f305456
SC
95class WXDLLEXPORT wxMacPortSaver
96{
97 DECLARE_NO_COPY_CLASS(wxMacPortSaver)
fb5246be 98
4f305456 99public:
54ce9ebb
JS
100 wxMacPortSaver( GrafPtr port );
101 ~wxMacPortSaver();
4f305456 102private :
6cce68ea
SC
103 GrafPtr m_port;
104};
4f305456 105
8cf73271
SC
106class WXDLLEXPORT wxMacPortSetter
107{
108 DECLARE_NO_COPY_CLASS(wxMacPortSetter)
fb5246be 109
8cf73271 110public:
6cce68ea
SC
111 wxMacPortSetter( const wxDC* dc );
112 ~wxMacPortSetter();
8cf73271 113private:
6cce68ea
SC
114 wxMacPortStateHelper m_ph;
115 const wxDC* m_dc;
116};
8cf73271 117
4f305456
SC
118/*
119 Clips to the visible region of a control within the current port
120 */
fb5246be 121
4f305456 122class WXDLLEXPORT wxMacWindowClipper : public wxMacPortSaver
8cf73271
SC
123{
124 DECLARE_NO_COPY_CLASS(wxMacWindowClipper)
fb5246be 125
8cf73271 126public:
6cce68ea
SC
127 wxMacWindowClipper( const wxWindow* win );
128 ~wxMacWindowClipper();
8cf73271 129private:
6cce68ea
SC
130 GrafPtr m_newPort;
131 RgnHandle m_formerClip;
132 RgnHandle m_newClip;
133};
8cf73271 134
01299d56
SC
135class WXDLLEXPORT wxMacWindowStateSaver : public wxMacWindowClipper
136{
137 DECLARE_NO_COPY_CLASS(wxMacWindowStateSaver)
fb5246be 138
01299d56 139public:
6cce68ea
SC
140 wxMacWindowStateSaver( const wxWindow* win );
141 ~wxMacWindowStateSaver();
01299d56 142private:
6cce68ea
SC
143 GrafPtr m_newPort;
144 ThemeDrawingState m_themeDrawingState;
145};
01299d56 146
ddb08e02 147#if wxMAC_USE_CORE_GRAPHICS
fb5246be 148class WXDLLEXPORT wxMacCGContextStateSaver
ddb08e02
SC
149{
150 DECLARE_NO_COPY_CLASS(wxMacCGContextStateSaver)
fb5246be 151
ddb08e02 152public:
fb5246be 153 wxMacCGContextStateSaver( CGContextRef cg )
ddb08e02 154 {
6cce68ea
SC
155 m_cg = cg;
156 CGContextSaveGState( cg );
ddb08e02 157 }
fb5246be 158 ~wxMacCGContextStateSaver()
ddb08e02 159 {
6cce68ea 160 CGContextRestoreGState( m_cg );
ddb08e02
SC
161 }
162private:
6cce68ea
SC
163 CGContextRef m_cg;
164};
ddb08e02
SC
165
166#endif
4f305456 167/*
8cf73271
SC
168class wxMacDrawingHelper
169{
170 DECLARE_NO_COPY_CLASS(wxMacDrawingHelper)
fb5246be 171
8cf73271 172public:
6cce68ea
SC
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; }
8cf73271 180private:
6cce68ea
SC
181 Point m_origin;
182 GrafPtr m_formerPort;
183 GrafPtr m_currentPort;
184 PenState m_savedPenState;
185 bool m_ok;
186};
4f305456 187*/
8cf73271
SC
188
189// app.h
6cce68ea 190bool wxMacConvertEventToRecord( EventRef event , EventRecord *rec);
8cf73271
SC
191
192#endif // wxUSE_GUI
193
194// filefn.h
6cce68ea
SC
195WXDLLEXPORT wxString wxMacFSSpec2MacFilename( const FSSpec *spec );
196WXDLLEXPORT void wxMacFilename2FSSpec( const wxString &path , FSSpec *spec );
8cf73271
SC
197
198// utils.h
17af82fb
VZ
199WXDLLEXPORT wxString wxMacFindFolderNoSeparator(short vRefNum,
200 OSType folderType,
201 Boolean createFolder);
8cf73271
SC
202WXDLLEXPORT wxString wxMacFindFolder(short vRefNum,
203 OSType folderType,
204 Boolean createFolder);
205
6cce68ea
SC
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; }
4f305456 219#if TARGET_API_MAC_OSX
6cce68ea
SC
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; }
4f305456 225#endif
b1fd3bad 226#if TARGET_API_MAC_OSX && ( MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2 )
6cce68ea 227template<> inline EventParamType wxMacGetEventParamType<CFDictionaryRef>() { return typeCFDictionaryRef; }
b1fd3bad 228#endif
6cce68ea
SC
229template<> inline EventParamType wxMacGetEventParamType<Collection>() { return typeCollection; }
230template<> inline EventParamType wxMacGetEventParamType<CGContextRef>() { return typeCGContextRef; }
4f305456 231/*
885fb02f 232 These are ambiguous
6cce68ea
SC
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; }
885fb02f 237 */
4f305456
SC
238
239class wxMacCarbonEvent
240{
fb5246be 241
4f305456 242public :
a4848597
SC
243 wxMacCarbonEvent()
244 {
6cce68ea
SC
245 m_eventRef = 0;
246 m_release = false;
a4848597 247 }
fb5246be
WS
248
249 wxMacCarbonEvent( EventRef event , bool release = false )
4f305456 250 {
6cce68ea
SC
251 m_eventRef = event;
252 m_release = release;
6d4c54a7 253 }
fb5246be
WS
254
255 wxMacCarbonEvent(UInt32 inClassID,UInt32 inKind,EventTime inWhen = 0 /*now*/,EventAttributes inAttributes=kEventAttributeNone)
6d4c54a7 256 {
6cce68ea
SC
257 m_eventRef = NULL;
258 verify_noerr( MacCreateEvent( NULL , inClassID, inKind,inWhen,inAttributes,&m_eventRef) );
259 m_release = true;
6d4c54a7 260 }
fb5246be 261
6d4c54a7
SC
262 ~wxMacCarbonEvent()
263 {
264 if ( m_release )
6cce68ea 265 ReleaseEvent( m_eventRef );
4f305456 266 }
fb5246be
WS
267
268 OSStatus Create(UInt32 inClassID,UInt32 inKind,EventTime inWhen = 0 /*now*/,EventAttributes inAttributes=kEventAttributeNone)
a4848597 269 {
6cce68ea 270 verify( (m_eventRef == NULL) || m_release );
a4848597
SC
271 if ( m_eventRef && m_release )
272 {
6cce68ea
SC
273 ReleaseEvent( m_eventRef );
274 m_release = false;
275 m_eventRef = NULL;
a4848597 276 }
6cce68ea 277 OSStatus err = MacCreateEvent( NULL , inClassID, inKind,inWhen,inAttributes,&m_eventRef);
a4848597 278 if ( err == noErr )
6cce68ea
SC
279 m_release = true;
280 return err;
a4848597 281 }
fb5246be 282
6cce68ea 283 OSStatus GetParameter( EventParamName inName, EventParamType inDesiredType, UInt32 inBufferSize, void * outData);
fb5246be 284
4f305456
SC
285 template <typename T> OSStatus GetParameter( EventParamName inName, EventParamType type , T *data )
286 {
6cce68ea 287 return GetParameter( inName, type , sizeof( T ) , data );
4f305456
SC
288 }
289 template <typename T> OSStatus GetParameter( EventParamName inName, T *data )
290 {
6cce68ea 291 return GetParameter<T>( inName, wxMacGetEventParamType<T>() , data );
4f305456 292 }
fb5246be 293
4f305456
SC
294 template <typename T> T GetParameter( EventParamName inName )
295 {
6cce68ea
SC
296 T value;
297 verify_noerr( GetParameter<T>( inName, &value ) );
298 return value;
4f305456
SC
299 }
300 template <typename T> T GetParameter( EventParamName inName, EventParamType inDesiredType )
301 {
6cce68ea
SC
302 T value;
303 verify_noerr( GetParameter<T>( inName, inDesiredType , &value ) );
304 return value;
4f305456 305 }
fb5246be 306
6cce68ea 307 OSStatus SetParameter( EventParamName inName, EventParamType inType, UInt32 inSize, const void * inData);
6d4c54a7 308 template <typename T> OSStatus SetParameter( EventParamName inName, EventParamType inDesiredType , const T *data )
4f305456 309 {
6cce68ea 310 return SetParameter( inName, inDesiredType , sizeof( T ) , data );
2aefa0ef 311 }
6d4c54a7 312 template <typename T> OSStatus SetParameter( EventParamName inName, EventParamType inDesiredType , const T& data )
2aefa0ef 313 {
6cce68ea 314 return SetParameter<T>( inName, inDesiredType , &data );
4f305456 315 }
6d4c54a7 316 template <typename T> OSStatus SetParameter( EventParamName inName, const T *data )
4f305456 317 {
6cce68ea 318 return SetParameter<T>( inName, wxMacGetEventParamType<T>() , data );
4f305456 319 }
6d4c54a7 320 template <typename T> OSStatus SetParameter( EventParamName inName, const T& data )
2aefa0ef 321 {
6cce68ea 322 return SetParameter<T>( inName, wxMacGetEventParamType<T>() , &data );
2aefa0ef 323 }
86d8b744
SC
324 UInt32 GetClass()
325 {
6cce68ea 326 return ::GetEventClass( m_eventRef );
86d8b744 327 }
41b53169 328 UInt32 GetKind()
4f305456 329 {
6cce68ea 330 return ::GetEventKind( m_eventRef );
4f305456
SC
331 }
332 EventTime GetTime()
333 {
6cce68ea 334 return ::GetEventTime( m_eventRef );
4f305456
SC
335 }
336 UInt32 GetTicks()
337 {
6cce68ea 338 return EventTimeToTicks( GetTime() );
4f305456 339 }
2c01d335 340 OSStatus SetCurrentTime( )
a4848597 341 {
6cce68ea 342 return ::SetEventTime( m_eventRef , GetCurrentEventTime() );
2c01d335 343 }
fb5246be 344 OSStatus SetTime( EventTime when )
2c01d335 345 {
6cce68ea 346 return ::SetEventTime( m_eventRef , when );
a4848597
SC
347 }
348 operator EventRef () { return m_eventRef; }
fb5246be 349
6cce68ea 350 bool IsValid() { return m_eventRef != 0; }
4f305456 351protected :
6cce68ea
SC
352 EventRef m_eventRef;
353 bool m_release;
354};
4f305456 355
3feeb1e1
SC
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 {
6cce68ea
SC
365 m_upp = NULL;
366 m_upp = (*newUPP)( NULL );
3feeb1e1
SC
367 }
368 ~wxMacUPP()
369 {
370 if ( m_upp )
6cce68ea 371 disposeUPP( m_upp );
3feeb1e1 372 }
6cce68ea 373 operator uppType() { return m_upp; }
3feeb1e1 374private :
6cce68ea
SC
375 uppType m_upp;
376};
3feeb1e1 377
6cce68ea 378typedef wxMacUPP<NMProcPtr,NMUPP,NewNMUPP,DisposeNMUPP> wxMacNMUPP;
3feeb1e1 379
18b94824
SC
380template <typename refType> class wxMacCFRefHolder
381{
382public :
383 wxMacCFRefHolder()
fb5246be 384 : m_ref(NULL) , m_release(false)
18b94824
SC
385 {
386 }
fb5246be
WS
387
388 wxMacCFRefHolder( refType ref , bool release = true )
18b94824
SC
389 : m_ref(ref) , m_release(release)
390 {
391 }
fb5246be 392
18b94824
SC
393 ~wxMacCFRefHolder()
394 {
6cce68ea 395 Release();
18b94824 396 }
fb5246be 397
18b94824
SC
398 void Release()
399 {
400 if ( m_release && m_ref != NULL )
6cce68ea
SC
401 CFRelease( m_ref );
402 m_ref = NULL;
18b94824 403 }
fb5246be 404
18b94824
SC
405 refType Detach()
406 {
6cce68ea
SC
407 refType val = m_ref;
408 m_release = false;
409 m_ref = NULL;
410 return val;
18b94824 411 }
fb5246be 412
18b94824
SC
413 void Set( refType ref , bool release = true )
414 {
6cce68ea
SC
415 Release();
416 m_release = release;
417 m_ref = ref;
18b94824 418 }
fb5246be 419
18b94824 420 operator refType () const { return m_ref; }
fb5246be 421
18b94824 422private :
6cce68ea
SC
423 refType m_ref;
424 bool m_release;
fb5246be 425
18b94824 426 DECLARE_NO_COPY_CLASS( wxMacCFRefHolder )
6cce68ea 427};
18b94824 428
885fb02f 429#if wxUSE_GUI
6cce68ea
SC
430
431#include "wx/listbox.h"
432
20b69855 433/*
6cce68ea
SC
434GWorldPtr wxMacCreateGWorld( int width , int height , int depth );
435void wxMacDestroyGWorld( GWorldPtr gw );
436PicHandle wxMacCreatePict( GWorldPtr gw , GWorldPtr mask = NULL );
437CIconHandle wxMacCreateCIcon(GWorldPtr image , GWorldPtr mask , short dstDepth , short iconSize );
438void wxMacSetColorTableEntry( CTabHandle newColors , int index , int red , int green , int blue );
439CTabHandle wxMacCreateColorTable( int numColors );
20b69855 440*/
6cce68ea
SC
441void wxMacCreateBitmapButton( ControlButtonContentInfo*info , const wxBitmap& bitmap , int forceType = 0 );
442void wxMacReleaseBitmapButton( ControlButtonContentInfo*info );
885fb02f
SC
443
444#define MAC_WXCOLORREF(a) (*((RGBColor*)&(a)))
445#define MAC_WXHBITMAP(a) (GWorldPtr(a))
446#define MAC_WXHMETAFILE(a) (PicHandle(a))
20b69855 447#define MAC_WXHICON(a) (IconRef(a))
885fb02f
SC
448#define MAC_WXHCURSOR(a) (CursHandle(a))
449#define MAC_WXHRGN(a) (RgnHandle(a))
450#define MAC_WXHWND(a) (WindowPtr(a))
451#define MAC_WXRECPTR(a) ((Rect*)a)
452#define MAC_WXPOINTPTR(a) ((Point*)a)
453#define MAC_WXHMENU(a) ((MenuHandle)a)
454
455struct wxOpaqueWindowRef
456{
6cce68ea
SC
457 wxOpaqueWindowRef( WindowRef ref ) { m_data = ref; }
458 operator WindowRef() { return m_data; }
885fb02f 459private :
6cce68ea
SC
460 WindowRef m_data;
461};
885fb02f 462
6cce68ea
SC
463void wxMacRectToNative( const wxRect *wx , Rect *n );
464void wxMacNativeToRect( const Rect *n , wxRect* wx );
465void wxMacPointToNative( const wxPoint* wx , Point *n );
466void wxMacNativeToPoint( const Point *n , wxPoint* wx );
285b5ce0 467
6cce68ea
SC
468wxWindow * wxFindControlFromMacControl(ControlRef inControl );
469wxTopLevelWindowMac* wxFindWinFromMacWindow( WindowRef inWindow );
470wxMenu* wxFindMenuFromMacMenu(MenuRef inMenuRef);
885fb02f 471
6cce68ea
SC
472int wxMacCommandToId( UInt32 macCommandId );
473UInt32 wxIdToMacCommand( int wxId );
474wxMenu* wxFindMenuFromMacCommand( const HICommand &macCommandId , wxMenuItem* &item );
1628261e 475
6cce68ea
SC
476extern wxWindow* g_MacLastWindow;
477pascal OSStatus wxMacTopLevelMouseEventHandler( EventHandlerCallRef handler , EventRef event , void *data );
478Rect wxMacGetBoundsForControl( wxWindow* window , const wxPoint& pos , const wxSize &size , bool adjustForOrigin = true );
885fb02f 479
6cce68ea 480ControlActionUPP GetwxMacLiveScrollbarActionProc();
285b5ce0 481
86d8b744
SC
482class wxMacControl
483{
484public :
6cce68ea
SC
485 wxMacControl( wxWindow* peer , bool isRootControl = false );
486 wxMacControl( wxWindow* peer , ControlRef control );
487 wxMacControl( wxWindow* peer , WXWidget control );
488 virtual ~wxMacControl();
489
490 void Init();
fb5246be 491
6cce68ea 492 virtual void Dispose();
fb5246be 493
6cce68ea 494 bool Ok() const { return GetControlRef() != NULL; }
5ca0d812 495
6cce68ea
SC
496 void SetReferenceInNativeControl();
497 static wxMacControl* GetReferenceFromNativeControl(ControlRef control);
5ca0d812 498
fb5246be 499 virtual ControlRef * GetControlRefAddr() { return &m_controlRef; }
6cce68ea 500 virtual ControlRef GetControlRef() const { return m_controlRef; }
fb5246be 501
6cce68ea 502 virtual void SetReference( SInt32 data );
5ca0d812 503 /*
6cce68ea 504 void operator= (ControlRef c) { m_controlRef = c; }
fb5246be
WS
505 operator ControlRef () { return m_controlRef; }
506 operator ControlRef * () { return &m_controlRef; }
5ca0d812 507 */
2837271a
SC
508 // accessing data and values
509
6cce68ea
SC
510 virtual OSStatus SetData( ControlPartCode inPartCode , ResType inTag , Size inSize , const void * inData );
511 virtual OSStatus GetData( ControlPartCode inPartCode , ResType inTag , Size inBufferSize , void * inOutBuffer , Size * outActualSize ) const;
512 virtual OSStatus GetDataSize( ControlPartCode inPartCode , ResType inTag , Size * outActualSize ) const;
513 virtual OSStatus SendEvent( EventRef ref , OptionBits inOptions = 0 );
514 virtual OSStatus SendHICommand( HICommand &command , OptionBits inOptions = 0 );
2837271a 515
6cce68ea 516 virtual OSStatus SendHICommand( UInt32 commandID , OptionBits inOptions = 0 );
2837271a 517
6cce68ea
SC
518 virtual SInt32 GetValue() const;
519 virtual SInt32 GetMaximum() const;
520 virtual SInt32 GetMinimum() const;
fb5246be 521
6cce68ea
SC
522 virtual void SetValue( SInt32 v );
523 virtual void SetMinimum( SInt32 v );
524 virtual void SetMaximum( SInt32 v );
2837271a 525
6cce68ea
SC
526 virtual void SetValueAndRange( SInt32 value , SInt32 minimum , SInt32 maximum );
527 virtual void SetRange( SInt32 minimum , SInt32 maximum );
fb5246be 528
6cce68ea
SC
529 virtual OSStatus SetFocus( ControlFocusPart focusPart );
530 virtual bool HasFocus() const;
531 virtual bool NeedsFocusRect() const;
532 virtual void SetNeedsFocusRect( bool needs );
fb5246be 533
2837271a
SC
534 // templated helpers
535
0fc3bc3b 536 Size GetDataSize( ControlPartCode inPartCode , ResType inTag ) const
86d8b744 537 {
6cce68ea
SC
538 Size sz;
539 verify_noerr( GetDataSize( inPartCode , inTag , &sz ) );
540 return sz;
86d8b744 541 }
6d4c54a7 542 template <typename T> OSStatus SetData( ControlPartCode inPartCode , ResType inTag , const T *data )
86d8b744 543 {
6cce68ea 544 return SetData( inPartCode , inTag , sizeof( T ) , data );
86d8b744 545 }
6d4c54a7 546 template <typename T> OSStatus SetData( ControlPartCode inPartCode , ResType inTag , const T& data )
86d8b744 547 {
6cce68ea 548 return SetData( inPartCode , inTag , sizeof( T ) , &data );
86d8b744 549 }
fbb7ee81
SC
550 template <typename T> OSStatus SetData( ResType inTag , const T *data )
551 {
6cce68ea 552 return SetData( kControlEntireControl , inTag , sizeof( T ) , data );
fbb7ee81
SC
553 }
554 template <typename T> OSStatus SetData( ResType inTag , const T& data )
555 {
6cce68ea 556 return SetData( kControlEntireControl , inTag , sizeof( T ) , &data );
fbb7ee81 557 }
0fc3bc3b 558 template <typename T> OSStatus GetData( ControlPartCode inPartCode , ResType inTag , T *data ) const
86d8b744 559 {
6cce68ea
SC
560 Size dummy;
561 return GetData( inPartCode , inTag , sizeof( T ) , data , &dummy );
86d8b744 562 }
0fc3bc3b 563 template <typename T> T GetData( ControlPartCode inPartCode , ResType inTag ) const
86d8b744 564 {
6cce68ea
SC
565 T value;
566 OSStatus err = GetData<T>( inPartCode , inTag , &value );
567
568 wxASSERT_MSG(err == noErr, wxString::Format(wxT("GetData Failed for Part [%i] and Tag [%i]"),
569 inPartCode, inTag));
570 return value;
86d8b744 571 }
fbb7ee81
SC
572 template <typename T> OSStatus GetData( ResType inTag , T *data ) const
573 {
6cce68ea
SC
574 Size dummy;
575 return GetData( kControlEntireControl , inTag , sizeof( T ) , data , &dummy );
fbb7ee81
SC
576 }
577 template <typename T> T GetData( ResType inTag ) const
578 {
6cce68ea 579 return GetData<T>( kControlEntireControl , inTag );
fbb7ee81
SC
580 }
581
6d4c54a7 582 // Flash the control for the specified amount of time
6cce68ea 583 virtual void Flash( ControlPartCode part , UInt32 ticks = 8 );
89a66f11 584
6cce68ea
SC
585 virtual void VisibilityChanged( bool shown );
586 virtual void SuperChangedPosition();
89a66f11
SC
587
588
6cce68ea
SC
589 virtual void SetFont( const wxFont & font , const wxColour& foreground , long windowStyle );
590 virtual void SetBackground( const wxBrush &brush );
591 virtual ControlPartCode HandleKey( SInt16 keyCode, SInt16 charCode, EventModifiers modifiers );
592 void SetActionProc( ControlActionUPP actionProc );
593 void SetViewSize( SInt32 viewSize );
594 SInt32 GetViewSize() const;
fb5246be 595
6cce68ea
SC
596 virtual bool IsVisible() const;
597 virtual void SetVisibility( bool visible , bool redraw );
598 virtual bool IsEnabled() const;
599 virtual bool IsActive() const;
600 virtual void Enable( bool enable );
fb5246be 601
5ca0d812 602 // invalidates this control and all children
6cce68ea
SC
603 virtual void InvalidateWithChildren();
604 virtual void SetDrawingEnabled( bool enable );
b905d6cc 605#ifdef __WXMAC_OSX__
6cce68ea 606 virtual bool GetNeedsDisplay() const;
b905d6cc 607#endif
285b5ce0 608 // where is in native window relative coordinates
6cce68ea 609 virtual void SetNeedsDisplay( RgnHandle where );
285b5ce0 610 // where is in native window relative coordinates
6cce68ea 611 virtual void SetNeedsDisplay( Rect* where = NULL );
285b5ce0 612
fb5246be 613 // if rect = NULL, entire view
6cce68ea 614 virtual void ScrollRect( wxRect *rect , int dx , int dy );
5ca0d812 615
285b5ce0 616 // in native parent window relative coordinates
6cce68ea 617 virtual void GetRect( Rect *r );
285b5ce0
SC
618
619 // in native parent window relative coordinates
6cce68ea 620 virtual void SetRect( Rect *r );
285b5ce0 621
6cce68ea
SC
622 virtual void GetRectInWindowCoords( Rect *r );
623 virtual void GetBestRect( Rect *r );
624 virtual void SetLabel( const wxString &title );
5ca0d812 625 // converts from Toplevel-Content relative to local
6cce68ea 626 static void Convert( wxPoint *pt , wxMacControl *convert , wxMacControl *to );
fb5246be 627
6cce68ea
SC
628 virtual void GetFeatures( UInt32 *features );
629 virtual OSStatus GetRegion( ControlPartCode partCode , RgnHandle region );
630 virtual OSStatus SetZOrder( bool above , wxMacControl* other );
ba5b8a68 631
6cce68ea
SC
632 bool IsCompositing() { return m_isCompositing; }
633 bool IsRootControl() { return m_isRootControl; }
634
635 wxWindow* GetPeer() const
636 {
637 return m_peer;
638 }
ba5b8a68
SC
639
640 // to be moved into a tab control class
641
6cce68ea
SC
642 virtual OSStatus SetTabEnabled( SInt16 tabNo , bool enable );
643protected :
644 ControlRef m_controlRef;
645 wxFont m_font;
646 long m_windowStyle;
647 wxWindow* m_peer;
648 bool m_needsFocusRect;
649 bool m_isCompositing;
650 bool m_isRootControl;
651};
652
653// ============================================================================
654// DataBrowser Wrapper
655// ============================================================================
656//
657// basing on DataBrowserItemIDs
658//
659
660class wxMacDataBrowserControl : public wxMacControl
661{
662public :
663 wxMacDataBrowserControl( wxWindow* peer, const wxPoint& pos, const wxSize& size, long style);
664
665 OSStatus SetCallbacks( const DataBrowserCallbacks *callbacks );
666
667 OSStatus GetItemCount( DataBrowserItemID container,
668 Boolean recurse,
669 DataBrowserItemState state,
670 UInt32 *numItems) const;
671
672 OSStatus GetItems( DataBrowserItemID container,
673 Boolean recurse,
674 DataBrowserItemState state,
675 Handle items) const;
676
677
678 OSStatus AddColumn( DataBrowserListViewColumnDesc *columnDesc,
679 DataBrowserTableViewColumnIndex position );
680
681 OSStatus AutoSizeColumns();
682
683 OSStatus SetHasScrollBars( bool horiz, bool vert );
684 OSStatus SetHiliteStyle( DataBrowserTableViewHiliteStyle hiliteStyle );
685
686 OSStatus SetHeaderButtonHeight( UInt16 height );
687 OSStatus GetHeaderButtonHeight( UInt16 *height );
688
689 OSStatus UpdateItems( DataBrowserItemID container, UInt32 numItems,
690 const DataBrowserItemID *items,
691 DataBrowserPropertyID preSortProperty,
692 DataBrowserPropertyID propertyID ) const;
693
694 OSStatus AddItems( DataBrowserItemID container, UInt32 numItems,
695 const DataBrowserItemID *items,
696 DataBrowserPropertyID preSortProperty );
697 OSStatus RemoveItems( DataBrowserItemID container, UInt32 numItems,
698 const DataBrowserItemID *items,
699 DataBrowserPropertyID preSortProperty );
700 OSStatus RevealItem( DataBrowserItemID item,
701 DataBrowserPropertyID propertyID,
702 DataBrowserRevealOptions options ) const;
703
704 OSStatus SetSelectionFlags( DataBrowserSelectionFlags );
705 OSStatus GetSelectionAnchor( DataBrowserItemID *first, DataBrowserItemID *last ) const;
706 bool IsItemSelected( DataBrowserItemID item ) const;
707 OSStatus SetSelectedItems( UInt32 numItems,
708 const DataBrowserItemID *items,
709 DataBrowserSetOption operation );
710
711 OSStatus GetItemID( DataBrowserTableViewRowIndex row,
712 DataBrowserItemID * item ) const;
713 OSStatus GetItemRow( DataBrowserItemID item,
714 DataBrowserTableViewRowIndex * row ) const;
715
716 OSStatus SetDefaultRowHeight( UInt16 height );
717 OSStatus GetDefaultRowHeight( UInt16 * height ) const;
718
719 OSStatus SetRowHeight( DataBrowserItemID item , UInt16 height);
720 OSStatus GetRowHeight( DataBrowserItemID item , UInt16 *height) const;
721
722 OSStatus GetColumnWidth( DataBrowserPropertyID column , UInt16 *width ) const;
723 OSStatus SetColumnWidth( DataBrowserPropertyID column , UInt16 width );
724
725 OSStatus GetDefaultColumnWidth( UInt16 *width ) const;
726 OSStatus SetDefaultColumnWidth( UInt16 width );
727
728 OSStatus GetColumnCount( UInt32* numColumns) const;
729
730 OSStatus GetColumnPosition( DataBrowserPropertyID column, UInt32 *position) const;
731 OSStatus SetColumnPosition( DataBrowserPropertyID column, UInt32 position);
732
733 OSStatus GetScrollPosition( UInt32 *top , UInt32 *left ) const;
734 OSStatus SetScrollPosition( UInt32 top , UInt32 left );
735
736 OSStatus GetSortProperty( DataBrowserPropertyID *column ) const;
737 OSStatus SetSortProperty( DataBrowserPropertyID column );
738
739 OSStatus GetSortOrder( DataBrowserSortOrder *order ) const;
740 OSStatus SetSortOrder( DataBrowserSortOrder order );
741
742 OSStatus GetPropertyFlags( DataBrowserPropertyID property, DataBrowserPropertyFlags *flags ) const;
743 OSStatus SetPropertyFlags( DataBrowserPropertyID property, DataBrowserPropertyFlags flags );
744
745 OSStatus GetHeaderDesc( DataBrowserPropertyID property, DataBrowserListViewHeaderDesc *desc ) const;
746 OSStatus SetHeaderDesc( DataBrowserPropertyID property, DataBrowserListViewHeaderDesc *desc );
747
748 OSStatus SetDisclosureColumn( DataBrowserPropertyID property , Boolean expandableRows );
86d8b744 749protected :
6cce68ea
SC
750
751 static pascal void DataBrowserItemNotificationProc(
752 ControlRef browser,
753 DataBrowserItemID itemID,
754 DataBrowserItemNotification message,
755 DataBrowserItemDataRef itemData );
756
757 virtual void ItemNotification(
758 DataBrowserItemID itemID,
759 DataBrowserItemNotification message,
760 DataBrowserItemDataRef itemData) = 0;
761
762 static pascal OSStatus DataBrowserGetSetItemDataProc(
763 ControlRef browser,
764 DataBrowserItemID itemID,
765 DataBrowserPropertyID property,
766 DataBrowserItemDataRef itemData,
767 Boolean changeValue );
768
769 virtual OSStatus GetSetItemData(
770 DataBrowserItemID itemID,
771 DataBrowserPropertyID property,
772 DataBrowserItemDataRef itemData,
773 Boolean changeValue ) = 0;
774
775 static pascal Boolean DataBrowserCompareProc(
776 ControlRef browser,
777 DataBrowserItemID itemOneID,
778 DataBrowserItemID itemTwoID,
779 DataBrowserPropertyID sortProperty);
780
781 virtual Boolean CompareItems(DataBrowserItemID itemOneID,
782 DataBrowserItemID itemTwoID,
783 DataBrowserPropertyID sortProperty) = 0;
784};
785
786// ============================================================================
787// Higher-level Databrowser
788// ============================================================================
789//
790// basing on data item objects
791//
792
793// forward decl
794
795class wxMacDataItemBrowserControl;
796
797// base class for databrowser items
798
799class wxMacDataItem
800{
801public :
802 wxMacDataItem();
803 virtual ~wxMacDataItem();
804
805 virtual bool IsLessThan(wxMacDataItemBrowserControl *owner ,
806 const wxMacDataItem*,
807 DataBrowserPropertyID property) const;
808
809 // returns true if access was successful, otherwise false
810 virtual OSStatus GetSetData(wxMacDataItemBrowserControl *owner ,
811 DataBrowserPropertyID property,
812 DataBrowserItemDataRef itemData,
813 bool changeValue );
814
815 virtual void Notification(wxMacDataItemBrowserControl *owner ,
816 DataBrowserItemNotification message,
817 DataBrowserItemDataRef itemData ) const;
818};
819
820typedef wxMacDataItem* wxMacDataItemPtr;
821const wxMacDataItemPtr wxMacDataBrowserRootContainer = NULL;
822
823WX_DEFINE_USER_EXPORTED_ARRAY_PTR(wxMacDataItemPtr, wxArrayMacDataItemPtr, class WXDLLIMPEXP_CORE);
824
825class wxMacDataItemBrowserControl : public wxMacDataBrowserControl
826{
827public :
828 wxMacDataItemBrowserControl( wxWindow* peer , const wxPoint& pos, const wxSize& size, long style);
829
830 unsigned int GetItemCount(const wxMacDataItem* container, bool recurse , DataBrowserItemState state) const;
831 void GetItems(const wxMacDataItem* container, bool recurse ,
832 DataBrowserItemState state, wxArrayMacDataItemPtr &items ) const;
833
834 unsigned int GetLineFromItem(const wxMacDataItem *item) const;
835 wxMacDataItem * GetItemFromLine(unsigned int n) const;
836
837 void UpdateItem(const wxMacDataItem *container, const wxMacDataItem *item,
838 DataBrowserPropertyID property) const;
839 void UpdateItems(const wxMacDataItem *container, wxArrayMacDataItemPtr &items,
840 DataBrowserPropertyID property) const;
841
842 void AddItem(wxMacDataItem *container, wxMacDataItem *item);
843 void AddItems(wxMacDataItem *container, wxArrayMacDataItemPtr &items );
844
845 void RemoveAllItems(wxMacDataItem *container);
846 void RemoveItem(wxMacDataItem *container, wxMacDataItem* item);
847 void RemoveItems(wxMacDataItem *container, wxArrayMacDataItemPtr &items);
848
849 void SetSelectedItem( wxMacDataItem* item , DataBrowserSetOption option);
850 void SetSelectedItems( wxArrayMacDataItemPtr &items , DataBrowserSetOption option);
851 void SetSelectedAllItems( DataBrowserSetOption option);
852 Boolean IsItemSelected( const wxMacDataItem* item) const;
853
854 void RevealItem( wxMacDataItem* item, DataBrowserRevealOptions options);
855
856 void GetSelectionAnchor( wxMacDataItemPtr* first , wxMacDataItemPtr* last) const;
857
858 // item aware methods, to be used in subclasses
859
860 virtual Boolean CompareItems(const wxMacDataItem* itemOneID,
861 const wxMacDataItem* itemTwoID,
862 DataBrowserPropertyID sortProperty);
863
864 virtual OSStatus GetSetItemData(wxMacDataItem* itemID,
865 DataBrowserPropertyID property,
866 DataBrowserItemDataRef itemData,
867 Boolean changeValue );
868
869 virtual void ItemNotification(
870 const wxMacDataItem* itemID,
871 DataBrowserItemNotification message,
872 DataBrowserItemDataRef itemData);
8b64a7e2
PC
873
874 // as we are getting the same events for human and API selection we have to suppress
875 // events in the latter case, since this will be used from many subclasses we keep it here
876
877 bool IsSelectionSuppressed() const { return m_suppressSelection; }
878 bool SuppressSelection( bool suppress );
879
880protected:
6cce68ea
SC
881 // ID aware base methods, should be 'final' ie not changed in subclasses
882
883 virtual Boolean CompareItems(DataBrowserItemID itemOneID,
884 DataBrowserItemID itemTwoID,
885 DataBrowserPropertyID sortProperty);
886
887 virtual OSStatus GetSetItemData(DataBrowserItemID itemID,
888 DataBrowserPropertyID property,
889 DataBrowserItemDataRef itemData,
890 Boolean changeValue );
891
892 virtual void ItemNotification(
893 DataBrowserItemID itemID,
894 DataBrowserItemNotification message,
895 DataBrowserItemDataRef itemData);
896
6cce68ea
SC
897private :
898
899 bool m_suppressSelection;
900};
901
902class wxMacDataItemBrowserSelectionSuppressor
903{
904public :
905 wxMacDataItemBrowserSelectionSuppressor(wxMacDataItemBrowserControl *browser);
906 ~wxMacDataItemBrowserSelectionSuppressor();
907
908private :
909
910 bool m_former;
911 wxMacDataItemBrowserControl* m_browser;
912};
913
914// ============================================================================
915// platform listbox implementation
916// ============================================================================
917//
918// exposed for reuse in wxCheckListBox
919
920class wxMacListBoxItem : public wxMacDataItem
921{
922public :
923 wxMacListBoxItem();
924
925 virtual ~wxMacListBoxItem();
926
927 void SetLabel( const wxString& str);
928 const wxString& GetLabel() const;
929
930 virtual bool IsLessThan(wxMacDataItemBrowserControl *owner ,
931 const wxMacDataItem* rhs,
932 DataBrowserPropertyID sortProperty) const;
933
934 virtual OSStatus GetSetData( wxMacDataItemBrowserControl *owner ,
935 DataBrowserPropertyID property,
936 DataBrowserItemDataRef itemData,
937 bool changeValue );
938
939 virtual void Notification(wxMacDataItemBrowserControl *owner ,
940 DataBrowserItemNotification message,
941 DataBrowserItemDataRef itemData ) const;
942
943 void SetOrder( SInt32 order );
944 SInt32 GetOrder() const;
945
946 void SetData( void* data);
947 void* GetData() const;
948
949private :
950 wxString m_label;
951 wxMacCFStringHolder m_cfLabel;
952 void * m_data;
953 SInt32 m_order;
954};
955
956class wxMacDataBrowserListControl : public wxMacDataItemBrowserControl , public wxMacListControl
957{
958public:
959 wxMacDataBrowserListControl( wxListBox *peer, const wxPoint& pos, const wxSize& size, long style );
960 ~wxMacDataBrowserListControl();
961
962 // create a list item (can be a subclass of wxMacListBoxItem)
963
964 virtual wxMacListBoxItem* CreateItem();
965
966 // add and remove
967
968 void MacDelete( unsigned int n );
969 void MacInsert( unsigned int n, const wxString& item );
970 void MacInsert( unsigned int n, const wxArrayString& items );
971 int MacAppend( const wxString& item );
972 void MacClear();
973
974 // selecting
975
976 void MacDeselectAll();
977 void MacSetSelection( unsigned int n, bool select );
978 int MacGetSelection() const;
979 int MacGetSelections( wxArrayInt& aSelections ) const;
980 bool MacIsSelected( unsigned int n ) const;
981
982 // display
983
984 void MacScrollTo( unsigned int n );
985
986 // accessing content
987
988 void MacSetString( unsigned int n, const wxString& item );
989 void MacSetClientData( unsigned int n, void * data);
990 wxString MacGetString( unsigned int n) const;
991 void * MacGetClientData( unsigned int) const;
992 unsigned int MacGetCount() const;
993
994 // client data
995
996 wxClientDataType GetClientDataType() const;
997 void SetClientDataType(wxClientDataType clientDataItemsType);
998
999 // pointing back
1000
1001 wxListBox * GetPeer() const;
1002private :
1003 bool m_stringSorted;
1004 wxClientDataType m_clientDataItemsType;
1005};
1006
1007// ============================================================================
1008// graphics implementation
1009// ============================================================================
86d8b744 1010
20b69855
SC
1011#if wxMAC_USE_CORE_GRAPHICS
1012
fb5246be 1013class WXDLLEXPORT wxMacCGPath : public wxGraphicPath
20b69855
SC
1014{
1015 DECLARE_NO_COPY_CLASS(wxMacCGPath)
1016public :
6cce68ea
SC
1017 wxMacCGPath();
1018 ~wxMacCGPath();
fb5246be 1019
20b69855 1020 // Starts a new subpath at
6cce68ea
SC
1021 void MoveToPoint( wxCoord x1 , wxCoord y1 );
1022 void AddLineToPoint( wxCoord x1 , wxCoord y1 );
1023 void AddQuadCurveToPoint( wxCoord cx1, wxCoord cy1, wxCoord x1, wxCoord y1 );
1024 void AddRectangle( wxCoord x, wxCoord y, wxCoord w, wxCoord h );
1025 void AddCircle( wxCoord x, wxCoord y , wxCoord r );
fb5246be 1026
20b69855 1027 // closes the current subpath
6cce68ea 1028 void CloseSubpath();
fb5246be 1029
6cce68ea 1030 CGPathRef GetPath() const;
20b69855 1031private :
6cce68ea
SC
1032 CGMutablePathRef m_path;
1033};
20b69855
SC
1034
1035class WXDLLEXPORT wxMacCGContext : public wxGraphicContext
1036{
1037 DECLARE_NO_COPY_CLASS(wxMacCGContext)
fb5246be 1038
20b69855 1039public:
6cce68ea
SC
1040 wxMacCGContext( CGrafPtr port );
1041 wxMacCGContext( CGContextRef cgcontext );
1042 wxMacCGContext();
1043 ~wxMacCGContext();
1044
1045 virtual void Clip( const wxRegion &region );
1046 virtual void StrokePath( const wxGraphicPath *p );
1047 virtual void DrawPath( const wxGraphicPath *p , int fillStyle = wxWINDING_RULE );
1048 virtual void FillPath( const wxGraphicPath *p , const wxColor &fillColor , int fillStyle = wxWINDING_RULE );
1049
1050 virtual wxGraphicPath* CreatePath();
1051 virtual void SetPen( const wxPen &pen ) ;
1052 virtual void SetBrush( const wxBrush &brush );
1053 CGContextRef GetNativeContext();
1054 void SetNativeContext( CGContextRef cg );
1055 CGPathDrawingMode GetDrawingMode() const { return m_mode; }
20b69855 1056private:
6cce68ea
SC
1057 CGContextRef m_cgContext;
1058 CGrafPtr m_qdPort;
1059 CGPathDrawingMode m_mode;
1060 wxPen m_pen;
1061 wxBrush m_brush;
1062};
20b69855 1063
30e77b5c
SC
1064#endif // wxMAC_USE_CORE_GRAPHICS
1065
1066#ifdef __WXMAC_OSX__
1067
6cce68ea
SC
1068CGColorSpaceRef wxMacGetGenericRGBColorSpace(void);
1069void wxMacMemoryBufferReleaseProc(void *info, const void *data, size_t size);
20b69855 1070
30e77b5c 1071#endif
20b69855
SC
1072
1073class WXDLLEXPORT wxBitmapRefData: public wxGDIRefData
1074{
1075 DECLARE_NO_COPY_CLASS(wxBitmapRefData)
fb5246be 1076
20b69855
SC
1077 friend class WXDLLEXPORT wxIcon;
1078 friend class WXDLLEXPORT wxCursor;
1079public:
1080 wxBitmapRefData(int width , int height , int depth);
1081 wxBitmapRefData();
1082 ~wxBitmapRefData();
1083
6cce68ea
SC
1084 void Free();
1085 bool Ok() const { return m_ok; }
1086 void SetOk( bool isOk) { m_ok = isOk; }
fb5246be 1087
6cce68ea
SC
1088 void SetWidth( int width ) { m_width = width; }
1089 void SetHeight( int height ) { m_height = height; }
1090 void SetDepth( int depth ) { m_depth = depth; }
20b69855 1091
6cce68ea
SC
1092 int GetWidth() const { return m_width; }
1093 int GetHeight() const { return m_height; }
1094 int GetDepth() const { return m_depth; }
fb5246be 1095
6cce68ea
SC
1096 void *GetRawAccess() const;
1097 void *BeginRawAccess();
1098 void EndRawAccess();
20b69855 1099
6cce68ea
SC
1100 bool HasAlpha() const { return m_hasAlpha; }
1101 void UseAlpha( bool useAlpha );
20b69855
SC
1102
1103public:
1104#if wxUSE_PALETTE
1105 wxPalette m_bitmapPalette;
1106#endif // wxUSE_PALETTE
fb5246be 1107
20b69855 1108 wxMask * m_bitmapMask; // Optional mask
30e77b5c 1109#ifdef __WXMAC_OSX__
6cce68ea 1110 CGImageRef CGImageCreate() const;
71cc158e 1111#endif
fb5246be 1112
6d2c830a
SC
1113 // returns true if the bitmap has a size that
1114 // can be natively transferred into a true icon
1115 // if no is returned GetIconRef will still produce
1116 // an icon but it will be generated via a PICT and
fb5246be 1117 // rescaled to 16 x 16
6cce68ea 1118 bool HasNativeSize();
fb5246be 1119
6d2c830a
SC
1120 // caller should increase ref count if needed longer
1121 // than the bitmap exists
6cce68ea 1122 IconRef GetIconRef();
fb5246be 1123
6d2c830a 1124 // returns a Pict from the bitmap content
6cce68ea
SC
1125 PicHandle GetPictHandle();
1126 GWorldPtr GetHBITMAP(GWorldPtr * mask = NULL ) const;
1127 void UpdateAlphaMask() const;
71cc158e 1128
20b69855 1129private :
6cce68ea
SC
1130 bool Create(int width , int height , int depth);
1131 void Init();
20b69855
SC
1132
1133 int m_width;
1134 int m_height;
6cce68ea 1135 int m_bytesPerRow;
20b69855
SC
1136 int m_depth;
1137 bool m_hasAlpha;
6cce68ea
SC
1138 wxMemoryBuffer m_memBuf;
1139 int m_rawAccessCount;
20b69855 1140 bool m_ok;
30e77b5c 1141#ifdef __WXMAC_OSX__
6cce68ea 1142 mutable CGImageRef m_cgImageRef;
71cc158e 1143#endif
6cce68ea
SC
1144 IconRef m_iconRef;
1145 PicHandle m_pictHandle;
20b69855 1146 GWorldPtr m_hBitmap;
6cce68ea
SC
1147 GWorldPtr m_hMaskBitmap;
1148 wxMemoryBuffer m_maskMemBuf;
1149 int m_maskBytesPerRow;
20b69855
SC
1150};
1151
20b69855
SC
1152class WXDLLEXPORT wxIconRefData : public wxGDIRefData
1153{
1154public:
6cce68ea
SC
1155 wxIconRefData();
1156 wxIconRefData( WXHICON );
20b69855
SC
1157 virtual ~wxIconRefData() { Free(); }
1158
6cce68ea 1159 void Init();
20b69855 1160 virtual void Free();
ddb08e02 1161
6cce68ea
SC
1162 void SetWidth( int width ) { m_width = width; }
1163 void SetHeight( int height ) { m_height = height; }
ddb08e02 1164
6cce68ea
SC
1165 int GetWidth() const { return m_width; }
1166 int GetHeight() const { return m_height; }
ddb08e02 1167
6cce68ea 1168 WXHICON GetHICON() const { return (WXHICON) m_iconRef; }
20b69855 1169private :
6cce68ea
SC
1170 IconRef m_iconRef;
1171 int m_width;
1172 int m_height;
20b69855
SC
1173};
1174
285b5ce0
SC
1175// toplevel.cpp
1176
6cce68ea 1177ControlRef wxMacFindControlUnderMouse( wxTopLevelWindowMac* toplevelWindow, const Point& location , WindowRef window , ControlPartCode *outPart );
285b5ce0 1178
ecf418ad 1179#ifdef WORDS_BIGENDIAN
7358f907
SC
1180 inline Rect* wxMacGetPictureBounds( PicHandle pict , Rect* rect )
1181 {
6cce68ea
SC
1182 *rect = (**pict).picFrame;
1183 return rect;
7358f907
SC
1184 }
1185#else
1186 inline Rect* wxMacGetPictureBounds( PicHandle pict , Rect* rect )
1187 {
6cce68ea 1188 return QDGetPictureBounds( pict , rect );
7358f907
SC
1189 }
1190#endif
1191
8cf73271
SC
1192#endif // wxUSE_GUI
1193
285b5ce0
SC
1194#define wxMAC_DEFINE_PROC_GETTER( UPP , x ) \
1195UPP Get##x() \
1196{ \
1197 static UPP sHandler = NULL; \
1198 if ( sHandler == NULL ) \
1199 sHandler = New##UPP( x ); \
1200 return sHandler; \
1201}
1202
8cf73271
SC
1203//---------------------------------------------------------------------------
1204// wxMac string conversions
1205//---------------------------------------------------------------------------
1206
6cce68ea
SC
1207void wxMacSetupConverters();
1208void wxMacCleanupConverters();
8cf73271 1209
6cce68ea
SC
1210void wxMacStringToPascal( const wxString&from , StringPtr to );
1211wxString wxMacMakeStringFromPascal( ConstStringPtr from );
8cf73271 1212
a2b77260
SC
1213// filefn.cpp
1214
6cce68ea
SC
1215wxString wxMacFSRefToPath( const FSRef *fsRef , CFStringRef additionalPathComponent = NULL );
1216OSStatus wxMacPathToFSRef( const wxString&path , FSRef *fsRef );
1217wxString wxMacHFSUniStrToString( ConstHFSUniStr255Param uniname );
aa0cc8a1 1218
8cf73271
SC
1219#endif
1220 // _WX_PRIVATE_H_