]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/calctrl.cpp
Rebake after recguard.h added to bakefiles
[wxWidgets.git] / src / generic / calctrl.cpp
index 13645353de2363fb6805bccbfacf970ed3e8921e..f2b7d1d1f624af9344c6714c7e2ab0ba72bf12cd 100644 (file)
@@ -755,9 +755,9 @@ wxSize wxCalendarCtrl::DoGetBestSize() const
         height += m_spinYear->GetBestSize().y;
 
 
-       wxCoord w2= m_comboMonth->GetBestSize().x + HORZ_MARGIN + GetCharWidth()*6;
-       if (width < w2)
-         width=w2;
+        wxCoord w2 = m_comboMonth->GetBestSize().x + HORZ_MARGIN + GetCharWidth()*6;
+        if (width < w2)
+            width = w2;
     }
 
     if ( !HasFlag(wxBORDER_NONE) )
@@ -841,9 +841,20 @@ void wxCalendarCtrl::RecalcGeometry()
 
     dc.SetFont(GetFont());
 
-    // determine the column width (we assume that the weekday names are always
-    // wider (in any language) than the numbers)
+    // determine the column width (weekday names are not necessarily wider
+    // than the numbers (in some languages), so let's not assume that they are)
     m_widthCol = 0;
+    for ( int day = 10; day <= 31; day++)
+    {
+        wxCoord width;
+        dc.GetTextExtent(wxString::Format(wxT("%d"), day), &width, &m_heightRow);
+        if ( width > m_widthCol )
+        {
+            // 1.5 times the width gives nice margins even if the weekday
+            // names are short
+            m_widthCol = width+width/2;
+        }
+    }
     wxDateTime::WeekDay wd;
     for ( wd = wxDateTime::Sun; wd < wxDateTime::Inv_WeekDay; wxNextWDay(wd) )
     {
@@ -1221,13 +1232,13 @@ void wxCalendarCtrl::HighlightRange(wxPaintDC* pDC, const wxDateTime& fromdate,
             if ( ( (tw - fw) == 1 ) && ( td < fd ) )
             {
                 // special case: interval 7 days or less not in same week
-                // split in two seperate intervals
+                // split in two separate intervals
                 wxDateTime tfd = fromdate + wxDateSpan::Days(7-fd);
                 wxDateTime ftd = tfd + wxDateSpan::Day();
 #if DEBUG_PAINT
-                wxLogDebug("Highlight: Seperate segments");
+                wxLogDebug("Highlight: Separate segments");
 #endif
-                // draw seperately
+                // draw separately
                 HighlightRange(pDC, fromdate, tfd, pPen, pBrush);
                 HighlightRange(pDC, ftd, todate, pPen, pBrush);
             }
@@ -1771,4 +1782,3 @@ wxCalendarCtrl::GetClassDefaultAttributes(wxWindowVariant variant)
 }
 
 #endif // wxUSE_CALENDARCTRL
-