Commit b83d9b32 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

comctl32/monthcal: Fix hittesting in blank areas of multiple calendars case.

parent ba69e780
...@@ -1679,7 +1679,7 @@ static LRESULT ...@@ -1679,7 +1679,7 @@ static LRESULT
MONTHCAL_HitTest(const MONTHCAL_INFO *infoPtr, MCHITTESTINFO *lpht) MONTHCAL_HitTest(const MONTHCAL_INFO *infoPtr, MCHITTESTINFO *lpht)
{ {
MCHITTESTINFO htinfo; MCHITTESTINFO htinfo;
SYSTEMTIME ht_month; SYSTEMTIME *ht_month;
INT day, calIdx; INT day, calIdx;
if(!lpht || lpht->cbSize < MCHITTESTINFO_V1_SIZE) return -1; if(!lpht || lpht->cbSize < MCHITTESTINFO_V1_SIZE) return -1;
...@@ -1718,8 +1718,6 @@ MONTHCAL_HitTest(const MONTHCAL_INFO *infoPtr, MCHITTESTINFO *lpht) ...@@ -1718,8 +1718,6 @@ MONTHCAL_HitTest(const MONTHCAL_INFO *infoPtr, MCHITTESTINFO *lpht)
return fill_hittest_info(&htinfo, lpht); return fill_hittest_info(&htinfo, lpht);
} }
ht_month = infoPtr->calendars[calIdx].month;
/* are we in the header? */ /* are we in the header? */
if (PtInRect(&infoPtr->calendars[calIdx].title, lpht->pt)) { if (PtInRect(&infoPtr->calendars[calIdx].title, lpht->pt)) {
/* FIXME: buttons hittesting could be optimized cause maximum /* FIXME: buttons hittesting could be optimized cause maximum
...@@ -1756,57 +1754,66 @@ MONTHCAL_HitTest(const MONTHCAL_INFO *infoPtr, MCHITTESTINFO *lpht) ...@@ -1756,57 +1754,66 @@ MONTHCAL_HitTest(const MONTHCAL_INFO *infoPtr, MCHITTESTINFO *lpht)
return fill_hittest_info(&htinfo, lpht); return fill_hittest_info(&htinfo, lpht);
} }
/* days area (including week days and week numbers */ ht_month = &infoPtr->calendars[calIdx].month;
/* days area (including week days and week numbers) */
day = MONTHCAL_GetDayFromPos(infoPtr, lpht->pt, calIdx); day = MONTHCAL_GetDayFromPos(infoPtr, lpht->pt, calIdx);
if (PtInRect(&infoPtr->calendars[calIdx].wdays, lpht->pt)) if (PtInRect(&infoPtr->calendars[calIdx].wdays, lpht->pt))
{ {
htinfo.uHit = MCHT_CALENDARDAY; htinfo.uHit = MCHT_CALENDARDAY;
htinfo.iOffset = calIdx; htinfo.iOffset = calIdx;
htinfo.st.wYear = ht_month.wYear; htinfo.st.wYear = ht_month->wYear;
htinfo.st.wMonth = (day < 1) ? ht_month.wMonth -1 : ht_month.wMonth; htinfo.st.wMonth = (day < 1) ? ht_month->wMonth -1 : ht_month->wMonth;
htinfo.st.wDay = (day < 1) ? htinfo.st.wDay = (day < 1) ?
MONTHCAL_MonthLength(ht_month.wMonth-1, ht_month.wYear) - day : day; MONTHCAL_MonthLength(ht_month->wMonth-1, ht_month->wYear) - day : day;
MONTHCAL_GetDayPos(infoPtr, &htinfo.st, &htinfo.iCol, &htinfo.iRow, calIdx); MONTHCAL_GetDayPos(infoPtr, &htinfo.st, &htinfo.iCol, &htinfo.iRow, calIdx);
} }
else if(PtInRect(&infoPtr->calendars[calIdx].weeknums, lpht->pt)) else if(PtInRect(&infoPtr->calendars[calIdx].weeknums, lpht->pt))
{ {
htinfo.uHit = MCHT_CALENDARWEEKNUM; htinfo.uHit = MCHT_CALENDARWEEKNUM;
htinfo.st.wYear = ht_month.wYear; htinfo.st.wYear = ht_month->wYear;
htinfo.iOffset = calIdx; htinfo.iOffset = calIdx;
if (day < 1) if (day < 1)
{ {
htinfo.st.wMonth = ht_month.wMonth - 1; htinfo.st.wMonth = ht_month->wMonth - 1;
htinfo.st.wDay = MONTHCAL_MonthLength(ht_month.wMonth-1, ht_month.wYear) - day; htinfo.st.wDay = MONTHCAL_MonthLength(ht_month->wMonth-1, ht_month->wYear) - day;
} }
else if (day > MONTHCAL_MonthLength(ht_month.wMonth, ht_month.wYear)) else if (day > MONTHCAL_MonthLength(ht_month->wMonth, ht_month->wYear))
{ {
htinfo.st.wMonth = ht_month.wMonth + 1; htinfo.st.wMonth = ht_month->wMonth + 1;
htinfo.st.wDay = day - MONTHCAL_MonthLength(ht_month.wMonth, ht_month.wYear); htinfo.st.wDay = day - MONTHCAL_MonthLength(ht_month->wMonth, ht_month->wYear);
} }
else else
{ {
htinfo.st.wMonth = ht_month.wMonth; htinfo.st.wMonth = ht_month->wMonth;
htinfo.st.wDay = day; htinfo.st.wDay = day;
} }
} }
else if(PtInRect(&infoPtr->calendars[calIdx].days, lpht->pt)) else if(PtInRect(&infoPtr->calendars[calIdx].days, lpht->pt))
{ {
htinfo.iOffset = calIdx; htinfo.iOffset = calIdx;
htinfo.st.wYear = ht_month.wYear; htinfo.st.wYear = ht_month->wYear;
htinfo.st.wMonth = ht_month.wMonth; htinfo.st.wMonth = ht_month->wMonth;
if (day < 1) /* previous month only valid for first calendar */
if (day < 1 && calIdx == 0)
{ {
htinfo.uHit = MCHT_CALENDARDATEPREV; htinfo.uHit = MCHT_CALENDARDATEPREV;
MONTHCAL_GetPrevMonth(&htinfo.st); MONTHCAL_GetPrevMonth(&htinfo.st);
htinfo.st.wDay = MONTHCAL_MonthLength(htinfo.st.wMonth, htinfo.st.wYear) + day; htinfo.st.wDay = MONTHCAL_MonthLength(htinfo.st.wMonth, htinfo.st.wYear) + day;
} }
else if (day > MONTHCAL_MonthLength(ht_month.wMonth, ht_month.wYear)) /* next month only valid for last calendar */
else if (day > MONTHCAL_MonthLength(ht_month->wMonth, ht_month->wYear) &&
calIdx == MONTHCAL_GetCalCount(infoPtr)-1)
{ {
htinfo.uHit = MCHT_CALENDARDATENEXT; htinfo.uHit = MCHT_CALENDARDATENEXT;
MONTHCAL_GetNextMonth(&htinfo.st); MONTHCAL_GetNextMonth(&htinfo.st);
htinfo.st.wDay = day - MONTHCAL_MonthLength(ht_month.wMonth, ht_month.wYear); htinfo.st.wDay = day - MONTHCAL_MonthLength(ht_month->wMonth, ht_month->wYear);
}
/* multiple calendars case - blank areas for previous/next month */
else if (day < 1 || day > MONTHCAL_MonthLength(ht_month->wMonth, ht_month->wYear))
{
htinfo.uHit = MCHT_CALENDARBK;
} }
else else
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment