X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/79a73b4f86090278c242a8cca5fd9147a31a4419..3c5487b14442ddbc6e43ee2f4475b5a6ba251fb1:/src/mac/carbon/utils.cpp diff --git a/src/mac/carbon/utils.cpp b/src/mac/carbon/utils.cpp index ab012ec103..5c4da3a625 100644 --- a/src/mac/carbon/utils.cpp +++ b/src/mac/carbon/utils.cpp @@ -45,9 +45,9 @@ #include #endif -#include "ATSUnicode.h" -#include "TextCommon.h" -#include "TextEncodingConverter.h" +#include +#include +#include #include "wx/mac/private.h" // includes mac headers @@ -198,11 +198,15 @@ long wxGetFreeMemory() void wxUsleep(unsigned long milliseconds) { + // TODO remove if we don't encounter any other problemsy + /* clock_t start = clock() ; do { YieldToAnyThread() ; } while( clock() - start < milliseconds / 1000.0 * CLOCKS_PER_SEC ) ; + */ + wxThread::Sleep( milliseconds ) ; } void wxSleep(int nSecs) @@ -456,30 +460,16 @@ void wxDisplaySizeMM(int *width, int *height) void wxClientDisplayRect(int *x, int *y, int *width, int *height) { - BitMap screenBits; - GetQDGlobalsScreenBits( &screenBits ); - - if (x) *x = 0; - if (y) *y = 0; - - if (width != NULL) { - *width = screenBits.bounds.right - screenBits.bounds.left ; - } - if (height != NULL) { - *height = screenBits.bounds.bottom - screenBits.bounds.top ; - } - - SInt16 mheight ; -#if TARGET_CARBON - GetThemeMenuBarHeight( &mheight ) ; -#else - mheight = LMGetMBarHeight() ; -#endif - if (height != NULL) { - *height -= mheight ; - } - if (y) - *y = mheight ; + Rect r ; + GetAvailableWindowPositioningBounds( GetMainDevice() , &r ) ; + if ( x ) + *x = r.left ; + if ( y ) + *y = r.top ; + if ( width ) + *width = r.right - r.left ; + if ( height ) + *height = r.bottom - r.top ; } wxWindow* wxFindWindowAtPoint(const wxPoint& pt) @@ -1152,10 +1142,10 @@ wxString wxMacCFStringHolder::AsString(wxFontEncoding encoding) #else CFIndex cStrLen ; CFStringGetBytes( m_cfs , CFRangeMake(0, cflen) , wxMacGetSystemEncFromFontEnc( encoding ) , - '?' , false , NULL , 0 , cStrLen ) ; + '?' , false , NULL , 0 , &cStrLen ) ; buf = new wxChar[ cStrLen + 1 ] ; - CFStringGetBytes( m_cfs , CFRangeMake(0, len) , wxMacGetSystemEncFromFontEnc( encoding ) , - '?' , false , (void*) buf , cStrLen , &StrLen) ; + CFStringGetBytes( m_cfs , CFRangeMake(0, cflen) , wxMacGetSystemEncFromFontEnc( encoding ) , + '?' , false , (unsigned char*) buf , cStrLen , &cStrLen) ; noChars = cStrLen ; #endif @@ -1238,6 +1228,83 @@ void wxMacConvertNewlines10To13( wxChar * data ) } #endif +// ---------------------------------------------------------------------------- +// Common Event Support +// ---------------------------------------------------------------------------- + +#endif // wxUSE_GUI + +#if wxUSE_BASE + +extern ProcessSerialNumber gAppProcess ; + +void wxMacWakeUp() +{ + ProcessSerialNumber psn ; + Boolean isSame ; + psn.highLongOfPSN = 0 ; + psn.lowLongOfPSN = kCurrentProcess ; + SameProcess( &gAppProcess , &psn , &isSame ) ; + if ( isSame ) + { +#if TARGET_CARBON + EventRef dummyEvent ; + OSStatus err = MacCreateEvent(nil, 'WXMC', 'WXMC', GetCurrentEventTime(), + kEventAttributeNone, &dummyEvent); + if (err == noErr) + { + err = PostEventToQueue(GetMainEventQueue(), dummyEvent, + kEventPriorityHigh); + } +#else + PostEvent( nullEvent , 0 ) ; +#endif + } + else + { + WakeUpProcess( &gAppProcess ) ; + } +} + +#endif // wxUSE_BASE + +#if wxUSE_GUI + + +// ---------------------------------------------------------------------------- +// Carbon Event Support +// ---------------------------------------------------------------------------- + + +OSStatus wxMacCarbonEvent::GetParameter(EventParamName inName, EventParamType inDesiredType, UInt32 inBufferSize, void * outData) +{ + return ::GetEventParameter( m_eventRef , inName , inDesiredType , NULL , inBufferSize , NULL , outData ) ; +} + +OSStatus wxMacCarbonEvent::SetParameter(EventParamName inName, EventParamType inType, UInt32 inBufferSize, void * inData) +{ + return ::SetEventParameter( m_eventRef , inName , inType , inBufferSize , inData ) ; +} + +// ---------------------------------------------------------------------------- +// Control Access Support +// ---------------------------------------------------------------------------- + +OSStatus wxMacControl::GetData(ControlPartCode inPartCode , ResType inTag , Size inBufferSize , void * inOutBuffer , Size * outActualSize ) +{ + return ::GetControlData( m_controlRef , inPartCode , inTag , inBufferSize , inOutBuffer , outActualSize ) ; +} + +OSStatus wxMacControl::GetDataSize(ControlPartCode inPartCode , ResType inTag , Size * outActualSize ) +{ + return ::GetControlDataSize( m_controlRef , inPartCode , inTag , outActualSize ) ; +} + +OSStatus wxMacControl::SetData(ControlPartCode inPartCode , ResType inTag , Size inSize , const void * inData) +{ + return ::SetControlData( m_controlRef , inPartCode , inTag , inSize , inData ) ; +} + // ---------------------------------------------------------------------------- // debugging support // ----------------------------------------------------------------------------