Nikolay Sivov : comctl32/monthcal: Reduce update rectangle after updating current selection.

Alexandre Julliard julliard at winehq.org
Wed Oct 14 09:01:59 CDT 2009


Module: wine
Branch: master
Commit: 2cc98ef94abd6ece5fd02d0b915aa14dd7269ba5
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=2cc98ef94abd6ece5fd02d0b915aa14dd7269ba5

Author: Nikolay Sivov <bunglehead at gmail.com>
Date:   Tue Oct 13 23:35:19 2009 +0400

comctl32/monthcal: Reduce update rectangle after updating current selection.

---

 dlls/comctl32/monthcal.c |   26 +++++++++++++++++++++-----
 1 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/dlls/comctl32/monthcal.c b/dlls/comctl32/monthcal.c
index ed0f6fe..ee7dc4e 100644
--- a/dlls/comctl32/monthcal.c
+++ b/dlls/comctl32/monthcal.c
@@ -174,7 +174,7 @@ static inline void MONTHCAL_NotifySelect(const MONTHCAL_INFO *infoPtr)
 /* january is 1, december is 12 */
 int MONTHCAL_MonthLength(int month, int year)
 {
-  const int mdays[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 0};
+  const int mdays[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
   /* Wrap around, this eases handling. Getting length only we shouldn't care
      about year change here cause January and December have
      the same day quantity */
@@ -813,7 +813,8 @@ static void MONTHCAL_PaintWeeknumbers(MONTHCAL_INFO *infoPtr, HDC hdc, const PAI
         WARN("Unknown LOCALE_IFIRSTWEEKOFYEAR value %d, defaulting to 0\n", weeknum);
 	mindays = 0;
   }
-  if (infoPtr->curSel.wMonth < 2)
+
+  if (infoPtr->curSel.wMonth == 1)
   {
     /* calculate all those exceptions for january */
     st.wDay = st.wMonth = 1;
@@ -1366,6 +1367,8 @@ MONTHCAL_GetCurSel(const MONTHCAL_INFO *infoPtr, SYSTEMTIME *curSel)
 static LRESULT
 MONTHCAL_SetCurSel(MONTHCAL_INFO *infoPtr, SYSTEMTIME *curSel)
 {
+  SYSTEMTIME prev = infoPtr->curSel;
+
   TRACE("%p\n", curSel);
   if(!curSel) return FALSE;
   if(infoPtr->dwStyle & MCS_MULTISELECT) return FALSE;
@@ -1379,10 +1382,23 @@ MONTHCAL_SetCurSel(MONTHCAL_INFO *infoPtr, SYSTEMTIME *curSel)
   infoPtr->minSel = *curSel;
   infoPtr->maxSel = *curSel;
 
-  infoPtr->curSel = *curSel;
+  /* if selection is still in current month, reduce rectangle */
+  prev.wDay = curSel->wDay;
+  if (MONTHCAL_IsDateEqual(&prev, curSel))
+  {
+    RECT r_prev, r_new;
 
-  /* FIXME: it's possible to reduce rectangle here */
-  InvalidateRect(infoPtr->hwndSelf, NULL, FALSE);
+    /* note that infoPtr->curSel isn't updated yet */
+    MONTHCAL_CalcPosFromDay(infoPtr, &infoPtr->curSel, &r_prev);
+    MONTHCAL_CalcPosFromDay(infoPtr, curSel, &r_new);
+
+    InvalidateRect(infoPtr->hwndSelf, &r_prev, FALSE);
+    InvalidateRect(infoPtr->hwndSelf, &r_new,  FALSE);
+  }
+  else
+    InvalidateRect(infoPtr->hwndSelf, NULL, FALSE);
+
+  infoPtr->curSel = *curSel;
 
   return TRUE;
 }




More information about the wine-cvs mailing list