]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/calctrl.cpp
[ 1509599 ] 'Split pickers page in widgets sample' with more icons and rebaking.
[wxWidgets.git] / src / generic / calctrl.cpp
index aa8032ad76d8702c2ae732ddaea43413522c895b..e5e98717bc626f66e9eebd949c3fbf953bbd1b87 100644 (file)
@@ -788,21 +788,32 @@ void wxCalendarCtrl::DoMoveWindow(int x, int y, int width, int height)
 {
     int yDiff;
 
-    if ( !HasFlag(wxCAL_SEQUENTIAL_MONTH_SELECTION) )
+    if ( !HasFlag(wxCAL_SEQUENTIAL_MONTH_SELECTION) && m_staticMonth )
     {
         wxSize sizeCombo = m_comboMonth->GetSize();
         wxSize sizeStatic = m_staticMonth->GetSize();
         wxSize sizeSpin = m_spinYear->GetSize();
-        int dy = (sizeCombo.y - sizeStatic.y) / 2;
+
+        // wxMSW sometimes reports the wrong combo height,
+        // 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;
         m_comboMonth->Move(x, y);
-        m_staticMonth->SetSize(x, y + dy, sizeCombo.x, sizeStatic.y);
+        m_staticMonth->SetSize(x, y + dy, sizeCombo.x, -1, sizeStatic.y);
 
         int xDiff = sizeCombo.x + HORZ_MARGIN;
 
-        m_spinYear->SetSize(x + xDiff, y, width - xDiff, sizeCombo.y);
+        m_spinYear->SetSize(x + xDiff, y, width - xDiff, requiredSpinHeight);
         m_staticYear->SetSize(x + xDiff, y + dy, width - xDiff, sizeStatic.y);
 
-        yDiff = wxMax(sizeSpin.y, sizeCombo.y) + VERT_MARGIN;
+        yDiff = wxMax(sizeSpin.y, maxHeight) + VERT_MARGIN;
     }
     else // no controls on the top
     {
@@ -816,7 +827,7 @@ void wxCalendarCtrl::DoGetPosition(int *x, int *y) const
 {
     wxControl::DoGetPosition(x, y);
 
-    if ( !(GetWindowStyle() & wxCAL_SEQUENTIAL_MONTH_SELECTION) )
+    if ( !HasFlag(wxCAL_SEQUENTIAL_MONTH_SELECTION) && GetMonthControl() )
     {
         // our real top corner is not in this position
         if ( y )
@@ -1211,7 +1222,7 @@ void wxCalendarCtrl::RefreshDate(const wxDateTime& date)
     Refresh(true, &rect);
 }
 
-void wxCalendarCtrl::HighlightRange(wxPaintDC* pDC, const wxDateTime& fromdate, const wxDateTime& todate, wxPen* pPen, wxBrush* pBrush)
+void wxCalendarCtrl::HighlightRange(wxPaintDC* pDC, const wxDateTime& fromdate, const wxDateTime& todate, const wxPen* pPen, const wxBrush* pBrush)
 {
     // Highlights the given range using pen and brush
     // Does nothing if todate < fromdate
@@ -1451,8 +1462,12 @@ 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.y;
+    wxCoord y = pos_corr.y;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////////
     if ( (GetWindowStyle() & wxCAL_SEQUENTIAL_MONTH_SELECTION) )
@@ -1461,7 +1476,7 @@ wxCalendarHitTestResult wxCalendarCtrl::HitTest(const wxPoint& pos,
 
         // 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) == wxInRegion )
+        if ( wxRegion(m_leftArrowRect).Contains(pos_corr) == wxInRegion )
         {
             if ( date )
             {
@@ -1478,7 +1493,7 @@ wxCalendarHitTestResult wxCalendarCtrl::HitTest(const wxPoint& pos,
             return wxCAL_HITTEST_DECMONTH;
         }
 
-        if ( wxRegion(m_rightArrowRect).Contains(pos) == wxInRegion )
+        if ( wxRegion(m_rightArrowRect).Contains(pos_corr) == wxInRegion )
         {
             if ( date )
             {
@@ -1500,9 +1515,7 @@ wxCalendarHitTestResult wxCalendarCtrl::HitTest(const wxPoint& pos,
 ///////////////////////////////////////////////////////////////////////////////////////////////////////
     // Header: Days
 
-    wxCoord x0 = wxMax( (GetSize().x - m_widthCol*7) /2 , 0 );
-
-    int wday = ( pos.x - x0 ) / m_widthCol;
+    int wday = pos_corr.x / m_widthCol;
 //    if ( y < m_heightRow )
     if ( y < (m_heightRow + m_rowOffset) )
     {
@@ -1653,13 +1666,13 @@ void wxCalendarCtrl::OnChar(wxKeyEvent& event)
             }
             break;
 
-        case WXK_PRIOR:
+        case WXK_PAGEUP:
             target = m_date - wxDateSpan::Month();
             ChangeMonth(&target);
             SetDateAndNotify(target); // always
             break;
 
-        case WXK_NEXT:
+        case WXK_PAGEDOWN:
             target = m_date + wxDateSpan::Month();
             ChangeMonth(&target);
             SetDateAndNotify(target); // always