]> git.saurik.com Git - wxWidgets.git/blob - src/mac/carbon/utils.cpp
applying patch 1894478, 10.5 AudioServices support
[wxWidgets.git] / src / mac / carbon / utils.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/mac/carbon/utils.cpp
3 // Purpose: Various utilities
4 // Author: Stefan Csomor
5 // Modified by:
6 // Created: 1998-01-01
7 // RCS-ID: $Id$
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #include "wx/wxprec.h"
13
14 #include "wx/utils.h"
15
16 #ifndef WX_PRECOMP
17 #include "wx/intl.h"
18 #include "wx/app.h"
19 #if wxUSE_GUI
20 #include "wx/toplevel.h"
21 #include "wx/font.h"
22 #endif
23 #endif
24
25 #include "wx/apptrait.h"
26
27 #if wxUSE_GUI
28 #include "wx/mac/uma.h"
29 #endif
30
31 #include <ctype.h>
32
33 #include <stdio.h>
34 #include <stdlib.h>
35 #include <string.h>
36 #include <stdarg.h>
37
38 // #include "MoreFilesX.h"
39
40 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
41 #include <AudioToolbox/AudioServices.h>
42 #endif
43
44 #if wxUSE_GUI
45 #include <CoreServices/CoreServices.h>
46 #include <Carbon/Carbon.h>
47 #include "wx/mac/private/timer.h"
48 #endif // wxUSE_GUI
49
50 #include "wx/evtloop.h"
51 #include "wx/mac/private.h"
52
53 #if defined(__MWERKS__) && wxUSE_UNICODE
54 #if __MWERKS__ < 0x4100
55 #include <wtime.h>
56 #endif
57 #endif
58
59 #if wxUSE_BASE
60
61 // our OS version is the same in non GUI and GUI cases
62 wxOperatingSystemId wxGetOsVersion(int *majorVsn, int *minorVsn)
63 {
64 SInt32 theSystem;
65 Gestalt(gestaltSystemVersion, &theSystem);
66
67 if ( majorVsn != NULL )
68 *majorVsn = (theSystem >> 8);
69
70 if ( minorVsn != NULL )
71 *minorVsn = (theSystem & 0xFF);
72
73 #if defined( __DARWIN__ )
74 return wxOS_MAC_OSX_DARWIN;
75 #else
76 return wxOS_MAC_OS;
77 #endif
78 }
79
80 extern bool WXDLLEXPORT wxIsDebuggerRunning()
81 {
82 // TODO : try to find out ...
83 return false;
84 }
85
86 // Emit a beeeeeep
87 void wxBell()
88 {
89 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
90 if ( AudioServicesPlayAlertSound )
91 AudioServicesPlayAlertSound(kUserPreferredAlert);
92 else
93 #endif
94 #if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
95 SysBeep(30);
96 #else
97 {
98 }
99 #endif
100 }
101
102
103 #endif // wxUSE_BASE
104
105 #if wxUSE_GUI
106
107 wxPortId wxGUIAppTraits::GetToolkitVersion(int *verMaj, int *verMin) const
108 {
109 // We suppose that toolkit version is the same as OS version under Mac
110 wxGetOsVersion(verMaj, verMin);
111
112 return wxPORT_MAC;
113 }
114
115 wxEventLoopBase* wxGUIAppTraits::CreateEventLoop()
116 {
117 return new wxEventLoop;
118 }
119
120 wxTimerImpl* wxGUIAppTraits::CreateTimerImpl(wxTimer *timer)
121 {
122 return new wxCarbonTimerImpl(timer);
123 }
124
125 int gs_wxBusyCursorCount = 0;
126 extern wxCursor gMacCurrentCursor;
127 wxCursor gMacStoredActiveCursor;
128
129 // Set the cursor to the busy cursor for all windows
130 void wxBeginBusyCursor(const wxCursor *cursor)
131 {
132 if (gs_wxBusyCursorCount++ == 0)
133 {
134 gMacStoredActiveCursor = gMacCurrentCursor;
135 cursor->MacInstall();
136
137 wxSetCursor(*cursor);
138 }
139 //else: nothing to do, already set
140 }
141
142 // Restore cursor to normal
143 void wxEndBusyCursor()
144 {
145 wxCHECK_RET( gs_wxBusyCursorCount > 0,
146 wxT("no matching wxBeginBusyCursor() for wxEndBusyCursor()") );
147
148 if (--gs_wxBusyCursorCount == 0)
149 {
150 gMacStoredActiveCursor.MacInstall();
151 gMacStoredActiveCursor = wxNullCursor;
152
153 wxSetCursor(wxNullCursor);
154 }
155 }
156
157 // true if we're between the above two calls
158 bool wxIsBusy()
159 {
160 return (gs_wxBusyCursorCount > 0);
161 }
162
163 #endif // wxUSE_GUI
164
165 #if wxUSE_BASE
166
167 wxString wxMacFindFolderNoSeparator( short vol,
168 OSType folderType,
169 Boolean createFolder)
170 {
171 FSRef fsRef;
172 wxString strDir;
173
174 if ( FSFindFolder( vol, folderType, createFolder, &fsRef) == noErr)
175 {
176 strDir = wxMacFSRefToPath( &fsRef );
177 }
178
179 return strDir;
180 }
181
182 wxString wxMacFindFolder( short vol,
183 OSType folderType,
184 Boolean createFolder)
185 {
186 return wxMacFindFolderNoSeparator(vol, folderType, createFolder) + wxFILE_SEP_PATH;
187 }
188
189 #endif // wxUSE_BASE
190
191 #if wxUSE_GUI
192
193 // Check whether this window wants to process messages, e.g. Stop button
194 // in long calculations.
195 bool wxCheckForInterrupt(wxWindow *WXUNUSED(wnd))
196 {
197 // TODO
198 return false;
199 }
200
201 void wxGetMousePosition( int* x, int* y )
202 {
203 #if wxMAC_USE_QUICKDRAW
204 Point pt;
205 GetGlobalMouse(&pt);
206 *x = pt.h;
207 *y = pt.v;
208 #else
209 // TODO
210 #endif
211 };
212
213 // Return true if we have a colour display
214 bool wxColourDisplay()
215 {
216 return true;
217 }
218
219 // Returns depth of screen
220 int wxDisplayDepth()
221 {
222 #if wxMAC_USE_QUICKDRAW
223 int theDepth = (int) CGDisplayBitsPerPixel(CGMainDisplayID());
224 Rect globRect;
225 SetRect(&globRect, -32760, -32760, 32760, 32760);
226 GDHandle theMaxDevice;
227
228 theMaxDevice = GetMaxDevice(&globRect);
229 if (theMaxDevice != NULL)
230 theDepth = (**(**theMaxDevice).gdPMap).pixelSize;
231
232 return theDepth;
233 #else
234 return 32; // TODO
235 #endif
236 }
237
238 // Get size of display
239 void wxDisplaySize(int *width, int *height)
240 {
241 // TODO adapt for multi-displays
242 CGRect bounds = CGDisplayBounds(CGMainDisplayID());
243 if ( width )
244 *width = (int)bounds.size.width ;
245 if ( height )
246 *height = (int)bounds.size.height;
247 }
248
249 void wxDisplaySizeMM(int *width, int *height)
250 {
251 wxDisplaySize(width, height);
252 // on mac 72 is fixed (at least now;-)
253 float cvPt2Mm = 25.4 / 72;
254
255 if (width != NULL)
256 *width = int( *width * cvPt2Mm );
257
258 if (height != NULL)
259 *height = int( *height * cvPt2Mm );
260 }
261
262 void wxClientDisplayRect(int *x, int *y, int *width, int *height)
263 {
264 #if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5
265 #if wxMAC_USE_QUICKDRAW
266
267 HIRect bounds ;
268 HIWindowGetAvailablePositioningBounds(kCGNullDirectDisplay,kHICoordSpace72DPIGlobal,
269 &bounds);
270 if ( x )
271 *x = bounds.origin.x;
272 if ( y )
273 *y = bounds.origin.y;
274 if ( width )
275 *width = bounds.size.width;
276 if ( height )
277 *height = bounds.size.height;
278 #else
279 int w, h;
280 wxDisplaySize(&w,&h);
281 if ( x )
282 *x = 0;
283 if ( y )
284 *y = 24;
285 if ( width )
286 *width = w;
287 if ( height )
288 *height = h-24;
289 #endif
290 #else
291 Rect r;
292 GetAvailableWindowPositioningBounds( GetMainDevice() , &r );
293 if ( x )
294 *x = r.left;
295 if ( y )
296 *y = r.top;
297 if ( width )
298 *width = r.right - r.left;
299 if ( height )
300 *height = r.bottom - r.top;
301 #endif
302 }
303
304 wxWindow* wxFindWindowAtPoint(const wxPoint& pt)
305 {
306 return wxGenericFindWindowAtPoint(pt);
307 }
308
309 #endif // wxUSE_GUI
310
311 #if wxUSE_BASE
312
313 #include <sys/utsname.h>
314
315 wxString wxGetOsDescription()
316 {
317 char data[128];
318 struct utsname name;
319 uname(&name);
320 sprintf(data, "Mac OS X (%s %s %s)", name.sysname, name.release, name.machine);
321 return wxString(data, wxConvUTF8);
322 }
323
324 #ifndef __DARWIN__
325 wxString wxGetUserHome (const wxString& user)
326 {
327 // TODO
328 return wxString();
329 }
330
331 bool wxGetDiskSpace(const wxString& path, wxDiskspaceSize_t *pTotal, wxDiskspaceSize_t *pFree)
332 {
333 if ( path.empty() )
334 return false;
335
336 wxString p = path;
337 if (p[0u] == ':' )
338 p = wxGetCwd() + p;
339
340 int pos = p.Find(':');
341 if ( pos != wxNOT_FOUND )
342 p = p.Mid(1,pos);
343
344 p = p + wxT(":");
345
346 OSErr err = noErr;
347
348 FSRef fsRef;
349 err = wxMacPathToFSRef( p , &fsRef );
350 if ( noErr == err )
351 {
352 FSVolumeRefNum vRefNum;
353 err = FSGetVRefNum( &fsRef , &vRefNum );
354 if ( noErr == err )
355 {
356 UInt64 freeBytes , totalBytes;
357 err = FSGetVInfo( vRefNum , NULL , &freeBytes , &totalBytes );
358 if ( noErr == err )
359 {
360 if ( pTotal )
361 *pTotal = wxDiskspaceSize_t( totalBytes );
362 if ( pFree )
363 *pFree = wxDiskspaceSize_t( freeBytes );
364 }
365 }
366 }
367
368 return err == noErr;
369 }
370 #endif // !__DARWIN__
371
372 //---------------------------------------------------------------------------
373 // wxMac Specific utility functions
374 //---------------------------------------------------------------------------
375
376 void wxMacStringToPascal( const wxString&from , StringPtr to )
377 {
378 wxCharBuffer buf = from.mb_str( wxConvLocal );
379 int len = strlen(buf);
380
381 if ( len > 255 )
382 len = 255;
383 to[0] = len;
384 memcpy( (char*) &to[1] , buf , len );
385 }
386
387 wxString wxMacMakeStringFromPascal( ConstStringPtr from )
388 {
389 return wxString( (char*) &from[1] , wxConvLocal , from[0] );
390 }
391
392 // ----------------------------------------------------------------------------
393 // Common Event Support
394 // ----------------------------------------------------------------------------
395
396 void wxMacWakeUp()
397 {
398 OSStatus err = noErr;
399
400 #if 0
401 // lead sometimes to race conditions, although all calls used should be thread safe ...
402 static wxMacCarbonEvent s_wakeupEvent;
403 if ( !s_wakeupEvent.IsValid() )
404 {
405 err = s_wakeupEvent.Create( 'WXMC', 'WXMC', GetCurrentEventTime(),
406 kEventAttributeNone );
407 }
408 if ( err == noErr )
409 {
410
411 if ( IsEventInQueue( GetMainEventQueue() , s_wakeupEvent ) )
412 return;
413 s_wakeupEvent.SetCurrentTime();
414 err = PostEventToQueue(GetMainEventQueue(), s_wakeupEvent,
415 kEventPriorityHigh );
416 }
417 #else
418 wxMacCarbonEvent wakeupEvent;
419 wakeupEvent.Create( 'WXMC', 'WXMC', GetCurrentEventTime(),
420 kEventAttributeNone );
421 err = PostEventToQueue(GetMainEventQueue(), wakeupEvent,
422 kEventPriorityHigh );
423 #endif
424 }
425
426 #endif // wxUSE_BASE
427
428 #if wxUSE_GUI
429
430 // ----------------------------------------------------------------------------
431 // Native Struct Conversions
432 // ----------------------------------------------------------------------------
433
434 void wxMacRectToNative( const wxRect *wx , Rect *n )
435 {
436 n->left = wx->x;
437 n->top = wx->y;
438 n->right = wx->x + wx->width;
439 n->bottom = wx->y + wx->height;
440 }
441
442 void wxMacNativeToRect( const Rect *n , wxRect* wx )
443 {
444 wx->x = n->left;
445 wx->y = n->top;
446 wx->width = n->right - n->left;
447 wx->height = n->bottom - n->top;
448 }
449
450 void wxMacPointToNative( const wxPoint* wx , Point *n )
451 {
452 n->h = wx->x;
453 n->v = wx->y;
454 }
455
456 void wxMacNativeToPoint( const Point *n , wxPoint* wx )
457 {
458 wx->x = n->h;
459 wx->y = n->v;
460 }
461
462 // ----------------------------------------------------------------------------
463 // Carbon Event Support
464 // ----------------------------------------------------------------------------
465
466 OSStatus wxMacCarbonEvent::GetParameter(EventParamName inName, EventParamType inDesiredType, UInt32 inBufferSize, void * outData)
467 {
468 return ::GetEventParameter( m_eventRef , inName , inDesiredType , NULL , inBufferSize , NULL , outData );
469 }
470
471 OSStatus wxMacCarbonEvent::SetParameter(EventParamName inName, EventParamType inType, UInt32 inBufferSize, const void * inData)
472 {
473 return ::SetEventParameter( m_eventRef , inName , inType , inBufferSize , inData );
474 }
475
476 // ----------------------------------------------------------------------------
477 // Control Access Support
478 // ----------------------------------------------------------------------------
479
480 #if wxMAC_USE_QUICKDRAW
481
482 IMPLEMENT_DYNAMIC_CLASS( wxMacControl , wxObject )
483
484 wxMacControl::wxMacControl()
485 {
486 Init();
487 }
488
489 wxMacControl::wxMacControl(wxWindow* peer , bool isRootControl )
490 {
491 Init();
492 m_peer = peer;
493 m_isRootControl = isRootControl;
494 }
495
496 wxMacControl::wxMacControl( wxWindow* peer , ControlRef control )
497 {
498 Init();
499 m_peer = peer;
500 m_controlRef = control;
501 }
502
503 wxMacControl::wxMacControl( wxWindow* peer , WXWidget control )
504 {
505 Init();
506 m_peer = peer;
507 m_controlRef = (ControlRef) control;
508 }
509
510 wxMacControl::~wxMacControl()
511 {
512 }
513
514 void wxMacControl::Init()
515 {
516 m_peer = NULL;
517 m_controlRef = NULL;
518 m_needsFocusRect = false;
519 m_isRootControl = false;
520 }
521
522 void wxMacControl::Dispose()
523 {
524 wxASSERT_MSG( m_controlRef != NULL , wxT("Control Handle already NULL, Dispose called twice ?") );
525 wxASSERT_MSG( IsValidControlHandle(m_controlRef) , wxT("Invalid Control Handle (maybe already released) in Dispose") );
526
527 // we cannot check the ref count here anymore, as autorelease objects might delete their refs later
528 // we can have situations when being embedded, where the control gets deleted behind our back, so only
529 // CFRelease if we are safe
530 if ( IsValidControlHandle(m_controlRef) )
531 CFRelease(m_controlRef);
532 m_controlRef = NULL;
533 }
534
535 void wxMacControl::SetReference( URefCon data )
536 {
537 SetControlReference( m_controlRef , data );
538 }
539
540 OSStatus wxMacControl::GetData(ControlPartCode inPartCode , ResType inTag , Size inBufferSize , void * inOutBuffer , Size * outActualSize ) const
541 {
542 return ::GetControlData( m_controlRef , inPartCode , inTag , inBufferSize , inOutBuffer , outActualSize );
543 }
544
545 OSStatus wxMacControl::GetDataSize(ControlPartCode inPartCode , ResType inTag , Size * outActualSize ) const
546 {
547 return ::GetControlDataSize( m_controlRef , inPartCode , inTag , outActualSize );
548 }
549
550 OSStatus wxMacControl::SetData(ControlPartCode inPartCode , ResType inTag , Size inSize , const void * inData)
551 {
552 return ::SetControlData( m_controlRef , inPartCode , inTag , inSize , inData );
553 }
554
555 OSStatus wxMacControl::SendEvent( EventRef event , OptionBits inOptions )
556 {
557 return SendEventToEventTargetWithOptions( event,
558 HIObjectGetEventTarget( (HIObjectRef) m_controlRef ), inOptions );
559 }
560
561 OSStatus wxMacControl::SendHICommand( HICommand &command , OptionBits inOptions )
562 {
563 wxMacCarbonEvent event( kEventClassCommand , kEventCommandProcess );
564
565 event.SetParameter<HICommand>(kEventParamDirectObject,command);
566
567 return SendEvent( event , inOptions );
568 }
569
570 OSStatus wxMacControl::SendHICommand( UInt32 commandID , OptionBits inOptions )
571 {
572 HICommand command;
573
574 memset( &command, 0 , sizeof(command) );
575 command.commandID = commandID;
576 return SendHICommand( command , inOptions );
577 }
578
579 void wxMacControl::Flash( ControlPartCode part , UInt32 ticks )
580 {
581 unsigned long finalTicks;
582
583 HiliteControl( m_controlRef , part );
584 Delay( ticks , &finalTicks );
585 HiliteControl( m_controlRef , kControlNoPart );
586 }
587
588 SInt32 wxMacControl::GetValue() const
589 {
590 return ::GetControl32BitValue( m_controlRef );
591 }
592
593 SInt32 wxMacControl::GetMaximum() const
594 {
595 return ::GetControl32BitMaximum( m_controlRef );
596 }
597
598 SInt32 wxMacControl::GetMinimum() const
599 {
600 return ::GetControl32BitMinimum( m_controlRef );
601 }
602
603 void wxMacControl::SetValue( SInt32 v )
604 {
605 ::SetControl32BitValue( m_controlRef , v );
606 }
607
608 void wxMacControl::SetMinimum( SInt32 v )
609 {
610 ::SetControl32BitMinimum( m_controlRef , v );
611 }
612
613 void wxMacControl::SetMaximum( SInt32 v )
614 {
615 ::SetControl32BitMaximum( m_controlRef , v );
616 }
617
618 void wxMacControl::SetValueAndRange( SInt32 value , SInt32 minimum , SInt32 maximum )
619 {
620 ::SetControl32BitMinimum( m_controlRef , minimum );
621 ::SetControl32BitMaximum( m_controlRef , maximum );
622 ::SetControl32BitValue( m_controlRef , value );
623 }
624
625 OSStatus wxMacControl::SetFocus( ControlFocusPart focusPart )
626 {
627 return SetKeyboardFocus( GetControlOwner( m_controlRef ), m_controlRef, focusPart );
628 }
629
630 bool wxMacControl::HasFocus() const
631 {
632 ControlRef control;
633 GetKeyboardFocus( GetUserFocusWindow() , &control );
634 return control == m_controlRef;
635 }
636
637 void wxMacControl::SetNeedsFocusRect( bool needs )
638 {
639 m_needsFocusRect = needs;
640 }
641
642 bool wxMacControl::NeedsFocusRect() const
643 {
644 return m_needsFocusRect;
645 }
646
647 void wxMacControl::VisibilityChanged(bool WXUNUSED(shown))
648 {
649 }
650
651 void wxMacControl::SuperChangedPosition()
652 {
653 }
654
655 void wxMacControl::SetFont( const wxFont & font , const wxColour& foreground , long windowStyle )
656 {
657 m_font = font;
658 #if wxMAC_USE_CORE_TEXT
659 if ( UMAGetSystemVersion() >= 0x1050 )
660 {
661 HIViewPartCode part = 0;
662 HIThemeTextHorizontalFlush flush = kHIThemeTextHorizontalFlushDefault;
663 if ( ( windowStyle & wxALIGN_MASK ) & wxALIGN_CENTER_HORIZONTAL )
664 flush = kHIThemeTextHorizontalFlushCenter;
665 else if ( ( windowStyle & wxALIGN_MASK ) & wxALIGN_RIGHT )
666 flush = kHIThemeTextHorizontalFlushRight;
667 HIViewSetTextFont( m_controlRef , part , (CTFontRef) font.MacGetCTFont() );
668 HIViewSetTextHorizontalFlush( m_controlRef, part, flush );
669
670 if ( foreground != *wxBLACK )
671 {
672 ControlFontStyleRec fontStyle;
673 foreground.GetRGBColor( &fontStyle.foreColor );
674 fontStyle.flags = kControlUseForeColorMask;
675 ::SetControlFontStyle( m_controlRef , &fontStyle );
676 }
677
678 }
679 #endif
680 #if wxMAC_USE_ATSU_TEXT
681 ControlFontStyleRec fontStyle;
682 if ( font.MacGetThemeFontID() != kThemeCurrentPortFont )
683 {
684 switch ( font.MacGetThemeFontID() )
685 {
686 case kThemeSmallSystemFont :
687 fontStyle.font = kControlFontSmallSystemFont;
688 break;
689
690 case 109 : // mini font
691 fontStyle.font = -5;
692 break;
693
694 case kThemeSystemFont :
695 fontStyle.font = kControlFontBigSystemFont;
696 break;
697
698 default :
699 fontStyle.font = kControlFontBigSystemFont;
700 break;
701 }
702
703 fontStyle.flags = kControlUseFontMask;
704 }
705 else
706 {
707 fontStyle.font = font.MacGetFontNum();
708 fontStyle.style = font.MacGetFontStyle();
709 fontStyle.size = font.MacGetFontSize();
710 fontStyle.flags = kControlUseFontMask | kControlUseFaceMask | kControlUseSizeMask;
711 }
712
713 fontStyle.just = teJustLeft;
714 fontStyle.flags |= kControlUseJustMask;
715 if ( ( windowStyle & wxALIGN_MASK ) & wxALIGN_CENTER_HORIZONTAL )
716 fontStyle.just = teJustCenter;
717 else if ( ( windowStyle & wxALIGN_MASK ) & wxALIGN_RIGHT )
718 fontStyle.just = teJustRight;
719
720
721 // we only should do this in case of a non-standard color, as otherwise 'disabled' controls
722 // won't get grayed out by the system anymore
723
724 if ( foreground != *wxBLACK )
725 {
726 foreground.GetRGBColor( &fontStyle.foreColor );
727 fontStyle.flags |= kControlUseForeColorMask;
728 }
729
730 ::SetControlFontStyle( m_controlRef , &fontStyle );
731 #endif
732 }
733
734 void wxMacControl::SetBackgroundColour( const wxColour &WXUNUSED(col) )
735 {
736 // HITextViewSetBackgroundColor( m_textView , color );
737 }
738
739 void wxMacControl::SetRange( SInt32 minimum , SInt32 maximum )
740 {
741 ::SetControl32BitMinimum( m_controlRef , minimum );
742 ::SetControl32BitMaximum( m_controlRef , maximum );
743 }
744
745 short wxMacControl::HandleKey( SInt16 keyCode, SInt16 charCode, EventModifiers modifiers )
746 {
747 #ifndef __LP64__
748 return HandleControlKey( m_controlRef , keyCode , charCode , modifiers );
749 #else
750 return 0;
751 #endif
752 }
753
754 void wxMacControl::SetActionProc( ControlActionUPP actionProc )
755 {
756 SetControlAction( m_controlRef , actionProc );
757 }
758
759 void wxMacControl::SetViewSize( SInt32 viewSize )
760 {
761 SetControlViewSize(m_controlRef , viewSize );
762 }
763
764 SInt32 wxMacControl::GetViewSize() const
765 {
766 return GetControlViewSize( m_controlRef );
767 }
768
769 bool wxMacControl::IsVisible() const
770 {
771 return IsControlVisible( m_controlRef );
772 }
773
774 void wxMacControl::SetVisibility( bool visible , bool redraw )
775 {
776 SetControlVisibility( m_controlRef , visible , redraw );
777 }
778
779 bool wxMacControl::IsEnabled() const
780 {
781 return IsControlEnabled( m_controlRef );
782 }
783
784 bool wxMacControl::IsActive() const
785 {
786 return IsControlActive( m_controlRef );
787 }
788
789 void wxMacControl::Enable( bool enable )
790 {
791 if ( enable )
792 EnableControl( m_controlRef );
793 else
794 DisableControl( m_controlRef );
795 }
796
797 void wxMacControl::SetDrawingEnabled( bool enable )
798 {
799 HIViewSetDrawingEnabled( m_controlRef , enable );
800 }
801
802 bool wxMacControl::GetNeedsDisplay() const
803 {
804 return HIViewGetNeedsDisplay( m_controlRef );
805 }
806
807 void wxMacControl::SetNeedsDisplay( RgnHandle where )
808 {
809 if ( !IsVisible() )
810 return;
811
812 HIViewSetNeedsDisplayInRegion( m_controlRef , where , true );
813 }
814
815 void wxMacControl::SetNeedsDisplay( Rect* where )
816 {
817 if ( !IsVisible() )
818 return;
819
820 if ( where != NULL )
821 {
822 RgnHandle update = NewRgn();
823 RectRgn( update , where );
824 HIViewSetNeedsDisplayInRegion( m_controlRef , update , true );
825 DisposeRgn( update );
826 }
827 else
828 HIViewSetNeedsDisplay( m_controlRef , true );
829 }
830
831 void wxMacControl::Convert( wxPoint *pt , wxMacControl *from , wxMacControl *to )
832 {
833 HIPoint hiPoint;
834
835 hiPoint.x = pt->x;
836 hiPoint.y = pt->y;
837 HIViewConvertPoint( &hiPoint , from->m_controlRef , to->m_controlRef );
838 pt->x = (int)hiPoint.x;
839 pt->y = (int)hiPoint.y;
840 }
841
842 void wxMacControl::SetRect( Rect *r )
843 {
844 //A HIRect is actually a CGRect on OSX - which consists of two structures -
845 //CGPoint and CGSize, which have two floats each
846 HIRect hir = { { r->left , r->top }, { r->right - r->left , r->bottom - r->top } };
847 HIViewSetFrame ( m_controlRef , &hir );
848 // eventuall we might have to do a SetVisibility( false , true );
849 // before and a SetVisibility( true , true ); after
850 }
851
852 void wxMacControl::GetRect( Rect *r )
853 {
854 GetControlBounds( m_controlRef , r );
855 }
856
857 void wxMacControl::GetRectInWindowCoords( Rect *r )
858 {
859 GetControlBounds( m_controlRef , r ) ;
860
861 WindowRef tlwref = GetControlOwner( m_controlRef ) ;
862
863 wxTopLevelWindowMac* tlwwx = wxFindWinFromMacWindow( tlwref ) ;
864 if ( tlwwx != NULL )
865 {
866 ControlRef rootControl = tlwwx->GetPeer()->GetControlRef() ;
867 HIPoint hiPoint = CGPointMake( 0 , 0 ) ;
868 HIViewConvertPoint( &hiPoint , HIViewGetSuperview(m_controlRef) , rootControl ) ;
869 OffsetRect( r , (short) hiPoint.x , (short) hiPoint.y ) ;
870 }
871 }
872
873 void wxMacControl::GetBestRect( Rect *r )
874 {
875 short baselineoffset;
876
877 GetBestControlRect( m_controlRef , r , &baselineoffset );
878 }
879
880 void wxMacControl::SetLabel( const wxString &title )
881 {
882 wxFontEncoding encoding;
883
884 if ( m_font.Ok() )
885 encoding = m_font.GetEncoding();
886 else
887 encoding = wxFont::GetDefaultEncoding();
888
889 SetControlTitleWithCFString( m_controlRef , wxCFStringRef( title , encoding ) );
890 }
891
892 void wxMacControl::GetFeatures( UInt32 * features )
893 {
894 GetControlFeatures( m_controlRef , features );
895 }
896
897 OSStatus wxMacControl::GetRegion( ControlPartCode partCode , RgnHandle region )
898 {
899 OSStatus err = GetControlRegion( m_controlRef , partCode , region );
900 return err;
901 }
902
903 OSStatus wxMacControl::SetZOrder( bool above , wxMacControl* other )
904 {
905 return HIViewSetZOrder( m_controlRef,above ? kHIViewZOrderAbove : kHIViewZOrderBelow,
906 (other != NULL) ? other->m_controlRef : NULL);
907 }
908
909 // SetNeedsDisplay would not invalidate the children
910 static void InvalidateControlAndChildren( HIViewRef control )
911 {
912 HIViewSetNeedsDisplay( control , true );
913 UInt16 childrenCount = 0;
914 OSStatus err = CountSubControls( control , &childrenCount );
915 if ( err == errControlIsNotEmbedder )
916 return;
917
918 wxASSERT_MSG( err == noErr , wxT("Unexpected error when accessing subcontrols") );
919
920 for ( UInt16 i = childrenCount; i >=1; --i )
921 {
922 HIViewRef child;
923
924 err = GetIndexedSubControl( control , i , & child );
925 if ( err == errControlIsNotEmbedder )
926 return;
927
928 InvalidateControlAndChildren( child );
929 }
930 }
931
932 void wxMacControl::InvalidateWithChildren()
933 {
934 InvalidateControlAndChildren( m_controlRef );
935 }
936
937 void wxMacControl::ScrollRect( wxRect *r , int dx , int dy )
938 {
939 wxASSERT( r != NULL );
940
941 HIRect scrollarea = CGRectMake( r->x , r->y , r->width , r->height);
942 HIViewScrollRect ( m_controlRef , &scrollarea , dx ,dy );
943 }
944
945 OSType wxMacCreator = 'WXMC';
946 OSType wxMacControlProperty = 'MCCT';
947
948 void wxMacControl::SetReferenceInNativeControl()
949 {
950 void * data = this;
951 verify_noerr( SetControlProperty ( m_controlRef ,
952 wxMacCreator,wxMacControlProperty, sizeof(data), &data ) );
953 }
954
955 wxMacControl* wxMacControl::GetReferenceFromNativeControl(ControlRef control)
956 {
957 wxMacControl* ctl = NULL;
958 ByteCount actualSize;
959 if ( GetControlProperty( control ,wxMacCreator,wxMacControlProperty, sizeof(ctl) ,
960 &actualSize , &ctl ) == noErr )
961 {
962 return ctl;
963 }
964 return NULL;
965 }
966
967 // ============================================================================
968 // DataBrowser Wrapper
969 // ============================================================================
970 //
971 // basing on DataBrowserItemIDs
972 //
973
974 IMPLEMENT_ABSTRACT_CLASS( wxMacDataBrowserControl , wxMacControl )
975
976 pascal void wxMacDataBrowserControl::DataBrowserItemNotificationProc(
977 ControlRef browser,
978 DataBrowserItemID itemID,
979 DataBrowserItemNotification message,
980 DataBrowserItemDataRef itemData )
981 {
982 wxMacDataBrowserControl* ctl = wxDynamicCast(wxMacControl::GetReferenceFromNativeControl( browser ), wxMacDataBrowserControl);
983 if ( ctl != 0 )
984 {
985 ctl->ItemNotification(itemID, message, itemData);
986 }
987 }
988
989 pascal OSStatus wxMacDataBrowserControl::DataBrowserGetSetItemDataProc(
990 ControlRef browser,
991 DataBrowserItemID itemID,
992 DataBrowserPropertyID property,
993 DataBrowserItemDataRef itemData,
994 Boolean changeValue )
995 {
996 OSStatus err = errDataBrowserPropertyNotSupported;
997 wxMacDataBrowserControl* ctl = wxDynamicCast(wxMacControl::GetReferenceFromNativeControl( browser ), wxMacDataBrowserControl);
998 if ( ctl != 0 )
999 {
1000 err = ctl->GetSetItemData(itemID, property, itemData, changeValue);
1001 }
1002 return err;
1003 }
1004
1005 pascal Boolean wxMacDataBrowserControl::DataBrowserCompareProc(
1006 ControlRef browser,
1007 DataBrowserItemID itemOneID,
1008 DataBrowserItemID itemTwoID,
1009 DataBrowserPropertyID sortProperty)
1010 {
1011 wxMacDataBrowserControl* ctl = wxDynamicCast(wxMacControl::GetReferenceFromNativeControl( browser ), wxMacDataBrowserControl);
1012 if ( ctl != 0 )
1013 {
1014 return ctl->CompareItems(itemOneID, itemTwoID, sortProperty);
1015 }
1016 return false;
1017 }
1018
1019 DataBrowserItemDataUPP gDataBrowserItemDataUPP = NULL;
1020 DataBrowserItemNotificationUPP gDataBrowserItemNotificationUPP = NULL;
1021 DataBrowserItemCompareUPP gDataBrowserItemCompareUPP = NULL;
1022
1023 wxMacDataBrowserControl::wxMacDataBrowserControl( wxWindow* peer,
1024 const wxPoint& pos,
1025 const wxSize& size,
1026 long WXUNUSED(style))
1027 : wxMacControl( peer )
1028 {
1029 Rect bounds = wxMacGetBoundsForControl( peer, pos, size );
1030 OSStatus err = ::CreateDataBrowserControl(
1031 MAC_WXHWND(peer->MacGetTopLevelWindowRef()),
1032 &bounds, kDataBrowserListView, &m_controlRef );
1033 SetReferenceInNativeControl();
1034 verify_noerr( err );
1035 if ( gDataBrowserItemCompareUPP == NULL )
1036 gDataBrowserItemCompareUPP = NewDataBrowserItemCompareUPP(DataBrowserCompareProc);
1037 if ( gDataBrowserItemDataUPP == NULL )
1038 gDataBrowserItemDataUPP = NewDataBrowserItemDataUPP(DataBrowserGetSetItemDataProc);
1039 if ( gDataBrowserItemNotificationUPP == NULL )
1040 {
1041 gDataBrowserItemNotificationUPP =
1042 (DataBrowserItemNotificationUPP) NewDataBrowserItemNotificationWithItemUPP(DataBrowserItemNotificationProc);
1043 }
1044
1045 DataBrowserCallbacks callbacks;
1046 InitializeDataBrowserCallbacks( &callbacks, kDataBrowserLatestCallbacks );
1047
1048 callbacks.u.v1.itemDataCallback = gDataBrowserItemDataUPP;
1049 callbacks.u.v1.itemCompareCallback = gDataBrowserItemCompareUPP;
1050 callbacks.u.v1.itemNotificationCallback = gDataBrowserItemNotificationUPP;
1051 SetCallbacks( &callbacks );
1052
1053 }
1054
1055 OSStatus wxMacDataBrowserControl::GetItemCount( DataBrowserItemID container,
1056 Boolean recurse,
1057 DataBrowserItemState state,
1058 ItemCount *numItems) const
1059 {
1060 return GetDataBrowserItemCount( m_controlRef, container, recurse, state, numItems );
1061 }
1062
1063 OSStatus wxMacDataBrowserControl::GetItems( DataBrowserItemID container,
1064 Boolean recurse,
1065 DataBrowserItemState state,
1066 Handle items) const
1067 {
1068 return GetDataBrowserItems( m_controlRef, container, recurse, state, items );
1069 }
1070
1071 OSStatus wxMacDataBrowserControl::SetSelectionFlags( DataBrowserSelectionFlags options )
1072 {
1073 return SetDataBrowserSelectionFlags( m_controlRef, options );
1074 }
1075
1076 OSStatus wxMacDataBrowserControl::AddColumn( DataBrowserListViewColumnDesc *columnDesc,
1077 DataBrowserTableViewColumnIndex position )
1078 {
1079 return AddDataBrowserListViewColumn( m_controlRef, columnDesc, position );
1080 }
1081
1082 OSStatus wxMacDataBrowserControl::GetColumnIDFromIndex( DataBrowserTableViewColumnIndex position, DataBrowserTableViewColumnID* id ){
1083 return GetDataBrowserTableViewColumnProperty( m_controlRef, position, id );
1084 }
1085
1086 OSStatus wxMacDataBrowserControl::RemoveColumn( DataBrowserTableViewColumnIndex position )
1087 {
1088 DataBrowserTableViewColumnID id;
1089 GetColumnIDFromIndex( position, &id );
1090 return RemoveDataBrowserTableViewColumn( m_controlRef, id );
1091 }
1092
1093 OSStatus wxMacDataBrowserControl::AutoSizeColumns()
1094 {
1095 return AutoSizeDataBrowserListViewColumns(m_controlRef);
1096 }
1097
1098 OSStatus wxMacDataBrowserControl::SetHasScrollBars( bool horiz, bool vert )
1099 {
1100 return SetDataBrowserHasScrollBars( m_controlRef, horiz, vert );
1101 }
1102
1103 OSStatus wxMacDataBrowserControl::SetHiliteStyle( DataBrowserTableViewHiliteStyle hiliteStyle )
1104 {
1105 return SetDataBrowserTableViewHiliteStyle( m_controlRef, hiliteStyle );
1106 }
1107
1108 OSStatus wxMacDataBrowserControl::SetHeaderButtonHeight(UInt16 height)
1109 {
1110 return SetDataBrowserListViewHeaderBtnHeight( m_controlRef, height );
1111 }
1112
1113 OSStatus wxMacDataBrowserControl::GetHeaderButtonHeight(UInt16 *height)
1114 {
1115 return GetDataBrowserListViewHeaderBtnHeight( m_controlRef, height );
1116 }
1117
1118 OSStatus wxMacDataBrowserControl::SetCallbacks(const DataBrowserCallbacks *callbacks)
1119 {
1120 return SetDataBrowserCallbacks( m_controlRef, callbacks );
1121 }
1122
1123 OSStatus wxMacDataBrowserControl::UpdateItems(
1124 DataBrowserItemID container,
1125 UInt32 numItems,
1126 const DataBrowserItemID *items,
1127 DataBrowserPropertyID preSortProperty,
1128 DataBrowserPropertyID propertyID ) const
1129 {
1130 return UpdateDataBrowserItems( m_controlRef, container, numItems, items, preSortProperty, propertyID );
1131 }
1132
1133 bool wxMacDataBrowserControl::IsItemSelected( DataBrowserItemID item ) const
1134 {
1135 return IsDataBrowserItemSelected( m_controlRef, item );
1136 }
1137
1138 OSStatus wxMacDataBrowserControl::AddItems(
1139 DataBrowserItemID container,
1140 UInt32 numItems,
1141 const DataBrowserItemID *items,
1142 DataBrowserPropertyID preSortProperty )
1143 {
1144 return AddDataBrowserItems( m_controlRef, container, numItems, items, preSortProperty );
1145 }
1146
1147 OSStatus wxMacDataBrowserControl::RemoveItems(
1148 DataBrowserItemID container,
1149 UInt32 numItems,
1150 const DataBrowserItemID *items,
1151 DataBrowserPropertyID preSortProperty )
1152 {
1153 return RemoveDataBrowserItems( m_controlRef, container, numItems, items, preSortProperty );
1154 }
1155
1156 OSStatus wxMacDataBrowserControl::RevealItem(
1157 DataBrowserItemID item,
1158 DataBrowserPropertyID propertyID,
1159 DataBrowserRevealOptions options ) const
1160 {
1161 return RevealDataBrowserItem( m_controlRef, item, propertyID, options );
1162 }
1163
1164 OSStatus wxMacDataBrowserControl::SetSelectedItems(
1165 UInt32 numItems,
1166 const DataBrowserItemID *items,
1167 DataBrowserSetOption operation )
1168 {
1169 return SetDataBrowserSelectedItems( m_controlRef, numItems, items, operation );
1170 }
1171
1172 OSStatus wxMacDataBrowserControl::GetSelectionAnchor( DataBrowserItemID *first, DataBrowserItemID *last ) const
1173 {
1174 return GetDataBrowserSelectionAnchor( m_controlRef, first, last );
1175 }
1176
1177 OSStatus wxMacDataBrowserControl::GetItemID( DataBrowserTableViewRowIndex row, DataBrowserItemID * item ) const
1178 {
1179 return GetDataBrowserTableViewItemID( m_controlRef, row, item );
1180 }
1181
1182 OSStatus wxMacDataBrowserControl::GetItemRow( DataBrowserItemID item, DataBrowserTableViewRowIndex * row ) const
1183 {
1184 return GetDataBrowserTableViewItemRow( m_controlRef, item, row );
1185 }
1186
1187 OSStatus wxMacDataBrowserControl::SetDefaultRowHeight( UInt16 height )
1188 {
1189 return SetDataBrowserTableViewRowHeight( m_controlRef , height );
1190 }
1191
1192 OSStatus wxMacDataBrowserControl::GetDefaultRowHeight( UInt16 * height ) const
1193 {
1194 return GetDataBrowserTableViewRowHeight( m_controlRef, height );
1195 }
1196
1197 OSStatus wxMacDataBrowserControl::SetRowHeight( DataBrowserItemID item , UInt16 height)
1198 {
1199 return SetDataBrowserTableViewItemRowHeight( m_controlRef, item , height );
1200 }
1201
1202 OSStatus wxMacDataBrowserControl::GetRowHeight( DataBrowserItemID item , UInt16 *height) const
1203 {
1204 return GetDataBrowserTableViewItemRowHeight( m_controlRef, item , height);
1205 }
1206
1207 OSStatus wxMacDataBrowserControl::GetColumnWidth( DataBrowserPropertyID column , UInt16 *width ) const
1208 {
1209 return GetDataBrowserTableViewNamedColumnWidth( m_controlRef , column , width );
1210 }
1211
1212 OSStatus wxMacDataBrowserControl::SetColumnWidth( DataBrowserPropertyID column , UInt16 width )
1213 {
1214 return SetDataBrowserTableViewNamedColumnWidth( m_controlRef , column , width );
1215 }
1216
1217 OSStatus wxMacDataBrowserControl::GetDefaultColumnWidth( UInt16 *width ) const
1218 {
1219 return GetDataBrowserTableViewColumnWidth( m_controlRef , width );
1220 }
1221
1222 OSStatus wxMacDataBrowserControl::SetDefaultColumnWidth( UInt16 width )
1223 {
1224 return SetDataBrowserTableViewColumnWidth( m_controlRef , width );
1225 }
1226
1227 OSStatus wxMacDataBrowserControl::GetColumnCount(UInt32* numColumns) const
1228 {
1229 return GetDataBrowserTableViewColumnCount( m_controlRef, numColumns);
1230 }
1231
1232 OSStatus wxMacDataBrowserControl::GetColumnPosition( DataBrowserPropertyID column,
1233 DataBrowserTableViewColumnIndex *position) const
1234 {
1235 return GetDataBrowserTableViewColumnPosition( m_controlRef , column , position);
1236 }
1237
1238 OSStatus wxMacDataBrowserControl::SetColumnPosition( DataBrowserPropertyID column, DataBrowserTableViewColumnIndex position)
1239 {
1240 return SetDataBrowserTableViewColumnPosition( m_controlRef , column , position);
1241 }
1242
1243 OSStatus wxMacDataBrowserControl::GetScrollPosition( UInt32 *top , UInt32 *left ) const
1244 {
1245 return GetDataBrowserScrollPosition( m_controlRef , top , left );
1246 }
1247
1248 OSStatus wxMacDataBrowserControl::SetScrollPosition( UInt32 top , UInt32 left )
1249 {
1250 return SetDataBrowserScrollPosition( m_controlRef , top , left );
1251 }
1252
1253 OSStatus wxMacDataBrowserControl::GetSortProperty( DataBrowserPropertyID *column ) const
1254 {
1255 return GetDataBrowserSortProperty( m_controlRef , column );
1256 }
1257
1258 OSStatus wxMacDataBrowserControl::SetSortProperty( DataBrowserPropertyID column )
1259 {
1260 return SetDataBrowserSortProperty( m_controlRef , column );
1261 }
1262
1263 OSStatus wxMacDataBrowserControl::GetSortOrder( DataBrowserSortOrder *order ) const
1264 {
1265 return GetDataBrowserSortOrder( m_controlRef , order );
1266 }
1267
1268 OSStatus wxMacDataBrowserControl::SetSortOrder( DataBrowserSortOrder order )
1269 {
1270 return SetDataBrowserSortOrder( m_controlRef , order );
1271 }
1272
1273 OSStatus wxMacDataBrowserControl::GetPropertyFlags( DataBrowserPropertyID property,
1274 DataBrowserPropertyFlags *flags ) const
1275 {
1276 return GetDataBrowserPropertyFlags( m_controlRef , property , flags );
1277 }
1278
1279 OSStatus wxMacDataBrowserControl::SetPropertyFlags( DataBrowserPropertyID property,
1280 DataBrowserPropertyFlags flags )
1281 {
1282 return SetDataBrowserPropertyFlags( m_controlRef , property , flags );
1283 }
1284
1285 OSStatus wxMacDataBrowserControl::GetHeaderDesc( DataBrowserPropertyID property,
1286 DataBrowserListViewHeaderDesc *desc ) const
1287 {
1288 return GetDataBrowserListViewHeaderDesc( m_controlRef , property , desc );
1289 }
1290
1291 OSStatus wxMacDataBrowserControl::SetHeaderDesc( DataBrowserPropertyID property,
1292 DataBrowserListViewHeaderDesc *desc )
1293 {
1294 return SetDataBrowserListViewHeaderDesc( m_controlRef , property , desc );
1295 }
1296
1297 OSStatus wxMacDataBrowserControl::SetDisclosureColumn( DataBrowserPropertyID property ,
1298 Boolean expandableRows )
1299 {
1300 return SetDataBrowserListViewDisclosureColumn( m_controlRef, property, expandableRows);
1301 }
1302
1303 // ============================================================================
1304 // Higher-level Databrowser
1305 // ============================================================================
1306 //
1307 // basing on data item objects
1308 //
1309
1310 wxMacDataItem::wxMacDataItem()
1311 {
1312 m_data = NULL;
1313
1314 m_order = 0;
1315 m_colId = kTextColumnId; // for compat with existing wx*ListBox impls.
1316 }
1317
1318 wxMacDataItem::~wxMacDataItem()
1319 {
1320 }
1321
1322 void wxMacDataItem::SetOrder( SInt32 order )
1323 {
1324 m_order = order;
1325 }
1326
1327 SInt32 wxMacDataItem::GetOrder() const
1328 {
1329 return m_order;
1330 }
1331
1332 void wxMacDataItem::SetData( void* data)
1333 {
1334 m_data = data;
1335 }
1336
1337 void* wxMacDataItem::GetData() const
1338 {
1339 return m_data;
1340 }
1341
1342 short wxMacDataItem::GetColumn()
1343 {
1344 return m_colId;
1345 }
1346
1347 void wxMacDataItem::SetColumn( short col )
1348 {
1349 m_colId = col;
1350 }
1351
1352 void wxMacDataItem::SetLabel( const wxString& str)
1353 {
1354 m_label = str;
1355 m_cfLabel = wxCFStringRef( str , wxLocale::GetSystemEncoding());
1356 }
1357
1358 const wxString& wxMacDataItem::GetLabel() const
1359 {
1360 return m_label;
1361 }
1362
1363 bool wxMacDataItem::IsLessThan(wxMacDataItemBrowserControl *WXUNUSED(owner) ,
1364 const wxMacDataItem* rhs,
1365 DataBrowserPropertyID sortProperty) const
1366 {
1367 const wxMacDataItem* otherItem = wx_const_cast(wxMacDataItem*,rhs);
1368 bool retval = false;
1369
1370 if ( sortProperty == m_colId ){
1371 retval = m_label.CmpNoCase( otherItem->m_label) < 0;
1372 }
1373
1374 else if ( sortProperty == kNumericOrderColumnId )
1375 retval = m_order < otherItem->m_order;
1376
1377 return retval;
1378 }
1379
1380 OSStatus wxMacDataItem::GetSetData( wxMacDataItemBrowserControl *WXUNUSED(owner) ,
1381 DataBrowserPropertyID property,
1382 DataBrowserItemDataRef itemData,
1383 bool changeValue )
1384 {
1385 OSStatus err = errDataBrowserPropertyNotSupported;
1386 if ( !changeValue )
1387 {
1388 if ( property == m_colId ){
1389 err = ::SetDataBrowserItemDataText( itemData, m_cfLabel );
1390 err = noErr;
1391 }
1392 else if ( property == kNumericOrderColumnId ){
1393 err = ::SetDataBrowserItemDataValue( itemData, m_order );
1394 err = noErr;
1395 }
1396 else{
1397 }
1398 }
1399 else
1400 {
1401 switch (property)
1402 {
1403 // no editable props here
1404 default:
1405 break;
1406 }
1407 }
1408
1409 return err;
1410 }
1411
1412 void wxMacDataItem::Notification(wxMacDataItemBrowserControl *WXUNUSED(owner) ,
1413 DataBrowserItemNotification WXUNUSED(message),
1414 DataBrowserItemDataRef WXUNUSED(itemData) ) const
1415 {
1416 }
1417
1418 IMPLEMENT_DYNAMIC_CLASS( wxMacDataItemBrowserControl , wxMacDataBrowserControl )
1419
1420 wxMacDataItemBrowserControl::wxMacDataItemBrowserControl( wxWindow* peer , const wxPoint& pos, const wxSize& size, long style) :
1421 wxMacDataBrowserControl( peer, pos, size, style )
1422 {
1423 m_suppressSelection = false;
1424 m_sortOrder = SortOrder_None;
1425 m_clientDataItemsType = wxClientData_None;
1426 }
1427
1428 wxMacDataItem* wxMacDataItemBrowserControl::CreateItem()
1429 {
1430 return new wxMacDataItem();
1431 }
1432
1433 wxMacDataItemBrowserSelectionSuppressor::wxMacDataItemBrowserSelectionSuppressor(wxMacDataItemBrowserControl *browser)
1434 {
1435 m_former = browser->SuppressSelection(true);
1436 m_browser = browser;
1437 }
1438
1439 wxMacDataItemBrowserSelectionSuppressor::~wxMacDataItemBrowserSelectionSuppressor()
1440 {
1441 m_browser->SuppressSelection(m_former);
1442 }
1443
1444 bool wxMacDataItemBrowserControl::SuppressSelection( bool suppress )
1445 {
1446 bool former = m_suppressSelection;
1447 m_suppressSelection = suppress;
1448
1449 return former;
1450 }
1451
1452 Boolean wxMacDataItemBrowserControl::CompareItems(DataBrowserItemID itemOneID,
1453 DataBrowserItemID itemTwoID,
1454 DataBrowserPropertyID sortProperty)
1455 {
1456 wxMacDataItem* itemOne = (wxMacDataItem*) itemOneID;
1457 wxMacDataItem* itemTwo = (wxMacDataItem*) itemTwoID;
1458 return CompareItems( itemOne , itemTwo , sortProperty );
1459 }
1460
1461 Boolean wxMacDataItemBrowserControl::CompareItems(const wxMacDataItem* itemOne,
1462 const wxMacDataItem* itemTwo,
1463 DataBrowserPropertyID sortProperty)
1464 {
1465 Boolean retval = false;
1466 if ( itemOne != NULL )
1467 retval = itemOne->IsLessThan( this , itemTwo , sortProperty);
1468 return retval;
1469 }
1470
1471 OSStatus wxMacDataItemBrowserControl::GetSetItemData(
1472 DataBrowserItemID itemID,
1473 DataBrowserPropertyID property,
1474 DataBrowserItemDataRef itemData,
1475 Boolean changeValue )
1476 {
1477 wxMacDataItem* item = (wxMacDataItem*) itemID;
1478 return GetSetItemData(item, property, itemData , changeValue );
1479 }
1480
1481 OSStatus wxMacDataItemBrowserControl::GetSetItemData(
1482 wxMacDataItem* item,
1483 DataBrowserPropertyID property,
1484 DataBrowserItemDataRef itemData,
1485 Boolean changeValue )
1486 {
1487 OSStatus err = errDataBrowserPropertyNotSupported;
1488 switch( property )
1489 {
1490 case kDataBrowserContainerIsClosableProperty :
1491 case kDataBrowserContainerIsSortableProperty :
1492 case kDataBrowserContainerIsOpenableProperty :
1493 // right now default behaviour on these
1494 break;
1495 default :
1496
1497 if ( item != NULL ){
1498 err = item->GetSetData( this, property , itemData , changeValue );
1499 }
1500 break;
1501
1502 }
1503 return err;
1504 }
1505
1506 void wxMacDataItemBrowserControl::ItemNotification(
1507 DataBrowserItemID itemID,
1508 DataBrowserItemNotification message,
1509 DataBrowserItemDataRef itemData)
1510 {
1511 wxMacDataItem* item = (wxMacDataItem*) itemID;
1512 ItemNotification( item , message, itemData);
1513 }
1514
1515 void wxMacDataItemBrowserControl::ItemNotification(
1516 const wxMacDataItem* item,
1517 DataBrowserItemNotification message,
1518 DataBrowserItemDataRef itemData)
1519 {
1520 if (item != NULL)
1521 item->Notification( this, message, itemData);
1522 }
1523
1524 unsigned int wxMacDataItemBrowserControl::GetItemCount(const wxMacDataItem* container,
1525 bool recurse , DataBrowserItemState state) const
1526 {
1527 ItemCount numItems = 0;
1528 verify_noerr( wxMacDataBrowserControl::GetItemCount( (DataBrowserItemID)container,
1529 recurse, state, &numItems ) );
1530 return numItems;
1531 }
1532
1533 unsigned int wxMacDataItemBrowserControl::GetSelectedItemCount( const wxMacDataItem* container,
1534 bool recurse ) const
1535 {
1536 return GetItemCount( container, recurse, kDataBrowserItemIsSelected );
1537
1538 }
1539
1540 void wxMacDataItemBrowserControl::GetItems(const wxMacDataItem* container,
1541 bool recurse , DataBrowserItemState state, wxArrayMacDataItemPtr &items) const
1542 {
1543 Handle handle = NewHandle(0);
1544 verify_noerr( wxMacDataBrowserControl::GetItems( (DataBrowserItemID)container ,
1545 recurse , state, handle) );
1546
1547 int itemCount = GetHandleSize(handle)/sizeof(DataBrowserItemID);
1548 HLock( handle );
1549 wxMacDataItemPtr* itemsArray = (wxMacDataItemPtr*) *handle;
1550 for ( int i = 0; i < itemCount; ++i)
1551 {
1552 items.Add(itemsArray[i]);
1553 }
1554 HUnlock( handle );
1555 DisposeHandle( handle );
1556 }
1557
1558 unsigned int wxMacDataItemBrowserControl::GetLineFromItem(const wxMacDataItem* item) const
1559 {
1560 DataBrowserTableViewRowIndex row;
1561 OSStatus err = GetItemRow( (DataBrowserItemID) item , &row);
1562 wxASSERT( err == noErr);
1563 return row;
1564 }
1565
1566 wxMacDataItem* wxMacDataItemBrowserControl::GetItemFromLine(unsigned int n) const
1567 {
1568 DataBrowserItemID id;
1569 OSStatus err = GetItemID( (DataBrowserTableViewRowIndex) n , &id);
1570 wxASSERT( err == noErr);
1571 return (wxMacDataItem*) id;
1572 }
1573
1574 void wxMacDataItemBrowserControl::UpdateItem(const wxMacDataItem *container,
1575 const wxMacDataItem *item , DataBrowserPropertyID property) const
1576 {
1577 verify_noerr( wxMacDataBrowserControl::UpdateItems((DataBrowserItemID)container, 1,
1578 (DataBrowserItemID*) &item, kDataBrowserItemNoProperty /* notSorted */, property ) );
1579 }
1580
1581 void wxMacDataItemBrowserControl::UpdateItems(const wxMacDataItem *container,
1582 wxArrayMacDataItemPtr &itemArray , DataBrowserPropertyID property) const
1583 {
1584 unsigned int noItems = itemArray.GetCount();
1585 DataBrowserItemID *items = new DataBrowserItemID[noItems];
1586 for ( unsigned int i = 0; i < noItems; ++i )
1587 items[i] = (DataBrowserItemID) itemArray[i];
1588
1589 verify_noerr( wxMacDataBrowserControl::UpdateItems((DataBrowserItemID)container, noItems,
1590 items, kDataBrowserItemNoProperty /* notSorted */, property ) );
1591 delete [] items;
1592 }
1593
1594 void wxMacDataItemBrowserControl::InsertColumn(int colId, DataBrowserPropertyType colType,
1595 const wxString& title, SInt16 just, int defaultWidth)
1596 {
1597 DataBrowserListViewColumnDesc columnDesc;
1598 columnDesc.headerBtnDesc.titleOffset = 0;
1599 columnDesc.headerBtnDesc.version = kDataBrowserListViewLatestHeaderDesc;
1600
1601 columnDesc.headerBtnDesc.btnFontStyle.flags =
1602 kControlUseFontMask | kControlUseJustMask;
1603
1604 columnDesc.headerBtnDesc.btnContentInfo.contentType = kControlContentTextOnly;
1605 columnDesc.headerBtnDesc.btnFontStyle.just = just;
1606 columnDesc.headerBtnDesc.btnFontStyle.font = kControlFontViewSystemFont;
1607 columnDesc.headerBtnDesc.btnFontStyle.style = normal;
1608
1609 // TODO: Why is m_font not defined when we enter wxLC_LIST mode, but is
1610 // defined for other modes?
1611 wxFontEncoding enc;
1612 if ( m_font.Ok() )
1613 enc = m_font.GetEncoding();
1614 else
1615 enc = wxLocale::GetSystemEncoding();
1616 wxCFStringRef cfTitle( title, enc );
1617 columnDesc.headerBtnDesc.titleString = cfTitle;
1618
1619 columnDesc.headerBtnDesc.minimumWidth = 0;
1620 columnDesc.headerBtnDesc.maximumWidth = 30000;
1621
1622 columnDesc.propertyDesc.propertyID = (kMinColumnId + colId);
1623 columnDesc.propertyDesc.propertyType = colType;
1624 columnDesc.propertyDesc.propertyFlags = kDataBrowserListViewSortableColumn;
1625 columnDesc.propertyDesc.propertyFlags |= kDataBrowserListViewTypeSelectColumn;
1626 columnDesc.propertyDesc.propertyFlags |= kDataBrowserListViewNoGapForIconInHeaderButton;
1627
1628 verify_noerr( AddColumn( &columnDesc, kDataBrowserListViewAppendColumn ) );
1629
1630 if (defaultWidth > 0){
1631 SetColumnWidth(colId, defaultWidth);
1632 }
1633
1634 }
1635
1636 void wxMacDataItemBrowserControl::SetColumnWidth(int colId, int width)
1637 {
1638 DataBrowserPropertyID id;
1639 GetColumnIDFromIndex(colId, &id);
1640 verify_noerr( wxMacDataBrowserControl::SetColumnWidth(id, width));
1641 }
1642
1643 int wxMacDataItemBrowserControl::GetColumnWidth(int colId)
1644 {
1645 DataBrowserPropertyID id;
1646 GetColumnIDFromIndex(colId, &id);
1647 UInt16 result;
1648 verify_noerr( wxMacDataBrowserControl::GetColumnWidth(id, &result));
1649 return result;
1650 }
1651
1652 void wxMacDataItemBrowserControl::AddItem(wxMacDataItem *container, wxMacDataItem *item)
1653 {
1654 verify_noerr( wxMacDataBrowserControl::AddItems( (DataBrowserItemID)container, 1,
1655 (DataBrowserItemID*) &item, kDataBrowserItemNoProperty ) );
1656 }
1657
1658 void wxMacDataItemBrowserControl::AddItems(wxMacDataItem *container, wxArrayMacDataItemPtr &itemArray )
1659 {
1660 unsigned int noItems = itemArray.GetCount();
1661 DataBrowserItemID *items = new DataBrowserItemID[noItems];
1662 for ( unsigned int i = 0; i < noItems; ++i )
1663 items[i] = (DataBrowserItemID) itemArray[i];
1664
1665 verify_noerr( wxMacDataBrowserControl::AddItems( (DataBrowserItemID)container, noItems,
1666 (DataBrowserItemID*) items, kDataBrowserItemNoProperty ) );
1667 delete [] items;
1668 }
1669
1670 void wxMacDataItemBrowserControl::RemoveItem(wxMacDataItem *container, wxMacDataItem* item)
1671 {
1672 OSStatus err = wxMacDataBrowserControl::RemoveItems( (DataBrowserItemID)container, 1,
1673 (DataBrowserItemID*) &item, kDataBrowserItemNoProperty );
1674 verify_noerr( err );
1675 }
1676
1677 void wxMacDataItemBrowserControl::RemoveItems(wxMacDataItem *container, wxArrayMacDataItemPtr &itemArray)
1678 {
1679 unsigned int noItems = itemArray.GetCount();
1680 DataBrowserItemID *items = new DataBrowserItemID[noItems];
1681 for ( unsigned int i = 0; i < noItems; ++i )
1682 items[i] = (DataBrowserItemID) itemArray[i];
1683
1684 OSStatus err = wxMacDataBrowserControl::RemoveItems( (DataBrowserItemID)container, noItems,
1685 (DataBrowserItemID*) items, kDataBrowserItemNoProperty );
1686 verify_noerr( err );
1687 delete [] items;
1688 }
1689
1690 void wxMacDataItemBrowserControl::RemoveAllItems(wxMacDataItem *container)
1691 {
1692 OSStatus err = wxMacDataBrowserControl::RemoveItems( (DataBrowserItemID)container, 0 , NULL , kDataBrowserItemNoProperty );
1693 verify_noerr( err );
1694 }
1695
1696 void wxMacDataItemBrowserControl::SetSelectedItem(wxMacDataItem* item , DataBrowserSetOption option)
1697 {
1698 verify_noerr(wxMacDataBrowserControl::SetSelectedItems( 1, (DataBrowserItemID*) &item, option ));
1699 }
1700
1701 void wxMacDataItemBrowserControl::SetSelectedAllItems(DataBrowserSetOption option)
1702 {
1703 verify_noerr(wxMacDataBrowserControl::SetSelectedItems( 0 , NULL , option ));
1704 }
1705
1706 void wxMacDataItemBrowserControl::SetSelectedItems(wxArrayMacDataItemPtr &itemArray , DataBrowserSetOption option)
1707 {
1708 unsigned int noItems = itemArray.GetCount();
1709 DataBrowserItemID *items = new DataBrowserItemID[noItems];
1710 for ( unsigned int i = 0; i < noItems; ++i )
1711 items[i] = (DataBrowserItemID) itemArray[i];
1712
1713 verify_noerr(wxMacDataBrowserControl::SetSelectedItems( noItems, (DataBrowserItemID*) items, option ));
1714 delete [] items;
1715 }
1716
1717 Boolean wxMacDataItemBrowserControl::IsItemSelected( const wxMacDataItem* item) const
1718 {
1719 return wxMacDataBrowserControl::IsItemSelected( (DataBrowserItemID) item);
1720 }
1721
1722 void wxMacDataItemBrowserControl::RevealItem( wxMacDataItem* item, DataBrowserRevealOptions options)
1723 {
1724 verify_noerr(wxMacDataBrowserControl::RevealItem( (DataBrowserItemID) item, kDataBrowserNoItem , options ) );
1725 }
1726
1727 void wxMacDataItemBrowserControl::GetSelectionAnchor( wxMacDataItemPtr* first , wxMacDataItemPtr* last) const
1728 {
1729 verify_noerr(wxMacDataBrowserControl::GetSelectionAnchor( (DataBrowserItemID*) first, (DataBrowserItemID*) last) );
1730 }
1731
1732 wxClientDataType wxMacDataItemBrowserControl::GetClientDataType() const
1733 {
1734 return m_clientDataItemsType;
1735 }
1736 void wxMacDataItemBrowserControl::SetClientDataType(wxClientDataType clientDataItemsType)
1737 {
1738 m_clientDataItemsType = clientDataItemsType;
1739 }
1740
1741 unsigned int wxMacDataItemBrowserControl::MacGetCount() const
1742 {
1743 return GetItemCount(wxMacDataBrowserRootContainer,false,kDataBrowserItemAnyState);
1744 }
1745
1746 void wxMacDataItemBrowserControl::MacDelete( unsigned int n )
1747 {
1748 wxMacDataItem* item = (wxMacDataItem*)GetItemFromLine( n );
1749 RemoveItem( wxMacDataBrowserRootContainer, item );
1750 }
1751
1752 void wxMacDataItemBrowserControl::MacInsert( unsigned int n,
1753 const wxArrayStringsAdapter& items,
1754 int column )
1755 {
1756 size_t itemsCount = items.GetCount();
1757 if ( itemsCount == 0 )
1758 return;
1759
1760 SInt32 frontLineOrder = 0;
1761
1762 if ( m_sortOrder == SortOrder_None )
1763 {
1764 // increase the order of the lines to be shifted
1765 unsigned int lines = MacGetCount();
1766 for ( unsigned int i = n; i < lines; ++i)
1767 {
1768 wxMacDataItem* iter = (wxMacDataItem*) GetItemFromLine(i);
1769 iter->SetOrder( iter->GetOrder() + itemsCount );
1770 }
1771 if ( n > 0 )
1772 {
1773 wxMacDataItem* iter = (wxMacDataItem*) GetItemFromLine(n-1);
1774 frontLineOrder = iter->GetOrder();
1775 }
1776 }
1777
1778 wxArrayMacDataItemPtr ids;
1779 ids.SetCount( itemsCount );
1780
1781 for ( unsigned int i = 0; i < itemsCount; ++i )
1782 {
1783 wxMacDataItem* item = CreateItem();
1784 item->SetLabel( items[i]);
1785 if ( column != -1 )
1786 item->SetColumn( kMinColumnId + column );
1787
1788 if ( m_sortOrder == SortOrder_None )
1789 item->SetOrder( frontLineOrder + 1 + i );
1790
1791 ids[i] = item;
1792 }
1793
1794 AddItems( wxMacDataBrowserRootContainer, ids );
1795 }
1796
1797 int wxMacDataItemBrowserControl::MacAppend( const wxString& text)
1798 {
1799 wxMacDataItem* item = CreateItem();
1800 item->SetLabel( text );
1801 if ( m_sortOrder == SortOrder_None )
1802 {
1803 unsigned int lines = MacGetCount();
1804 if ( lines == 0 )
1805 item->SetOrder( 1 );
1806 else
1807 {
1808 wxMacDataItem* frontItem = (wxMacDataItem*) GetItemFromLine(lines-1);
1809 item->SetOrder( frontItem->GetOrder() + 1 );
1810 }
1811 }
1812 AddItem( wxMacDataBrowserRootContainer, item );
1813
1814 return GetLineFromItem(item);
1815 }
1816
1817 void wxMacDataItemBrowserControl::MacClear()
1818 {
1819 wxMacDataItemBrowserSelectionSuppressor suppressor(this);
1820 RemoveAllItems(wxMacDataBrowserRootContainer);
1821 }
1822
1823 void wxMacDataItemBrowserControl::MacDeselectAll()
1824 {
1825 wxMacDataItemBrowserSelectionSuppressor suppressor(this);
1826 SetSelectedAllItems( kDataBrowserItemsRemove );
1827 }
1828
1829 void wxMacDataItemBrowserControl::MacSetSelection( unsigned int n, bool select, bool multi )
1830 {
1831 wxMacDataItem* item = (wxMacDataItem*) GetItemFromLine(n);
1832 wxMacDataItemBrowserSelectionSuppressor suppressor(this);
1833
1834 if ( IsItemSelected( item ) != select )
1835 {
1836 if ( select )
1837 SetSelectedItem( item, multi ? kDataBrowserItemsAdd : kDataBrowserItemsAssign );
1838 else
1839 SetSelectedItem( item, kDataBrowserItemsRemove );
1840 }
1841
1842 MacScrollTo( n );
1843 }
1844
1845 bool wxMacDataItemBrowserControl::MacIsSelected( unsigned int n ) const
1846 {
1847 wxMacDataItem* item = (wxMacDataItem*) GetItemFromLine(n);
1848 return IsItemSelected( item );
1849 }
1850
1851 int wxMacDataItemBrowserControl::MacGetSelection() const
1852 {
1853 wxMacDataItemPtr first, last;
1854 GetSelectionAnchor( &first, &last );
1855
1856 if ( first != NULL )
1857 {
1858 return GetLineFromItem( first );
1859 }
1860
1861 return -1;
1862 }
1863
1864 int wxMacDataItemBrowserControl::MacGetSelections( wxArrayInt& aSelections ) const
1865 {
1866 aSelections.Empty();
1867 wxArrayMacDataItemPtr selectedItems;
1868 GetItems( wxMacDataBrowserRootContainer, false , kDataBrowserItemIsSelected, selectedItems);
1869
1870 int count = selectedItems.GetCount();
1871
1872 for ( int i = 0; i < count; ++i)
1873 {
1874 aSelections.Add(GetLineFromItem(selectedItems[i]));
1875 }
1876
1877 return count;
1878 }
1879
1880 void wxMacDataItemBrowserControl::MacSetString( unsigned int n, const wxString& text )
1881 {
1882 // as we don't store the strings we only have to issue a redraw
1883 wxMacDataItem* item = (wxMacDataItem*) GetItemFromLine( n);
1884 item->SetLabel( text );
1885 UpdateItem( wxMacDataBrowserRootContainer, item , kTextColumnId );
1886 }
1887
1888 wxString wxMacDataItemBrowserControl::MacGetString( unsigned int n ) const
1889 {
1890 wxMacDataItem * item = (wxMacDataItem*) GetItemFromLine( n );
1891 return item->GetLabel();
1892 }
1893
1894 void wxMacDataItemBrowserControl::MacSetClientData( unsigned int n, void * data)
1895 {
1896 wxMacDataItem* item = (wxMacDataItem*) GetItemFromLine( n);
1897 item->SetData( data );
1898 // not displayed, therefore no Update infos to DataBrowser
1899 }
1900
1901 void * wxMacDataItemBrowserControl::MacGetClientData( unsigned int n) const
1902 {
1903 wxMacDataItem * item = (wxMacDataItem*) GetItemFromLine( n );
1904 return item->GetData();
1905 }
1906
1907 void wxMacDataItemBrowserControl::MacScrollTo( unsigned int n )
1908 {
1909 UInt32 top , left ;
1910 GetScrollPosition( &top , &left ) ;
1911 wxMacDataItem * item = (wxMacDataItem*) GetItemFromLine( n );
1912
1913 // there is a bug in RevealItem that leads to situations
1914 // in large lists, where the item does not get scrolled
1915 // into sight, so we do a pre-scroll if necessary
1916 UInt16 height ;
1917 GetRowHeight( (DataBrowserItemID) item , &height ) ;
1918 UInt32 linetop = n * ((UInt32) height );
1919 UInt32 linebottom = linetop + height;
1920 Rect rect ;
1921 GetRect( &rect );
1922
1923 if ( linetop < top || linebottom > (top + rect.bottom - rect.top ) )
1924 SetScrollPosition( wxMax( n-2, 0 ) * ((UInt32)height) , left ) ;
1925
1926 RevealItem( item , kDataBrowserRevealWithoutSelecting );
1927 }
1928
1929
1930
1931 //
1932 // Tab Control
1933 //
1934
1935 OSStatus wxMacControl::SetTabEnabled( SInt16 tabNo , bool enable )
1936 {
1937 return ::SetTabEnabled( m_controlRef , tabNo , enable );
1938 }
1939
1940 #endif
1941
1942 //
1943 // Quartz Support
1944 //
1945
1946 /*
1947 Return the generic RGB color space. This is a 'get' function and the caller should
1948 not release the returned value unless the caller retains it first. Usually callers
1949 of this routine will immediately use the returned colorspace with CoreGraphics
1950 so they typically do not need to retain it themselves.
1951
1952 This function creates the generic RGB color space once and hangs onto it so it can
1953 return it whenever this function is called.
1954 */
1955
1956 CGColorSpaceRef wxMacGetGenericRGBColorSpace()
1957 {
1958 static wxCFRef<CGColorSpaceRef> genericRGBColorSpace;
1959
1960 if (genericRGBColorSpace == NULL)
1961 {
1962 genericRGBColorSpace.reset( CGColorSpaceCreateWithName( kCGColorSpaceGenericRGB ) );
1963 }
1964
1965 return genericRGBColorSpace;
1966 }
1967
1968 CGColorRef wxMacCreateCGColorFromHITheme( ThemeBrush brush )
1969 {
1970 CGColorRef color ;
1971 HIThemeBrushCreateCGColor( brush, &color );
1972 return color;
1973 }
1974
1975 #if wxMAC_USE_QUICKDRAW
1976
1977 static inline void PointFromHIPoint(const HIPoint& p, Point *pt)
1978 {
1979 pt->h = wx_static_cast(short, p.x);
1980 pt->v = wx_static_cast(short, p.y);
1981 }
1982
1983 void wxMacGlobalToLocal( WindowRef window , Point*pt )
1984 {
1985 HIPoint p = CGPointMake( pt->h, pt->v );
1986 HIViewRef contentView ;
1987 // TODO check toolbar offset
1988 HIViewFindByID( HIViewGetRoot( window ), kHIViewWindowContentID , &contentView) ;
1989 HIPointConvert( &p, kHICoordSpace72DPIGlobal, NULL, kHICoordSpaceView, contentView );
1990 PointFromHIPoint(p, pt);
1991 }
1992
1993 void wxMacLocalToGlobal( WindowRef window , Point*pt )
1994 {
1995 HIPoint p = CGPointMake( pt->h, pt->v );
1996 HIViewRef contentView ;
1997 // TODO check toolbar offset
1998 HIViewFindByID( HIViewGetRoot( window ), kHIViewWindowContentID , &contentView) ;
1999 HIPointConvert( &p, kHICoordSpaceView, contentView, kHICoordSpace72DPIGlobal, NULL );
2000 PointFromHIPoint(p, pt);
2001 }
2002
2003 #endif // wxMAC_USE_QUICKDRAW
2004
2005 #endif // wxUSE_GUI
2006
2007 #if wxUSE_BASE
2008
2009 #endif