From 7cd7bc23d574ea5ec62f1abea73eb363a9ea8126 Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Sat, 14 Oct 2006 16:18:09 +0000 Subject: [PATCH] cleanup for 10.5 git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@42012 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/mac/carbon/choice.cpp | 22 +++++++++++++++++----- src/mac/carbon/dataobj.cpp | 4 ++++ src/mac/carbon/listbox.cpp | 18 ++++++++++++++++-- src/mac/carbon/stattext.cpp | 8 ++++++++ src/mac/carbon/toplevel.cpp | 33 ++++++++++++++++++++++----------- 5 files changed, 67 insertions(+), 18 deletions(-) diff --git a/src/mac/carbon/choice.cpp b/src/mac/carbon/choice.cpp index f2173eb03c..8898554b20 100644 --- a/src/mac/carbon/choice.cpp +++ b/src/mac/carbon/choice.cpp @@ -300,13 +300,16 @@ wxSize wxChoice::DoGetBestSize() const int wLine; #if TARGET_CARBON - long metric ; + SInt32 metric ; GetThemeMetric( kThemeMetricPopupButtonHeight , &metric ); lbHeight = metric ; #endif { +#if wxMAC_USE_CORE_GRAPHICS + wxClientDC dc(const_cast(this)); +#else wxMacPortStateHelper st( UMAGetWindowPort( (WindowRef) MacGetTopLevelWindowRef() ) ) ; if ( m_font.Ok() ) { @@ -320,12 +323,16 @@ wxSize wxChoice::DoGetBestSize() const ::TextSize( 9 ) ; ::TextFace( 0 ) ; } - +#endif // Find the widest line for(unsigned int i = 0; i < GetCount(); i++) { wxString str(GetString(i)); - +#if wxMAC_USE_CORE_GRAPHICS + wxCoord width, height ; + dc.GetTextExtent( str , &width, &height); + wLine = width ; +#else #if wxUSE_UNICODE Point bounds = { 0, 0 } ; SInt16 baseline ; @@ -341,15 +348,20 @@ wxSize wxChoice::DoGetBestSize() const #else wLine = ::TextWidth( str.c_str() , 0 , str.length() ) ; #endif - +#endif lbWidth = wxMax( lbWidth, wLine ) ; } // Add room for the popup arrow lbWidth += 2 * lbHeight ; - +#if wxMAC_USE_CORE_GRAPHICS + wxCoord width, height ; + dc.GetTextExtent( wxT("X"), &width, &height); + int cx = width ; +#else // And just a bit more int cx = ::TextWidth( "X" , 0 , 1 ) ; +#endif lbWidth += cx ; } diff --git a/src/mac/carbon/dataobj.cpp b/src/mac/carbon/dataobj.cpp index cc1c352206..07a1e39a98 100644 --- a/src/mac/carbon/dataobj.cpp +++ b/src/mac/carbon/dataobj.cpp @@ -311,8 +311,10 @@ void wxBitmapDataObject::Clear() { if (m_pictHandle != NULL) { +#ifndef __LP64__ if (m_pictCreated) KillPicture( (PicHandle)m_pictHandle ); +#endif m_pictHandle = NULL; } @@ -356,6 +358,7 @@ bool wxBitmapDataObject::SetData( size_t nSize, const void *pBuf ) // ownership is transferred to the bitmap m_pictCreated = false; +#ifndef __LP64__ Rect frame; wxMacGetPictureBounds( picHandle, &frame ); @@ -366,6 +369,7 @@ bool wxBitmapDataObject::SetData( size_t nSize, const void *pBuf ) mdc.SelectObject( m_bitmap ); mf.Play( &mdc ); mdc.SelectObject( wxNullBitmap ); +#endif return m_bitmap.Ok(); } diff --git a/src/mac/carbon/listbox.cpp b/src/mac/carbon/listbox.cpp index 35de39915c..faf519d08a 100644 --- a/src/mac/carbon/listbox.cpp +++ b/src/mac/carbon/listbox.cpp @@ -247,6 +247,9 @@ wxSize wxListBox::DoGetBestSize() const int wLine; { +#if wxMAC_USE_CORE_GRAPHICS + wxClientDC dc(const_cast(this)); +#else wxMacPortStateHelper st( UMAGetWindowPort( (WindowRef)MacGetTopLevelWindowRef() ) ); // TODO: clean this up @@ -262,12 +265,16 @@ wxSize wxListBox::DoGetBestSize() const ::TextSize( 9 ); ::TextFace( 0 ); } - +#endif // Find the widest line for (unsigned int i = 0; i < GetCount(); i++) { wxString str( GetString( i ) ); - +#if wxMAC_USE_CORE_GRAPHICS + wxCoord width, height ; + dc.GetTextExtent( str , &width, &height); + wLine = width ; +#else #if wxUSE_UNICODE Point bounds = {0, 0}; SInt16 baseline; @@ -286,6 +293,7 @@ wxSize wxListBox::DoGetBestSize() const #endif lbWidth = wxMax( lbWidth, wLine ); +#endif } // Add room for the scrollbar @@ -293,7 +301,13 @@ wxSize wxListBox::DoGetBestSize() const // And just a bit more int cy = 12; +#if wxMAC_USE_CORE_GRAPHICS + wxCoord width, height ; + dc.GetTextExtent( wxT("X") , &width, &height); + int cx = width ; +#else int cx = ::TextWidth( "X", 0, 1 ); +#endif lbWidth += cx; // don't make the listbox too tall (limit height to around 10 items) diff --git a/src/mac/carbon/stattext.cpp b/src/mac/carbon/stattext.cpp index 0898022392..21ed1ed771 100644 --- a/src/mac/carbon/stattext.cpp +++ b/src/mac/carbon/stattext.cpp @@ -91,6 +91,13 @@ wxSize wxStaticText::DoGetBestSize() const } else { +#if wxMAC_USE_CORE_GRAPHICS + wxClientDC dc(const_cast(this)); + wxCoord width, height ; + dc.GetTextExtent( m_label , &width, &height); + bounds.h = width; + bounds.v = height; +#else wxMacWindowStateSaver sv( this ); ::TextFont( m_font.MacGetFontNum() ); ::TextSize( (short)(m_font.MacGetFontSize()) ); @@ -100,6 +107,7 @@ wxSize wxStaticText::DoGetBestSize() const (!m_label.empty() ? (CFStringRef)str : CFSTR(" ")), kThemeCurrentPortFont, kThemeStateActive, false, &bounds, &baseline ); verify_noerr( err ); +#endif } if ( m_label.empty() ) diff --git a/src/mac/carbon/toplevel.cpp b/src/mac/carbon/toplevel.cpp index 6a5284d6da..e18ed8044b 100644 --- a/src/mac/carbon/toplevel.cpp +++ b/src/mac/carbon/toplevel.cpp @@ -130,7 +130,7 @@ static pascal OSStatus KeyboardEventHandler( EventHandlerCallRef handler , Event UInt32 when = EventTimeToTicks( GetEventTime( event ) ) ; #if wxUSE_UNICODE - UInt32 dataSize = 0 ; + ByteCount dataSize = 0 ; if ( GetEventParameter( event, kEventParamKeyUnicodes, typeUnicodeText, NULL, 0 , &dataSize, NULL ) == noErr ) { UniChar buf[2] ; @@ -359,7 +359,7 @@ static void SetupMouseEvent( wxMouseEvent &wxevent , wxMacCarbonEvent &cEvent ) wxevent.SetEventType( wxEVT_MOUSEWHEEL ) ; // EventMouseWheelAxis axis = cEvent.GetParameter(kEventParamMouseWheelAxis, typeMouseWheelAxis) ; - SInt32 delta = cEvent.GetParameter(kEventParamMouseWheelDelta, typeLongInteger) ; + SInt32 delta = cEvent.GetParameter(kEventParamMouseWheelDelta, typeSInt32) ; wxevent.m_wheelRotation = delta; wxevent.m_wheelDelta = 1; @@ -467,7 +467,7 @@ pascal OSStatus wxMacTopLevelMouseEventHandler( EventHandlerCallRef handler , Ev if ( window ) { - QDGlobalToLocalPoint( UMAGetWindowPort(window ) , &windowMouseLocation ) ; + wxMacGlobalToLocal( window, &windowMouseLocation ) ; if ( wxApp::s_captureWindow #if !NEW_CAPTURE_HANDLING @@ -980,10 +980,18 @@ void wxTopLevelWindowMac::Maximize(bool maximize) Point idealSize = { 0 , 0 } ; if ( maximize ) { +#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 + HIRect bounds ; + HIWindowGetAvailablePositioningBounds(kCGNullDirectDisplay,kHICoordSpace72DPIGlobal, + &bounds); + idealSize.h = bounds.size.width; + idealSize.v = bounds.size.height; +#else Rect rect ; GetAvailableWindowPositioningBounds(GetMainDevice(),&rect) ; idealSize.h = rect.right - rect.left ; idealSize.v = rect.bottom - rect.top ; +#endif } ZoomWindowIdeal( (WindowRef)m_macWindow , maximize ? inZoomOut : inZoomIn , &idealSize ) ; } @@ -1157,8 +1165,12 @@ void wxTopLevelWindowMac::MacCreateRealWindow( { WindowDefSpec customWindowDefSpec; customWindowDefSpec.defType = kWindowDefProcPtr; - customWindowDefSpec.u.defProc = NewWindowDefUPP(wxShapedMacWindowDef); - + customWindowDefSpec.u.defProc = +#ifdef __LP64__ + (WindowDefUPP) wxShapedMacWindowDef; +#else + NewWindowDefUPP(wxShapedMacWindowDef); +#endif err = ::CreateCustomWindow( &customWindowDefSpec, wclass, attr, &theBoundsRect, (WindowRef*) &m_macWindow); @@ -1604,7 +1616,7 @@ bool wxTopLevelWindowMac::SetShape(const wxRegion& region) DisposeRgn(oldRgn); // Save the region so we can use it later - SetWRefCon((WindowRef)MacGetWindowRef(), (SInt32)shapeRegion); + SetWRefCon((WindowRef)MacGetWindowRef(), (URefCon)shapeRegion); // inform the window manager that the window has changed shape ReshapeCustomWindow((WindowRef)MacGetWindowRef()); @@ -1620,13 +1632,12 @@ bool wxTopLevelWindowMac::SetShape(const wxRegion& region) static void wxShapedMacWindowGetPos(WindowRef window, Rect* inRect) { GetWindowPortBounds(window, inRect); - Point pt = { inRect->left, inRect->top }; - - QDLocalToGlobalPoint( GetWindowPort(window), &pt ) ; + Point pt = { inRect->top ,inRect->left }; + wxMacLocalToGlobal( window, &pt ) ; + inRect->bottom += pt.v - inRect->top; + inRect->right += pt.h - inRect->left; inRect->top = pt.v; inRect->left = pt.h; - inRect->bottom += pt.v; - inRect->right += pt.h; } static SInt32 wxShapedMacWindowGetFeatures(WindowRef window, SInt32 param) -- 2.45.2