]> git.saurik.com Git - wxWidgets.git/blame - include/wx/mac/carbon/private.h
Restore compilation with --enable-stl, fix SetFocus with the generic control, and...
[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
bf9a1615 490class wxMacControl : public wxObject
86d8b744
SC
491{
492public :
6cce68ea
SC
493 wxMacControl( wxWindow* peer , bool isRootControl = false );
494 wxMacControl( wxWindow* peer , ControlRef control );
495 wxMacControl( wxWindow* peer , WXWidget control );
bf9a1615 496 wxMacControl() ;
6cce68ea
SC
497 virtual ~wxMacControl();
498
499 void Init();
fb5246be 500
6cce68ea 501 virtual void Dispose();
fb5246be 502
b7cacb43
VZ
503 bool Ok() const { return IsOk(); }
504 bool IsOk() const { return GetControlRef() != NULL; }
5ca0d812 505
6cce68ea
SC
506 void SetReferenceInNativeControl();
507 static wxMacControl* GetReferenceFromNativeControl(ControlRef control);
5ca0d812 508
fb5246be 509 virtual ControlRef * GetControlRefAddr() { return &m_controlRef; }
6cce68ea 510 virtual ControlRef GetControlRef() const { return m_controlRef; }
fb5246be 511
eb89f88a 512 virtual void SetReference( URefCon data );
5ca0d812 513 /*
6cce68ea 514 void operator= (ControlRef c) { m_controlRef = c; }
fb5246be
WS
515 operator ControlRef () { return m_controlRef; }
516 operator ControlRef * () { return &m_controlRef; }
5ca0d812 517 */
2837271a
SC
518 // accessing data and values
519
6cce68ea
SC
520 virtual OSStatus SetData( ControlPartCode inPartCode , ResType inTag , Size inSize , const void * inData );
521 virtual OSStatus GetData( ControlPartCode inPartCode , ResType inTag , Size inBufferSize , void * inOutBuffer , Size * outActualSize ) const;
522 virtual OSStatus GetDataSize( ControlPartCode inPartCode , ResType inTag , Size * outActualSize ) const;
523 virtual OSStatus SendEvent( EventRef ref , OptionBits inOptions = 0 );
524 virtual OSStatus SendHICommand( HICommand &command , OptionBits inOptions = 0 );
2837271a 525
6cce68ea 526 virtual OSStatus SendHICommand( UInt32 commandID , OptionBits inOptions = 0 );
2837271a 527
6cce68ea
SC
528 virtual SInt32 GetValue() const;
529 virtual SInt32 GetMaximum() const;
530 virtual SInt32 GetMinimum() const;
fb5246be 531
6cce68ea
SC
532 virtual void SetValue( SInt32 v );
533 virtual void SetMinimum( SInt32 v );
534 virtual void SetMaximum( SInt32 v );
2837271a 535
6cce68ea
SC
536 virtual void SetValueAndRange( SInt32 value , SInt32 minimum , SInt32 maximum );
537 virtual void SetRange( SInt32 minimum , SInt32 maximum );
fb5246be 538
6cce68ea
SC
539 virtual OSStatus SetFocus( ControlFocusPart focusPart );
540 virtual bool HasFocus() const;
541 virtual bool NeedsFocusRect() const;
542 virtual void SetNeedsFocusRect( bool needs );
fb5246be 543
2837271a
SC
544 // templated helpers
545
0fc3bc3b 546 Size GetDataSize( ControlPartCode inPartCode , ResType inTag ) const
86d8b744 547 {
6cce68ea
SC
548 Size sz;
549 verify_noerr( GetDataSize( inPartCode , inTag , &sz ) );
550 return sz;
86d8b744 551 }
6d4c54a7 552 template <typename T> OSStatus SetData( ControlPartCode inPartCode , ResType inTag , const T *data )
86d8b744 553 {
6cce68ea 554 return SetData( inPartCode , inTag , sizeof( T ) , data );
86d8b744 555 }
6d4c54a7 556 template <typename T> OSStatus SetData( ControlPartCode inPartCode , ResType inTag , const T& data )
86d8b744 557 {
6cce68ea 558 return SetData( inPartCode , inTag , sizeof( T ) , &data );
86d8b744 559 }
fbb7ee81
SC
560 template <typename T> OSStatus SetData( ResType inTag , const T *data )
561 {
6cce68ea 562 return SetData( kControlEntireControl , inTag , sizeof( T ) , data );
fbb7ee81
SC
563 }
564 template <typename T> OSStatus SetData( ResType inTag , const T& data )
565 {
6cce68ea 566 return SetData( kControlEntireControl , inTag , sizeof( T ) , &data );
fbb7ee81 567 }
0fc3bc3b 568 template <typename T> OSStatus GetData( ControlPartCode inPartCode , ResType inTag , T *data ) const
86d8b744 569 {
6cce68ea
SC
570 Size dummy;
571 return GetData( inPartCode , inTag , sizeof( T ) , data , &dummy );
86d8b744 572 }
0fc3bc3b 573 template <typename T> T GetData( ControlPartCode inPartCode , ResType inTag ) const
86d8b744 574 {
6cce68ea
SC
575 T value;
576 OSStatus err = GetData<T>( inPartCode , inTag , &value );
725566ca
VZ
577
578 wxASSERT_MSG( err == noErr,
579 wxString::Format(wxT("GetData Failed for Part [%i] and Tag [%i]"),
580 inPartCode, (int)inTag) );
6cce68ea 581 return value;
86d8b744 582 }
fbb7ee81
SC
583 template <typename T> OSStatus GetData( ResType inTag , T *data ) const
584 {
6cce68ea
SC
585 Size dummy;
586 return GetData( kControlEntireControl , inTag , sizeof( T ) , data , &dummy );
fbb7ee81
SC
587 }
588 template <typename T> T GetData( ResType inTag ) const
589 {
6cce68ea 590 return GetData<T>( kControlEntireControl , inTag );
fbb7ee81 591 }
725566ca 592
6d4c54a7 593 // Flash the control for the specified amount of time
6cce68ea 594 virtual void Flash( ControlPartCode part , UInt32 ticks = 8 );
89a66f11 595
6cce68ea
SC
596 virtual void VisibilityChanged( bool shown );
597 virtual void SuperChangedPosition();
89a66f11
SC
598
599
6cce68ea
SC
600 virtual void SetFont( const wxFont & font , const wxColour& foreground , long windowStyle );
601 virtual void SetBackground( const wxBrush &brush );
602 virtual ControlPartCode HandleKey( SInt16 keyCode, SInt16 charCode, EventModifiers modifiers );
603 void SetActionProc( ControlActionUPP actionProc );
604 void SetViewSize( SInt32 viewSize );
605 SInt32 GetViewSize() const;
fb5246be 606
6cce68ea
SC
607 virtual bool IsVisible() const;
608 virtual void SetVisibility( bool visible , bool redraw );
609 virtual bool IsEnabled() const;
610 virtual bool IsActive() const;
611 virtual void Enable( bool enable );
fb5246be 612
5ca0d812 613 // invalidates this control and all children
6cce68ea
SC
614 virtual void InvalidateWithChildren();
615 virtual void SetDrawingEnabled( bool enable );
b905d6cc 616#ifdef __WXMAC_OSX__
6cce68ea 617 virtual bool GetNeedsDisplay() const;
b905d6cc 618#endif
285b5ce0 619 // where is in native window relative coordinates
6cce68ea 620 virtual void SetNeedsDisplay( RgnHandle where );
285b5ce0 621 // where is in native window relative coordinates
6cce68ea 622 virtual void SetNeedsDisplay( Rect* where = NULL );
285b5ce0 623
fb5246be 624 // if rect = NULL, entire view
6cce68ea 625 virtual void ScrollRect( wxRect *rect , int dx , int dy );
5ca0d812 626
285b5ce0 627 // in native parent window relative coordinates
6cce68ea 628 virtual void GetRect( Rect *r );
285b5ce0
SC
629
630 // in native parent window relative coordinates
6cce68ea 631 virtual void SetRect( Rect *r );
285b5ce0 632
6cce68ea
SC
633 virtual void GetRectInWindowCoords( Rect *r );
634 virtual void GetBestRect( Rect *r );
635 virtual void SetLabel( const wxString &title );
5ca0d812 636 // converts from Toplevel-Content relative to local
6cce68ea 637 static void Convert( wxPoint *pt , wxMacControl *convert , wxMacControl *to );
fb5246be 638
6cce68ea
SC
639 virtual void GetFeatures( UInt32 *features );
640 virtual OSStatus GetRegion( ControlPartCode partCode , RgnHandle region );
641 virtual OSStatus SetZOrder( bool above , wxMacControl* other );
725566ca 642
6cce68ea 643 bool IsRootControl() { return m_isRootControl; }
725566ca 644
6cce68ea
SC
645 wxWindow* GetPeer() const
646 {
647 return m_peer;
648 }
ba5b8a68
SC
649
650 // to be moved into a tab control class
651
6cce68ea
SC
652 virtual OSStatus SetTabEnabled( SInt16 tabNo , bool enable );
653protected :
654 ControlRef m_controlRef;
655 wxFont m_font;
656 long m_windowStyle;
657 wxWindow* m_peer;
658 bool m_needsFocusRect;
6cce68ea 659 bool m_isRootControl;
bf9a1615 660 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacControl)
6cce68ea
SC
661};
662
663// ============================================================================
664// DataBrowser Wrapper
665// ============================================================================
666//
667// basing on DataBrowserItemIDs
668//
669
670class wxMacDataBrowserControl : public wxMacControl
671{
672public :
673 wxMacDataBrowserControl( wxWindow* peer, const wxPoint& pos, const wxSize& size, long style);
bf9a1615 674 wxMacDataBrowserControl() {}
6cce68ea
SC
675
676 OSStatus SetCallbacks( const DataBrowserCallbacks *callbacks );
725566ca 677
6cce68ea
SC
678 OSStatus GetItemCount( DataBrowserItemID container,
679 Boolean recurse,
680 DataBrowserItemState state,
eb89f88a 681 ItemCount *numItems) const;
725566ca 682
6cce68ea
SC
683 OSStatus GetItems( DataBrowserItemID container,
684 Boolean recurse,
685 DataBrowserItemState state,
686 Handle items) const;
725566ca 687
6cce68ea
SC
688
689 OSStatus AddColumn( DataBrowserListViewColumnDesc *columnDesc,
690 DataBrowserTableViewColumnIndex position );
7b514b3b 691
e2bc1d69 692 OSStatus RemoveColumn( DataBrowserTableViewColumnIndex position );
725566ca 693
6cce68ea 694 OSStatus AutoSizeColumns();
725566ca 695
6cce68ea
SC
696 OSStatus SetHasScrollBars( bool horiz, bool vert );
697 OSStatus SetHiliteStyle( DataBrowserTableViewHiliteStyle hiliteStyle );
725566ca 698
6cce68ea
SC
699 OSStatus SetHeaderButtonHeight( UInt16 height );
700 OSStatus GetHeaderButtonHeight( UInt16 *height );
701
702 OSStatus UpdateItems( DataBrowserItemID container, UInt32 numItems,
703 const DataBrowserItemID *items,
704 DataBrowserPropertyID preSortProperty,
705 DataBrowserPropertyID propertyID ) const;
725566ca 706
6cce68ea
SC
707 OSStatus AddItems( DataBrowserItemID container, UInt32 numItems,
708 const DataBrowserItemID *items,
709 DataBrowserPropertyID preSortProperty );
710 OSStatus RemoveItems( DataBrowserItemID container, UInt32 numItems,
711 const DataBrowserItemID *items,
712 DataBrowserPropertyID preSortProperty );
713 OSStatus RevealItem( DataBrowserItemID item,
714 DataBrowserPropertyID propertyID,
715 DataBrowserRevealOptions options ) const;
716
717 OSStatus SetSelectionFlags( DataBrowserSelectionFlags );
718 OSStatus GetSelectionAnchor( DataBrowserItemID *first, DataBrowserItemID *last ) const;
719 bool IsItemSelected( DataBrowserItemID item ) const;
720 OSStatus SetSelectedItems( UInt32 numItems,
721 const DataBrowserItemID *items,
722 DataBrowserSetOption operation );
723
725566ca 724 OSStatus GetItemID( DataBrowserTableViewRowIndex row,
6cce68ea 725 DataBrowserItemID * item ) const;
725566ca 726 OSStatus GetItemRow( DataBrowserItemID item,
6cce68ea 727 DataBrowserTableViewRowIndex * row ) const;
725566ca 728
6cce68ea
SC
729 OSStatus SetDefaultRowHeight( UInt16 height );
730 OSStatus GetDefaultRowHeight( UInt16 * height ) const;
725566ca 731
6cce68ea
SC
732 OSStatus SetRowHeight( DataBrowserItemID item , UInt16 height);
733 OSStatus GetRowHeight( DataBrowserItemID item , UInt16 *height) const;
725566ca 734
6cce68ea
SC
735 OSStatus GetColumnWidth( DataBrowserPropertyID column , UInt16 *width ) const;
736 OSStatus SetColumnWidth( DataBrowserPropertyID column , UInt16 width );
725566ca 737
6cce68ea
SC
738 OSStatus GetDefaultColumnWidth( UInt16 *width ) const;
739 OSStatus SetDefaultColumnWidth( UInt16 width );
725566ca 740
6cce68ea
SC
741 OSStatus GetColumnCount( UInt32* numColumns) const;
742
e2bc1d69
KO
743 OSStatus GetColumnIDFromIndex( DataBrowserTableViewColumnIndex position, DataBrowserTableViewColumnID* id );
744
eb89f88a
SC
745 OSStatus GetColumnPosition( DataBrowserPropertyID column, DataBrowserTableViewColumnIndex *position) const;
746 OSStatus SetColumnPosition( DataBrowserPropertyID column, DataBrowserTableViewColumnIndex position);
725566ca 747
6cce68ea
SC
748 OSStatus GetScrollPosition( UInt32 *top , UInt32 *left ) const;
749 OSStatus SetScrollPosition( UInt32 top , UInt32 left );
725566ca 750
6cce68ea
SC
751 OSStatus GetSortProperty( DataBrowserPropertyID *column ) const;
752 OSStatus SetSortProperty( DataBrowserPropertyID column );
725566ca 753
6cce68ea
SC
754 OSStatus GetSortOrder( DataBrowserSortOrder *order ) const;
755 OSStatus SetSortOrder( DataBrowserSortOrder order );
725566ca 756
6cce68ea
SC
757 OSStatus GetPropertyFlags( DataBrowserPropertyID property, DataBrowserPropertyFlags *flags ) const;
758 OSStatus SetPropertyFlags( DataBrowserPropertyID property, DataBrowserPropertyFlags flags );
725566ca 759
6cce68ea
SC
760 OSStatus GetHeaderDesc( DataBrowserPropertyID property, DataBrowserListViewHeaderDesc *desc ) const;
761 OSStatus SetHeaderDesc( DataBrowserPropertyID property, DataBrowserListViewHeaderDesc *desc );
725566ca 762
6cce68ea 763 OSStatus SetDisclosureColumn( DataBrowserPropertyID property , Boolean expandableRows );
86d8b744 764protected :
725566ca 765
6cce68ea
SC
766 static pascal void DataBrowserItemNotificationProc(
767 ControlRef browser,
768 DataBrowserItemID itemID,
769 DataBrowserItemNotification message,
770 DataBrowserItemDataRef itemData );
771
772 virtual void ItemNotification(
773 DataBrowserItemID itemID,
774 DataBrowserItemNotification message,
775 DataBrowserItemDataRef itemData) = 0;
776
777 static pascal OSStatus DataBrowserGetSetItemDataProc(
778 ControlRef browser,
779 DataBrowserItemID itemID,
780 DataBrowserPropertyID property,
781 DataBrowserItemDataRef itemData,
782 Boolean changeValue );
783
784 virtual OSStatus GetSetItemData(
785 DataBrowserItemID itemID,
786 DataBrowserPropertyID property,
787 DataBrowserItemDataRef itemData,
788 Boolean changeValue ) = 0;
789
790 static pascal Boolean DataBrowserCompareProc(
1b88201f
WS
791 ControlRef browser,
792 DataBrowserItemID itemOneID,
793 DataBrowserItemID itemTwoID,
794 DataBrowserPropertyID sortProperty);
795
796 virtual Boolean CompareItems(DataBrowserItemID itemOneID,
797 DataBrowserItemID itemTwoID,
798 DataBrowserPropertyID sortProperty) = 0;
bf9a1615 799 DECLARE_ABSTRACT_CLASS(wxMacDataBrowserControl)
6cce68ea
SC
800};
801
802// ============================================================================
725566ca 803// Higher-level Databrowser
6cce68ea
SC
804// ============================================================================
805//
806// basing on data item objects
807//
808
809// forward decl
810
811class wxMacDataItemBrowserControl;
e2bc1d69
KO
812class wxMacListBoxItem;
813
e362c2b9
SC
814const DataBrowserPropertyID kTextColumnId = 1024;
815const DataBrowserPropertyID kNumericOrderColumnId = 1025;
e2bc1d69 816
7b514b3b 817// for multi-column controls, we will use this + the column ID to identify the
e2bc1d69 818// column. We don't use kTextColumnId there, and ideally the two should merge.
e362c2b9 819const DataBrowserPropertyID kMinColumnId = 1050;
e2bc1d69
KO
820
821// base API for high-level databrowser operations
822
823class wxMacListControl
824{
825public:
826 virtual void MacDelete( unsigned int n ) = 0;
827 virtual void MacInsert( unsigned int n, const wxString& item, int column = -1 ) = 0;
828 virtual void MacInsert( unsigned int n, const wxArrayString& items, int column = -1 ) = 0;
829 // returns index of newly created line
830 virtual int MacAppend( const wxString& item ) = 0;
831 virtual void MacSetString( unsigned int n, const wxString& item ) = 0;
832 virtual void MacClear() = 0;
833 virtual void MacDeselectAll() = 0;
834 virtual void MacSetSelection( unsigned int n, bool select, bool multi ) = 0;
835 virtual int MacGetSelection() const = 0;
836 virtual int MacGetSelections( wxArrayInt& aSelections ) const = 0;
837 virtual bool MacIsSelected( unsigned int n ) const = 0;
838 virtual void MacScrollTo( unsigned int n ) = 0;
839 virtual wxString MacGetString( unsigned int n) const = 0;
840 virtual unsigned int MacGetCount() const = 0;
841
842 virtual void MacSetClientData( unsigned int n, void * data) = 0;
843 virtual void * MacGetClientData( unsigned int) const = 0;
844
845 virtual ~wxMacListControl() { }
7b514b3b 846};
6cce68ea
SC
847
848// base class for databrowser items
849
e2bc1d69
KO
850enum DataItemType {
851 DataItem_Text
852};
853
6cce68ea
SC
854class wxMacDataItem
855{
856public :
857 wxMacDataItem();
858 virtual ~wxMacDataItem();
725566ca
VZ
859
860 virtual bool IsLessThan(wxMacDataItemBrowserControl *owner ,
861 const wxMacDataItem*,
6cce68ea 862 DataBrowserPropertyID property) const;
725566ca 863
6cce68ea 864 // returns true if access was successful, otherwise false
725566ca 865 virtual OSStatus GetSetData(wxMacDataItemBrowserControl *owner ,
6cce68ea
SC
866 DataBrowserPropertyID property,
867 DataBrowserItemDataRef itemData,
868 bool changeValue );
869
725566ca 870 virtual void Notification(wxMacDataItemBrowserControl *owner ,
6cce68ea
SC
871 DataBrowserItemNotification message,
872 DataBrowserItemDataRef itemData ) const;
7b514b3b 873
e2bc1d69 874 void SetLabel( const wxString& str);
7b514b3b 875 const wxString& GetLabel() const;
e2bc1d69
KO
876
877 void SetOrder( SInt32 order );
878 SInt32 GetOrder() const;
879
880 void SetData( void* data);
881 void* GetData() const;
7b514b3b 882
e2bc1d69 883 void SetColumn( short col );
7b514b3b
VZ
884 short GetColumn();
885
e2bc1d69
KO
886protected :
887 wxString m_label;
888 wxMacCFStringHolder m_cfLabel;
889 void * m_data;
890 SInt32 m_order;
7b514b3b
VZ
891 DataBrowserPropertyID m_colId;
892
e2bc1d69
KO
893};
894
895enum ListSortOrder {
896 SortOrder_None,
897 SortOrder_Text_Ascending,
898 SortOrder_Text_Descending
6cce68ea
SC
899};
900
901typedef wxMacDataItem* wxMacDataItemPtr;
902const wxMacDataItemPtr wxMacDataBrowserRootContainer = NULL;
903
904WX_DEFINE_USER_EXPORTED_ARRAY_PTR(wxMacDataItemPtr, wxArrayMacDataItemPtr, class WXDLLIMPEXP_CORE);
905
e2bc1d69 906class wxMacDataItemBrowserControl : public wxMacDataBrowserControl, public wxMacListControl
6cce68ea
SC
907{
908public :
909 wxMacDataItemBrowserControl( wxWindow* peer , const wxPoint& pos, const wxSize& size, long style);
bf9a1615 910 wxMacDataItemBrowserControl() {}
e2bc1d69
KO
911 // create a list item (can be a subclass of wxMacListBoxItem)
912
913 virtual wxMacDataItem* CreateItem();
914
6cce68ea 915 unsigned int GetItemCount(const wxMacDataItem* container, bool recurse , DataBrowserItemState state) const;
725566ca 916 void GetItems(const wxMacDataItem* container, bool recurse ,
6cce68ea 917 DataBrowserItemState state, wxArrayMacDataItemPtr &items ) const;
7b514b3b 918
e2bc1d69 919 unsigned int GetSelectedItemCount( const wxMacDataItem* container, bool recurse ) const;
725566ca 920
6cce68ea
SC
921 unsigned int GetLineFromItem(const wxMacDataItem *item) const;
922 wxMacDataItem * GetItemFromLine(unsigned int n) const;
725566ca
VZ
923
924 void UpdateItem(const wxMacDataItem *container, const wxMacDataItem *item,
6cce68ea 925 DataBrowserPropertyID property) const;
725566ca 926 void UpdateItems(const wxMacDataItem *container, wxArrayMacDataItemPtr &items,
6cce68ea 927 DataBrowserPropertyID property) const;
725566ca 928
3ef4e126
SC
929 void InsertColumn(int colId, DataBrowserPropertyType colType,
930 const wxString& title, SInt16 just = teFlushDefault, int defaultWidth = -1);
7b514b3b 931
e2bc1d69
KO
932 int GetColumnWidth(int colId);
933 void SetColumnWidth(int colId, int width);
934
6cce68ea
SC
935 void AddItem(wxMacDataItem *container, wxMacDataItem *item);
936 void AddItems(wxMacDataItem *container, wxArrayMacDataItemPtr &items );
937
938 void RemoveAllItems(wxMacDataItem *container);
939 void RemoveItem(wxMacDataItem *container, wxMacDataItem* item);
940 void RemoveItems(wxMacDataItem *container, wxArrayMacDataItemPtr &items);
725566ca 941
6cce68ea
SC
942 void SetSelectedItem( wxMacDataItem* item , DataBrowserSetOption option);
943 void SetSelectedItems( wxArrayMacDataItemPtr &items , DataBrowserSetOption option);
944 void SetSelectedAllItems( DataBrowserSetOption option);
945 Boolean IsItemSelected( const wxMacDataItem* item) const;
725566ca 946
6cce68ea 947 void RevealItem( wxMacDataItem* item, DataBrowserRevealOptions options);
725566ca 948
6cce68ea 949 void GetSelectionAnchor( wxMacDataItemPtr* first , wxMacDataItemPtr* last) const;
725566ca 950
6cce68ea 951 // item aware methods, to be used in subclasses
725566ca
VZ
952
953 virtual Boolean CompareItems(const wxMacDataItem* itemOneID,
954 const wxMacDataItem* itemTwoID,
6cce68ea
SC
955 DataBrowserPropertyID sortProperty);
956
957 virtual OSStatus GetSetItemData(wxMacDataItem* itemID,
958 DataBrowserPropertyID property,
959 DataBrowserItemDataRef itemData,
960 Boolean changeValue );
961
962 virtual void ItemNotification(
963 const wxMacDataItem* itemID,
964 DataBrowserItemNotification message,
965 DataBrowserItemDataRef itemData);
8b64a7e2
PC
966
967 // as we are getting the same events for human and API selection we have to suppress
968 // events in the latter case, since this will be used from many subclasses we keep it here
969
970 bool IsSelectionSuppressed() const { return m_suppressSelection; }
971 bool SuppressSelection( bool suppress );
7b514b3b
VZ
972
973
e2bc1d69
KO
974 // wxMacListControl Methods
975 // add and remove
976
977 virtual void MacDelete( unsigned int n );
978 virtual void MacInsert( unsigned int n, const wxString& item, int column = -1 );
979 virtual void MacInsert( unsigned int n, const wxArrayString& items, int column = -1 );
980 virtual int MacAppend( const wxString& item );
981 virtual void MacClear();
982
983 // selecting
984
985 virtual void MacDeselectAll();
986 virtual void MacSetSelection( unsigned int n, bool select, bool multi = false );
987 virtual int MacGetSelection() const;
988 virtual int MacGetSelections( wxArrayInt& aSelections ) const;
989 virtual bool MacIsSelected( unsigned int n ) const;
990
991 // display
992
993 virtual void MacScrollTo( unsigned int n );
994
995 // accessing content
996
997 virtual void MacSetString( unsigned int n, const wxString& item );
998 virtual void MacSetClientData( unsigned int n, void * data);
999 virtual wxString MacGetString( unsigned int n) const;
1000 virtual void * MacGetClientData( unsigned int) const;
1001 virtual unsigned int MacGetCount() const;
1002
1003 // client data
1004
1005 virtual wxClientDataType GetClientDataType() const;
1006 virtual void SetClientDataType(wxClientDataType clientDataItemsType);
67650ea0
KO
1007 //virtual ListSortOrder GetSortOrder() const;
1008 //virtual void SetSortOrder(const ListSortOrder sort);
e2bc1d69 1009
7b514b3b 1010
8b64a7e2
PC
1011
1012protected:
e2bc1d69
KO
1013
1014 ListSortOrder m_sortOrder;
1015 wxClientDataType m_clientDataItemsType;
1016
6cce68ea 1017 // ID aware base methods, should be 'final' ie not changed in subclasses
725566ca
VZ
1018
1019 virtual Boolean CompareItems(DataBrowserItemID itemOneID,
1020 DataBrowserItemID itemTwoID,
6cce68ea
SC
1021 DataBrowserPropertyID sortProperty);
1022
1023 virtual OSStatus GetSetItemData(DataBrowserItemID itemID,
1024 DataBrowserPropertyID property,
1025 DataBrowserItemDataRef itemData,
1026 Boolean changeValue );
1027
1028 virtual void ItemNotification(
1029 DataBrowserItemID itemID,
1030 DataBrowserItemNotification message,
1031 DataBrowserItemDataRef itemData);
1032
e2bc1d69 1033
6cce68ea
SC
1034private :
1035
1036 bool m_suppressSelection;
bf9a1615 1037 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacDataItemBrowserControl)
6cce68ea
SC
1038};
1039
1040class wxMacDataItemBrowserSelectionSuppressor
1041{
1042public :
1043 wxMacDataItemBrowserSelectionSuppressor(wxMacDataItemBrowserControl *browser);
1044 ~wxMacDataItemBrowserSelectionSuppressor();
725566ca 1045
6cce68ea
SC
1046private :
1047
1048 bool m_former;
1049 wxMacDataItemBrowserControl* m_browser;
1050};
1051
1052// ============================================================================
1053// platform listbox implementation
1054// ============================================================================
e2bc1d69 1055
6cce68ea
SC
1056// exposed for reuse in wxCheckListBox
1057
1058class wxMacListBoxItem : public wxMacDataItem
1059{
1060public :
1061 wxMacListBoxItem();
725566ca 1062
6cce68ea 1063 virtual ~wxMacListBoxItem();
725566ca 1064
725566ca 1065 virtual void Notification(wxMacDataItemBrowserControl *owner ,
6cce68ea
SC
1066 DataBrowserItemNotification message,
1067 DataBrowserItemDataRef itemData ) const;
6cce68ea
SC
1068};
1069
e2bc1d69 1070class wxMacDataBrowserListControl : public wxMacDataItemBrowserControl
6cce68ea
SC
1071{
1072public:
e2bc1d69 1073 wxMacDataBrowserListControl( wxWindow *peer, const wxPoint& pos, const wxSize& size, long style );
bf9a1615 1074 wxMacDataBrowserListControl() {}
d3c7fc99 1075 virtual ~wxMacDataBrowserListControl();
6cce68ea 1076
e6fd62dd
RD
1077 virtual wxMacDataItem* CreateItem();
1078
6cce68ea
SC
1079 // pointing back
1080
e2bc1d69
KO
1081 wxWindow * GetPeer() const;
1082
bf9a1615 1083 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacDataBrowserListControl)
6cce68ea
SC
1084};
1085
1086// ============================================================================
1087// graphics implementation
1088// ============================================================================
86d8b744 1089
cd7d36c0 1090#if wxMAC_USE_CORE_GRAPHICS && !wxUSE_GRAPHICS_CONTEXT
20b69855 1091
fb5246be 1092class WXDLLEXPORT wxMacCGPath : public wxGraphicPath
20b69855
SC
1093{
1094 DECLARE_NO_COPY_CLASS(wxMacCGPath)
1095public :
6cce68ea
SC
1096 wxMacCGPath();
1097 ~wxMacCGPath();
fb5246be 1098
20b69855 1099 // Starts a new subpath at
6cce68ea
SC
1100 void MoveToPoint( wxCoord x1 , wxCoord y1 );
1101 void AddLineToPoint( wxCoord x1 , wxCoord y1 );
1102 void AddQuadCurveToPoint( wxCoord cx1, wxCoord cy1, wxCoord x1, wxCoord y1 );
1103 void AddRectangle( wxCoord x, wxCoord y, wxCoord w, wxCoord h );
1104 void AddCircle( wxCoord x, wxCoord y , wxCoord r );
fb5246be 1105
a85ff267
SC
1106 // draws a an arc to two tangents connecting (current) to (x1,y1) and (x1,y1) to (x2,y2)
1107 virtual void AddArcToPoint( wxCoord x1, wxCoord y1 , wxCoord x2, wxCoord y2, wxCoord r ) ;
1108 virtual void AddArc( wxCoord x, wxCoord y, wxCoord r, double startAngle, double endAngle, bool clockwise ) ;
1109
20b69855 1110 // closes the current subpath
6cce68ea 1111 void CloseSubpath();
fb5246be 1112
6cce68ea 1113 CGPathRef GetPath() const;
20b69855 1114private :
6cce68ea
SC
1115 CGMutablePathRef m_path;
1116};
20b69855
SC
1117
1118class WXDLLEXPORT wxMacCGContext : public wxGraphicContext
1119{
1120 DECLARE_NO_COPY_CLASS(wxMacCGContext)
fb5246be 1121
20b69855 1122public:
6cce68ea
SC
1123 wxMacCGContext( CGrafPtr port );
1124 wxMacCGContext( CGContextRef cgcontext );
1125 wxMacCGContext();
d3c7fc99 1126 virtual ~wxMacCGContext();
6cce68ea
SC
1127
1128 virtual void Clip( const wxRegion &region );
1129 virtual void StrokePath( const wxGraphicPath *p );
1130 virtual void DrawPath( const wxGraphicPath *p , int fillStyle = wxWINDING_RULE );
1131 virtual void FillPath( const wxGraphicPath *p , const wxColor &fillColor , int fillStyle = wxWINDING_RULE );
1132
1133 virtual wxGraphicPath* CreatePath();
1134 virtual void SetPen( const wxPen &pen ) ;
1135 virtual void SetBrush( const wxBrush &brush );
1136 CGContextRef GetNativeContext();
1137 void SetNativeContext( CGContextRef cg );
1138 CGPathDrawingMode GetDrawingMode() const { return m_mode; }
a85ff267 1139
7b514b3b
VZ
1140 virtual void Translate( wxCoord dx , wxCoord dy );
1141 virtual void Scale( wxCoord xScale , wxCoord yScale );
a85ff267
SC
1142 virtual void DrawBitmap( const wxBitmap &bmp, wxCoord x, wxCoord y, wxCoord w, wxCoord h );
1143 virtual void DrawIcon( const wxIcon &icon, wxCoord x, wxCoord y, wxCoord w, wxCoord h );
7b514b3b 1144 virtual void PushState();
a85ff267 1145 virtual void PopState();
7b514b3b 1146
a85ff267 1147 virtual void DrawText( const wxString &str, wxCoord x, wxCoord y, double angle ) ;
7b514b3b 1148
a85ff267
SC
1149 virtual void GetTextExtent( const wxString &str, wxCoord *width, wxCoord *height,
1150 wxCoord *descent, wxCoord *externalLeading ) const ;
7b514b3b 1151
a85ff267 1152 virtual void GetPartialTextExtents(const wxString& text, wxArrayInt& widths) const ;
7b514b3b 1153
a85ff267
SC
1154 virtual void SetFont( const wxFont &font ) ;
1155
7b514b3b 1156 virtual void SetTextColor( const wxColour &col ) ;
20b69855 1157private:
6cce68ea
SC
1158 CGContextRef m_cgContext;
1159 CGrafPtr m_qdPort;
1160 CGPathDrawingMode m_mode;
a85ff267 1161 ATSUStyle m_macATSUIStyle ;
6cce68ea
SC
1162 wxPen m_pen;
1163 wxBrush m_brush;
a85ff267 1164 wxColor m_textForegroundColor ;
6cce68ea 1165};
20b69855 1166
30e77b5c
SC
1167#endif // wxMAC_USE_CORE_GRAPHICS
1168
1169#ifdef __WXMAC_OSX__
1170
6cce68ea
SC
1171CGColorSpaceRef wxMacGetGenericRGBColorSpace(void);
1172void wxMacMemoryBufferReleaseProc(void *info, const void *data, size_t size);
20b69855 1173
30e77b5c 1174#endif
20b69855
SC
1175
1176class WXDLLEXPORT wxBitmapRefData: public wxGDIRefData
1177{
20b69855
SC
1178 friend class WXDLLEXPORT wxIcon;
1179 friend class WXDLLEXPORT wxCursor;
1180public:
1181 wxBitmapRefData(int width , int height , int depth);
1182 wxBitmapRefData();
2bf8f4c0
RD
1183 wxBitmapRefData(const wxBitmapRefData &tocopy);
1184
d3c7fc99 1185 virtual ~wxBitmapRefData();
20b69855 1186
6cce68ea 1187 void Free();
b7cacb43
VZ
1188 bool Ok() const { return IsOk(); }
1189 bool IsOk() const { return m_ok; }
6cce68ea 1190 void SetOk( bool isOk) { m_ok = isOk; }
fb5246be 1191
6cce68ea
SC
1192 void SetWidth( int width ) { m_width = width; }
1193 void SetHeight( int height ) { m_height = height; }
1194 void SetDepth( int depth ) { m_depth = depth; }
20b69855 1195
6cce68ea
SC
1196 int GetWidth() const { return m_width; }
1197 int GetHeight() const { return m_height; }
1198 int GetDepth() const { return m_depth; }
fb5246be 1199
6cce68ea
SC
1200 void *GetRawAccess() const;
1201 void *BeginRawAccess();
1202 void EndRawAccess();
20b69855 1203
6cce68ea
SC
1204 bool HasAlpha() const { return m_hasAlpha; }
1205 void UseAlpha( bool useAlpha );
20b69855
SC
1206
1207public:
1208#if wxUSE_PALETTE
1209 wxPalette m_bitmapPalette;
1210#endif // wxUSE_PALETTE
fb5246be 1211
20b69855 1212 wxMask * m_bitmapMask; // Optional mask
30e77b5c 1213#ifdef __WXMAC_OSX__
6cce68ea 1214 CGImageRef CGImageCreate() const;
71cc158e 1215#endif
fb5246be 1216
6d2c830a
SC
1217 // returns true if the bitmap has a size that
1218 // can be natively transferred into a true icon
1219 // if no is returned GetIconRef will still produce
1220 // an icon but it will be generated via a PICT and
fb5246be 1221 // rescaled to 16 x 16
6cce68ea 1222 bool HasNativeSize();
fb5246be 1223
6d2c830a
SC
1224 // caller should increase ref count if needed longer
1225 // than the bitmap exists
6cce68ea 1226 IconRef GetIconRef();
fb5246be 1227
6d2c830a 1228 // returns a Pict from the bitmap content
6cce68ea
SC
1229 PicHandle GetPictHandle();
1230 GWorldPtr GetHBITMAP(GWorldPtr * mask = NULL ) const;
1231 void UpdateAlphaMask() const;
71cc158e 1232
20b69855 1233private :
6cce68ea
SC
1234 bool Create(int width , int height , int depth);
1235 void Init();
20b69855
SC
1236
1237 int m_width;
1238 int m_height;
6cce68ea 1239 int m_bytesPerRow;
20b69855
SC
1240 int m_depth;
1241 bool m_hasAlpha;
6cce68ea
SC
1242 wxMemoryBuffer m_memBuf;
1243 int m_rawAccessCount;
20b69855 1244 bool m_ok;
30e77b5c 1245#ifdef __WXMAC_OSX__
6cce68ea 1246 mutable CGImageRef m_cgImageRef;
71cc158e 1247#endif
6cce68ea
SC
1248 IconRef m_iconRef;
1249 PicHandle m_pictHandle;
20b69855 1250 GWorldPtr m_hBitmap;
6cce68ea
SC
1251 GWorldPtr m_hMaskBitmap;
1252 wxMemoryBuffer m_maskMemBuf;
1253 int m_maskBytesPerRow;
20b69855
SC
1254};
1255
20b69855
SC
1256class WXDLLEXPORT wxIconRefData : public wxGDIRefData
1257{
1258public:
6cce68ea
SC
1259 wxIconRefData();
1260 wxIconRefData( WXHICON );
20b69855
SC
1261 virtual ~wxIconRefData() { Free(); }
1262
6cce68ea 1263 void Init();
20b69855 1264 virtual void Free();
ddb08e02 1265
6cce68ea
SC
1266 void SetWidth( int width ) { m_width = width; }
1267 void SetHeight( int height ) { m_height = height; }
ddb08e02 1268
6cce68ea
SC
1269 int GetWidth() const { return m_width; }
1270 int GetHeight() const { return m_height; }
ddb08e02 1271
6cce68ea 1272 WXHICON GetHICON() const { return (WXHICON) m_iconRef; }
20b69855 1273private :
6cce68ea
SC
1274 IconRef m_iconRef;
1275 int m_width;
1276 int m_height;
20b69855
SC
1277};
1278
285b5ce0
SC
1279// toplevel.cpp
1280
6cce68ea 1281ControlRef wxMacFindControlUnderMouse( wxTopLevelWindowMac* toplevelWindow, const Point& location , WindowRef window , ControlPartCode *outPart );
285b5ce0 1282
eb89f88a
SC
1283#ifndef __LP64__
1284
ecf418ad 1285#ifdef WORDS_BIGENDIAN
725566ca
VZ
1286 inline Rect* wxMacGetPictureBounds( PicHandle pict , Rect* rect )
1287 {
1288 *rect = (**pict).picFrame;
6cce68ea 1289 return rect;
7358f907
SC
1290 }
1291#else
725566ca
VZ
1292 inline Rect* wxMacGetPictureBounds( PicHandle pict , Rect* rect )
1293 {
6cce68ea 1294 return QDGetPictureBounds( pict , rect );
7358f907
SC
1295 }
1296#endif
1297
eb89f88a
SC
1298#endif
1299
8cf73271
SC
1300#endif // wxUSE_GUI
1301
285b5ce0
SC
1302#define wxMAC_DEFINE_PROC_GETTER( UPP , x ) \
1303UPP Get##x() \
1304{ \
1305 static UPP sHandler = NULL; \
1306 if ( sHandler == NULL ) \
1307 sHandler = New##UPP( x ); \
1308 return sHandler; \
1309}
1310
8cf73271
SC
1311//---------------------------------------------------------------------------
1312// wxMac string conversions
1313//---------------------------------------------------------------------------
1314
6cce68ea
SC
1315void wxMacSetupConverters();
1316void wxMacCleanupConverters();
8cf73271 1317
6cce68ea
SC
1318void wxMacStringToPascal( const wxString&from , StringPtr to );
1319wxString wxMacMakeStringFromPascal( ConstStringPtr from );
8cf73271 1320
a2b77260
SC
1321// filefn.cpp
1322
6cce68ea
SC
1323wxString wxMacFSRefToPath( const FSRef *fsRef , CFStringRef additionalPathComponent = NULL );
1324OSStatus wxMacPathToFSRef( const wxString&path , FSRef *fsRef );
1325wxString wxMacHFSUniStrToString( ConstHFSUniStr255Param uniname );
aa0cc8a1 1326
eb89f88a
SC
1327#if wxUSE_GUI
1328
1329// deprecating QD
1330
1331void wxMacLocalToGlobal( WindowRef window , Point*pt );
1332void wxMacGlobalToLocal( WindowRef window , Point*pt );
1333
1334#endif
1335
8cf73271
SC
1336#endif
1337 // _WX_PRIVATE_H_