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:
parent
7b5c661b6d
commit
da07e0335e
@ -10,28 +10,28 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "radiobox.h"
|
||||
#pragma implementation "radiobox.h"
|
||||
#endif
|
||||
|
||||
// For compilers that support precompilation, includes "wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include <stdio.h>
|
||||
#include "wx/setup.h"
|
||||
#include "wx/bitmap.h"
|
||||
#include "wx/brush.h"
|
||||
#include "wx/radiobox.h"
|
||||
#include <stdio.h>
|
||||
#include "wx/setup.h"
|
||||
#include "wx/bitmap.h"
|
||||
#include "wx/brush.h"
|
||||
#include "wx/radiobox.h"
|
||||
#endif
|
||||
|
||||
#include "wx/msw/private.h"
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxRadioBox, wxControl)
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxRadioBox, wxControl)
|
||||
#endif
|
||||
|
||||
bool wxRadioBox::MSWCommand(WXUINT param, WXWORD id)
|
||||
@ -127,10 +127,10 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& title,
|
||||
WXDWORD exStyle = Determine3DEffects(0, &want3D) ;
|
||||
// Even with extended styles, need to combine with WS_BORDER
|
||||
// for them to look right.
|
||||
/*
|
||||
/*
|
||||
if ( want3D || wxStyleHasBorder(m_windowStyle) )
|
||||
msStyle |= WS_BORDER;
|
||||
*/
|
||||
*/
|
||||
|
||||
|
||||
HWND the_handle = (HWND) parent->GetHWND() ;
|
||||
@ -344,10 +344,10 @@ void wxRadioBox::SetLabel(int item, const wxString& label)
|
||||
|
||||
void wxRadioBox::SetLabel(int item, wxBitmap *bitmap)
|
||||
{
|
||||
/*
|
||||
/*
|
||||
m_radioWidth[item] = bitmap->GetWidth() + FB_MARGIN ;
|
||||
m_radioHeight[item] = bitmap->GetHeight() + FB_MARGIN ;
|
||||
*/
|
||||
*/
|
||||
}
|
||||
|
||||
int wxRadioBox::FindString(const wxString& s) const
|
||||
@ -367,7 +367,7 @@ void wxRadioBox::SetSelection(int N)
|
||||
if ((N < 0) || (N >= m_noItems))
|
||||
return;
|
||||
|
||||
// Following necessary for Win32s, because Win32s translate BM_SETCHECK
|
||||
// Following necessary for Win32s, because Win32s translate BM_SETCHECK
|
||||
if (m_selectedButton >= 0 && m_selectedButton < m_noItems)
|
||||
SendMessage((HWND) m_radioButtons[m_selectedButton], BM_SETCHECK, 0, 0L);
|
||||
|
||||
@ -402,49 +402,17 @@ 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;
|
||||
int current_width, cyf;
|
||||
|
||||
int cx1,cy1 ;
|
||||
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, ¤t_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;
|
||||
|
||||
int nbHor,nbVer;
|
||||
|
||||
// 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, ¤t_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, ¤t_width, &cyf,NULL,NULL, & this->GetFont());
|
||||
textRadioButton = wxGetWindowText(m_radioButtons[i]);
|
||||
GetTextExtent(textRadioButton, ¤t_width, &cyf,
|
||||
NULL,NULL, & this->GetFont());
|
||||
|
||||
// How do we find out radio button bitmap size!!
|
||||
// By adjusting them carefully, manually :-)
|
||||
@ -683,7 +708,7 @@ WXHBRUSH wxRadioBox::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
|
||||
|
||||
// Note that this will be cleaned up in wxApp::OnIdle, if backgroundBrush
|
||||
// has a zero usage count.
|
||||
// backgroundBrush->RealizeResource();
|
||||
// backgroundBrush->RealizeResource();
|
||||
return (WXHBRUSH) backgroundBrush->GetResourceHandle();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user