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