1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/mac/carbon/utils.cpp
3 // Purpose: Various utilities
4 // Author: Stefan Csomor
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #include "wx/wxprec.h"
20 #include "wx/toplevel.h"
25 #include "wx/apptrait.h"
28 #include "wx/mac/uma.h"
38 #include "MoreFilesX.h"
46 #if TARGET_API_MAC_OSX
47 #include <CoreServices/CoreServices.h>
49 #include <DriverServices.h>
50 #include <Multiprocessing.h>
54 #include <Carbon/Carbon.h>
56 #include <ATSUnicode.h>
57 #include <TextCommon.h>
58 #include <TextEncodingConverter.h>
62 #include "wx/mac/private.h"
64 #if defined(__MWERKS__) && wxUSE_UNICODE
65 #if __MWERKS__ < 0x4100 || !defined(__DARWIN__)
72 // our OS version is the same in non GUI and GUI cases
73 wxOperatingSystemId
wxGetOsVersion(int *majorVsn
, int *minorVsn
)
76 Gestalt(gestaltSystemVersion
, &theSystem
);
78 if ( majorVsn
!= NULL
)
79 *majorVsn
= (theSystem
>> 8);
81 if ( minorVsn
!= NULL
)
82 *minorVsn
= (theSystem
& 0xFF);
84 #if defined( __DARWIN__ )
85 return wxOS_MAC_OSX_DARWIN
;
91 // ----------------------------------------------------------------------------
93 // ----------------------------------------------------------------------------
95 #if defined(__WXDEBUG__) && defined(__WXMAC__) && !defined(__DARWIN__) && defined(__MWERKS__) && (__MWERKS__ >= 0x2400)
97 // MetroNub stuff doesn't seem to work in CodeWarrior 5.3 Carbon builds...
99 #ifndef __MetroNubUtils__
100 #include "MetroNubUtils.h"
107 #if TARGET_API_MAC_CARBON
109 #include <CodeFragments.h>
111 extern "C" long CallUniversalProc(UniversalProcPtr theProcPtr
, ProcInfoType procInfo
, ...);
113 ProcPtr gCallUniversalProc_Proc
= NULL
;
117 static MetroNubUserEntryBlock
* gMetroNubEntry
= NULL
;
119 static long fRunOnce
= false;
122 Boolean
IsMetroNubInstalled()
129 gMetroNubEntry
= NULL
;
131 if (Gestalt(gestaltSystemVersion
, &value
) == noErr
&& value
< 0x1000)
133 // look for MetroNub's Gestalt selector
134 if (Gestalt(kMetroNubUserSignature
, &result
) == noErr
)
136 #if TARGET_API_MAC_CARBON
137 if (gCallUniversalProc_Proc
== NULL
)
139 CFragConnectionID connectionID
;
142 ProcPtr symbolAddress
;
144 CFragSymbolClass symbolClass
;
146 symbolAddress
= NULL
;
147 err
= GetSharedLibrary("\pInterfaceLib", kPowerPCCFragArch
, kFindCFrag
,
148 &connectionID
, &mainAddress
, errorString
);
152 gCallUniversalProc_Proc
= NULL
;
156 err
= FindSymbol(connectionID
, "\pCallUniversalProc",
157 (Ptr
*) &gCallUniversalProc_Proc
, &symbolClass
);
161 gCallUniversalProc_Proc
= NULL
;
168 MetroNubUserEntryBlock
* block
= (MetroNubUserEntryBlock
*)result
;
170 // make sure the version of the API is compatible
171 if (block
->apiLowVersion
<= kMetroNubUserAPIVersion
&&
172 kMetroNubUserAPIVersion
<= block
->apiHiVersion
)
175 gMetroNubEntry
= block
;
184 #if TARGET_API_MAC_CARBON
185 return (gMetroNubEntry
!= NULL
&& gCallUniversalProc_Proc
!= NULL
);
187 return (gMetroNubEntry
!= NULL
);
191 Boolean
IsMWDebuggerRunning()
193 if (IsMetroNubInstalled())
194 return CallIsDebuggerRunningProc(gMetroNubEntry
->isDebuggerRunning
);
199 Boolean
AmIBeingMWDebugged()
201 if (IsMetroNubInstalled())
202 return CallAmIBeingDebuggedProc(gMetroNubEntry
->amIBeingDebugged
);
207 extern bool WXDLLEXPORT
wxIsDebuggerRunning()
209 return IsMWDebuggerRunning() && AmIBeingMWDebugged();
214 extern bool WXDLLEXPORT
wxIsDebuggerRunning()
219 #endif // defined(__WXMAC__) && !defined(__DARWIN__) && (__MWERKS__ >= 0x2400)
223 // defined in unix/utilsunx.cpp for Mac OS X
225 // get full hostname (with domain name if possible)
226 bool wxGetFullHostName(wxChar
*buf
, int maxSize
)
228 return wxGetHostName(buf
, maxSize
);
231 // Get user ID e.g. jacs
232 bool wxGetUserId(wxChar
*buf
, int maxSize
)
234 return wxGetUserName( buf
, maxSize
);
237 const wxChar
* wxGetHomeDir(wxString
*pstr
)
239 *pstr
= wxMacFindFolder( (short) kOnSystemDisk
, kPreferencesFolderType
, kDontCreateFolder
);
240 return pstr
->c_str();
243 // Get hostname only (without domain name)
244 bool wxGetHostName(wxChar
*buf
, int maxSize
)
246 // Gets Chooser name of user by examining a System resource.
249 const short kComputerNameID
= -16413;
251 short oldResFile
= CurResFile();
253 StringHandle chooserName
= (StringHandle
)::GetString(kComputerNameID
);
254 UseResFile(oldResFile
);
256 if (chooserName
&& *chooserName
)
258 HLock( (Handle
) chooserName
);
259 wxString name
= wxMacMakeStringFromPascal( *chooserName
);
260 HUnlock( (Handle
) chooserName
);
261 ReleaseResource( (Handle
) chooserName
);
262 wxStrncpy( buf
, name
, maxSize
- 1 );
268 // Get user name e.g. Stefan Csomor
269 bool wxGetUserName(wxChar
*buf
, int maxSize
)
271 // Gets Chooser name of user by examining a System resource.
274 const short kChooserNameID
= -16096;
276 short oldResFile
= CurResFile();
278 StringHandle chooserName
= (StringHandle
)::GetString(kChooserNameID
);
279 UseResFile(oldResFile
);
281 if (chooserName
&& *chooserName
)
283 HLock( (Handle
) chooserName
);
284 wxString name
= wxMacMakeStringFromPascal( *chooserName
);
285 HUnlock( (Handle
) chooserName
);
286 ReleaseResource( (Handle
) chooserName
);
287 wxStrncpy( buf
, name
, maxSize
- 1 );
293 int wxKill(long pid
, wxSignal sig
, wxKillError
*rc
, int flags
)
299 WXDLLEXPORT
bool wxGetEnv(const wxString
& var
, wxString
*value
)
301 // TODO : under classic there is no environement support, under X yes
305 // set the env var name to the given value, return true on success
306 WXDLLEXPORT
bool wxSetEnv(const wxString
& var
, const wxChar
*value
)
308 // TODO : under classic there is no environement support, under X yes
312 // Execute a program in an Interactive Shell
313 bool wxShell(const wxString
& command
)
319 // Shutdown or reboot the PC
320 bool wxShutdown(wxShutdownFlags wFlags
)
326 // Get free memory in bytes, or -1 if cannot determine amount (e.g. on UNIX)
327 wxMemorySize
wxGetFreeMemory()
329 return (wxMemorySize
)FreeMem();
334 void wxMicroSleep(unsigned long microseconds
)
336 AbsoluteTime wakeup
= AddDurationToAbsolute( microseconds
* durationMicrosecond
, UpTime());
337 MPDelayUntil( & wakeup
);
340 void wxMilliSleep(unsigned long milliseconds
)
342 AbsoluteTime wakeup
= AddDurationToAbsolute( milliseconds
, UpTime());
343 MPDelayUntil( & wakeup
);
346 void wxSleep(int nSecs
)
348 wxMilliSleep(1000*nSecs
);
353 // Consume all events until no more left
358 #endif // !__DARWIN__
373 wxPortId
wxGUIAppTraits::GetToolkitVersion(int *verMaj
, int *verMin
) const
375 // We suppose that toolkit version is the same as OS version under Mac
376 wxGetOsVersion(verMaj
, verMin
);
381 // Reading and writing resources (eg WIN.INI, .Xdefaults)
383 bool wxWriteResource(const wxString
& section
, const wxString
& entry
, const wxString
& value
, const wxString
& file
)
389 bool wxWriteResource(const wxString
& section
, const wxString
& entry
, float value
, const wxString
& file
)
392 buf
.Printf(wxT("%.4f"), value
);
394 return wxWriteResource(section
, entry
, buf
, file
);
397 bool wxWriteResource(const wxString
& section
, const wxString
& entry
, long value
, const wxString
& file
)
400 buf
.Printf(wxT("%ld"), value
);
402 return wxWriteResource(section
, entry
, buf
, file
);
405 bool wxWriteResource(const wxString
& section
, const wxString
& entry
, int value
, const wxString
& file
)
408 buf
.Printf(wxT("%d"), value
);
410 return wxWriteResource(section
, entry
, buf
, file
);
413 bool wxGetResource(const wxString
& section
, const wxString
& entry
, char **value
, const wxString
& file
)
419 bool wxGetResource(const wxString
& section
, const wxString
& entry
, float *value
, const wxString
& file
)
422 bool succ
= wxGetResource(section
, entry
, (char **)&s
, file
);
425 *value
= (float)strtod(s
, NULL
);
432 bool wxGetResource(const wxString
& section
, const wxString
& entry
, long *value
, const wxString
& file
)
435 bool succ
= wxGetResource(section
, entry
, (char **)&s
, file
);
438 *value
= strtol(s
, NULL
, 10);
445 bool wxGetResource(const wxString
& section
, const wxString
& entry
, int *value
, const wxString
& file
)
448 bool succ
= wxGetResource(section
, entry
, (char **)&s
, file
);
451 *value
= (int)strtol(s
, NULL
, 10);
457 #endif // wxUSE_RESOURCES
459 int gs_wxBusyCursorCount
= 0;
460 extern wxCursor gMacCurrentCursor
;
461 wxCursor gMacStoredActiveCursor
;
463 // Set the cursor to the busy cursor for all windows
464 void wxBeginBusyCursor(const wxCursor
*cursor
)
466 if (gs_wxBusyCursorCount
++ == 0)
468 gMacStoredActiveCursor
= gMacCurrentCursor
;
469 cursor
->MacInstall();
471 //else: nothing to do, already set
474 // Restore cursor to normal
475 void wxEndBusyCursor()
477 wxCHECK_RET( gs_wxBusyCursorCount
> 0,
478 wxT("no matching wxBeginBusyCursor() for wxEndBusyCursor()") );
480 if (--gs_wxBusyCursorCount
== 0)
482 gMacStoredActiveCursor
.MacInstall();
483 gMacStoredActiveCursor
= wxNullCursor
;
487 // true if we're between the above two calls
490 return (gs_wxBusyCursorCount
> 0);
497 wxString
wxMacFindFolderNoSeparator( short vol
,
499 Boolean createFolder
)
504 if ( FSFindFolder( vol
, folderType
, createFolder
, &fsRef
) == noErr
)
506 strDir
= wxMacFSRefToPath( &fsRef
);
512 wxString
wxMacFindFolder( short vol
,
514 Boolean createFolder
)
516 return wxMacFindFolderNoSeparator(vol
, folderType
, createFolder
) + wxFILE_SEP_PATH
;
523 // Check whether this window wants to process messages, e.g. Stop button
524 // in long calculations.
525 bool wxCheckForInterrupt(wxWindow
*wnd
)
531 void wxGetMousePosition( int* x
, int* y
)
534 #if wxMAC_USE_CORE_GRAPHICS
538 LocalToGlobal( &pt
);
544 // Return true if we have a colour display
545 bool wxColourDisplay()
550 // Returns depth of screen
554 #if wxMAC_USE_CORE_GRAPHICS
555 theDepth
= (int) CGDisplayBitsPerPixel(CGMainDisplayID());
558 SetRect(&globRect
, -32760, -32760, 32760, 32760);
559 GDHandle theMaxDevice
;
561 theMaxDevice
= GetMaxDevice(&globRect
);
562 if (theMaxDevice
!= NULL
)
563 theDepth
= (**(**theMaxDevice
).gdPMap
).pixelSize
;
568 // Get size of display
569 void wxDisplaySize(int *width
, int *height
)
571 #if wxMAC_USE_CORE_GRAPHICS
572 // TODO adapt for multi-displays
573 CGRect bounds
= CGDisplayBounds(CGMainDisplayID());
575 *width
= (int)bounds
.size
.width
;
577 *height
= (int)bounds
.size
.height
;
580 GetQDGlobalsScreenBits( &screenBits
);
583 *width
= screenBits
.bounds
.right
- screenBits
.bounds
.left
;
586 *height
= screenBits
.bounds
.bottom
- screenBits
.bounds
.top
;
590 void wxDisplaySizeMM(int *width
, int *height
)
592 wxDisplaySize(width
, height
);
593 // on mac 72 is fixed (at least now;-)
594 float cvPt2Mm
= 25.4 / 72;
597 *width
= int( *width
* cvPt2Mm
);
600 *height
= int( *height
* cvPt2Mm
);
603 void wxClientDisplayRect(int *x
, int *y
, int *width
, int *height
)
605 #if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5
607 HIWindowGetAvailablePositioningBounds(kCGNullDirectDisplay
,kHICoordSpace72DPIGlobal
,
610 *x
= bounds
.origin
.x
;
612 *y
= bounds
.origin
.y
;
614 *width
= bounds
.size
.width
;
616 *height
= bounds
.size
.height
;
619 GetAvailableWindowPositioningBounds( GetMainDevice() , &r
);
625 *width
= r
.right
- r
.left
;
627 *height
= r
.bottom
- r
.top
;
631 wxWindow
* wxFindWindowAtPoint(const wxPoint
& pt
)
633 return wxGenericFindWindowAtPoint(pt
);
640 wxString
wxGetOsDescription()
642 #ifdef WXWIN_OS_DESCRIPTION
643 // use configure generated description if available
644 return wxString(wxT("MacOS (")) + wxT(WXWIN_OS_DESCRIPTION
) + wxString(wxT(")"));
646 return wxT("MacOS"); //TODO:define further
651 wxChar
*wxGetUserHome (const wxString
& user
)
657 bool wxGetDiskSpace(const wxString
& path
, wxDiskspaceSize_t
*pTotal
, wxDiskspaceSize_t
*pFree
)
666 int pos
= p
.Find(':');
667 if ( pos
!= wxNOT_FOUND
)
675 err
= wxMacPathToFSRef( p
, &fsRef
);
678 FSVolumeRefNum vRefNum
;
679 err
= FSGetVRefNum( &fsRef
, &vRefNum
);
682 UInt64 freeBytes
, totalBytes
;
683 err
= FSGetVInfo( vRefNum
, NULL
, &freeBytes
, &totalBytes
);
687 *pTotal
= wxDiskspaceSize_t( totalBytes
);
689 *pFree
= wxDiskspaceSize_t( freeBytes
);
696 #endif // !__DARWIN__
698 //---------------------------------------------------------------------------
699 // wxMac Specific utility functions
700 //---------------------------------------------------------------------------
702 void wxMacStringToPascal( const wxString
&from
, StringPtr to
)
704 wxCharBuffer buf
= from
.mb_str( wxConvLocal
);
705 int len
= strlen(buf
);
710 memcpy( (char*) &to
[1] , buf
, len
);
713 wxString
wxMacMakeStringFromPascal( ConstStringPtr from
)
715 return wxString( (char*) &from
[1] , wxConvLocal
, from
[0] );
718 // ----------------------------------------------------------------------------
719 // Common Event Support
720 // ----------------------------------------------------------------------------
722 extern ProcessSerialNumber gAppProcess
;
726 ProcessSerialNumber psn
;
728 psn
.highLongOfPSN
= 0;
729 psn
.lowLongOfPSN
= kCurrentProcess
;
730 SameProcess( &gAppProcess
, &psn
, &isSame
);
734 OSStatus err
= noErr
;
737 // lead sometimes to race conditions, although all calls used should be thread safe ...
738 static wxMacCarbonEvent s_wakeupEvent
;
739 if ( !s_wakeupEvent
.IsValid() )
741 err
= s_wakeupEvent
.Create( 'WXMC', 'WXMC', GetCurrentEventTime(),
742 kEventAttributeNone
);
747 if ( IsEventInQueue( GetMainEventQueue() , s_wakeupEvent
) )
749 s_wakeupEvent
.SetCurrentTime();
750 err
= PostEventToQueue(GetMainEventQueue(), s_wakeupEvent
,
751 kEventPriorityHigh
);
754 wxMacCarbonEvent wakeupEvent
;
755 wakeupEvent
.Create( 'WXMC', 'WXMC', GetCurrentEventTime(),
756 kEventAttributeNone
);
757 err
= PostEventToQueue(GetMainEventQueue(), wakeupEvent
,
758 kEventPriorityHigh
);
761 PostEvent( nullEvent
, 0 );
766 WakeUpProcess( &gAppProcess
);
774 // ----------------------------------------------------------------------------
775 // Native Struct Conversions
776 // ----------------------------------------------------------------------------
778 void wxMacRectToNative( const wxRect
*wx
, Rect
*n
)
782 n
->right
= wx
->x
+ wx
->width
;
783 n
->bottom
= wx
->y
+ wx
->height
;
786 void wxMacNativeToRect( const Rect
*n
, wxRect
* wx
)
790 wx
->width
= n
->right
- n
->left
;
791 wx
->height
= n
->bottom
- n
->top
;
794 void wxMacPointToNative( const wxPoint
* wx
, Point
*n
)
800 void wxMacNativeToPoint( const Point
*n
, wxPoint
* wx
)
806 // ----------------------------------------------------------------------------
807 // Carbon Event Support
808 // ----------------------------------------------------------------------------
810 OSStatus
wxMacCarbonEvent::GetParameter(EventParamName inName
, EventParamType inDesiredType
, UInt32 inBufferSize
, void * outData
)
812 return ::GetEventParameter( m_eventRef
, inName
, inDesiredType
, NULL
, inBufferSize
, NULL
, outData
);
815 OSStatus
wxMacCarbonEvent::SetParameter(EventParamName inName
, EventParamType inType
, UInt32 inBufferSize
, const void * inData
)
817 return ::SetEventParameter( m_eventRef
, inName
, inType
, inBufferSize
, inData
);
820 // ----------------------------------------------------------------------------
821 // Control Access Support
822 // ----------------------------------------------------------------------------
824 IMPLEMENT_DYNAMIC_CLASS( wxMacControl
, wxObject
)
826 wxMacControl::wxMacControl()
831 wxMacControl::wxMacControl(wxWindow
* peer
, bool isRootControl
)
835 m_isRootControl
= isRootControl
;
838 wxMacControl::wxMacControl( wxWindow
* peer
, ControlRef control
)
842 m_controlRef
= control
;
845 wxMacControl::wxMacControl( wxWindow
* peer
, WXWidget control
)
849 m_controlRef
= (ControlRef
) control
;
852 wxMacControl::~wxMacControl()
856 void wxMacControl::Init()
860 m_needsFocusRect
= false;
861 m_isRootControl
= false;
864 void wxMacControl::Dispose()
866 wxASSERT_MSG( m_controlRef
!= NULL
, wxT("Control Handle already NULL, Dispose called twice ?") );
867 wxASSERT_MSG( IsValidControlHandle(m_controlRef
) , wxT("Invalid Control Handle (maybe already released) in Dispose") );
869 // we cannot check the ref count here anymore, as autorelease objects might delete their refs later
870 CFRelease(m_controlRef
);
874 void wxMacControl::SetReference( URefCon data
)
876 SetControlReference( m_controlRef
, data
);
879 OSStatus
wxMacControl::GetData(ControlPartCode inPartCode
, ResType inTag
, Size inBufferSize
, void * inOutBuffer
, Size
* outActualSize
) const
881 return ::GetControlData( m_controlRef
, inPartCode
, inTag
, inBufferSize
, inOutBuffer
, outActualSize
);
884 OSStatus
wxMacControl::GetDataSize(ControlPartCode inPartCode
, ResType inTag
, Size
* outActualSize
) const
886 return ::GetControlDataSize( m_controlRef
, inPartCode
, inTag
, outActualSize
);
889 OSStatus
wxMacControl::SetData(ControlPartCode inPartCode
, ResType inTag
, Size inSize
, const void * inData
)
891 return ::SetControlData( m_controlRef
, inPartCode
, inTag
, inSize
, inData
);
894 OSStatus
wxMacControl::SendEvent( EventRef event
, OptionBits inOptions
)
896 #if TARGET_API_MAC_OSX
897 return SendEventToEventTargetWithOptions( event
,
898 HIObjectGetEventTarget( (HIObjectRef
) m_controlRef
), inOptions
);
900 #pragma unused(inOptions)
901 return SendEventToEventTarget(event
,GetControlEventTarget( m_controlRef
) );
905 OSStatus
wxMacControl::SendHICommand( HICommand
&command
, OptionBits inOptions
)
907 wxMacCarbonEvent
event( kEventClassCommand
, kEventCommandProcess
);
909 event
.SetParameter
<HICommand
>(kEventParamDirectObject
,command
);
911 return SendEvent( event
, inOptions
);
914 OSStatus
wxMacControl::SendHICommand( UInt32 commandID
, OptionBits inOptions
)
918 memset( &command
, 0 , sizeof(command
) );
919 command
.commandID
= commandID
;
920 return SendHICommand( command
, inOptions
);
923 void wxMacControl::Flash( ControlPartCode part
, UInt32 ticks
)
925 unsigned long finalTicks
;
927 HiliteControl( m_controlRef
, part
);
928 Delay( ticks
, &finalTicks
);
929 HiliteControl( m_controlRef
, kControlNoPart
);
932 SInt32
wxMacControl::GetValue() const
934 return ::GetControl32BitValue( m_controlRef
);
937 SInt32
wxMacControl::GetMaximum() const
939 return ::GetControl32BitMaximum( m_controlRef
);
942 SInt32
wxMacControl::GetMinimum() const
944 return ::GetControl32BitMinimum( m_controlRef
);
947 void wxMacControl::SetValue( SInt32 v
)
949 ::SetControl32BitValue( m_controlRef
, v
);
952 void wxMacControl::SetMinimum( SInt32 v
)
954 ::SetControl32BitMinimum( m_controlRef
, v
);
957 void wxMacControl::SetMaximum( SInt32 v
)
959 ::SetControl32BitMaximum( m_controlRef
, v
);
962 void wxMacControl::SetValueAndRange( SInt32 value
, SInt32 minimum
, SInt32 maximum
)
964 ::SetControl32BitMinimum( m_controlRef
, minimum
);
965 ::SetControl32BitMaximum( m_controlRef
, maximum
);
966 ::SetControl32BitValue( m_controlRef
, value
);
969 OSStatus
wxMacControl::SetFocus( ControlFocusPart focusPart
)
971 return SetKeyboardFocus( GetControlOwner( m_controlRef
), m_controlRef
, focusPart
);
974 bool wxMacControl::HasFocus() const
977 GetKeyboardFocus( GetUserFocusWindow() , &control
);
978 return control
== m_controlRef
;
981 void wxMacControl::SetNeedsFocusRect( bool needs
)
983 m_needsFocusRect
= needs
;
986 bool wxMacControl::NeedsFocusRect() const
988 return m_needsFocusRect
;
991 void wxMacControl::VisibilityChanged(bool shown
)
995 void wxMacControl::SuperChangedPosition()
999 void wxMacControl::SetFont( const wxFont
& font
, const wxColour
& foreground
, long windowStyle
)
1002 ControlFontStyleRec fontStyle
;
1003 if ( font
.MacGetThemeFontID() != kThemeCurrentPortFont
)
1005 switch ( font
.MacGetThemeFontID() )
1007 case kThemeSmallSystemFont
:
1008 fontStyle
.font
= kControlFontSmallSystemFont
;
1011 case 109 : // mini font
1012 fontStyle
.font
= -5;
1015 case kThemeSystemFont
:
1016 fontStyle
.font
= kControlFontBigSystemFont
;
1020 fontStyle
.font
= kControlFontBigSystemFont
;
1024 fontStyle
.flags
= kControlUseFontMask
;
1028 fontStyle
.font
= font
.MacGetFontNum();
1029 fontStyle
.style
= font
.MacGetFontStyle();
1030 fontStyle
.size
= font
.MacGetFontSize();
1031 fontStyle
.flags
= kControlUseFontMask
| kControlUseFaceMask
| kControlUseSizeMask
;
1034 fontStyle
.just
= teJustLeft
;
1035 fontStyle
.flags
|= kControlUseJustMask
;
1036 if ( ( windowStyle
& wxALIGN_MASK
) & wxALIGN_CENTER_HORIZONTAL
)
1037 fontStyle
.just
= teJustCenter
;
1038 else if ( ( windowStyle
& wxALIGN_MASK
) & wxALIGN_RIGHT
)
1039 fontStyle
.just
= teJustRight
;
1042 // we only should do this in case of a non-standard color, as otherwise 'disabled' controls
1043 // won't get grayed out by the system anymore
1045 if ( foreground
!= *wxBLACK
)
1047 fontStyle
.foreColor
= MAC_WXCOLORREF( foreground
.GetPixel() );
1048 fontStyle
.flags
|= kControlUseForeColorMask
;
1051 ::SetControlFontStyle( m_controlRef
, &fontStyle
);
1054 void wxMacControl::SetBackground( const wxBrush
&WXUNUSED(brush
) )
1057 // setting up a color proc is not recommended anymore
1060 void wxMacControl::SetRange( SInt32 minimum
, SInt32 maximum
)
1062 ::SetControl32BitMinimum( m_controlRef
, minimum
);
1063 ::SetControl32BitMaximum( m_controlRef
, maximum
);
1066 short wxMacControl::HandleKey( SInt16 keyCode
, SInt16 charCode
, EventModifiers modifiers
)
1069 return HandleControlKey( m_controlRef
, keyCode
, charCode
, modifiers
);
1075 void wxMacControl::SetActionProc( ControlActionUPP actionProc
)
1077 SetControlAction( m_controlRef
, actionProc
);
1080 void wxMacControl::SetViewSize( SInt32 viewSize
)
1082 SetControlViewSize(m_controlRef
, viewSize
);
1085 SInt32
wxMacControl::GetViewSize() const
1087 return GetControlViewSize( m_controlRef
);
1090 bool wxMacControl::IsVisible() const
1092 return IsControlVisible( m_controlRef
);
1095 void wxMacControl::SetVisibility( bool visible
, bool redraw
)
1097 SetControlVisibility( m_controlRef
, visible
, redraw
);
1100 bool wxMacControl::IsEnabled() const
1102 #if TARGET_API_MAC_OSX
1103 return IsControlEnabled( m_controlRef
);
1105 return IsControlActive( m_controlRef
);
1109 bool wxMacControl::IsActive() const
1111 return IsControlActive( m_controlRef
);
1114 void wxMacControl::Enable( bool enable
)
1117 EnableControl( m_controlRef
);
1119 DisableControl( m_controlRef
);
1122 void wxMacControl::SetDrawingEnabled( bool enable
)
1124 HIViewSetDrawingEnabled( m_controlRef
, enable
);
1127 bool wxMacControl::GetNeedsDisplay() const
1129 return HIViewGetNeedsDisplay( m_controlRef
);
1132 void wxMacControl::SetNeedsDisplay( RgnHandle where
)
1137 HIViewSetNeedsDisplayInRegion( m_controlRef
, where
, true );
1140 void wxMacControl::SetNeedsDisplay( Rect
* where
)
1145 if ( where
!= NULL
)
1147 RgnHandle update
= NewRgn();
1148 RectRgn( update
, where
);
1149 HIViewSetNeedsDisplayInRegion( m_controlRef
, update
, true );
1150 DisposeRgn( update
);
1153 HIViewSetNeedsDisplay( m_controlRef
, true );
1156 void wxMacControl::Convert( wxPoint
*pt
, wxMacControl
*from
, wxMacControl
*to
)
1162 HIViewConvertPoint( &hiPoint
, from
->m_controlRef
, to
->m_controlRef
);
1163 pt
->x
= (int)hiPoint
.x
;
1164 pt
->y
= (int)hiPoint
.y
;
1167 void wxMacControl::SetRect( Rect
*r
)
1169 //A HIRect is actually a CGRect on OSX - which consists of two structures -
1170 //CGPoint and CGSize, which have two floats each
1171 HIRect hir
= { { r
->left
, r
->top
}, { r
->right
- r
->left
, r
->bottom
- r
->top
} };
1172 HIViewSetFrame ( m_controlRef
, &hir
);
1173 // eventuall we might have to do a SetVisibility( false , true );
1174 // before and a SetVisibility( true , true ); after
1177 void wxMacControl::GetRect( Rect
*r
)
1179 GetControlBounds( m_controlRef
, r
);
1182 void wxMacControl::GetRectInWindowCoords( Rect
*r
)
1184 UMAGetControlBoundsInWindowCoords( m_controlRef
, r
);
1187 void wxMacControl::GetBestRect( Rect
*r
)
1189 short baselineoffset
;
1191 GetBestControlRect( m_controlRef
, r
, &baselineoffset
);
1194 void wxMacControl::SetLabel( const wxString
&title
)
1196 wxFontEncoding encoding
;
1199 encoding
= m_font
.GetEncoding();
1201 encoding
= wxFont::GetDefaultEncoding();
1203 UMASetControlTitle( m_controlRef
, title
, encoding
);
1206 void wxMacControl::GetFeatures( UInt32
* features
)
1208 GetControlFeatures( m_controlRef
, features
);
1211 OSStatus
wxMacControl::GetRegion( ControlPartCode partCode
, RgnHandle region
)
1213 OSStatus err
= GetControlRegion( m_controlRef
, partCode
, region
);
1217 OSStatus
wxMacControl::SetZOrder( bool above
, wxMacControl
* other
)
1219 #if TARGET_API_MAC_OSX
1220 return HIViewSetZOrder( m_controlRef
,above
? kHIViewZOrderAbove
: kHIViewZOrderBelow
,
1221 (other
!= NULL
) ? other
->m_controlRef
: NULL
);
1227 #if TARGET_API_MAC_OSX
1228 // SetNeedsDisplay would not invalidate the children
1229 static void InvalidateControlAndChildren( HIViewRef control
)
1231 HIViewSetNeedsDisplay( control
, true );
1232 UInt16 childrenCount
= 0;
1233 OSStatus err
= CountSubControls( control
, &childrenCount
);
1234 if ( err
== errControlIsNotEmbedder
)
1237 wxASSERT_MSG( err
== noErr
, wxT("Unexpected error when accessing subcontrols") );
1239 for ( UInt16 i
= childrenCount
; i
>=1; --i
)
1243 err
= GetIndexedSubControl( control
, i
, & child
);
1244 if ( err
== errControlIsNotEmbedder
)
1247 InvalidateControlAndChildren( child
);
1252 void wxMacControl::InvalidateWithChildren()
1254 #if TARGET_API_MAC_OSX
1255 InvalidateControlAndChildren( m_controlRef
);
1259 void wxMacControl::ScrollRect( wxRect
*r
, int dx
, int dy
)
1261 wxASSERT( r
!= NULL
);
1263 HIRect scrollarea
= CGRectMake( r
->x
, r
->y
, r
->width
, r
->height
);
1264 HIViewScrollRect ( m_controlRef
, &scrollarea
, dx
,dy
);
1267 OSType wxMacCreator
= 'WXMC';
1268 OSType wxMacControlProperty
= 'MCCT';
1270 void wxMacControl::SetReferenceInNativeControl()
1273 verify_noerr( SetControlProperty ( m_controlRef
,
1274 wxMacCreator
,wxMacControlProperty
, sizeof(data
), &data
) );
1277 wxMacControl
* wxMacControl::GetReferenceFromNativeControl(ControlRef control
)
1279 wxMacControl
* ctl
= NULL
;
1280 ByteCount actualSize
;
1281 if ( GetControlProperty( control
,wxMacCreator
,wxMacControlProperty
, sizeof(ctl
) ,
1282 &actualSize
, &ctl
) == noErr
)
1289 // ============================================================================
1290 // DataBrowser Wrapper
1291 // ============================================================================
1293 // basing on DataBrowserItemIDs
1296 IMPLEMENT_ABSTRACT_CLASS( wxMacDataBrowserControl
, wxMacControl
)
1298 pascal void wxMacDataBrowserControl::DataBrowserItemNotificationProc(
1300 DataBrowserItemID itemID
,
1301 DataBrowserItemNotification message
,
1302 DataBrowserItemDataRef itemData
)
1304 wxMacDataBrowserControl
* ctl
= wxDynamicCast(wxMacControl::GetReferenceFromNativeControl( browser
), wxMacDataBrowserControl
);
1307 ctl
->ItemNotification(itemID
, message
, itemData
);
1311 pascal OSStatus
wxMacDataBrowserControl::DataBrowserGetSetItemDataProc(
1313 DataBrowserItemID itemID
,
1314 DataBrowserPropertyID property
,
1315 DataBrowserItemDataRef itemData
,
1316 Boolean changeValue
)
1318 OSStatus err
= errDataBrowserPropertyNotSupported
;
1319 wxMacDataBrowserControl
* ctl
= wxDynamicCast(wxMacControl::GetReferenceFromNativeControl( browser
), wxMacDataBrowserControl
);
1322 err
= ctl
->GetSetItemData(itemID
, property
, itemData
, changeValue
);
1327 pascal Boolean
wxMacDataBrowserControl::DataBrowserCompareProc(
1329 DataBrowserItemID itemOneID
,
1330 DataBrowserItemID itemTwoID
,
1331 DataBrowserPropertyID sortProperty
)
1333 wxMacDataBrowserControl
* ctl
= wxDynamicCast(wxMacControl::GetReferenceFromNativeControl( browser
), wxMacDataBrowserControl
);
1336 return ctl
->CompareItems(itemOneID
, itemTwoID
, sortProperty
);
1341 DataBrowserItemDataUPP gDataBrowserItemDataUPP
= NULL
;
1342 DataBrowserItemNotificationUPP gDataBrowserItemNotificationUPP
= NULL
;
1343 DataBrowserItemCompareUPP gDataBrowserItemCompareUPP
= NULL
;
1345 wxMacDataBrowserControl::wxMacDataBrowserControl( wxWindow
* peer
, const wxPoint
& pos
, const wxSize
& size
, long style
) : wxMacControl( peer
)
1347 Rect bounds
= wxMacGetBoundsForControl( peer
, pos
, size
);
1348 OSStatus err
= ::CreateDataBrowserControl(
1349 MAC_WXHWND(peer
->MacGetTopLevelWindowRef()),
1350 &bounds
, kDataBrowserListView
, &m_controlRef
);
1351 SetReferenceInNativeControl();
1352 verify_noerr( err
);
1353 if ( gDataBrowserItemCompareUPP
== NULL
)
1354 gDataBrowserItemCompareUPP
= NewDataBrowserItemCompareUPP(DataBrowserCompareProc
);
1355 if ( gDataBrowserItemDataUPP
== NULL
)
1356 gDataBrowserItemDataUPP
= NewDataBrowserItemDataUPP(DataBrowserGetSetItemDataProc
);
1357 if ( gDataBrowserItemNotificationUPP
== NULL
)
1359 gDataBrowserItemNotificationUPP
=
1360 #if TARGET_API_MAC_OSX
1361 (DataBrowserItemNotificationUPP
) NewDataBrowserItemNotificationWithItemUPP(DataBrowserItemNotificationProc
);
1363 NewDataBrowserItemNotificationUPP(DataBrowserItemNotificationProc
);
1367 DataBrowserCallbacks callbacks
;
1368 InitializeDataBrowserCallbacks( &callbacks
, kDataBrowserLatestCallbacks
);
1370 callbacks
.u
.v1
.itemDataCallback
= gDataBrowserItemDataUPP
;
1371 callbacks
.u
.v1
.itemCompareCallback
= gDataBrowserItemCompareUPP
;
1372 callbacks
.u
.v1
.itemNotificationCallback
= gDataBrowserItemNotificationUPP
;
1373 SetCallbacks( &callbacks
);
1377 OSStatus
wxMacDataBrowserControl::GetItemCount( DataBrowserItemID container
,
1379 DataBrowserItemState state
,
1380 ItemCount
*numItems
) const
1382 return GetDataBrowserItemCount( m_controlRef
, container
, recurse
, state
, numItems
);
1385 OSStatus
wxMacDataBrowserControl::GetItems( DataBrowserItemID container
,
1387 DataBrowserItemState state
,
1390 return GetDataBrowserItems( m_controlRef
, container
, recurse
, state
, items
);
1393 OSStatus
wxMacDataBrowserControl::SetSelectionFlags( DataBrowserSelectionFlags options
)
1395 return SetDataBrowserSelectionFlags( m_controlRef
, options
);
1398 OSStatus
wxMacDataBrowserControl::AddColumn( DataBrowserListViewColumnDesc
*columnDesc
,
1399 DataBrowserTableViewColumnIndex position
)
1401 return AddDataBrowserListViewColumn( m_controlRef
, columnDesc
, position
);
1404 OSStatus
wxMacDataBrowserControl::GetColumnIDFromIndex( DataBrowserTableViewColumnIndex position
, DataBrowserTableViewColumnID
* id
){
1405 return GetDataBrowserTableViewColumnProperty( m_controlRef
, position
, id
);
1408 OSStatus
wxMacDataBrowserControl::RemoveColumn( DataBrowserTableViewColumnIndex position
)
1410 DataBrowserTableViewColumnID id
;
1411 GetColumnIDFromIndex( position
, &id
);
1412 return RemoveDataBrowserTableViewColumn( m_controlRef
, id
);
1415 OSStatus
wxMacDataBrowserControl::AutoSizeColumns()
1417 return AutoSizeDataBrowserListViewColumns(m_controlRef
);
1420 OSStatus
wxMacDataBrowserControl::SetHasScrollBars( bool horiz
, bool vert
)
1422 return SetDataBrowserHasScrollBars( m_controlRef
, horiz
, vert
);
1425 OSStatus
wxMacDataBrowserControl::SetHiliteStyle( DataBrowserTableViewHiliteStyle hiliteStyle
)
1427 return SetDataBrowserTableViewHiliteStyle( m_controlRef
, hiliteStyle
);
1430 OSStatus
wxMacDataBrowserControl::SetHeaderButtonHeight(UInt16 height
)
1432 return SetDataBrowserListViewHeaderBtnHeight( m_controlRef
, height
);
1435 OSStatus
wxMacDataBrowserControl::GetHeaderButtonHeight(UInt16
*height
)
1437 return GetDataBrowserListViewHeaderBtnHeight( m_controlRef
, height
);
1440 OSStatus
wxMacDataBrowserControl::SetCallbacks(const DataBrowserCallbacks
*callbacks
)
1442 return SetDataBrowserCallbacks( m_controlRef
, callbacks
);
1445 OSStatus
wxMacDataBrowserControl::UpdateItems(
1446 DataBrowserItemID container
,
1448 const DataBrowserItemID
*items
,
1449 DataBrowserPropertyID preSortProperty
,
1450 DataBrowserPropertyID propertyID
) const
1452 return UpdateDataBrowserItems( m_controlRef
, container
, numItems
, items
, preSortProperty
, propertyID
);
1455 bool wxMacDataBrowserControl::IsItemSelected( DataBrowserItemID item
) const
1457 return IsDataBrowserItemSelected( m_controlRef
, item
);
1460 OSStatus
wxMacDataBrowserControl::AddItems(
1461 DataBrowserItemID container
,
1463 const DataBrowserItemID
*items
,
1464 DataBrowserPropertyID preSortProperty
)
1466 return AddDataBrowserItems( m_controlRef
, container
, numItems
, items
, preSortProperty
);
1469 OSStatus
wxMacDataBrowserControl::RemoveItems(
1470 DataBrowserItemID container
,
1472 const DataBrowserItemID
*items
,
1473 DataBrowserPropertyID preSortProperty
)
1475 return RemoveDataBrowserItems( m_controlRef
, container
, numItems
, items
, preSortProperty
);
1478 OSStatus
wxMacDataBrowserControl::RevealItem(
1479 DataBrowserItemID item
,
1480 DataBrowserPropertyID propertyID
,
1481 DataBrowserRevealOptions options
) const
1483 return RevealDataBrowserItem( m_controlRef
, item
, propertyID
, options
);
1486 OSStatus
wxMacDataBrowserControl::SetSelectedItems(
1488 const DataBrowserItemID
*items
,
1489 DataBrowserSetOption operation
)
1491 return SetDataBrowserSelectedItems( m_controlRef
, numItems
, items
, operation
);
1494 OSStatus
wxMacDataBrowserControl::GetSelectionAnchor( DataBrowserItemID
*first
, DataBrowserItemID
*last
) const
1496 return GetDataBrowserSelectionAnchor( m_controlRef
, first
, last
);
1499 OSStatus
wxMacDataBrowserControl::GetItemID( DataBrowserTableViewRowIndex row
, DataBrowserItemID
* item
) const
1501 return GetDataBrowserTableViewItemID( m_controlRef
, row
, item
);
1504 OSStatus
wxMacDataBrowserControl::GetItemRow( DataBrowserItemID item
, DataBrowserTableViewRowIndex
* row
) const
1506 return GetDataBrowserTableViewItemRow( m_controlRef
, item
, row
);
1509 OSStatus
wxMacDataBrowserControl::SetDefaultRowHeight( UInt16 height
)
1511 return SetDataBrowserTableViewRowHeight( m_controlRef
, height
);
1514 OSStatus
wxMacDataBrowserControl::GetDefaultRowHeight( UInt16
* height
) const
1516 return GetDataBrowserTableViewRowHeight( m_controlRef
, height
);
1519 OSStatus
wxMacDataBrowserControl::SetRowHeight( DataBrowserItemID item
, UInt16 height
)
1521 return SetDataBrowserTableViewItemRowHeight( m_controlRef
, item
, height
);
1524 OSStatus
wxMacDataBrowserControl::GetRowHeight( DataBrowserItemID item
, UInt16
*height
) const
1526 return GetDataBrowserTableViewItemRowHeight( m_controlRef
, item
, height
);
1529 OSStatus
wxMacDataBrowserControl::GetColumnWidth( DataBrowserPropertyID column
, UInt16
*width
) const
1531 return GetDataBrowserTableViewNamedColumnWidth( m_controlRef
, column
, width
);
1534 OSStatus
wxMacDataBrowserControl::SetColumnWidth( DataBrowserPropertyID column
, UInt16 width
)
1536 return SetDataBrowserTableViewNamedColumnWidth( m_controlRef
, column
, width
);
1539 OSStatus
wxMacDataBrowserControl::GetDefaultColumnWidth( UInt16
*width
) const
1541 return GetDataBrowserTableViewColumnWidth( m_controlRef
, width
);
1544 OSStatus
wxMacDataBrowserControl::SetDefaultColumnWidth( UInt16 width
)
1546 return SetDataBrowserTableViewColumnWidth( m_controlRef
, width
);
1549 OSStatus
wxMacDataBrowserControl::GetColumnCount(UInt32
* numColumns
) const
1551 return GetDataBrowserTableViewColumnCount( m_controlRef
, numColumns
);
1554 OSStatus
wxMacDataBrowserControl::GetColumnPosition( DataBrowserPropertyID column
,
1555 DataBrowserTableViewColumnIndex
*position
) const
1557 return GetDataBrowserTableViewColumnPosition( m_controlRef
, column
, position
);
1560 OSStatus
wxMacDataBrowserControl::SetColumnPosition( DataBrowserPropertyID column
, DataBrowserTableViewColumnIndex position
)
1562 return SetDataBrowserTableViewColumnPosition( m_controlRef
, column
, position
);
1565 OSStatus
wxMacDataBrowserControl::GetScrollPosition( UInt32
*top
, UInt32
*left
) const
1567 return GetDataBrowserScrollPosition( m_controlRef
, top
, left
);
1570 OSStatus
wxMacDataBrowserControl::SetScrollPosition( UInt32 top
, UInt32 left
)
1572 return SetDataBrowserScrollPosition( m_controlRef
, top
, left
);
1575 OSStatus
wxMacDataBrowserControl::GetSortProperty( DataBrowserPropertyID
*column
) const
1577 return GetDataBrowserSortProperty( m_controlRef
, column
);
1580 OSStatus
wxMacDataBrowserControl::SetSortProperty( DataBrowserPropertyID column
)
1582 return SetDataBrowserSortProperty( m_controlRef
, column
);
1585 OSStatus
wxMacDataBrowserControl::GetSortOrder( DataBrowserSortOrder
*order
) const
1587 return GetDataBrowserSortOrder( m_controlRef
, order
);
1590 OSStatus
wxMacDataBrowserControl::SetSortOrder( DataBrowserSortOrder order
)
1592 return SetDataBrowserSortOrder( m_controlRef
, order
);
1595 OSStatus
wxMacDataBrowserControl::GetPropertyFlags( DataBrowserPropertyID property
,
1596 DataBrowserPropertyFlags
*flags
) const
1598 return GetDataBrowserPropertyFlags( m_controlRef
, property
, flags
);
1601 OSStatus
wxMacDataBrowserControl::SetPropertyFlags( DataBrowserPropertyID property
,
1602 DataBrowserPropertyFlags flags
)
1604 return SetDataBrowserPropertyFlags( m_controlRef
, property
, flags
);
1607 OSStatus
wxMacDataBrowserControl::GetHeaderDesc( DataBrowserPropertyID property
,
1608 DataBrowserListViewHeaderDesc
*desc
) const
1610 return GetDataBrowserListViewHeaderDesc( m_controlRef
, property
, desc
);
1613 OSStatus
wxMacDataBrowserControl::SetHeaderDesc( DataBrowserPropertyID property
,
1614 DataBrowserListViewHeaderDesc
*desc
)
1616 return SetDataBrowserListViewHeaderDesc( m_controlRef
, property
, desc
);
1619 OSStatus
wxMacDataBrowserControl::SetDisclosureColumn( DataBrowserPropertyID property
,
1620 Boolean expandableRows
)
1622 return SetDataBrowserListViewDisclosureColumn( m_controlRef
, property
, expandableRows
);
1625 // ============================================================================
1626 // Higher-level Databrowser
1627 // ============================================================================
1629 // basing on data item objects
1632 wxMacDataItem::wxMacDataItem()
1637 m_colId
= kTextColumnId
; // for compat with existing wx*ListBox impls.
1640 wxMacDataItem::~wxMacDataItem()
1644 void wxMacDataItem::SetOrder( SInt32 order
)
1649 SInt32
wxMacDataItem::GetOrder() const
1654 void wxMacDataItem::SetData( void* data
)
1659 void* wxMacDataItem::GetData() const
1664 short wxMacDataItem::GetColumn()
1669 void wxMacDataItem::SetColumn( short col
)
1674 void wxMacDataItem::SetLabel( const wxString
& str
)
1677 m_cfLabel
.Assign( str
, wxLocale::GetSystemEncoding());
1680 const wxString
& wxMacDataItem::GetLabel() const
1685 bool wxMacDataItem::IsLessThan(wxMacDataItemBrowserControl
*owner
,
1686 const wxMacDataItem
* rhs
,
1687 DataBrowserPropertyID sortProperty
) const
1689 const wxMacDataItem
* otherItem
= wx_const_cast(wxMacDataItem
*,rhs
);
1690 bool retval
= false;
1692 if ( sortProperty
== m_colId
){
1693 retval
= m_label
.CmpNoCase( otherItem
->m_label
) < 0;
1696 else if ( sortProperty
== kNumericOrderColumnId
)
1697 retval
= m_order
< otherItem
->m_order
;
1702 OSStatus
wxMacDataItem::GetSetData( wxMacDataItemBrowserControl
*owner
,
1703 DataBrowserPropertyID property
,
1704 DataBrowserItemDataRef itemData
,
1707 OSStatus err
= errDataBrowserPropertyNotSupported
;
1710 if ( property
== m_colId
){
1711 err
= ::SetDataBrowserItemDataText( itemData
, m_cfLabel
);
1714 else if ( property
== kNumericOrderColumnId
){
1715 err
= ::SetDataBrowserItemDataValue( itemData
, m_order
);
1725 // no editable props here
1734 void wxMacDataItem::Notification(wxMacDataItemBrowserControl
*owner
,
1735 DataBrowserItemNotification message
,
1736 DataBrowserItemDataRef itemData
) const
1740 IMPLEMENT_DYNAMIC_CLASS( wxMacDataItemBrowserControl
, wxMacDataBrowserControl
)
1742 wxMacDataItemBrowserControl::wxMacDataItemBrowserControl( wxWindow
* peer
, const wxPoint
& pos
, const wxSize
& size
, long style
) :
1743 wxMacDataBrowserControl( peer
, pos
, size
, style
)
1745 m_suppressSelection
= false;
1746 m_sortOrder
= SortOrder_None
;
1747 m_clientDataItemsType
= wxClientData_None
;
1750 wxMacDataItem
* wxMacDataItemBrowserControl::CreateItem()
1752 return new wxMacDataItem();
1755 wxMacDataItemBrowserSelectionSuppressor::wxMacDataItemBrowserSelectionSuppressor(wxMacDataItemBrowserControl
*browser
)
1757 m_former
= browser
->SuppressSelection(true);
1758 m_browser
= browser
;
1761 wxMacDataItemBrowserSelectionSuppressor::~wxMacDataItemBrowserSelectionSuppressor()
1763 m_browser
->SuppressSelection(m_former
);
1766 bool wxMacDataItemBrowserControl::SuppressSelection( bool suppress
)
1768 bool former
= m_suppressSelection
;
1769 m_suppressSelection
= suppress
;
1774 Boolean
wxMacDataItemBrowserControl::CompareItems(DataBrowserItemID itemOneID
,
1775 DataBrowserItemID itemTwoID
,
1776 DataBrowserPropertyID sortProperty
)
1778 wxMacDataItem
* itemOne
= (wxMacDataItem
*) itemOneID
;
1779 wxMacDataItem
* itemTwo
= (wxMacDataItem
*) itemTwoID
;
1780 return CompareItems( itemOne
, itemTwo
, sortProperty
);
1783 Boolean
wxMacDataItemBrowserControl::CompareItems(const wxMacDataItem
* itemOne
,
1784 const wxMacDataItem
* itemTwo
,
1785 DataBrowserPropertyID sortProperty
)
1787 Boolean retval
= false;
1788 if ( itemOne
!= NULL
)
1789 retval
= itemOne
->IsLessThan( this , itemTwo
, sortProperty
);
1793 OSStatus
wxMacDataItemBrowserControl::GetSetItemData(
1794 DataBrowserItemID itemID
,
1795 DataBrowserPropertyID property
,
1796 DataBrowserItemDataRef itemData
,
1797 Boolean changeValue
)
1799 wxMacDataItem
* item
= (wxMacDataItem
*) itemID
;
1800 return GetSetItemData(item
, property
, itemData
, changeValue
);
1803 OSStatus
wxMacDataItemBrowserControl::GetSetItemData(
1804 wxMacDataItem
* item
,
1805 DataBrowserPropertyID property
,
1806 DataBrowserItemDataRef itemData
,
1807 Boolean changeValue
)
1809 OSStatus err
= errDataBrowserPropertyNotSupported
;
1812 case kDataBrowserContainerIsClosableProperty
:
1813 case kDataBrowserContainerIsSortableProperty
:
1814 case kDataBrowserContainerIsOpenableProperty
:
1815 // right now default behaviour on these
1819 if ( item
!= NULL
){
1820 err
= item
->GetSetData( this, property
, itemData
, changeValue
);
1828 void wxMacDataItemBrowserControl::ItemNotification(
1829 DataBrowserItemID itemID
,
1830 DataBrowserItemNotification message
,
1831 DataBrowserItemDataRef itemData
)
1833 wxMacDataItem
* item
= (wxMacDataItem
*) itemID
;
1834 ItemNotification( item
, message
, itemData
);
1837 void wxMacDataItemBrowserControl::ItemNotification(
1838 const wxMacDataItem
* item
,
1839 DataBrowserItemNotification message
,
1840 DataBrowserItemDataRef itemData
)
1843 item
->Notification( this, message
, itemData
);
1846 unsigned int wxMacDataItemBrowserControl::GetItemCount(const wxMacDataItem
* container
,
1847 bool recurse
, DataBrowserItemState state
) const
1849 ItemCount numItems
= 0;
1850 verify_noerr( wxMacDataBrowserControl::GetItemCount( (DataBrowserItemID
)container
,
1851 recurse
, state
, &numItems
) );
1855 unsigned int wxMacDataItemBrowserControl::GetSelectedItemCount( const wxMacDataItem
* container
,
1856 bool recurse
) const
1858 return GetItemCount( container
, recurse
, kDataBrowserItemIsSelected
);
1862 void wxMacDataItemBrowserControl::GetItems(const wxMacDataItem
* container
,
1863 bool recurse
, DataBrowserItemState state
, wxArrayMacDataItemPtr
&items
) const
1865 Handle handle
= NewHandle(0);
1866 verify_noerr( wxMacDataBrowserControl::GetItems( (DataBrowserItemID
)container
,
1867 recurse
, state
, handle
) );
1869 int itemCount
= GetHandleSize(handle
)/sizeof(DataBrowserItemID
);
1871 wxMacDataItemPtr
* itemsArray
= (wxMacDataItemPtr
*) *handle
;
1872 for ( int i
= 0; i
< itemCount
; ++i
)
1874 items
.Add(itemsArray
[i
]);
1877 DisposeHandle( handle
);
1880 unsigned int wxMacDataItemBrowserControl::GetLineFromItem(const wxMacDataItem
* item
) const
1882 DataBrowserTableViewRowIndex row
;
1883 OSStatus err
= GetItemRow( (DataBrowserItemID
) item
, &row
);
1884 wxASSERT( err
== noErr
);
1888 wxMacDataItem
* wxMacDataItemBrowserControl::GetItemFromLine(unsigned int n
) const
1890 DataBrowserItemID id
;
1891 OSStatus err
= GetItemID( (DataBrowserTableViewRowIndex
) n
, &id
);
1892 wxASSERT( err
== noErr
);
1893 return (wxMacDataItem
*) id
;
1896 void wxMacDataItemBrowserControl::UpdateItem(const wxMacDataItem
*container
,
1897 const wxMacDataItem
*item
, DataBrowserPropertyID property
) const
1899 verify_noerr( wxMacDataBrowserControl::UpdateItems((DataBrowserItemID
)container
, 1,
1900 (DataBrowserItemID
*) &item
, kDataBrowserItemNoProperty
/* notSorted */, property
) );
1903 void wxMacDataItemBrowserControl::UpdateItems(const wxMacDataItem
*container
,
1904 wxArrayMacDataItemPtr
&itemArray
, DataBrowserPropertyID property
) const
1906 unsigned int noItems
= itemArray
.GetCount();
1907 DataBrowserItemID
*items
= new DataBrowserItemID
[noItems
];
1908 for ( unsigned int i
= 0; i
< noItems
; ++i
)
1909 items
[i
] = (DataBrowserItemID
) itemArray
[i
];
1911 verify_noerr( wxMacDataBrowserControl::UpdateItems((DataBrowserItemID
)container
, noItems
,
1912 items
, kDataBrowserItemNoProperty
/* notSorted */, property
) );
1916 void wxMacDataItemBrowserControl::InsertColumn(int colId
, DataBrowserPropertyType colType
,
1917 const wxString
& title
, SInt16 just
, int defaultWidth
)
1919 DataBrowserListViewColumnDesc columnDesc
;
1920 columnDesc
.headerBtnDesc
.titleOffset
= 0;
1921 columnDesc
.headerBtnDesc
.version
= kDataBrowserListViewLatestHeaderDesc
;
1923 columnDesc
.headerBtnDesc
.btnFontStyle
.flags
=
1924 kControlUseFontMask
| kControlUseJustMask
;
1926 columnDesc
.headerBtnDesc
.btnContentInfo
.contentType
= kControlContentTextOnly
;
1927 columnDesc
.headerBtnDesc
.btnFontStyle
.just
= just
;
1928 columnDesc
.headerBtnDesc
.btnFontStyle
.font
= kControlFontViewSystemFont
;
1929 columnDesc
.headerBtnDesc
.btnFontStyle
.style
= normal
;
1931 // TODO: Why is m_font not defined when we enter wxLC_LIST mode, but is
1932 // defined for other modes?
1935 enc
= m_font
.GetEncoding();
1937 enc
= wxLocale::GetSystemEncoding();
1938 wxMacCFStringHolder cfTitle
;
1939 cfTitle
.Assign( title
, enc
);
1940 columnDesc
.headerBtnDesc
.titleString
= cfTitle
;
1942 columnDesc
.headerBtnDesc
.minimumWidth
= 0;
1943 columnDesc
.headerBtnDesc
.maximumWidth
= 30000;
1945 columnDesc
.propertyDesc
.propertyID
= (kMinColumnId
+ colId
);
1946 columnDesc
.propertyDesc
.propertyType
= colType
;
1947 columnDesc
.propertyDesc
.propertyFlags
= kDataBrowserListViewSortableColumn
;
1948 #if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2
1949 columnDesc
.propertyDesc
.propertyFlags
|= kDataBrowserListViewTypeSelectColumn
;
1951 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
1952 columnDesc
.propertyDesc
.propertyFlags
|= kDataBrowserListViewNoGapForIconInHeaderButton
;
1955 verify_noerr( AddColumn( &columnDesc
, kDataBrowserListViewAppendColumn
) );
1957 if (defaultWidth
> 0){
1958 SetColumnWidth(colId
, defaultWidth
);
1963 void wxMacDataItemBrowserControl::SetColumnWidth(int colId
, int width
)
1965 DataBrowserPropertyID id
;
1966 GetColumnIDFromIndex(colId
, &id
);
1967 verify_noerr( wxMacDataBrowserControl::SetColumnWidth(id
, width
));
1970 int wxMacDataItemBrowserControl::GetColumnWidth(int colId
)
1972 DataBrowserPropertyID id
;
1973 GetColumnIDFromIndex(colId
, &id
);
1975 verify_noerr( wxMacDataBrowserControl::GetColumnWidth(id
, &result
));
1979 void wxMacDataItemBrowserControl::AddItem(wxMacDataItem
*container
, wxMacDataItem
*item
)
1981 verify_noerr( wxMacDataBrowserControl::AddItems( (DataBrowserItemID
)container
, 1,
1982 (DataBrowserItemID
*) &item
, kDataBrowserItemNoProperty
) );
1985 void wxMacDataItemBrowserControl::AddItems(wxMacDataItem
*container
, wxArrayMacDataItemPtr
&itemArray
)
1987 unsigned int noItems
= itemArray
.GetCount();
1988 DataBrowserItemID
*items
= new DataBrowserItemID
[noItems
];
1989 for ( unsigned int i
= 0; i
< noItems
; ++i
)
1990 items
[i
] = (DataBrowserItemID
) itemArray
[i
];
1992 verify_noerr( wxMacDataBrowserControl::AddItems( (DataBrowserItemID
)container
, noItems
,
1993 (DataBrowserItemID
*) items
, kDataBrowserItemNoProperty
) );
1997 void wxMacDataItemBrowserControl::RemoveItem(wxMacDataItem
*container
, wxMacDataItem
* item
)
1999 OSStatus err
= wxMacDataBrowserControl::RemoveItems( (DataBrowserItemID
)container
, 1,
2000 (DataBrowserItemID
*) &item
, kDataBrowserItemNoProperty
);
2001 verify_noerr( err
);
2004 void wxMacDataItemBrowserControl::RemoveItems(wxMacDataItem
*container
, wxArrayMacDataItemPtr
&itemArray
)
2006 unsigned int noItems
= itemArray
.GetCount();
2007 DataBrowserItemID
*items
= new DataBrowserItemID
[noItems
];
2008 for ( unsigned int i
= 0; i
< noItems
; ++i
)
2009 items
[i
] = (DataBrowserItemID
) itemArray
[i
];
2011 OSStatus err
= wxMacDataBrowserControl::RemoveItems( (DataBrowserItemID
)container
, noItems
,
2012 (DataBrowserItemID
*) items
, kDataBrowserItemNoProperty
);
2013 verify_noerr( err
);
2017 void wxMacDataItemBrowserControl::RemoveAllItems(wxMacDataItem
*container
)
2019 OSStatus err
= wxMacDataBrowserControl::RemoveItems( (DataBrowserItemID
)container
, 0 , NULL
, kDataBrowserItemNoProperty
);
2020 verify_noerr( err
);
2023 void wxMacDataItemBrowserControl::SetSelectedItem(wxMacDataItem
* item
, DataBrowserSetOption option
)
2025 verify_noerr(wxMacDataBrowserControl::SetSelectedItems( 1, (DataBrowserItemID
*) &item
, option
));
2028 void wxMacDataItemBrowserControl::SetSelectedAllItems(DataBrowserSetOption option
)
2030 verify_noerr(wxMacDataBrowserControl::SetSelectedItems( 0 , NULL
, option
));
2033 void wxMacDataItemBrowserControl::SetSelectedItems(wxArrayMacDataItemPtr
&itemArray
, DataBrowserSetOption option
)
2035 unsigned int noItems
= itemArray
.GetCount();
2036 DataBrowserItemID
*items
= new DataBrowserItemID
[noItems
];
2037 for ( unsigned int i
= 0; i
< noItems
; ++i
)
2038 items
[i
] = (DataBrowserItemID
) itemArray
[i
];
2040 verify_noerr(wxMacDataBrowserControl::SetSelectedItems( noItems
, (DataBrowserItemID
*) items
, option
));
2044 Boolean
wxMacDataItemBrowserControl::IsItemSelected( const wxMacDataItem
* item
) const
2046 return wxMacDataBrowserControl::IsItemSelected( (DataBrowserItemID
) item
);
2049 void wxMacDataItemBrowserControl::RevealItem( wxMacDataItem
* item
, DataBrowserRevealOptions options
)
2051 verify_noerr(wxMacDataBrowserControl::RevealItem( (DataBrowserItemID
) item
, kDataBrowserNoItem
, options
) );
2054 void wxMacDataItemBrowserControl::GetSelectionAnchor( wxMacDataItemPtr
* first
, wxMacDataItemPtr
* last
) const
2056 verify_noerr(wxMacDataBrowserControl::GetSelectionAnchor( (DataBrowserItemID
*) first
, (DataBrowserItemID
*) last
) );
2059 wxClientDataType
wxMacDataItemBrowserControl::GetClientDataType() const
2061 return m_clientDataItemsType
;
2063 void wxMacDataItemBrowserControl::SetClientDataType(wxClientDataType clientDataItemsType
)
2065 m_clientDataItemsType
= clientDataItemsType
;
2068 unsigned int wxMacDataItemBrowserControl::MacGetCount() const
2070 return GetItemCount(wxMacDataBrowserRootContainer
,false,kDataBrowserItemAnyState
);
2073 void wxMacDataItemBrowserControl::MacDelete( unsigned int n
)
2075 wxMacDataItem
* item
= (wxMacDataItem
*)GetItemFromLine( n
);
2076 RemoveItem( wxMacDataBrowserRootContainer
, item
);
2079 void wxMacDataItemBrowserControl::MacInsert( unsigned int n
, const wxString
& text
, int column
)
2081 wxMacDataItem
* newItem
= CreateItem();
2082 newItem
->SetLabel( text
);
2084 newItem
->SetColumn( kMinColumnId
+ column
);
2086 if ( m_sortOrder
== SortOrder_None
)
2088 // increase the order of the lines to be shifted
2089 unsigned int lines
= MacGetCount();
2090 for ( unsigned int i
= n
; i
< lines
; ++i
)
2092 wxMacDataItem
* iter
= (wxMacDataItem
*) GetItemFromLine(i
);
2093 iter
->SetOrder( iter
->GetOrder() + 1 );
2096 SInt32 frontLineOrder
= 0;
2099 wxMacDataItem
* iter
= (wxMacDataItem
*) GetItemFromLine(n
-1);
2100 frontLineOrder
= iter
->GetOrder();
2102 newItem
->SetOrder( frontLineOrder
+ 1 );
2105 AddItem( wxMacDataBrowserRootContainer
, newItem
);
2108 void wxMacDataItemBrowserControl::MacInsert( unsigned int n
, const wxArrayString
& items
, int column
)
2110 size_t itemsCount
= items
.GetCount();
2111 if ( itemsCount
== 0 )
2114 SInt32 frontLineOrder
= 0;
2116 if ( m_sortOrder
== SortOrder_None
)
2118 // increase the order of the lines to be shifted
2119 unsigned int lines
= MacGetCount();
2120 for ( unsigned int i
= n
; i
< lines
; ++i
)
2122 wxMacDataItem
* iter
= (wxMacDataItem
*) GetItemFromLine(i
);
2123 iter
->SetOrder( iter
->GetOrder() + itemsCount
);
2127 wxMacDataItem
* iter
= (wxMacDataItem
*) GetItemFromLine(n
-1);
2128 frontLineOrder
= iter
->GetOrder();
2132 wxArrayMacDataItemPtr ids
;
2133 ids
.SetCount( itemsCount
);
2135 for ( unsigned int i
= 0; i
< itemsCount
; ++i
)
2137 wxMacDataItem
* item
= CreateItem();
2138 item
->SetLabel( items
[i
]);
2140 item
->SetColumn( kMinColumnId
+ column
);
2142 if ( m_sortOrder
== SortOrder_None
)
2143 item
->SetOrder( frontLineOrder
+ 1 + i
);
2148 AddItems( wxMacDataBrowserRootContainer
, ids
);
2151 int wxMacDataItemBrowserControl::MacAppend( const wxString
& text
)
2153 wxMacDataItem
* item
= CreateItem();
2154 item
->SetLabel( text
);
2155 if ( m_sortOrder
== SortOrder_None
)
2157 unsigned int lines
= MacGetCount();
2159 item
->SetOrder( 1 );
2162 wxMacDataItem
* frontItem
= (wxMacDataItem
*) GetItemFromLine(lines
-1);
2163 item
->SetOrder( frontItem
->GetOrder() + 1 );
2166 AddItem( wxMacDataBrowserRootContainer
, item
);
2168 return GetLineFromItem(item
);
2171 void wxMacDataItemBrowserControl::MacClear()
2173 wxMacDataItemBrowserSelectionSuppressor
suppressor(this);
2174 RemoveAllItems(wxMacDataBrowserRootContainer
);
2177 void wxMacDataItemBrowserControl::MacDeselectAll()
2179 wxMacDataItemBrowserSelectionSuppressor
suppressor(this);
2180 SetSelectedAllItems( kDataBrowserItemsRemove
);
2183 void wxMacDataItemBrowserControl::MacSetSelection( unsigned int n
, bool select
, bool multi
)
2185 wxMacDataItem
* item
= (wxMacDataItem
*) GetItemFromLine(n
);
2186 wxMacDataItemBrowserSelectionSuppressor
suppressor(this);
2188 if ( IsItemSelected( item
) != select
)
2191 SetSelectedItem( item
, multi
? kDataBrowserItemsAdd
: kDataBrowserItemsAssign
);
2193 SetSelectedItem( item
, kDataBrowserItemsRemove
);
2199 bool wxMacDataItemBrowserControl::MacIsSelected( unsigned int n
) const
2201 wxMacDataItem
* item
= (wxMacDataItem
*) GetItemFromLine(n
);
2202 return IsItemSelected( item
);
2205 int wxMacDataItemBrowserControl::MacGetSelection() const
2207 wxMacDataItemPtr first
, last
;
2208 GetSelectionAnchor( &first
, &last
);
2210 if ( first
!= NULL
)
2212 return GetLineFromItem( first
);
2218 int wxMacDataItemBrowserControl::MacGetSelections( wxArrayInt
& aSelections
) const
2220 aSelections
.Empty();
2221 wxArrayMacDataItemPtr selectedItems
;
2222 GetItems( wxMacDataBrowserRootContainer
, false , kDataBrowserItemIsSelected
, selectedItems
);
2224 int count
= selectedItems
.GetCount();
2226 for ( int i
= 0; i
< count
; ++i
)
2228 aSelections
.Add(GetLineFromItem(selectedItems
[i
]));
2234 void wxMacDataItemBrowserControl::MacSetString( unsigned int n
, const wxString
& text
)
2236 // as we don't store the strings we only have to issue a redraw
2237 wxMacDataItem
* item
= (wxMacDataItem
*) GetItemFromLine( n
);
2238 item
->SetLabel( text
);
2239 UpdateItem( wxMacDataBrowserRootContainer
, item
, kTextColumnId
);
2242 wxString
wxMacDataItemBrowserControl::MacGetString( unsigned int n
) const
2244 wxMacDataItem
* item
= (wxMacDataItem
*) GetItemFromLine( n
);
2245 return item
->GetLabel();
2248 void wxMacDataItemBrowserControl::MacSetClientData( unsigned int n
, void * data
)
2250 wxMacDataItem
* item
= (wxMacDataItem
*) GetItemFromLine( n
);
2251 item
->SetData( data
);
2252 // not displayed, therefore no Update infos to DataBrowser
2255 void * wxMacDataItemBrowserControl::MacGetClientData( unsigned int n
) const
2257 wxMacDataItem
* item
= (wxMacDataItem
*) GetItemFromLine( n
);
2258 return item
->GetData();
2261 void wxMacDataItemBrowserControl::MacScrollTo( unsigned int n
)
2263 RevealItem( GetItemFromLine( n
) , kDataBrowserRevealWithoutSelecting
);
2272 OSStatus
wxMacControl::SetTabEnabled( SInt16 tabNo
, bool enable
)
2274 return ::SetTabEnabled( m_controlRef
, tabNo
, enable
);
2281 #ifdef __WXMAC_OSX__
2282 // snippets from Sketch Sample from Apple :
2284 #define kGenericRGBProfilePathStr "/System/Library/ColorSync/Profiles/Generic RGB Profile.icc"
2287 This function locates, opens, and returns the profile reference for the calibrated
2288 Generic RGB color space. It is up to the caller to call CMCloseProfile when done
2289 with the profile reference this function returns.
2291 CMProfileRef
wxMacOpenGenericProfile()
2293 static CMProfileRef cachedRGBProfileRef
= NULL
;
2295 // we only create the profile reference once
2296 if (cachedRGBProfileRef
== NULL
)
2298 CMProfileLocation loc
;
2300 loc
.locType
= cmPathBasedProfile
;
2301 strcpy(loc
.u
.pathLoc
.path
, kGenericRGBProfilePathStr
);
2303 verify_noerr( CMOpenProfile(&cachedRGBProfileRef
, &loc
) );
2306 // clone the profile reference so that the caller has their own reference, not our cached one
2307 if (cachedRGBProfileRef
)
2308 CMCloneProfileRef(cachedRGBProfileRef
);
2310 return cachedRGBProfileRef
;
2314 Return the generic RGB color space. This is a 'get' function and the caller should
2315 not release the returned value unless the caller retains it first. Usually callers
2316 of this routine will immediately use the returned colorspace with CoreGraphics
2317 so they typically do not need to retain it themselves.
2319 This function creates the generic RGB color space once and hangs onto it so it can
2320 return it whenever this function is called.
2323 CGColorSpaceRef
wxMacGetGenericRGBColorSpace()
2325 static wxMacCFRefHolder
<CGColorSpaceRef
> genericRGBColorSpace
;
2327 if (genericRGBColorSpace
== NULL
)
2329 if ( UMAGetSystemVersion() >= 0x1040 )
2331 genericRGBColorSpace
.Set( CGColorSpaceCreateWithName( CFSTR("kCGColorSpaceGenericRGB") ) );
2335 CMProfileRef genericRGBProfile
= wxMacOpenGenericProfile();
2337 if (genericRGBProfile
)
2339 genericRGBColorSpace
.Set( CGColorSpaceCreateWithPlatformColorSpace(genericRGBProfile
) );
2341 wxASSERT_MSG( genericRGBColorSpace
!= NULL
, wxT("couldn't create the generic RGB color space") );
2343 // we opened the profile so it is up to us to close it
2344 CMCloseProfile(genericRGBProfile
);
2349 return genericRGBColorSpace
;
2355 wxMacPortSaver::wxMacPortSaver( GrafPtr port
)
2357 ::GetPort( &m_port
);
2361 wxMacPortSaver::~wxMacPortSaver()
2363 ::SetPort( m_port
);
2367 void wxMacGlobalToLocal( WindowRef window
, Point
*pt
)
2369 #if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_4
2370 HIPoint p
= CGPointMake( pt
->h
, pt
->v
);
2371 HIViewRef contentView
;
2372 // TODO check toolbar offset
2373 HIViewFindByID( HIViewGetRoot( window
), kHIViewWindowContentID
, &contentView
) ;
2374 HIPointConvert( &p
, kHICoordSpace72DPIGlobal
, NULL
, kHICoordSpaceView
, contentView
);
2378 QDGlobalToLocalPoint( GetWindowPort(window
), pt
) ;
2382 void wxMacLocalToGlobal( WindowRef window
, Point
*pt
)
2384 #if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_4
2385 HIPoint p
= CGPointMake( pt
->h
, pt
->v
);
2386 HIViewRef contentView
;
2387 // TODO check toolbar offset
2388 HIViewFindByID( HIViewGetRoot( window
), kHIViewWindowContentID
, &contentView
) ;
2389 HIPointConvert( &p
, kHICoordSpaceView
, contentView
, kHICoordSpace72DPIGlobal
, NULL
);
2393 QDLocalToGlobalPoint( GetWindowPort(window
), pt
) ;