]> git.saurik.com Git - wxWidgets.git/blame - include/wx/mac/carbon/private.h
wxMultiChoiceDialog uses now wxCheckListBox if possible, wxListBox if not
[wxWidgets.git] / include / wx / mac / carbon / private.h
CommitLineData
8cf73271
SC
1/////////////////////////////////////////////////////////////////////////////
2// Name: private.h
3// Purpose: Private declarations: as this header is only included by
77ffb593 4// wxWidgets itself, it may contain identifiers which don't start
8cf73271
SC
5// with "wx".
6// Author: Stefan Csomor
7// Modified by:
8// Created: 1998-01-01
9// RCS-ID: $Id$
10// Copyright: (c) Stefan Csomor
65571936 11// Licence: wxWindows licence
8cf73271
SC
12/////////////////////////////////////////////////////////////////////////////
13
14#ifndef _WX_PRIVATE_H_
15#define _WX_PRIVATE_H_
16
17#include "wx/defs.h"
18#include "wx/app.h"
19
20#ifdef __DARWIN__
21# include <Carbon/Carbon.h>
22#else
4f305456 23# include <Debugging.h>
8cf73271
SC
24# include <Quickdraw.h>
25# include <Appearance.h>
26# include <Folders.h>
27# include <Controls.h>
28# include <ControlDefinitions.h>
29# include <LowMem.h>
30# include <Gestalt.h>
d9af087c 31# include <FixMath.h>
a6140a4c 32# include <CoreServices.h>
8cf73271
SC
33#endif
34
a6140a4c 35#if UNIVERSAL_INTERFACES_VERSION < 0x0342
8cf73271
SC
36 #error "please update to Apple's lastest universal headers from http://developer.apple.com/sdk/"
37#endif
38
c3a404b0
SC
39#ifndef MAC_OS_X_VERSION_10_3
40 #define MAC_OS_X_VERSION_10_3 1030
41#endif
42
ddb08e02
SC
43#ifndef MAC_OS_X_VERSION_10_4
44 #define MAC_OS_X_VERSION_10_4 1040
45#endif
46
5185263f
DE
47#ifdef __WXMAC_CARBON__
48#include "wx/mac/corefoundation/cfstring.h"
49#endif
50
3d639707
SC
51#ifndef FixedToInt
52// as macro in FixMath.h for 10.3
53inline Fixed IntToFixed( int inInt )
54{
55 return (((SInt32) inInt) << 16);
56}
57
58inline int FixedToInt( Fixed inFixed )
59{
60 return (((SInt32) inFixed) >> 16);
61}
62#endif
63
8cf73271
SC
64#if wxUSE_GUI
65
20b69855 66#include "wx/dc.h"
8cf73271 67#include "wx/window.h"
285b5ce0 68#include "wx/toplevel.h"
8cf73271
SC
69
70class wxMacPortStateHelper
71{
72 DECLARE_NO_COPY_CLASS(wxMacPortStateHelper)
73
74public:
75 wxMacPortStateHelper( GrafPtr newport) ;
76 wxMacPortStateHelper() ;
77 ~wxMacPortStateHelper() ;
78
79 void Setup( GrafPtr newport ) ;
80 void Clear() ;
81 bool IsCleared() { return m_clip == NULL ; }
82 GrafPtr GetCurrentPort() { return m_currentPort ; }
83
84private:
85 GrafPtr m_currentPort ;
86 GrafPtr m_oldPort ;
87 RgnHandle m_clip ;
88 ThemeDrawingState m_drawingState ;
89 short m_textFont ;
90 short m_textSize ;
91 short m_textStyle ;
92 short m_textMode ;
93} ;
94
4f305456
SC
95class WXDLLEXPORT wxMacPortSaver
96{
97 DECLARE_NO_COPY_CLASS(wxMacPortSaver)
98
99public:
100 wxMacPortSaver( GrafPtr port )
101 {
102 ::GetPort( &m_port ) ;
103 ::SetPort( port ) ;
104 }
105 ~wxMacPortSaver()
106 {
107 ::SetPort( m_port ) ;
108 }
109private :
110 GrafPtr m_port ;
111} ;
112
8cf73271
SC
113class WXDLLEXPORT wxMacPortSetter
114{
115 DECLARE_NO_COPY_CLASS(wxMacPortSetter)
116
117public:
118 wxMacPortSetter( const wxDC* dc ) ;
119 ~wxMacPortSetter() ;
120private:
121 wxMacPortStateHelper m_ph ;
122 const wxDC* m_dc ;
123} ;
124
4f305456
SC
125/*
126 Clips to the visible region of a control within the current port
127 */
128
129class WXDLLEXPORT wxMacWindowClipper : public wxMacPortSaver
8cf73271
SC
130{
131 DECLARE_NO_COPY_CLASS(wxMacWindowClipper)
132
133public:
134 wxMacWindowClipper( const wxWindow* win ) ;
135 ~wxMacWindowClipper() ;
136private:
01299d56 137 GrafPtr m_newPort ;
8cf73271
SC
138 RgnHandle m_formerClip ;
139 RgnHandle m_newClip ;
140} ;
141
01299d56
SC
142class WXDLLEXPORT wxMacWindowStateSaver : public wxMacWindowClipper
143{
144 DECLARE_NO_COPY_CLASS(wxMacWindowStateSaver)
145
146public:
147 wxMacWindowStateSaver( const wxWindow* win ) ;
148 ~wxMacWindowStateSaver() ;
149private:
150 GrafPtr m_newPort ;
151 ThemeDrawingState m_themeDrawingState ;
152} ;
153
ddb08e02
SC
154#if wxMAC_USE_CORE_GRAPHICS
155class WXDLLEXPORT wxMacCGContextStateSaver
156{
157 DECLARE_NO_COPY_CLASS(wxMacCGContextStateSaver)
158
159public:
160 wxMacCGContextStateSaver( CGContextRef cg )
161 {
162 m_cg = cg ;
163 CGContextSaveGState( cg ) ;
164 }
165 ~wxMacCGContextStateSaver()
166 {
167 CGContextRestoreGState( m_cg ) ;
168 }
169private:
170 CGContextRef m_cg ;
171} ;
172
173#endif
4f305456 174/*
8cf73271
SC
175class wxMacDrawingHelper
176{
177 DECLARE_NO_COPY_CLASS(wxMacDrawingHelper)
178
179public:
180 wxMacDrawingHelper( wxWindowMac * theWindow , bool clientArea = false ) ;
181 ~wxMacDrawingHelper() ;
182 bool Ok() { return m_ok ; }
183 void LocalToWindow( Rect *rect) { OffsetRect( rect , m_origin.h , m_origin.v ) ; }
184 void LocalToWindow( Point *pt ) { AddPt( m_origin , pt ) ; }
185 void LocalToWindow( RgnHandle rgn ) { OffsetRgn( rgn , m_origin.h , m_origin.v ) ; }
186 const Point& GetOrigin() { return m_origin ; }
187private:
188 Point m_origin ;
189 GrafPtr m_formerPort ;
190 GrafPtr m_currentPort ;
191 PenState m_savedPenState ;
192 bool m_ok ;
193} ;
4f305456 194*/
8cf73271
SC
195
196// app.h
197bool wxMacConvertEventToRecord( EventRef event , EventRecord *rec) ;
198
199#endif // wxUSE_GUI
200
201// filefn.h
202WXDLLEXPORT wxString wxMacFSSpec2MacFilename( const FSSpec *spec ) ;
a2b77260 203WXDLLEXPORT void wxMacFilename2FSSpec( const wxString &path , FSSpec *spec ) ;
8cf73271
SC
204
205// utils.h
206WXDLLEXPORT wxString wxMacFindFolder(short vRefNum,
207 OSType folderType,
208 Boolean createFolder);
209
4f305456
SC
210template<typename T> EventParamType wxMacGetEventParamType() { wxFAIL_MSG( wxT("Unknown Param Type") ) ; return 0 ; }
211template<> inline EventParamType wxMacGetEventParamType<RgnHandle>() { return typeQDRgnHandle ; }
212template<> inline EventParamType wxMacGetEventParamType<ControlRef>() { return typeControlRef ; }
213template<> inline EventParamType wxMacGetEventParamType<WindowRef>() { return typeWindowRef ; }
214template<> inline EventParamType wxMacGetEventParamType<MenuRef>() { return typeMenuRef ; }
215template<> inline EventParamType wxMacGetEventParamType<EventRef>() { return typeEventRef ; }
216template<> inline EventParamType wxMacGetEventParamType<Point>() { return typeQDPoint ; }
217template<> inline EventParamType wxMacGetEventParamType<Rect>() { return typeQDRectangle ; }
218template<> inline EventParamType wxMacGetEventParamType<Boolean>() { return typeBoolean ; }
219#if TARGET_API_MAC_OSX
6d4c54a7 220template<> inline EventParamType wxMacGetEventParamType<HICommand>() { return typeHICommand ; }
4f305456
SC
221template<> inline EventParamType wxMacGetEventParamType<HIPoint>() { return typeHIPoint ; }
222template<> inline EventParamType wxMacGetEventParamType<HISize>() { return typeHISize ; }
223template<> inline EventParamType wxMacGetEventParamType<HIRect>() { return typeHIRect ; }
224template<> inline EventParamType wxMacGetEventParamType<void*>() { return typeVoidPtr ; }
225#endif
226template<> inline EventParamType wxMacGetEventParamType<Collection>() { return typeCollection ; }
227template<> inline EventParamType wxMacGetEventParamType<CGContextRef>() { return typeCGContextRef ; }
228/*
885fb02f
SC
229 These are ambiguous
230 template<> EventParamType wxMacGetEventParamType<GrafPtr>() { return typeGrafPtr ; }
231 template<> EventParamType wxMacGetEventParamType<OSStatus>() { return typeOSStatus ; }
232 template<> EventParamType wxMacGetEventParamType<CFIndex>() { return typeCFIndex ; }
233 template<> EventParamType wxMacGetEventParamType<GWorldPtr>() { return typeGWorldPtr ; }
234 */
4f305456
SC
235
236class wxMacCarbonEvent
237{
238
239public :
a4848597
SC
240 wxMacCarbonEvent()
241 {
242 m_eventRef = 0 ;
243 m_release = false ;
244 }
245
6d4c54a7 246 wxMacCarbonEvent( EventRef event , bool release = false )
4f305456
SC
247 {
248 m_eventRef = event ;
6d4c54a7
SC
249 m_release = release ;
250 }
885fb02f 251
6d4c54a7
SC
252 wxMacCarbonEvent(UInt32 inClassID,UInt32 inKind,EventTime inWhen = 0 /*now*/,EventAttributes inAttributes=kEventAttributeNone)
253 {
254 m_eventRef = NULL ;
255 verify_noerr( MacCreateEvent( NULL , inClassID, inKind,inWhen,inAttributes,&m_eventRef) ) ;
256 m_release = true ;
257 }
885fb02f 258
6d4c54a7
SC
259 ~wxMacCarbonEvent()
260 {
261 if ( m_release )
262 ReleaseEvent( m_eventRef ) ;
4f305456
SC
263 }
264
a4848597
SC
265 OSStatus Create(UInt32 inClassID,UInt32 inKind,EventTime inWhen = 0 /*now*/,EventAttributes inAttributes=kEventAttributeNone)
266 {
267 verify( (m_eventRef == NULL) || m_release ) ;
268 if ( m_eventRef && m_release )
269 {
270 ReleaseEvent( m_eventRef ) ;
271 m_release = false ;
272 m_eventRef = NULL ;
273
274 }
275 OSStatus err = MacCreateEvent( NULL , inClassID, inKind,inWhen,inAttributes,&m_eventRef) ;
276 if ( err == noErr )
277 m_release = true ;
278 return err ;
279 }
885fb02f 280
4f305456
SC
281 OSStatus GetParameter( EventParamName inName, EventParamType inDesiredType, UInt32 inBufferSize, void * outData) ;
282
283 template <typename T> OSStatus GetParameter( EventParamName inName, EventParamType type , T *data )
284 {
285 return GetParameter( inName, type , sizeof( T ) , data ) ;
286 }
287 template <typename T> OSStatus GetParameter( EventParamName inName, T *data )
288 {
289 return GetParameter<T>( inName, wxMacGetEventParamType<T>() , data ) ;
290 }
291
292 template <typename T> T GetParameter( EventParamName inName )
293 {
294 T value ;
295 verify_noerr( GetParameter<T>( inName, &value ) ) ;
296 return value ;
297 }
298 template <typename T> T GetParameter( EventParamName inName, EventParamType inDesiredType )
299 {
300 T value ;
301 verify_noerr( GetParameter<T>( inName, inDesiredType , &value ) ) ;
302 return value ;
303 }
885fb02f 304
6d4c54a7
SC
305 OSStatus SetParameter( EventParamName inName, EventParamType inType, UInt32 inSize, const void * inData) ;
306 template <typename T> OSStatus SetParameter( EventParamName inName, EventParamType inDesiredType , const T *data )
4f305456 307 {
2aefa0ef
SC
308 return SetParameter( inName, inDesiredType , sizeof( T ) , data ) ;
309 }
6d4c54a7 310 template <typename T> OSStatus SetParameter( EventParamName inName, EventParamType inDesiredType , const T& data )
2aefa0ef
SC
311 {
312 return SetParameter<T>( inName, inDesiredType , &data ) ;
4f305456 313 }
6d4c54a7 314 template <typename T> OSStatus SetParameter( EventParamName inName, const T *data )
4f305456
SC
315 {
316 return SetParameter<T>( inName, wxMacGetEventParamType<T>() , data ) ;
317 }
6d4c54a7 318 template <typename T> OSStatus SetParameter( EventParamName inName, const T& data )
2aefa0ef
SC
319 {
320 return SetParameter<T>( inName, wxMacGetEventParamType<T>() , &data ) ;
321 }
86d8b744
SC
322 UInt32 GetClass()
323 {
324 return ::GetEventClass( m_eventRef ) ;
325 }
41b53169 326 UInt32 GetKind()
4f305456
SC
327 {
328 return ::GetEventKind( m_eventRef ) ;
329 }
330 EventTime GetTime()
331 {
332 return ::GetEventTime( m_eventRef ) ;
333 }
334 UInt32 GetTicks()
335 {
336 return EventTimeToTicks( GetTime() ) ;
337 }
2c01d335 338 OSStatus SetCurrentTime( )
a4848597 339 {
2c01d335
VZ
340 return ::SetEventTime( m_eventRef , GetCurrentEventTime() ) ;
341 }
342 OSStatus SetTime( EventTime when )
343 {
344 return ::SetEventTime( m_eventRef , when ) ;
a4848597
SC
345 }
346 operator EventRef () { return m_eventRef; }
885fb02f 347
a4848597 348 bool IsValid() { return m_eventRef != 0 ; }
4f305456
SC
349protected :
350 EventRef m_eventRef ;
6d4c54a7 351 bool m_release ;
4f305456
SC
352} ;
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 {
363 m_upp = NULL ;
364 m_upp = (*newUPP)( NULL ) ;
365 }
366 ~wxMacUPP()
367 {
368 if ( m_upp )
369 disposeUPP( m_upp ) ;
370 }
371 operator uppType() { return m_upp ; }
372private :
373 uppType m_upp ;
374} ;
375
376typedef wxMacUPP<NMProcPtr,NMUPP,NewNMUPP,DisposeNMUPP> wxMacNMUPP ;
377
885fb02f 378#if wxUSE_GUI
20b69855 379/*
885fb02f
SC
380GWorldPtr wxMacCreateGWorld( int width , int height , int depth ) ;
381void wxMacDestroyGWorld( GWorldPtr gw ) ;
382PicHandle wxMacCreatePict( GWorldPtr gw , GWorldPtr mask = NULL ) ;
383CIconHandle wxMacCreateCIcon(GWorldPtr image , GWorldPtr mask , short dstDepth , short iconSize ) ;
384void wxMacSetColorTableEntry( CTabHandle newColors , int index , int red , int green , int blue ) ;
385CTabHandle wxMacCreateColorTable( int numColors ) ;
20b69855 386*/
885fb02f 387void wxMacCreateBitmapButton( ControlButtonContentInfo*info , const wxBitmap& bitmap , int forceType = 0 ) ;
20b69855 388void wxMacReleaseBitmapButton( ControlButtonContentInfo*info ) ;
885fb02f
SC
389
390#define MAC_WXCOLORREF(a) (*((RGBColor*)&(a)))
391#define MAC_WXHBITMAP(a) (GWorldPtr(a))
392#define MAC_WXHMETAFILE(a) (PicHandle(a))
20b69855 393#define MAC_WXHICON(a) (IconRef(a))
885fb02f
SC
394#define MAC_WXHCURSOR(a) (CursHandle(a))
395#define MAC_WXHRGN(a) (RgnHandle(a))
396#define MAC_WXHWND(a) (WindowPtr(a))
397#define MAC_WXRECPTR(a) ((Rect*)a)
398#define MAC_WXPOINTPTR(a) ((Point*)a)
399#define MAC_WXHMENU(a) ((MenuHandle)a)
400
401struct wxOpaqueWindowRef
402{
403 wxOpaqueWindowRef( WindowRef ref ) { m_data = ref ; }
404 operator WindowRef() { return m_data ; }
405private :
406 WindowRef m_data ;
407} ;
408
285b5ce0
SC
409void wxMacRectToNative( const wxRect *wx , Rect *n ) ;
410void wxMacNativeToRect( const Rect *n , wxRect* wx ) ;
411void wxMacPointToNative( const wxPoint* wx , Point *n ) ;
412void wxMacNativeToPoint( const Point *n , wxPoint* wx ) ;
413
885fb02f
SC
414wxWindow * wxFindControlFromMacControl(ControlRef inControl ) ;
415wxTopLevelWindowMac* wxFindWinFromMacWindow( WindowRef inWindow ) ;
416wxMenu* wxFindMenuFromMacMenu(MenuRef inMenuRef) ;
417
418extern wxWindow* g_MacLastWindow ;
419pascal OSStatus wxMacTopLevelMouseEventHandler( EventHandlerCallRef handler , EventRef event , void *data ) ;
420Rect wxMacGetBoundsForControl( wxWindow* window , const wxPoint& pos , const wxSize &size , bool adjustForOrigin = true ) ;
421
285b5ce0
SC
422ControlActionUPP GetwxMacLiveScrollbarActionProc() ;
423
86d8b744
SC
424class wxMacControl
425{
426public :
285b5ce0 427 wxMacControl( wxWindow* peer , bool isRootControl = false ) ;
9b89f11a
SC
428 wxMacControl( wxWindow* peer , ControlRef control ) ;
429 wxMacControl( wxWindow* peer , WXWidget control ) ;
430 virtual ~wxMacControl() ;
6d4c54a7 431
9b89f11a 432 void Init() ;
6d4c54a7 433
5ca0d812
SC
434 virtual void Dispose() ;
435
436 bool Ok() const { return GetControlRef() != NULL ; }
437
438 virtual ControlRef * GetControlRefAddr() { return &m_controlRef; }
439 virtual ControlRef GetControlRef() const { return m_controlRef ; }
440
441 virtual void SetReference( SInt32 data ) ;
442 /*
2837271a
SC
443 void operator= (ControlRef c) { m_controlRef = c ; }
444 operator ControlRef () { return m_controlRef; }
445 operator ControlRef * () { return &m_controlRef; }
5ca0d812 446 */
2837271a
SC
447 // accessing data and values
448
449 virtual OSStatus SetData( ControlPartCode inPartCode , ResType inTag , Size inSize , const void * inData ) ;
0fc3bc3b
SC
450 virtual OSStatus GetData( ControlPartCode inPartCode , ResType inTag , Size inBufferSize , void * inOutBuffer , Size * outActualSize ) const ;
451 virtual OSStatus GetDataSize( ControlPartCode inPartCode , ResType inTag , Size * outActualSize ) const ;
2837271a
SC
452 virtual OSStatus SendEvent( EventRef ref , OptionBits inOptions = 0 ) ;
453 virtual OSStatus SendHICommand( HICommand &command , OptionBits inOptions = 0 ) ;
454
0fc3bc3b 455 virtual OSStatus SendHICommand( UInt32 commandID , OptionBits inOptions = 0 ) ;
2837271a 456
0fc3bc3b
SC
457 virtual SInt32 GetValue() const ;
458 virtual SInt32 GetMaximum() const ;
459 virtual SInt32 GetMinimum() const ;
2837271a 460
0fc3bc3b
SC
461 virtual void SetValue( SInt32 v ) ;
462 virtual void SetMinimum( SInt32 v ) ;
463 virtual void SetMaximum( SInt32 v ) ;
2837271a 464
0fc3bc3b
SC
465 virtual void SetValueAndRange( SInt32 value , SInt32 minimum , SInt32 maximum ) ;
466 virtual void SetRange( SInt32 minimum , SInt32 maximum ) ;
2837271a 467
5ca0d812
SC
468 virtual OSStatus SetFocus( ControlFocusPart focusPart ) ;
469 virtual bool HasFocus() const ;
470 virtual bool NeedsFocusRect() const ;
9b89f11a 471 virtual void SetNeedsFocusRect( bool needs ) ;
5ca0d812 472
2837271a
SC
473 // templated helpers
474
0fc3bc3b 475 Size GetDataSize( ControlPartCode inPartCode , ResType inTag ) const
86d8b744
SC
476 {
477 Size sz ;
478 verify_noerr( GetDataSize( inPartCode , inTag , &sz ) ) ;
479 return sz ;
480 }
6d4c54a7 481 template <typename T> OSStatus SetData( ControlPartCode inPartCode , ResType inTag , const T *data )
86d8b744
SC
482 {
483 return SetData( inPartCode , inTag , sizeof( T ) , data ) ;
484 }
6d4c54a7 485 template <typename T> OSStatus SetData( ControlPartCode inPartCode , ResType inTag , const T& data )
86d8b744
SC
486 {
487 return SetData( inPartCode , inTag , sizeof( T ) , &data ) ;
488 }
0fc3bc3b 489 template <typename T> OSStatus GetData( ControlPartCode inPartCode , ResType inTag , T *data ) const
86d8b744
SC
490 {
491 Size dummy ;
492 return GetData( inPartCode , inTag , sizeof( T ) , data , &dummy ) ;
493 }
0fc3bc3b 494 template <typename T> T GetData( ControlPartCode inPartCode , ResType inTag ) const
86d8b744
SC
495 {
496 T value ;
497 verify_noerr( GetData<T>( inPartCode , inTag , &value ) ) ;
498 return value ;
499 }
2837271a 500
6d4c54a7 501 // Flash the control for the specified amount of time
0fc3bc3b 502 virtual void Flash( ControlPartCode part , UInt32 ticks = 8 ) ;
89a66f11 503
0fc3bc3b 504 virtual void VisibilityChanged( bool shown ) ;
89a66f11
SC
505 virtual void SuperChangedPosition() ;
506
507
0fc3bc3b 508 virtual void SetFont( const wxFont & font , const wxColour& foreground , long windowStyle ) ;
7ea087b7 509 virtual void SetBackground( const wxBrush &brush ) ;
5ca0d812
SC
510 virtual ControlPartCode HandleKey( SInt16 keyCode, SInt16 charCode, EventModifiers modifiers ) ;
511 void SetActionProc( ControlActionUPP actionProc ) ;
512 void SetViewSize( SInt32 viewSize ) ;
513 SInt32 GetViewSize() const ;
514
515 virtual bool IsVisible() const ;
516 virtual void SetVisibility( bool visible , bool redraw ) ;
517 virtual bool IsEnabled() const ;
518 virtual bool IsActive() const ;
519 virtual void Enable( bool enable ) ;
520
521 // invalidates this control and all children
522 virtual void InvalidateWithChildren() ;
523 virtual void SetDrawingEnabled( bool enable ) ;
b905d6cc 524#ifdef __WXMAC_OSX__
5ca0d812 525 virtual bool GetNeedsDisplay() const ;
b905d6cc 526#endif
285b5ce0
SC
527 // where is in native window relative coordinates
528 virtual void SetNeedsDisplay( RgnHandle where ) ;
529 // where is in native window relative coordinates
530 virtual void SetNeedsDisplay( Rect* where = NULL ) ;
531
92346151
SC
532 // if rect = NULL, entire view
533 virtual void ScrollRect( wxRect *rect , int dx , int dy ) ;
5ca0d812 534
285b5ce0 535 // in native parent window relative coordinates
5ca0d812 536 virtual void GetRect( Rect *r ) ;
285b5ce0
SC
537
538 // in native parent window relative coordinates
5ca0d812 539 virtual void SetRect( Rect *r ) ;
285b5ce0 540
5ca0d812
SC
541 virtual void GetRectInWindowCoords( Rect *r ) ;
542 virtual void GetBestRect( Rect *r ) ;
543 virtual void SetTitle( const wxString &title ) ;
544 // converts from Toplevel-Content relative to local
545 static void Convert( wxPoint *pt , wxMacControl *convert , wxMacControl *to ) ;
546
547 virtual void GetFeatures( UInt32 *features ) ;
548 virtual OSStatus GetRegion( ControlPartCode partCode , RgnHandle region ) ;
549 virtual OSStatus SetZOrder( bool above , wxMacControl* other ) ;
550 // to be moved into a databrowser subclass
551
552 virtual OSStatus SetSelectionFlags( DataBrowserSelectionFlags ) ;
553 virtual OSStatus AddListViewColumn( DataBrowserListViewColumnDesc *columnDesc,
554 DataBrowserTableViewColumnIndex position ) ;
555 virtual OSStatus AutoSizeListViewColumns() ;
556 virtual OSStatus SetHasScrollBars( bool horiz , bool vert ) ;
557 virtual OSStatus SetTableViewHiliteStyle( DataBrowserTableViewHiliteStyle hiliteStyle ) ;
558 virtual OSStatus SetListViewHeaderBtnHeight(UInt16 height) ;
559 virtual OSStatus SetCallbacks(const DataBrowserCallbacks * callbacks) ;
560 virtual OSStatus UpdateItems( DataBrowserItemID container, UInt32 numItems,
561 const DataBrowserItemID* items,
562 DataBrowserPropertyID preSortProperty,
563 DataBrowserPropertyID propertyID ) ;
564 virtual OSStatus AddItems( DataBrowserItemID container, UInt32 numItems,
565 const DataBrowserItemID* items,
566 DataBrowserPropertyID preSortProperty ) ;
567 virtual OSStatus RemoveItems( DataBrowserItemID container, UInt32 numItems,
568 const DataBrowserItemID* items,
569 DataBrowserPropertyID preSortProperty ) ;
570 virtual OSStatus RevealItem( DataBrowserItemID item,
571 DataBrowserPropertyID propertyID,
572 DataBrowserRevealOptions options ) ;
fe3dc505 573 virtual OSStatus GetSelectionAnchor( DataBrowserItemID * first, DataBrowserItemID * last ) ;
5ca0d812
SC
574 virtual bool IsItemSelected( DataBrowserItemID item ) ;
575 virtual OSStatus SetSelectedItems(UInt32 numItems,
576 const DataBrowserItemID * items,
577 DataBrowserSetOption operation ) ;
578
579 // to be moved into a tab control class
580
581 virtual OSStatus SetTabEnabled( SInt16 tabNo , bool enable ) ;
9b89f11a 582 bool IsCompositing() { return m_isCompositing ; }
285b5ce0 583 bool IsRootControl() { return m_isRootControl ; }
86d8b744 584protected :
0fc3bc3b
SC
585 ControlRef m_controlRef ;
586 wxFont m_font ;
587 long m_windowStyle ;
b905d6cc 588 wxWindow* m_peer ;
9b89f11a
SC
589 bool m_needsFocusRect ;
590 bool m_isCompositing ;
285b5ce0 591 bool m_isRootControl ;
86d8b744
SC
592} ;
593
20b69855
SC
594#if wxMAC_USE_CORE_GRAPHICS
595
596class WXDLLEXPORT wxMacCGPath : public wxGraphicPath
597{
598 DECLARE_NO_COPY_CLASS(wxMacCGPath)
599public :
600 wxMacCGPath() ;
601 ~wxMacCGPath() ;
602
603 // Starts a new subpath at
604 void MoveToPoint( wxCoord x1 , wxCoord y1 ) ;
605 void AddLineToPoint( wxCoord x1 , wxCoord y1 ) ;
fea3713c 606 void AddQuadCurveToPoint( wxCoord cx1, wxCoord cy1, wxCoord x1, wxCoord y1 ) ;
20b69855
SC
607 void AddRectangle( wxCoord x, wxCoord y, wxCoord w, wxCoord h ) ;
608 void AddCircle( wxCoord x, wxCoord y , wxCoord r ) ;
609
610 // closes the current subpath
611 void CloseSubpath() ;
612
613 CGPathRef GetPath() const ;
614private :
615 CGMutablePathRef m_path ;
616} ;
617
618class WXDLLEXPORT wxMacCGContext : public wxGraphicContext
619{
620 DECLARE_NO_COPY_CLASS(wxMacCGContext)
621
622public:
623 wxMacCGContext( CGrafPtr port ) ;
624 wxMacCGContext( CGContextRef cgcontext ) ;
625 wxMacCGContext() ;
626 ~wxMacCGContext() ;
627
628 virtual void Clip( const wxRegion &region ) ;
629 virtual void StrokePath( const wxGraphicPath *p ) ;
630 virtual void DrawPath( const wxGraphicPath *p , int fillStyle = wxWINDING_RULE ) ;
631 virtual void FillPath( const wxGraphicPath *p , const wxColor &fillColor , int fillStyle = wxWINDING_RULE ) ;
632
633 virtual wxGraphicPath* CreatePath() ;
634 virtual void SetPen( const wxPen &pen ) ;
635 virtual void SetBrush( const wxBrush &brush ) ;
636 CGContextRef GetNativeContext() ;
637 void SetNativeContext( CGContextRef cg ) ;
638 CGPathDrawingMode GetDrawingMode() const { return m_mode ; }
639private:
640 CGContextRef m_cgContext ;
641 CGrafPtr m_qdPort ;
642 CGPathDrawingMode m_mode ;
643 wxPen m_pen ;
644 wxBrush m_brush ;
645} ;
646
30e77b5c
SC
647#endif // wxMAC_USE_CORE_GRAPHICS
648
649#ifdef __WXMAC_OSX__
650
20b69855 651CGColorSpaceRef wxMacGetGenericRGBColorSpace(void) ;
71cc158e 652void wxMacMemoryBufferReleaseProc(void *info, const void *data, size_t size) ;
20b69855 653
30e77b5c 654#endif
20b69855
SC
655
656class WXDLLEXPORT wxBitmapRefData: public wxGDIRefData
657{
658 DECLARE_NO_COPY_CLASS(wxBitmapRefData)
659
660 friend class WXDLLEXPORT wxIcon;
661 friend class WXDLLEXPORT wxCursor;
662public:
663 wxBitmapRefData(int width , int height , int depth);
664 wxBitmapRefData();
665 ~wxBitmapRefData();
666
667 void Free() ;
668 bool Ok() const { return m_ok ; }
669 void SetOk( bool isOk) { m_ok = isOk ; }
670
671 void SetWidth( int width ) { m_width = width ; }
672 void SetHeight( int height ) { m_height = height ; }
673 void SetDepth( int depth ) { m_depth = depth ; }
674
675 int GetWidth() const { return m_width ; }
676 int GetHeight() const { return m_height ; }
677 int GetDepth() const { return m_depth ; }
678
679 void *GetRawAccess() const ;
680 void *BeginRawAccess() ;
681 void EndRawAccess() ;
682
683 bool HasAlpha() const { return m_hasAlpha ; }
684 void UseAlpha( bool useAlpha ) ;
685
686public:
687#if wxUSE_PALETTE
688 wxPalette m_bitmapPalette;
689#endif // wxUSE_PALETTE
690
691 wxMask * m_bitmapMask; // Optional mask
30e77b5c 692#ifdef __WXMAC_OSX__
20b69855 693 CGImageRef CGImageCreate() const ;
71cc158e 694#endif
6d2c830a
SC
695
696 // returns true if the bitmap has a size that
697 // can be natively transferred into a true icon
698 // if no is returned GetIconRef will still produce
699 // an icon but it will be generated via a PICT and
700 // rescaled to 16 x 16
701 bool HasNativeSize() ;
702
703 // caller should increase ref count if needed longer
704 // than the bitmap exists
705 IconRef GetIconRef() ;
706
707 // returns a Pict from the bitmap content
708 PicHandle GetPictHandle() ;
20b69855
SC
709 GWorldPtr GetHBITMAP(GWorldPtr * mask = NULL ) const ;
710 void UpdateAlphaMask() const ;
71cc158e 711
20b69855
SC
712private :
713 bool Create(int width , int height , int depth) ;
714 void Init() ;
715
716 int m_width;
717 int m_height;
718 int m_bytesPerRow ;
719 int m_depth;
720 bool m_hasAlpha;
721 wxMemoryBuffer m_memBuf ;
722 int m_rawAccessCount ;
723 bool m_ok;
30e77b5c 724#ifdef __WXMAC_OSX__
20b69855 725 mutable CGImageRef m_cgImageRef ;
71cc158e 726#endif
6d2c830a
SC
727 IconRef m_iconRef ;
728 PicHandle m_pictHandle ;
20b69855
SC
729 GWorldPtr m_hBitmap;
730 GWorldPtr m_hMaskBitmap ;
731 wxMemoryBuffer m_maskMemBuf ;
732 int m_maskBytesPerRow ;
20b69855
SC
733};
734
20b69855
SC
735class WXDLLEXPORT wxIconRefData : public wxGDIRefData
736{
737public:
738 wxIconRefData() ;
739 wxIconRefData( WXHICON ) ;
740 virtual ~wxIconRefData() { Free(); }
741
742 void Init() ;
743 virtual void Free();
ddb08e02
SC
744
745 void SetWidth( int width ) { m_width = width ; }
746 void SetHeight( int height ) { m_height = height ; }
747
748 int GetWidth() const { return m_width ; }
749 int GetHeight() const { return m_height ; }
750
20b69855
SC
751 WXHICON GetHICON() const { return (WXHICON) m_iconRef ; }
752private :
753 IconRef m_iconRef ;
ddb08e02
SC
754 int m_width ;
755 int m_height ;
20b69855
SC
756};
757
285b5ce0
SC
758// toplevel.cpp
759
fbfb8bcc 760ControlRef wxMacFindControlUnderMouse( wxTopLevelWindowMac* toplevelWindow, const Point& location , WindowRef window , ControlPartCode *outPart ) ;
285b5ce0 761
8cf73271
SC
762#endif // wxUSE_GUI
763
285b5ce0
SC
764#define wxMAC_DEFINE_PROC_GETTER( UPP , x ) \
765UPP Get##x() \
766{ \
767 static UPP sHandler = NULL; \
768 if ( sHandler == NULL ) \
769 sHandler = New##UPP( x ); \
770 return sHandler; \
771}
772
8cf73271
SC
773//---------------------------------------------------------------------------
774// wxMac string conversions
775//---------------------------------------------------------------------------
776
777void wxMacSetupConverters() ;
778void wxMacCleanupConverters() ;
779
780void wxMacStringToPascal( const wxString&from , StringPtr to ) ;
781wxString wxMacMakeStringFromPascal( ConstStringPtr from ) ;
782
a2b77260
SC
783// filefn.cpp
784
785wxString wxMacFSRefToPath( const FSRef *fsRef , CFStringRef additionalPathComponent = NULL ) ;
786OSStatus wxMacPathToFSRef( const wxString&path , FSRef *fsRef ) ;
787wxString wxMacHFSUniStrToString( ConstHFSUniStr255Param uniname ) ;
aa0cc8a1 788
8cf73271
SC
789#endif
790 // _WX_PRIVATE_H_