Merge branch 'msw-fix-BCM_GETIDEALSIZE'
Fix size of the buttons when not using manifest in wxMSW. See https://github.com/wxWidgets/wxWidgets/pull/2346
This commit is contained in:
@@ -580,17 +580,20 @@ wxSize wxAnyButton::DoGetBestSize() const
|
|||||||
|
|
||||||
wxSize size;
|
wxSize size;
|
||||||
|
|
||||||
// BCM_GETIDEALSIZE works properly only it there is a text label in the button.
|
// The preferred way is to use BCM_GETIDEALSIZE, but it only works properly
|
||||||
if ( !IsOwnerDrawn() && ShowsLabel() )
|
// if there is a text label in the button and can't be used under old
|
||||||
|
// systems or without a manifest.
|
||||||
|
if ( !IsOwnerDrawn() && ShowsLabel() &&
|
||||||
|
wxGetWinVersion() >= wxWinVersion_Vista )
|
||||||
{
|
{
|
||||||
SIZE idealSize = { 0, 0 };
|
SIZE idealSize = { 0, 0 };
|
||||||
::SendMessage(GetHwnd(), BCM_GETIDEALSIZE, 0, (LPARAM)&idealSize);
|
if ( ::SendMessage(GetHwnd(), BCM_GETIDEALSIZE, 0, (LPARAM)&idealSize) )
|
||||||
size.Set(idealSize.cx, idealSize.cy);
|
size.Set(idealSize.cx, idealSize.cy);
|
||||||
|
|
||||||
if ( m_imageData )
|
|
||||||
AdjustForBitmapMargins(size);
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
// If we failed to set the size using BCM_GETIDEALSIZE above, determine it
|
||||||
|
// ourselves.
|
||||||
|
if ( size == wxSize() )
|
||||||
{
|
{
|
||||||
// Account for the text part if we have it.
|
// Account for the text part if we have it.
|
||||||
if ( ShowsLabel() )
|
if ( ShowsLabel() )
|
||||||
@@ -615,11 +618,11 @@ wxSize wxAnyButton::DoGetBestSize() const
|
|||||||
size = wxMSWButton::ComputeBestFittingSize(self, flags);
|
size = wxMSWButton::ComputeBestFittingSize(self, flags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( m_imageData )
|
|
||||||
AdjustForBitmapSize(size);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( m_imageData )
|
||||||
|
AdjustForBitmapMargins(size);
|
||||||
|
|
||||||
return wxMSWButton::IncreaseToStdSizeAndCache(self, size);
|
return wxMSWButton::IncreaseToStdSizeAndCache(self, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user