Nikolay Sivov : comctl32/monthcal: Move partially visible months painting outside of calendar loop.

Alexandre Julliard julliard at winehq.org
Mon Mar 28 14:22:00 CDT 2011


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

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Sat Mar 26 02:23:01 2011 +0300

comctl32/monthcal: Move partially visible months painting outside of calendar loop.

---

 dlls/comctl32/monthcal.c |   87 ++++++++++++++++++++++++----------------------
 1 files changed, 45 insertions(+), 42 deletions(-)

diff --git a/dlls/comctl32/monthcal.c b/dlls/comctl32/monthcal.c
index b973ff9..745ccbd 100644
--- a/dlls/comctl32/monthcal.c
+++ b/dlls/comctl32/monthcal.c
@@ -946,6 +946,46 @@ static void MONTHCAL_PaintFocusAndCircle(const MONTHCAL_INFO *infoPtr, HDC hdc,
   }
 }
 
+/* months before first calendar month and after last calendar month */
+static void MONTHCAL_PaintLeadTrailMonths(const MONTHCAL_INFO *infoPtr, HDC hdc, const PAINTSTRUCT *ps)
+{
+  INT prev_month, mask, length;
+  SYSTEMTIME st_max, st;
+
+  if (infoPtr->dwStyle & MCS_NOTRAILINGDATES) return;
+
+  SetTextColor(hdc, infoPtr->colors[MCSC_TRAILINGTEXT]);
+
+  prev_month = infoPtr->calendars[0].month.wMonth - 1;
+
+  /* draw prev month */
+  MONTHCAL_GetMinDate(infoPtr, &st);
+  mask = 1 << (st.wDay-1);
+  /* December and January both 31 days long, so no worries if wrapped */
+  length = MONTHCAL_MonthLength(infoPtr->calendars[0].month.wMonth - 1,
+                                infoPtr->calendars[0].month.wYear);
+  while(st.wDay <= length)
+  {
+      MONTHCAL_DrawDay(infoPtr, hdc, &st, infoPtr->monthdayState[0] & mask, ps);
+      mask <<= 1;
+      st.wDay++;
+  }
+
+  /* draw next month */
+  st = infoPtr->calendars[infoPtr->cal_num-1].month;
+  st.wDay = 1;
+  MONTHCAL_GetNextMonth(&st);
+  MONTHCAL_GetMaxDate(infoPtr, &st_max);
+  mask = 1;
+
+  while(st.wDay <= st_max.wDay)
+  {
+      MONTHCAL_DrawDay(infoPtr, hdc, &st, infoPtr->monthdayState[2] & mask, ps);
+      mask <<= 1;
+      st.wDay++;
+  }
+}
+
 /* paint a calendar area */
 static void MONTHCAL_PaintCalendar(const MONTHCAL_INFO *infoPtr, HDC hdc, const PAINTSTRUCT *ps, INT calIdx)
 {
@@ -978,7 +1018,7 @@ static void MONTHCAL_PaintCalendar(const MONTHCAL_INFO *infoPtr, HDC hdc, const
   infoPtr->calendars[calIdx].wdays.left = infoPtr->calendars[calIdx].days.left =
       infoPtr->calendars[calIdx].weeknums.right;
 
-  /* 1. draw day abbreviations */
+  /* draw day abbreviations */
   SelectObject(hdc, infoPtr->hFont);
   SetBkColor(hdc, infoPtr->colors[MCSC_MONTHBK]);
   SetTextColor(hdc, infoPtr->colors[MCSC_TRAILINGTEXT]);
@@ -993,47 +1033,7 @@ static void MONTHCAL_PaintCalendar(const MONTHCAL_INFO *infoPtr, HDC hdc, const
     OffsetRect(&r, infoPtr->width_increment, 0);
   }
 
-  /* 2. previous and next months */
-  if (!(infoPtr->dwStyle & MCS_NOTRAILINGDATES) && (calIdx == 0 || calIdx == infoPtr->cal_num - 1))
-  {
-    SYSTEMTIME st_max;
-
-    SetTextColor(hdc, infoPtr->colors[MCSC_TRAILINGTEXT]);
-
-    /* draw prev month */
-    if (calIdx == 0)
-    {
-      MONTHCAL_GetMinDate(infoPtr, &st);
-      mask = 1 << (st.wDay-1);
-      length = MONTHCAL_MonthLength(prev_month, date->wYear);
-
-      while(st.wDay <= length)
-      {
-        MONTHCAL_DrawDay(infoPtr, hdc, &st, infoPtr->monthdayState[0] & mask, ps);
-        mask <<= 1;
-        st.wDay++;
-      }
-    }
-
-    /* draw next month */
-    if (calIdx == infoPtr->cal_num - 1)
-    {
-      st = *date;
-      st.wDay = 1;
-      MONTHCAL_GetNextMonth(&st);
-      MONTHCAL_GetMaxDate(infoPtr, &st_max);
-      mask = 1;
-
-      while(st.wDay <= st_max.wDay)
-      {
-        MONTHCAL_DrawDay(infoPtr, hdc, &st, infoPtr->monthdayState[2] & mask, ps);
-        mask <<= 1;
-        st.wDay++;
-      }
-    }
-  }
-
-  /* 3. current month */
+  /* draw current month */
   SetTextColor(hdc, infoPtr->colors[MCSC_TEXT]);
   st = *date;
   st.wDay = 1;
@@ -1075,6 +1075,9 @@ static void MONTHCAL_Refresh(MONTHCAL_INFO *infoPtr, HDC hdc, const PAINTSTRUCT
     MONTHCAL_PaintWeeknumbers(infoPtr, hdc, ps, i);
   }
 
+  /* partially visible months */
+  MONTHCAL_PaintLeadTrailMonths(infoPtr, hdc, ps);
+
   /* focus and today rectangle */
   MONTHCAL_PaintFocusAndCircle(infoPtr, hdc, ps);
 




More information about the wine-cvs mailing list