correct positioning of the control and removed workarounds for old MSW bugs

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@53072 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2008-04-07 01:06:57 +00:00
parent 5cb947fdc2
commit c3a899dd92
2 changed files with 12 additions and 62 deletions

View File

@@ -168,9 +168,6 @@ public:
protected: protected:
// override some base class virtuals // override some base class virtuals
virtual wxSize DoGetBestSize() const; virtual wxSize DoGetBestSize() const;
virtual void DoGetPosition(int *x, int *y) const;
virtual void DoGetSize(int *width, int *height) const;
virtual void DoSetSize(int x, int y, int width, int height, int sizeFlags);
virtual void DoMoveWindow(int x, int y, int width, int height); virtual void DoMoveWindow(int x, int y, int width, int height);
private: private:
@@ -256,6 +253,7 @@ private:
// typed in by the user // typed in by the user
void SetUserChangedYear() { m_userChangedYear = true; } void SetUserChangedYear() { m_userChangedYear = true; }
// the subcontrols // the subcontrols
wxStaticText *m_staticMonth; wxStaticText *m_staticMonth;
wxComboBox *m_comboMonth; wxComboBox *m_comboMonth;

View File

@@ -789,39 +789,30 @@ wxSize wxGenericCalendarCtrl::DoGetBestSize() const
wx_const_cast(wxGenericCalendarCtrl *, this)->RecalcGeometry(); wx_const_cast(wxGenericCalendarCtrl *, this)->RecalcGeometry();
wxCoord width = 7*m_widthCol, wxCoord width = 7*m_widthCol,
height = 7*m_heightRow + m_rowOffset + VERT_MARGIN; height = 7*m_heightRow + m_rowOffset;
if ( !HasFlag(wxCAL_SEQUENTIAL_MONTH_SELECTION) ) if ( !HasFlag(wxCAL_SEQUENTIAL_MONTH_SELECTION) )
{ {
// the combobox doesn't report its height correctly (it returns the const wxSize bestSizeCombo = m_comboMonth->GetBestSize();
// height including the drop down list) so don't use it
height += m_spinYear->GetBestSize().y;
height += wxMax(bestSizeCombo.y, m_spinYear->GetBestSize().y)
+ VERT_MARGIN;
wxCoord w2 = m_comboMonth->GetBestSize().x + HORZ_MARGIN + GetCharWidth()*6; wxCoord w2 = bestSizeCombo.x + HORZ_MARGIN + GetCharWidth()*6;
if ( width < w2 ) if ( width < w2 )
width = w2; width = w2;
} }
wxSize best(width, height);
if ( !HasFlag(wxBORDER_NONE) ) if ( !HasFlag(wxBORDER_NONE) )
{ {
// the border would clip the last line otherwise best += GetWindowBorderSize();
height += 6;
width += 4;
} }
wxSize best(width, height);
CacheBestSize(best); CacheBestSize(best);
return best; return best;
} }
void wxGenericCalendarCtrl::DoSetSize(int x, int y,
int width, int height,
int sizeFlags)
{
wxControl::DoSetSize(x, y, width, height, sizeFlags);
}
void wxGenericCalendarCtrl::DoMoveWindow(int x, int y, int width, int height) void wxGenericCalendarCtrl::DoMoveWindow(int x, int y, int width, int height)
{ {
int yDiff; int yDiff;
@@ -832,26 +823,17 @@ void wxGenericCalendarCtrl::DoMoveWindow(int x, int y, int width, int height)
wxSize sizeStatic = m_staticMonth->GetSize(); wxSize sizeStatic = m_staticMonth->GetSize();
wxSize sizeSpin = m_spinYear->GetSize(); wxSize sizeSpin = m_spinYear->GetSize();
// wxMSW sometimes reports the wrong combo height, int maxHeight = wxMax(sizeSpin.y, sizeCombo.y);
// so on this platform we'll use the spin control
// height instead.
#ifdef __WXMSW__
int maxHeight = sizeSpin.y;
int requiredSpinHeight = -1;
#else
int maxHeight = sizeCombo.y;
int requiredSpinHeight = sizeCombo.y;
#endif
int dy = (maxHeight - sizeStatic.y) / 2; int dy = (maxHeight - sizeStatic.y) / 2;
m_comboMonth->Move(x, y); m_comboMonth->Move(x, y);
m_staticMonth->SetSize(x, y + dy, sizeCombo.x, -1, sizeStatic.y); m_staticMonth->SetSize(x, y + dy, sizeCombo.x, -1, sizeStatic.y);
int xDiff = sizeCombo.x + HORZ_MARGIN; int xDiff = sizeCombo.x + HORZ_MARGIN;
m_spinYear->SetSize(x + xDiff, y, width - xDiff, requiredSpinHeight); m_spinYear->SetSize(x + xDiff, y, width - xDiff, maxHeight);
m_staticYear->SetSize(x + xDiff, y + dy, width - xDiff, sizeStatic.y); m_staticYear->SetSize(x + xDiff, y + dy, width - xDiff, sizeStatic.y);
yDiff = wxMax(sizeSpin.y, maxHeight) + VERT_MARGIN; yDiff = maxHeight + VERT_MARGIN;
} }
else // no controls on the top else // no controls on the top
{ {
@@ -861,36 +843,6 @@ void wxGenericCalendarCtrl::DoMoveWindow(int x, int y, int width, int height)
wxControl::DoMoveWindow(x, y + yDiff, width, height - yDiff); wxControl::DoMoveWindow(x, y + yDiff, width, height - yDiff);
} }
void wxGenericCalendarCtrl::DoGetPosition(int *x, int *y) const
{
wxControl::DoGetPosition(x, y);
#ifndef __WXPM__
if ( !HasFlag(wxCAL_SEQUENTIAL_MONTH_SELECTION) && GetMonthControl() )
{
// our real top corner is not in this position
if ( y )
{
*y -= GetMonthControl()->GetSize().y + VERT_MARGIN;
}
}
#endif
}
void wxGenericCalendarCtrl::DoGetSize(int *width, int *height) const
{
wxControl::DoGetSize(width, height);
#ifndef __WXPM__
if ( !HasFlag(wxCAL_SEQUENTIAL_MONTH_SELECTION) )
{
// our real height is bigger
if ( height && GetMonthControl())
{
*height += GetMonthControl()->GetSize().y + VERT_MARGIN;
}
}
#endif
}
void wxGenericCalendarCtrl::RecalcGeometry() void wxGenericCalendarCtrl::RecalcGeometry()
{ {
wxClientDC dc(this); wxClientDC dc(this);