width and height arguments are no longer ignored in wxRadioBox::SetSize()

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1476 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
1999-01-25 21:55:59 +00:00
parent 7b5c661b6d
commit da07e0335e

View File

@@ -402,7 +402,7 @@ void wxRadioBox::SetSize(int x, int y, int width, int height, int sizeFlags)
AdjustForParentClientOrigin(xx, yy, sizeFlags);
char buf[400];
wxString textRadioButton;
int y_offset = yy;
int x_offset = xx;
@@ -410,41 +410,9 @@ void wxRadioBox::SetSize(int x, int y, int width, int height, int sizeFlags)
int cx1,cy1;
wxGetCharSize(m_hWnd, &cx1, &cy1, & this->GetFont());
// Attempt to have a look coherent with other platforms:
// We compute the biggest toggle dim, then we align all
// items according this value.
int maxWidth = -1;
int maxHeight = -1 ;
int i;
for (i = 0 ; i < m_noItems; i++)
{
int eachWidth;
int eachHeight ;
if (m_radioWidth[i]<0)
{
// It's a labelled toggle
GetWindowText((HWND) m_radioButtons[i], buf, 300);
GetTextExtent(buf, &current_width, &cyf,NULL,NULL, & this->GetFont());
eachWidth = (int)(current_width + RADIO_SIZE);
eachHeight = (int)((3*cyf)/2);
}
else
{
eachWidth = m_radioWidth[i] ;
eachHeight = m_radioHeight[i] ;
}
if (maxWidth<eachWidth) maxWidth = eachWidth ;
if (maxHeight<eachHeight) maxHeight = eachHeight ;
}
if (m_hWnd)
{
int totWidth ;
int totHeight;
// number of radio boxes in both directions
int nbHor, nbVer;
if (m_windowStyle & wxRA_VERTICAL)
{
nbVer = m_majorDim ;
@@ -456,6 +424,62 @@ void wxRadioBox::SetSize(int x, int y, int width, int height, int sizeFlags)
nbVer = (m_noItems+m_majorDim-1)/m_majorDim ;
}
// Attempt to have a look coherent with other platforms:
// We compute the biggest toggle dim, then we align all
// items according this value.
int maxWidth = width,
maxHeight = height;
// if we're given the width or height explicitly do not recalculate it, but
// use what we have
bool calcWidth = maxWidth == -1,
calcHeight = maxHeight == -1;
if ( calcWidth || calcHeight )
{
// init vars to avoid compiler warnings, even if we don't use them
int eachWidth = 0,
eachHeight = 0;
for ( int i = 0 ; i < m_noItems; i++ )
{
if ( m_radioWidth[i] < 0 )
{
// It's a labelled toggle
textRadioButton = wxGetWindowText(m_radioButtons[i]);
GetTextExtent(textRadioButton, &current_width, &cyf,
NULL,NULL, & this->GetFont());
if ( calcWidth )
eachWidth = (int)(current_width + RADIO_SIZE);
if ( calcHeight )
eachHeight = (int)((3*cyf)/2);
}
else
{
if ( calcWidth )
eachWidth = m_radioWidth[i] ;
if ( calcHeight )
eachHeight = m_radioHeight[i] ;
}
if ( calcWidth && maxWidth < eachWidth )
maxWidth = eachWidth;
if ( calcHeight && maxHeight < eachHeight )
maxHeight = eachHeight;
}
}
else
{
maxHeight = height/nbVer;
maxWidth = width/nbHor;
}
if (m_hWnd)
{
int totWidth ;
int totHeight;
// this formula works, but I don't know why.
// Please, be sure what you do if you modify it!!
if (m_radioWidth[0]<0)
@@ -481,7 +505,7 @@ void wxRadioBox::SetSize(int x, int y, int width, int height, int sizeFlags)
int startX = x_offset ;
int startY = y_offset ;
for ( i = 0 ; i < m_noItems; i++)
for ( int i = 0 ; i < m_noItems; i++)
{
// Bidimensional radio adjustment
if (i&&((i%m_majorDim)==0)) // Why is this omitted for i = 0?
@@ -504,8 +528,9 @@ void wxRadioBox::SetSize(int x, int y, int width, int height, int sizeFlags)
if (m_radioWidth[i]<0)
{
// It's a labeled item
GetWindowText((HWND) m_radioButtons[i], buf, 300);
GetTextExtent(buf, &current_width, &cyf,NULL,NULL, & this->GetFont());
textRadioButton = wxGetWindowText(m_radioButtons[i]);
GetTextExtent(textRadioButton, &current_width, &cyf,
NULL,NULL, & this->GetFont());
// How do we find out radio button bitmap size!!
// By adjusting them carefully, manually :-)