updates for DoGetBestSize

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4639 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
David Webster
1999-11-21 01:03:00 +00:00
parent 06d2a9e76e
commit e78c4d503e
24 changed files with 44 additions and 84 deletions

View File

@@ -923,4 +923,3 @@ void wxSetInstance(HINSTANCE hInst)
wxhInstance = hInst;
}

View File

@@ -72,14 +72,14 @@ wxButton::~wxButton()
// size management including autosizing
// ----------------------------------------------------------------------------
wxSize wxButton::DoGetBestSize()
wxSize wxButton::DoGetBestSize() const
{
wxString label = wxGetWindowText(GetHWND());
int wBtn;
GetTextExtent(label, &wBtn, NULL);
int wChar, hChar;
wxGetCharSize(GetHWND(), &wChar, &hChar, &GetFont());
wxGetCharSize(GetHWND(), &wChar, &hChar, (wxFont*)&GetFont());
// add a margin - the button is wider than just its label
wBtn += 3*wChar;

View File

@@ -96,7 +96,7 @@ void wxCheckBox::SetLabel(const wxString& label)
// TODO
}
wxSize wxCheckBox::DoGetBestSize()
wxSize wxCheckBox::DoGetBestSize() const
{
int wCheckbox, hCheckbox;

View File

@@ -216,7 +216,7 @@ void wxChoice::DoSetSize(int x, int y,
wxControl::DoSetSize(x, y, width, -1, sizeFlags);
}
wxSize wxChoice::DoGetBestSize()
wxSize wxChoice::DoGetBestSize() const
{
// find the widest string
int wLine;
@@ -237,7 +237,7 @@ wxSize wxChoice::DoGetBestSize()
// the combobox should be larger than the widest string
int cx, cy;
wxGetCharSize(GetHWND(), &cx, &cy, &GetFont());
wxGetCharSize(GetHWND(), &cx, &cy, (wxFont*)&GetFont());
wChoice += 5*cx;

View File

@@ -81,7 +81,7 @@ bool wxControl::OS2CreateControl(const wxChar *classname, WXDWORD style)
return TRUE;
}
wxSize wxControl::DoGetBestSize()
wxSize wxControl::DoGetBestSize() const
{
return wxSize(DEFAULT_ITEM_WIDTH, DEFAULT_ITEM_HEIGHT);
}

View File

@@ -606,7 +606,7 @@ void wxListBox::SetHorizontalExtent(const wxString& s)
*/
}
wxSize wxListBox::DoGetBestSize()
wxSize wxListBox::DoGetBestSize() const
{
// find the widest string
int wLine;
@@ -626,7 +626,7 @@ wxSize wxListBox::DoGetBestSize()
// the listbox should be slightly larger than the widest string
int cx, cy;
wxGetCharSize(GetHWND(), &cx, &cy, &GetFont());
wxGetCharSize(GetHWND(), &cx, &cy, (wxFont*)&GetFont());
wListbox += 3*cx;

View File

@@ -65,7 +65,7 @@ wxSpinButton::~wxSpinButton()
// size calculation
// ----------------------------------------------------------------------------
wxSize wxSpinButton::DoGetBestSize()
wxSize wxSpinButton::DoGetBestSize() const
{
// TODO:
/*

View File

@@ -100,7 +100,7 @@ void wxStaticBitmap::Free()
m_image.icon = NULL;
}
wxSize wxStaticBitmap::DoGetBestSize()
wxSize wxStaticBitmap::DoGetBestSize() const
{
// reuse the current size (as wxWindow does) instead of using some
// arbitrary default size (as wxControl, our immediate base class, does)

View File

@@ -93,10 +93,10 @@ bool wxStaticBox::Create(wxWindow *parent, wxWindowID id,
return FALSE;
}
wxSize wxStaticBox::DoGetBestSize()
wxSize wxStaticBox::DoGetBestSize() const
{
int cx, cy;
wxGetCharSize(GetHWND(), &cx, &cy, &GetFont());
wxGetCharSize(GetHWND(), &cx, &cy, (wxFont*)&GetFont());
int wBox;
GetTextExtent(wxGetWindowText(m_hWnd), &wBox, &cy);

View File

@@ -60,20 +60,33 @@ bool wxStaticText::Create(wxWindow *parent, wxWindowID id,
return FALSE;
}
wxSize wxStaticText::DoGetBestSize()
wxSize wxStaticText::DoGetBestSize() const
{
wxString text(wxGetWindowText(GetHWND()));
int widthTextMax = 0, widthLine,
heightTextTotal = 0, heightLine;
heightTextTotal = 0, heightLineDefault = 0, heightLine = 0;
wxString curLine;
for ( const wxChar *pc = text; ; pc++ ) {
if ( *pc == wxT('\n') || *pc == wxT('\0') ) {
GetTextExtent(curLine, &widthLine, &heightLine);
if ( widthLine > widthTextMax )
widthTextMax = widthLine;
heightTextTotal += heightLine;
if ( !curLine ) {
// we can't use GetTextExtent - it will return 0 for both width
// and height and an empty line should count in height
// calculation
if ( !heightLineDefault )
heightLineDefault = heightLine;
if ( !heightLineDefault )
GetTextExtent(_T("W"), NULL, &heightLineDefault);
heightTextTotal += heightLineDefault;
}
else {
GetTextExtent(curLine, &widthLine, &heightLine);
if ( widthLine > widthTextMax )
widthTextMax = widthLine;
heightTextTotal += heightLine;
}
if ( *pc == wxT('\n') ) {
curLine.Empty();

View File

@@ -798,10 +798,10 @@ bool wxTextCtrl::AcceptsFocus() const
return IsEditable() && wxControl::AcceptsFocus();
}
wxSize wxTextCtrl::DoGetBestSize()
wxSize wxTextCtrl::DoGetBestSize() const
{
int cx, cy;
wxGetCharSize(GetHWND(), &cx, &cy, &GetFont());
wxGetCharSize(GetHWND(), &cx, &cy, (wxFont*)&GetFont());
int wText = DEFAULT_ITEM_WIDTH;

View File

@@ -239,48 +239,6 @@ void wxCondition::Broadcast()
}
}
// ----------------------------------------------------------------------------
// wxCriticalSection implementation
// ----------------------------------------------------------------------------
class wxCriticalSectionInternal
{
public:
// init the critical section object
wxCriticalSectionInternal()
{ }
// free the associated ressources
~wxCriticalSectionInternal()
{ }
private:
};
// ----------------------------------------------------------------------------
// wxCriticalSection implementation
// ----------------------------------------------------------------------------
wxCriticalSection::wxCriticalSection()
{
m_critsect = new wxCriticalSectionInternal;
}
wxCriticalSection::~wxCriticalSection()
{
delete m_critsect;
}
void wxCriticalSection::Enter()
{
::DosEnterCritSec();
}
void wxCriticalSection::Leave()
{
::DosExitCritSec();
}
// ----------------------------------------------------------------------------
// wxThread implementation
// ----------------------------------------------------------------------------

View File

@@ -814,12 +814,6 @@ void wxWindow::DoSetSize(int x, int y,
// TODO:
}
// for a generic window there is no natural best size - just use the current one
wxSize wxWindow::DoGetBestSize()
{
return GetSize();
}
void wxWindow::DoSetClientSize(int width, int height)
{
// TODO: