winehq.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2025
February
January
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
January
2003
December
November
October
September
August
July
June
May
April
March
February
January
2002
December
November
October
September
August
July
June
May
April
March
February
January
2001
December
November
October
September
August
July
June
May
April
March
February
List overview
wine-commits
October 2009
----- 2025 -----
February 2025
January 2025
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
January 2004
----- 2003 -----
December 2003
November 2003
October 2003
September 2003
August 2003
July 2003
June 2003
May 2003
April 2003
March 2003
February 2003
January 2003
----- 2002 -----
December 2002
November 2002
October 2002
September 2002
August 2002
July 2002
June 2002
May 2002
April 2002
March 2002
February 2002
January 2002
----- 2001 -----
December 2001
November 2001
October 2001
September 2001
August 2001
July 2001
June 2001
May 2001
April 2001
March 2001
February 2001
wine-commits@winehq.org
3 participants
1207 discussions
Start a n
N
ew thread
Nikolay Sivov : comctl32/monthcal: Fix selection during navigation with prev/next buttons.
by Alexandre Julliard
12 Oct '09
12 Oct '09
Module: wine Branch: master Commit: ecf89c7e3d1e21434e73a25eadfc77bca9dbff71 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=ecf89c7e3d1e21434e73a25ea…
Author: Nikolay Sivov <bunglehead(a)gmail.com> Date: Sun Oct 11 15:33:02 2009 +0400 comctl32/monthcal: Fix selection during navigation with prev/next buttons. --- dlls/comctl32/monthcal.c | 80 ++++++++++++++++++++++----------------------- 1 files changed, 39 insertions(+), 41 deletions(-) diff --git a/dlls/comctl32/monthcal.c b/dlls/comctl32/monthcal.c index cdb21c6..b46bac6 100644 --- a/dlls/comctl32/monthcal.c +++ b/dlls/comctl32/monthcal.c @@ -1520,10 +1520,12 @@ MONTHCAL_SetSelRange(MONTHCAL_INFO *infoPtr, SYSTEMTIME *range) infoPtr->minSel = range[1]; infoPtr->maxSel = range[0]; } + infoPtr->curSel = infoPtr->minSel; /* update day of week */ MONTHCAL_CalculateDayOfWeek(&infoPtr->minSel, TRUE); MONTHCAL_CalculateDayOfWeek(&infoPtr->maxSel, TRUE); + MONTHCAL_CalculateDayOfWeek(&infoPtr->curSel, TRUE); /* redraw if bounds changed */ /* FIXME: no actual need to redraw everything */ @@ -1725,35 +1727,42 @@ static void MONTHCAL_NotifyDayState(MONTHCAL_INFO *infoPtr) } } -static void MONTHCAL_GoToNextMonth(MONTHCAL_INFO *infoPtr) +static void MONTHCAL_GoToPrevNextMonth(MONTHCAL_INFO *infoPtr, BOOL prev) { - SYSTEMTIME next = infoPtr->curSel; - - TRACE("\n"); - - MONTHCAL_GetNextMonth(&next); - - if(!MONTHCAL_IsDateInValidRange(infoPtr, &next, FALSE)) return; - - infoPtr->curSel = next; + SYSTEMTIME st = infoPtr->curSel; - MONTHCAL_NotifyDayState(infoPtr); -} + TRACE("%s\n", prev ? "prev" : "next"); + if(prev) MONTHCAL_GetPrevMonth(&st); else MONTHCAL_GetNextMonth(&st); -static void MONTHCAL_GoToPrevMonth(MONTHCAL_INFO *infoPtr) -{ - SYSTEMTIME prev = infoPtr->curSel; + if(!MONTHCAL_IsDateInValidRange(infoPtr, &st, FALSE)) return; - TRACE("\n"); + if(infoPtr->dwStyle & MCS_MULTISELECT) + { + SYSTEMTIME range[2]; - MONTHCAL_GetPrevMonth(&prev); + range[0] = infoPtr->minSel; + range[1] = infoPtr->maxSel; - if(!MONTHCAL_IsDateInValidRange(infoPtr, &prev, FALSE)) return; + if(prev) + { + MONTHCAL_GetPrevMonth(&range[0]); + MONTHCAL_GetPrevMonth(&range[1]); + } + else + { + MONTHCAL_GetNextMonth(&range[0]); + MONTHCAL_GetNextMonth(&range[1]); + } - infoPtr->curSel = prev; + MONTHCAL_SetSelRange(infoPtr, range); + } + else + MONTHCAL_SetCurSel(infoPtr, &st); MONTHCAL_NotifyDayState(infoPtr); + + MONTHCAL_NotifySelectionChange(infoPtr); } static LRESULT @@ -1892,14 +1901,14 @@ MONTHCAL_LButtonDown(MONTHCAL_INFO *infoPtr, LPARAM lParam) switch(hit) { case MCHT_TITLEBTNNEXT: - MONTHCAL_GoToNextMonth(infoPtr); + MONTHCAL_GoToPrevNextMonth(infoPtr, FALSE); infoPtr->status = MC_NEXTPRESSED; SetTimer(infoPtr->hwndSelf, MC_PREVNEXTMONTHTIMER, MC_PREVNEXTMONTHDELAY, 0); InvalidateRect(infoPtr->hwndSelf, NULL, FALSE); return 0; case MCHT_TITLEBTNPREV: - MONTHCAL_GoToPrevMonth(infoPtr); + MONTHCAL_GoToPrevNextMonth(infoPtr, TRUE); infoPtr->status = MC_PREVPRESSED; SetTimer(infoPtr->hwndSelf, MC_PREVNEXTMONTHTIMER, MC_PREVNEXTMONTHDELAY, 0); InvalidateRect(infoPtr->hwndSelf, NULL, FALSE); @@ -1951,17 +1960,13 @@ MONTHCAL_LButtonDown(MONTHCAL_INFO *infoPtr, LPARAM lParam) case MCHT_CALENDARDATEPREV: case MCHT_CALENDARDATE: { - MONTHCAL_CopyDate(&ht.st, &infoPtr->firstSel); - - if(infoPtr->dwStyle & MCS_MULTISELECT) - { - SYSTEMTIME st[2]; + SYSTEMTIME st[2]; - st[0] = st[1] = ht.st; + MONTHCAL_CopyDate(&ht.st, &infoPtr->firstSel); - /* clear selection range */ - MONTHCAL_SetSelRange(infoPtr, st); - } + st[0] = st[1] = ht.st; + /* clear selection range */ + MONTHCAL_SetSelRange(infoPtr, st); infoPtr->status = MC_SEL_LBUTDOWN; MONTHCAL_SetDayFocus(infoPtr, &ht.st); @@ -2016,15 +2021,8 @@ MONTHCAL_LButtonUp(MONTHCAL_INFO *infoPtr, LPARAM lParam) { SYSTEMTIME sel = infoPtr->curSel; - if(!(infoPtr->dwStyle & MCS_MULTISELECT)) - { - SYSTEMTIME st[2]; - - st[0] = st[1] = ht.st; - MONTHCAL_SetSelRange(infoPtr, st); - /* will be invalidated here */ - MONTHCAL_SetCurSel(infoPtr, &st[0]); - } + /* will be invalidated here */ + MONTHCAL_SetCurSel(infoPtr, &ht.st); /* send MCN_SELCHANGE only if new date selected */ if (!MONTHCAL_IsDateEqual(&sel, &ht.st)) @@ -2044,8 +2042,8 @@ MONTHCAL_Timer(MONTHCAL_INFO *infoPtr, WPARAM id) switch(id) { case MC_PREVNEXTMONTHTIMER: - if(infoPtr->status & MC_NEXTPRESSED) MONTHCAL_GoToNextMonth(infoPtr); - if(infoPtr->status & MC_PREVPRESSED) MONTHCAL_GoToPrevMonth(infoPtr); + if(infoPtr->status & MC_NEXTPRESSED) MONTHCAL_GoToPrevNextMonth(infoPtr, FALSE); + if(infoPtr->status & MC_PREVPRESSED) MONTHCAL_GoToPrevNextMonth(infoPtr, TRUE); InvalidateRect(infoPtr->hwndSelf, NULL, FALSE); break; case MC_TODAYUPDATETIMER:
1
0
0
0
Nikolay Sivov : comctl32/monthcal: Fix multiselection days painting, including intersections with prev/next months.
by Alexandre Julliard
12 Oct '09
12 Oct '09
Module: wine Branch: master Commit: c9e3e3bc8e592dc717fd0ba2779690d5ddcc9878 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=c9e3e3bc8e592dc717fd0ba27…
Author: Nikolay Sivov <bunglehead(a)gmail.com> Date: Sun Oct 11 05:03:59 2009 +0400 comctl32/monthcal: Fix multiselection days painting, including intersections with prev/next months. --- dlls/comctl32/monthcal.c | 50 ++++++++++++++++++++++++++++++--------------- 1 files changed, 33 insertions(+), 17 deletions(-) diff --git a/dlls/comctl32/monthcal.c b/dlls/comctl32/monthcal.c index a0fa58f..cdb21c6 100644 --- a/dlls/comctl32/monthcal.c +++ b/dlls/comctl32/monthcal.c @@ -283,6 +283,17 @@ static LONG MONTHCAL_CompareMonths(const SYSTEMTIME *first, const SYSTEMTIME *se return MONTHCAL_CompareSystemTime(&st_first, &st_second); } +static LONG MONTHCAL_CompareDate(const SYSTEMTIME *first, const SYSTEMTIME *second) +{ + SYSTEMTIME st_first, st_second; + + st_first = st_second = st_null; + MONTHCAL_CopyDate(first, &st_first); + MONTHCAL_CopyDate(second, &st_second); + + return MONTHCAL_CompareSystemTime(&st_first, &st_second); +} + /* Checks largest possible date range and configured one * * PARAMETERS @@ -634,7 +645,7 @@ static void MONTHCAL_CircleDay(const MONTHCAL_INFO *infoPtr, HDC hdc, SelectObject(hdc, hOldPen2); } -static void MONTHCAL_DrawDay(const MONTHCAL_INFO *infoPtr, HDC hdc, int day, int month, +static void MONTHCAL_DrawDay(const MONTHCAL_INFO *infoPtr, HDC hdc, const SYSTEMTIME *st, int x, int y, int bold) { static const WCHAR fmtW[] = { '%','d',0 }; @@ -645,7 +656,7 @@ static void MONTHCAL_DrawDay(const MONTHCAL_INFO *infoPtr, HDC hdc, int day, int COLORREF oldCol = 0; COLORREF oldBk = 0; - wsprintfW(buf, fmtW, day); + wsprintfW(buf, fmtW, st->wDay); /* No need to check styles: when selection is not valid, it is set to zero. * 1<day<31, so everything is OK. @@ -653,11 +664,11 @@ static void MONTHCAL_DrawDay(const MONTHCAL_INFO *infoPtr, HDC hdc, int day, int MONTHCAL_CalcDayRect(infoPtr, &r, x, y); - if((day>=infoPtr->minSel.wDay) && (day<=infoPtr->maxSel.wDay) - && (month == infoPtr->curSel.wMonth)) { + if ((MONTHCAL_CompareDate(st, &infoPtr->minSel) >= 0) && + (MONTHCAL_CompareDate(st, &infoPtr->maxSel) <= 0)) { RECT r2; - TRACE("%d %d %d\n",day, infoPtr->minSel.wDay, infoPtr->maxSel.wDay); + TRACE("%d %d %d\n", st->wDay, infoPtr->minSel.wDay, infoPtr->maxSel.wDay); TRACE("%s\n", wine_dbgstr_rect(&r)); oldCol = SetTextColor(hdc, infoPtr->monthbk); oldBk = SetBkColor(hdc, infoPtr->trailingtxt); @@ -853,53 +864,54 @@ static void MONTHCAL_Refresh(MONTHCAL_INFO *infoPtr, HDC hdc, const PAINTSTRUCT i = 0; m = 0; - while(day <= MONTHCAL_MonthLength(prevMonth, infoPtr->curSel.wYear)) { + while(st.wDay <= MONTHCAL_MonthLength(prevMonth, infoPtr->curSel.wYear)) { MONTHCAL_CalcDayRect(infoPtr, &rcDay, i, 0); if(IntersectRect(&rcTemp, &(ps->rcPaint), &rcDay)) { - MONTHCAL_DrawDay(infoPtr, hdc, day, prevMonth, i, 0, + MONTHCAL_DrawDay(infoPtr, hdc, &st, i, 0, infoPtr->monthdayState[m] & mask); } - mask<<=1; - day++; + mask <<= 1; + st.wDay++; i++; } /* draw `current' month */ day = 1; /* start at the beginning of the current month */ - + st = infoPtr->curSel; + st.wDay = 1; infoPtr->firstDayplace = i; SetTextColor(hdc, infoPtr->txt); m++; mask = 1; /* draw the first week of the current month */ - while(i<7) { + while(i < 7) { MONTHCAL_CalcDayRect(infoPtr, &rcDay, i, 0); if(IntersectRect(&rcTemp, &(ps->rcPaint), &rcDay)) { - MONTHCAL_DrawDay(infoPtr, hdc, day, infoPtr->curSel.wMonth, i, 0, + MONTHCAL_DrawDay(infoPtr, hdc, &st, i, 0, infoPtr->monthdayState[m] & mask); } mask<<=1; - day++; + st.wDay++; i++; } j = 1; /* move to the 2nd week of the current month */ i = 0; /* move back to sunday */ - while(day <= MONTHCAL_MonthLength(infoPtr->curSel.wMonth, infoPtr->curSel.wYear)) { + while(st.wDay <= MONTHCAL_MonthLength(infoPtr->curSel.wMonth, infoPtr->curSel.wYear)) { MONTHCAL_CalcDayRect(infoPtr, &rcDay, i, j); if(IntersectRect(&rcTemp, &(ps->rcPaint), &rcDay)) { - MONTHCAL_DrawDay(infoPtr, hdc, day, infoPtr->curSel.wMonth, i, j, + MONTHCAL_DrawDay(infoPtr, hdc, &st, i, j, infoPtr->monthdayState[m] & mask); } mask<<=1; - day++; + st.wDay++; i++; if(i>6) { /* past saturday, goto the next weeks sunday */ i = 0; @@ -910,6 +922,9 @@ static void MONTHCAL_Refresh(MONTHCAL_INFO *infoPtr, HDC hdc, const PAINTSTRUCT /* draw `next' month */ day = 1; /* start at the first day of the next month */ + st = infoPtr->curSel; + st.wDay = 1; + MONTHCAL_GetNextMonth(&st); m++; mask = 1; @@ -918,11 +933,12 @@ static void MONTHCAL_Refresh(MONTHCAL_INFO *infoPtr, HDC hdc, const PAINTSTRUCT MONTHCAL_CalcDayRect(infoPtr, &rcDay, i, j); if(IntersectRect(&rcTemp, &(ps->rcPaint), &rcDay)) { - MONTHCAL_DrawDay(infoPtr, hdc, day, infoPtr->curSel.wMonth + 1, i, j, + MONTHCAL_DrawDay(infoPtr, hdc, &st, i, j, infoPtr->monthdayState[m] & mask); } mask<<=1; + st.wDay++; day++; i++; if(i==7) { /* past saturday, go to next week's sunday */
1
0
0
0
Nikolay Sivov : comctl32/monthcal: Simplify parameter set of day of week calculation helper.
by Alexandre Julliard
12 Oct '09
12 Oct '09
Module: wine Branch: master Commit: 4651624d350e887398bc83eb7f8ae77e58a5f369 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=4651624d350e887398bc83eb7…
Author: Nikolay Sivov <bunglehead(a)gmail.com> Date: Sun Oct 11 04:28:09 2009 +0400 comctl32/monthcal: Simplify parameter set of day of week calculation helper. --- dlls/comctl32/comctl32.h | 2 +- dlls/comctl32/datetime.c | 6 +-- dlls/comctl32/monthcal.c | 70 ++++++++++++++++++++++----------------------- 3 files changed, 37 insertions(+), 41 deletions(-) diff --git a/dlls/comctl32/comctl32.h b/dlls/comctl32/comctl32.h index 4cad907..3d172ae 100644 --- a/dlls/comctl32/comctl32.h +++ b/dlls/comctl32/comctl32.h @@ -231,7 +231,7 @@ extern void UPDOWN_Unregister(void); int MONTHCAL_MonthLength(int month, int year); -int MONTHCAL_CalculateDayOfWeek(WORD day, WORD month, WORD year); +int MONTHCAL_CalculateDayOfWeek(SYSTEMTIME *date, BOOL inplace); extern void THEMING_Initialize(void); extern void THEMING_Uninitialize(void); diff --git a/dlls/comctl32/datetime.c b/dlls/comctl32/datetime.c index 0165166..f00b588 100644 --- a/dlls/comctl32/datetime.c +++ b/dlls/comctl32/datetime.c @@ -88,7 +88,7 @@ typedef struct /* in monthcal.c */ extern int MONTHCAL_MonthLength(int month, int year); -extern int MONTHCAL_CalculateDayOfWeek(WORD day, WORD month, WORD year); +extern int MONTHCAL_CalculateDayOfWeek(SYSTEMTIME *date, BOOL inplace); /* this list of defines is closely related to `allowedformatchars' defined * in datetime.c; the high nibble indicates the `base type' of the format @@ -177,9 +177,7 @@ DATETIME_SetSystemTime (DATETIME_INFO *infoPtr, DWORD flag, const SYSTEMTIME *sy infoPtr->dateValid = TRUE; infoPtr->date = *systime; /* always store a valid day of week */ - infoPtr->date.wDayOfWeek = - MONTHCAL_CalculateDayOfWeek(infoPtr->date.wDay, infoPtr->date.wMonth, - infoPtr->date.wYear); + MONTHCAL_CalculateDayOfWeek(&infoPtr->date, TRUE); SendMessageW (infoPtr->hMonthCal, MCM_SETCURSEL, 0, (LPARAM)(&infoPtr->date)); SendMessageW (infoPtr->hwndCheckbut, BM_SETCHECK, BST_CHECKED, 0); diff --git a/dlls/comctl32/monthcal.c b/dlls/comctl32/monthcal.c index 72d102a..a0fa58f 100644 --- a/dlls/comctl32/monthcal.c +++ b/dlls/comctl32/monthcal.c @@ -406,26 +406,24 @@ static BOOL MONTHCAL_ValidateTime(const SYSTEMTIME *time) /* Returns the day in the week * * PARAMETERS - * [i] day : day of month [1, 31] - * [I] month : month number [1, 12] - * [I] year : year value + * [i] date : input date + * [I] inplace : set calculated value back to date structure * * RETURN VALUE * day of week in SYSTEMTIME format: (0 == sunday,..., 6 == saturday) */ -int MONTHCAL_CalculateDayOfWeek(WORD day, WORD month, WORD year) +int MONTHCAL_CalculateDayOfWeek(SYSTEMTIME *date, BOOL inplace) { + SYSTEMTIME st = st_null; FILETIME ft; - SYSTEMTIME st; - st.wYear = year; - st.wMonth = month; - st.wDay = day; - st.wHour = st.wMinute = st.wSecond = st.wMilliseconds = 0; + MONTHCAL_CopyDate(date, &st); SystemTimeToFileTime(&st, &ft); FileTimeToSystemTime(&ft, &st); + if (inplace) date->wDayOfWeek = st.wDayOfWeek; + return st.wDayOfWeek; } @@ -437,8 +435,7 @@ static inline void MONTHCAL_GetNextMonth(SYSTEMTIME *date) date->wMonth = 1; date->wYear++; } - date->wDayOfWeek = MONTHCAL_CalculateDayOfWeek(date->wDay, date->wMonth, - date->wYear); + MONTHCAL_CalculateDayOfWeek(date, TRUE); } /* properly updates date to point on prev month */ @@ -449,16 +446,17 @@ static inline void MONTHCAL_GetPrevMonth(SYSTEMTIME *date) date->wMonth = 12; date->wYear--; } - date->wDayOfWeek = MONTHCAL_CalculateDayOfWeek(date->wDay, date->wMonth, - date->wYear); + MONTHCAL_CalculateDayOfWeek(date, TRUE); } /* Returns full date for a first currently visible day */ static void MONTHCAL_GetMinDate(const MONTHCAL_INFO *infoPtr, SYSTEMTIME *date) { + SYSTEMTIME st_first = infoPtr->curSel; int firstDay; - firstDay = MONTHCAL_CalculateDayOfWeek(1, infoPtr->curSel.wMonth, infoPtr->curSel.wYear); + st_first.wDay = 1; + firstDay = MONTHCAL_CalculateDayOfWeek(&st_first, FALSE); *date = infoPtr->curSel; MONTHCAL_GetPrevMonth(date); @@ -470,8 +468,7 @@ static void MONTHCAL_GetMinDate(const MONTHCAL_INFO *infoPtr, SYSTEMTIME *date) date->wDay -= 7; /* fix day of week */ - date->wDayOfWeek = MONTHCAL_CalculateDayOfWeek(date->wDay, date->wMonth, - date->wYear); + MONTHCAL_CalculateDayOfWeek(date, TRUE); } /* Returns full date for a last currently visible day */ @@ -488,8 +485,7 @@ static void MONTHCAL_GetMaxDate(const MONTHCAL_INFO *infoPtr, SYSTEMTIME *date) MONTHCAL_MonthLength(infoPtr->curSel.wMonth, infoPtr->curSel.wYear); /* fix day of week */ - date->wDayOfWeek = MONTHCAL_CalculateDayOfWeek(date->wDay, date->wMonth, - date->wYear); + MONTHCAL_CalculateDayOfWeek(date, TRUE); } /* From a given point, calculate the row (weekpos), column(daypos) @@ -500,6 +496,7 @@ static int MONTHCAL_CalcDayFromPos(const MONTHCAL_INFO *infoPtr, int x, int y, { int retval, firstDay; RECT rcClient; + SYSTEMTIME st = infoPtr->curSel; GetClientRect(infoPtr->hwndSelf, &rcClient); @@ -512,7 +509,8 @@ static int MONTHCAL_CalcDayFromPos(const MONTHCAL_INFO *infoPtr, int x, int y, *daypos = (x - infoPtr->days.left ) / infoPtr->width_increment; *weekpos = (y - infoPtr->days.top ) / infoPtr->height_increment; - firstDay = (MONTHCAL_CalculateDayOfWeek(1, infoPtr->curSel.wMonth, infoPtr->curSel.wYear)+6 - infoPtr->firstDay)%7; + st.wDay = 1; + firstDay = (MONTHCAL_CalculateDayOfWeek(&st, FALSE) + 6 - infoPtr->firstDay) % 7; retval = *daypos + (7 * *weekpos) - firstDay; return retval; } @@ -529,10 +527,12 @@ static int MONTHCAL_CalcDayFromPos(const MONTHCAL_INFO *infoPtr, int x, int y, static void MONTHCAL_CalcDayXY(const MONTHCAL_INFO *infoPtr, const SYSTEMTIME *date, int *x, int *y) { + SYSTEMTIME st = infoPtr->curSel; LONG cmp; int first; - first = (MONTHCAL_CalculateDayOfWeek(1, infoPtr->curSel.wMonth, infoPtr->curSel.wYear) +6 - infoPtr->firstDay)%7; + st.wDay = 1; + first = (MONTHCAL_CalculateDayOfWeek(&st, FALSE) + 6 - infoPtr->firstDay) % 7; cmp = MONTHCAL_CompareMonths(date, &infoPtr->curSel); @@ -985,6 +985,7 @@ static void MONTHCAL_Refresh(MONTHCAL_INFO *infoPtr, HDC hdc, const PAINTSTRUCT if(infoPtr->dwStyle & MCS_WEEKNUMBERS) { static const WCHAR fmt_weekW[] = { '%','d',0 }; /* week numbers format */ int mindays, weeknum, weeknum1; + SYSTEMTIME st = infoPtr->curSel; /* Rules what week to call the first week of a new year: LOCALE_IFIRSTWEEKOFYEAR == 0 (e.g US?): @@ -1009,7 +1010,8 @@ static void MONTHCAL_Refresh(MONTHCAL_INFO *infoPtr, HDC hdc, const PAINTSTRUCT if (infoPtr->curSel.wMonth < 2) { /* calculate all those exceptions for january */ - weeknum1 = MONTHCAL_CalculateDayOfWeek(1, 1, infoPtr->curSel.wYear); + st.wDay = st.wMonth = 1; + weeknum1 = MONTHCAL_CalculateDayOfWeek(&st, FALSE); if ((infoPtr->firstDay - weeknum1) % 7 > mindays) weeknum = 1; else @@ -1018,9 +1020,10 @@ static void MONTHCAL_Refresh(MONTHCAL_INFO *infoPtr, HDC hdc, const PAINTSTRUCT for(i = 0; i < 11; i++) weeknum += MONTHCAL_MonthLength(i+1, infoPtr->curSel.wYear - 1); - weeknum += startofprescal + 7; - weeknum /= 7; - weeknum1 = MONTHCAL_CalculateDayOfWeek(1, 1, infoPtr->curSel.wYear - 1); + weeknum += startofprescal + 7; + weeknum /= 7; + st.wYear -= 1; + weeknum1 = MONTHCAL_CalculateDayOfWeek(&st, FALSE); if ((infoPtr->firstDay - weeknum1) % 7 > mindays) weeknum++; } } @@ -1032,7 +1035,8 @@ static void MONTHCAL_Refresh(MONTHCAL_INFO *infoPtr, HDC hdc, const PAINTSTRUCT weeknum += startofprescal + 7; weeknum /= 7; - weeknum1 = MONTHCAL_CalculateDayOfWeek(1, 1, infoPtr->curSel.wYear); + st.wDay = st.wMonth = 1; + weeknum1 = MONTHCAL_CalculateDayOfWeek(&st, FALSE); if ((infoPtr->firstDay - weeknum1) % 7 > mindays) weeknum++; } @@ -1272,11 +1276,10 @@ MONTHCAL_GetMonthRange(const MONTHCAL_INFO *infoPtr, DWORD flag, SYSTEMTIME *st) } else st[0].wDay = 1; - st[0].wDayOfWeek = MONTHCAL_CalculateDayOfWeek(1, st[0].wMonth, st[0].wYear); + MONTHCAL_CalculateDayOfWeek(&st[0], TRUE); st[1].wDay = MONTHCAL_MonthLength(st[1].wMonth, st[1].wYear); - st[1].wDayOfWeek = MONTHCAL_CalculateDayOfWeek(st[1].wDay, st[1].wMonth, - st[1].wYear); + MONTHCAL_CalculateDayOfWeek(&st[1], TRUE); /* a single current month used */ return 1; } @@ -1503,12 +1506,8 @@ MONTHCAL_SetSelRange(MONTHCAL_INFO *infoPtr, SYSTEMTIME *range) } /* update day of week */ - infoPtr->minSel.wDayOfWeek = - MONTHCAL_CalculateDayOfWeek(infoPtr->minSel.wDay, infoPtr->minSel.wMonth, - infoPtr->minSel.wYear); - infoPtr->maxSel.wDayOfWeek = - MONTHCAL_CalculateDayOfWeek(infoPtr->maxSel.wDay, infoPtr->maxSel.wMonth, - infoPtr->maxSel.wYear); + MONTHCAL_CalculateDayOfWeek(&infoPtr->minSel, TRUE); + MONTHCAL_CalculateDayOfWeek(&infoPtr->maxSel, TRUE); /* redraw if bounds changed */ /* FIXME: no actual need to redraw everything */ @@ -1667,8 +1666,7 @@ MONTHCAL_HitTest(const MONTHCAL_INFO *infoPtr, MCHITTESTINFO *lpht) lpht->st.wDay = day; } /* always update day of week */ - lpht->st.wDayOfWeek = MONTHCAL_CalculateDayOfWeek(lpht->st.wDay, lpht->st.wMonth, - lpht->st.wYear); + MONTHCAL_CalculateDayOfWeek(&lpht->st, TRUE); goto done; } if(PtInRect(&infoPtr->todayrect, lpht->pt)) {
1
0
0
0
Nikolay Sivov : comctl32/monthcal: Fix column/ row calculation for previous and next month.
by Alexandre Julliard
12 Oct '09
12 Oct '09
Module: wine Branch: master Commit: 7d2ef4f23da2651b97867a085283cac3518ae2fe URL:
http://source.winehq.org/git/wine.git/?a=commit;h=7d2ef4f23da2651b97867a085…
Author: Nikolay Sivov <bunglehead(a)gmail.com> Date: Sun Oct 11 03:54:11 2009 +0400 comctl32/monthcal: Fix column/row calculation for previous and next month. --- dlls/comctl32/monthcal.c | 166 +++++++++++++++++++++++++-------------------- 1 files changed, 92 insertions(+), 74 deletions(-) diff --git a/dlls/comctl32/monthcal.c b/dlls/comctl32/monthcal.c index 87ce751..72d102a 100644 --- a/dlls/comctl32/monthcal.c +++ b/dlls/comctl32/monthcal.c @@ -217,6 +217,35 @@ static BOOL MONTHCAL_ValidateDate(const SYSTEMTIME *time) return TRUE; } +/* Copies timestamp part only. + * + * PARAMETERS + * + * [I] from : source date + * [O] to : dest date + */ +static void MONTHCAL_CopyTime(const SYSTEMTIME *from, SYSTEMTIME *to) +{ + to->wHour = from->wHour; + to->wMinute = from->wMinute; + to->wSecond = from->wSecond; +} + +/* Copies date part only. + * + * PARAMETERS + * + * [I] from : source date + * [O] to : dest date + */ +static void MONTHCAL_CopyDate(const SYSTEMTIME *from, SYSTEMTIME *to) +{ + to->wYear = from->wYear; + to->wMonth = from->wMonth; + to->wDay = from->wDay; + to->wDayOfWeek = from->wDayOfWeek; +} + /* Compares two dates in SYSTEMTIME format * * PARAMETERS @@ -242,6 +271,18 @@ static LONG MONTHCAL_CompareSystemTime(const SYSTEMTIME *first, const SYSTEMTIME return CompareFileTime(&ft_first, &ft_second); } +static LONG MONTHCAL_CompareMonths(const SYSTEMTIME *first, const SYSTEMTIME *second) +{ + SYSTEMTIME st_first, st_second; + + st_first = st_second = st_null; + MONTHCAL_CopyDate(first, &st_first); + MONTHCAL_CopyDate(second, &st_second); + st_first.wDay = st_second.wDay = 1; + + return MONTHCAL_CompareSystemTime(&st_first, &st_second); +} + /* Checks largest possible date range and configured one * * PARAMETERS @@ -355,35 +396,6 @@ static BOOL MONTHCAL_ValidateTime(const SYSTEMTIME *time) return TRUE; } -/* Copies timestamp part only. - * - * PARAMETERS - * - * [I] from : source date - * [O] to : dest date - */ -static void MONTHCAL_CopyTime(const SYSTEMTIME *from, SYSTEMTIME *to) -{ - to->wHour = from->wHour; - to->wMinute = from->wMinute; - to->wSecond = from->wSecond; -} - -/* Copies date part only. - * - * PARAMETERS - * - * [I] from : source date - * [O] to : dest date - */ -static void MONTHCAL_CopyDate(const SYSTEMTIME *from, SYSTEMTIME *to) -{ - to->wYear = from->wYear; - to->wMonth = from->wMonth; - to->wDay = from->wDay; - to->wDayOfWeek = from->wDayOfWeek; -} - /* Note:Depending on DST, this may be offset by a day. Need to find out if we're on a DST place & adjust the clock accordingly. Above function assumes we have a valid data. @@ -505,39 +517,45 @@ static int MONTHCAL_CalcDayFromPos(const MONTHCAL_INFO *infoPtr, int x, int y, return retval; } -/* day is the day of the month, 1 == 1st day of the month */ -/* sets x and y to be the position of the day */ -/* x == day, y == week where(0,0) == firstDay, 1st week */ -static void MONTHCAL_CalcDayXY(const MONTHCAL_INFO *infoPtr, int day, int month, - int *x, int *y) +/* Sets the RECT struct r to the rectangle around the date + * + * PARAMETERS + * + * [I] infoPtr : pointer to control data + * [I] date : date value + * [O] x : day column (zero based) + * [O] y : week column (zero based) + */ +static void MONTHCAL_CalcDayXY(const MONTHCAL_INFO *infoPtr, + const SYSTEMTIME *date, int *x, int *y) { - int firstDay, prevMonth; + LONG cmp; + int first; - firstDay = (MONTHCAL_CalculateDayOfWeek(1, infoPtr->curSel.wMonth, infoPtr->curSel.wYear) +6 - infoPtr->firstDay)%7; + first = (MONTHCAL_CalculateDayOfWeek(1, infoPtr->curSel.wMonth, infoPtr->curSel.wYear) +6 - infoPtr->firstDay)%7; - if(month==infoPtr->curSel.wMonth) { - *x = (day + firstDay) % 7; - *y = (day + firstDay - *x) / 7; - return; - } - if(month < infoPtr->curSel.wMonth) { - prevMonth = month - 1; - if(prevMonth==0) - prevMonth = 12; + cmp = MONTHCAL_CompareMonths(date, &infoPtr->curSel); - *x = (MONTHCAL_MonthLength(prevMonth, infoPtr->curSel.wYear) - firstDay) % 7; + /* previous month */ + if(cmp == -1) { + *x = (first - MONTHCAL_MonthLength(date->wMonth, infoPtr->curSel.wYear) + date->wDay) % 7; *y = 0; return; } - *y = MONTHCAL_MonthLength(month, infoPtr->curSel.wYear - 1) / 7; - *x = (day + firstDay + MONTHCAL_MonthLength(month, - infoPtr->curSel.wYear)) % 7; + /* next month calculation is same as for current, + just add current month length */ + if(cmp == 1) { + first += MONTHCAL_MonthLength(infoPtr->curSel.wMonth, infoPtr->curSel.wYear); + } + + *x = (date->wDay + first) % 7; + *y = (date->wDay + first - *x) / 7; } /* x: column(day), y: row(week) */ -static void MONTHCAL_CalcDayRect(const MONTHCAL_INFO *infoPtr, RECT *r, int x, int y) +static inline void MONTHCAL_CalcDayRect(const MONTHCAL_INFO *infoPtr, RECT *r, int x, int y) { r->left = infoPtr->days.left + x * infoPtr->width_increment; r->right = r->left + infoPtr->width_increment; @@ -546,15 +564,13 @@ static void MONTHCAL_CalcDayRect(const MONTHCAL_INFO *infoPtr, RECT *r, int x, i } -/* sets the RECT struct r to the rectangle around the day and month */ -/* day is the day value of the month(1 == 1st), month is the month */ -/* value(january == 1, december == 12) */ +/* Sets the RECT struct r to the rectangle around the date */ static inline void MONTHCAL_CalcPosFromDay(const MONTHCAL_INFO *infoPtr, - int day, int month, RECT *r) + const SYSTEMTIME *date, RECT *r) { int x, y; - MONTHCAL_CalcDayXY(infoPtr, day, month, &x, &y); + MONTHCAL_CalcDayXY(infoPtr, date, &x, &y); MONTHCAL_CalcDayRect(infoPtr, r, x, y); } @@ -577,15 +593,13 @@ static BOOL MONTHCAL_SetDayFocus(MONTHCAL_INFO *infoPtr, const SYSTEMTIME *st) if(MONTHCAL_IsDateEqual(&infoPtr->focusedSel, st)) return FALSE; /* invalidate old focused day */ - MONTHCAL_CalcPosFromDay(infoPtr, infoPtr->focusedSel.wDay, - infoPtr->focusedSel.wMonth, &r); + MONTHCAL_CalcPosFromDay(infoPtr, &infoPtr->focusedSel, &r); InvalidateRect(infoPtr->hwndSelf, &r, FALSE); infoPtr->focusedSel = *st; } - MONTHCAL_CalcPosFromDay(infoPtr, infoPtr->focusedSel.wDay, - infoPtr->focusedSel.wMonth, &r); + MONTHCAL_CalcPosFromDay(infoPtr, &infoPtr->focusedSel, &r); if(!st && MONTHCAL_ValidateDate(&infoPtr->focusedSel)) infoPtr->focusedSel = st_null; @@ -596,16 +610,21 @@ static BOOL MONTHCAL_SetDayFocus(MONTHCAL_INFO *infoPtr, const SYSTEMTIME *st) return TRUE; } -/* day is the day in the month(1 == 1st of the month) */ -/* month is the month value(1 == january, 12 == december) */ -static void MONTHCAL_CircleDay(const MONTHCAL_INFO *infoPtr, HDC hdc, int day, int month) +/* Draw today day mark rectangle + * + * [I] hdc : context to draw in + * [I] day : day to mark with rectangle + * + */ +static void MONTHCAL_CircleDay(const MONTHCAL_INFO *infoPtr, HDC hdc, + const SYSTEMTIME *date) { HPEN hRedPen = CreatePen(PS_SOLID, 1, RGB(255, 0, 0)); HPEN hOldPen2 = SelectObject(hdc, hRedPen); HBRUSH hOldBrush; RECT day_rect; - MONTHCAL_CalcPosFromDay(infoPtr, day, month, &day_rect); + MONTHCAL_CalcPosFromDay(infoPtr, date, &day_rect); hOldBrush = SelectObject(hdc, GetStockObject(NULL_BRUSH)); Rectangle(hdc, day_rect.left, day_rect.top, day_rect.right, day_rect.bottom); @@ -918,14 +937,13 @@ static void MONTHCAL_Refresh(MONTHCAL_INFO *infoPtr, HDC hdc, const PAINTSTRUCT (infoPtr->curSel.wYear == infoPtr->todaysDate.wYear) && !(infoPtr->dwStyle & MCS_NOTODAYCIRCLE)) { - MONTHCAL_CircleDay(infoPtr, hdc, infoPtr->todaysDate.wDay, infoPtr->todaysDate.wMonth); + MONTHCAL_CircleDay(infoPtr, hdc, &infoPtr->todaysDate); } /* draw focused day */ if(!MONTHCAL_IsDateEqual(&infoPtr->focusedSel, &st_null)) { - MONTHCAL_CalcPosFromDay(infoPtr, infoPtr->focusedSel.wDay, - infoPtr->focusedSel.wMonth, &rcDay); + MONTHCAL_CalcPosFromDay(infoPtr, &infoPtr->focusedSel, &rcDay); DrawFocusRect(hdc, &rcDay); } @@ -937,11 +955,12 @@ static void MONTHCAL_Refresh(MONTHCAL_INFO *infoPtr, HDC hdc, const PAINTSTRUCT static const WCHAR fmt_todayW[] = { '%','s',' ','%','s',0 }; RECT rtoday; - if(!(infoPtr->dwStyle & MCS_NOTODAYCIRCLE)) { + if(!(infoPtr->dwStyle & MCS_NOTODAYCIRCLE)) { + SYSTEMTIME fake_st = infoPtr->curSel; + /*day is the number of days from nextmonth we put on the calendar */ - MONTHCAL_CircleDay(infoPtr, hdc, - day+MONTHCAL_MonthLength(infoPtr->curSel.wMonth, infoPtr->curSel.wYear), - infoPtr->curSel.wMonth); + fake_st.wDay = day + MONTHCAL_MonthLength(infoPtr->curSel.wMonth, infoPtr->curSel.wYear); + MONTHCAL_CircleDay(infoPtr, hdc, &fake_st); } if (!LoadStringW(COMCTL32_hModule, IDM_TODAY, buf1, countof(buf1))) { @@ -1531,9 +1550,8 @@ MONTHCAL_UpdateToday(MONTHCAL_INFO *infoPtr, const SYSTEMTIME *today) if(MONTHCAL_IsDateEqual(today, &infoPtr->todaysDate)) return FALSE; - MONTHCAL_CalcPosFromDay(infoPtr, infoPtr->todaysDate.wDay, - infoPtr->todaysDate.wMonth, &old_r); - MONTHCAL_CalcPosFromDay(infoPtr, today->wDay, today->wMonth, &new_r); + MONTHCAL_CalcPosFromDay(infoPtr, &infoPtr->todaysDate, &old_r); + MONTHCAL_CalcPosFromDay(infoPtr, today, &new_r); infoPtr->todaysDate = *today; @@ -2069,7 +2087,7 @@ MONTHCAL_MouseMove(MONTHCAL_INFO *infoPtr, LPARAM lParam) /* if pointer is over focused day still there's nothing to do */ if(!MONTHCAL_SetDayFocus(infoPtr, &ht.st)) return 0; - MONTHCAL_CalcPosFromDay(infoPtr, ht.st.wDay, ht.st.wMonth, &r); + MONTHCAL_CalcPosFromDay(infoPtr, &ht.st, &r); if(infoPtr->dwStyle & MCS_MULTISELECT) { SYSTEMTIME st[2];
1
0
0
0
Nikolay Sivov : comctl32/monthcal: Fix a test skip condition - zero is a valid day of week.
by Alexandre Julliard
12 Oct '09
12 Oct '09
Module: wine Branch: master Commit: 22dddce999629c5e61d801ae0edcab2e6dcbfb5a URL:
http://source.winehq.org/git/wine.git/?a=commit;h=22dddce999629c5e61d801ae0…
Author: Nikolay Sivov <bunglehead(a)gmail.com> Date: Sun Oct 11 00:32:59 2009 +0400 comctl32/monthcal: Fix a test skip condition - zero is a valid day of week. --- dlls/comctl32/tests/monthcal.c | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-) diff --git a/dlls/comctl32/tests/monthcal.c b/dlls/comctl32/tests/monthcal.c index 3ead3ed..8d59e72 100644 --- a/dlls/comctl32/tests/monthcal.c +++ b/dlls/comctl32/tests/monthcal.c @@ -1584,18 +1584,18 @@ static void test_monthcal_selrange(void) expect(st.wYear, range[0].wYear); expect(st.wMonth, range[0].wMonth); expect(st.wDay, range[0].wDay); - if (range[0].wDayOfWeek == 0) + if (range[0].wDayOfWeek != st.wDayOfWeek) { win_skip("comctl32 <= 4.70 doesn't set some values\n"); old_comctl32 = TRUE; } else { - expect(st.wDayOfWeek, range[0].wDayOfWeek); - expect(st.wHour, range[0].wHour); - expect(st.wMinute, range[0].wMinute); - expect(st.wSecond, range[0].wSecond); - expect(st.wMilliseconds, range[0].wMilliseconds); + expect(st.wDayOfWeek, range[0].wDayOfWeek); + expect(st.wHour, range[0].wHour); + expect(st.wMinute, range[0].wMinute); + expect(st.wSecond, range[0].wSecond); + expect(st.wMilliseconds, range[0].wMilliseconds); } expect(st.wYear, range[1].wYear);
1
0
0
0
Nikolay Sivov : comctl32/monthcal: Handle over/ underflow while navigation with month menu.
by Alexandre Julliard
12 Oct '09
12 Oct '09
Module: wine Branch: master Commit: 6b72f16906b4659d6d7a33e3e5cf1b8e9317ae07 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=6b72f16906b4659d6d7a33e3e…
Author: Nikolay Sivov <bunglehead(a)gmail.com> Date: Sun Oct 11 00:28:51 2009 +0400 comctl32/monthcal: Handle over/underflow while navigation with month menu. --- dlls/comctl32/monthcal.c | 40 ++++++++++++++++++++++++++++------------ 1 files changed, 28 insertions(+), 12 deletions(-) diff --git a/dlls/comctl32/monthcal.c b/dlls/comctl32/monthcal.c index 9f242ed..87ce751 100644 --- a/dlls/comctl32/monthcal.c +++ b/dlls/comctl32/monthcal.c @@ -248,26 +248,41 @@ static LONG MONTHCAL_CompareSystemTime(const SYSTEMTIME *first, const SYSTEMTIME * * [I] infoPtr : valid pointer to control data * [I] date : pointer to valid date data to check + * [I] fix : make date fit valid range * * RETURN VALUE * * TRUE - date whithin largest and configured range * FALSE - date is outside largest or configured range */ -static BOOL MONTHCAL_IsDateInValidRange(const MONTHCAL_INFO *infoPtr, const SYSTEMTIME *date) +static BOOL MONTHCAL_IsDateInValidRange(const MONTHCAL_INFO *infoPtr, + SYSTEMTIME *date, BOOL fix) { - if((MONTHCAL_CompareSystemTime(date, &max_allowed_date) == 1) || - (MONTHCAL_CompareSystemTime(date, &min_allowed_date) == -1)) return FALSE; + const SYSTEMTIME *fix_st = NULL; - if(infoPtr->rangeValid & GDTR_MAX) { - if((MONTHCAL_CompareSystemTime(date, &infoPtr->maxDate) == 1)) return FALSE; + if(MONTHCAL_CompareSystemTime(date, &max_allowed_date) == 1) { + fix_st = &max_allowed_date; + } + else if(MONTHCAL_CompareSystemTime(date, &min_allowed_date) == -1) { + fix_st = &min_allowed_date; + } + else if(infoPtr->rangeValid & GDTR_MAX) { + if((MONTHCAL_CompareSystemTime(date, &infoPtr->maxDate) == 1)) { + fix_st = &infoPtr->maxDate; + } + } + else if(infoPtr->rangeValid & GDTR_MIN) { + if((MONTHCAL_CompareSystemTime(date, &infoPtr->minDate) == -1)) { + fix_st = &infoPtr->minDate; + } } - if(infoPtr->rangeValid & GDTR_MIN) { - if((MONTHCAL_CompareSystemTime(date, &infoPtr->minDate) == -1)) return FALSE; + if (fix && fix_st) { + date->wYear = fix_st->wYear; + date->wMonth = fix_st->wMonth; } - return TRUE; + return fix_st ? FALSE : TRUE; } /* Checks passed range width with configured maximum selection count @@ -1369,7 +1384,7 @@ MONTHCAL_GetCurSel(const MONTHCAL_INFO *infoPtr, SYSTEMTIME *curSel) /* FIXME: if the specified date is not visible, make it visible */ static LRESULT -MONTHCAL_SetCurSel(MONTHCAL_INFO *infoPtr, const SYSTEMTIME *curSel) +MONTHCAL_SetCurSel(MONTHCAL_INFO *infoPtr, SYSTEMTIME *curSel) { TRACE("%p\n", curSel); if(!curSel) return FALSE; @@ -1379,7 +1394,7 @@ MONTHCAL_SetCurSel(MONTHCAL_INFO *infoPtr, const SYSTEMTIME *curSel) /* exit earlier if selection equals current */ if (MONTHCAL_IsDateEqual(&infoPtr->curSel, curSel)) return TRUE; - if(!MONTHCAL_IsDateInValidRange(infoPtr, curSel)) return FALSE; + if(!MONTHCAL_IsDateInValidRange(infoPtr, curSel, FALSE)) return FALSE; infoPtr->minSel = *curSel; infoPtr->maxSel = *curSel; @@ -1686,7 +1701,7 @@ static void MONTHCAL_GoToNextMonth(MONTHCAL_INFO *infoPtr) MONTHCAL_GetNextMonth(&next); - if(!MONTHCAL_IsDateInValidRange(infoPtr, &next)) return; + if(!MONTHCAL_IsDateInValidRange(infoPtr, &next, FALSE)) return; infoPtr->curSel = next; @@ -1702,7 +1717,7 @@ static void MONTHCAL_GoToPrevMonth(MONTHCAL_INFO *infoPtr) MONTHCAL_GetPrevMonth(&prev); - if(!MONTHCAL_IsDateInValidRange(infoPtr, &prev)) return; + if(!MONTHCAL_IsDateInValidRange(infoPtr, &prev, FALSE)) return; infoPtr->curSel = prev; @@ -1879,6 +1894,7 @@ MONTHCAL_LButtonDown(MONTHCAL_INFO *infoPtr, LPARAM lParam) if ((i > 0) && (i < 13) && infoPtr->curSel.wMonth != i) { infoPtr->curSel.wMonth = i; + MONTHCAL_IsDateInValidRange(infoPtr, &infoPtr->curSel, TRUE); InvalidateRect(infoPtr->hwndSelf, NULL, FALSE); } return 0;
1
0
0
0
Nikolay Sivov : comctl32/monthcal: Handle September 1752 with a special case - it's a 19 day month.
by Alexandre Julliard
12 Oct '09
12 Oct '09
Module: wine Branch: master Commit: 18857222ecf7c13a113efe4d15fd8952d80efcce URL:
http://source.winehq.org/git/wine.git/?a=commit;h=18857222ecf7c13a113efe4d1…
Author: Nikolay Sivov <bunglehead(a)gmail.com> Date: Sat Oct 10 23:12:43 2009 +0400 comctl32/monthcal: Handle September 1752 with a special case - it's a 19 day month. --- dlls/comctl32/monthcal.c | 17 +++++++++++++---- dlls/comctl32/tests/monthcal.c | 25 +++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/dlls/comctl32/monthcal.c b/dlls/comctl32/monthcal.c index d75526a..9f242ed 100644 --- a/dlls/comctl32/monthcal.c +++ b/dlls/comctl32/monthcal.c @@ -184,6 +184,9 @@ int MONTHCAL_MonthLength(int month, int year) else if(month == 13) month = 1; + /* special case for calendar transition year */ + if(month == min_allowed_date.wMonth && year == min_allowed_date.wYear) return 19; + /* if we have a leap year add 1 day to February */ /* a leap year is a year either divisible by 400 */ /* or divisible by 4 and not by 100 */ @@ -1224,11 +1227,17 @@ MONTHCAL_GetMonthRange(const MONTHCAL_INFO *infoPtr, DWORD flag, SYSTEMTIME *st) switch (flag) { case GMR_VISIBLE: { - /*FIXME: currently multicalendar feature isn't implelented, so entirely + /*FIXME: currently multicalendar feature isn't implemented, so entirely visible month is current */ st[0] = st[1] = infoPtr->curSel; - st[0].wDay = 1; + if (infoPtr->curSel.wMonth == min_allowed_date.wMonth && + infoPtr->curSel.wYear == min_allowed_date.wYear) + { + st[0].wDay = min_allowed_date.wDay; + } + else + st[0].wDay = 1; st[0].wDayOfWeek = MONTHCAL_CalculateDayOfWeek(1, st[0].wMonth, st[0].wYear); st[1].wDay = MONTHCAL_MonthLength(st[1].wMonth, st[1].wYear); @@ -1239,7 +1248,7 @@ MONTHCAL_GetMonthRange(const MONTHCAL_INFO *infoPtr, DWORD flag, SYSTEMTIME *st) } case GMR_DAYSTATE: { - /*FIXME: currently multicalendar feature isn't implelented, + /*FIXME: currently multicalendar feature isn't implemented, min date from previous month and max date from next one returned */ MONTHCAL_GetMinDate(infoPtr, &st[0]); MONTHCAL_GetMaxDate(infoPtr, &st[1]); @@ -1625,7 +1634,7 @@ MONTHCAL_HitTest(const MONTHCAL_INFO *infoPtr, MCHITTESTINFO *lpht) lpht->st.wDay = day; } /* always update day of week */ - lpht->st.wDayOfWeek = MONTHCAL_CalculateDayOfWeek(day, lpht->st.wMonth, + lpht->st.wDayOfWeek = MONTHCAL_CalculateDayOfWeek(lpht->st.wDay, lpht->st.wMonth, lpht->st.wYear); goto done; } diff --git a/dlls/comctl32/tests/monthcal.c b/dlls/comctl32/tests/monthcal.c index d767066..3ead3ed 100644 --- a/dlls/comctl32/tests/monthcal.c +++ b/dlls/comctl32/tests/monthcal.c @@ -1350,6 +1350,7 @@ static void test_monthcal_monthrange(void) int res; SYSTEMTIME st_visible[2], st_daystate[2], st; HWND hwnd; + RECT r; hwnd = create_monthcal_control(0); @@ -1404,6 +1405,30 @@ static void test_monthcal_monthrange(void) ok_sequence(sequences, MONTHCAL_SEQ_INDEX, monthcal_monthrange_seq, "monthcal monthrange", FALSE); + /* resize control to display single Calendar */ + res = SendMessage(hwnd, MCM_GETMINREQRECT, 0, (LPARAM)&r); + MoveWindow(hwnd, 0, 0, r.right, r.bottom, FALSE); + + memset(&st, 0, sizeof(st)); + st.wMonth = 9; + st.wYear = 1752; + st.wDay = 14; + + res = SendMessage(hwnd, MCM_SETCURSEL, 0, (LPARAM)&st); + expect(1, res); + + /* September 1752 has 19 days */ + res = SendMessage(hwnd, MCM_GETMONTHRANGE, GMR_VISIBLE, (LPARAM)st_visible); + expect(1, res); + + expect(1752, st_visible[0].wYear); + expect(9, st_visible[0].wMonth); + expect(14, st_visible[0].wDay); + + expect(1752, st_visible[1].wYear); + expect(9, st_visible[1].wMonth); + expect(19, st_visible[1].wDay); + DestroyWindow(hwnd); }
1
0
0
0
Nikolay Sivov : comctl32/monthcal: Reuse existing calls to get day of week.
by Alexandre Julliard
12 Oct '09
12 Oct '09
Module: wine Branch: master Commit: a00c217ce910bc20f5c40a0a864c588dc720bf37 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=a00c217ce910bc20f5c40a0a8…
Author: Nikolay Sivov <bunglehead(a)gmail.com> Date: Sat Oct 10 21:20:26 2009 +0400 comctl32/monthcal: Reuse existing calls to get day of week. --- dlls/comctl32/monthcal.c | 18 +++++++++++------- 1 files changed, 11 insertions(+), 7 deletions(-) diff --git a/dlls/comctl32/monthcal.c b/dlls/comctl32/monthcal.c index fc73537..d75526a 100644 --- a/dlls/comctl32/monthcal.c +++ b/dlls/comctl32/monthcal.c @@ -131,10 +131,6 @@ typedef struct WNDPROC EditWndProc; /* original Edit window procedure */ } MONTHCAL_INFO, *LPMONTHCAL_INFO; - -/* Offsets of days in the week to the weekday of january 1 in a leap year */ -static const int DayOfWeekTable[] = {0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4}; - static const WCHAR themeClass[] = { 'S','c','r','o','l','l','b','a','r',0 }; /* empty SYSTEMTIME const */ @@ -389,10 +385,18 @@ static void MONTHCAL_CopyDate(const SYSTEMTIME *from, SYSTEMTIME *to) */ int MONTHCAL_CalculateDayOfWeek(WORD day, WORD month, WORD year) { - year-=(month < 3); + FILETIME ft; + SYSTEMTIME st; + + st.wYear = year; + st.wMonth = month; + st.wDay = day; + st.wHour = st.wMinute = st.wSecond = st.wMilliseconds = 0; + + SystemTimeToFileTime(&st, &ft); + FileTimeToSystemTime(&ft, &st); - return((year + year/4 - year/100 + year/400 + - DayOfWeekTable[month-1] + day ) % 7); + return st.wDayOfWeek; } /* properly updates date to point on next month */
1
0
0
0
Nikolay Sivov : comctl32/monthcal: Process UpDown year control through subclass procedure.
by Alexandre Julliard
12 Oct '09
12 Oct '09
Module: wine Branch: master Commit: 2906aaf605e432bdb7d46be33727fe53a525470a URL:
http://source.winehq.org/git/wine.git/?a=commit;h=2906aaf605e432bdb7d46be33…
Author: Nikolay Sivov <bunglehead(a)gmail.com> Date: Sat Oct 10 21:04:16 2009 +0400 comctl32/monthcal: Process UpDown year control through subclass procedure. --- dlls/comctl32/monthcal.c | 126 ++++++++++++++++++++++++++++----------- dlls/comctl32/tests/monthcal.c | 23 +++++++ 2 files changed, 113 insertions(+), 36 deletions(-) diff --git a/dlls/comctl32/monthcal.c b/dlls/comctl32/monthcal.c index 7697187..fc73537 100644 --- a/dlls/comctl32/monthcal.c +++ b/dlls/comctl32/monthcal.c @@ -128,6 +128,7 @@ typedef struct HWND hwndNotify; /* Window to receive the notifications */ HWND hWndYearEdit; /* Window Handle of edit box to handle years */ HWND hWndYearUpDown;/* Window Handle of updown box to handle years */ + WNDPROC EditWndProc; /* original Edit window procedure */ } MONTHCAL_INFO, *LPMONTHCAL_INFO; @@ -1355,7 +1356,7 @@ MONTHCAL_GetCurSel(const MONTHCAL_INFO *infoPtr, SYSTEMTIME *curSel) /* FIXME: if the specified date is not visible, make it visible */ static LRESULT -MONTHCAL_SetCurSel(MONTHCAL_INFO *infoPtr, SYSTEMTIME *curSel) +MONTHCAL_SetCurSel(MONTHCAL_INFO *infoPtr, const SYSTEMTIME *curSel) { TRACE("%p\n", curSel); if(!curSel) return FALSE; @@ -1725,6 +1726,53 @@ MONTHCAL_RButtonUp(MONTHCAL_INFO *infoPtr, LPARAM lParam) return 0; } +/*** + * DESCRIPTION: + * Subclassed edit control windproc function + * + * PARAMETER(S): + * [I] hwnd : the edit window handle + * [I] uMsg : the message that is to be processed + * [I] wParam : first message parameter + * [I] lParam : second message parameter + * + */ +static LRESULT CALLBACK EditWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + MONTHCAL_INFO *infoPtr = (MONTHCAL_INFO *)GetWindowLongPtrW(GetParent(hwnd), 0); + + TRACE("(hwnd=%p, uMsg=%x, wParam=%lx, lParam=%lx)\n", + hwnd, uMsg, wParam, lParam); + + switch (uMsg) + { + case WM_GETDLGCODE: + return DLGC_WANTARROWS | DLGC_WANTALLKEYS; + + case WM_DESTROY: + { + WNDPROC editProc = infoPtr->EditWndProc; + infoPtr->EditWndProc = NULL; + SetWindowLongPtrW(hwnd, GWLP_WNDPROC, (DWORD_PTR)editProc); + return CallWindowProcW(editProc, hwnd, uMsg, wParam, lParam); + } + + case WM_KILLFOCUS: + break; + + case WM_KEYDOWN: + if ((VK_ESCAPE == (INT)wParam) || (VK_RETURN == (INT)wParam)) + break; + + default: + return CallWindowProcW(infoPtr->EditWndProc, hwnd, uMsg, wParam, lParam); + } + + SendMessageW(infoPtr->hWndYearUpDown, WM_CLOSE, 0, 0); + SendMessageW(hwnd, WM_CLOSE, 0, 0); + return 0; +} + /* creates updown control and edit box */ static void MONTHCAL_EditYear(MONTHCAL_INFO *infoPtr) { @@ -1749,6 +1797,12 @@ static void MONTHCAL_EditYear(MONTHCAL_INFO *infoPtr) MAKELONG(max_allowed_date.wYear, min_allowed_date.wYear)); SendMessageW(infoPtr->hWndYearUpDown, UDM_SETBUDDY, (WPARAM)infoPtr->hWndYearEdit, 0); SendMessageW(infoPtr->hWndYearUpDown, UDM_SETPOS, 0, infoPtr->curSel.wYear); + + /* subclass edit box */ + infoPtr->EditWndProc = (WNDPROC)SetWindowLongPtrW(infoPtr->hWndYearEdit, + GWLP_WNDPROC, (DWORD_PTR)EditWndProc); + + SetFocus(infoPtr->hWndYearEdit); } static LRESULT @@ -1757,24 +1811,12 @@ MONTHCAL_LButtonDown(MONTHCAL_INFO *infoPtr, LPARAM lParam) MCHITTESTINFO ht; DWORD hit; - if (infoPtr->hWndYearUpDown) + /* Actually we don't need input focus for calendar, this is used to kill + year updown and its buddy edit box */ + if (IsWindow(infoPtr->hWndYearUpDown)) { - infoPtr->curSel.wYear = SendMessageW(infoPtr->hWndYearUpDown, UDM_SETPOS, 0, 0); - if(!DestroyWindow(infoPtr->hWndYearUpDown)) - { - FIXME("Can't destroy Updown Control\n"); - } - else - infoPtr->hWndYearUpDown = 0; - - if(!DestroyWindow(infoPtr->hWndYearEdit)) - { - FIXME("Can't destroy Updown Control\n"); - } - else - infoPtr->hWndYearEdit = 0; - - InvalidateRect(infoPtr->hwndSelf, NULL, FALSE); + SetFocus(infoPtr->hwndSelf); + return 0; } SetCapture(infoPtr->hwndSelf); @@ -1899,6 +1941,8 @@ MONTHCAL_LButtonUp(MONTHCAL_INFO *infoPtr, LPARAM lParam) SendMessageW(infoPtr->hwndNotify, WM_NOTIFY, nmhdr.idFrom, (LPARAM)&nmhdr); + if(!(infoPtr->status & MC_SEL_LBUTDOWN)) return 0; + ht.cbSize = sizeof(MCHITTESTINFO); ht.pt.x = (short)LOWORD(lParam); ht.pt.y = (short)HIWORD(lParam); @@ -2049,21 +2093,6 @@ MONTHCAL_Paint(MONTHCAL_INFO *infoPtr, HDC hdc_paint) return 0; } - -static LRESULT -MONTHCAL_KillFocus(const MONTHCAL_INFO *infoPtr, HWND hFocusWnd) -{ - TRACE("\n"); - - if (infoPtr->hwndNotify != hFocusWnd) - ShowWindow(infoPtr->hwndSelf, SW_HIDE); - else - InvalidateRect(infoPtr->hwndSelf, NULL, TRUE); - - return 0; -} - - static LRESULT MONTHCAL_SetFocus(const MONTHCAL_INFO *infoPtr) { @@ -2360,6 +2389,31 @@ MONTHCAL_Destroy(MONTHCAL_INFO *infoPtr) return 0; } +/* + * Handler for WM_NOTIFY messages + */ +static LRESULT +MONTHCAL_Notify(MONTHCAL_INFO *infoPtr, NMHDR *hdr) +{ + /* notification from year edit updown */ + if (hdr->code == UDN_DELTAPOS) + { + NMUPDOWN *nmud = (NMUPDOWN*)hdr; + + if (hdr->hwndFrom == infoPtr->hWndYearUpDown) + { + /* year value limits are set up explicitly after updown creation */ + if ((nmud->iDelta + nmud->iPos) != infoPtr->curSel.wYear) + { + SYSTEMTIME new_date = infoPtr->curSel; + + new_date.wYear = nmud->iDelta + nmud->iPos; + MONTHCAL_SetCurSel(infoPtr, &new_date); + } + } + } + return 0; +} static LRESULT WINAPI MONTHCAL_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) @@ -2439,9 +2493,6 @@ MONTHCAL_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) case WM_GETDLGCODE: return DLGC_WANTARROWS | DLGC_WANTCHARS; - case WM_KILLFOCUS: - return MONTHCAL_KillFocus(infoPtr, (HWND)wParam); - case WM_RBUTTONUP: return MONTHCAL_RButtonUp(infoPtr, lParam); @@ -2464,6 +2515,9 @@ MONTHCAL_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) case WM_SIZE: return MONTHCAL_Size(infoPtr, (SHORT)LOWORD(lParam), (SHORT)HIWORD(lParam)); + case WM_NOTIFY: + return MONTHCAL_Notify(infoPtr, (NMHDR*)lParam); + case WM_CREATE: return MONTHCAL_Create(hwnd, (LPCREATESTRUCTW)lParam); diff --git a/dlls/comctl32/tests/monthcal.c b/dlls/comctl32/tests/monthcal.c index 21c171e..d767066 100644 --- a/dlls/comctl32/tests/monthcal.c +++ b/dlls/comctl32/tests/monthcal.c @@ -1647,6 +1647,28 @@ static void test_monthcal_selrange(void) DestroyWindow(hwnd); } +static void test_killfocus(void) +{ + HWND hwnd; + DWORD style; + + hwnd = create_monthcal_control(0); + + /* make parent invisible */ + style = GetWindowLong(parent_wnd, GWL_STYLE); + SetWindowLong(parent_wnd, GWL_STYLE, style &~ WS_VISIBLE); + + SendMessage(hwnd, WM_KILLFOCUS, (WPARAM)GetDesktopWindow(), 0); + + style = GetWindowLong(hwnd, GWL_STYLE); + ok(style & WS_VISIBLE, "Expected WS_VISIBLE to be set\n"); + + style = GetWindowLong(parent_wnd, GWL_STYLE); + SetWindowLong(parent_wnd, GWL_STYLE, style | WS_VISIBLE); + + DestroyWindow(hwnd); +} + START_TEST(monthcal) { HMODULE hComctl32; @@ -1684,6 +1706,7 @@ START_TEST(monthcal) test_monthcal_size(); test_monthcal_maxselday(); test_monthcal_selrange(); + test_killfocus(); flush_sequences(sequences, NUM_MSG_SEQUENCES); DestroyWindow(parent_wnd);
1
0
0
0
Nikolay Sivov : comctl32/tab: Support for TCN_KEYDOWN notification.
by Alexandre Julliard
12 Oct '09
12 Oct '09
Module: wine Branch: master Commit: 48fcccd861394f85ebae0065927431612e43739b URL:
http://source.winehq.org/git/wine.git/?a=commit;h=48fcccd861394f85ebae00659…
Author: Nikolay Sivov <bunglehead(a)gmail.com> Date: Sat Oct 10 03:27:33 2009 +0400 comctl32/tab: Support for TCN_KEYDOWN notification. --- dlls/comctl32/tab.c | 14 +++++++++++--- 1 files changed, 11 insertions(+), 3 deletions(-) diff --git a/dlls/comctl32/tab.c b/dlls/comctl32/tab.c index 431c54c..22af8d7 100644 --- a/dlls/comctl32/tab.c +++ b/dlls/comctl32/tab.c @@ -46,7 +46,6 @@ * NM_RELEASEDCAPTURE * TCN_FOCUSCHANGE * TCN_GETOBJECT - * TCN_KEYDOWN * * Macros: * TabCtrl_AdjustRect @@ -488,9 +487,18 @@ TAB_GetItemRect(const TAB_INFO *infoPtr, INT item, RECT *rect) * * This method is called to handle keyboard input */ -static LRESULT TAB_KeyDown(TAB_INFO* infoPtr, WPARAM keyCode) +static LRESULT TAB_KeyDown(TAB_INFO* infoPtr, WPARAM keyCode, LPARAM lParam) { INT newItem = -1; + NMTCKEYDOWN nm; + + /* TCN_KEYDOWN notification sent always */ + nm.hdr.hwndFrom = infoPtr->hwnd; + nm.hdr.idFrom = GetWindowLongPtrW(infoPtr->hwnd, GWLP_ID); + nm.hdr.code = TCN_KEYDOWN; + nm.wVKey = keyCode; + nm.flags = lParam; + SendMessageW(infoPtr->hwndNotify, WM_NOTIFY, nm.hdr.idFrom, (LPARAM)&nm); switch (keyCode) { @@ -3473,7 +3481,7 @@ TAB_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) break; /* Don't disturb normal focus behavior */ case WM_KEYDOWN: - return TAB_KeyDown(infoPtr, wParam); + return TAB_KeyDown(infoPtr, wParam, lParam); case WM_NCHITTEST: return TAB_NCHitTest(infoPtr, lParam);
1
0
0
0
← Newer
1
...
74
75
76
77
78
79
80
...
121
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
Results per page:
10
25
50
100
200