]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/calctrlg.cpp
Don't send event from ChangeValue
[wxWidgets.git] / src / generic / calctrlg.cpp
index c52a74808ae554f43c51a7e0c75042d687c4c2e3..cb153cce2894629f43e8ad3ee47a4460ee18abba 100644 (file)
@@ -211,7 +211,7 @@ void wxGenericCalendarCtrl::InitColours()
     m_colHighlightFg = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT);
     m_colHighlightBg = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT);
     m_colBackground = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
-    m_colSorrounding = wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT);
+    m_colSurrounding = wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT);
 
     m_colHolidayFg = *wxRED;
     // don't set m_colHolidayBg - by default, same as our bg colour
@@ -789,39 +789,30 @@ wxSize wxGenericCalendarCtrl::DoGetBestSize() const
     wx_const_cast(wxGenericCalendarCtrl *, this)->RecalcGeometry();
 
     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) )
     {
-        // the combobox doesn't report its height correctly (it returns the
-        // height including the drop down list) so don't use it
-        height += m_spinYear->GetBestSize().y;
+        const wxSize bestSizeCombo = m_comboMonth->GetBestSize();
 
+        height += wxMax(bestSizeCombo.y, m_spinYear->GetBestSize().y)
+                    + VERT_MARGIN;
 
-        wxCoord w2 = m_comboMonth->GetBestSize().x + HORZ_MARGIN + GetCharWidth()*6;
-        if (width < w2)
+        wxCoord w2 = bestSizeCombo.x + HORZ_MARGIN + GetCharWidth()*6;
+        if ( width < w2 )
             width = w2;
     }
 
+    wxSize best(width, height);
     if ( !HasFlag(wxBORDER_NONE) )
     {
-        // the border would clip the last line otherwise
-        height += 6;
-        width += 4;
+        best += GetWindowBorderSize();
     }
 
-    wxSize best(width, height);
     CacheBestSize(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)
 {
     int yDiff;
@@ -832,26 +823,17 @@ void wxGenericCalendarCtrl::DoMoveWindow(int x, int y, int width, int height)
         wxSize sizeStatic = m_staticMonth->GetSize();
         wxSize sizeSpin = m_spinYear->GetSize();
 
-        // 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 maxHeight = wxMax(sizeSpin.y, sizeCombo.y);
         int dy = (maxHeight - sizeStatic.y) / 2;
         m_comboMonth->Move(x, 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, requiredSpinHeight);
+        m_spinYear->SetSize(x + xDiff, y, width - xDiff, maxHeight);
         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
     {
@@ -861,36 +843,6 @@ void wxGenericCalendarCtrl::DoMoveWindow(int x, int y, int width, int height)
     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()
 {
     wxClientDC dc(this);
@@ -1092,9 +1044,8 @@ void wxGenericCalendarCtrl::OnPaint(wxPaintEvent& WXUNUSED(event))
 
                 if ( date.GetMonth() != m_date.GetMonth() || !IsDateInRange(date) )
                 {
-                    // surrounding week or out-of-range
-                    // draw "disabled"
-                    dc.SetTextForeground(m_colSorrounding);
+                    // draw the days of adjacent months in different colour
+                    dc.SetTextForeground(m_colSurrounding);
                     changedColours = true;
                 }
                 else
@@ -1500,6 +1451,10 @@ void wxGenericCalendarCtrl::OnClick(wxMouseEvent& event)
             event.Skip();
             break;
     }
+
+    // as we don't (always) skip the message, we're not going to receive the
+    // focus on click by default if we don't do it ourselves
+    SetFocus();
 }
 
 wxCalendarHitTestResult wxGenericCalendarCtrl::HitTest(const wxPoint& pos,