X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9576de5c8ba98414b940e319e37cb8cc762596ca..9a0a58f5afb88fc72f04333e32208e3b3bf2ccc5:/src/generic/calctrl.cpp diff --git a/src/generic/calctrl.cpp b/src/generic/calctrl.cpp index 1b4e84226f..a76d41f1b8 100644 --- a/src/generic/calctrl.cpp +++ b/src/generic/calctrl.cpp @@ -202,9 +202,6 @@ bool wxCalendarCtrl::Create(wxWindow *parent, long style, const wxString& name) { - // set the style first to avoid assert in our SetWindowStyleFlag() - m_windowStyle = style; - if ( !wxControl::Create(parent, id, pos, size, style | wxCLIP_CHILDREN | wxWANTS_CHARS | wxFULL_REPAINT_ON_RESIZE, wxDefaultValidator, name) ) @@ -256,6 +253,14 @@ wxCalendarCtrl::~wxCalendarCtrl() { delete m_attrs[n]; } + + if ( !HasFlag(wxCAL_SEQUENTIAL_MONTH_SELECTION) ) + { + delete m_comboMonth; + delete m_staticMonth; + delete m_spinYear; + delete m_staticYear; + } } void wxCalendarCtrl::SetWindowStyleFlag(long style) @@ -1479,21 +1484,17 @@ wxCalendarHitTestResult wxCalendarCtrl::HitTest(const wxPoint& pos, wxDateTime::WeekDay *wd) { RecalcGeometry(); - // use the correct x-pos - wxCoord x0 = wxMax((GetSize().x - m_widthCol*7) /2, 0); - wxPoint pos_corr = pos; - pos_corr.x -= x0; - wxCoord y = pos_corr.y; + // the position where the calendar really begins + wxCoord x0 = wxMax((GetSize().x - m_widthCol*7)/2, 0); -/////////////////////////////////////////////////////////////////////////////////////////////////////// - if ( (GetWindowStyle() & wxCAL_SEQUENTIAL_MONTH_SELECTION) ) + if ( HasFlag(wxCAL_SEQUENTIAL_MONTH_SELECTION) ) { // Header: month // we need to find out if the hit is on left arrow, on month or on right arrow // left arrow? - if ( wxRegion(m_leftArrowRect).Contains(pos_corr) == wxInRegion ) + if ( m_leftArrowRect.Contains(pos) ) { if ( date ) { @@ -1510,7 +1511,7 @@ wxCalendarHitTestResult wxCalendarCtrl::HitTest(const wxPoint& pos, return wxCAL_HITTEST_DECMONTH; } - if ( wxRegion(m_rightArrowRect).Contains(pos_corr) == wxInRegion ) + if ( m_rightArrowRect.Contains(pos) ) { if ( date ) { @@ -1529,14 +1530,11 @@ wxCalendarHitTestResult wxCalendarCtrl::HitTest(const wxPoint& pos, } -/////////////////////////////////////////////////////////////////////////////////////////////////////// - // Header: Days - - int wday = pos_corr.x / m_widthCol; -// if ( y < m_heightRow ) - if ( y < (m_heightRow + m_rowOffset) ) + // header: week days + int wday = (pos.x - x0) / m_widthCol; + if ( pos.y < (m_heightRow + m_rowOffset) ) { - if ( y > m_rowOffset ) + if ( pos.y > m_rowOffset ) { if ( wd ) { @@ -1556,8 +1554,7 @@ wxCalendarHitTestResult wxCalendarCtrl::HitTest(const wxPoint& pos, } } -// int week = (y - m_heightRow) / m_heightRow; - int week = (y - (m_heightRow + m_rowOffset)) / m_heightRow; + int week = (pos.y - (m_heightRow + m_rowOffset)) / m_heightRow; if ( week >= 6 || wday >= 7 ) { return wxCAL_HITTEST_NOWHERE;