]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/calctrl.cpp
try to fix SF bug 1913671
[wxWidgets.git] / src / msw / calctrl.cpp
index 4a4c4d9ede388d047c251862565e84b65f466caa..2f2feb40a4245112786f7fe894c90f9b64bb248e 100644 (file)
@@ -97,6 +97,8 @@ wxCalendarCtrl::Create(wxWindow *parent,
 
     UpdateMarks();
 
+    Connect(wxEVT_LEFT_DOWN,
+            wxMouseEventHandler(wxCalendarCtrl::MSWOnClick));
     Connect(wxEVT_LEFT_DCLICK,
             wxMouseEventHandler(wxCalendarCtrl::MSWOnDoubleClick));
 
@@ -107,9 +109,8 @@ WXDWORD wxCalendarCtrl::MSWGetStyle(long style, WXDWORD *exstyle) const
 {
     WXDWORD styleMSW = wxCalendarCtrlBase::MSWGetStyle(style, exstyle);
 
-    // right now we don't support any native styles but we should add wx styles
-    // corresponding to MCS_NOTODAY, MCS_NOTODAYCIRCLE and MCS_WEEKNUMBERS
-    // probably (TODO)
+    // right now we don't support all native styles but we should add wx styles
+    // corresponding to MCS_NOTODAY and MCS_NOTODAYCIRCLE probably (TODO)
 
     // for compatibility with the other versions, just turn off today display
     // unconditionally for now
@@ -118,6 +119,9 @@ WXDWORD wxCalendarCtrl::MSWGetStyle(long style, WXDWORD *exstyle) const
     // we also need this style for Mark() to work
     styleMSW |= MCS_DAYSTATE;
 
+    if ( style & wxCAL_SHOW_WEEK_NUMBERS )
+       styleMSW |= MCS_WEEKNUMBERS;
+
     return styleMSW;
 }
 
@@ -328,7 +332,7 @@ void wxCalendarCtrl::UpdateMarks()
 {
     MONTHDAYSTATE states[3];
     const int nMonths = MonthCal_GetMonthRange(GetHwnd(), GMR_DAYSTATE, NULL);
-    wxCHECK_RET( nMonths <= WXSIZEOF(states), "unexpected months range" );
+    wxCHECK_RET( nMonths <= (int)WXSIZEOF(states), "unexpected months range" );
 
     for ( int i = 0; i < nMonths; i++ )
         states[i] = m_marks;
@@ -400,4 +404,13 @@ void wxCalendarCtrl::MSWOnDoubleClick(wxMouseEvent& event)
     event.Skip();
 }
 
+void wxCalendarCtrl::MSWOnClick(wxMouseEvent& event)
+{
+    // for some reason, the control doesn't get focus on its own when the user
+    // clicks in it
+    SetFocus();
+
+    event.Skip();
+}
+
 #endif // wxUSE_CALENDARCTRL