cleanup for 10.5

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@42012 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Csomor
2006-10-14 16:18:09 +00:00
parent 4913272f9c
commit 7cd7bc23d5
5 changed files with 67 additions and 18 deletions

View File

@@ -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<wxChoice*>(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 ;
}

View File

@@ -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();
}

View File

@@ -247,6 +247,9 @@ wxSize wxListBox::DoGetBestSize() const
int wLine;
{
#if wxMAC_USE_CORE_GRAPHICS
wxClientDC dc(const_cast<wxListBox*>(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)

View File

@@ -91,6 +91,13 @@ wxSize wxStaticText::DoGetBestSize() const
}
else
{
#if wxMAC_USE_CORE_GRAPHICS
wxClientDC dc(const_cast<wxStaticText*>(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() )

View File

@@ -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<EventMouseWheelAxis>(kEventParamMouseWheelAxis, typeMouseWheelAxis) ;
SInt32 delta = cEvent.GetParameter<SInt32>(kEventParamMouseWheelDelta, typeLongInteger) ;
SInt32 delta = cEvent.GetParameter<SInt32>(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)