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

@@ -59,7 +59,7 @@ protected:
// send a notification event, return TRUE if processed
bool SendClickEvent();
virtual wxSize DoGetBestSize();
virtual wxSize DoGetBestSize() const;
};
#endif

View File

@@ -53,7 +53,7 @@ class WXDLLEXPORT wxCheckBox: public wxControl
WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
protected:
virtual wxSize DoGetBestSize();
virtual wxSize DoGetBestSize() const;
};
class WXDLLEXPORT wxBitmapCheckBox: public wxCheckBox

View File

@@ -70,7 +70,7 @@ protected:
virtual wxClientData* DoGetItemClientObject( int n ) const;
// OS2 implementation
virtual wxSize DoGetBestSize();
virtual wxSize DoGetBestSize() const;
virtual void DoSetSize(int x, int y,
int width, int height,
int sizeFlags = wxSIZE_AUTO);

View File

@@ -63,7 +63,7 @@ protected:
// For controls like radiobuttons which are really composite
wxList m_subControls;
virtual wxSize DoGetBestSize();
virtual wxSize DoGetBestSize() const;
// create the control of the given class with the given style, returns FALSE
// if creation failed

View File

@@ -123,7 +123,7 @@ protected:
int m_noItems;
int m_selected;
virtual wxSize DoGetBestSize();
virtual wxSize DoGetBestSize() const;
#if wxUSE_OWNER_DRAWN
// control items

View File

@@ -64,7 +64,7 @@ public:
);
protected:
virtual wxSize DoGetBestSize();
virtual wxSize DoGetBestSize() const;
private:
DECLARE_DYNAMIC_CLASS(wxSpinButton)
};

View File

@@ -71,7 +71,7 @@ protected:
wxBitmap *bitmap;
} m_image;
virtual wxSize DoGetBestSize();
virtual wxSize DoGetBestSize() const;
};
#endif

View File

@@ -58,7 +58,7 @@ class WXDLLEXPORT wxStaticBox: public wxControl
virtual bool AcceptsFocus() const { return FALSE; }
protected:
virtual wxSize DoGetBestSize();
virtual wxSize DoGetBestSize() const;
private:
DECLARE_EVENT_TABLE()

View File

@@ -56,7 +56,7 @@ class WXDLLEXPORT wxStaticText: public wxControl
virtual MRESULT OS2WindowProc(HWND hwnd, WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
protected:
virtual wxSize DoGetBestSize();
virtual wxSize DoGetBestSize() const;
};
#endif

View File

@@ -146,7 +146,7 @@ protected:
// limit is big enough)
void AdjustSpaceLimit();
virtual wxSize DoGetBestSize();
virtual wxSize DoGetBestSize() const;
private:
DECLARE_EVENT_TABLE()

View File

@@ -524,10 +524,6 @@ protected:
,int nHeight
);
// get the size which best suits the window: e.g., for a static text it
// will be the width and height of the text
virtual wxSize DoGetBestSize(void);
// move the window to the specified location and resize it: this is called
// from both DoSetSize() and DoSetClientSize() and would usually just call
// ::MoveWindow() except for composite controls which will want to arrange

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') ) {
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: