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 // send a notification event, return TRUE if processed
bool SendClickEvent(); bool SendClickEvent();
virtual wxSize DoGetBestSize(); virtual wxSize DoGetBestSize() const;
}; };
#endif #endif

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -58,7 +58,7 @@ class WXDLLEXPORT wxStaticBox: public wxControl
virtual bool AcceptsFocus() const { return FALSE; } virtual bool AcceptsFocus() const { return FALSE; }
protected: protected:
virtual wxSize DoGetBestSize(); virtual wxSize DoGetBestSize() const;
private: private:
DECLARE_EVENT_TABLE() 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); virtual MRESULT OS2WindowProc(HWND hwnd, WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
protected: protected:
virtual wxSize DoGetBestSize(); virtual wxSize DoGetBestSize() const;
}; };
#endif #endif

View File

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

View File

@@ -524,10 +524,6 @@ protected:
,int nHeight ,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 // move the window to the specified location and resize it: this is called
// from both DoSetSize() and DoSetClientSize() and would usually just call // from both DoSetSize() and DoSetClientSize() and would usually just call
// ::MoveWindow() except for composite controls which will want to arrange // ::MoveWindow() except for composite controls which will want to arrange

View File

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

View File

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

View File

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

View File

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

View File

@@ -81,7 +81,7 @@ bool wxControl::OS2CreateControl(const wxChar *classname, WXDWORD style)
return TRUE; return TRUE;
} }
wxSize wxControl::DoGetBestSize() wxSize wxControl::DoGetBestSize() const
{ {
return wxSize(DEFAULT_ITEM_WIDTH, DEFAULT_ITEM_HEIGHT); 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 // find the widest string
int wLine; int wLine;
@@ -626,7 +626,7 @@ wxSize wxListBox::DoGetBestSize()
// the listbox should be slightly larger than the widest string // the listbox should be slightly larger than the widest string
int cx, cy; int cx, cy;
wxGetCharSize(GetHWND(), &cx, &cy, &GetFont()); wxGetCharSize(GetHWND(), &cx, &cy, (wxFont*)&GetFont());
wListbox += 3*cx; wListbox += 3*cx;

View File

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

View File

@@ -100,7 +100,7 @@ void wxStaticBitmap::Free()
m_image.icon = NULL; m_image.icon = NULL;
} }
wxSize wxStaticBitmap::DoGetBestSize() wxSize wxStaticBitmap::DoGetBestSize() const
{ {
// reuse the current size (as wxWindow does) instead of using some // reuse the current size (as wxWindow does) instead of using some
// arbitrary default size (as wxControl, our immediate base class, does) // 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; return FALSE;
} }
wxSize wxStaticBox::DoGetBestSize() wxSize wxStaticBox::DoGetBestSize() const
{ {
int cx, cy; int cx, cy;
wxGetCharSize(GetHWND(), &cx, &cy, &GetFont()); wxGetCharSize(GetHWND(), &cx, &cy, (wxFont*)&GetFont());
int wBox; int wBox;
GetTextExtent(wxGetWindowText(m_hWnd), &wBox, &cy); GetTextExtent(wxGetWindowText(m_hWnd), &wBox, &cy);

View File

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

View File

@@ -798,10 +798,10 @@ bool wxTextCtrl::AcceptsFocus() const
return IsEditable() && wxControl::AcceptsFocus(); return IsEditable() && wxControl::AcceptsFocus();
} }
wxSize wxTextCtrl::DoGetBestSize() wxSize wxTextCtrl::DoGetBestSize() const
{ {
int cx, cy; int cx, cy;
wxGetCharSize(GetHWND(), &cx, &cy, &GetFont()); wxGetCharSize(GetHWND(), &cx, &cy, (wxFont*)&GetFont());
int wText = DEFAULT_ITEM_WIDTH; 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 // wxThread implementation
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@@ -814,12 +814,6 @@ void wxWindow::DoSetSize(int x, int y,
// TODO: // 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) void wxWindow::DoSetClientSize(int width, int height)
{ {
// TODO: // TODO: