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