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