2009-10-06 21:20:48 +00:00
|
|
|
/*
|
|
|
|
* Month calendar control
|
1998-11-08 11:30:27 +00:00
|
|
|
*
|
1999-07-10 12:00:04 +00:00
|
|
|
* Copyright 1998, 1999 Eric Kohl (ekohl@abo.rhein-zeitung.de)
|
2000-01-04 00:30:21 +00:00
|
|
|
* Copyright 1999 Alex Priem (alexp@sci.kun.nl)
|
|
|
|
* Copyright 1999 Chris Morgan <cmorgan@wpi.edu> and
|
|
|
|
* James Abbatiello <abbeyj@wpi.edu>
|
2000-10-15 00:27:28 +00:00
|
|
|
* Copyright 2000 Uwe Bonnes <bon@elektron.ikp.physik.tu-darmstadt.de>
|
2009-10-06 21:20:48 +00:00
|
|
|
* Copyright 2009 Nikolay Sivov
|
1998-11-08 11:30:27 +00:00
|
|
|
*
|
2002-03-09 23:29:33 +00:00
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 12:49:52 +00:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2002-03-09 23:29:33 +00:00
|
|
|
*
|
2004-10-21 19:52:28 +00:00
|
|
|
* NOTE
|
|
|
|
*
|
|
|
|
* This code was audited for completeness against the documented features
|
|
|
|
* of Comctl32.dll version 6.0 on Oct. 20, 2004, by Dimitrie O. Paun.
|
|
|
|
*
|
|
|
|
* Unless otherwise noted, we believe this code to be complete, as per
|
|
|
|
* the specification mentioned above.
|
|
|
|
* If you discover missing features, or bugs, please note them below.
|
|
|
|
*
|
1998-11-08 11:30:27 +00:00
|
|
|
* TODO:
|
2004-10-21 19:52:28 +00:00
|
|
|
* -- MCM_[GS]ETUNICODEFORMAT
|
|
|
|
* -- MONTHCAL_GetMonthRange
|
|
|
|
* -- handle resources better (doesn't work now);
|
|
|
|
* -- take care of internationalization.
|
|
|
|
* -- keyboard handling.
|
|
|
|
* -- search for FIXME
|
1998-11-08 11:30:27 +00:00
|
|
|
*/
|
|
|
|
|
1999-11-21 02:04:09 +00:00
|
|
|
#include <math.h>
|
2003-09-05 23:08:26 +00:00
|
|
|
#include <stdarg.h>
|
2000-02-10 19:03:02 +00:00
|
|
|
#include <stdio.h>
|
2000-11-01 03:11:12 +00:00
|
|
|
#include <stdlib.h>
|
2001-01-26 20:43:40 +00:00
|
|
|
#include <string.h>
|
1999-11-21 02:04:09 +00:00
|
|
|
|
2000-02-10 19:03:02 +00:00
|
|
|
#include "windef.h"
|
2003-09-05 23:08:26 +00:00
|
|
|
#include "winbase.h"
|
2000-02-10 19:03:02 +00:00
|
|
|
#include "wingdi.h"
|
1999-07-10 12:00:04 +00:00
|
|
|
#include "winuser.h"
|
|
|
|
#include "winnls.h"
|
1998-11-08 11:30:27 +00:00
|
|
|
#include "commctrl.h"
|
1999-07-10 12:00:04 +00:00
|
|
|
#include "comctl32.h"
|
2005-08-11 17:05:00 +00:00
|
|
|
#include "uxtheme.h"
|
|
|
|
#include "tmschema.h"
|
2005-04-11 14:21:00 +00:00
|
|
|
#include "wine/unicode.h"
|
2002-03-09 23:29:33 +00:00
|
|
|
#include "wine/debug.h"
|
1998-11-08 11:30:27 +00:00
|
|
|
|
2002-03-09 23:29:33 +00:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(monthcal);
|
1999-04-19 14:56:29 +00:00
|
|
|
|
2000-08-09 00:41:17 +00:00
|
|
|
#define MC_SEL_LBUTUP 1 /* Left button released */
|
|
|
|
#define MC_SEL_LBUTDOWN 2 /* Left button pressed in calendar */
|
|
|
|
#define MC_PREVPRESSED 4 /* Prev month button pressed */
|
|
|
|
#define MC_NEXTPRESSED 8 /* Next month button pressed */
|
2009-10-06 20:58:22 +00:00
|
|
|
#define MC_PREVNEXTMONTHDELAY 350 /* when continuously pressing `next/prev
|
|
|
|
month', wait 500 ms before going
|
|
|
|
to the next/prev month */
|
|
|
|
#define MC_TODAYUPDATEDELAY 120000 /* time between today check for update (2 min) */
|
|
|
|
|
2009-10-06 19:23:55 +00:00
|
|
|
#define MC_PREVNEXTMONTHTIMER 1 /* Timer ID's */
|
2009-10-06 20:58:22 +00:00
|
|
|
#define MC_TODAYUPDATETIMER 2
|
2000-08-09 00:41:17 +00:00
|
|
|
|
2005-04-11 14:21:00 +00:00
|
|
|
#define countof(arr) (sizeof(arr)/sizeof(arr[0]))
|
|
|
|
|
2009-10-04 19:17:07 +00:00
|
|
|
/* convert from days to 100 nanoseconds unit - used as FILETIME unit */
|
|
|
|
#define DAYSTO100NSECS(days) (((ULONGLONG)(days))*24*60*60*10000000)
|
|
|
|
|
2000-08-09 00:41:17 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
2009-09-08 06:44:55 +00:00
|
|
|
HWND hwndSelf;
|
|
|
|
DWORD dwStyle; /* cached GWL_STYLE */
|
2000-08-09 00:41:17 +00:00
|
|
|
COLORREF bk;
|
|
|
|
COLORREF txt;
|
|
|
|
COLORREF titlebk;
|
|
|
|
COLORREF titletxt;
|
|
|
|
COLORREF monthbk;
|
|
|
|
COLORREF trailingtxt;
|
|
|
|
HFONT hFont;
|
|
|
|
HFONT hBoldFont;
|
|
|
|
int textHeight;
|
|
|
|
int textWidth;
|
|
|
|
int height_increment;
|
|
|
|
int width_increment;
|
|
|
|
int firstDayplace; /* place of the first day of the current month */
|
2009-09-24 23:43:38 +00:00
|
|
|
INT delta; /* scroll rate; # of months that the */
|
2000-08-09 00:41:17 +00:00
|
|
|
/* control moves when user clicks a scroll button */
|
|
|
|
int visible; /* # of months visible */
|
2009-10-07 20:45:05 +00:00
|
|
|
int firstDay; /* Start month calendar with firstDay's day,
|
|
|
|
stored in SYSTEMTIME format */
|
|
|
|
BOOL firstDaySet; /* first week day differs from locale defined */
|
|
|
|
|
2000-08-09 00:41:17 +00:00
|
|
|
int monthRange;
|
|
|
|
MONTHDAYSTATE *monthdayState;
|
|
|
|
SYSTEMTIME todaysDate;
|
2009-10-06 20:58:22 +00:00
|
|
|
BOOL todaySet; /* Today was forced with MCM_SETTODAY */
|
2000-08-09 00:41:17 +00:00
|
|
|
int status; /* See MC_SEL flags */
|
2009-10-04 19:17:07 +00:00
|
|
|
SYSTEMTIME firstSel; /* first selected day */
|
2009-09-24 23:16:51 +00:00
|
|
|
INT maxSelCount;
|
2000-08-09 00:41:17 +00:00
|
|
|
SYSTEMTIME minSel;
|
|
|
|
SYSTEMTIME maxSel;
|
2009-09-26 11:17:59 +00:00
|
|
|
SYSTEMTIME curSel; /* contains currently selected year, month and day */
|
2009-10-04 19:16:41 +00:00
|
|
|
SYSTEMTIME focusedSel; /* date currently focused with mouse movement */
|
2000-08-09 00:41:17 +00:00
|
|
|
DWORD rangeValid;
|
|
|
|
SYSTEMTIME minDate;
|
|
|
|
SYSTEMTIME maxDate;
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2000-08-09 00:41:17 +00:00
|
|
|
RECT title; /* rect for the header above the calendar */
|
|
|
|
RECT titlebtnnext; /* the `next month' button in the header */
|
2002-05-31 23:06:46 +00:00
|
|
|
RECT titlebtnprev; /* the `prev month' button in the header */
|
2000-08-09 00:41:17 +00:00
|
|
|
RECT titlemonth; /* the `month name' txt in the header */
|
|
|
|
RECT titleyear; /* the `year number' txt in the header */
|
2000-10-15 00:27:28 +00:00
|
|
|
RECT wdays; /* week days at top */
|
|
|
|
RECT days; /* calendar area */
|
2000-08-09 00:41:17 +00:00
|
|
|
RECT weeknums; /* week numbers at left side */
|
2000-10-15 00:27:28 +00:00
|
|
|
RECT todayrect; /* `today: xx/xx/xx' text rect */
|
2003-11-20 22:04:13 +00:00
|
|
|
HWND hwndNotify; /* Window to receive the notifications */
|
2000-10-15 00:27:28 +00:00
|
|
|
HWND hWndYearEdit; /* Window Handle of edit box to handle years */
|
|
|
|
HWND hWndYearUpDown;/* Window Handle of updown box to handle years */
|
2009-10-10 17:04:16 +00:00
|
|
|
WNDPROC EditWndProc; /* original Edit window procedure */
|
2000-08-09 00:41:17 +00:00
|
|
|
} MONTHCAL_INFO, *LPMONTHCAL_INFO;
|
|
|
|
|
2005-08-11 17:05:00 +00:00
|
|
|
static const WCHAR themeClass[] = { 'S','c','r','o','l','l','b','a','r',0 };
|
1999-07-10 12:00:04 +00:00
|
|
|
|
2009-10-05 16:34:05 +00:00
|
|
|
/* empty SYSTEMTIME const */
|
|
|
|
static const SYSTEMTIME st_null;
|
2009-10-05 18:37:04 +00:00
|
|
|
/* valid date limits */
|
|
|
|
static const SYSTEMTIME max_allowed_date = { .wYear = 9999, .wMonth = 12, .wDay = 31 };
|
|
|
|
static const SYSTEMTIME min_allowed_date = { .wYear = 1752, .wMonth = 9, .wDay = 14 };
|
|
|
|
|
2009-10-05 16:34:05 +00:00
|
|
|
|
2004-08-25 17:33:01 +00:00
|
|
|
#define MONTHCAL_GetInfoPtr(hwnd) ((MONTHCAL_INFO *)GetWindowLongPtrW(hwnd, 0))
|
1998-11-08 11:30:27 +00:00
|
|
|
|
1999-11-21 02:04:09 +00:00
|
|
|
/* helper functions */
|
|
|
|
|
2009-10-01 18:12:21 +00:00
|
|
|
/* send a single MCN_SELCHANGE notification */
|
|
|
|
static inline void MONTHCAL_NotifySelectionChange(const MONTHCAL_INFO *infoPtr)
|
|
|
|
{
|
|
|
|
NMSELCHANGE nmsc;
|
|
|
|
|
|
|
|
nmsc.nmhdr.hwndFrom = infoPtr->hwndSelf;
|
|
|
|
nmsc.nmhdr.idFrom = GetWindowLongPtrW(infoPtr->hwndSelf, GWLP_ID);
|
|
|
|
nmsc.nmhdr.code = MCN_SELCHANGE;
|
|
|
|
nmsc.stSelStart = infoPtr->minSel;
|
|
|
|
nmsc.stSelEnd = infoPtr->maxSel;
|
|
|
|
SendMessageW(infoPtr->hwndNotify, WM_NOTIFY, nmsc.nmhdr.idFrom, (LPARAM)&nmsc);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* send a single MCN_SELECT notification */
|
|
|
|
static inline void MONTHCAL_NotifySelect(const MONTHCAL_INFO *infoPtr)
|
|
|
|
{
|
|
|
|
NMSELCHANGE nmsc;
|
|
|
|
|
|
|
|
nmsc.nmhdr.hwndFrom = infoPtr->hwndSelf;
|
|
|
|
nmsc.nmhdr.idFrom = GetWindowLongPtrW(infoPtr->hwndSelf, GWLP_ID);
|
|
|
|
nmsc.nmhdr.code = MCN_SELECT;
|
|
|
|
nmsc.stSelStart = infoPtr->minSel;
|
|
|
|
nmsc.stSelEnd = infoPtr->maxSel;
|
|
|
|
|
|
|
|
SendMessageW(infoPtr->hwndNotify, WM_NOTIFY, nmsc.nmhdr.idFrom, (LPARAM)&nmsc);
|
|
|
|
}
|
|
|
|
|
2000-10-15 00:27:28 +00:00
|
|
|
/* returns the number of days in any given month, checking for leap days */
|
1999-11-21 02:04:09 +00:00
|
|
|
/* january is 1, december is 12 */
|
2000-10-15 00:27:28 +00:00
|
|
|
int MONTHCAL_MonthLength(int month, int year)
|
1999-11-21 02:04:09 +00:00
|
|
|
{
|
2005-06-09 09:50:56 +00:00
|
|
|
const int mdays[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 0};
|
2009-10-07 20:45:05 +00:00
|
|
|
/* 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 */
|
2000-10-15 00:27:28 +00:00
|
|
|
if(month == 0)
|
|
|
|
month = 12;
|
2009-10-07 20:45:05 +00:00
|
|
|
else if(month == 13)
|
2000-10-15 00:27:28 +00:00
|
|
|
month = 1;
|
|
|
|
|
2009-10-10 19:12:43 +00:00
|
|
|
/* special case for calendar transition year */
|
|
|
|
if(month == min_allowed_date.wMonth && year == min_allowed_date.wYear) return 19;
|
|
|
|
|
1999-11-21 02:04:09 +00:00
|
|
|
/* 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 */
|
|
|
|
if(month == 2) { /* February */
|
|
|
|
return mdays[month - 1] + ((year%400 == 0) ? 1 : ((year%100 != 0) &&
|
2000-01-04 00:30:21 +00:00
|
|
|
(year%4 == 0)) ? 1 : 0);
|
1999-11-21 02:04:09 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
return mdays[month - 1];
|
|
|
|
}
|
|
|
|
}
|
1999-07-10 12:00:04 +00:00
|
|
|
|
2009-09-24 23:32:18 +00:00
|
|
|
/* compares timestamps using date part only */
|
|
|
|
static inline BOOL MONTHCAL_IsDateEqual(const SYSTEMTIME *first, const SYSTEMTIME *second)
|
|
|
|
{
|
|
|
|
return (first->wYear == second->wYear) && (first->wMonth == second->wMonth) &&
|
|
|
|
(first->wDay == second->wDay);
|
|
|
|
}
|
1999-07-10 12:00:04 +00:00
|
|
|
|
2009-09-26 16:06:48 +00:00
|
|
|
/* make sure that date fields are valid */
|
|
|
|
static BOOL MONTHCAL_ValidateDate(const SYSTEMTIME *time)
|
1999-07-10 12:00:04 +00:00
|
|
|
{
|
2009-09-26 16:06:48 +00:00
|
|
|
if(time->wMonth < 1 || time->wMonth > 12 ) return FALSE;
|
|
|
|
if(time->wDayOfWeek > 6) return FALSE;
|
|
|
|
if(time->wDay > MONTHCAL_MonthLength(time->wMonth, time->wYear))
|
2000-01-04 00:30:21 +00:00
|
|
|
return FALSE;
|
|
|
|
|
1999-11-21 02:04:09 +00:00
|
|
|
return TRUE;
|
1999-07-10 12:00:04 +00:00
|
|
|
}
|
|
|
|
|
2009-10-10 23:54:11 +00:00
|
|
|
/* 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;
|
|
|
|
}
|
|
|
|
|
2009-10-04 19:17:33 +00:00
|
|
|
/* Compares two dates in SYSTEMTIME format
|
|
|
|
*
|
|
|
|
* PARAMETERS
|
|
|
|
*
|
|
|
|
* [I] first : pointer to valid first date data to compare
|
|
|
|
* [I] second : pointer to valid second date data to compare
|
|
|
|
*
|
|
|
|
* RETURN VALUE
|
|
|
|
*
|
|
|
|
* -1 : first < second
|
|
|
|
* 0 : first == second
|
|
|
|
* 1 : first > second
|
|
|
|
*
|
|
|
|
* Note that no date validation performed, alreadt validated values expected.
|
|
|
|
*/
|
|
|
|
static LONG MONTHCAL_CompareSystemTime(const SYSTEMTIME *first, const SYSTEMTIME *second)
|
|
|
|
{
|
|
|
|
FILETIME ft_first, ft_second;
|
|
|
|
|
|
|
|
SystemTimeToFileTime(first, &ft_first);
|
|
|
|
SystemTimeToFileTime(second, &ft_second);
|
|
|
|
|
|
|
|
return CompareFileTime(&ft_first, &ft_second);
|
|
|
|
}
|
|
|
|
|
2009-10-10 23:54:11 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2009-10-11 01:03:59 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2009-10-04 19:17:33 +00:00
|
|
|
/* Checks largest possible date range and configured one
|
|
|
|
*
|
|
|
|
* PARAMETERS
|
|
|
|
*
|
|
|
|
* [I] infoPtr : valid pointer to control data
|
|
|
|
* [I] date : pointer to valid date data to check
|
2009-10-10 20:28:51 +00:00
|
|
|
* [I] fix : make date fit valid range
|
2009-10-04 19:17:33 +00:00
|
|
|
*
|
|
|
|
* RETURN VALUE
|
|
|
|
*
|
|
|
|
* TRUE - date whithin largest and configured range
|
|
|
|
* FALSE - date is outside largest or configured range
|
|
|
|
*/
|
2009-10-10 20:28:51 +00:00
|
|
|
static BOOL MONTHCAL_IsDateInValidRange(const MONTHCAL_INFO *infoPtr,
|
|
|
|
SYSTEMTIME *date, BOOL fix)
|
2009-10-04 19:17:33 +00:00
|
|
|
{
|
2009-10-10 20:28:51 +00:00
|
|
|
const SYSTEMTIME *fix_st = NULL;
|
2009-10-04 19:17:33 +00:00
|
|
|
|
2009-10-10 20:28:51 +00:00
|
|
|
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;
|
|
|
|
}
|
2009-10-04 19:17:33 +00:00
|
|
|
}
|
|
|
|
|
2009-10-10 20:28:51 +00:00
|
|
|
if (fix && fix_st) {
|
|
|
|
date->wYear = fix_st->wYear;
|
|
|
|
date->wMonth = fix_st->wMonth;
|
2009-10-04 19:17:33 +00:00
|
|
|
}
|
|
|
|
|
2009-10-10 20:28:51 +00:00
|
|
|
return fix_st ? FALSE : TRUE;
|
2009-10-04 19:17:33 +00:00
|
|
|
}
|
|
|
|
|
2009-10-05 16:29:31 +00:00
|
|
|
/* Checks passed range width with configured maximum selection count
|
|
|
|
*
|
|
|
|
* PARAMETERS
|
|
|
|
*
|
|
|
|
* [I] infoPtr : valid pointer to control data
|
|
|
|
* [I] range0 : pointer to valid date data (requested bound)
|
|
|
|
* [I] range1 : pointer to valid date data (primary bound)
|
|
|
|
* [O] adjust : returns adjusted range bound to fit maximum range (optional)
|
|
|
|
*
|
|
|
|
* Adjust value computed basing on primary bound and current maximum selection
|
|
|
|
* count. For simple range check (without adjusted value required) (range0, range1)
|
|
|
|
* relation means nothing.
|
|
|
|
*
|
|
|
|
* RETURN VALUE
|
|
|
|
*
|
|
|
|
* TRUE - range is shorter or equal to maximum
|
|
|
|
* FALSE - range is larger than maximum
|
|
|
|
*/
|
|
|
|
static BOOL MONTHCAL_IsSelRangeValid(const MONTHCAL_INFO *infoPtr,
|
|
|
|
const SYSTEMTIME *range0,
|
|
|
|
const SYSTEMTIME *range1,
|
|
|
|
SYSTEMTIME *adjust)
|
|
|
|
{
|
|
|
|
ULARGE_INTEGER ul_range0, ul_range1, ul_diff;
|
|
|
|
FILETIME ft_range0, ft_range1;
|
|
|
|
LONG cmp;
|
|
|
|
|
|
|
|
SystemTimeToFileTime(range0, &ft_range0);
|
|
|
|
SystemTimeToFileTime(range1, &ft_range1);
|
|
|
|
|
|
|
|
ul_range0.LowPart = ft_range0.dwLowDateTime;
|
|
|
|
ul_range0.HighPart = ft_range0.dwHighDateTime;
|
|
|
|
ul_range1.LowPart = ft_range1.dwLowDateTime;
|
|
|
|
ul_range1.HighPart = ft_range1.dwHighDateTime;
|
|
|
|
|
|
|
|
cmp = CompareFileTime(&ft_range0, &ft_range1);
|
|
|
|
|
|
|
|
if(cmp == 1)
|
|
|
|
ul_diff.QuadPart = ul_range0.QuadPart - ul_range1.QuadPart;
|
|
|
|
else
|
|
|
|
ul_diff.QuadPart = -ul_range0.QuadPart + ul_range1.QuadPart;
|
|
|
|
|
|
|
|
if(ul_diff.QuadPart >= DAYSTO100NSECS(infoPtr->maxSelCount)) {
|
|
|
|
|
|
|
|
if(adjust) {
|
|
|
|
if(cmp == 1)
|
|
|
|
ul_range0.QuadPart = ul_range1.QuadPart + DAYSTO100NSECS(infoPtr->maxSelCount - 1);
|
|
|
|
else
|
|
|
|
ul_range0.QuadPart = ul_range1.QuadPart - DAYSTO100NSECS(infoPtr->maxSelCount - 1);
|
|
|
|
|
|
|
|
ft_range0.dwLowDateTime = ul_range0.LowPart;
|
|
|
|
ft_range0.dwHighDateTime = ul_range0.HighPart;
|
|
|
|
FileTimeToSystemTime(&ft_range0, adjust);
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
else return TRUE;
|
|
|
|
}
|
|
|
|
|
2009-09-26 16:06:48 +00:00
|
|
|
/* Used in MCM_SETRANGE/MCM_SETSELRANGE to determine resulting time part.
|
2009-10-08 09:23:19 +00:00
|
|
|
Milliseconds are intentionally not validated. */
|
2009-09-26 16:06:48 +00:00
|
|
|
static BOOL MONTHCAL_ValidateTime(const SYSTEMTIME *time)
|
|
|
|
{
|
|
|
|
if((time->wHour > 24) || (time->wMinute > 59) || (time->wSecond > 59))
|
|
|
|
return FALSE;
|
|
|
|
else
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2002-05-31 23:06:46 +00:00
|
|
|
/* Note:Depending on DST, this may be offset by a day.
|
1999-07-10 12:00:04 +00:00
|
|
|
Need to find out if we're on a DST place & adjust the clock accordingly.
|
|
|
|
Above function assumes we have a valid data.
|
1999-11-21 02:04:09 +00:00
|
|
|
Valid for year>1752; 1 <= d <= 31, 1 <= m <= 12.
|
2005-04-14 11:31:17 +00:00
|
|
|
0 = Sunday.
|
1999-07-10 12:00:04 +00:00
|
|
|
*/
|
|
|
|
|
2009-10-07 20:45:05 +00:00
|
|
|
/* Returns the day in the week
|
|
|
|
*
|
|
|
|
* PARAMETERS
|
2009-10-11 00:28:09 +00:00
|
|
|
* [i] date : input date
|
|
|
|
* [I] inplace : set calculated value back to date structure
|
2009-10-07 20:45:05 +00:00
|
|
|
*
|
|
|
|
* RETURN VALUE
|
|
|
|
* day of week in SYSTEMTIME format: (0 == sunday,..., 6 == saturday)
|
|
|
|
*/
|
2009-10-11 00:28:09 +00:00
|
|
|
int MONTHCAL_CalculateDayOfWeek(SYSTEMTIME *date, BOOL inplace)
|
1999-07-10 12:00:04 +00:00
|
|
|
{
|
2009-10-11 00:28:09 +00:00
|
|
|
SYSTEMTIME st = st_null;
|
2009-10-10 17:20:26 +00:00
|
|
|
FILETIME ft;
|
|
|
|
|
2009-10-11 00:28:09 +00:00
|
|
|
MONTHCAL_CopyDate(date, &st);
|
2009-10-10 17:20:26 +00:00
|
|
|
|
|
|
|
SystemTimeToFileTime(&st, &ft);
|
|
|
|
FileTimeToSystemTime(&ft, &st);
|
1999-11-21 02:04:09 +00:00
|
|
|
|
2009-10-11 00:28:09 +00:00
|
|
|
if (inplace) date->wDayOfWeek = st.wDayOfWeek;
|
|
|
|
|
2009-10-10 17:20:26 +00:00
|
|
|
return st.wDayOfWeek;
|
1999-07-10 12:00:04 +00:00
|
|
|
}
|
|
|
|
|
2009-10-06 23:19:52 +00:00
|
|
|
/* properly updates date to point on next month */
|
2009-10-08 10:02:18 +00:00
|
|
|
static inline void MONTHCAL_GetNextMonth(SYSTEMTIME *date)
|
2009-10-06 23:19:52 +00:00
|
|
|
{
|
|
|
|
if(++date->wMonth > 12)
|
|
|
|
{
|
|
|
|
date->wMonth = 1;
|
|
|
|
date->wYear++;
|
|
|
|
}
|
2009-10-11 00:28:09 +00:00
|
|
|
MONTHCAL_CalculateDayOfWeek(date, TRUE);
|
2009-10-06 23:19:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* properly updates date to point on prev month */
|
2009-10-08 10:02:18 +00:00
|
|
|
static inline void MONTHCAL_GetPrevMonth(SYSTEMTIME *date)
|
2009-10-06 23:19:52 +00:00
|
|
|
{
|
|
|
|
if(--date->wMonth < 1)
|
|
|
|
{
|
|
|
|
date->wMonth = 12;
|
|
|
|
date->wYear--;
|
|
|
|
}
|
2009-10-11 00:28:09 +00:00
|
|
|
MONTHCAL_CalculateDayOfWeek(date, TRUE);
|
2009-10-06 23:19:52 +00:00
|
|
|
}
|
|
|
|
|
2009-10-08 10:02:18 +00:00
|
|
|
/* Returns full date for a first currently visible day */
|
|
|
|
static void MONTHCAL_GetMinDate(const MONTHCAL_INFO *infoPtr, SYSTEMTIME *date)
|
|
|
|
{
|
2009-10-11 00:28:09 +00:00
|
|
|
SYSTEMTIME st_first = infoPtr->curSel;
|
2009-10-08 10:02:18 +00:00
|
|
|
int firstDay;
|
|
|
|
|
2009-10-11 00:28:09 +00:00
|
|
|
st_first.wDay = 1;
|
|
|
|
firstDay = MONTHCAL_CalculateDayOfWeek(&st_first, FALSE);
|
2009-10-08 10:02:18 +00:00
|
|
|
|
|
|
|
*date = infoPtr->curSel;
|
|
|
|
MONTHCAL_GetPrevMonth(date);
|
|
|
|
|
|
|
|
date->wDay = MONTHCAL_MonthLength(date->wMonth, date->wYear) +
|
|
|
|
(infoPtr->firstDay - firstDay) % 7 + 1;
|
|
|
|
|
|
|
|
if(date->wDay > MONTHCAL_MonthLength(date->wMonth, date->wYear))
|
|
|
|
date->wDay -= 7;
|
|
|
|
|
|
|
|
/* fix day of week */
|
2009-10-11 00:28:09 +00:00
|
|
|
MONTHCAL_CalculateDayOfWeek(date, TRUE);
|
2009-10-08 10:02:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Returns full date for a last currently visible day */
|
|
|
|
static void MONTHCAL_GetMaxDate(const MONTHCAL_INFO *infoPtr, SYSTEMTIME *date)
|
|
|
|
{
|
|
|
|
SYSTEMTIME st;
|
|
|
|
|
|
|
|
*date = infoPtr->curSel;
|
|
|
|
MONTHCAL_GetNextMonth(date);
|
|
|
|
|
|
|
|
MONTHCAL_GetMinDate(infoPtr, &st);
|
|
|
|
/* Use month length to get max day. 42 means max day count in calendar area */
|
|
|
|
date->wDay = 42 - (MONTHCAL_MonthLength(st.wMonth, st.wYear) - st.wDay + 1) -
|
|
|
|
MONTHCAL_MonthLength(infoPtr->curSel.wMonth, infoPtr->curSel.wYear);
|
|
|
|
|
|
|
|
/* fix day of week */
|
2009-10-11 00:28:09 +00:00
|
|
|
MONTHCAL_CalculateDayOfWeek(date, TRUE);
|
2009-10-08 10:02:18 +00:00
|
|
|
}
|
|
|
|
|
2000-10-15 00:27:28 +00:00
|
|
|
/* From a given point, calculate the row (weekpos), column(daypos)
|
|
|
|
and day in the calendar. day== 0 mean the last day of tha last month
|
|
|
|
*/
|
2007-03-29 21:09:32 +00:00
|
|
|
static int MONTHCAL_CalcDayFromPos(const MONTHCAL_INFO *infoPtr, int x, int y,
|
2002-05-31 23:06:46 +00:00
|
|
|
int *daypos,int *weekpos)
|
1999-07-10 12:00:04 +00:00
|
|
|
{
|
2000-10-15 00:27:28 +00:00
|
|
|
int retval, firstDay;
|
2004-11-08 20:27:02 +00:00
|
|
|
RECT rcClient;
|
2009-10-11 00:28:09 +00:00
|
|
|
SYSTEMTIME st = infoPtr->curSel;
|
2004-11-08 20:27:02 +00:00
|
|
|
|
|
|
|
GetClientRect(infoPtr->hwndSelf, &rcClient);
|
1999-07-10 12:00:04 +00:00
|
|
|
|
1999-11-21 02:04:09 +00:00
|
|
|
/* if the point is outside the x bounds of the window put
|
2005-05-30 09:56:56 +00:00
|
|
|
it at the boundary */
|
2004-11-08 20:27:02 +00:00
|
|
|
if (x > rcClient.right)
|
|
|
|
x = rcClient.right;
|
|
|
|
|
1999-07-10 12:00:04 +00:00
|
|
|
|
2000-10-15 00:27:28 +00:00
|
|
|
*daypos = (x - infoPtr->days.left ) / infoPtr->width_increment;
|
|
|
|
*weekpos = (y - infoPtr->days.top ) / infoPtr->height_increment;
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2009-10-11 00:28:09 +00:00
|
|
|
st.wDay = 1;
|
|
|
|
firstDay = (MONTHCAL_CalculateDayOfWeek(&st, FALSE) + 6 - infoPtr->firstDay) % 7;
|
2000-10-15 00:27:28 +00:00
|
|
|
retval = *daypos + (7 * *weekpos) - firstDay;
|
1999-11-21 02:04:09 +00:00
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2009-10-10 23:54:11 +00:00
|
|
|
/* 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)
|
1999-07-10 12:00:04 +00:00
|
|
|
{
|
2009-10-11 00:28:09 +00:00
|
|
|
SYSTEMTIME st = infoPtr->curSel;
|
2009-10-10 23:54:11 +00:00
|
|
|
LONG cmp;
|
|
|
|
int first;
|
1999-07-10 12:00:04 +00:00
|
|
|
|
2009-10-11 00:28:09 +00:00
|
|
|
st.wDay = 1;
|
|
|
|
first = (MONTHCAL_CalculateDayOfWeek(&st, FALSE) + 6 - infoPtr->firstDay) % 7;
|
1999-11-21 02:04:09 +00:00
|
|
|
|
2009-10-10 23:54:11 +00:00
|
|
|
cmp = MONTHCAL_CompareMonths(date, &infoPtr->curSel);
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2009-10-10 23:54:11 +00:00
|
|
|
/* previous month */
|
|
|
|
if(cmp == -1) {
|
|
|
|
*x = (first - MONTHCAL_MonthLength(date->wMonth, infoPtr->curSel.wYear) + date->wDay) % 7;
|
1999-11-21 02:04:09 +00:00
|
|
|
*y = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-10-10 23:54:11 +00:00
|
|
|
/* 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;
|
1999-07-10 12:00:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-11-21 02:04:09 +00:00
|
|
|
/* x: column(day), y: row(week) */
|
2009-10-10 23:54:11 +00:00
|
|
|
static inline void MONTHCAL_CalcDayRect(const MONTHCAL_INFO *infoPtr, RECT *r, int x, int y)
|
1999-07-10 12:00:04 +00:00
|
|
|
{
|
2000-10-15 00:27:28 +00:00
|
|
|
r->left = infoPtr->days.left + x * infoPtr->width_increment;
|
1999-11-21 02:04:09 +00:00
|
|
|
r->right = r->left + infoPtr->width_increment;
|
2000-10-15 00:27:28 +00:00
|
|
|
r->top = infoPtr->days.top + y * infoPtr->height_increment;
|
1999-07-10 12:00:04 +00:00
|
|
|
r->bottom = r->top + infoPtr->textHeight;
|
|
|
|
}
|
|
|
|
|
1999-11-21 02:04:09 +00:00
|
|
|
|
2009-10-10 23:54:11 +00:00
|
|
|
/* Sets the RECT struct r to the rectangle around the date */
|
2007-03-29 21:09:32 +00:00
|
|
|
static inline void MONTHCAL_CalcPosFromDay(const MONTHCAL_INFO *infoPtr,
|
2009-10-10 23:54:11 +00:00
|
|
|
const SYSTEMTIME *date, RECT *r)
|
1999-07-10 12:00:04 +00:00
|
|
|
{
|
2000-01-04 00:30:21 +00:00
|
|
|
int x, y;
|
1999-07-10 12:00:04 +00:00
|
|
|
|
2009-10-10 23:54:11 +00:00
|
|
|
MONTHCAL_CalcDayXY(infoPtr, date, &x, &y);
|
2000-01-04 00:30:21 +00:00
|
|
|
MONTHCAL_CalcDayRect(infoPtr, r, x, y);
|
1999-07-10 12:00:04 +00:00
|
|
|
}
|
|
|
|
|
2009-10-04 19:16:41 +00:00
|
|
|
/* Focused day helper:
|
|
|
|
|
|
|
|
- set focused date to given value;
|
|
|
|
- reset to zero value if NULL passed;
|
|
|
|
- invalidate previous and new day rectangle only if needed.
|
2009-10-05 16:32:15 +00:00
|
|
|
|
|
|
|
Returns TRUE if focused day changed, FALSE otherwise.
|
2009-10-04 19:16:41 +00:00
|
|
|
*/
|
2009-10-05 16:32:15 +00:00
|
|
|
static BOOL MONTHCAL_SetDayFocus(MONTHCAL_INFO *infoPtr, const SYSTEMTIME *st)
|
2009-10-04 19:16:41 +00:00
|
|
|
{
|
|
|
|
RECT r;
|
|
|
|
|
|
|
|
if(st)
|
|
|
|
{
|
|
|
|
/* there's nothing to do if it's the same date,
|
|
|
|
mouse move within same date rectangle case */
|
2009-10-05 16:32:15 +00:00
|
|
|
if(MONTHCAL_IsDateEqual(&infoPtr->focusedSel, st)) return FALSE;
|
2009-10-04 19:16:41 +00:00
|
|
|
|
|
|
|
/* invalidate old focused day */
|
2009-10-10 23:54:11 +00:00
|
|
|
MONTHCAL_CalcPosFromDay(infoPtr, &infoPtr->focusedSel, &r);
|
2009-10-04 19:16:41 +00:00
|
|
|
InvalidateRect(infoPtr->hwndSelf, &r, FALSE);
|
|
|
|
|
|
|
|
infoPtr->focusedSel = *st;
|
|
|
|
}
|
|
|
|
|
2009-10-10 23:54:11 +00:00
|
|
|
MONTHCAL_CalcPosFromDay(infoPtr, &infoPtr->focusedSel, &r);
|
2009-10-04 19:16:41 +00:00
|
|
|
|
2009-10-05 20:06:55 +00:00
|
|
|
if(!st && MONTHCAL_ValidateDate(&infoPtr->focusedSel))
|
2009-10-04 19:16:41 +00:00
|
|
|
infoPtr->focusedSel = st_null;
|
|
|
|
|
|
|
|
/* on set invalidates new day, on reset clears previous focused day */
|
|
|
|
InvalidateRect(infoPtr->hwndSelf, &r, FALSE);
|
2009-10-05 16:32:15 +00:00
|
|
|
|
|
|
|
return TRUE;
|
2009-10-04 19:16:41 +00:00
|
|
|
}
|
1999-07-10 12:00:04 +00:00
|
|
|
|
2009-10-10 23:54:11 +00:00
|
|
|
/* 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)
|
1999-07-10 12:00:04 +00:00
|
|
|
{
|
2009-09-08 07:55:22 +00:00
|
|
|
HPEN hRedPen = CreatePen(PS_SOLID, 1, RGB(255, 0, 0));
|
2000-01-04 00:30:21 +00:00
|
|
|
HPEN hOldPen2 = SelectObject(hdc, hRedPen);
|
2009-09-08 07:55:22 +00:00
|
|
|
HBRUSH hOldBrush;
|
1999-11-21 02:04:09 +00:00
|
|
|
RECT day_rect;
|
1999-07-10 12:00:04 +00:00
|
|
|
|
2009-10-10 23:54:11 +00:00
|
|
|
MONTHCAL_CalcPosFromDay(infoPtr, date, &day_rect);
|
1999-07-10 12:00:04 +00:00
|
|
|
|
2009-09-08 07:55:22 +00:00
|
|
|
hOldBrush = SelectObject(hdc, GetStockObject(NULL_BRUSH));
|
|
|
|
Rectangle(hdc, day_rect.left, day_rect.top, day_rect.right, day_rect.bottom);
|
|
|
|
|
|
|
|
SelectObject(hdc, hOldBrush);
|
2000-01-04 00:30:21 +00:00
|
|
|
DeleteObject(hRedPen);
|
|
|
|
SelectObject(hdc, hOldPen2);
|
1999-11-21 02:04:09 +00:00
|
|
|
}
|
1999-07-10 12:00:04 +00:00
|
|
|
|
2009-10-11 01:03:59 +00:00
|
|
|
static void MONTHCAL_DrawDay(const MONTHCAL_INFO *infoPtr, HDC hdc, const SYSTEMTIME *st,
|
2000-05-30 20:06:33 +00:00
|
|
|
int x, int y, int bold)
|
1999-07-10 12:00:04 +00:00
|
|
|
{
|
2005-04-11 14:21:00 +00:00
|
|
|
static const WCHAR fmtW[] = { '%','d',0 };
|
|
|
|
WCHAR buf[10];
|
1999-07-10 12:00:04 +00:00
|
|
|
RECT r;
|
2009-09-08 07:55:22 +00:00
|
|
|
static BOOL haveBoldFont, haveSelectedDay = FALSE;
|
1999-11-21 02:04:09 +00:00
|
|
|
HBRUSH hbr;
|
|
|
|
COLORREF oldCol = 0;
|
|
|
|
COLORREF oldBk = 0;
|
1999-07-10 12:00:04 +00:00
|
|
|
|
2009-10-11 01:03:59 +00:00
|
|
|
wsprintfW(buf, fmtW, st->wDay);
|
1999-07-10 12:00:04 +00:00
|
|
|
|
2002-05-31 23:06:46 +00:00
|
|
|
/* No need to check styles: when selection is not valid, it is set to zero.
|
2008-01-23 22:05:21 +00:00
|
|
|
* 1<day<31, so everything is OK.
|
1999-07-10 12:00:04 +00:00
|
|
|
*/
|
|
|
|
|
2000-01-04 00:30:21 +00:00
|
|
|
MONTHCAL_CalcDayRect(infoPtr, &r, x, y);
|
1999-07-10 12:00:04 +00:00
|
|
|
|
2009-10-11 01:03:59 +00:00
|
|
|
if ((MONTHCAL_CompareDate(st, &infoPtr->minSel) >= 0) &&
|
|
|
|
(MONTHCAL_CompareDate(st, &infoPtr->maxSel) <= 0)) {
|
1999-11-21 02:04:09 +00:00
|
|
|
RECT r2;
|
|
|
|
|
2009-10-11 01:03:59 +00:00
|
|
|
TRACE("%d %d %d\n", st->wDay, infoPtr->minSel.wDay, infoPtr->maxSel.wDay);
|
2008-01-24 23:06:37 +00:00
|
|
|
TRACE("%s\n", wine_dbgstr_rect(&r));
|
2000-01-04 00:30:21 +00:00
|
|
|
oldCol = SetTextColor(hdc, infoPtr->monthbk);
|
|
|
|
oldBk = SetBkColor(hdc, infoPtr->trailingtxt);
|
2009-09-08 07:55:22 +00:00
|
|
|
hbr = GetSysColorBrush(COLOR_HIGHLIGHT);
|
|
|
|
FillRect(hdc, &r, hbr);
|
1999-11-21 02:04:09 +00:00
|
|
|
|
|
|
|
/* FIXME: this may need to be changed now b/c of the other
|
|
|
|
drawing changes 11/3/99 CMM */
|
|
|
|
r2.left = r.left - 0.25 * infoPtr->textWidth;
|
|
|
|
r2.top = r.top;
|
|
|
|
r2.right = r.left + 0.5 * infoPtr->textWidth;
|
|
|
|
r2.bottom = r.bottom;
|
2000-01-04 00:30:21 +00:00
|
|
|
if(haveSelectedDay) FillRect(hdc, &r2, hbr);
|
1999-11-21 02:04:09 +00:00
|
|
|
haveSelectedDay = TRUE;
|
|
|
|
} else {
|
|
|
|
haveSelectedDay = FALSE;
|
|
|
|
}
|
1999-07-10 12:00:04 +00:00
|
|
|
|
1999-11-21 02:04:09 +00:00
|
|
|
/* need to add some code for multiple selections */
|
1999-07-10 12:00:04 +00:00
|
|
|
|
2000-01-04 00:30:21 +00:00
|
|
|
if((bold) &&(!haveBoldFont)) {
|
|
|
|
SelectObject(hdc, infoPtr->hBoldFont);
|
1999-11-21 02:04:09 +00:00
|
|
|
haveBoldFont = TRUE;
|
|
|
|
}
|
2000-01-04 00:30:21 +00:00
|
|
|
if((!bold) &&(haveBoldFont)) {
|
|
|
|
SelectObject(hdc, infoPtr->hFont);
|
1999-11-21 02:04:09 +00:00
|
|
|
haveBoldFont = FALSE;
|
|
|
|
}
|
|
|
|
|
2009-09-08 07:55:22 +00:00
|
|
|
SetBkMode(hdc,TRANSPARENT);
|
|
|
|
DrawTextW(hdc, buf, -1, &r, DT_CENTER | DT_VCENTER | DT_SINGLELINE );
|
|
|
|
|
2000-01-04 00:30:21 +00:00
|
|
|
if(haveSelectedDay) {
|
1999-11-21 02:04:09 +00:00
|
|
|
SetTextColor(hdc, oldCol);
|
|
|
|
SetBkColor(hdc, oldBk);
|
|
|
|
}
|
1999-07-10 12:00:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-10-07 18:13:07 +00:00
|
|
|
static void paint_button (MONTHCAL_INFO *infoPtr, HDC hdc, BOOL btnNext)
|
2005-08-11 17:05:00 +00:00
|
|
|
{
|
|
|
|
HTHEME theme = GetWindowTheme (infoPtr->hwndSelf);
|
2009-10-07 18:13:07 +00:00
|
|
|
RECT *r = btnNext ? &infoPtr->titlebtnnext : &infoPtr->titlebtnprev;
|
|
|
|
BOOL pressed = btnNext ? (infoPtr->status & MC_NEXTPRESSED) :
|
|
|
|
(infoPtr->status & MC_PREVPRESSED);
|
2005-08-11 17:05:00 +00:00
|
|
|
if (theme)
|
|
|
|
{
|
|
|
|
static const int states[] = {
|
|
|
|
/* Prev button */
|
|
|
|
ABS_LEFTNORMAL, ABS_LEFTPRESSED, ABS_LEFTDISABLED,
|
|
|
|
/* Next button */
|
|
|
|
ABS_RIGHTNORMAL, ABS_RIGHTPRESSED, ABS_RIGHTDISABLED
|
|
|
|
};
|
|
|
|
int stateNum = btnNext ? 3 : 0;
|
|
|
|
if (pressed)
|
|
|
|
stateNum += 1;
|
|
|
|
else
|
|
|
|
{
|
2009-09-23 23:23:27 +00:00
|
|
|
if (infoPtr->dwStyle & WS_DISABLED) stateNum += 2;
|
2005-08-11 17:05:00 +00:00
|
|
|
}
|
|
|
|
DrawThemeBackground (theme, hdc, SBP_ARROWBTN, states[stateNum], r, NULL);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int style = btnNext ? DFCS_SCROLLRIGHT : DFCS_SCROLLLEFT;
|
|
|
|
if (pressed)
|
|
|
|
style |= DFCS_PUSHED;
|
|
|
|
else
|
|
|
|
{
|
2009-09-23 23:23:27 +00:00
|
|
|
if (infoPtr->dwStyle & WS_DISABLED) style |= DFCS_INACTIVE;
|
2005-08-11 17:05:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DrawFrameControl(hdc, r, DFC_SCROLL, style);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-03-29 21:09:32 +00:00
|
|
|
static void MONTHCAL_Refresh(MONTHCAL_INFO *infoPtr, HDC hdc, const PAINTSTRUCT *ps)
|
1999-07-10 12:00:04 +00:00
|
|
|
{
|
2009-10-07 18:13:07 +00:00
|
|
|
static const WCHAR fmt_monthW[] = { '%','s',' ','%','l','d',0 };
|
1999-11-21 02:04:09 +00:00
|
|
|
RECT *title=&infoPtr->title;
|
|
|
|
RECT *titlemonth=&infoPtr->titlemonth;
|
|
|
|
RECT *titleyear=&infoPtr->titleyear;
|
2000-01-04 00:30:21 +00:00
|
|
|
RECT dayrect;
|
2009-10-08 10:02:18 +00:00
|
|
|
int i, j, m, mask, day, prevMonth;
|
2008-04-12 17:31:43 +00:00
|
|
|
int textHeight = infoPtr->textHeight;
|
1999-11-21 02:04:09 +00:00
|
|
|
SIZE size;
|
|
|
|
HBRUSH hbr;
|
|
|
|
HFONT currentFont;
|
2005-04-11 14:21:00 +00:00
|
|
|
WCHAR buf[20];
|
|
|
|
WCHAR buf1[20];
|
|
|
|
WCHAR buf2[32];
|
2000-01-04 00:30:21 +00:00
|
|
|
COLORREF oldTextColor, oldBkColor;
|
2000-05-30 20:06:33 +00:00
|
|
|
RECT rcTemp;
|
|
|
|
RECT rcDay; /* used in MONTHCAL_CalcDayRect() */
|
2000-10-15 00:27:28 +00:00
|
|
|
int startofprescal;
|
2009-10-08 10:02:18 +00:00
|
|
|
SYSTEMTIME st;
|
1999-11-21 02:04:09 +00:00
|
|
|
|
2009-05-18 15:03:40 +00:00
|
|
|
oldTextColor = SetTextColor(hdc, comctl32_color.clrWindowText);
|
1999-07-10 12:00:04 +00:00
|
|
|
|
2000-07-08 11:43:57 +00:00
|
|
|
/* fill background */
|
|
|
|
hbr = CreateSolidBrush (infoPtr->bk);
|
2004-11-08 20:27:02 +00:00
|
|
|
FillRect(hdc, &ps->rcPaint, hbr);
|
2002-05-31 23:06:46 +00:00
|
|
|
DeleteObject(hbr);
|
1999-07-10 12:00:04 +00:00
|
|
|
|
1999-11-21 02:04:09 +00:00
|
|
|
/* draw header */
|
2000-05-30 20:06:33 +00:00
|
|
|
if(IntersectRect(&rcTemp, &(ps->rcPaint), title))
|
|
|
|
{
|
|
|
|
hbr = CreateSolidBrush(infoPtr->titlebk);
|
|
|
|
FillRect(hdc, title, hbr);
|
2000-07-08 11:43:57 +00:00
|
|
|
DeleteObject(hbr);
|
2000-05-30 20:06:33 +00:00
|
|
|
}
|
2002-05-31 23:06:46 +00:00
|
|
|
|
1999-11-21 02:04:09 +00:00
|
|
|
/* if the previous button is pressed draw it depressed */
|
2009-10-07 18:13:07 +00:00
|
|
|
if(IntersectRect(&rcTemp, &(ps->rcPaint), &infoPtr->titlebtnprev))
|
|
|
|
paint_button(infoPtr, hdc, FALSE);
|
1999-11-21 02:04:09 +00:00
|
|
|
|
2002-05-31 23:06:46 +00:00
|
|
|
/* if next button is depressed draw it depressed */
|
2009-10-07 18:13:07 +00:00
|
|
|
if(IntersectRect(&rcTemp, &(ps->rcPaint), &infoPtr->titlebtnnext))
|
|
|
|
paint_button(infoPtr, hdc, TRUE);
|
1999-11-21 02:04:09 +00:00
|
|
|
|
2000-01-04 00:30:21 +00:00
|
|
|
oldBkColor = SetBkColor(hdc, infoPtr->titlebk);
|
1999-11-21 02:04:09 +00:00
|
|
|
SetTextColor(hdc, infoPtr->titletxt);
|
2000-01-04 00:30:21 +00:00
|
|
|
currentFont = SelectObject(hdc, infoPtr->hBoldFont);
|
1999-11-21 02:04:09 +00:00
|
|
|
|
2009-09-26 11:17:59 +00:00
|
|
|
GetLocaleInfoW( LOCALE_USER_DEFAULT,LOCALE_SMONTHNAME1+infoPtr->curSel.wMonth -1,
|
2005-04-11 14:21:00 +00:00
|
|
|
buf1,countof(buf1));
|
2009-10-07 18:13:07 +00:00
|
|
|
wsprintfW(buf, fmt_monthW, buf1, infoPtr->curSel.wYear);
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2005-04-20 12:51:37 +00:00
|
|
|
if(IntersectRect(&rcTemp, &(ps->rcPaint), title))
|
2000-05-30 20:06:33 +00:00
|
|
|
{
|
2005-04-20 12:51:37 +00:00
|
|
|
DrawTextW(hdc, buf, strlenW(buf), title,
|
2000-01-04 00:30:21 +00:00
|
|
|
DT_CENTER | DT_VCENTER | DT_SINGLELINE);
|
2000-05-30 20:06:33 +00:00
|
|
|
}
|
|
|
|
|
2000-01-04 00:30:21 +00:00
|
|
|
/* titlemonth left/right contained rect for whole titletxt('June 1999')
|
1999-07-10 12:00:04 +00:00
|
|
|
* MCM_HitTestInfo wants month & year rects, so prepare these now.
|
2002-05-31 23:06:46 +00:00
|
|
|
*(no, we can't draw them separately; the whole text is centered)
|
1999-07-10 12:00:04 +00:00
|
|
|
*/
|
2005-04-11 14:21:00 +00:00
|
|
|
GetTextExtentPoint32W(hdc, buf, strlenW(buf), &size);
|
2005-04-20 12:51:37 +00:00
|
|
|
titlemonth->left = title->right / 2 + title->left / 2 - size.cx / 2;
|
|
|
|
titleyear->right = title->right / 2 + title->left / 2 + size.cx / 2;
|
2005-04-11 14:21:00 +00:00
|
|
|
GetTextExtentPoint32W(hdc, buf1, strlenW(buf1), &size);
|
2000-01-04 00:30:21 +00:00
|
|
|
titlemonth->right = titlemonth->left + size.cx;
|
2000-10-15 00:27:28 +00:00
|
|
|
titleyear->left = titlemonth->right;
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2000-10-15 00:27:28 +00:00
|
|
|
/* draw month area */
|
|
|
|
rcTemp.top=infoPtr->wdays.top;
|
|
|
|
rcTemp.left=infoPtr->wdays.left;
|
|
|
|
rcTemp.bottom=infoPtr->todayrect.bottom;
|
|
|
|
rcTemp.right =infoPtr->todayrect.right;
|
|
|
|
if(IntersectRect(&rcTemp, &(ps->rcPaint), &rcTemp))
|
|
|
|
{
|
|
|
|
hbr = CreateSolidBrush(infoPtr->monthbk);
|
|
|
|
FillRect(hdc, &rcTemp, hbr);
|
|
|
|
DeleteObject(hbr);
|
|
|
|
}
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2008-01-23 22:05:21 +00:00
|
|
|
/* draw line under day abbreviations */
|
1999-07-10 12:00:04 +00:00
|
|
|
|
2000-10-15 00:27:28 +00:00
|
|
|
MoveToEx(hdc, infoPtr->days.left + 3, title->bottom + textHeight + 1, NULL);
|
2004-11-08 20:27:02 +00:00
|
|
|
LineTo(hdc, infoPtr->days.right - 3, title->bottom + textHeight + 1);
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2009-09-26 11:17:59 +00:00
|
|
|
prevMonth = infoPtr->curSel.wMonth - 1;
|
|
|
|
if(prevMonth == 0) /* if curSel.wMonth is january(1) prevMonth is */
|
2000-10-15 00:27:28 +00:00
|
|
|
prevMonth = 12; /* december(12) of the previous year */
|
|
|
|
|
|
|
|
infoPtr->wdays.left = infoPtr->days.left = infoPtr->weeknums.right;
|
1999-07-10 12:00:04 +00:00
|
|
|
|
2009-10-07 18:13:07 +00:00
|
|
|
/* draw day abbreviations */
|
2005-04-20 12:51:37 +00:00
|
|
|
SelectObject(hdc, infoPtr->hFont);
|
2000-01-04 00:30:21 +00:00
|
|
|
SetBkColor(hdc, infoPtr->monthbk);
|
1999-11-21 02:04:09 +00:00
|
|
|
SetTextColor(hdc, infoPtr->trailingtxt);
|
1999-07-10 12:00:04 +00:00
|
|
|
|
2009-10-07 18:13:07 +00:00
|
|
|
/* rectangle to draw a single day abbreviation within */
|
|
|
|
dayrect = infoPtr->wdays;
|
|
|
|
dayrect.right = dayrect.left + infoPtr->width_increment;
|
2000-01-04 00:30:21 +00:00
|
|
|
|
1999-11-21 02:04:09 +00:00
|
|
|
i = infoPtr->firstDay;
|
1999-07-10 12:00:04 +00:00
|
|
|
|
2009-10-07 18:13:07 +00:00
|
|
|
for(j = 0; j < 7; j++) {
|
|
|
|
GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SABBREVDAYNAME1 + (i+j+6)%7, buf, countof(buf));
|
|
|
|
DrawTextW(hdc, buf, strlenW(buf), &dayrect, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
|
|
|
|
dayrect.left += infoPtr->width_increment;
|
|
|
|
dayrect.right += infoPtr->width_increment;
|
1999-11-21 02:04:09 +00:00
|
|
|
}
|
1999-07-10 12:00:04 +00:00
|
|
|
|
2009-10-07 20:45:05 +00:00
|
|
|
/* draw day numbers; first, the previous month */
|
2009-10-08 10:02:18 +00:00
|
|
|
MONTHCAL_GetMinDate(infoPtr, &st);
|
|
|
|
day = st.wDay;
|
2000-10-15 00:27:28 +00:00
|
|
|
startofprescal = day;
|
1999-11-21 02:04:09 +00:00
|
|
|
mask = 1<<(day-1);
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
m = 0;
|
2009-10-11 01:03:59 +00:00
|
|
|
while(st.wDay <= MONTHCAL_MonthLength(prevMonth, infoPtr->curSel.wYear)) {
|
2000-05-30 20:06:33 +00:00
|
|
|
MONTHCAL_CalcDayRect(infoPtr, &rcDay, i, 0);
|
|
|
|
if(IntersectRect(&rcTemp, &(ps->rcPaint), &rcDay))
|
|
|
|
{
|
2009-10-11 01:03:59 +00:00
|
|
|
MONTHCAL_DrawDay(infoPtr, hdc, &st, i, 0,
|
1999-11-21 02:04:09 +00:00
|
|
|
infoPtr->monthdayState[m] & mask);
|
2000-05-30 20:06:33 +00:00
|
|
|
}
|
|
|
|
|
2009-10-11 01:03:59 +00:00
|
|
|
mask <<= 1;
|
|
|
|
st.wDay++;
|
1999-11-21 02:04:09 +00:00
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
1999-07-10 12:00:04 +00:00
|
|
|
/* draw `current' month */
|
|
|
|
|
1999-11-21 02:04:09 +00:00
|
|
|
day = 1; /* start at the beginning of the current month */
|
2009-10-11 01:03:59 +00:00
|
|
|
st = infoPtr->curSel;
|
|
|
|
st.wDay = 1;
|
1999-11-21 02:04:09 +00:00
|
|
|
infoPtr->firstDayplace = i;
|
|
|
|
SetTextColor(hdc, infoPtr->txt);
|
|
|
|
m++;
|
|
|
|
mask = 1;
|
|
|
|
|
|
|
|
/* draw the first week of the current month */
|
2009-10-11 01:03:59 +00:00
|
|
|
while(i < 7) {
|
2000-05-30 20:06:33 +00:00
|
|
|
MONTHCAL_CalcDayRect(infoPtr, &rcDay, i, 0);
|
|
|
|
if(IntersectRect(&rcTemp, &(ps->rcPaint), &rcDay))
|
|
|
|
{
|
2009-10-11 01:03:59 +00:00
|
|
|
MONTHCAL_DrawDay(infoPtr, hdc, &st, i, 0,
|
1999-11-21 02:04:09 +00:00
|
|
|
infoPtr->monthdayState[m] & mask);
|
|
|
|
}
|
|
|
|
|
|
|
|
mask<<=1;
|
2009-10-11 01:03:59 +00:00
|
|
|
st.wDay++;
|
1999-11-21 02:04:09 +00:00
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
j = 1; /* move to the 2nd week of the current month */
|
|
|
|
i = 0; /* move back to sunday */
|
2009-10-11 01:03:59 +00:00
|
|
|
while(st.wDay <= MONTHCAL_MonthLength(infoPtr->curSel.wMonth, infoPtr->curSel.wYear)) {
|
2000-05-30 20:06:33 +00:00
|
|
|
MONTHCAL_CalcDayRect(infoPtr, &rcDay, i, j);
|
|
|
|
if(IntersectRect(&rcTemp, &(ps->rcPaint), &rcDay))
|
|
|
|
{
|
2009-10-11 01:03:59 +00:00
|
|
|
MONTHCAL_DrawDay(infoPtr, hdc, &st, i, j,
|
1999-11-21 02:04:09 +00:00
|
|
|
infoPtr->monthdayState[m] & mask);
|
2000-05-30 20:06:33 +00:00
|
|
|
}
|
1999-11-21 02:04:09 +00:00
|
|
|
mask<<=1;
|
2009-10-11 01:03:59 +00:00
|
|
|
st.wDay++;
|
1999-11-21 02:04:09 +00:00
|
|
|
i++;
|
2000-01-04 00:30:21 +00:00
|
|
|
if(i>6) { /* past saturday, goto the next weeks sunday */
|
1999-11-21 02:04:09 +00:00
|
|
|
i = 0;
|
|
|
|
j++;
|
|
|
|
}
|
|
|
|
}
|
1999-07-10 12:00:04 +00:00
|
|
|
|
|
|
|
/* draw `next' month */
|
|
|
|
|
1999-11-21 02:04:09 +00:00
|
|
|
day = 1; /* start at the first day of the next month */
|
2009-10-11 01:03:59 +00:00
|
|
|
st = infoPtr->curSel;
|
|
|
|
st.wDay = 1;
|
|
|
|
MONTHCAL_GetNextMonth(&st);
|
1999-11-21 02:04:09 +00:00
|
|
|
m++;
|
|
|
|
mask = 1;
|
|
|
|
|
|
|
|
SetTextColor(hdc, infoPtr->trailingtxt);
|
2000-01-04 00:30:21 +00:00
|
|
|
while((i<7) &&(j<6)) {
|
2000-05-30 20:06:33 +00:00
|
|
|
MONTHCAL_CalcDayRect(infoPtr, &rcDay, i, j);
|
|
|
|
if(IntersectRect(&rcTemp, &(ps->rcPaint), &rcDay))
|
2002-05-31 23:06:46 +00:00
|
|
|
{
|
2009-10-11 01:03:59 +00:00
|
|
|
MONTHCAL_DrawDay(infoPtr, hdc, &st, i, j,
|
1999-11-21 02:04:09 +00:00
|
|
|
infoPtr->monthdayState[m] & mask);
|
2000-05-30 20:06:33 +00:00
|
|
|
}
|
1999-11-21 02:04:09 +00:00
|
|
|
|
|
|
|
mask<<=1;
|
2009-10-11 01:03:59 +00:00
|
|
|
st.wDay++;
|
1999-11-21 02:04:09 +00:00
|
|
|
day++;
|
2002-05-31 23:06:46 +00:00
|
|
|
i++;
|
2000-01-04 00:30:21 +00:00
|
|
|
if(i==7) { /* past saturday, go to next week's sunday */
|
1999-11-21 02:04:09 +00:00
|
|
|
i = 0;
|
|
|
|
j++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SetTextColor(hdc, infoPtr->txt);
|
1999-07-10 12:00:04 +00:00
|
|
|
|
2009-10-05 16:34:05 +00:00
|
|
|
/* draw today mark rectangle */
|
|
|
|
if((infoPtr->curSel.wMonth == infoPtr->todaysDate.wMonth) &&
|
|
|
|
(infoPtr->curSel.wYear == infoPtr->todaysDate.wYear) &&
|
|
|
|
!(infoPtr->dwStyle & MCS_NOTODAYCIRCLE))
|
|
|
|
{
|
2009-10-10 23:54:11 +00:00
|
|
|
MONTHCAL_CircleDay(infoPtr, hdc, &infoPtr->todaysDate);
|
2009-10-05 16:34:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* draw focused day */
|
|
|
|
if(!MONTHCAL_IsDateEqual(&infoPtr->focusedSel, &st_null))
|
|
|
|
{
|
2009-10-10 23:54:11 +00:00
|
|
|
MONTHCAL_CalcPosFromDay(infoPtr, &infoPtr->focusedSel, &rcDay);
|
2009-10-05 16:34:05 +00:00
|
|
|
|
|
|
|
DrawFocusRect(hdc, &rcDay);
|
|
|
|
}
|
1999-07-10 12:00:04 +00:00
|
|
|
|
2009-10-07 18:13:07 +00:00
|
|
|
/* draw `today' date if style allows it, and draw a circle before today's
|
|
|
|
* date if necessary */
|
2009-09-23 23:23:27 +00:00
|
|
|
if(!(infoPtr->dwStyle & MCS_NOTODAY)) {
|
2009-10-07 18:13:07 +00:00
|
|
|
static const WCHAR todayW[] = { 'T','o','d','a','y',':',0 };
|
|
|
|
static const WCHAR fmt_todayW[] = { '%','s',' ','%','s',0 };
|
|
|
|
RECT rtoday;
|
|
|
|
|
2009-10-10 23:54:11 +00:00
|
|
|
if(!(infoPtr->dwStyle & MCS_NOTODAYCIRCLE)) {
|
|
|
|
SYSTEMTIME fake_st = infoPtr->curSel;
|
|
|
|
|
2000-10-15 00:27:28 +00:00
|
|
|
/*day is the number of days from nextmonth we put on the calendar */
|
2009-10-10 23:54:11 +00:00
|
|
|
fake_st.wDay = day + MONTHCAL_MonthLength(infoPtr->curSel.wMonth, infoPtr->curSel.wYear);
|
|
|
|
MONTHCAL_CircleDay(infoPtr, hdc, &fake_st);
|
1999-11-21 02:04:09 +00:00
|
|
|
}
|
2009-10-07 18:13:07 +00:00
|
|
|
if (!LoadStringW(COMCTL32_hModule, IDM_TODAY, buf1, countof(buf1)))
|
|
|
|
{
|
2000-10-15 00:27:28 +00:00
|
|
|
WARN("Can't load resource\n");
|
2005-04-11 14:21:00 +00:00
|
|
|
strcpyW(buf1, todayW);
|
2009-10-07 18:13:07 +00:00
|
|
|
}
|
2000-10-15 00:27:28 +00:00
|
|
|
MONTHCAL_CalcDayRect(infoPtr, &rtoday, 1, 6);
|
2009-10-07 18:13:07 +00:00
|
|
|
GetDateFormatW(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &infoPtr->todaysDate, NULL,
|
|
|
|
buf2, countof(buf2));
|
|
|
|
wsprintfW(buf, fmt_todayW, buf1, buf2);
|
2000-01-04 00:30:21 +00:00
|
|
|
SelectObject(hdc, infoPtr->hBoldFont);
|
2000-05-30 20:06:33 +00:00
|
|
|
|
2005-04-20 12:51:37 +00:00
|
|
|
DrawTextW(hdc, buf, -1, &rtoday, DT_CALCRECT | DT_LEFT | DT_VCENTER | DT_SINGLELINE);
|
2000-10-15 00:27:28 +00:00
|
|
|
if(IntersectRect(&rcTemp, &(ps->rcPaint), &rtoday))
|
2000-05-30 20:06:33 +00:00
|
|
|
{
|
2005-04-11 14:21:00 +00:00
|
|
|
DrawTextW(hdc, buf, -1, &rtoday, DT_LEFT | DT_VCENTER | DT_SINGLELINE);
|
2000-05-30 20:06:33 +00:00
|
|
|
}
|
2000-01-04 00:30:21 +00:00
|
|
|
SelectObject(hdc, infoPtr->hFont);
|
1999-11-21 02:04:09 +00:00
|
|
|
}
|
1999-07-10 12:00:04 +00:00
|
|
|
|
2009-10-07 18:13:07 +00:00
|
|
|
/* eventually draw week numbers */
|
|
|
|
if(infoPtr->dwStyle & MCS_WEEKNUMBERS) {
|
|
|
|
static const WCHAR fmt_weekW[] = { '%','d',0 }; /* week numbers format */
|
|
|
|
int mindays, weeknum, weeknum1;
|
2009-10-11 00:28:09 +00:00
|
|
|
SYSTEMTIME st = infoPtr->curSel;
|
2000-10-15 00:27:28 +00:00
|
|
|
|
|
|
|
/* Rules what week to call the first week of a new year:
|
|
|
|
LOCALE_IFIRSTWEEKOFYEAR == 0 (e.g US?):
|
|
|
|
The week containing Jan 1 is the first week of year
|
2002-05-31 23:06:46 +00:00
|
|
|
LOCALE_IFIRSTWEEKOFYEAR == 2 (e.g. Germany):
|
2000-10-15 00:27:28 +00:00
|
|
|
First week of year must contain 4 days of the new year
|
|
|
|
LOCALE_IFIRSTWEEKOFYEAR == 1 (what contries?)
|
|
|
|
The first week of the year must contain only days of the new year
|
|
|
|
*/
|
2005-04-11 14:21:00 +00:00
|
|
|
GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_IFIRSTWEEKOFYEAR, buf, countof(buf));
|
|
|
|
weeknum = atoiW(buf);
|
2000-10-15 00:27:28 +00:00
|
|
|
switch (weeknum)
|
2009-10-07 18:13:07 +00:00
|
|
|
{
|
2000-10-15 00:27:28 +00:00
|
|
|
case 1: mindays = 6;
|
|
|
|
break;
|
|
|
|
case 2: mindays = 3;
|
|
|
|
break;
|
|
|
|
case 0:
|
|
|
|
default:
|
|
|
|
mindays = 0;
|
2009-10-07 18:13:07 +00:00
|
|
|
}
|
2009-09-26 11:17:59 +00:00
|
|
|
if (infoPtr->curSel.wMonth < 2)
|
2009-10-07 18:13:07 +00:00
|
|
|
{
|
2000-10-15 00:27:28 +00:00
|
|
|
/* calculate all those exceptions for january */
|
2009-10-11 00:28:09 +00:00
|
|
|
st.wDay = st.wMonth = 1;
|
|
|
|
weeknum1 = MONTHCAL_CalculateDayOfWeek(&st, FALSE);
|
2009-10-07 20:45:05 +00:00
|
|
|
if ((infoPtr->firstDay - weeknum1) % 7 > mindays)
|
2009-10-07 18:13:07 +00:00
|
|
|
weeknum = 1;
|
2000-10-15 00:27:28 +00:00
|
|
|
else
|
2009-10-07 18:13:07 +00:00
|
|
|
{
|
2000-10-15 00:27:28 +00:00
|
|
|
weeknum = 0;
|
2009-10-07 18:13:07 +00:00
|
|
|
for(i = 0; i < 11; i++)
|
|
|
|
weeknum += MONTHCAL_MonthLength(i+1, infoPtr->curSel.wYear - 1);
|
|
|
|
|
2009-10-11 00:28:09 +00:00
|
|
|
weeknum += startofprescal + 7;
|
|
|
|
weeknum /= 7;
|
|
|
|
st.wYear -= 1;
|
|
|
|
weeknum1 = MONTHCAL_CalculateDayOfWeek(&st, FALSE);
|
2009-10-07 20:45:05 +00:00
|
|
|
if ((infoPtr->firstDay - weeknum1) % 7 > mindays) weeknum++;
|
2009-10-07 18:13:07 +00:00
|
|
|
}
|
|
|
|
}
|
2000-10-15 00:27:28 +00:00
|
|
|
else
|
2009-10-07 18:13:07 +00:00
|
|
|
{
|
2000-10-15 00:27:28 +00:00
|
|
|
weeknum = 0;
|
2009-10-07 18:13:07 +00:00
|
|
|
for(i = 0; i < prevMonth - 1; i++)
|
|
|
|
weeknum += MONTHCAL_MonthLength(i+1, infoPtr->curSel.wYear);
|
|
|
|
|
|
|
|
weeknum += startofprescal + 7;
|
|
|
|
weeknum /= 7;
|
2009-10-11 00:28:09 +00:00
|
|
|
st.wDay = st.wMonth = 1;
|
|
|
|
weeknum1 = MONTHCAL_CalculateDayOfWeek(&st, FALSE);
|
2009-10-07 20:45:05 +00:00
|
|
|
if ((infoPtr->firstDay - weeknum1) % 7 > mindays) weeknum++;
|
2009-10-07 18:13:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
dayrect = infoPtr->weeknums;
|
|
|
|
dayrect.bottom = dayrect.top + infoPtr->height_increment;
|
|
|
|
|
|
|
|
for(i = 0; i < 6; i++) {
|
|
|
|
if((i == 0) && (weeknum > 50))
|
|
|
|
{
|
|
|
|
wsprintfW(buf, fmt_weekW, weeknum);
|
|
|
|
weeknum = 0;
|
|
|
|
}
|
|
|
|
else if((i == 5) && (weeknum > 47))
|
|
|
|
{
|
|
|
|
wsprintfW(buf, fmt_weekW, 1);
|
2000-10-15 00:27:28 +00:00
|
|
|
}
|
|
|
|
else
|
2009-10-07 18:13:07 +00:00
|
|
|
wsprintfW(buf, fmt_weekW, weeknum + i);
|
|
|
|
|
|
|
|
DrawTextW(hdc, buf, -1, &dayrect, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
|
|
|
|
dayrect.top += infoPtr->height_increment;
|
|
|
|
dayrect.bottom += infoPtr->height_increment;
|
1999-11-21 02:04:09 +00:00
|
|
|
}
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2000-10-15 00:27:28 +00:00
|
|
|
MoveToEx(hdc, infoPtr->weeknums.right, infoPtr->weeknums.top + 3 , NULL);
|
2009-10-07 18:13:07 +00:00
|
|
|
LineTo(hdc, infoPtr->weeknums.right, infoPtr->weeknums.bottom);
|
1999-11-21 02:04:09 +00:00
|
|
|
}
|
1999-07-10 12:00:04 +00:00
|
|
|
|
2009-10-07 18:13:07 +00:00
|
|
|
/* currentFont was font at entering Refresh */
|
2000-01-04 00:30:21 +00:00
|
|
|
SetBkColor(hdc, oldBkColor);
|
2002-05-31 23:06:46 +00:00
|
|
|
SelectObject(hdc, currentFont);
|
2000-01-04 00:30:21 +00:00
|
|
|
SetTextColor(hdc, oldTextColor);
|
1999-07-10 12:00:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-05-31 23:06:46 +00:00
|
|
|
static LRESULT
|
2009-09-23 23:02:31 +00:00
|
|
|
MONTHCAL_GetMinReqRect(const MONTHCAL_INFO *infoPtr, LPRECT lpRect)
|
1999-07-10 12:00:04 +00:00
|
|
|
{
|
2004-11-30 17:35:16 +00:00
|
|
|
TRACE("rect %p\n", lpRect);
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2009-09-23 23:02:31 +00:00
|
|
|
if(!lpRect) return FALSE;
|
1999-07-10 12:00:04 +00:00
|
|
|
|
2009-09-28 20:12:39 +00:00
|
|
|
lpRect->left = infoPtr->title.left;
|
|
|
|
lpRect->top = infoPtr->title.top;
|
|
|
|
lpRect->right = infoPtr->title.right;
|
2004-11-08 20:27:02 +00:00
|
|
|
lpRect->bottom = infoPtr->todayrect.bottom;
|
2009-09-28 20:12:39 +00:00
|
|
|
|
2009-09-23 23:23:27 +00:00
|
|
|
AdjustWindowRect(lpRect, infoPtr->dwStyle, FALSE);
|
2004-11-08 20:27:02 +00:00
|
|
|
|
2009-09-28 20:12:39 +00:00
|
|
|
/* minimal rectangle is zero based */
|
|
|
|
OffsetRect(lpRect, -lpRect->left, -lpRect->top);
|
|
|
|
|
2004-11-08 20:27:02 +00:00
|
|
|
TRACE("%s\n", wine_dbgstr_rect(lpRect));
|
|
|
|
|
1999-11-21 02:04:09 +00:00
|
|
|
return TRUE;
|
1999-07-10 12:00:04 +00:00
|
|
|
}
|
|
|
|
|
2000-05-30 20:06:33 +00:00
|
|
|
|
2002-05-31 23:06:46 +00:00
|
|
|
static LRESULT
|
2009-09-24 23:43:38 +00:00
|
|
|
MONTHCAL_GetColor(const MONTHCAL_INFO *infoPtr, INT index)
|
1999-07-10 12:00:04 +00:00
|
|
|
{
|
2004-11-30 17:35:16 +00:00
|
|
|
TRACE("\n");
|
1999-11-21 02:04:09 +00:00
|
|
|
|
2009-09-24 23:43:38 +00:00
|
|
|
switch(index) {
|
1999-11-21 02:04:09 +00:00
|
|
|
case MCSC_BACKGROUND:
|
|
|
|
return infoPtr->bk;
|
|
|
|
case MCSC_TEXT:
|
|
|
|
return infoPtr->txt;
|
|
|
|
case MCSC_TITLEBK:
|
|
|
|
return infoPtr->titlebk;
|
|
|
|
case MCSC_TITLETEXT:
|
|
|
|
return infoPtr->titletxt;
|
|
|
|
case MCSC_MONTHBK:
|
|
|
|
return infoPtr->monthbk;
|
|
|
|
case MCSC_TRAILINGTEXT:
|
|
|
|
return infoPtr->trailingtxt;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
1999-07-10 12:00:04 +00:00
|
|
|
}
|
|
|
|
|
2000-05-30 20:06:33 +00:00
|
|
|
|
2002-05-31 23:06:46 +00:00
|
|
|
static LRESULT
|
2009-09-24 22:52:37 +00:00
|
|
|
MONTHCAL_SetColor(MONTHCAL_INFO *infoPtr, INT index, COLORREF color)
|
1999-07-10 12:00:04 +00:00
|
|
|
{
|
2009-09-24 22:52:37 +00:00
|
|
|
COLORREF prev = -1;
|
1999-11-21 02:04:09 +00:00
|
|
|
|
2009-09-24 22:52:37 +00:00
|
|
|
TRACE("%d: color %08x\n", index, color);
|
1999-11-21 02:04:09 +00:00
|
|
|
|
2009-09-24 22:52:37 +00:00
|
|
|
switch(index) {
|
1999-11-21 02:04:09 +00:00
|
|
|
case MCSC_BACKGROUND:
|
|
|
|
prev = infoPtr->bk;
|
2009-09-23 23:02:31 +00:00
|
|
|
infoPtr->bk = color;
|
1999-11-21 02:04:09 +00:00
|
|
|
break;
|
|
|
|
case MCSC_TEXT:
|
|
|
|
prev = infoPtr->txt;
|
2009-09-23 23:02:31 +00:00
|
|
|
infoPtr->txt = color;
|
1999-11-21 02:04:09 +00:00
|
|
|
break;
|
|
|
|
case MCSC_TITLEBK:
|
|
|
|
prev = infoPtr->titlebk;
|
2009-09-23 23:02:31 +00:00
|
|
|
infoPtr->titlebk = color;
|
1999-11-21 02:04:09 +00:00
|
|
|
break;
|
|
|
|
case MCSC_TITLETEXT:
|
|
|
|
prev=infoPtr->titletxt;
|
2009-09-23 23:02:31 +00:00
|
|
|
infoPtr->titletxt = color;
|
1999-11-21 02:04:09 +00:00
|
|
|
break;
|
|
|
|
case MCSC_MONTHBK:
|
|
|
|
prev = infoPtr->monthbk;
|
2009-09-23 23:02:31 +00:00
|
|
|
infoPtr->monthbk = color;
|
1999-11-21 02:04:09 +00:00
|
|
|
break;
|
|
|
|
case MCSC_TRAILINGTEXT:
|
|
|
|
prev = infoPtr->trailingtxt;
|
2009-09-23 23:02:31 +00:00
|
|
|
infoPtr->trailingtxt = color;
|
1999-11-21 02:04:09 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2009-09-24 22:52:37 +00:00
|
|
|
InvalidateRect(infoPtr->hwndSelf, NULL, index == MCSC_BACKGROUND ? TRUE : FALSE);
|
1999-11-21 02:04:09 +00:00
|
|
|
return prev;
|
1999-07-10 12:00:04 +00:00
|
|
|
}
|
|
|
|
|
2000-05-30 20:06:33 +00:00
|
|
|
|
2002-05-31 23:06:46 +00:00
|
|
|
static LRESULT
|
2007-03-29 21:09:32 +00:00
|
|
|
MONTHCAL_GetMonthDelta(const MONTHCAL_INFO *infoPtr)
|
1999-07-10 12:00:04 +00:00
|
|
|
{
|
2004-11-30 17:35:16 +00:00
|
|
|
TRACE("\n");
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2000-01-04 00:30:21 +00:00
|
|
|
if(infoPtr->delta)
|
1999-11-21 02:04:09 +00:00
|
|
|
return infoPtr->delta;
|
|
|
|
else
|
|
|
|
return infoPtr->visible;
|
1999-07-10 12:00:04 +00:00
|
|
|
}
|
|
|
|
|
2000-05-30 20:06:33 +00:00
|
|
|
|
2002-05-31 23:06:46 +00:00
|
|
|
static LRESULT
|
2009-09-24 23:43:38 +00:00
|
|
|
MONTHCAL_SetMonthDelta(MONTHCAL_INFO *infoPtr, INT delta)
|
1999-07-10 12:00:04 +00:00
|
|
|
{
|
2009-09-24 23:43:38 +00:00
|
|
|
INT prev = infoPtr->delta;
|
1999-07-10 12:00:04 +00:00
|
|
|
|
2009-09-24 23:43:38 +00:00
|
|
|
TRACE("delta %d\n", delta);
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2009-09-24 23:43:38 +00:00
|
|
|
infoPtr->delta = delta;
|
1999-11-21 02:04:09 +00:00
|
|
|
return prev;
|
1999-07-10 12:00:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-10-07 20:45:05 +00:00
|
|
|
static inline LRESULT
|
2007-03-29 21:09:32 +00:00
|
|
|
MONTHCAL_GetFirstDayOfWeek(const MONTHCAL_INFO *infoPtr)
|
1999-07-10 12:00:04 +00:00
|
|
|
{
|
2009-10-07 20:45:05 +00:00
|
|
|
int day;
|
|
|
|
|
|
|
|
/* convert from SYSTEMTIME to locale format */
|
|
|
|
day = (infoPtr->firstDay >= 0) ? (infoPtr->firstDay+6)%7 : infoPtr->firstDay;
|
|
|
|
|
|
|
|
return MAKELONG(day, infoPtr->firstDaySet);
|
1999-07-10 12:00:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-10-07 18:13:07 +00:00
|
|
|
/* Sets the first day of the week that will appear in the control
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* PARAMETERS:
|
|
|
|
* [I] infoPtr : valid pointer to control data
|
|
|
|
* [I] day : day number to set as new first day (0 == Monday,...,6 == Sunday)
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* RETURN VALUE:
|
|
|
|
* Low word contains previous first day,
|
|
|
|
* high word indicates was first day forced with this message before or is
|
|
|
|
* locale difined (TRUE - was forced, FALSE - wasn't).
|
|
|
|
*
|
|
|
|
* FIXME: this needs to be implemented properly in MONTHCAL_Refresh()
|
|
|
|
* FIXME: we need more error checking here
|
|
|
|
*/
|
2002-05-31 23:06:46 +00:00
|
|
|
static LRESULT
|
2009-09-23 23:02:31 +00:00
|
|
|
MONTHCAL_SetFirstDayOfWeek(MONTHCAL_INFO *infoPtr, INT day)
|
1999-07-10 12:00:04 +00:00
|
|
|
{
|
2009-10-07 20:45:05 +00:00
|
|
|
LRESULT prev = MONTHCAL_GetFirstDayOfWeek(infoPtr);
|
|
|
|
int new_day;
|
1999-11-21 02:04:09 +00:00
|
|
|
|
2009-10-07 20:45:05 +00:00
|
|
|
TRACE("%d\n", day);
|
1999-11-21 02:04:09 +00:00
|
|
|
|
2009-09-23 23:02:31 +00:00
|
|
|
if(day == -1)
|
2007-04-10 01:25:41 +00:00
|
|
|
{
|
2009-10-01 17:52:16 +00:00
|
|
|
WCHAR buf[80];
|
|
|
|
|
|
|
|
GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_IFIRSTDAYOFWEEK, buf, countof(buf));
|
|
|
|
TRACE("%s %d\n", debugstr_w(buf), strlenW(buf));
|
|
|
|
|
2009-10-07 20:45:05 +00:00
|
|
|
new_day = atoiW(buf);
|
2009-10-01 17:52:16 +00:00
|
|
|
|
2009-10-07 20:45:05 +00:00
|
|
|
infoPtr->firstDaySet = FALSE;
|
2007-04-10 01:25:41 +00:00
|
|
|
}
|
2009-09-23 23:02:31 +00:00
|
|
|
else if(day >= 7)
|
2007-04-10 01:25:41 +00:00
|
|
|
{
|
2009-10-07 20:45:05 +00:00
|
|
|
new_day = 6; /* max first day allowed */
|
|
|
|
infoPtr->firstDaySet = TRUE;
|
2007-04-10 01:25:41 +00:00
|
|
|
}
|
2000-10-15 00:27:28 +00:00
|
|
|
else
|
2007-04-10 01:25:41 +00:00
|
|
|
{
|
2009-10-07 20:45:05 +00:00
|
|
|
/* Native behaviour for that case is broken: invalid date number >31
|
|
|
|
got displayed at (0,0) position, current month starts always from
|
|
|
|
(1,0) position. Should be implemnted here as well. */
|
|
|
|
if (day < -1)
|
|
|
|
FIXME("No bug compatibility for day=%d\n", day);
|
|
|
|
|
|
|
|
new_day = day;
|
|
|
|
infoPtr->firstDaySet = TRUE;
|
2007-04-10 01:25:41 +00:00
|
|
|
}
|
2007-03-16 07:34:36 +00:00
|
|
|
|
2009-10-07 20:45:05 +00:00
|
|
|
/* convert from locale to SYSTEMTIME format */
|
|
|
|
infoPtr->firstDay = (new_day >= 0) ? (++new_day) % 7 : new_day;
|
|
|
|
|
2009-10-07 00:25:45 +00:00
|
|
|
InvalidateRect(infoPtr->hwndSelf, NULL, FALSE);
|
|
|
|
|
1999-11-21 02:04:09 +00:00
|
|
|
return prev;
|
1999-07-10 12:00:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static LRESULT
|
2009-10-04 14:27:21 +00:00
|
|
|
MONTHCAL_GetMonthRange(const MONTHCAL_INFO *infoPtr, DWORD flag, SYSTEMTIME *st)
|
1999-07-10 12:00:04 +00:00
|
|
|
{
|
2004-11-30 17:35:16 +00:00
|
|
|
TRACE("\n");
|
1999-11-21 02:04:09 +00:00
|
|
|
|
2009-10-04 14:27:21 +00:00
|
|
|
if(st)
|
|
|
|
{
|
2009-10-08 10:02:18 +00:00
|
|
|
switch (flag) {
|
|
|
|
case GMR_VISIBLE:
|
2009-10-04 14:27:21 +00:00
|
|
|
{
|
2009-10-10 19:12:43 +00:00
|
|
|
/*FIXME: currently multicalendar feature isn't implemented, so entirely
|
2009-10-04 14:27:21 +00:00
|
|
|
visible month is current */
|
|
|
|
st[0] = st[1] = infoPtr->curSel;
|
|
|
|
|
2009-10-10 19:12:43 +00:00
|
|
|
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;
|
2009-10-11 00:28:09 +00:00
|
|
|
MONTHCAL_CalculateDayOfWeek(&st[0], TRUE);
|
2009-10-04 14:27:21 +00:00
|
|
|
|
|
|
|
st[1].wDay = MONTHCAL_MonthLength(st[1].wMonth, st[1].wYear);
|
2009-10-11 00:28:09 +00:00
|
|
|
MONTHCAL_CalculateDayOfWeek(&st[1], TRUE);
|
2009-10-08 10:02:18 +00:00
|
|
|
/* a single current month used */
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
case GMR_DAYSTATE:
|
|
|
|
{
|
2009-10-10 19:12:43 +00:00
|
|
|
/*FIXME: currently multicalendar feature isn't implemented,
|
2009-10-08 10:02:18 +00:00
|
|
|
min date from previous month and max date from next one returned */
|
|
|
|
MONTHCAL_GetMinDate(infoPtr, &st[0]);
|
|
|
|
MONTHCAL_GetMaxDate(infoPtr, &st[1]);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
WARN("Unknown flag value, got %d\n", flag);
|
2009-10-04 14:27:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-07-10 12:00:04 +00:00
|
|
|
return infoPtr->monthRange;
|
|
|
|
}
|
|
|
|
|
1999-11-21 02:04:09 +00:00
|
|
|
|
1999-07-10 12:00:04 +00:00
|
|
|
static LRESULT
|
2007-03-29 21:09:32 +00:00
|
|
|
MONTHCAL_GetMaxTodayWidth(const MONTHCAL_INFO *infoPtr)
|
1999-07-10 12:00:04 +00:00
|
|
|
{
|
2000-10-15 00:27:28 +00:00
|
|
|
return(infoPtr->todayrect.right - infoPtr->todayrect.left);
|
1999-07-10 12:00:04 +00:00
|
|
|
}
|
|
|
|
|
1999-11-21 02:04:09 +00:00
|
|
|
|
1999-07-10 12:00:04 +00:00
|
|
|
static LRESULT
|
2009-09-23 23:02:31 +00:00
|
|
|
MONTHCAL_SetRange(MONTHCAL_INFO *infoPtr, SHORT limits, SYSTEMTIME *range)
|
1999-07-10 12:00:04 +00:00
|
|
|
{
|
2006-02-16 11:19:36 +00:00
|
|
|
FILETIME ft_min, ft_max;
|
2006-02-14 16:12:45 +00:00
|
|
|
|
2009-09-23 23:02:31 +00:00
|
|
|
TRACE("%x %p\n", limits, range);
|
2006-02-14 16:12:45 +00:00
|
|
|
|
2009-09-26 16:06:48 +00:00
|
|
|
if ((limits & GDTR_MIN && !MONTHCAL_ValidateDate(&range[0])) ||
|
|
|
|
(limits & GDTR_MAX && !MONTHCAL_ValidateDate(&range[1])))
|
2006-02-14 16:12:45 +00:00
|
|
|
return FALSE;
|
|
|
|
|
2009-09-23 23:02:31 +00:00
|
|
|
if (limits & GDTR_MIN)
|
2006-02-14 16:12:45 +00:00
|
|
|
{
|
2009-09-26 16:06:48 +00:00
|
|
|
if (!MONTHCAL_ValidateTime(&range[0]))
|
|
|
|
MONTHCAL_CopyTime(&infoPtr->todaysDate, &range[0]);
|
|
|
|
|
2009-09-25 19:41:08 +00:00
|
|
|
infoPtr->minDate = range[0];
|
2006-02-14 16:12:45 +00:00
|
|
|
infoPtr->rangeValid |= GDTR_MIN;
|
1999-11-21 02:04:09 +00:00
|
|
|
}
|
2009-09-23 23:02:31 +00:00
|
|
|
if (limits & GDTR_MAX)
|
2006-02-14 16:12:45 +00:00
|
|
|
{
|
2009-09-26 16:06:48 +00:00
|
|
|
if (!MONTHCAL_ValidateTime(&range[1]))
|
|
|
|
MONTHCAL_CopyTime(&infoPtr->todaysDate, &range[1]);
|
|
|
|
|
2009-09-25 19:41:08 +00:00
|
|
|
infoPtr->maxDate = range[1];
|
2006-02-14 16:12:45 +00:00
|
|
|
infoPtr->rangeValid |= GDTR_MAX;
|
1999-11-21 02:04:09 +00:00
|
|
|
}
|
|
|
|
|
2006-02-16 11:19:36 +00:00
|
|
|
/* Only one limit set - we are done */
|
|
|
|
if ((infoPtr->rangeValid & (GDTR_MIN | GDTR_MAX)) != (GDTR_MIN | GDTR_MAX))
|
|
|
|
return TRUE;
|
2009-09-25 23:09:06 +00:00
|
|
|
|
2006-02-16 11:19:36 +00:00
|
|
|
SystemTimeToFileTime(&infoPtr->maxDate, &ft_max);
|
|
|
|
SystemTimeToFileTime(&infoPtr->minDate, &ft_min);
|
|
|
|
|
2009-09-25 23:09:06 +00:00
|
|
|
if (CompareFileTime(&ft_min, &ft_max) >= 0)
|
2006-02-16 11:19:36 +00:00
|
|
|
{
|
2009-09-23 23:02:31 +00:00
|
|
|
if ((limits & (GDTR_MIN | GDTR_MAX)) == (GDTR_MIN | GDTR_MAX))
|
2006-02-16 11:19:36 +00:00
|
|
|
{
|
|
|
|
/* Native swaps limits only when both limits are being set. */
|
|
|
|
SYSTEMTIME st_tmp = infoPtr->minDate;
|
|
|
|
infoPtr->minDate = infoPtr->maxDate;
|
|
|
|
infoPtr->maxDate = st_tmp;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-09-25 23:09:06 +00:00
|
|
|
/* reset the other limit */
|
2009-10-05 18:37:04 +00:00
|
|
|
if (limits & GDTR_MIN) infoPtr->maxDate = st_null;
|
|
|
|
if (limits & GDTR_MAX) infoPtr->minDate = st_null;
|
|
|
|
infoPtr->rangeValid &= limits & GDTR_MIN ? ~GDTR_MAX : ~GDTR_MIN;
|
2006-02-16 11:19:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-02-16 11:19:09 +00:00
|
|
|
return TRUE;
|
1999-07-10 12:00:04 +00:00
|
|
|
}
|
|
|
|
|
1998-11-08 11:30:27 +00:00
|
|
|
|
1999-07-10 12:00:04 +00:00
|
|
|
static LRESULT
|
2009-09-23 23:02:31 +00:00
|
|
|
MONTHCAL_GetRange(const MONTHCAL_INFO *infoPtr, SYSTEMTIME *range)
|
1999-07-10 12:00:04 +00:00
|
|
|
{
|
2009-09-23 23:02:31 +00:00
|
|
|
TRACE("%p\n", range);
|
1999-07-10 12:00:04 +00:00
|
|
|
|
2009-09-23 23:02:31 +00:00
|
|
|
if(!range) return FALSE;
|
1999-07-10 12:00:04 +00:00
|
|
|
|
2009-09-25 19:41:08 +00:00
|
|
|
range[1] = infoPtr->maxDate;
|
|
|
|
range[0] = infoPtr->minDate;
|
1999-07-10 12:00:04 +00:00
|
|
|
|
|
|
|
return infoPtr->rangeValid;
|
|
|
|
}
|
|
|
|
|
1999-11-21 02:04:09 +00:00
|
|
|
|
1999-07-10 12:00:04 +00:00
|
|
|
static LRESULT
|
2009-09-23 23:02:31 +00:00
|
|
|
MONTHCAL_SetDayState(const MONTHCAL_INFO *infoPtr, INT months, MONTHDAYSTATE *states)
|
1999-07-10 12:00:04 +00:00
|
|
|
{
|
2009-09-23 23:02:31 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
TRACE("%d %p\n", months, states);
|
|
|
|
if(months != infoPtr->monthRange) return 0;
|
1999-07-10 12:00:04 +00:00
|
|
|
|
2009-09-23 23:02:31 +00:00
|
|
|
for(i = 0; i < months; i++)
|
|
|
|
infoPtr->monthdayState[i] = states[i];
|
1999-07-10 12:00:04 +00:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2002-05-31 23:06:46 +00:00
|
|
|
static LRESULT
|
2009-09-23 23:02:31 +00:00
|
|
|
MONTHCAL_GetCurSel(const MONTHCAL_INFO *infoPtr, SYSTEMTIME *curSel)
|
1999-07-10 12:00:04 +00:00
|
|
|
{
|
2009-09-23 23:02:31 +00:00
|
|
|
TRACE("%p\n", curSel);
|
|
|
|
if(!curSel) return FALSE;
|
2009-09-08 06:44:55 +00:00
|
|
|
if(infoPtr->dwStyle & MCS_MULTISELECT) return FALSE;
|
1999-07-10 12:00:04 +00:00
|
|
|
|
2009-10-06 23:19:52 +00:00
|
|
|
*curSel = infoPtr->curSel;
|
2009-09-23 23:02:31 +00:00
|
|
|
TRACE("%d/%d/%d\n", curSel->wYear, curSel->wMonth, curSel->wDay);
|
1999-07-10 12:00:04 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* FIXME: if the specified date is not visible, make it visible */
|
2002-05-31 23:06:46 +00:00
|
|
|
static LRESULT
|
2009-10-10 20:28:51 +00:00
|
|
|
MONTHCAL_SetCurSel(MONTHCAL_INFO *infoPtr, SYSTEMTIME *curSel)
|
1999-07-10 12:00:04 +00:00
|
|
|
{
|
2009-09-23 23:02:31 +00:00
|
|
|
TRACE("%p\n", curSel);
|
|
|
|
if(!curSel) return FALSE;
|
2009-09-08 06:44:55 +00:00
|
|
|
if(infoPtr->dwStyle & MCS_MULTISELECT) return FALSE;
|
1999-07-10 12:00:04 +00:00
|
|
|
|
2009-09-26 16:06:48 +00:00
|
|
|
if(!MONTHCAL_ValidateDate(curSel)) return FALSE;
|
2009-10-05 19:05:53 +00:00
|
|
|
/* exit earlier if selection equals current */
|
|
|
|
if (MONTHCAL_IsDateEqual(&infoPtr->curSel, curSel)) return TRUE;
|
|
|
|
|
2009-10-10 20:28:51 +00:00
|
|
|
if(!MONTHCAL_IsDateInValidRange(infoPtr, curSel, FALSE)) return FALSE;
|
2007-03-09 04:48:48 +00:00
|
|
|
|
2009-09-25 19:41:08 +00:00
|
|
|
infoPtr->minSel = *curSel;
|
|
|
|
infoPtr->maxSel = *curSel;
|
1999-07-10 12:00:04 +00:00
|
|
|
|
2009-09-26 11:17:59 +00:00
|
|
|
infoPtr->curSel = *curSel;
|
2009-09-24 23:13:38 +00:00
|
|
|
|
2009-10-04 19:17:07 +00:00
|
|
|
/* FIXME: it's possible to reduce rectangle here */
|
2004-11-30 17:35:16 +00:00
|
|
|
InvalidateRect(infoPtr->hwndSelf, NULL, FALSE);
|
2000-05-30 20:06:33 +00:00
|
|
|
|
1999-07-10 12:00:04 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
1999-11-21 02:04:09 +00:00
|
|
|
|
2002-05-31 23:06:46 +00:00
|
|
|
static LRESULT
|
2007-03-29 21:09:32 +00:00
|
|
|
MONTHCAL_GetMaxSelCount(const MONTHCAL_INFO *infoPtr)
|
1999-07-10 12:00:04 +00:00
|
|
|
{
|
|
|
|
return infoPtr->maxSelCount;
|
|
|
|
}
|
|
|
|
|
1999-11-21 02:04:09 +00:00
|
|
|
|
2002-05-31 23:06:46 +00:00
|
|
|
static LRESULT
|
2009-09-24 23:16:51 +00:00
|
|
|
MONTHCAL_SetMaxSelCount(MONTHCAL_INFO *infoPtr, INT max)
|
1999-07-10 12:00:04 +00:00
|
|
|
{
|
2009-09-24 23:16:51 +00:00
|
|
|
TRACE("%d\n", max);
|
1999-07-10 12:00:04 +00:00
|
|
|
|
2009-10-01 19:02:56 +00:00
|
|
|
if(!(infoPtr->dwStyle & MCS_MULTISELECT)) return FALSE;
|
|
|
|
if(max <= 0) return FALSE;
|
|
|
|
|
|
|
|
infoPtr->maxSelCount = max;
|
1999-07-10 12:00:04 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-05-31 23:06:46 +00:00
|
|
|
static LRESULT
|
2009-09-23 23:02:31 +00:00
|
|
|
MONTHCAL_GetSelRange(const MONTHCAL_INFO *infoPtr, SYSTEMTIME *range)
|
1999-07-10 12:00:04 +00:00
|
|
|
{
|
2009-09-23 23:02:31 +00:00
|
|
|
TRACE("%p\n", range);
|
1999-07-10 12:00:04 +00:00
|
|
|
|
2009-09-23 23:02:31 +00:00
|
|
|
if(!range) return FALSE;
|
1999-07-10 12:00:04 +00:00
|
|
|
|
2009-09-08 06:44:55 +00:00
|
|
|
if(infoPtr->dwStyle & MCS_MULTISELECT)
|
2000-01-04 00:30:21 +00:00
|
|
|
{
|
2009-09-25 19:41:08 +00:00
|
|
|
range[1] = infoPtr->maxSel;
|
|
|
|
range[0] = infoPtr->minSel;
|
2000-01-04 00:30:21 +00:00
|
|
|
TRACE("[min,max]=[%d %d]\n", infoPtr->minSel.wDay, infoPtr->maxSel.wDay);
|
1999-11-21 02:04:09 +00:00
|
|
|
return TRUE;
|
1999-07-10 12:00:04 +00:00
|
|
|
}
|
2002-05-31 23:06:46 +00:00
|
|
|
|
1999-07-10 12:00:04 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
1999-11-21 02:04:09 +00:00
|
|
|
|
2002-05-31 23:06:46 +00:00
|
|
|
static LRESULT
|
2009-09-23 23:02:31 +00:00
|
|
|
MONTHCAL_SetSelRange(MONTHCAL_INFO *infoPtr, SYSTEMTIME *range)
|
1999-07-10 12:00:04 +00:00
|
|
|
{
|
2009-09-23 23:02:31 +00:00
|
|
|
TRACE("%p\n", range);
|
1999-07-10 12:00:04 +00:00
|
|
|
|
2009-09-23 23:02:31 +00:00
|
|
|
if(!range) return FALSE;
|
1999-07-10 12:00:04 +00:00
|
|
|
|
2009-09-08 06:44:55 +00:00
|
|
|
if(infoPtr->dwStyle & MCS_MULTISELECT)
|
2000-01-04 00:30:21 +00:00
|
|
|
{
|
2009-10-04 19:17:07 +00:00
|
|
|
SYSTEMTIME old_range[2];
|
|
|
|
|
2009-09-26 16:06:48 +00:00
|
|
|
/* adjust timestamps */
|
|
|
|
if(!MONTHCAL_ValidateTime(&range[0]))
|
|
|
|
MONTHCAL_CopyTime(&infoPtr->todaysDate, &range[0]);
|
|
|
|
if(!MONTHCAL_ValidateTime(&range[1]))
|
|
|
|
MONTHCAL_CopyTime(&infoPtr->todaysDate, &range[1]);
|
|
|
|
|
2009-10-05 16:29:31 +00:00
|
|
|
/* maximum range exceeded */
|
|
|
|
if(!MONTHCAL_IsSelRangeValid(infoPtr, &range[0], &range[1], NULL)) return FALSE;
|
|
|
|
|
2009-10-04 19:17:07 +00:00
|
|
|
old_range[0] = infoPtr->minSel;
|
|
|
|
old_range[1] = infoPtr->maxSel;
|
|
|
|
|
2009-10-05 16:26:43 +00:00
|
|
|
/* swap if min > max */
|
|
|
|
if(MONTHCAL_CompareSystemTime(&range[0], &range[1]) <= 0)
|
|
|
|
{
|
|
|
|
infoPtr->minSel = range[0];
|
|
|
|
infoPtr->maxSel = range[1];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
infoPtr->minSel = range[1];
|
|
|
|
infoPtr->maxSel = range[0];
|
|
|
|
}
|
2009-10-11 11:33:02 +00:00
|
|
|
infoPtr->curSel = infoPtr->minSel;
|
2009-10-05 16:26:43 +00:00
|
|
|
|
|
|
|
/* update day of week */
|
2009-10-11 00:28:09 +00:00
|
|
|
MONTHCAL_CalculateDayOfWeek(&infoPtr->minSel, TRUE);
|
|
|
|
MONTHCAL_CalculateDayOfWeek(&infoPtr->maxSel, TRUE);
|
2009-10-11 11:33:02 +00:00
|
|
|
MONTHCAL_CalculateDayOfWeek(&infoPtr->curSel, TRUE);
|
2009-09-26 16:06:48 +00:00
|
|
|
|
2009-10-04 19:17:07 +00:00
|
|
|
/* redraw if bounds changed */
|
|
|
|
/* FIXME: no actual need to redraw everything */
|
|
|
|
if(!MONTHCAL_IsDateEqual(&old_range[0], &range[0]) ||
|
|
|
|
!MONTHCAL_IsDateEqual(&old_range[1], &range[1]))
|
|
|
|
{
|
|
|
|
InvalidateRect(infoPtr->hwndSelf, NULL, FALSE);
|
|
|
|
}
|
|
|
|
|
2000-01-04 00:30:21 +00:00
|
|
|
TRACE("[min,max]=[%d %d]\n", infoPtr->minSel.wDay, infoPtr->maxSel.wDay);
|
1999-11-21 02:04:09 +00:00
|
|
|
return TRUE;
|
1999-07-10 12:00:04 +00:00
|
|
|
}
|
2002-05-31 23:06:46 +00:00
|
|
|
|
1999-07-10 12:00:04 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-05-31 23:06:46 +00:00
|
|
|
static LRESULT
|
2009-09-23 23:02:31 +00:00
|
|
|
MONTHCAL_GetToday(const MONTHCAL_INFO *infoPtr, SYSTEMTIME *today)
|
1999-07-10 12:00:04 +00:00
|
|
|
{
|
2009-09-23 23:02:31 +00:00
|
|
|
TRACE("%p\n", today);
|
1999-07-10 12:00:04 +00:00
|
|
|
|
2009-09-23 23:02:31 +00:00
|
|
|
if(!today) return FALSE;
|
2009-09-25 19:41:08 +00:00
|
|
|
*today = infoPtr->todaysDate;
|
1999-07-10 12:00:04 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2009-10-06 20:58:22 +00:00
|
|
|
/* Internal helper for MCM_SETTODAY handler and auto update timer handler
|
|
|
|
*
|
|
|
|
* RETURN VALUE
|
|
|
|
*
|
|
|
|
* TRUE - today date changed
|
|
|
|
* FALSE - today date isn't changed
|
|
|
|
*/
|
|
|
|
static BOOL
|
|
|
|
MONTHCAL_UpdateToday(MONTHCAL_INFO *infoPtr, const SYSTEMTIME *today)
|
|
|
|
{
|
|
|
|
RECT new_r, old_r;
|
|
|
|
|
|
|
|
if(MONTHCAL_IsDateEqual(today, &infoPtr->todaysDate)) return FALSE;
|
1999-07-10 12:00:04 +00:00
|
|
|
|
2009-10-10 23:54:11 +00:00
|
|
|
MONTHCAL_CalcPosFromDay(infoPtr, &infoPtr->todaysDate, &old_r);
|
|
|
|
MONTHCAL_CalcPosFromDay(infoPtr, today, &new_r);
|
2009-10-06 20:58:22 +00:00
|
|
|
|
|
|
|
infoPtr->todaysDate = *today;
|
|
|
|
|
|
|
|
/* only two days need redrawing */
|
|
|
|
InvalidateRect(infoPtr->hwndSelf, &old_r, FALSE);
|
|
|
|
InvalidateRect(infoPtr->hwndSelf, &new_r, FALSE);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* MCM_SETTODAT handler */
|
2002-05-31 23:06:46 +00:00
|
|
|
static LRESULT
|
2009-10-06 20:58:22 +00:00
|
|
|
MONTHCAL_SetToday(MONTHCAL_INFO *infoPtr, const SYSTEMTIME *today)
|
1999-07-31 11:13:25 +00:00
|
|
|
{
|
2009-09-23 23:02:31 +00:00
|
|
|
TRACE("%p\n", today);
|
1999-07-10 12:00:04 +00:00
|
|
|
|
2009-09-23 23:02:31 +00:00
|
|
|
if(!today) return FALSE;
|
2009-09-24 23:32:18 +00:00
|
|
|
|
2009-10-06 20:58:22 +00:00
|
|
|
/* remember if date was set successfully */
|
|
|
|
if(MONTHCAL_UpdateToday(infoPtr, today)) infoPtr->todaySet = TRUE;
|
2009-09-24 23:32:18 +00:00
|
|
|
|
1999-07-31 11:13:25 +00:00
|
|
|
return TRUE;
|
1999-07-10 12:00:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static LRESULT
|
2009-09-23 23:02:31 +00:00
|
|
|
MONTHCAL_HitTest(const MONTHCAL_INFO *infoPtr, MCHITTESTINFO *lpht)
|
1999-07-10 12:00:04 +00:00
|
|
|
{
|
2000-10-15 00:27:28 +00:00
|
|
|
UINT x,y;
|
|
|
|
DWORD retval;
|
|
|
|
int day,wday,wnum;
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2009-09-26 19:26:53 +00:00
|
|
|
if(!lpht || lpht->cbSize < MCHITTESTINFO_V1_SIZE) return -1;
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2000-10-15 00:27:28 +00:00
|
|
|
x = lpht->pt.x;
|
|
|
|
y = lpht->pt.y;
|
1999-07-10 12:00:04 +00:00
|
|
|
|
2005-04-11 12:57:57 +00:00
|
|
|
ZeroMemory(&lpht->st, sizeof(lpht->st));
|
2002-05-31 23:06:46 +00:00
|
|
|
|
|
|
|
/* Comment in for debugging...
|
|
|
|
TRACE("%d %d wd[%d %d %d %d] d[%d %d %d %d] t[%d %d %d %d] wn[%d %d %d %d]\n", x, y,
|
2000-10-15 00:27:28 +00:00
|
|
|
infoPtr->wdays.left, infoPtr->wdays.right,
|
|
|
|
infoPtr->wdays.top, infoPtr->wdays.bottom,
|
|
|
|
infoPtr->days.left, infoPtr->days.right,
|
|
|
|
infoPtr->days.top, infoPtr->days.bottom,
|
|
|
|
infoPtr->todayrect.left, infoPtr->todayrect.right,
|
|
|
|
infoPtr->todayrect.top, infoPtr->todayrect.bottom,
|
|
|
|
infoPtr->weeknums.left, infoPtr->weeknums.right,
|
|
|
|
infoPtr->weeknums.top, infoPtr->weeknums.bottom);
|
|
|
|
*/
|
1999-07-10 12:00:04 +00:00
|
|
|
|
2000-10-15 00:27:28 +00:00
|
|
|
/* are we in the header? */
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2000-01-04 00:30:21 +00:00
|
|
|
if(PtInRect(&infoPtr->title, lpht->pt)) {
|
|
|
|
if(PtInRect(&infoPtr->titlebtnprev, lpht->pt)) {
|
1999-11-21 02:04:09 +00:00
|
|
|
retval = MCHT_TITLEBTNPREV;
|
|
|
|
goto done;
|
|
|
|
}
|
2000-01-04 00:30:21 +00:00
|
|
|
if(PtInRect(&infoPtr->titlebtnnext, lpht->pt)) {
|
1999-11-21 02:04:09 +00:00
|
|
|
retval = MCHT_TITLEBTNNEXT;
|
|
|
|
goto done;
|
|
|
|
}
|
2000-01-04 00:30:21 +00:00
|
|
|
if(PtInRect(&infoPtr->titlemonth, lpht->pt)) {
|
1999-11-21 02:04:09 +00:00
|
|
|
retval = MCHT_TITLEMONTH;
|
|
|
|
goto done;
|
|
|
|
}
|
2000-01-04 00:30:21 +00:00
|
|
|
if(PtInRect(&infoPtr->titleyear, lpht->pt)) {
|
1999-11-21 02:04:09 +00:00
|
|
|
retval = MCHT_TITLEYEAR;
|
|
|
|
goto done;
|
|
|
|
}
|
2002-05-31 23:06:46 +00:00
|
|
|
|
1999-11-21 02:04:09 +00:00
|
|
|
retval = MCHT_TITLE;
|
|
|
|
goto done;
|
|
|
|
}
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2000-10-15 00:27:28 +00:00
|
|
|
day = MONTHCAL_CalcDayFromPos(infoPtr,x,y,&wday,&wnum);
|
|
|
|
if(PtInRect(&infoPtr->wdays, lpht->pt)) {
|
|
|
|
retval = MCHT_CALENDARDAY;
|
2009-09-26 11:17:59 +00:00
|
|
|
lpht->st.wYear = infoPtr->curSel.wYear;
|
|
|
|
lpht->st.wMonth = (day < 1)? infoPtr->curSel.wMonth -1 : infoPtr->curSel.wMonth;
|
2002-05-31 23:06:46 +00:00
|
|
|
lpht->st.wDay = (day < 1)?
|
2009-09-26 11:17:59 +00:00
|
|
|
MONTHCAL_MonthLength(infoPtr->curSel.wMonth-1, infoPtr->curSel.wYear) -day : day;
|
1999-11-21 02:04:09 +00:00
|
|
|
goto done;
|
|
|
|
}
|
2002-05-31 23:06:46 +00:00
|
|
|
if(PtInRect(&infoPtr->weeknums, lpht->pt)) {
|
|
|
|
retval = MCHT_CALENDARWEEKNUM;
|
2009-09-26 11:17:59 +00:00
|
|
|
lpht->st.wYear = infoPtr->curSel.wYear;
|
|
|
|
lpht->st.wMonth = (day < 1) ? infoPtr->curSel.wMonth -1 :
|
|
|
|
(day > MONTHCAL_MonthLength(infoPtr->curSel.wMonth,infoPtr->curSel.wYear)) ?
|
|
|
|
infoPtr->curSel.wMonth +1 :infoPtr->curSel.wMonth;
|
2002-05-31 23:06:46 +00:00
|
|
|
lpht->st.wDay = (day < 1 ) ?
|
2009-09-26 11:17:59 +00:00
|
|
|
MONTHCAL_MonthLength(infoPtr->curSel.wMonth-1,infoPtr->curSel.wYear) -day :
|
|
|
|
(day > MONTHCAL_MonthLength(infoPtr->curSel.wMonth,infoPtr->curSel.wYear)) ?
|
|
|
|
day - MONTHCAL_MonthLength(infoPtr->curSel.wMonth,infoPtr->curSel.wYear) : day;
|
2002-05-31 23:06:46 +00:00
|
|
|
goto done;
|
1999-11-21 02:04:09 +00:00
|
|
|
}
|
2002-05-31 23:06:46 +00:00
|
|
|
if(PtInRect(&infoPtr->days, lpht->pt))
|
2009-09-29 19:30:49 +00:00
|
|
|
{
|
2009-09-26 11:17:59 +00:00
|
|
|
lpht->st.wYear = infoPtr->curSel.wYear;
|
2009-10-06 23:19:52 +00:00
|
|
|
lpht->st.wMonth = infoPtr->curSel.wMonth;
|
|
|
|
if (day < 1)
|
2009-09-29 19:30:49 +00:00
|
|
|
{
|
2000-10-15 00:27:28 +00:00
|
|
|
retval = MCHT_CALENDARDATEPREV;
|
2009-10-06 23:19:52 +00:00
|
|
|
MONTHCAL_GetPrevMonth(&lpht->st);
|
|
|
|
lpht->st.wDay = MONTHCAL_MonthLength(lpht->st.wMonth, lpht->st.wYear) + day;
|
2009-09-29 19:30:49 +00:00
|
|
|
}
|
2009-10-06 23:19:52 +00:00
|
|
|
else if (day > MONTHCAL_MonthLength(infoPtr->curSel.wMonth, infoPtr->curSel.wYear))
|
2009-09-29 19:30:49 +00:00
|
|
|
{
|
2000-10-15 00:27:28 +00:00
|
|
|
retval = MCHT_CALENDARDATENEXT;
|
2009-10-06 23:19:52 +00:00
|
|
|
MONTHCAL_GetNextMonth(&lpht->st);
|
|
|
|
lpht->st.wDay = day - MONTHCAL_MonthLength(infoPtr->curSel.wMonth, infoPtr->curSel.wYear);
|
2009-09-29 19:30:49 +00:00
|
|
|
}
|
2000-10-15 00:27:28 +00:00
|
|
|
else {
|
|
|
|
retval = MCHT_CALENDARDATE;
|
2009-10-06 23:19:52 +00:00
|
|
|
lpht->st.wDay = day;
|
2000-10-15 00:27:28 +00:00
|
|
|
}
|
2009-10-06 23:19:52 +00:00
|
|
|
/* always update day of week */
|
2009-10-11 00:28:09 +00:00
|
|
|
MONTHCAL_CalculateDayOfWeek(&lpht->st, TRUE);
|
2000-10-15 00:27:28 +00:00
|
|
|
goto done;
|
2009-10-06 23:19:52 +00:00
|
|
|
}
|
2000-10-15 00:27:28 +00:00
|
|
|
if(PtInRect(&infoPtr->todayrect, lpht->pt)) {
|
2002-05-31 23:06:46 +00:00
|
|
|
retval = MCHT_TODAYLINK;
|
1999-11-21 02:04:09 +00:00
|
|
|
goto done;
|
|
|
|
}
|
2002-05-31 23:06:46 +00:00
|
|
|
|
|
|
|
|
1999-11-21 02:04:09 +00:00
|
|
|
/* Hit nothing special? What's left must be background :-) */
|
2002-05-31 23:06:46 +00:00
|
|
|
|
|
|
|
retval = MCHT_CALENDARBK;
|
|
|
|
done:
|
1999-11-21 02:04:09 +00:00
|
|
|
lpht->uHit = retval;
|
1999-07-10 12:00:04 +00:00
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2009-09-26 12:03:34 +00:00
|
|
|
/* MCN_GETDAYSTATE notification helper */
|
|
|
|
static void MONTHCAL_NotifyDayState(MONTHCAL_INFO *infoPtr)
|
1999-07-31 11:13:25 +00:00
|
|
|
{
|
2009-09-08 06:44:55 +00:00
|
|
|
if(infoPtr->dwStyle & MCS_DAYSTATE) {
|
1999-11-21 02:04:09 +00:00
|
|
|
NMDAYSTATE nmds;
|
2009-09-26 11:55:27 +00:00
|
|
|
INT i;
|
1999-07-31 11:13:25 +00:00
|
|
|
|
2004-11-30 17:35:16 +00:00
|
|
|
nmds.nmhdr.hwndFrom = infoPtr->hwndSelf;
|
|
|
|
nmds.nmhdr.idFrom = GetWindowLongPtrW(infoPtr->hwndSelf, GWLP_ID);
|
1999-11-21 02:04:09 +00:00
|
|
|
nmds.nmhdr.code = MCN_GETDAYSTATE;
|
|
|
|
nmds.cDayState = infoPtr->monthRange;
|
2003-09-22 21:32:33 +00:00
|
|
|
nmds.prgDayState = Alloc(infoPtr->monthRange * sizeof(MONTHDAYSTATE));
|
1999-07-31 11:13:25 +00:00
|
|
|
|
2008-08-29 16:17:55 +00:00
|
|
|
nmds.stStart = infoPtr->todaysDate;
|
2009-09-26 11:55:27 +00:00
|
|
|
nmds.stStart.wYear = infoPtr->curSel.wYear;
|
2009-09-26 11:17:59 +00:00
|
|
|
nmds.stStart.wMonth = infoPtr->curSel.wMonth;
|
2008-08-29 16:17:55 +00:00
|
|
|
nmds.stStart.wDay = 1;
|
|
|
|
|
2007-12-29 15:37:34 +00:00
|
|
|
SendMessageW(infoPtr->hwndNotify, WM_NOTIFY, nmds.nmhdr.idFrom, (LPARAM)&nmds);
|
2009-09-26 11:55:27 +00:00
|
|
|
for(i = 0; i < infoPtr->monthRange; i++)
|
1999-11-21 02:04:09 +00:00
|
|
|
infoPtr->monthdayState[i] = nmds.prgDayState[i];
|
2009-09-26 11:55:27 +00:00
|
|
|
|
|
|
|
Free(nmds.prgDayState);
|
1999-11-21 02:04:09 +00:00
|
|
|
}
|
1999-07-31 11:13:25 +00:00
|
|
|
}
|
|
|
|
|
2009-10-11 11:33:02 +00:00
|
|
|
static void MONTHCAL_GoToPrevNextMonth(MONTHCAL_INFO *infoPtr, BOOL prev)
|
2009-09-26 12:03:34 +00:00
|
|
|
{
|
2009-10-11 11:33:02 +00:00
|
|
|
SYSTEMTIME st = infoPtr->curSel;
|
2009-09-26 12:03:34 +00:00
|
|
|
|
2009-10-11 11:33:02 +00:00
|
|
|
TRACE("%s\n", prev ? "prev" : "next");
|
2009-09-26 13:15:17 +00:00
|
|
|
|
2009-10-11 11:33:02 +00:00
|
|
|
if(prev) MONTHCAL_GetPrevMonth(&st); else MONTHCAL_GetNextMonth(&st);
|
2009-09-26 12:03:34 +00:00
|
|
|
|
2009-10-11 11:33:02 +00:00
|
|
|
if(!MONTHCAL_IsDateInValidRange(infoPtr, &st, FALSE)) return;
|
1999-07-31 11:13:25 +00:00
|
|
|
|
2009-10-11 11:33:02 +00:00
|
|
|
if(infoPtr->dwStyle & MCS_MULTISELECT)
|
|
|
|
{
|
|
|
|
SYSTEMTIME range[2];
|
1999-11-21 02:04:09 +00:00
|
|
|
|
2009-10-11 11:33:02 +00:00
|
|
|
range[0] = infoPtr->minSel;
|
|
|
|
range[1] = infoPtr->maxSel;
|
1999-11-21 02:04:09 +00:00
|
|
|
|
2009-10-11 11:33:02 +00:00
|
|
|
if(prev)
|
|
|
|
{
|
|
|
|
MONTHCAL_GetPrevMonth(&range[0]);
|
|
|
|
MONTHCAL_GetPrevMonth(&range[1]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
MONTHCAL_GetNextMonth(&range[0]);
|
|
|
|
MONTHCAL_GetNextMonth(&range[1]);
|
|
|
|
}
|
2009-09-26 13:15:17 +00:00
|
|
|
|
2009-10-11 11:33:02 +00:00
|
|
|
MONTHCAL_SetSelRange(infoPtr, range);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
MONTHCAL_SetCurSel(infoPtr, &st);
|
2009-09-26 13:15:17 +00:00
|
|
|
|
2009-09-26 12:03:34 +00:00
|
|
|
MONTHCAL_NotifyDayState(infoPtr);
|
2009-10-11 11:33:02 +00:00
|
|
|
|
|
|
|
MONTHCAL_NotifySelectionChange(infoPtr);
|
1999-07-31 11:13:25 +00:00
|
|
|
}
|
|
|
|
|
2000-10-15 00:27:28 +00:00
|
|
|
static LRESULT
|
2009-09-28 18:04:41 +00:00
|
|
|
MONTHCAL_RButtonUp(MONTHCAL_INFO *infoPtr, LPARAM lParam)
|
2000-10-15 00:27:28 +00:00
|
|
|
{
|
2005-04-11 14:21:00 +00:00
|
|
|
static const WCHAR todayW[] = { 'G','o',' ','t','o',' ','T','o','d','a','y',':',0 };
|
2000-10-15 00:27:28 +00:00
|
|
|
HMENU hMenu;
|
|
|
|
POINT menupoint;
|
2005-04-11 14:21:00 +00:00
|
|
|
WCHAR buf[32];
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2000-10-15 00:27:28 +00:00
|
|
|
hMenu = CreatePopupMenu();
|
2009-09-26 11:33:47 +00:00
|
|
|
if (!LoadStringW(COMCTL32_hModule, IDM_GOTODAY, buf, countof(buf)))
|
|
|
|
{
|
2000-10-15 00:27:28 +00:00
|
|
|
WARN("Can't load resource\n");
|
2005-04-11 14:21:00 +00:00
|
|
|
strcpyW(buf, todayW);
|
2009-09-26 11:33:47 +00:00
|
|
|
}
|
|
|
|
AppendMenuW(hMenu, MF_STRING|MF_ENABLED, 1, buf);
|
|
|
|
menupoint.x = (short)LOWORD(lParam);
|
|
|
|
menupoint.y = (short)HIWORD(lParam);
|
2004-11-30 17:35:16 +00:00
|
|
|
ClientToScreen(infoPtr->hwndSelf, &menupoint);
|
2009-09-26 11:33:47 +00:00
|
|
|
if( TrackPopupMenu(hMenu, TPM_RIGHTBUTTON | TPM_NONOTIFY | TPM_RETURNCMD,
|
2004-11-30 17:35:16 +00:00
|
|
|
menupoint.x, menupoint.y, 0, infoPtr->hwndSelf, NULL))
|
2009-09-26 11:33:47 +00:00
|
|
|
{
|
|
|
|
infoPtr->curSel = infoPtr->todaysDate;
|
|
|
|
infoPtr->minSel = infoPtr->todaysDate;
|
|
|
|
infoPtr->maxSel = infoPtr->todaysDate;
|
2004-11-30 17:35:16 +00:00
|
|
|
InvalidateRect(infoPtr->hwndSelf, NULL, FALSE);
|
2009-09-26 11:33:47 +00:00
|
|
|
}
|
|
|
|
|
2000-10-15 00:27:28 +00:00
|
|
|
return 0;
|
|
|
|
}
|
1999-07-31 11:13:25 +00:00
|
|
|
|
2009-10-10 17:04:16 +00:00
|
|
|
/***
|
|
|
|
* 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;
|
|
|
|
}
|
|
|
|
|
2009-09-25 23:50:22 +00:00
|
|
|
/* creates updown control and edit box */
|
|
|
|
static void MONTHCAL_EditYear(MONTHCAL_INFO *infoPtr)
|
|
|
|
{
|
|
|
|
infoPtr->hWndYearEdit =
|
2009-10-07 21:04:08 +00:00
|
|
|
CreateWindowExW(0, WC_EDITW, 0, WS_VISIBLE | WS_CHILD | ES_READONLY,
|
2009-09-25 23:50:22 +00:00
|
|
|
infoPtr->titleyear.left + 3, infoPtr->titlebtnnext.top,
|
|
|
|
infoPtr->titleyear.right - infoPtr->titleyear.left + 4,
|
|
|
|
infoPtr->textHeight, infoPtr->hwndSelf,
|
|
|
|
NULL, NULL, NULL);
|
|
|
|
|
|
|
|
SendMessageW(infoPtr->hWndYearEdit, WM_SETFONT, (WPARAM)infoPtr->hBoldFont, TRUE);
|
|
|
|
|
|
|
|
infoPtr->hWndYearUpDown =
|
|
|
|
CreateWindowExW(0, UPDOWN_CLASSW, 0,
|
|
|
|
WS_VISIBLE | WS_CHILD | UDS_SETBUDDYINT | UDS_NOTHOUSANDS | UDS_ARROWKEYS,
|
|
|
|
infoPtr->titleyear.right + 7, infoPtr->titlebtnnext.top,
|
|
|
|
18, infoPtr->textHeight, infoPtr->hwndSelf,
|
|
|
|
NULL, NULL, NULL);
|
|
|
|
|
|
|
|
/* attach edit box */
|
2009-10-05 18:37:04 +00:00
|
|
|
SendMessageW(infoPtr->hWndYearUpDown, UDM_SETRANGE, 0,
|
|
|
|
MAKELONG(max_allowed_date.wYear, min_allowed_date.wYear));
|
2009-09-25 23:50:22 +00:00
|
|
|
SendMessageW(infoPtr->hWndYearUpDown, UDM_SETBUDDY, (WPARAM)infoPtr->hWndYearEdit, 0);
|
2009-09-26 11:17:59 +00:00
|
|
|
SendMessageW(infoPtr->hWndYearUpDown, UDM_SETPOS, 0, infoPtr->curSel.wYear);
|
2009-10-10 17:04:16 +00:00
|
|
|
|
|
|
|
/* subclass edit box */
|
|
|
|
infoPtr->EditWndProc = (WNDPROC)SetWindowLongPtrW(infoPtr->hWndYearEdit,
|
|
|
|
GWLP_WNDPROC, (DWORD_PTR)EditWndProc);
|
|
|
|
|
|
|
|
SetFocus(infoPtr->hWndYearEdit);
|
2009-09-25 23:50:22 +00:00
|
|
|
}
|
|
|
|
|
1999-07-10 12:00:04 +00:00
|
|
|
static LRESULT
|
2004-11-30 17:35:16 +00:00
|
|
|
MONTHCAL_LButtonDown(MONTHCAL_INFO *infoPtr, LPARAM lParam)
|
1999-07-10 12:00:04 +00:00
|
|
|
{
|
1999-11-21 02:04:09 +00:00
|
|
|
MCHITTESTINFO ht;
|
|
|
|
DWORD hit;
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2009-10-10 17:04:16 +00:00
|
|
|
/* 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))
|
2009-09-25 23:50:22 +00:00
|
|
|
{
|
2009-10-10 17:04:16 +00:00
|
|
|
SetFocus(infoPtr->hwndSelf);
|
|
|
|
return 0;
|
2009-09-25 23:50:22 +00:00
|
|
|
}
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2009-10-04 19:16:41 +00:00
|
|
|
SetCapture(infoPtr->hwndSelf);
|
|
|
|
|
2009-09-26 19:26:53 +00:00
|
|
|
ht.cbSize = sizeof(MCHITTESTINFO);
|
2006-10-25 15:41:48 +00:00
|
|
|
ht.pt.x = (short)LOWORD(lParam);
|
|
|
|
ht.pt.y = (short)HIWORD(lParam);
|
2009-09-25 23:50:22 +00:00
|
|
|
|
2009-09-23 23:02:31 +00:00
|
|
|
hit = MONTHCAL_HitTest(infoPtr, &ht);
|
1999-11-21 02:04:09 +00:00
|
|
|
|
2009-10-04 19:16:41 +00:00
|
|
|
TRACE("%x at (%d, %d)\n", hit, ht.pt.x, ht.pt.y);
|
|
|
|
|
2009-09-25 23:50:22 +00:00
|
|
|
switch(hit)
|
|
|
|
{
|
|
|
|
case MCHT_TITLEBTNNEXT:
|
2009-10-11 11:33:02 +00:00
|
|
|
MONTHCAL_GoToPrevNextMonth(infoPtr, FALSE);
|
1999-11-21 02:04:09 +00:00
|
|
|
infoPtr->status = MC_NEXTPRESSED;
|
2009-10-06 20:58:22 +00:00
|
|
|
SetTimer(infoPtr->hwndSelf, MC_PREVNEXTMONTHTIMER, MC_PREVNEXTMONTHDELAY, 0);
|
2004-11-30 17:35:16 +00:00
|
|
|
InvalidateRect(infoPtr->hwndSelf, NULL, FALSE);
|
2007-10-15 00:45:37 +00:00
|
|
|
return 0;
|
2009-09-25 23:50:22 +00:00
|
|
|
|
|
|
|
case MCHT_TITLEBTNPREV:
|
2009-10-11 11:33:02 +00:00
|
|
|
MONTHCAL_GoToPrevNextMonth(infoPtr, TRUE);
|
2000-01-04 00:30:21 +00:00
|
|
|
infoPtr->status = MC_PREVPRESSED;
|
2009-10-06 20:58:22 +00:00
|
|
|
SetTimer(infoPtr->hwndSelf, MC_PREVNEXTMONTHTIMER, MC_PREVNEXTMONTHDELAY, 0);
|
2004-11-30 17:35:16 +00:00
|
|
|
InvalidateRect(infoPtr->hwndSelf, NULL, FALSE);
|
2007-10-15 00:45:37 +00:00
|
|
|
return 0;
|
1999-11-21 02:04:09 +00:00
|
|
|
|
2009-09-25 23:50:22 +00:00
|
|
|
case MCHT_TITLEMONTH:
|
|
|
|
{
|
|
|
|
HMENU hMenu = CreatePopupMenu();
|
|
|
|
WCHAR buf[32];
|
|
|
|
POINT menupoint;
|
|
|
|
INT i;
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2009-09-25 23:50:22 +00:00
|
|
|
for (i = 0; i < 12; i++)
|
|
|
|
{
|
|
|
|
GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SMONTHNAME1+i, buf, countof(buf));
|
|
|
|
AppendMenuW(hMenu, MF_STRING|MF_ENABLED, i + 1, buf);
|
|
|
|
}
|
2009-09-28 18:13:56 +00:00
|
|
|
menupoint.x = ht.pt.x;
|
|
|
|
menupoint.y = ht.pt.y;
|
2004-11-30 17:35:16 +00:00
|
|
|
ClientToScreen(infoPtr->hwndSelf, &menupoint);
|
2009-09-25 23:50:22 +00:00
|
|
|
i = TrackPopupMenu(hMenu,TPM_LEFTALIGN | TPM_NONOTIFY | TPM_RIGHTBUTTON | TPM_RETURNCMD,
|
|
|
|
menupoint.x, menupoint.y, 0, infoPtr->hwndSelf, NULL);
|
|
|
|
|
2009-10-01 17:59:49 +00:00
|
|
|
if ((i > 0) && (i < 13) && infoPtr->curSel.wMonth != i)
|
2009-09-25 23:50:22 +00:00
|
|
|
{
|
2009-09-26 11:17:59 +00:00
|
|
|
infoPtr->curSel.wMonth = i;
|
2009-10-10 20:28:51 +00:00
|
|
|
MONTHCAL_IsDateInValidRange(infoPtr, &infoPtr->curSel, TRUE);
|
2004-11-30 17:35:16 +00:00
|
|
|
InvalidateRect(infoPtr->hwndSelf, NULL, FALSE);
|
2009-09-25 23:50:22 +00:00
|
|
|
}
|
2009-09-28 18:13:56 +00:00
|
|
|
return 0;
|
1999-11-21 02:04:09 +00:00
|
|
|
}
|
2009-09-25 23:50:22 +00:00
|
|
|
case MCHT_TITLEYEAR:
|
|
|
|
{
|
|
|
|
MONTHCAL_EditYear(infoPtr);
|
2007-10-15 00:45:37 +00:00
|
|
|
return 0;
|
1999-11-21 02:04:09 +00:00
|
|
|
}
|
2009-09-25 23:50:22 +00:00
|
|
|
case MCHT_TODAYLINK:
|
|
|
|
{
|
2009-09-26 11:23:44 +00:00
|
|
|
infoPtr->curSel = infoPtr->todaysDate;
|
2009-09-25 19:41:08 +00:00
|
|
|
infoPtr->minSel = infoPtr->todaysDate;
|
|
|
|
infoPtr->maxSel = infoPtr->todaysDate;
|
2004-11-30 17:35:16 +00:00
|
|
|
InvalidateRect(infoPtr->hwndSelf, NULL, FALSE);
|
2007-10-15 01:25:45 +00:00
|
|
|
|
2009-10-01 18:12:21 +00:00
|
|
|
MONTHCAL_NotifySelectionChange(infoPtr);
|
|
|
|
MONTHCAL_NotifySelect(infoPtr);
|
2007-10-15 00:45:37 +00:00
|
|
|
return 0;
|
1999-11-21 02:04:09 +00:00
|
|
|
}
|
2009-10-04 19:16:41 +00:00
|
|
|
case MCHT_CALENDARDATENEXT:
|
|
|
|
case MCHT_CALENDARDATEPREV:
|
2009-09-25 23:50:22 +00:00
|
|
|
case MCHT_CALENDARDATE:
|
|
|
|
{
|
2009-10-11 11:33:02 +00:00
|
|
|
SYSTEMTIME st[2];
|
2009-10-04 19:17:07 +00:00
|
|
|
|
2009-10-11 11:33:02 +00:00
|
|
|
MONTHCAL_CopyDate(&ht.st, &infoPtr->firstSel);
|
2009-10-04 19:17:07 +00:00
|
|
|
|
2009-10-11 11:33:02 +00:00
|
|
|
st[0] = st[1] = ht.st;
|
|
|
|
/* clear selection range */
|
|
|
|
MONTHCAL_SetSelRange(infoPtr, st);
|
2009-10-04 19:17:07 +00:00
|
|
|
|
1999-11-21 02:04:09 +00:00
|
|
|
infoPtr->status = MC_SEL_LBUTDOWN;
|
2009-10-04 19:16:41 +00:00
|
|
|
MONTHCAL_SetDayFocus(infoPtr, &ht.st);
|
2007-10-15 00:45:37 +00:00
|
|
|
return 0;
|
2000-01-04 00:30:21 +00:00
|
|
|
}
|
2009-09-25 23:50:22 +00:00
|
|
|
}
|
2000-01-04 00:30:21 +00:00
|
|
|
|
2007-10-15 00:45:37 +00:00
|
|
|
return 1;
|
1999-07-10 12:00:04 +00:00
|
|
|
}
|
|
|
|
|
1999-11-21 02:04:09 +00:00
|
|
|
|
1999-07-10 12:00:04 +00:00
|
|
|
static LRESULT
|
2004-11-30 17:35:16 +00:00
|
|
|
MONTHCAL_LButtonUp(MONTHCAL_INFO *infoPtr, LPARAM lParam)
|
1999-07-10 12:00:04 +00:00
|
|
|
{
|
1999-11-21 02:04:09 +00:00
|
|
|
NMHDR nmhdr;
|
2000-10-15 00:27:28 +00:00
|
|
|
MCHITTESTINFO ht;
|
|
|
|
DWORD hit;
|
2000-01-04 00:30:21 +00:00
|
|
|
|
|
|
|
TRACE("\n");
|
1999-07-31 11:13:25 +00:00
|
|
|
|
2009-10-06 19:23:55 +00:00
|
|
|
if(infoPtr->status & (MC_PREVPRESSED | MC_NEXTPRESSED)) {
|
2009-10-06 21:20:48 +00:00
|
|
|
RECT *r;
|
|
|
|
|
2009-10-06 19:23:55 +00:00
|
|
|
KillTimer(infoPtr->hwndSelf, MC_PREVNEXTMONTHTIMER);
|
2009-10-06 21:20:48 +00:00
|
|
|
r = infoPtr->status & MC_PREVPRESSED ? &infoPtr->titlebtnprev : &infoPtr->titlebtnnext;
|
2009-10-06 19:23:55 +00:00
|
|
|
infoPtr->status &= ~(MC_PREVPRESSED | MC_NEXTPRESSED);
|
2009-10-06 21:20:48 +00:00
|
|
|
|
|
|
|
InvalidateRect(infoPtr->hwndSelf, r, FALSE);
|
2000-01-04 00:30:21 +00:00
|
|
|
}
|
1999-07-10 12:00:04 +00:00
|
|
|
|
2009-10-04 19:16:41 +00:00
|
|
|
ReleaseCapture();
|
|
|
|
|
2009-09-29 20:22:51 +00:00
|
|
|
/* always send NM_RELEASEDCAPTURE notification */
|
|
|
|
nmhdr.hwndFrom = infoPtr->hwndSelf;
|
|
|
|
nmhdr.idFrom = GetWindowLongPtrW(infoPtr->hwndSelf, GWLP_ID);
|
|
|
|
nmhdr.code = NM_RELEASEDCAPTURE;
|
|
|
|
TRACE("Sent notification from %p to %p\n", infoPtr->hwndSelf, infoPtr->hwndNotify);
|
|
|
|
|
|
|
|
SendMessageW(infoPtr->hwndNotify, WM_NOTIFY, nmhdr.idFrom, (LPARAM)&nmhdr);
|
|
|
|
|
2009-10-10 17:04:16 +00:00
|
|
|
if(!(infoPtr->status & MC_SEL_LBUTDOWN)) return 0;
|
|
|
|
|
2009-09-26 19:26:53 +00:00
|
|
|
ht.cbSize = sizeof(MCHITTESTINFO);
|
2006-10-25 15:41:48 +00:00
|
|
|
ht.pt.x = (short)LOWORD(lParam);
|
|
|
|
ht.pt.y = (short)HIWORD(lParam);
|
2009-09-23 23:02:31 +00:00
|
|
|
hit = MONTHCAL_HitTest(infoPtr, &ht);
|
2000-10-15 00:27:28 +00:00
|
|
|
|
1999-11-21 02:04:09 +00:00
|
|
|
infoPtr->status = MC_SEL_LBUTUP;
|
2009-10-04 19:16:41 +00:00
|
|
|
MONTHCAL_SetDayFocus(infoPtr, NULL);
|
1999-07-31 11:13:25 +00:00
|
|
|
|
2009-10-06 21:20:48 +00:00
|
|
|
if((hit & MCHT_CALENDARDATE) == MCHT_CALENDARDATE)
|
2009-09-29 20:22:51 +00:00
|
|
|
{
|
2009-10-04 19:17:07 +00:00
|
|
|
SYSTEMTIME sel = infoPtr->curSel;
|
2009-09-29 19:49:08 +00:00
|
|
|
|
2009-10-11 11:33:02 +00:00
|
|
|
/* will be invalidated here */
|
|
|
|
MONTHCAL_SetCurSel(infoPtr, &ht.st);
|
2009-09-29 19:49:08 +00:00
|
|
|
|
2009-09-29 20:22:51 +00:00
|
|
|
/* send MCN_SELCHANGE only if new date selected */
|
|
|
|
if (!MONTHCAL_IsDateEqual(&sel, &ht.st))
|
2009-10-01 18:12:21 +00:00
|
|
|
MONTHCAL_NotifySelectionChange(infoPtr);
|
1999-07-31 11:13:25 +00:00
|
|
|
|
2009-10-01 18:12:21 +00:00
|
|
|
MONTHCAL_NotifySelect(infoPtr);
|
2004-04-21 22:24:09 +00:00
|
|
|
}
|
2009-09-29 20:22:51 +00:00
|
|
|
|
1999-11-21 02:04:09 +00:00
|
|
|
return 0;
|
1999-07-10 12:00:04 +00:00
|
|
|
}
|
|
|
|
|
1999-11-21 02:04:09 +00:00
|
|
|
|
1999-07-31 11:13:25 +00:00
|
|
|
static LRESULT
|
2009-10-06 19:23:55 +00:00
|
|
|
MONTHCAL_Timer(MONTHCAL_INFO *infoPtr, WPARAM id)
|
1999-07-31 11:13:25 +00:00
|
|
|
{
|
2009-10-06 19:23:55 +00:00
|
|
|
TRACE("%ld\n", id);
|
1999-11-21 02:04:09 +00:00
|
|
|
|
2009-10-06 19:23:55 +00:00
|
|
|
switch(id) {
|
|
|
|
case MC_PREVNEXTMONTHTIMER:
|
2009-10-11 11:33:02 +00:00
|
|
|
if(infoPtr->status & MC_NEXTPRESSED) MONTHCAL_GoToPrevNextMonth(infoPtr, FALSE);
|
|
|
|
if(infoPtr->status & MC_PREVPRESSED) MONTHCAL_GoToPrevNextMonth(infoPtr, TRUE);
|
2009-10-06 19:23:55 +00:00
|
|
|
InvalidateRect(infoPtr->hwndSelf, NULL, FALSE);
|
1999-11-21 02:04:09 +00:00
|
|
|
break;
|
2009-10-06 20:58:22 +00:00
|
|
|
case MC_TODAYUPDATETIMER:
|
|
|
|
{
|
|
|
|
SYSTEMTIME st;
|
|
|
|
|
|
|
|
if(infoPtr->todaySet) return 0;
|
|
|
|
|
|
|
|
GetLocalTime(&st);
|
|
|
|
MONTHCAL_UpdateToday(infoPtr, &st);
|
|
|
|
|
|
|
|
/* notification sent anyway */
|
|
|
|
MONTHCAL_NotifySelectionChange(infoPtr);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
1999-11-21 02:04:09 +00:00
|
|
|
default:
|
2009-10-06 19:23:55 +00:00
|
|
|
ERR("got unknown timer %ld\n", id);
|
2004-11-30 17:35:16 +00:00
|
|
|
break;
|
1999-11-21 02:04:09 +00:00
|
|
|
}
|
1999-07-31 11:13:25 +00:00
|
|
|
|
1999-11-21 02:04:09 +00:00
|
|
|
return 0;
|
|
|
|
}
|
1999-07-31 11:13:25 +00:00
|
|
|
|
1999-07-10 12:00:04 +00:00
|
|
|
|
|
|
|
static LRESULT
|
2008-09-07 14:20:38 +00:00
|
|
|
MONTHCAL_MouseMove(MONTHCAL_INFO *infoPtr, LPARAM lParam)
|
1999-07-10 12:00:04 +00:00
|
|
|
{
|
1999-11-21 02:04:09 +00:00
|
|
|
MCHITTESTINFO ht;
|
2009-10-04 19:17:07 +00:00
|
|
|
SYSTEMTIME old_focused, st_ht;
|
|
|
|
INT hit;
|
1999-11-21 02:04:09 +00:00
|
|
|
RECT r;
|
1999-07-10 12:00:04 +00:00
|
|
|
|
2000-01-04 00:30:21 +00:00
|
|
|
if(!(infoPtr->status & MC_SEL_LBUTDOWN)) return 0;
|
1999-07-10 12:00:04 +00:00
|
|
|
|
2009-09-26 19:26:53 +00:00
|
|
|
ht.cbSize = sizeof(MCHITTESTINFO);
|
2006-10-25 15:41:48 +00:00
|
|
|
ht.pt.x = (short)LOWORD(lParam);
|
|
|
|
ht.pt.y = (short)HIWORD(lParam);
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2009-09-23 23:02:31 +00:00
|
|
|
hit = MONTHCAL_HitTest(infoPtr, &ht);
|
2002-05-31 23:06:46 +00:00
|
|
|
|
1999-11-21 02:04:09 +00:00
|
|
|
/* not on the calendar date numbers? bail out */
|
2000-01-04 00:30:21 +00:00
|
|
|
TRACE("hit:%x\n",hit);
|
2009-10-04 19:16:41 +00:00
|
|
|
if((hit & MCHT_CALENDARDATE) != MCHT_CALENDARDATE)
|
|
|
|
{
|
|
|
|
MONTHCAL_SetDayFocus(infoPtr, NULL);
|
|
|
|
return 0;
|
|
|
|
}
|
1999-11-21 02:04:09 +00:00
|
|
|
|
2009-10-04 19:17:07 +00:00
|
|
|
st_ht = ht.st;
|
2009-10-04 19:16:41 +00:00
|
|
|
old_focused = infoPtr->focusedSel;
|
2009-10-05 16:32:15 +00:00
|
|
|
|
|
|
|
/* if pointer is over focused day still there's nothing to do */
|
|
|
|
if(!MONTHCAL_SetDayFocus(infoPtr, &ht.st)) return 0;
|
2009-10-04 19:16:41 +00:00
|
|
|
|
2009-10-10 23:54:11 +00:00
|
|
|
MONTHCAL_CalcPosFromDay(infoPtr, &ht.st, &r);
|
1999-11-21 02:04:09 +00:00
|
|
|
|
2009-10-05 16:32:15 +00:00
|
|
|
if(infoPtr->dwStyle & MCS_MULTISELECT) {
|
2009-10-04 19:17:07 +00:00
|
|
|
SYSTEMTIME st[2];
|
|
|
|
|
|
|
|
MONTHCAL_GetSelRange(infoPtr, st);
|
|
|
|
|
2009-10-05 16:32:15 +00:00
|
|
|
/* If we're still at the first selected date and range is empty, return.
|
|
|
|
If range isn't empty we should change range to a single firstSel */
|
|
|
|
if(MONTHCAL_IsDateEqual(&infoPtr->firstSel, &st_ht) &&
|
|
|
|
MONTHCAL_IsDateEqual(&st[0], &st[1])) goto done;
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2009-10-05 16:29:31 +00:00
|
|
|
MONTHCAL_IsSelRangeValid(infoPtr, &st_ht, &infoPtr->firstSel, &st_ht);
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2009-10-05 16:32:15 +00:00
|
|
|
st[0] = infoPtr->firstSel;
|
|
|
|
/* we should overwrite timestamp here */
|
|
|
|
MONTHCAL_CopyDate(&st_ht, &st[1]);
|
2009-10-04 19:17:07 +00:00
|
|
|
|
2009-10-05 16:32:15 +00:00
|
|
|
/* bounds will be swapped here if needed */
|
|
|
|
MONTHCAL_SetSelRange(infoPtr, st);
|
|
|
|
|
|
|
|
return 0;
|
1999-11-21 02:04:09 +00:00
|
|
|
}
|
1999-07-10 12:00:04 +00:00
|
|
|
|
|
|
|
done:
|
|
|
|
|
2009-10-05 16:32:15 +00:00
|
|
|
/* FIXME: this should specify a rectangle containing only the days that changed
|
|
|
|
using InvalidateRect */
|
|
|
|
InvalidateRect(infoPtr->hwndSelf, NULL, FALSE);
|
1999-07-10 12:00:04 +00:00
|
|
|
|
1999-11-21 02:04:09 +00:00
|
|
|
return 0;
|
1999-07-10 12:00:04 +00:00
|
|
|
}
|
|
|
|
|
1999-11-21 02:04:09 +00:00
|
|
|
|
1999-07-10 12:00:04 +00:00
|
|
|
static LRESULT
|
2009-09-24 23:43:38 +00:00
|
|
|
MONTHCAL_Paint(MONTHCAL_INFO *infoPtr, HDC hdc_paint)
|
1999-07-10 12:00:04 +00:00
|
|
|
{
|
1999-11-21 02:04:09 +00:00
|
|
|
HDC hdc;
|
|
|
|
PAINTSTRUCT ps;
|
1999-07-10 12:00:04 +00:00
|
|
|
|
2009-09-24 23:43:38 +00:00
|
|
|
if (hdc_paint)
|
2004-11-08 20:27:02 +00:00
|
|
|
{
|
2004-11-30 17:35:16 +00:00
|
|
|
GetClientRect(infoPtr->hwndSelf, &ps.rcPaint);
|
2009-09-24 23:43:38 +00:00
|
|
|
hdc = hdc_paint;
|
2004-11-08 20:27:02 +00:00
|
|
|
}
|
|
|
|
else
|
2004-11-30 17:35:16 +00:00
|
|
|
hdc = BeginPaint(infoPtr->hwndSelf, &ps);
|
2000-05-30 20:06:33 +00:00
|
|
|
|
2004-11-30 17:35:16 +00:00
|
|
|
MONTHCAL_Refresh(infoPtr, hdc, &ps);
|
2009-09-24 23:43:38 +00:00
|
|
|
if (!hdc_paint) EndPaint(infoPtr->hwndSelf, &ps);
|
1999-11-21 02:04:09 +00:00
|
|
|
return 0;
|
1999-07-10 12:00:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static LRESULT
|
2007-03-29 21:09:32 +00:00
|
|
|
MONTHCAL_SetFocus(const MONTHCAL_INFO *infoPtr)
|
1999-07-10 12:00:04 +00:00
|
|
|
{
|
2000-01-04 00:30:21 +00:00
|
|
|
TRACE("\n");
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2004-11-30 17:35:16 +00:00
|
|
|
InvalidateRect(infoPtr->hwndSelf, NULL, FALSE);
|
1999-07-10 12:00:04 +00:00
|
|
|
|
1999-11-21 02:04:09 +00:00
|
|
|
return 0;
|
1999-07-10 12:00:04 +00:00
|
|
|
}
|
|
|
|
|
2000-01-04 00:30:21 +00:00
|
|
|
/* sets the size information */
|
2004-11-30 17:35:16 +00:00
|
|
|
static void MONTHCAL_UpdateSize(MONTHCAL_INFO *infoPtr)
|
2000-01-04 00:30:21 +00:00
|
|
|
{
|
2005-04-11 14:21:00 +00:00
|
|
|
static const WCHAR O0W[] = { '0','0',0 };
|
2004-11-30 17:35:16 +00:00
|
|
|
HDC hdc = GetDC(infoPtr->hwndSelf);
|
2000-01-04 00:30:21 +00:00
|
|
|
RECT *title=&infoPtr->title;
|
|
|
|
RECT *prev=&infoPtr->titlebtnprev;
|
|
|
|
RECT *next=&infoPtr->titlebtnnext;
|
|
|
|
RECT *titlemonth=&infoPtr->titlemonth;
|
|
|
|
RECT *titleyear=&infoPtr->titleyear;
|
2000-10-15 00:27:28 +00:00
|
|
|
RECT *wdays=&infoPtr->wdays;
|
|
|
|
RECT *weeknumrect=&infoPtr->weeknums;
|
2000-01-04 00:30:21 +00:00
|
|
|
RECT *days=&infoPtr->days;
|
2000-10-15 00:27:28 +00:00
|
|
|
RECT *todayrect=&infoPtr->todayrect;
|
2009-09-29 22:15:40 +00:00
|
|
|
SIZE size, sz;
|
2005-04-11 14:21:00 +00:00
|
|
|
TEXTMETRICW tm;
|
2000-01-04 00:30:21 +00:00
|
|
|
HFONT currentFont;
|
2009-09-29 22:15:40 +00:00
|
|
|
INT xdiv, dx, dy, i;
|
2004-11-08 20:27:02 +00:00
|
|
|
RECT rcClient;
|
2009-09-29 22:15:40 +00:00
|
|
|
WCHAR buff[80];
|
2000-01-04 00:30:21 +00:00
|
|
|
|
2004-11-30 17:35:16 +00:00
|
|
|
GetClientRect(infoPtr->hwndSelf, &rcClient);
|
2000-01-04 00:30:21 +00:00
|
|
|
|
2004-11-08 20:27:02 +00:00
|
|
|
currentFont = SelectObject(hdc, infoPtr->hFont);
|
2000-01-04 00:30:21 +00:00
|
|
|
|
|
|
|
/* get the height and width of each day's text */
|
2005-04-11 14:21:00 +00:00
|
|
|
GetTextMetricsW(hdc, &tm);
|
2004-11-08 20:27:02 +00:00
|
|
|
infoPtr->textHeight = tm.tmHeight + tm.tmExternalLeading + tm.tmInternalLeading;
|
2009-09-29 22:15:40 +00:00
|
|
|
|
|
|
|
/* find largest abbreviated day name for current locale */
|
|
|
|
size.cx = sz.cx = 0;
|
|
|
|
for (i = 0; i < 7; i++)
|
|
|
|
{
|
2009-10-08 20:47:42 +00:00
|
|
|
if(GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SABBREVDAYNAME1 + i,
|
2009-09-29 22:15:40 +00:00
|
|
|
buff, countof(buff)))
|
|
|
|
{
|
|
|
|
GetTextExtentPoint32W(hdc, buff, lstrlenW(buff), &sz);
|
|
|
|
if (sz.cx > size.cx) size.cx = sz.cx;
|
|
|
|
}
|
|
|
|
else /* locale independent fallback on failure */
|
|
|
|
{
|
|
|
|
static const WCHAR SunW[] = { 'S','u','n',0 };
|
|
|
|
|
|
|
|
GetTextExtentPoint32W(hdc, SunW, lstrlenW(SunW), &size);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-01-04 00:30:21 +00:00
|
|
|
infoPtr->textWidth = size.cx + 2;
|
|
|
|
|
2004-11-08 20:27:02 +00:00
|
|
|
/* recalculate the height and width increments and offsets */
|
2005-04-11 14:21:00 +00:00
|
|
|
GetTextExtentPoint32W(hdc, O0W, 2, &size);
|
2000-01-04 00:30:21 +00:00
|
|
|
|
2009-09-08 06:44:55 +00:00
|
|
|
xdiv = (infoPtr->dwStyle & MCS_WEEKNUMBERS) ? 8 : 7;
|
2000-01-04 00:30:21 +00:00
|
|
|
|
2009-09-28 20:44:45 +00:00
|
|
|
infoPtr->width_increment = size.cx * 2 + 4;
|
2004-11-08 20:27:02 +00:00
|
|
|
infoPtr->height_increment = infoPtr->textHeight;
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2000-01-04 00:30:21 +00:00
|
|
|
/* calculate title area */
|
2009-09-28 20:44:45 +00:00
|
|
|
title->top = 0;
|
|
|
|
title->bottom = 3 * infoPtr->height_increment / 2;
|
|
|
|
title->left = 0;
|
|
|
|
title->right = infoPtr->width_increment * xdiv;
|
2000-01-04 00:30:21 +00:00
|
|
|
|
|
|
|
/* set the dimensions of the next and previous buttons and center */
|
|
|
|
/* the month text vertically */
|
2004-11-08 20:27:02 +00:00
|
|
|
prev->top = next->top = title->top + 4;
|
|
|
|
prev->bottom = next->bottom = title->bottom - 4;
|
|
|
|
prev->left = title->left + 4;
|
2009-09-28 20:44:45 +00:00
|
|
|
prev->right = prev->left + (title->bottom - title->top);
|
2004-11-08 20:27:02 +00:00
|
|
|
next->right = title->right - 4;
|
2000-10-15 00:27:28 +00:00
|
|
|
next->left = next->right - (title->bottom - title->top);
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2000-01-04 00:30:21 +00:00
|
|
|
/* titlemonth->left and right change based upon the current month */
|
|
|
|
/* and are recalculated in refresh as the current month may change */
|
|
|
|
/* without the control being resized */
|
2000-10-15 00:27:28 +00:00
|
|
|
titlemonth->top = titleyear->top = title->top + (infoPtr->height_increment)/2;
|
|
|
|
titlemonth->bottom = titleyear->bottom = title->bottom - (infoPtr->height_increment)/2;
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2000-01-04 00:30:21 +00:00
|
|
|
/* setup the dimensions of the rectangle we draw the names of the */
|
|
|
|
/* days of the week in */
|
2009-09-28 20:44:45 +00:00
|
|
|
weeknumrect->left = 0;
|
|
|
|
|
2009-09-08 06:44:55 +00:00
|
|
|
if(infoPtr->dwStyle & MCS_WEEKNUMBERS)
|
2009-09-28 20:44:45 +00:00
|
|
|
weeknumrect->right = prev->right;
|
2000-10-15 00:27:28 +00:00
|
|
|
else
|
2009-09-28 20:44:45 +00:00
|
|
|
weeknumrect->right = weeknumrect->left;
|
|
|
|
|
2000-10-15 00:27:28 +00:00
|
|
|
wdays->left = days->left = weeknumrect->right;
|
|
|
|
wdays->right = days->right = wdays->left + 7 * infoPtr->width_increment;
|
2009-09-28 20:44:45 +00:00
|
|
|
wdays->top = title->bottom;
|
2000-10-15 00:27:28 +00:00
|
|
|
wdays->bottom = wdays->top + infoPtr->height_increment;
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2009-09-28 20:44:45 +00:00
|
|
|
days->top = weeknumrect->top = wdays->bottom;
|
2004-11-08 20:27:02 +00:00
|
|
|
days->bottom = weeknumrect->bottom = days->top + 6 * infoPtr->height_increment;
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2009-09-28 20:44:45 +00:00
|
|
|
todayrect->left = 0;
|
|
|
|
todayrect->right = title->right;
|
2000-10-15 00:27:28 +00:00
|
|
|
todayrect->top = days->bottom;
|
|
|
|
todayrect->bottom = days->bottom + infoPtr->height_increment;
|
|
|
|
|
2009-09-28 20:44:45 +00:00
|
|
|
/* offset all rectangles to center in client area */
|
|
|
|
dx = (rcClient.right - title->right) / 2;
|
|
|
|
dy = (rcClient.bottom - todayrect->bottom) / 2;
|
|
|
|
|
|
|
|
/* if calendar doesn't fit client area show it at left/top bounds */
|
|
|
|
if (title->left + dx < 0) dx = 0;
|
|
|
|
if (title->top + dy < 0) dy = 0;
|
|
|
|
|
|
|
|
if (dx != 0 || dy != 0)
|
|
|
|
{
|
|
|
|
OffsetRect(title, dx, dy);
|
|
|
|
OffsetRect(prev, dx, dy);
|
|
|
|
OffsetRect(next, dx, dy);
|
|
|
|
OffsetRect(titlemonth, dx, dy);
|
|
|
|
OffsetRect(titleyear, dx, dy);
|
|
|
|
OffsetRect(wdays, dx, dy);
|
|
|
|
OffsetRect(weeknumrect, dx, dy);
|
|
|
|
OffsetRect(days, dx, dy);
|
|
|
|
OffsetRect(todayrect, dx, dy);
|
|
|
|
}
|
|
|
|
|
2004-11-08 20:27:02 +00:00
|
|
|
TRACE("dx=%d dy=%d client[%s] title[%s] wdays[%s] days[%s] today[%s]\n",
|
2000-10-15 00:27:28 +00:00
|
|
|
infoPtr->width_increment,infoPtr->height_increment,
|
2004-11-08 20:27:02 +00:00
|
|
|
wine_dbgstr_rect(&rcClient),
|
|
|
|
wine_dbgstr_rect(title),
|
|
|
|
wine_dbgstr_rect(wdays),
|
|
|
|
wine_dbgstr_rect(days),
|
|
|
|
wine_dbgstr_rect(todayrect));
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2000-01-04 00:30:21 +00:00
|
|
|
/* restore the originally selected font */
|
2002-05-31 23:06:46 +00:00
|
|
|
SelectObject(hdc, currentFont);
|
2000-01-04 00:30:21 +00:00
|
|
|
|
2004-11-30 17:35:16 +00:00
|
|
|
ReleaseDC(infoPtr->hwndSelf, hdc);
|
2000-01-04 00:30:21 +00:00
|
|
|
}
|
|
|
|
|
2004-11-30 17:35:16 +00:00
|
|
|
static LRESULT MONTHCAL_Size(MONTHCAL_INFO *infoPtr, int Width, int Height)
|
2000-01-04 00:30:21 +00:00
|
|
|
{
|
2004-11-30 17:35:16 +00:00
|
|
|
TRACE("(width=%d, height=%d)\n", Width, Height);
|
2000-01-04 00:30:21 +00:00
|
|
|
|
2004-11-30 17:35:16 +00:00
|
|
|
MONTHCAL_UpdateSize(infoPtr);
|
2000-01-04 00:30:21 +00:00
|
|
|
|
|
|
|
/* invalidate client area and erase background */
|
2004-11-30 17:35:16 +00:00
|
|
|
InvalidateRect(infoPtr->hwndSelf, NULL, TRUE);
|
2000-01-04 00:30:21 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
1999-07-10 12:00:04 +00:00
|
|
|
|
2007-03-29 21:09:32 +00:00
|
|
|
static LRESULT MONTHCAL_GetFont(const MONTHCAL_INFO *infoPtr)
|
2004-11-30 17:35:16 +00:00
|
|
|
{
|
|
|
|
return (LRESULT)infoPtr->hFont;
|
|
|
|
}
|
|
|
|
|
|
|
|
static LRESULT MONTHCAL_SetFont(MONTHCAL_INFO *infoPtr, HFONT hFont, BOOL redraw)
|
|
|
|
{
|
|
|
|
HFONT hOldFont;
|
|
|
|
LOGFONTW lf;
|
|
|
|
|
|
|
|
if (!hFont) return 0;
|
|
|
|
|
|
|
|
hOldFont = infoPtr->hFont;
|
|
|
|
infoPtr->hFont = hFont;
|
|
|
|
|
|
|
|
GetObjectW(infoPtr->hFont, sizeof(lf), &lf);
|
|
|
|
lf.lfWeight = FW_BOLD;
|
|
|
|
infoPtr->hBoldFont = CreateFontIndirectW(&lf);
|
|
|
|
|
2008-10-25 16:04:52 +00:00
|
|
|
MONTHCAL_UpdateSize(infoPtr);
|
|
|
|
|
2004-11-30 17:35:16 +00:00
|
|
|
if (redraw)
|
|
|
|
InvalidateRect(infoPtr->hwndSelf, NULL, FALSE);
|
|
|
|
|
|
|
|
return (LRESULT)hOldFont;
|
|
|
|
}
|
|
|
|
|
2005-08-11 17:05:00 +00:00
|
|
|
/* update theme after a WM_THEMECHANGED message */
|
2007-03-29 21:09:32 +00:00
|
|
|
static LRESULT theme_changed (const MONTHCAL_INFO* infoPtr)
|
2005-08-11 17:05:00 +00:00
|
|
|
{
|
|
|
|
HTHEME theme = GetWindowTheme (infoPtr->hwndSelf);
|
|
|
|
CloseThemeData (theme);
|
2008-11-19 23:27:51 +00:00
|
|
|
OpenThemeData (infoPtr->hwndSelf, themeClass);
|
2005-08-11 17:05:00 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-09-08 06:44:55 +00:00
|
|
|
static INT MONTHCAL_StyleChanged(MONTHCAL_INFO *infoPtr, WPARAM wStyleType,
|
|
|
|
const STYLESTRUCT *lpss)
|
|
|
|
{
|
|
|
|
TRACE("(styletype=%lx, styleOld=0x%08x, styleNew=0x%08x)\n",
|
|
|
|
wStyleType, lpss->styleOld, lpss->styleNew);
|
|
|
|
|
|
|
|
if (wStyleType != GWL_STYLE) return 0;
|
|
|
|
|
|
|
|
infoPtr->dwStyle = lpss->styleNew;
|
|
|
|
|
2009-10-06 23:50:02 +00:00
|
|
|
/* make room for week numbers */
|
|
|
|
if ((lpss->styleNew ^ lpss->styleOld) & MCS_WEEKNUMBERS)
|
|
|
|
MONTHCAL_UpdateSize(infoPtr);
|
|
|
|
|
2009-09-08 06:44:55 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-10-01 18:49:02 +00:00
|
|
|
static INT MONTHCAL_StyleChanging(MONTHCAL_INFO *infoPtr, WPARAM wStyleType,
|
|
|
|
STYLESTRUCT *lpss)
|
|
|
|
{
|
|
|
|
TRACE("(styletype=%lx, styleOld=0x%08x, styleNew=0x%08x)\n",
|
|
|
|
wStyleType, lpss->styleOld, lpss->styleNew);
|
|
|
|
|
|
|
|
/* block MCS_MULTISELECT change */
|
|
|
|
if ((lpss->styleNew ^ lpss->styleOld) & MCS_MULTISELECT)
|
|
|
|
{
|
|
|
|
if (lpss->styleOld & MCS_MULTISELECT)
|
|
|
|
lpss->styleNew |= MCS_MULTISELECT;
|
|
|
|
else
|
|
|
|
lpss->styleNew &= ~MCS_MULTISELECT;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1999-07-10 12:00:04 +00:00
|
|
|
/* FIXME: check whether dateMin/dateMax need to be adjusted. */
|
1998-11-08 11:30:27 +00:00
|
|
|
static LRESULT
|
2009-09-23 23:02:31 +00:00
|
|
|
MONTHCAL_Create(HWND hwnd, LPCREATESTRUCTW lpcs)
|
1998-11-08 11:30:27 +00:00
|
|
|
{
|
1999-11-21 02:04:09 +00:00
|
|
|
MONTHCAL_INFO *infoPtr;
|
1998-11-08 11:30:27 +00:00
|
|
|
|
1999-11-21 02:04:09 +00:00
|
|
|
/* allocate memory for info structure */
|
2008-10-23 21:52:10 +00:00
|
|
|
infoPtr = Alloc(sizeof(MONTHCAL_INFO));
|
2004-08-25 17:33:01 +00:00
|
|
|
SetWindowLongPtrW(hwnd, 0, (DWORD_PTR)infoPtr);
|
1999-07-10 12:00:04 +00:00
|
|
|
|
2000-01-04 00:30:21 +00:00
|
|
|
if(infoPtr == NULL) {
|
|
|
|
ERR( "could not allocate info memory!\n");
|
1999-11-21 02:04:09 +00:00
|
|
|
return 0;
|
|
|
|
}
|
1998-11-08 11:30:27 +00:00
|
|
|
|
2004-11-08 20:27:02 +00:00
|
|
|
infoPtr->hwndSelf = hwnd;
|
2009-09-23 23:02:31 +00:00
|
|
|
infoPtr->hwndNotify = lpcs->hwndParent;
|
2009-09-08 06:44:55 +00:00
|
|
|
infoPtr->dwStyle = GetWindowLongW(hwnd, GWL_STYLE);
|
2003-11-20 22:04:13 +00:00
|
|
|
|
2004-11-30 17:35:16 +00:00
|
|
|
MONTHCAL_SetFont(infoPtr, GetStockObject(DEFAULT_GUI_FONT), FALSE);
|
1999-11-21 02:04:09 +00:00
|
|
|
|
|
|
|
/* initialize info structure */
|
2000-01-04 00:30:21 +00:00
|
|
|
/* FIXME: calculate systemtime ->> localtime(substract timezoneinfo) */
|
1999-11-21 02:04:09 +00:00
|
|
|
|
2005-04-20 12:51:37 +00:00
|
|
|
GetLocalTime(&infoPtr->todaysDate);
|
2009-09-23 23:02:31 +00:00
|
|
|
MONTHCAL_SetFirstDayOfWeek(infoPtr, -1);
|
2009-09-26 13:15:17 +00:00
|
|
|
|
2009-10-01 18:49:02 +00:00
|
|
|
infoPtr->maxSelCount = (infoPtr->dwStyle & MCS_MULTISELECT) ? 7 : 1;
|
2009-09-25 21:20:33 +00:00
|
|
|
infoPtr->monthRange = 3;
|
|
|
|
infoPtr->monthdayState = Alloc(infoPtr->monthRange * sizeof(MONTHDAYSTATE));
|
|
|
|
infoPtr->titlebk = comctl32_color.clrActiveCaption;
|
|
|
|
infoPtr->titletxt = comctl32_color.clrWindow;
|
|
|
|
infoPtr->monthbk = comctl32_color.clrWindow;
|
|
|
|
infoPtr->trailingtxt = comctl32_color.clrGrayText;
|
|
|
|
infoPtr->bk = comctl32_color.clrWindow;
|
|
|
|
infoPtr->txt = comctl32_color.clrWindowText;
|
|
|
|
|
|
|
|
infoPtr->minSel = infoPtr->todaysDate;
|
|
|
|
infoPtr->maxSel = infoPtr->todaysDate;
|
2009-09-26 13:15:17 +00:00
|
|
|
infoPtr->curSel = infoPtr->todaysDate;
|
2006-12-24 07:43:56 +00:00
|
|
|
|
2000-01-04 00:30:21 +00:00
|
|
|
/* call MONTHCAL_UpdateSize to set all of the dimensions */
|
|
|
|
/* of the control */
|
2004-11-30 17:35:16 +00:00
|
|
|
MONTHCAL_UpdateSize(infoPtr);
|
2009-10-06 20:58:22 +00:00
|
|
|
|
|
|
|
/* today auto update timer, to be freed only on control destruction */
|
|
|
|
SetTimer(infoPtr->hwndSelf, MC_TODAYUPDATETIMER, MC_TODAYUPDATEDELAY, 0);
|
|
|
|
|
2005-08-11 17:05:00 +00:00
|
|
|
OpenThemeData (infoPtr->hwndSelf, themeClass);
|
1999-11-21 02:04:09 +00:00
|
|
|
|
|
|
|
return 0;
|
1998-11-08 11:30:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static LRESULT
|
2004-11-30 17:35:16 +00:00
|
|
|
MONTHCAL_Destroy(MONTHCAL_INFO *infoPtr)
|
1998-11-08 11:30:27 +00:00
|
|
|
{
|
1999-11-21 02:04:09 +00:00
|
|
|
/* free month calendar info data */
|
2007-02-13 20:18:24 +00:00
|
|
|
Free(infoPtr->monthdayState);
|
2004-11-30 17:35:16 +00:00
|
|
|
SetWindowLongPtrW(infoPtr->hwndSelf, 0, 0);
|
2007-02-13 20:18:24 +00:00
|
|
|
|
2005-08-11 17:05:00 +00:00
|
|
|
CloseThemeData (GetWindowTheme (infoPtr->hwndSelf));
|
|
|
|
|
2003-09-22 21:32:33 +00:00
|
|
|
Free(infoPtr);
|
1999-11-21 02:04:09 +00:00
|
|
|
return 0;
|
1998-11-08 11:30:27 +00:00
|
|
|
}
|
|
|
|
|
2009-10-10 17:04:16 +00:00
|
|
|
/*
|
|
|
|
* 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;
|
|
|
|
}
|
1998-11-08 11:30:27 +00:00
|
|
|
|
1999-07-31 14:41:43 +00:00
|
|
|
static LRESULT WINAPI
|
2000-01-04 00:30:21 +00:00
|
|
|
MONTHCAL_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
1998-11-08 11:30:27 +00:00
|
|
|
{
|
2004-11-30 17:35:16 +00:00
|
|
|
MONTHCAL_INFO *infoPtr;
|
|
|
|
|
2007-05-24 14:41:17 +00:00
|
|
|
TRACE("hwnd=%p msg=%x wparam=%lx lparam=%lx\n", hwnd, uMsg, wParam, lParam);
|
2004-11-30 17:35:16 +00:00
|
|
|
|
|
|
|
infoPtr = MONTHCAL_GetInfoPtr(hwnd);
|
|
|
|
if (!infoPtr && (uMsg != WM_CREATE))
|
2005-04-11 14:21:00 +00:00
|
|
|
return DefWindowProcW(hwnd, uMsg, wParam, lParam);
|
2000-01-04 00:30:21 +00:00
|
|
|
switch(uMsg)
|
1999-11-21 02:04:09 +00:00
|
|
|
{
|
|
|
|
case MCM_GETCURSEL:
|
2009-09-23 23:02:31 +00:00
|
|
|
return MONTHCAL_GetCurSel(infoPtr, (LPSYSTEMTIME)lParam);
|
1999-07-31 11:13:25 +00:00
|
|
|
|
1999-11-21 02:04:09 +00:00
|
|
|
case MCM_SETCURSEL:
|
2009-09-23 23:02:31 +00:00
|
|
|
return MONTHCAL_SetCurSel(infoPtr, (LPSYSTEMTIME)lParam);
|
1999-07-10 12:00:04 +00:00
|
|
|
|
1999-11-21 02:04:09 +00:00
|
|
|
case MCM_GETMAXSELCOUNT:
|
2004-11-30 17:35:16 +00:00
|
|
|
return MONTHCAL_GetMaxSelCount(infoPtr);
|
1999-07-10 12:00:04 +00:00
|
|
|
|
1999-11-21 02:04:09 +00:00
|
|
|
case MCM_SETMAXSELCOUNT:
|
2004-11-30 17:35:16 +00:00
|
|
|
return MONTHCAL_SetMaxSelCount(infoPtr, wParam);
|
1999-07-10 12:00:04 +00:00
|
|
|
|
1999-11-21 02:04:09 +00:00
|
|
|
case MCM_GETSELRANGE:
|
2009-09-23 23:02:31 +00:00
|
|
|
return MONTHCAL_GetSelRange(infoPtr, (LPSYSTEMTIME)lParam);
|
1999-07-10 12:00:04 +00:00
|
|
|
|
1999-11-21 02:04:09 +00:00
|
|
|
case MCM_SETSELRANGE:
|
2009-09-23 23:02:31 +00:00
|
|
|
return MONTHCAL_SetSelRange(infoPtr, (LPSYSTEMTIME)lParam);
|
1999-07-10 12:00:04 +00:00
|
|
|
|
1999-11-21 02:04:09 +00:00
|
|
|
case MCM_GETMONTHRANGE:
|
2009-10-04 14:27:21 +00:00
|
|
|
return MONTHCAL_GetMonthRange(infoPtr, wParam, (SYSTEMTIME*)lParam);
|
1999-07-10 12:00:04 +00:00
|
|
|
|
1999-11-21 02:04:09 +00:00
|
|
|
case MCM_SETDAYSTATE:
|
2009-09-23 23:02:31 +00:00
|
|
|
return MONTHCAL_SetDayState(infoPtr, (INT)wParam, (LPMONTHDAYSTATE)lParam);
|
1999-07-10 12:00:04 +00:00
|
|
|
|
1999-11-21 02:04:09 +00:00
|
|
|
case MCM_GETMINREQRECT:
|
2009-09-23 23:02:31 +00:00
|
|
|
return MONTHCAL_GetMinReqRect(infoPtr, (LPRECT)lParam);
|
1999-07-10 12:00:04 +00:00
|
|
|
|
1999-11-21 02:04:09 +00:00
|
|
|
case MCM_GETCOLOR:
|
2004-11-30 17:35:16 +00:00
|
|
|
return MONTHCAL_GetColor(infoPtr, wParam);
|
1999-07-10 12:00:04 +00:00
|
|
|
|
1999-11-21 02:04:09 +00:00
|
|
|
case MCM_SETCOLOR:
|
2009-09-23 23:02:31 +00:00
|
|
|
return MONTHCAL_SetColor(infoPtr, wParam, (COLORREF)lParam);
|
1999-07-10 12:00:04 +00:00
|
|
|
|
1999-11-21 02:04:09 +00:00
|
|
|
case MCM_GETTODAY:
|
2009-09-23 23:02:31 +00:00
|
|
|
return MONTHCAL_GetToday(infoPtr, (LPSYSTEMTIME)lParam);
|
1999-07-10 12:00:04 +00:00
|
|
|
|
1999-11-21 02:04:09 +00:00
|
|
|
case MCM_SETTODAY:
|
2009-09-23 23:02:31 +00:00
|
|
|
return MONTHCAL_SetToday(infoPtr, (LPSYSTEMTIME)lParam);
|
1999-07-10 12:00:04 +00:00
|
|
|
|
1999-11-21 02:04:09 +00:00
|
|
|
case MCM_HITTEST:
|
2009-09-23 23:02:31 +00:00
|
|
|
return MONTHCAL_HitTest(infoPtr, (PMCHITTESTINFO)lParam);
|
1999-07-10 12:00:04 +00:00
|
|
|
|
1999-11-21 02:04:09 +00:00
|
|
|
case MCM_GETFIRSTDAYOFWEEK:
|
2004-11-30 17:35:16 +00:00
|
|
|
return MONTHCAL_GetFirstDayOfWeek(infoPtr);
|
1999-07-10 12:00:04 +00:00
|
|
|
|
1999-11-21 02:04:09 +00:00
|
|
|
case MCM_SETFIRSTDAYOFWEEK:
|
2009-09-23 23:02:31 +00:00
|
|
|
return MONTHCAL_SetFirstDayOfWeek(infoPtr, (INT)lParam);
|
1999-07-10 12:00:04 +00:00
|
|
|
|
1999-11-21 02:04:09 +00:00
|
|
|
case MCM_GETRANGE:
|
2009-09-23 23:02:31 +00:00
|
|
|
return MONTHCAL_GetRange(infoPtr, (LPSYSTEMTIME)lParam);
|
1999-07-10 12:00:04 +00:00
|
|
|
|
1999-11-21 02:04:09 +00:00
|
|
|
case MCM_SETRANGE:
|
2009-09-23 23:02:31 +00:00
|
|
|
return MONTHCAL_SetRange(infoPtr, (SHORT)wParam, (LPSYSTEMTIME)lParam);
|
1999-07-10 12:00:04 +00:00
|
|
|
|
1999-11-21 02:04:09 +00:00
|
|
|
case MCM_GETMONTHDELTA:
|
2004-11-30 17:35:16 +00:00
|
|
|
return MONTHCAL_GetMonthDelta(infoPtr);
|
1999-07-10 12:00:04 +00:00
|
|
|
|
1999-11-21 02:04:09 +00:00
|
|
|
case MCM_SETMONTHDELTA:
|
2004-11-30 17:35:16 +00:00
|
|
|
return MONTHCAL_SetMonthDelta(infoPtr, wParam);
|
1999-07-10 12:00:04 +00:00
|
|
|
|
1999-11-21 02:04:09 +00:00
|
|
|
case MCM_GETMAXTODAYWIDTH:
|
2004-11-30 17:35:16 +00:00
|
|
|
return MONTHCAL_GetMaxTodayWidth(infoPtr);
|
1999-07-10 12:00:04 +00:00
|
|
|
|
1999-11-21 02:04:09 +00:00
|
|
|
case WM_GETDLGCODE:
|
|
|
|
return DLGC_WANTARROWS | DLGC_WANTCHARS;
|
1999-07-10 12:00:04 +00:00
|
|
|
|
2009-09-28 18:04:41 +00:00
|
|
|
case WM_RBUTTONUP:
|
|
|
|
return MONTHCAL_RButtonUp(infoPtr, lParam);
|
2000-10-15 00:27:28 +00:00
|
|
|
|
1999-11-21 02:04:09 +00:00
|
|
|
case WM_LBUTTONDOWN:
|
2004-11-30 17:35:16 +00:00
|
|
|
return MONTHCAL_LButtonDown(infoPtr, lParam);
|
1999-07-10 12:00:04 +00:00
|
|
|
|
1999-11-21 02:04:09 +00:00
|
|
|
case WM_MOUSEMOVE:
|
2008-09-07 14:20:38 +00:00
|
|
|
return MONTHCAL_MouseMove(infoPtr, lParam);
|
1999-07-10 12:00:04 +00:00
|
|
|
|
1999-11-21 02:04:09 +00:00
|
|
|
case WM_LBUTTONUP:
|
2004-11-30 17:35:16 +00:00
|
|
|
return MONTHCAL_LButtonUp(infoPtr, lParam);
|
1999-07-10 12:00:04 +00:00
|
|
|
|
2005-11-08 12:52:35 +00:00
|
|
|
case WM_PRINTCLIENT:
|
1999-11-21 02:04:09 +00:00
|
|
|
case WM_PAINT:
|
2009-09-24 23:43:38 +00:00
|
|
|
return MONTHCAL_Paint(infoPtr, (HDC)wParam);
|
1999-07-10 12:00:04 +00:00
|
|
|
|
1999-11-21 02:04:09 +00:00
|
|
|
case WM_SETFOCUS:
|
2004-11-30 17:35:16 +00:00
|
|
|
return MONTHCAL_SetFocus(infoPtr);
|
2000-01-04 00:30:21 +00:00
|
|
|
|
|
|
|
case WM_SIZE:
|
2004-11-30 17:35:16 +00:00
|
|
|
return MONTHCAL_Size(infoPtr, (SHORT)LOWORD(lParam), (SHORT)HIWORD(lParam));
|
1998-11-08 11:30:27 +00:00
|
|
|
|
2009-10-10 17:04:16 +00:00
|
|
|
case WM_NOTIFY:
|
|
|
|
return MONTHCAL_Notify(infoPtr, (NMHDR*)lParam);
|
|
|
|
|
1999-11-21 02:04:09 +00:00
|
|
|
case WM_CREATE:
|
2009-09-23 23:02:31 +00:00
|
|
|
return MONTHCAL_Create(hwnd, (LPCREATESTRUCTW)lParam);
|
1998-11-08 11:30:27 +00:00
|
|
|
|
2004-11-30 17:35:16 +00:00
|
|
|
case WM_SETFONT:
|
|
|
|
return MONTHCAL_SetFont(infoPtr, (HFONT)wParam, (BOOL)lParam);
|
|
|
|
|
|
|
|
case WM_GETFONT:
|
|
|
|
return MONTHCAL_GetFont(infoPtr);
|
|
|
|
|
1999-11-21 02:04:09 +00:00
|
|
|
case WM_TIMER:
|
2004-11-30 17:35:16 +00:00
|
|
|
return MONTHCAL_Timer(infoPtr, wParam);
|
2005-08-11 17:05:00 +00:00
|
|
|
|
|
|
|
case WM_THEMECHANGED:
|
|
|
|
return theme_changed (infoPtr);
|
1999-07-31 11:13:25 +00:00
|
|
|
|
1999-11-21 02:04:09 +00:00
|
|
|
case WM_DESTROY:
|
2004-11-30 17:35:16 +00:00
|
|
|
return MONTHCAL_Destroy(infoPtr);
|
1998-11-08 11:30:27 +00:00
|
|
|
|
2009-05-18 15:03:40 +00:00
|
|
|
case WM_SYSCOLORCHANGE:
|
|
|
|
COMCTL32_RefreshSysColors();
|
|
|
|
return 0;
|
|
|
|
|
2009-09-08 06:44:55 +00:00
|
|
|
case WM_STYLECHANGED:
|
|
|
|
return MONTHCAL_StyleChanged(infoPtr, wParam, (LPSTYLESTRUCT)lParam);
|
|
|
|
|
2009-10-01 18:49:02 +00:00
|
|
|
case WM_STYLECHANGING:
|
|
|
|
return MONTHCAL_StyleChanging(infoPtr, wParam, (LPSTYLESTRUCT)lParam);
|
|
|
|
|
1999-11-21 02:04:09 +00:00
|
|
|
default:
|
2008-07-21 22:18:09 +00:00
|
|
|
if ((uMsg >= WM_USER) && (uMsg < WM_APP) && !COMCTL32_IsReflectedMessage(uMsg))
|
2007-05-24 14:41:17 +00:00
|
|
|
ERR( "unknown msg %04x wp=%08lx lp=%08lx\n", uMsg, wParam, lParam);
|
2005-04-11 14:21:00 +00:00
|
|
|
return DefWindowProcW(hwnd, uMsg, wParam, lParam);
|
1999-11-21 02:04:09 +00:00
|
|
|
}
|
1998-11-08 11:30:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-07-31 11:13:25 +00:00
|
|
|
void
|
2000-01-04 00:30:21 +00:00
|
|
|
MONTHCAL_Register(void)
|
1998-11-08 11:30:27 +00:00
|
|
|
{
|
2005-04-11 14:21:00 +00:00
|
|
|
WNDCLASSW wndClass;
|
1999-11-21 02:04:09 +00:00
|
|
|
|
2005-04-11 14:21:00 +00:00
|
|
|
ZeroMemory(&wndClass, sizeof(WNDCLASSW));
|
1999-11-21 02:04:09 +00:00
|
|
|
wndClass.style = CS_GLOBALCLASS;
|
2004-11-06 03:49:03 +00:00
|
|
|
wndClass.lpfnWndProc = MONTHCAL_WindowProc;
|
1999-11-21 02:04:09 +00:00
|
|
|
wndClass.cbClsExtra = 0;
|
|
|
|
wndClass.cbWndExtra = sizeof(MONTHCAL_INFO *);
|
2005-04-11 14:21:00 +00:00
|
|
|
wndClass.hCursor = LoadCursorW(0, (LPWSTR)IDC_ARROW);
|
1999-11-21 02:04:09 +00:00
|
|
|
wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
|
2005-04-11 14:21:00 +00:00
|
|
|
wndClass.lpszClassName = MONTHCAL_CLASSW;
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2005-04-11 14:21:00 +00:00
|
|
|
RegisterClassW(&wndClass);
|
1998-11-08 11:30:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-07-31 11:13:25 +00:00
|
|
|
void
|
2000-01-04 00:30:21 +00:00
|
|
|
MONTHCAL_Unregister(void)
|
1998-11-08 11:30:27 +00:00
|
|
|
{
|
2005-04-11 14:21:00 +00:00
|
|
|
UnregisterClassW(MONTHCAL_CLASSW, NULL);
|
1998-11-08 11:30:27 +00:00
|
|
|
}
|