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