2009-10-06 23:20:48 +02:00
|
|
|
/*
|
|
|
|
* Month calendar control
|
1998-11-08 12:30:27 +01:00
|
|
|
*
|
1999-07-10 14:00:04 +02:00
|
|
|
* Copyright 1998, 1999 Eric Kohl (ekohl@abo.rhein-zeitung.de)
|
2000-01-04 01:30:21 +01: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 02:27:28 +02:00
|
|
|
* Copyright 2000 Uwe Bonnes <bon@elektron.ikp.physik.tu-darmstadt.de>
|
2011-04-02 09:43:59 +02:00
|
|
|
* Copyright 2009-2011 Nikolay Sivov
|
1998-11-08 12:30:27 +01:00
|
|
|
*
|
2002-03-10 00:29:33 +01: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 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
1998-11-08 12:30:27 +01:00
|
|
|
* TODO:
|
2004-10-21 21:52:28 +02:00
|
|
|
* -- MCM_[GS]ETUNICODEFORMAT
|
|
|
|
* -- handle resources better (doesn't work now);
|
|
|
|
* -- take care of internationalization.
|
|
|
|
* -- keyboard handling.
|
|
|
|
* -- search for FIXME
|
1998-11-08 12:30:27 +01:00
|
|
|
*/
|
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
#include <math.h>
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
2000-02-10 20:03:02 +01:00
|
|
|
#include <stdio.h>
|
2000-11-01 04:11:12 +01:00
|
|
|
#include <stdlib.h>
|
2001-01-26 21:43:40 +01:00
|
|
|
#include <string.h>
|
1999-11-21 03:04:09 +01:00
|
|
|
|
2000-02-10 20:03:02 +01:00
|
|
|
#include "windef.h"
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "winbase.h"
|
2000-02-10 20:03:02 +01:00
|
|
|
#include "wingdi.h"
|
1999-07-10 14:00:04 +02:00
|
|
|
#include "winuser.h"
|
|
|
|
#include "winnls.h"
|
1998-11-08 12:30:27 +01:00
|
|
|
#include "commctrl.h"
|
1999-07-10 14:00:04 +02:00
|
|
|
#include "comctl32.h"
|
2005-08-11 19:05:00 +02:00
|
|
|
#include "uxtheme.h"
|
2011-06-27 14:21:48 +02:00
|
|
|
#include "vssym32.h"
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
2018-02-06 06:50:24 +01:00
|
|
|
#include "wine/heap.h"
|
1998-11-08 12:30:27 +01:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(monthcal);
|
1999-04-19 16:56:29 +02:00
|
|
|
|
2000-08-09 02:41:17 +02: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 22:58:22 +02:00
|
|
|
#define MC_PREVNEXTMONTHDELAY 350 /* when continuously pressing `next/prev
|
2010-07-18 14:12:41 +02:00
|
|
|
month', wait 350 ms before going
|
2009-10-06 22:58:22 +02:00
|
|
|
to the next/prev month */
|
|
|
|
#define MC_TODAYUPDATEDELAY 120000 /* time between today check for update (2 min) */
|
|
|
|
|
2011-07-30 12:03:08 +02:00
|
|
|
#define MC_PREVNEXTMONTHTIMER 1 /* Timer IDs */
|
2009-10-06 22:58:22 +02:00
|
|
|
#define MC_TODAYUPDATETIMER 2
|
2000-08-09 02:41:17 +02:00
|
|
|
|
2011-09-22 15:56:40 +02:00
|
|
|
#define MC_CALENDAR_PADDING 6
|
|
|
|
|
2009-10-04 21:17:07 +02:00
|
|
|
/* convert from days to 100 nanoseconds unit - used as FILETIME unit */
|
|
|
|
#define DAYSTO100NSECS(days) (((ULONGLONG)(days))*24*60*60*10000000)
|
|
|
|
|
2011-04-02 11:15:42 +02:00
|
|
|
enum CachedPen
|
|
|
|
{
|
|
|
|
PenRed = 0,
|
|
|
|
PenText,
|
|
|
|
PenLast
|
|
|
|
};
|
|
|
|
|
2011-04-02 11:33:48 +02:00
|
|
|
enum CachedBrush
|
|
|
|
{
|
|
|
|
BrushTitle = 0,
|
|
|
|
BrushMonth,
|
|
|
|
BrushBackground,
|
|
|
|
BrushLast
|
|
|
|
};
|
|
|
|
|
2010-07-18 14:12:41 +02:00
|
|
|
/* single calendar data */
|
|
|
|
typedef struct _CALENDAR_INFO
|
|
|
|
{
|
|
|
|
RECT title; /* rect for the header above the calendar */
|
|
|
|
RECT titlemonth; /* the 'month name' text in the header */
|
|
|
|
RECT titleyear; /* the 'year number' text in the header */
|
|
|
|
RECT wdays; /* week days at top */
|
|
|
|
RECT days; /* calendar area */
|
|
|
|
RECT weeknums; /* week numbers at left side */
|
2010-07-18 14:14:56 +02:00
|
|
|
|
|
|
|
SYSTEMTIME month;/* contains calendar main month/year */
|
2010-07-18 14:12:41 +02:00
|
|
|
} CALENDAR_INFO;
|
|
|
|
|
2000-08-09 02:41:17 +02:00
|
|
|
typedef struct
|
|
|
|
{
|
2009-09-08 08:44:55 +02:00
|
|
|
HWND hwndSelf;
|
|
|
|
DWORD dwStyle; /* cached GWL_STYLE */
|
2010-08-08 14:54:23 +02:00
|
|
|
|
|
|
|
COLORREF colors[MCSC_TRAILINGTEXT+1];
|
2011-04-02 11:33:48 +02:00
|
|
|
HBRUSH brushes[BrushLast];
|
2011-04-02 11:15:42 +02:00
|
|
|
HPEN pens[PenLast];
|
2010-08-08 14:54:23 +02:00
|
|
|
|
2000-08-09 02:41:17 +02:00
|
|
|
HFONT hFont;
|
|
|
|
HFONT hBoldFont;
|
|
|
|
int textHeight;
|
|
|
|
int height_increment;
|
|
|
|
int width_increment;
|
2009-09-25 01:43:38 +02:00
|
|
|
INT delta; /* scroll rate; # of months that the */
|
2000-08-09 02:41:17 +02:00
|
|
|
/* control moves when user clicks a scroll button */
|
2009-10-07 22:45:05 +02:00
|
|
|
int firstDay; /* Start month calendar with firstDay's day,
|
|
|
|
stored in SYSTEMTIME format */
|
|
|
|
BOOL firstDaySet; /* first week day differs from locale defined */
|
|
|
|
|
2009-10-15 18:16:27 +02:00
|
|
|
BOOL isUnicode; /* value set with MCM_SETUNICODE format */
|
|
|
|
|
2000-08-09 02:41:17 +02:00
|
|
|
MONTHDAYSTATE *monthdayState;
|
|
|
|
SYSTEMTIME todaysDate;
|
2009-10-06 22:58:22 +02:00
|
|
|
BOOL todaySet; /* Today was forced with MCM_SETTODAY */
|
2000-08-09 02:41:17 +02:00
|
|
|
int status; /* See MC_SEL flags */
|
2009-10-04 21:17:07 +02:00
|
|
|
SYSTEMTIME firstSel; /* first selected day */
|
2009-09-25 01:16:51 +02:00
|
|
|
INT maxSelCount;
|
2010-08-02 07:36:12 +02:00
|
|
|
SYSTEMTIME minSel; /* contains single selection when used without MCS_MULTISELECT */
|
2000-08-09 02:41:17 +02:00
|
|
|
SYSTEMTIME maxSel;
|
2009-10-04 21:16:41 +02:00
|
|
|
SYSTEMTIME focusedSel; /* date currently focused with mouse movement */
|
2000-08-09 02:41:17 +02:00
|
|
|
DWORD rangeValid;
|
|
|
|
SYSTEMTIME minDate;
|
|
|
|
SYSTEMTIME maxDate;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-08-09 02:41:17 +02:00
|
|
|
RECT titlebtnnext; /* the `next month' button in the header */
|
2002-06-01 01:06:46 +02:00
|
|
|
RECT titlebtnprev; /* the `prev month' button in the header */
|
2000-10-15 02:27:28 +02:00
|
|
|
RECT todayrect; /* `today: xx/xx/xx' text rect */
|
2003-11-20 23:04:13 +01:00
|
|
|
HWND hwndNotify; /* Window to receive the notifications */
|
2000-10-15 02:27:28 +02:00
|
|
|
HWND hWndYearEdit; /* Window Handle of edit box to handle years */
|
|
|
|
HWND hWndYearUpDown;/* Window Handle of updown box to handle years */
|
2009-10-10 19:04:16 +02:00
|
|
|
WNDPROC EditWndProc; /* original Edit window procedure */
|
2010-07-18 14:12:41 +02:00
|
|
|
|
|
|
|
CALENDAR_INFO *calendars;
|
2011-09-13 19:45:07 +02:00
|
|
|
SIZE dim; /* [cx,cy] - dimensions of calendars matrix, row/column count */
|
2000-08-09 02:41:17 +02:00
|
|
|
} MONTHCAL_INFO, *LPMONTHCAL_INFO;
|
|
|
|
|
2005-08-11 19:05:00 +02:00
|
|
|
static const WCHAR themeClass[] = { 'S','c','r','o','l','l','b','a','r',0 };
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2009-10-05 18:34:05 +02:00
|
|
|
/* empty SYSTEMTIME const */
|
|
|
|
static const SYSTEMTIME st_null;
|
2009-10-05 20:37:04 +02:00
|
|
|
/* valid date limits */
|
2012-01-27 23:56:10 +01:00
|
|
|
static const SYSTEMTIME max_allowed_date = { /* wYear */ 9999, /* wMonth */ 12, /* wDayOfWeek */ 0, /* wDay */ 31 };
|
|
|
|
static const SYSTEMTIME min_allowed_date = { /* wYear */ 1752, /* wMonth */ 9, /* wDayOfWeek */ 0, /* wDay */ 14 };
|
2009-10-05 20:37:04 +02:00
|
|
|
|
2010-07-31 11:25:47 +02:00
|
|
|
/* Prev/Next buttons */
|
|
|
|
enum nav_direction
|
|
|
|
{
|
|
|
|
DIRECTION_BACKWARD,
|
|
|
|
DIRECTION_FORWARD
|
|
|
|
};
|
2009-10-05 18:34:05 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
/* helper functions */
|
2011-09-13 19:45:07 +02:00
|
|
|
static inline INT MONTHCAL_GetCalCount(const MONTHCAL_INFO *infoPtr)
|
|
|
|
{
|
|
|
|
return infoPtr->dim.cx * infoPtr->dim.cy;
|
|
|
|
}
|
1999-11-21 03:04:09 +01:00
|
|
|
|
2009-10-01 20:12:21 +02: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;
|
2012-08-17 08:24:12 +02:00
|
|
|
nmsc.stSelStart.wDayOfWeek = 0;
|
|
|
|
if(infoPtr->dwStyle & MCS_MULTISELECT){
|
|
|
|
nmsc.stSelEnd = infoPtr->maxSel;
|
|
|
|
nmsc.stSelEnd.wDayOfWeek = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
nmsc.stSelEnd = st_null;
|
|
|
|
|
2009-10-01 20:12:21 +02:00
|
|
|
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;
|
2012-08-17 08:24:12 +02:00
|
|
|
nmsc.stSelStart.wDayOfWeek = 0;
|
|
|
|
if(infoPtr->dwStyle & MCS_MULTISELECT){
|
|
|
|
nmsc.stSelEnd = infoPtr->maxSel;
|
|
|
|
nmsc.stSelEnd.wDayOfWeek = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
nmsc.stSelEnd = st_null;
|
2009-10-01 20:12:21 +02:00
|
|
|
|
|
|
|
SendMessageW(infoPtr->hwndNotify, WM_NOTIFY, nmsc.nmhdr.idFrom, (LPARAM)&nmsc);
|
|
|
|
}
|
|
|
|
|
2011-09-19 08:44:22 +02:00
|
|
|
static inline int MONTHCAL_MonthDiff(const SYSTEMTIME *left, const SYSTEMTIME *right)
|
|
|
|
{
|
|
|
|
return (right->wYear - left->wYear)*12 + right->wMonth - left->wMonth;
|
|
|
|
}
|
|
|
|
|
2000-10-15 02:27:28 +02:00
|
|
|
/* returns the number of days in any given month, checking for leap days */
|
2011-07-30 12:03:08 +02:00
|
|
|
/* January is 1, December is 12 */
|
2000-10-15 02:27:28 +02:00
|
|
|
int MONTHCAL_MonthLength(int month, int year)
|
1999-11-21 03:04:09 +01:00
|
|
|
{
|
2018-12-04 05:42:48 +01:00
|
|
|
static const int mdays[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
|
2009-10-07 22:45:05 +02: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 02:27:28 +02:00
|
|
|
if(month == 0)
|
|
|
|
month = 12;
|
2009-10-07 22:45:05 +02:00
|
|
|
else if(month == 13)
|
2000-10-15 02:27:28 +02:00
|
|
|
month = 1;
|
|
|
|
|
2009-10-10 21:12:43 +02:00
|
|
|
/* special case for calendar transition year */
|
|
|
|
if(month == min_allowed_date.wMonth && year == min_allowed_date.wYear) return 19;
|
|
|
|
|
1999-11-21 03:04:09 +01: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 01:30:21 +01:00
|
|
|
(year%4 == 0)) ? 1 : 0);
|
1999-11-21 03:04:09 +01:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
return mdays[month - 1];
|
|
|
|
}
|
|
|
|
}
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2009-09-25 01:32:18 +02: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 14:00:04 +02:00
|
|
|
|
2009-09-26 18:06:48 +02:00
|
|
|
/* make sure that date fields are valid */
|
|
|
|
static BOOL MONTHCAL_ValidateDate(const SYSTEMTIME *time)
|
1999-07-10 14:00:04 +02:00
|
|
|
{
|
2017-08-27 23:07:51 +02:00
|
|
|
if (time->wMonth < 1 || time->wMonth > 12 )
|
|
|
|
return FALSE;
|
|
|
|
if (time->wDay == 0 || time->wDay > MONTHCAL_MonthLength(time->wMonth, time->wYear))
|
|
|
|
return FALSE;
|
2000-01-04 01:30:21 +01:00
|
|
|
|
2017-08-27 23:07:51 +02:00
|
|
|
return TRUE;
|
1999-07-10 14:00:04 +02:00
|
|
|
}
|
|
|
|
|
2009-10-11 01:54:11 +02: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 21:17:33 +02: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
|
|
|
|
*
|
2011-07-30 12:03:08 +02:00
|
|
|
* Note that no date validation performed, already validated values expected.
|
2009-10-04 21:17:33 +02:00
|
|
|
*/
|
2012-03-08 12:34:13 +01:00
|
|
|
LONG MONTHCAL_CompareSystemTime(const SYSTEMTIME *first, const SYSTEMTIME *second)
|
2009-10-04 21:17:33 +02:00
|
|
|
{
|
|
|
|
FILETIME ft_first, ft_second;
|
|
|
|
|
|
|
|
SystemTimeToFileTime(first, &ft_first);
|
|
|
|
SystemTimeToFileTime(second, &ft_second);
|
|
|
|
|
|
|
|
return CompareFileTime(&ft_first, &ft_second);
|
|
|
|
}
|
|
|
|
|
2009-10-11 01:54:11 +02: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 03:03:59 +02: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 21:17:33 +02: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 22:28:51 +02:00
|
|
|
* [I] fix : make date fit valid range
|
2009-10-04 21:17:33 +02:00
|
|
|
*
|
|
|
|
* RETURN VALUE
|
|
|
|
*
|
2011-07-30 12:03:08 +02:00
|
|
|
* TRUE - date within largest and configured range
|
2009-10-04 21:17:33 +02:00
|
|
|
* FALSE - date is outside largest or configured range
|
|
|
|
*/
|
2009-10-10 22:28:51 +02:00
|
|
|
static BOOL MONTHCAL_IsDateInValidRange(const MONTHCAL_INFO *infoPtr,
|
|
|
|
SYSTEMTIME *date, BOOL fix)
|
2009-10-04 21:17:33 +02:00
|
|
|
{
|
2009-10-10 22:28:51 +02:00
|
|
|
const SYSTEMTIME *fix_st = NULL;
|
2009-10-04 21:17:33 +02:00
|
|
|
|
2009-10-10 22:28:51 +02: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;
|
|
|
|
}
|
2012-03-08 12:34:01 +01:00
|
|
|
else {
|
|
|
|
if(infoPtr->rangeValid & GDTR_MAX) {
|
|
|
|
if((MONTHCAL_CompareSystemTime(date, &infoPtr->maxDate) == 1)) {
|
|
|
|
fix_st = &infoPtr->maxDate;
|
|
|
|
}
|
2009-10-10 22:28:51 +02:00
|
|
|
}
|
2012-03-08 12:34:01 +01:00
|
|
|
|
|
|
|
if(infoPtr->rangeValid & GDTR_MIN) {
|
|
|
|
if((MONTHCAL_CompareSystemTime(date, &infoPtr->minDate) == -1)) {
|
|
|
|
fix_st = &infoPtr->minDate;
|
|
|
|
}
|
2009-10-10 22:28:51 +02:00
|
|
|
}
|
2009-10-04 21:17:33 +02:00
|
|
|
}
|
|
|
|
|
2009-10-10 22:28:51 +02:00
|
|
|
if (fix && fix_st) {
|
|
|
|
date->wYear = fix_st->wYear;
|
|
|
|
date->wMonth = fix_st->wMonth;
|
2009-10-04 21:17:33 +02:00
|
|
|
}
|
|
|
|
|
2012-08-08 21:00:22 +02:00
|
|
|
return !fix_st;
|
2009-10-04 21:17:33 +02:00
|
|
|
}
|
|
|
|
|
2009-10-05 18:29:31 +02: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);
|
|
|
|
|
2009-10-17 20:27:44 +02:00
|
|
|
ul_range0.u.LowPart = ft_range0.dwLowDateTime;
|
|
|
|
ul_range0.u.HighPart = ft_range0.dwHighDateTime;
|
|
|
|
ul_range1.u.LowPart = ft_range1.dwLowDateTime;
|
|
|
|
ul_range1.u.HighPart = ft_range1.dwHighDateTime;
|
2009-10-05 18:29:31 +02:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
2009-10-17 20:27:44 +02:00
|
|
|
ft_range0.dwLowDateTime = ul_range0.u.LowPart;
|
|
|
|
ft_range0.dwHighDateTime = ul_range0.u.HighPart;
|
2009-10-05 18:29:31 +02:00
|
|
|
FileTimeToSystemTime(&ft_range0, adjust);
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
else return TRUE;
|
|
|
|
}
|
|
|
|
|
2009-09-26 18:06:48 +02:00
|
|
|
/* Used in MCM_SETRANGE/MCM_SETSELRANGE to determine resulting time part.
|
2009-10-08 11:23:19 +02:00
|
|
|
Milliseconds are intentionally not validated. */
|
2009-09-26 18:06:48 +02:00
|
|
|
static BOOL MONTHCAL_ValidateTime(const SYSTEMTIME *time)
|
|
|
|
{
|
|
|
|
if((time->wHour > 24) || (time->wMinute > 59) || (time->wSecond > 59))
|
|
|
|
return FALSE;
|
|
|
|
else
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
/* Note:Depending on DST, this may be offset by a day.
|
1999-07-10 14:00:04 +02: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 03:04:09 +01:00
|
|
|
Valid for year>1752; 1 <= d <= 31, 1 <= m <= 12.
|
2005-04-14 13:31:17 +02:00
|
|
|
0 = Sunday.
|
1999-07-10 14:00:04 +02:00
|
|
|
*/
|
|
|
|
|
2009-10-07 22:45:05 +02:00
|
|
|
/* Returns the day in the week
|
|
|
|
*
|
|
|
|
* PARAMETERS
|
2009-10-11 02:28:09 +02:00
|
|
|
* [i] date : input date
|
|
|
|
* [I] inplace : set calculated value back to date structure
|
2009-10-07 22:45:05 +02:00
|
|
|
*
|
|
|
|
* RETURN VALUE
|
|
|
|
* day of week in SYSTEMTIME format: (0 == sunday,..., 6 == saturday)
|
|
|
|
*/
|
2009-10-11 02:28:09 +02:00
|
|
|
int MONTHCAL_CalculateDayOfWeek(SYSTEMTIME *date, BOOL inplace)
|
1999-07-10 14:00:04 +02:00
|
|
|
{
|
2009-10-11 02:28:09 +02:00
|
|
|
SYSTEMTIME st = st_null;
|
2009-10-10 19:20:26 +02:00
|
|
|
FILETIME ft;
|
|
|
|
|
2009-10-11 02:28:09 +02:00
|
|
|
MONTHCAL_CopyDate(date, &st);
|
2009-10-10 19:20:26 +02:00
|
|
|
|
|
|
|
SystemTimeToFileTime(&st, &ft);
|
|
|
|
FileTimeToSystemTime(&ft, &st);
|
1999-11-21 03:04:09 +01:00
|
|
|
|
2009-10-11 02:28:09 +02:00
|
|
|
if (inplace) date->wDayOfWeek = st.wDayOfWeek;
|
|
|
|
|
2009-10-10 19:20:26 +02:00
|
|
|
return st.wDayOfWeek;
|
1999-07-10 14:00:04 +02:00
|
|
|
}
|
|
|
|
|
2011-05-09 09:03:40 +02:00
|
|
|
/* add/subtract 'months' from date */
|
2010-08-01 08:25:00 +02:00
|
|
|
static inline void MONTHCAL_GetMonth(SYSTEMTIME *date, INT months)
|
2009-10-07 01:19:52 +02:00
|
|
|
{
|
2010-08-08 13:32:52 +02:00
|
|
|
INT length, m = date->wMonth + months;
|
2010-07-31 11:36:37 +02:00
|
|
|
|
2010-08-08 13:32:52 +02:00
|
|
|
date->wYear += m > 0 ? (m - 1) / 12 : m / 12 - 1;
|
|
|
|
date->wMonth = m > 0 ? (m - 1) % 12 + 1 : 12 + m % 12;
|
2010-07-31 11:36:37 +02:00
|
|
|
/* fix moving from last day in a month */
|
|
|
|
length = MONTHCAL_MonthLength(date->wMonth, date->wYear);
|
|
|
|
if(date->wDay > length) date->wDay = length;
|
2009-10-11 02:28:09 +02:00
|
|
|
MONTHCAL_CalculateDayOfWeek(date, TRUE);
|
2009-10-07 01:19:52 +02:00
|
|
|
}
|
|
|
|
|
2010-08-01 08:25:00 +02:00
|
|
|
/* properly updates date to point on next month */
|
|
|
|
static inline void MONTHCAL_GetNextMonth(SYSTEMTIME *date)
|
|
|
|
{
|
2011-08-06 13:51:11 +02:00
|
|
|
MONTHCAL_GetMonth(date, 1);
|
2010-08-01 08:25:00 +02:00
|
|
|
}
|
|
|
|
|
2009-10-07 01:19:52 +02:00
|
|
|
/* properly updates date to point on prev month */
|
2009-10-08 12:02:18 +02:00
|
|
|
static inline void MONTHCAL_GetPrevMonth(SYSTEMTIME *date)
|
2009-10-07 01:19:52 +02:00
|
|
|
{
|
2011-08-06 13:51:11 +02:00
|
|
|
MONTHCAL_GetMonth(date, -1);
|
2009-10-07 01:19:52 +02:00
|
|
|
}
|
|
|
|
|
2009-10-08 12:02:18 +02:00
|
|
|
/* Returns full date for a first currently visible day */
|
|
|
|
static void MONTHCAL_GetMinDate(const MONTHCAL_INFO *infoPtr, SYSTEMTIME *date)
|
|
|
|
{
|
2010-07-18 14:14:56 +02:00
|
|
|
/* zero indexed calendar has the earliest date */
|
|
|
|
SYSTEMTIME st_first = infoPtr->calendars[0].month;
|
|
|
|
INT firstDay;
|
2009-10-08 12:02:18 +02:00
|
|
|
|
2009-10-11 02:28:09 +02:00
|
|
|
st_first.wDay = 1;
|
|
|
|
firstDay = MONTHCAL_CalculateDayOfWeek(&st_first, FALSE);
|
2009-10-08 12:02:18 +02:00
|
|
|
|
2010-07-18 14:14:56 +02:00
|
|
|
*date = infoPtr->calendars[0].month;
|
2009-10-08 12:02:18 +02:00
|
|
|
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 02:28:09 +02:00
|
|
|
MONTHCAL_CalculateDayOfWeek(date, TRUE);
|
2009-10-08 12:02:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Returns full date for a last currently visible day */
|
|
|
|
static void MONTHCAL_GetMaxDate(const MONTHCAL_INFO *infoPtr, SYSTEMTIME *date)
|
|
|
|
{
|
2010-07-18 14:14:56 +02:00
|
|
|
/* the latest date is in latest calendar */
|
2011-09-14 20:59:13 +02:00
|
|
|
SYSTEMTIME st, *lt_month = &infoPtr->calendars[MONTHCAL_GetCalCount(infoPtr)-1].month;
|
|
|
|
INT first_day;
|
|
|
|
|
|
|
|
*date = *lt_month;
|
|
|
|
st = *lt_month;
|
|
|
|
|
|
|
|
/* day of week of first day of current month */
|
|
|
|
st.wDay = 1;
|
|
|
|
first_day = MONTHCAL_CalculateDayOfWeek(&st, FALSE);
|
2009-10-08 12:02:18 +02:00
|
|
|
|
|
|
|
MONTHCAL_GetNextMonth(date);
|
2011-09-14 20:59:13 +02:00
|
|
|
MONTHCAL_GetPrevMonth(&st);
|
|
|
|
|
|
|
|
/* last calendar starts with some date from previous month that not displayed */
|
|
|
|
st.wDay = MONTHCAL_MonthLength(st.wMonth, st.wYear) +
|
|
|
|
(infoPtr->firstDay - first_day) % 7 + 1;
|
|
|
|
if (st.wDay > MONTHCAL_MonthLength(st.wMonth, st.wYear)) st.wDay -= 7;
|
2009-10-08 12:02:18 +02:00
|
|
|
|
|
|
|
/* 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) -
|
2011-09-14 20:59:13 +02:00
|
|
|
MONTHCAL_MonthLength(lt_month->wMonth, lt_month->wYear);
|
2009-10-08 12:02:18 +02:00
|
|
|
|
|
|
|
/* fix day of week */
|
2009-10-11 02:28:09 +02:00
|
|
|
MONTHCAL_CalculateDayOfWeek(date, TRUE);
|
2009-10-08 12:02:18 +02:00
|
|
|
}
|
|
|
|
|
2011-09-04 17:48:28 +02:00
|
|
|
/* From a given point calculate the row, column and day in the calendar,
|
|
|
|
'day == 0' means the last day of the last month. */
|
|
|
|
static int MONTHCAL_GetDayFromPos(const MONTHCAL_INFO *infoPtr, POINT pt, INT calIdx)
|
1999-07-10 14:00:04 +02:00
|
|
|
{
|
2011-09-04 17:48:28 +02:00
|
|
|
SYSTEMTIME st = infoPtr->calendars[calIdx].month;
|
|
|
|
int firstDay, col, row;
|
|
|
|
RECT client;
|
2004-11-08 21:27:02 +01:00
|
|
|
|
2011-09-04 17:48:28 +02:00
|
|
|
GetClientRect(infoPtr->hwndSelf, &client);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2011-09-04 17:48:28 +02:00
|
|
|
/* if the point is outside the x bounds of the window put it at the boundary */
|
|
|
|
if (pt.x > client.right) pt.x = client.right;
|
2004-11-08 21:27:02 +01:00
|
|
|
|
2011-09-04 17:48:28 +02:00
|
|
|
col = (pt.x - infoPtr->calendars[calIdx].days.left ) / infoPtr->width_increment;
|
|
|
|
row = (pt.y - infoPtr->calendars[calIdx].days.top ) / infoPtr->height_increment;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2009-10-11 02:28:09 +02:00
|
|
|
st.wDay = 1;
|
|
|
|
firstDay = (MONTHCAL_CalculateDayOfWeek(&st, FALSE) + 6 - infoPtr->firstDay) % 7;
|
2011-09-04 17:48:28 +02:00
|
|
|
return col + 7 * row - firstDay;
|
1999-11-21 03:04:09 +01:00
|
|
|
}
|
|
|
|
|
2011-09-04 17:48:28 +02:00
|
|
|
/* Get day position for given date and calendar
|
2009-10-11 01:54:11 +02:00
|
|
|
*
|
|
|
|
* PARAMETERS
|
|
|
|
*
|
|
|
|
* [I] infoPtr : pointer to control data
|
|
|
|
* [I] date : date value
|
2011-09-04 17:48:28 +02:00
|
|
|
* [O] col : day column (zero based)
|
|
|
|
* [O] row : week column (zero based)
|
|
|
|
* [I] calIdx : calendar index
|
2009-10-11 01:54:11 +02:00
|
|
|
*/
|
2011-09-04 17:48:28 +02:00
|
|
|
static void MONTHCAL_GetDayPos(const MONTHCAL_INFO *infoPtr, const SYSTEMTIME *date,
|
|
|
|
INT *col, INT *row, INT calIdx)
|
1999-07-10 14:00:04 +02:00
|
|
|
{
|
2011-09-04 17:48:28 +02:00
|
|
|
SYSTEMTIME st = infoPtr->calendars[calIdx].month;
|
|
|
|
INT first;
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2009-10-11 02:28:09 +02:00
|
|
|
st.wDay = 1;
|
|
|
|
first = (MONTHCAL_CalculateDayOfWeek(&st, FALSE) + 6 - infoPtr->firstDay) % 7;
|
1999-11-21 03:04:09 +01:00
|
|
|
|
2011-09-13 19:45:07 +02:00
|
|
|
if (calIdx == 0 || calIdx == MONTHCAL_GetCalCount(infoPtr)-1) {
|
2011-09-04 17:48:28 +02:00
|
|
|
const SYSTEMTIME *cal = &infoPtr->calendars[calIdx].month;
|
|
|
|
LONG cmp = MONTHCAL_CompareMonths(date, &st);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2011-09-04 17:48:28 +02:00
|
|
|
/* previous month */
|
|
|
|
if (cmp == -1) {
|
|
|
|
*col = (first - MONTHCAL_MonthLength(date->wMonth, cal->wYear) + date->wDay) % 7;
|
|
|
|
*row = 0;
|
|
|
|
return;
|
|
|
|
}
|
1999-11-21 03:04:09 +01:00
|
|
|
|
2011-09-04 17:48:28 +02:00
|
|
|
/* next month calculation is same as for current, just add current month length */
|
|
|
|
if (cmp == 1)
|
|
|
|
first += MONTHCAL_MonthLength(cal->wMonth, cal->wYear);
|
2009-10-11 01:54:11 +02:00
|
|
|
}
|
|
|
|
|
2011-09-04 17:48:28 +02:00
|
|
|
*col = (date->wDay + first) % 7;
|
|
|
|
*row = (date->wDay + first - *col) / 7;
|
1999-07-10 14:00:04 +02:00
|
|
|
}
|
|
|
|
|
2011-09-04 17:48:28 +02:00
|
|
|
/* returns bounding box for day in given position in given calendar */
|
|
|
|
static inline void MONTHCAL_GetDayRectI(const MONTHCAL_INFO *infoPtr, RECT *r,
|
|
|
|
INT col, INT row, INT calIdx)
|
1999-07-10 14:00:04 +02:00
|
|
|
{
|
2011-09-04 17:48:28 +02:00
|
|
|
r->left = infoPtr->calendars[calIdx].days.left + col * infoPtr->width_increment;
|
|
|
|
r->right = r->left + infoPtr->width_increment;
|
|
|
|
r->top = infoPtr->calendars[calIdx].days.top + row * infoPtr->height_increment;
|
1999-07-10 14:00:04 +02:00
|
|
|
r->bottom = r->top + infoPtr->textHeight;
|
|
|
|
}
|
|
|
|
|
2011-09-04 17:48:28 +02:00
|
|
|
/* Returns bounding box for given date
|
|
|
|
*
|
|
|
|
* NOTE: when calendar index is unknown pass -1
|
|
|
|
*/
|
2017-08-27 23:07:52 +02:00
|
|
|
static BOOL MONTHCAL_GetDayRect(const MONTHCAL_INFO *infoPtr, const SYSTEMTIME *date, RECT *r, INT calIdx)
|
1999-07-10 14:00:04 +02:00
|
|
|
{
|
2011-09-04 17:48:28 +02:00
|
|
|
INT col, row;
|
|
|
|
|
2017-08-27 23:07:52 +02:00
|
|
|
if (!MONTHCAL_ValidateDate(date))
|
|
|
|
{
|
|
|
|
SetRectEmpty(r);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2011-09-04 17:48:28 +02:00
|
|
|
if (calIdx == -1)
|
|
|
|
{
|
|
|
|
INT cmp = MONTHCAL_CompareMonths(date, &infoPtr->calendars[0].month);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2011-09-04 17:48:28 +02:00
|
|
|
if (cmp <= 0)
|
|
|
|
calIdx = 0;
|
|
|
|
else
|
|
|
|
{
|
2011-09-13 19:45:07 +02:00
|
|
|
cmp = MONTHCAL_CompareMonths(date, &infoPtr->calendars[MONTHCAL_GetCalCount(infoPtr)-1].month);
|
2011-09-04 17:48:28 +02:00
|
|
|
if (cmp >= 0)
|
2011-09-13 19:45:07 +02:00
|
|
|
calIdx = MONTHCAL_GetCalCount(infoPtr)-1;
|
2011-09-04 17:48:28 +02:00
|
|
|
else
|
|
|
|
{
|
2011-09-13 19:45:07 +02:00
|
|
|
for (calIdx = 1; calIdx < MONTHCAL_GetCalCount(infoPtr)-1; calIdx++)
|
2011-09-04 17:48:28 +02:00
|
|
|
if (MONTHCAL_CompareMonths(date, &infoPtr->calendars[calIdx].month) == 0)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
MONTHCAL_GetDayPos(infoPtr, date, &col, &row, calIdx);
|
|
|
|
MONTHCAL_GetDayRectI(infoPtr, r, col, row, calIdx);
|
2017-08-27 23:07:52 +02:00
|
|
|
|
|
|
|
return TRUE;
|
1999-07-10 14:00:04 +02:00
|
|
|
}
|
|
|
|
|
2011-09-23 10:25:35 +02:00
|
|
|
static LRESULT
|
|
|
|
MONTHCAL_GetMonthRange(const MONTHCAL_INFO *infoPtr, DWORD flag, SYSTEMTIME *st)
|
|
|
|
{
|
|
|
|
INT range;
|
|
|
|
|
|
|
|
TRACE("flag=%d, st=%p\n", flag, st);
|
|
|
|
|
|
|
|
switch (flag) {
|
|
|
|
case GMR_VISIBLE:
|
|
|
|
{
|
|
|
|
if (st)
|
|
|
|
{
|
|
|
|
st[0] = infoPtr->calendars[0].month;
|
|
|
|
st[1] = infoPtr->calendars[MONTHCAL_GetCalCount(infoPtr)-1].month;
|
|
|
|
|
|
|
|
if (st[0].wMonth == min_allowed_date.wMonth &&
|
|
|
|
st[0].wYear == min_allowed_date.wYear)
|
|
|
|
{
|
|
|
|
st[0].wDay = min_allowed_date.wDay;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
st[0].wDay = 1;
|
|
|
|
MONTHCAL_CalculateDayOfWeek(&st[0], TRUE);
|
|
|
|
|
|
|
|
st[1].wDay = MONTHCAL_MonthLength(st[1].wMonth, st[1].wYear);
|
|
|
|
MONTHCAL_CalculateDayOfWeek(&st[1], TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
range = MONTHCAL_GetCalCount(infoPtr);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case GMR_DAYSTATE:
|
|
|
|
{
|
|
|
|
if (st)
|
|
|
|
{
|
|
|
|
MONTHCAL_GetMinDate(infoPtr, &st[0]);
|
|
|
|
MONTHCAL_GetMaxDate(infoPtr, &st[1]);
|
|
|
|
}
|
|
|
|
/* include two partially visible months */
|
|
|
|
range = MONTHCAL_GetCalCount(infoPtr) + 2;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
WARN("Unknown flag value, got %d\n", flag);
|
|
|
|
range = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return range;
|
|
|
|
}
|
|
|
|
|
2009-10-04 21:16:41 +02: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 18:32:15 +02:00
|
|
|
|
|
|
|
Returns TRUE if focused day changed, FALSE otherwise.
|
2009-10-04 21:16:41 +02:00
|
|
|
*/
|
2009-10-05 18:32:15 +02:00
|
|
|
static BOOL MONTHCAL_SetDayFocus(MONTHCAL_INFO *infoPtr, const SYSTEMTIME *st)
|
2009-10-04 21:16:41 +02: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 18:32:15 +02:00
|
|
|
if(MONTHCAL_IsDateEqual(&infoPtr->focusedSel, st)) return FALSE;
|
2009-10-04 21:16:41 +02:00
|
|
|
|
|
|
|
/* invalidate old focused day */
|
2017-08-27 23:07:52 +02:00
|
|
|
if (MONTHCAL_GetDayRect(infoPtr, &infoPtr->focusedSel, &r, -1))
|
|
|
|
InvalidateRect(infoPtr->hwndSelf, &r, FALSE);
|
2009-10-04 21:16:41 +02:00
|
|
|
|
|
|
|
infoPtr->focusedSel = *st;
|
|
|
|
}
|
|
|
|
|
2017-08-27 23:07:52 +02:00
|
|
|
/* On set invalidates new day, on reset clears previous focused day. */
|
|
|
|
if (MONTHCAL_GetDayRect(infoPtr, &infoPtr->focusedSel, &r, -1))
|
|
|
|
InvalidateRect(infoPtr->hwndSelf, &r, FALSE);
|
2009-10-04 21:16:41 +02:00
|
|
|
|
2009-10-05 22:06:55 +02:00
|
|
|
if(!st && MONTHCAL_ValidateDate(&infoPtr->focusedSel))
|
2009-10-04 21:16:41 +02:00
|
|
|
infoPtr->focusedSel = st_null;
|
|
|
|
|
2009-10-05 18:32:15 +02:00
|
|
|
return TRUE;
|
2009-10-04 21:16:41 +02:00
|
|
|
}
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2011-04-02 10:40:56 +02:00
|
|
|
/* draw today boundary box for specified rectangle */
|
|
|
|
static void MONTHCAL_Circle(const MONTHCAL_INFO *infoPtr, HDC hdc, const RECT *r)
|
|
|
|
{
|
2011-04-02 11:15:42 +02:00
|
|
|
HPEN old_pen = SelectObject(hdc, infoPtr->pens[PenRed]);
|
2011-04-02 10:40:56 +02:00
|
|
|
HBRUSH old_brush;
|
|
|
|
|
|
|
|
old_brush = SelectObject(hdc, GetStockObject(NULL_BRUSH));
|
|
|
|
Rectangle(hdc, r->left, r->top, r->right, r->bottom);
|
|
|
|
|
|
|
|
SelectObject(hdc, old_brush);
|
|
|
|
SelectObject(hdc, old_pen);
|
|
|
|
}
|
|
|
|
|
2009-10-11 01:54:11 +02:00
|
|
|
/* Draw today day mark rectangle
|
|
|
|
*
|
2011-04-02 10:40:56 +02:00
|
|
|
* [I] hdc : context to draw in
|
|
|
|
* [I] date : day to mark with rectangle
|
2009-10-11 01:54:11 +02:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
static void MONTHCAL_CircleDay(const MONTHCAL_INFO *infoPtr, HDC hdc,
|
|
|
|
const SYSTEMTIME *date)
|
1999-07-10 14:00:04 +02:00
|
|
|
{
|
2011-09-04 17:48:28 +02:00
|
|
|
RECT r;
|
|
|
|
|
|
|
|
MONTHCAL_GetDayRect(infoPtr, date, &r, -1);
|
|
|
|
MONTHCAL_Circle(infoPtr, hdc, &r);
|
1999-11-21 03:04:09 +01:00
|
|
|
}
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2009-10-11 03:03:59 +02:00
|
|
|
static void MONTHCAL_DrawDay(const MONTHCAL_INFO *infoPtr, HDC hdc, const SYSTEMTIME *st,
|
2009-10-13 02:05:31 +02:00
|
|
|
int bold, const PAINTSTRUCT *ps)
|
1999-07-10 14:00:04 +02:00
|
|
|
{
|
2005-04-11 16:21:00 +02:00
|
|
|
static const WCHAR fmtW[] = { '%','d',0 };
|
|
|
|
WCHAR buf[10];
|
2009-10-13 02:05:31 +02:00
|
|
|
RECT r, r_temp;
|
1999-11-21 03:04:09 +01:00
|
|
|
COLORREF oldCol = 0;
|
2009-10-13 20:06:48 +02:00
|
|
|
COLORREF oldBk = 0;
|
2011-03-26 20:11:54 +01:00
|
|
|
INT old_bkmode, selection;
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2011-03-26 20:11:54 +01:00
|
|
|
/* no need to check styles: when selection is not valid, it is set to zero.
|
|
|
|
1 < day < 31, so everything is OK */
|
2011-09-04 17:48:28 +02:00
|
|
|
MONTHCAL_GetDayRect(infoPtr, st, &r, -1);
|
2009-10-13 02:05:31 +02:00
|
|
|
if(!IntersectRect(&r_temp, &(ps->rcPaint), &r)) return;
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2009-10-11 03:03:59 +02:00
|
|
|
if ((MONTHCAL_CompareDate(st, &infoPtr->minSel) >= 0) &&
|
2011-03-26 20:11:54 +01:00
|
|
|
(MONTHCAL_CompareDate(st, &infoPtr->maxSel) <= 0))
|
|
|
|
{
|
2009-10-11 03:03:59 +02:00
|
|
|
TRACE("%d %d %d\n", st->wDay, infoPtr->minSel.wDay, infoPtr->maxSel.wDay);
|
2008-01-25 00:06:37 +01:00
|
|
|
TRACE("%s\n", wine_dbgstr_rect(&r));
|
2010-08-08 14:54:23 +02:00
|
|
|
oldCol = SetTextColor(hdc, infoPtr->colors[MCSC_MONTHBK]);
|
|
|
|
oldBk = SetBkColor(hdc, infoPtr->colors[MCSC_TRAILINGTEXT]);
|
2011-04-02 11:33:48 +02:00
|
|
|
FillRect(hdc, &r, infoPtr->brushes[BrushTitle]);
|
1999-11-21 03:04:09 +01:00
|
|
|
|
2011-03-26 20:11:54 +01:00
|
|
|
selection = 1;
|
1999-11-21 03:04:09 +01:00
|
|
|
}
|
2011-03-26 20:11:54 +01:00
|
|
|
else
|
|
|
|
selection = 0;
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2011-03-26 20:11:54 +01:00
|
|
|
SelectObject(hdc, bold ? infoPtr->hBoldFont : infoPtr->hFont);
|
1999-11-21 03:04:09 +01:00
|
|
|
|
2011-03-26 20:11:54 +01:00
|
|
|
old_bkmode = SetBkMode(hdc, TRANSPARENT);
|
2009-10-13 02:05:31 +02:00
|
|
|
wsprintfW(buf, fmtW, st->wDay);
|
2009-09-08 09:55:22 +02:00
|
|
|
DrawTextW(hdc, buf, -1, &r, DT_CENTER | DT_VCENTER | DT_SINGLELINE );
|
2011-03-26 20:11:54 +01:00
|
|
|
SetBkMode(hdc, old_bkmode);
|
2009-09-08 09:55:22 +02:00
|
|
|
|
2011-03-26 20:11:54 +01:00
|
|
|
if (selection)
|
|
|
|
{
|
1999-11-21 03:04:09 +01:00
|
|
|
SetTextColor(hdc, oldCol);
|
|
|
|
SetBkColor(hdc, oldBk);
|
|
|
|
}
|
1999-07-10 14:00:04 +02:00
|
|
|
}
|
|
|
|
|
2010-08-08 15:24:38 +02:00
|
|
|
static void MONTHCAL_PaintButton(MONTHCAL_INFO *infoPtr, HDC hdc, enum nav_direction button)
|
2005-08-11 19:05:00 +02:00
|
|
|
{
|
|
|
|
HTHEME theme = GetWindowTheme (infoPtr->hwndSelf);
|
2010-08-08 15:24:38 +02:00
|
|
|
RECT *r = button == DIRECTION_FORWARD ? &infoPtr->titlebtnnext : &infoPtr->titlebtnprev;
|
|
|
|
BOOL pressed = button == DIRECTION_FORWARD ? infoPtr->status & MC_NEXTPRESSED :
|
|
|
|
infoPtr->status & MC_PREVPRESSED;
|
2005-08-11 19:05:00 +02:00
|
|
|
if (theme)
|
|
|
|
{
|
|
|
|
static const int states[] = {
|
|
|
|
/* Prev button */
|
|
|
|
ABS_LEFTNORMAL, ABS_LEFTPRESSED, ABS_LEFTDISABLED,
|
|
|
|
/* Next button */
|
|
|
|
ABS_RIGHTNORMAL, ABS_RIGHTPRESSED, ABS_RIGHTDISABLED
|
|
|
|
};
|
2010-08-08 15:24:38 +02:00
|
|
|
int stateNum = button == DIRECTION_FORWARD ? 3 : 0;
|
2005-08-11 19:05:00 +02:00
|
|
|
if (pressed)
|
|
|
|
stateNum += 1;
|
|
|
|
else
|
|
|
|
{
|
2009-09-24 01:23:27 +02:00
|
|
|
if (infoPtr->dwStyle & WS_DISABLED) stateNum += 2;
|
2005-08-11 19:05:00 +02:00
|
|
|
}
|
|
|
|
DrawThemeBackground (theme, hdc, SBP_ARROWBTN, states[stateNum], r, NULL);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-08-08 15:24:38 +02:00
|
|
|
int style = button == DIRECTION_FORWARD ? DFCS_SCROLLRIGHT : DFCS_SCROLLLEFT;
|
2005-08-11 19:05:00 +02:00
|
|
|
if (pressed)
|
|
|
|
style |= DFCS_PUSHED;
|
|
|
|
else
|
|
|
|
{
|
2009-09-24 01:23:27 +02:00
|
|
|
if (infoPtr->dwStyle & WS_DISABLED) style |= DFCS_INACTIVE;
|
2005-08-11 19:05:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
DrawFrameControl(hdc, r, DFC_SCROLL, style);
|
|
|
|
}
|
|
|
|
}
|
2011-09-04 17:48:28 +02:00
|
|
|
|
2009-10-13 02:05:31 +02:00
|
|
|
/* paint a title with buttons and month/year string */
|
2010-07-18 14:13:44 +02:00
|
|
|
static void MONTHCAL_PaintTitle(MONTHCAL_INFO *infoPtr, HDC hdc, const PAINTSTRUCT *ps, INT calIdx)
|
1999-07-10 14:00:04 +02:00
|
|
|
{
|
2015-06-17 10:57:21 +02:00
|
|
|
static const WCHAR mmmmW[] = {'M','M','M','M',0};
|
|
|
|
static const WCHAR mmmW[] = {'M','M','M',0};
|
|
|
|
static const WCHAR mmW[] = {'M','M',0};
|
|
|
|
static const WCHAR fmtyearW[] = {'%','l','d',0};
|
|
|
|
static const WCHAR fmtmmW[] = {'%','0','2','d',0};
|
|
|
|
static const WCHAR fmtmW[] = {'%','d',0};
|
2010-07-18 14:13:44 +02:00
|
|
|
RECT *title = &infoPtr->calendars[calIdx].title;
|
2010-08-02 07:36:12 +02:00
|
|
|
const SYSTEMTIME *st = &infoPtr->calendars[calIdx].month;
|
2015-06-17 10:57:21 +02:00
|
|
|
WCHAR monthW[80], strW[80], fmtW[80], yearW[6] /* valid year range is 1601-30827 */;
|
|
|
|
int yearoffset, monthoffset, shiftX;
|
2009-10-13 02:05:31 +02:00
|
|
|
SIZE sz;
|
1999-11-21 03:04:09 +01:00
|
|
|
|
2009-10-13 02:05:31 +02:00
|
|
|
/* fill header box */
|
2011-04-02 11:33:48 +02:00
|
|
|
FillRect(hdc, title, infoPtr->brushes[BrushTitle]);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2009-10-13 02:05:31 +02:00
|
|
|
/* month/year string */
|
2010-08-08 14:54:23 +02:00
|
|
|
SetBkColor(hdc, infoPtr->colors[MCSC_TITLEBK]);
|
|
|
|
SetTextColor(hdc, infoPtr->colors[MCSC_TITLETEXT]);
|
2009-10-13 02:05:31 +02:00
|
|
|
SelectObject(hdc, infoPtr->hBoldFont);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2015-06-17 10:57:21 +02:00
|
|
|
/* draw formatted date string */
|
2018-02-26 23:29:13 +01:00
|
|
|
GetDateFormatW(LOCALE_USER_DEFAULT, DATE_YEARMONTH, st, NULL, strW, ARRAY_SIZE(strW));
|
2019-05-29 08:44:58 +02:00
|
|
|
DrawTextW(hdc, strW, lstrlenW(strW), title, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
|
2015-06-17 10:57:21 +02:00
|
|
|
|
2018-02-26 23:29:13 +01:00
|
|
|
GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SYEARMONTH, fmtW, ARRAY_SIZE(fmtW));
|
2015-06-17 10:57:21 +02:00
|
|
|
wsprintfW(yearW, fmtyearW, st->wYear);
|
|
|
|
|
|
|
|
/* month is trickier as it's possible to have different format pictures, we'll
|
|
|
|
test for M, MM, MMM, and MMMM */
|
2019-05-29 08:44:58 +02:00
|
|
|
if (wcsstr(fmtW, mmmmW))
|
2018-02-26 23:29:13 +01:00
|
|
|
GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SMONTHNAME1+st->wMonth-1, monthW, ARRAY_SIZE(monthW));
|
2019-05-29 08:44:58 +02:00
|
|
|
else if (wcsstr(fmtW, mmmW))
|
2018-02-26 23:29:13 +01:00
|
|
|
GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SABBREVMONTHNAME1+st->wMonth-1, monthW, ARRAY_SIZE(monthW));
|
2019-05-29 08:44:58 +02:00
|
|
|
else if (wcsstr(fmtW, mmW))
|
2015-06-17 10:57:21 +02:00
|
|
|
wsprintfW(monthW, fmtmmW, st->wMonth);
|
|
|
|
else
|
|
|
|
wsprintfW(monthW, fmtmW, st->wMonth);
|
1999-11-21 03:04:09 +01:00
|
|
|
|
2015-06-17 10:57:21 +02:00
|
|
|
/* update hit boxes */
|
|
|
|
yearoffset = 0;
|
|
|
|
while (strW[yearoffset])
|
|
|
|
{
|
2019-05-29 08:44:58 +02:00
|
|
|
if (!wcsncmp(&strW[yearoffset], yearW, lstrlenW(yearW)))
|
2015-06-17 10:57:21 +02:00
|
|
|
break;
|
|
|
|
yearoffset++;
|
|
|
|
}
|
1999-11-21 03:04:09 +01:00
|
|
|
|
2015-06-17 10:57:21 +02:00
|
|
|
monthoffset = 0;
|
|
|
|
while (strW[monthoffset])
|
|
|
|
{
|
2019-05-29 08:44:58 +02:00
|
|
|
if (!wcsncmp(&strW[monthoffset], monthW, lstrlenW(monthW)))
|
2015-06-17 10:57:21 +02:00
|
|
|
break;
|
|
|
|
monthoffset++;
|
|
|
|
}
|
1999-11-21 03:04:09 +01:00
|
|
|
|
2015-06-17 10:57:21 +02:00
|
|
|
/* for left limits use offsets */
|
|
|
|
sz.cx = 0;
|
|
|
|
if (yearoffset)
|
|
|
|
GetTextExtentPoint32W(hdc, strW, yearoffset, &sz);
|
|
|
|
infoPtr->calendars[calIdx].titleyear.left = sz.cx;
|
|
|
|
|
|
|
|
sz.cx = 0;
|
|
|
|
if (monthoffset)
|
|
|
|
GetTextExtentPoint32W(hdc, strW, monthoffset, &sz);
|
|
|
|
infoPtr->calendars[calIdx].titlemonth.left = sz.cx;
|
|
|
|
|
|
|
|
/* for right limits use actual string parts lengths */
|
2019-05-29 08:44:58 +02:00
|
|
|
GetTextExtentPoint32W(hdc, &strW[yearoffset], lstrlenW(yearW), &sz);
|
2015-06-17 10:57:21 +02:00
|
|
|
infoPtr->calendars[calIdx].titleyear.right = infoPtr->calendars[calIdx].titleyear.left + sz.cx;
|
|
|
|
|
2019-05-29 08:44:58 +02:00
|
|
|
GetTextExtentPoint32W(hdc, monthW, lstrlenW(monthW), &sz);
|
2010-07-18 14:13:44 +02:00
|
|
|
infoPtr->calendars[calIdx].titlemonth.right = infoPtr->calendars[calIdx].titlemonth.left + sz.cx;
|
2015-06-17 10:57:21 +02:00
|
|
|
|
|
|
|
/* Finally translate rectangles to match center aligned string,
|
|
|
|
hit rectangles are relative to title rectangle before translation. */
|
2019-05-29 08:44:58 +02:00
|
|
|
GetTextExtentPoint32W(hdc, strW, lstrlenW(strW), &sz);
|
2015-06-17 10:57:21 +02:00
|
|
|
shiftX = (title->right - title->left - sz.cx) / 2 + title->left;
|
|
|
|
OffsetRect(&infoPtr->calendars[calIdx].titleyear, shiftX, 0);
|
|
|
|
OffsetRect(&infoPtr->calendars[calIdx].titlemonth, shiftX, 0);
|
2009-10-13 02:05:31 +02:00
|
|
|
}
|
|
|
|
|
2010-07-18 14:13:44 +02:00
|
|
|
static void MONTHCAL_PaintWeeknumbers(const MONTHCAL_INFO *infoPtr, HDC hdc, const PAINTSTRUCT *ps, INT calIdx)
|
2009-10-13 02:05:31 +02:00
|
|
|
{
|
2010-08-02 07:36:12 +02:00
|
|
|
const SYSTEMTIME *date = &infoPtr->calendars[calIdx].month;
|
2009-10-13 02:05:31 +02:00
|
|
|
static const WCHAR fmt_weekW[] = { '%','d',0 };
|
|
|
|
INT mindays, weeknum, weeknum1, startofprescal;
|
|
|
|
INT i, prev_month;
|
2010-08-02 07:36:12 +02:00
|
|
|
SYSTEMTIME st;
|
|
|
|
WCHAR buf[80];
|
2011-04-02 11:15:42 +02:00
|
|
|
HPEN old_pen;
|
2010-08-02 07:36:12 +02:00
|
|
|
RECT r;
|
2009-10-13 02:05:31 +02:00
|
|
|
|
|
|
|
if (!(infoPtr->dwStyle & MCS_WEEKNUMBERS)) return;
|
|
|
|
|
|
|
|
MONTHCAL_GetMinDate(infoPtr, &st);
|
|
|
|
startofprescal = st.wDay;
|
2010-08-02 07:36:12 +02:00
|
|
|
st = *date;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2010-08-02 07:36:12 +02:00
|
|
|
prev_month = date->wMonth - 1;
|
2009-10-13 02:05:31 +02:00
|
|
|
if(prev_month == 0) prev_month = 12;
|
|
|
|
|
|
|
|
/*
|
|
|
|
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
|
|
|
|
LOCALE_IFIRSTWEEKOFYEAR == 2 (e.g. Germany):
|
|
|
|
First week of year must contain 4 days of the new year
|
2011-07-30 12:03:08 +02:00
|
|
|
LOCALE_IFIRSTWEEKOFYEAR == 1 (what countries?)
|
2009-10-13 02:05:31 +02:00
|
|
|
The first week of the year must contain only days of the new year
|
|
|
|
*/
|
2018-02-26 23:29:13 +01:00
|
|
|
GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_IFIRSTWEEKOFYEAR, buf, ARRAY_SIZE(buf));
|
2019-05-29 08:44:58 +02:00
|
|
|
weeknum = wcstol(buf, NULL, 10);
|
2009-10-13 02:05:31 +02:00
|
|
|
switch (weeknum)
|
2000-05-30 22:06:33 +02:00
|
|
|
{
|
2009-10-13 02:05:31 +02:00
|
|
|
case 1: mindays = 6;
|
|
|
|
break;
|
|
|
|
case 2: mindays = 3;
|
|
|
|
break;
|
|
|
|
case 0: mindays = 0;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
WARN("Unknown LOCALE_IFIRSTWEEKOFYEAR value %d, defaulting to 0\n", weeknum);
|
|
|
|
mindays = 0;
|
2000-05-30 22:06:33 +02:00
|
|
|
}
|
2009-10-13 21:35:19 +02:00
|
|
|
|
2010-08-02 07:36:12 +02:00
|
|
|
if (date->wMonth == 1)
|
2009-10-13 02:05:31 +02:00
|
|
|
{
|
2011-07-30 12:03:08 +02:00
|
|
|
/* calculate all those exceptions for January */
|
2009-10-13 02:05:31 +02:00
|
|
|
st.wDay = st.wMonth = 1;
|
|
|
|
weeknum1 = MONTHCAL_CalculateDayOfWeek(&st, FALSE);
|
|
|
|
if ((infoPtr->firstDay - weeknum1) % 7 > mindays)
|
|
|
|
weeknum = 1;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
weeknum = 0;
|
|
|
|
for(i = 0; i < 11; i++)
|
2010-08-02 07:36:12 +02:00
|
|
|
weeknum += MONTHCAL_MonthLength(i+1, date->wYear - 1);
|
2000-05-30 22:06:33 +02:00
|
|
|
|
2009-10-13 02:05:31 +02:00
|
|
|
weeknum += startofprescal + 7;
|
|
|
|
weeknum /= 7;
|
|
|
|
st.wYear -= 1;
|
|
|
|
weeknum1 = MONTHCAL_CalculateDayOfWeek(&st, FALSE);
|
|
|
|
if ((infoPtr->firstDay - weeknum1) % 7 > mindays) weeknum++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2000-10-15 02:27:28 +02:00
|
|
|
{
|
2009-10-13 02:05:31 +02:00
|
|
|
weeknum = 0;
|
|
|
|
for(i = 0; i < prev_month - 1; i++)
|
2010-08-02 07:36:12 +02:00
|
|
|
weeknum += MONTHCAL_MonthLength(i+1, date->wYear);
|
2009-10-13 02:05:31 +02:00
|
|
|
|
|
|
|
weeknum += startofprescal + 7;
|
|
|
|
weeknum /= 7;
|
|
|
|
st.wDay = st.wMonth = 1;
|
|
|
|
weeknum1 = MONTHCAL_CalculateDayOfWeek(&st, FALSE);
|
|
|
|
if ((infoPtr->firstDay - weeknum1) % 7 > mindays) weeknum++;
|
2000-10-15 02:27:28 +02:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2010-07-18 14:13:44 +02:00
|
|
|
r = infoPtr->calendars[calIdx].weeknums;
|
2010-08-02 07:48:07 +02:00
|
|
|
|
|
|
|
/* erase whole week numbers area */
|
2011-09-28 14:33:37 +02:00
|
|
|
FillRect(hdc, &r, infoPtr->brushes[BrushMonth]);
|
2011-04-02 09:43:59 +02:00
|
|
|
SetTextColor(hdc, infoPtr->colors[MCSC_TITLEBK]);
|
2010-08-02 07:48:07 +02:00
|
|
|
|
|
|
|
/* reduce rectangle to one week number */
|
2009-10-13 02:05:31 +02:00
|
|
|
r.bottom = r.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);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
wsprintfW(buf, fmt_weekW, weeknum + i);
|
|
|
|
|
|
|
|
DrawTextW(hdc, buf, -1, &r, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
|
|
|
|
OffsetRect(&r, 0, infoPtr->height_increment);
|
|
|
|
}
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2009-10-13 02:05:31 +02:00
|
|
|
/* line separator for week numbers column */
|
2011-04-02 11:15:42 +02:00
|
|
|
old_pen = SelectObject(hdc, infoPtr->pens[PenText]);
|
2010-07-18 14:13:44 +02:00
|
|
|
MoveToEx(hdc, infoPtr->calendars[calIdx].weeknums.right, infoPtr->calendars[calIdx].weeknums.top + 3 , NULL);
|
|
|
|
LineTo(hdc, infoPtr->calendars[calIdx].weeknums.right, infoPtr->calendars[calIdx].weeknums.bottom);
|
2011-04-02 11:15:42 +02:00
|
|
|
SelectObject(hdc, old_pen);
|
2010-07-18 14:13:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* bottom today date */
|
|
|
|
static void MONTHCAL_PaintTodayTitle(const MONTHCAL_INFO *infoPtr, HDC hdc, const PAINTSTRUCT *ps)
|
|
|
|
{
|
2011-04-02 10:40:56 +02:00
|
|
|
static const WCHAR fmt_todayW[] = { '%','s',' ','%','s',0 };
|
|
|
|
WCHAR buf_todayW[30], buf_dateW[20], buf[80];
|
|
|
|
RECT text_rect, box_rect;
|
|
|
|
HFONT old_font;
|
|
|
|
INT col;
|
|
|
|
|
|
|
|
if(infoPtr->dwStyle & MCS_NOTODAY) return;
|
|
|
|
|
2018-02-26 23:29:13 +01:00
|
|
|
LoadStringW(COMCTL32_hModule, IDM_TODAY, buf_todayW, ARRAY_SIZE(buf_todayW));
|
2011-04-02 10:40:56 +02:00
|
|
|
col = infoPtr->dwStyle & MCS_NOTODAYCIRCLE ? 0 : 1;
|
|
|
|
if (infoPtr->dwStyle & MCS_WEEKNUMBERS) col--;
|
2011-09-20 08:45:24 +02:00
|
|
|
/* label is located below first calendar last row */
|
|
|
|
MONTHCAL_GetDayRectI(infoPtr, &text_rect, col, 6, infoPtr->dim.cx * infoPtr->dim.cy - infoPtr->dim.cx);
|
2011-04-02 10:40:56 +02:00
|
|
|
box_rect = text_rect;
|
2010-07-18 14:13:44 +02:00
|
|
|
|
2018-02-26 23:29:13 +01:00
|
|
|
GetDateFormatW(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &infoPtr->todaysDate, NULL, buf_dateW, ARRAY_SIZE(buf_dateW));
|
2011-04-02 10:40:56 +02:00
|
|
|
old_font = SelectObject(hdc, infoPtr->hBoldFont);
|
|
|
|
SetTextColor(hdc, infoPtr->colors[MCSC_TEXT]);
|
2010-07-18 14:13:44 +02:00
|
|
|
|
2011-04-02 10:40:56 +02:00
|
|
|
wsprintfW(buf, fmt_todayW, buf_todayW, buf_dateW);
|
|
|
|
DrawTextW(hdc, buf, -1, &text_rect, DT_CALCRECT | DT_LEFT | DT_VCENTER | DT_SINGLELINE);
|
|
|
|
DrawTextW(hdc, buf, -1, &text_rect, DT_LEFT | DT_VCENTER | DT_SINGLELINE);
|
2010-07-18 14:13:44 +02:00
|
|
|
|
2011-04-02 10:40:56 +02:00
|
|
|
if(!(infoPtr->dwStyle & MCS_NOTODAYCIRCLE)) {
|
|
|
|
OffsetRect(&box_rect, -infoPtr->width_increment, 0);
|
|
|
|
MONTHCAL_Circle(infoPtr, hdc, &box_rect);
|
2010-07-18 14:13:44 +02:00
|
|
|
}
|
2011-04-02 10:40:56 +02:00
|
|
|
|
|
|
|
SelectObject(hdc, old_font);
|
2010-07-18 14:13:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* today mark + focus */
|
|
|
|
static void MONTHCAL_PaintFocusAndCircle(const MONTHCAL_INFO *infoPtr, HDC hdc, const PAINTSTRUCT *ps)
|
|
|
|
{
|
2011-09-20 09:35:54 +02:00
|
|
|
/* circle today date if only it's in fully visible month */
|
|
|
|
if (!(infoPtr->dwStyle & MCS_NOTODAYCIRCLE))
|
2010-07-18 14:13:44 +02:00
|
|
|
{
|
2011-09-20 09:35:54 +02:00
|
|
|
INT i;
|
|
|
|
|
|
|
|
for (i = 0; i < MONTHCAL_GetCalCount(infoPtr); i++)
|
|
|
|
if (!MONTHCAL_CompareMonths(&infoPtr->todaysDate, &infoPtr->calendars[i].month))
|
|
|
|
{
|
|
|
|
MONTHCAL_CircleDay(infoPtr, hdc, &infoPtr->todaysDate);
|
|
|
|
break;
|
|
|
|
}
|
2010-07-18 14:13:44 +02:00
|
|
|
}
|
|
|
|
|
2011-09-20 09:35:54 +02:00
|
|
|
if (!MONTHCAL_IsDateEqual(&infoPtr->focusedSel, &st_null))
|
2010-07-18 14:13:44 +02:00
|
|
|
{
|
|
|
|
RECT r;
|
2011-09-04 17:48:28 +02:00
|
|
|
MONTHCAL_GetDayRect(infoPtr, &infoPtr->focusedSel, &r, -1);
|
2010-07-18 14:13:44 +02:00
|
|
|
DrawFocusRect(hdc, &r);
|
|
|
|
}
|
2009-10-13 02:05:31 +02:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2011-03-26 00:23:01 +01:00
|
|
|
/* months before first calendar month and after last calendar month */
|
|
|
|
static void MONTHCAL_PaintLeadTrailMonths(const MONTHCAL_INFO *infoPtr, HDC hdc, const PAINTSTRUCT *ps)
|
|
|
|
{
|
2012-12-28 23:05:31 +01:00
|
|
|
INT mask, index;
|
|
|
|
UINT length;
|
2011-03-26 00:23:01 +01:00
|
|
|
SYSTEMTIME st_max, st;
|
|
|
|
|
|
|
|
if (infoPtr->dwStyle & MCS_NOTRAILINGDATES) return;
|
|
|
|
|
|
|
|
SetTextColor(hdc, infoPtr->colors[MCSC_TRAILINGTEXT]);
|
|
|
|
|
|
|
|
/* draw prev month */
|
|
|
|
MONTHCAL_GetMinDate(infoPtr, &st);
|
|
|
|
mask = 1 << (st.wDay-1);
|
|
|
|
/* December and January both 31 days long, so no worries if wrapped */
|
|
|
|
length = MONTHCAL_MonthLength(infoPtr->calendars[0].month.wMonth - 1,
|
|
|
|
infoPtr->calendars[0].month.wYear);
|
2011-09-23 10:25:35 +02:00
|
|
|
index = 0;
|
2011-03-26 00:23:01 +01:00
|
|
|
while(st.wDay <= length)
|
|
|
|
{
|
2011-09-23 10:25:35 +02:00
|
|
|
MONTHCAL_DrawDay(infoPtr, hdc, &st, infoPtr->monthdayState[index] & mask, ps);
|
2011-03-26 00:23:01 +01:00
|
|
|
mask <<= 1;
|
|
|
|
st.wDay++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* draw next month */
|
2011-09-13 19:45:07 +02:00
|
|
|
st = infoPtr->calendars[MONTHCAL_GetCalCount(infoPtr)-1].month;
|
2011-03-26 00:23:01 +01:00
|
|
|
st.wDay = 1;
|
|
|
|
MONTHCAL_GetNextMonth(&st);
|
|
|
|
MONTHCAL_GetMaxDate(infoPtr, &st_max);
|
|
|
|
mask = 1;
|
2011-09-23 10:25:35 +02:00
|
|
|
index = MONTHCAL_GetMonthRange(infoPtr, GMR_DAYSTATE, 0)-1;
|
2011-03-26 00:23:01 +01:00
|
|
|
while(st.wDay <= st_max.wDay)
|
|
|
|
{
|
2011-09-23 10:25:35 +02:00
|
|
|
MONTHCAL_DrawDay(infoPtr, hdc, &st, infoPtr->monthdayState[index] & mask, ps);
|
2011-03-26 00:23:01 +01:00
|
|
|
mask <<= 1;
|
|
|
|
st.wDay++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-17 20:21:07 +02:00
|
|
|
static int get_localized_dayname(const MONTHCAL_INFO *infoPtr, unsigned int day, WCHAR *buff, unsigned int count)
|
|
|
|
{
|
|
|
|
LCTYPE lctype;
|
|
|
|
|
|
|
|
if (infoPtr->dwStyle & MCS_SHORTDAYSOFWEEK)
|
|
|
|
lctype = LOCALE_SSHORTESTDAYNAME1 + day;
|
|
|
|
else
|
|
|
|
lctype = LOCALE_SABBREVDAYNAME1 + day;
|
|
|
|
|
|
|
|
return GetLocaleInfoW(LOCALE_USER_DEFAULT, lctype, buff, count);
|
|
|
|
}
|
|
|
|
|
2009-10-13 02:05:31 +02:00
|
|
|
/* paint a calendar area */
|
2010-07-18 14:13:44 +02:00
|
|
|
static void MONTHCAL_PaintCalendar(const MONTHCAL_INFO *infoPtr, HDC hdc, const PAINTSTRUCT *ps, INT calIdx)
|
2009-10-13 02:05:31 +02:00
|
|
|
{
|
2010-08-02 07:36:12 +02:00
|
|
|
const SYSTEMTIME *date = &infoPtr->calendars[calIdx].month;
|
2012-12-28 23:05:31 +01:00
|
|
|
INT i, j;
|
|
|
|
UINT length;
|
2010-08-02 07:36:12 +02:00
|
|
|
RECT r, fill_bk_rect;
|
|
|
|
SYSTEMTIME st;
|
2009-10-13 02:05:31 +02:00
|
|
|
WCHAR buf[80];
|
2011-04-02 11:15:42 +02:00
|
|
|
HPEN old_pen;
|
2009-10-13 02:05:31 +02:00
|
|
|
int mask;
|
2000-10-15 02:27:28 +02:00
|
|
|
|
2010-07-18 14:13:44 +02:00
|
|
|
/* fill whole days area - from week days area to today note rectangle */
|
|
|
|
fill_bk_rect = infoPtr->calendars[calIdx].wdays;
|
|
|
|
fill_bk_rect.bottom = infoPtr->calendars[calIdx].days.bottom +
|
|
|
|
(infoPtr->todayrect.bottom - infoPtr->todayrect.top);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2011-04-02 11:33:48 +02:00
|
|
|
FillRect(hdc, &fill_bk_rect, infoPtr->brushes[BrushMonth]);
|
2009-10-13 02:05:31 +02:00
|
|
|
|
|
|
|
/* draw line under day abbreviations */
|
2011-04-02 11:15:42 +02:00
|
|
|
old_pen = SelectObject(hdc, infoPtr->pens[PenText]);
|
2010-07-18 14:13:44 +02:00
|
|
|
MoveToEx(hdc, infoPtr->calendars[calIdx].days.left + 3,
|
|
|
|
infoPtr->calendars[calIdx].title.bottom + infoPtr->textHeight + 1, NULL);
|
|
|
|
LineTo(hdc, infoPtr->calendars[calIdx].days.right - 3,
|
|
|
|
infoPtr->calendars[calIdx].title.bottom + infoPtr->textHeight + 1);
|
2011-04-02 11:15:42 +02:00
|
|
|
SelectObject(hdc, old_pen);
|
2009-10-13 02:05:31 +02:00
|
|
|
|
2010-07-18 14:13:44 +02:00
|
|
|
infoPtr->calendars[calIdx].wdays.left = infoPtr->calendars[calIdx].days.left =
|
|
|
|
infoPtr->calendars[calIdx].weeknums.right;
|
2009-10-13 02:05:31 +02:00
|
|
|
|
2011-03-26 00:23:01 +01:00
|
|
|
/* draw day abbreviations */
|
2005-04-20 14:51:37 +02:00
|
|
|
SelectObject(hdc, infoPtr->hFont);
|
2010-08-08 14:54:23 +02:00
|
|
|
SetBkColor(hdc, infoPtr->colors[MCSC_MONTHBK]);
|
2011-03-26 14:49:21 +01:00
|
|
|
SetTextColor(hdc, infoPtr->colors[MCSC_TITLEBK]);
|
2009-10-07 20:13:07 +02:00
|
|
|
/* rectangle to draw a single day abbreviation within */
|
2010-07-18 14:13:44 +02:00
|
|
|
r = infoPtr->calendars[calIdx].wdays;
|
2009-10-13 02:05:31 +02:00
|
|
|
r.right = r.left + infoPtr->width_increment;
|
2000-01-04 01:30:21 +01:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
i = infoPtr->firstDay;
|
2009-10-07 20:13:07 +02:00
|
|
|
for(j = 0; j < 7; j++) {
|
2018-02-26 23:29:13 +01:00
|
|
|
get_localized_dayname(infoPtr, (i + j + 6) % 7, buf, ARRAY_SIZE(buf));
|
2019-05-29 08:44:58 +02:00
|
|
|
DrawTextW(hdc, buf, lstrlenW(buf), &r, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
|
2009-10-13 02:05:31 +02:00
|
|
|
OffsetRect(&r, infoPtr->width_increment, 0);
|
1999-11-21 03:04:09 +01:00
|
|
|
}
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2011-03-26 00:23:01 +01:00
|
|
|
/* draw current month */
|
2010-08-08 14:54:23 +02:00
|
|
|
SetTextColor(hdc, infoPtr->colors[MCSC_TEXT]);
|
2010-08-02 07:36:12 +02:00
|
|
|
st = *date;
|
2009-10-11 03:03:59 +02:00
|
|
|
st.wDay = 1;
|
1999-11-21 03:04:09 +01:00
|
|
|
mask = 1;
|
2010-08-02 07:42:36 +02:00
|
|
|
length = MONTHCAL_MonthLength(date->wMonth, date->wYear);
|
|
|
|
while(st.wDay <= length)
|
2010-08-02 07:36:12 +02:00
|
|
|
{
|
2011-09-23 10:25:35 +02:00
|
|
|
MONTHCAL_DrawDay(infoPtr, hdc, &st, infoPtr->monthdayState[calIdx+1] & mask, ps);
|
2009-10-13 02:05:31 +02:00
|
|
|
mask <<= 1;
|
2009-10-11 03:03:59 +02:00
|
|
|
st.wDay++;
|
1999-11-21 03:04:09 +01:00
|
|
|
}
|
2009-10-13 02:05:31 +02:00
|
|
|
}
|
2009-10-07 20:13:07 +02:00
|
|
|
|
2009-10-13 02:05:31 +02:00
|
|
|
static void MONTHCAL_Refresh(MONTHCAL_INFO *infoPtr, HDC hdc, const PAINTSTRUCT *ps)
|
|
|
|
{
|
|
|
|
COLORREF old_text_clr, old_bk_clr;
|
|
|
|
HFONT old_font;
|
2010-07-18 14:13:44 +02:00
|
|
|
INT i;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2009-10-13 02:05:31 +02:00
|
|
|
old_text_clr = SetTextColor(hdc, comctl32_color.clrWindowText);
|
|
|
|
old_bk_clr = GetBkColor(hdc);
|
|
|
|
old_font = GetCurrentObject(hdc, OBJ_FONT);
|
|
|
|
|
2011-09-13 19:45:07 +02:00
|
|
|
for (i = 0; i < MONTHCAL_GetCalCount(infoPtr); i++)
|
2010-07-18 14:13:44 +02:00
|
|
|
{
|
|
|
|
RECT *title = &infoPtr->calendars[i].title;
|
|
|
|
RECT r;
|
|
|
|
|
|
|
|
/* draw title, redraw all its elements */
|
|
|
|
if (IntersectRect(&r, &(ps->rcPaint), title))
|
|
|
|
MONTHCAL_PaintTitle(infoPtr, hdc, ps, i);
|
2009-10-13 02:05:31 +02:00
|
|
|
|
2010-07-18 14:13:44 +02:00
|
|
|
/* draw calendar area */
|
|
|
|
UnionRect(&r, &infoPtr->calendars[i].wdays, &infoPtr->todayrect);
|
|
|
|
if (IntersectRect(&r, &(ps->rcPaint), &r))
|
|
|
|
MONTHCAL_PaintCalendar(infoPtr, hdc, ps, i);
|
2009-10-13 02:05:31 +02:00
|
|
|
|
2010-07-18 14:13:44 +02:00
|
|
|
/* week numbers */
|
|
|
|
MONTHCAL_PaintWeeknumbers(infoPtr, hdc, ps, i);
|
|
|
|
}
|
|
|
|
|
2011-03-26 00:23:01 +01:00
|
|
|
/* partially visible months */
|
|
|
|
MONTHCAL_PaintLeadTrailMonths(infoPtr, hdc, ps);
|
|
|
|
|
2010-07-18 14:13:44 +02:00
|
|
|
/* focus and today rectangle */
|
|
|
|
MONTHCAL_PaintFocusAndCircle(infoPtr, hdc, ps);
|
|
|
|
|
|
|
|
/* today at the bottom left */
|
|
|
|
MONTHCAL_PaintTodayTitle(infoPtr, hdc, ps);
|
|
|
|
|
|
|
|
/* navigation buttons */
|
2010-08-08 15:24:38 +02:00
|
|
|
MONTHCAL_PaintButton(infoPtr, hdc, DIRECTION_BACKWARD);
|
|
|
|
MONTHCAL_PaintButton(infoPtr, hdc, DIRECTION_FORWARD);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2009-10-13 02:05:31 +02:00
|
|
|
/* restore context */
|
|
|
|
SetBkColor(hdc, old_bk_clr);
|
|
|
|
SelectObject(hdc, old_font);
|
|
|
|
SetTextColor(hdc, old_text_clr);
|
1999-07-10 14:00:04 +02:00
|
|
|
}
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
static LRESULT
|
2010-08-08 13:58:13 +02:00
|
|
|
MONTHCAL_GetMinReqRect(const MONTHCAL_INFO *infoPtr, RECT *rect)
|
1999-07-10 14:00:04 +02:00
|
|
|
{
|
2010-08-08 13:58:13 +02:00
|
|
|
TRACE("rect %p\n", rect);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2010-08-08 13:58:13 +02:00
|
|
|
if(!rect) return FALSE;
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2010-08-08 13:58:13 +02:00
|
|
|
*rect = infoPtr->calendars[0].title;
|
|
|
|
rect->bottom = infoPtr->calendars[0].days.bottom + infoPtr->todayrect.bottom -
|
|
|
|
infoPtr->todayrect.top;
|
2009-09-28 22:12:39 +02:00
|
|
|
|
2010-08-08 13:58:13 +02:00
|
|
|
AdjustWindowRect(rect, infoPtr->dwStyle, FALSE);
|
2004-11-08 21:27:02 +01:00
|
|
|
|
2009-09-28 22:12:39 +02:00
|
|
|
/* minimal rectangle is zero based */
|
2010-08-08 13:58:13 +02:00
|
|
|
OffsetRect(rect, -rect->left, -rect->top);
|
2009-09-28 22:12:39 +02:00
|
|
|
|
2010-08-08 13:58:13 +02:00
|
|
|
TRACE("%s\n", wine_dbgstr_rect(rect));
|
2004-11-08 21:27:02 +01:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
return TRUE;
|
1999-07-10 14:00:04 +02:00
|
|
|
}
|
|
|
|
|
2010-08-08 14:54:23 +02:00
|
|
|
static COLORREF
|
|
|
|
MONTHCAL_GetColor(const MONTHCAL_INFO *infoPtr, UINT index)
|
1999-07-10 14:00:04 +02:00
|
|
|
{
|
2010-08-08 14:54:23 +02:00
|
|
|
TRACE("%p, %d\n", infoPtr, index);
|
1999-11-21 03:04:09 +01:00
|
|
|
|
2010-08-08 14:54:23 +02:00
|
|
|
if (index > MCSC_TRAILINGTEXT) return -1;
|
|
|
|
return infoPtr->colors[index];
|
1999-07-10 14:00:04 +02:00
|
|
|
}
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
static LRESULT
|
2010-08-08 14:54:23 +02:00
|
|
|
MONTHCAL_SetColor(MONTHCAL_INFO *infoPtr, UINT index, COLORREF color)
|
|
|
|
{
|
2011-04-02 11:33:48 +02:00
|
|
|
enum CachedBrush type;
|
2010-08-08 14:54:23 +02:00
|
|
|
COLORREF prev;
|
|
|
|
|
|
|
|
TRACE("%p, %d: color %08x\n", infoPtr, index, color);
|
|
|
|
|
|
|
|
if (index > MCSC_TRAILINGTEXT) return -1;
|
|
|
|
|
|
|
|
prev = infoPtr->colors[index];
|
|
|
|
infoPtr->colors[index] = color;
|
1999-11-21 03:04:09 +01:00
|
|
|
|
2011-03-26 13:58:59 +01:00
|
|
|
/* update cached brush */
|
2011-04-02 11:33:48 +02:00
|
|
|
switch (index)
|
|
|
|
{
|
|
|
|
case MCSC_BACKGROUND:
|
|
|
|
type = BrushBackground;
|
|
|
|
break;
|
|
|
|
case MCSC_TITLEBK:
|
|
|
|
type = BrushTitle;
|
|
|
|
break;
|
|
|
|
case MCSC_MONTHBK:
|
|
|
|
type = BrushMonth;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
type = BrushLast;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (type != BrushLast)
|
2011-03-26 13:58:59 +01:00
|
|
|
{
|
2011-04-02 11:33:48 +02:00
|
|
|
DeleteObject(infoPtr->brushes[type]);
|
|
|
|
infoPtr->brushes[type] = CreateSolidBrush(color);
|
2011-03-26 13:58:59 +01:00
|
|
|
}
|
|
|
|
|
2011-04-02 11:15:42 +02:00
|
|
|
/* update cached pen */
|
|
|
|
if (index == MCSC_TEXT)
|
|
|
|
{
|
|
|
|
DeleteObject(infoPtr->pens[PenText]);
|
|
|
|
infoPtr->pens[PenText] = CreatePen(PS_SOLID, 1, infoPtr->colors[index]);
|
|
|
|
}
|
|
|
|
|
2012-08-08 21:00:22 +02:00
|
|
|
InvalidateRect(infoPtr->hwndSelf, NULL, index == MCSC_BACKGROUND);
|
1999-11-21 03:04:09 +01:00
|
|
|
return prev;
|
1999-07-10 14:00:04 +02:00
|
|
|
}
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
static LRESULT
|
2007-03-29 23:09:32 +02:00
|
|
|
MONTHCAL_GetMonthDelta(const MONTHCAL_INFO *infoPtr)
|
1999-07-10 14:00:04 +02:00
|
|
|
{
|
2004-11-30 18:35:16 +01:00
|
|
|
TRACE("\n");
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
if(infoPtr->delta)
|
1999-11-21 03:04:09 +01:00
|
|
|
return infoPtr->delta;
|
2013-08-29 21:57:48 +02:00
|
|
|
|
|
|
|
return MONTHCAL_GetMonthRange(infoPtr, GMR_VISIBLE, NULL);
|
1999-07-10 14:00:04 +02:00
|
|
|
}
|
|
|
|
|
2000-05-30 22:06:33 +02:00
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
static LRESULT
|
2009-09-25 01:43:38 +02:00
|
|
|
MONTHCAL_SetMonthDelta(MONTHCAL_INFO *infoPtr, INT delta)
|
1999-07-10 14:00:04 +02:00
|
|
|
{
|
2009-09-25 01:43:38 +02:00
|
|
|
INT prev = infoPtr->delta;
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2009-09-25 01:43:38 +02:00
|
|
|
TRACE("delta %d\n", delta);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2009-09-25 01:43:38 +02:00
|
|
|
infoPtr->delta = delta;
|
1999-11-21 03:04:09 +01:00
|
|
|
return prev;
|
1999-07-10 14:00:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-10-07 22:45:05 +02:00
|
|
|
static inline LRESULT
|
2007-03-29 23:09:32 +02:00
|
|
|
MONTHCAL_GetFirstDayOfWeek(const MONTHCAL_INFO *infoPtr)
|
1999-07-10 14:00:04 +02:00
|
|
|
{
|
2009-10-07 22:45:05 +02: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 14:00:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-10-07 20:13:07 +02: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
|
2011-07-30 12:03:08 +02:00
|
|
|
* locale defined (TRUE - was forced, FALSE - wasn't).
|
2009-10-07 20:13:07 +02:00
|
|
|
*
|
|
|
|
* FIXME: this needs to be implemented properly in MONTHCAL_Refresh()
|
|
|
|
* FIXME: we need more error checking here
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
static LRESULT
|
2009-09-24 01:02:31 +02:00
|
|
|
MONTHCAL_SetFirstDayOfWeek(MONTHCAL_INFO *infoPtr, INT day)
|
1999-07-10 14:00:04 +02:00
|
|
|
{
|
2009-10-07 22:45:05 +02:00
|
|
|
LRESULT prev = MONTHCAL_GetFirstDayOfWeek(infoPtr);
|
|
|
|
int new_day;
|
1999-11-21 03:04:09 +01:00
|
|
|
|
2009-10-07 22:45:05 +02:00
|
|
|
TRACE("%d\n", day);
|
1999-11-21 03:04:09 +01:00
|
|
|
|
2009-09-24 01:02:31 +02:00
|
|
|
if(day == -1)
|
2007-04-10 03:25:41 +02:00
|
|
|
{
|
2009-10-01 19:52:16 +02:00
|
|
|
WCHAR buf[80];
|
|
|
|
|
2018-02-26 23:29:13 +01:00
|
|
|
GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_IFIRSTDAYOFWEEK, buf, ARRAY_SIZE(buf));
|
2019-05-29 08:44:58 +02:00
|
|
|
TRACE("%s %d\n", debugstr_w(buf), lstrlenW(buf));
|
2009-10-01 19:52:16 +02:00
|
|
|
|
2019-05-29 08:44:58 +02:00
|
|
|
new_day = wcstol(buf, NULL, 10);
|
2009-10-01 19:52:16 +02:00
|
|
|
|
2009-10-07 22:45:05 +02:00
|
|
|
infoPtr->firstDaySet = FALSE;
|
2007-04-10 03:25:41 +02:00
|
|
|
}
|
2009-09-24 01:02:31 +02:00
|
|
|
else if(day >= 7)
|
2007-04-10 03:25:41 +02:00
|
|
|
{
|
2009-10-07 22:45:05 +02:00
|
|
|
new_day = 6; /* max first day allowed */
|
|
|
|
infoPtr->firstDaySet = TRUE;
|
2007-04-10 03:25:41 +02:00
|
|
|
}
|
2000-10-15 02:27:28 +02:00
|
|
|
else
|
2007-04-10 03:25:41 +02:00
|
|
|
{
|
2009-10-07 22:45:05 +02:00
|
|
|
/* Native behaviour for that case is broken: invalid date number >31
|
|
|
|
got displayed at (0,0) position, current month starts always from
|
2010-07-18 14:42:08 +02:00
|
|
|
(1,0) position. Should be implemented here as well only if there's
|
|
|
|
nothing else to do. */
|
2009-10-07 22:45:05 +02:00
|
|
|
if (day < -1)
|
|
|
|
FIXME("No bug compatibility for day=%d\n", day);
|
|
|
|
|
|
|
|
new_day = day;
|
|
|
|
infoPtr->firstDaySet = TRUE;
|
2007-04-10 03:25:41 +02:00
|
|
|
}
|
2007-03-16 08:34:36 +01:00
|
|
|
|
2009-10-07 22:45:05 +02:00
|
|
|
/* convert from locale to SYSTEMTIME format */
|
|
|
|
infoPtr->firstDay = (new_day >= 0) ? (++new_day) % 7 : new_day;
|
|
|
|
|
2009-10-07 02:25:45 +02:00
|
|
|
InvalidateRect(infoPtr->hwndSelf, NULL, FALSE);
|
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
return prev;
|
1999-07-10 14:00:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static LRESULT
|
2007-03-29 23:09:32 +02:00
|
|
|
MONTHCAL_GetMaxTodayWidth(const MONTHCAL_INFO *infoPtr)
|
1999-07-10 14:00:04 +02:00
|
|
|
{
|
2000-10-15 02:27:28 +02:00
|
|
|
return(infoPtr->todayrect.right - infoPtr->todayrect.left);
|
1999-07-10 14:00:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static LRESULT
|
2009-09-24 01:02:31 +02:00
|
|
|
MONTHCAL_SetRange(MONTHCAL_INFO *infoPtr, SHORT limits, SYSTEMTIME *range)
|
1999-07-10 14:00:04 +02:00
|
|
|
{
|
2006-02-16 12:19:36 +01:00
|
|
|
FILETIME ft_min, ft_max;
|
2006-02-14 17:12:45 +01:00
|
|
|
|
2009-09-24 01:02:31 +02:00
|
|
|
TRACE("%x %p\n", limits, range);
|
2006-02-14 17:12:45 +01:00
|
|
|
|
2009-09-26 18:06:48 +02:00
|
|
|
if ((limits & GDTR_MIN && !MONTHCAL_ValidateDate(&range[0])) ||
|
|
|
|
(limits & GDTR_MAX && !MONTHCAL_ValidateDate(&range[1])))
|
2006-02-14 17:12:45 +01:00
|
|
|
return FALSE;
|
|
|
|
|
2016-03-14 18:19:25 +01:00
|
|
|
infoPtr->rangeValid = 0;
|
|
|
|
infoPtr->minDate = infoPtr->maxDate = st_null;
|
|
|
|
|
2009-09-24 01:02:31 +02:00
|
|
|
if (limits & GDTR_MIN)
|
2006-02-14 17:12:45 +01:00
|
|
|
{
|
2009-09-26 18:06:48 +02:00
|
|
|
if (!MONTHCAL_ValidateTime(&range[0]))
|
|
|
|
MONTHCAL_CopyTime(&infoPtr->todaysDate, &range[0]);
|
|
|
|
|
2009-09-25 21:41:08 +02:00
|
|
|
infoPtr->minDate = range[0];
|
2006-02-14 17:12:45 +01:00
|
|
|
infoPtr->rangeValid |= GDTR_MIN;
|
1999-11-21 03:04:09 +01:00
|
|
|
}
|
2009-09-24 01:02:31 +02:00
|
|
|
if (limits & GDTR_MAX)
|
2006-02-14 17:12:45 +01:00
|
|
|
{
|
2009-09-26 18:06:48 +02:00
|
|
|
if (!MONTHCAL_ValidateTime(&range[1]))
|
|
|
|
MONTHCAL_CopyTime(&infoPtr->todaysDate, &range[1]);
|
|
|
|
|
2009-09-25 21:41:08 +02:00
|
|
|
infoPtr->maxDate = range[1];
|
2006-02-14 17:12:45 +01:00
|
|
|
infoPtr->rangeValid |= GDTR_MAX;
|
1999-11-21 03:04:09 +01:00
|
|
|
}
|
|
|
|
|
2006-02-16 12:19:36 +01:00
|
|
|
/* Only one limit set - we are done */
|
|
|
|
if ((infoPtr->rangeValid & (GDTR_MIN | GDTR_MAX)) != (GDTR_MIN | GDTR_MAX))
|
|
|
|
return TRUE;
|
2009-09-26 01:09:06 +02:00
|
|
|
|
2006-02-16 12:19:36 +01:00
|
|
|
SystemTimeToFileTime(&infoPtr->maxDate, &ft_max);
|
|
|
|
SystemTimeToFileTime(&infoPtr->minDate, &ft_min);
|
|
|
|
|
2009-09-26 01:09:06 +02:00
|
|
|
if (CompareFileTime(&ft_min, &ft_max) >= 0)
|
2006-02-16 12:19:36 +01:00
|
|
|
{
|
2009-09-24 01:02:31 +02:00
|
|
|
if ((limits & (GDTR_MIN | GDTR_MAX)) == (GDTR_MIN | GDTR_MAX))
|
2006-02-16 12:19:36 +01: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-26 01:09:06 +02:00
|
|
|
/* reset the other limit */
|
2009-10-05 20:37:04 +02: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 12:19:36 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-02-16 12:19:09 +01:00
|
|
|
return TRUE;
|
1999-07-10 14:00:04 +02:00
|
|
|
}
|
|
|
|
|
1998-11-08 12:30:27 +01:00
|
|
|
|
1999-07-10 14:00:04 +02:00
|
|
|
static LRESULT
|
2009-09-24 01:02:31 +02:00
|
|
|
MONTHCAL_GetRange(const MONTHCAL_INFO *infoPtr, SYSTEMTIME *range)
|
1999-07-10 14:00:04 +02:00
|
|
|
{
|
2009-09-24 01:02:31 +02:00
|
|
|
TRACE("%p\n", range);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2016-03-14 10:59:17 +01:00
|
|
|
if (!range) return 0;
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2009-09-25 21:41:08 +02:00
|
|
|
range[1] = infoPtr->maxDate;
|
|
|
|
range[0] = infoPtr->minDate;
|
1999-07-10 14:00:04 +02:00
|
|
|
|
|
|
|
return infoPtr->rangeValid;
|
|
|
|
}
|
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
|
1999-07-10 14:00:04 +02:00
|
|
|
static LRESULT
|
2009-09-24 01:02:31 +02:00
|
|
|
MONTHCAL_SetDayState(const MONTHCAL_INFO *infoPtr, INT months, MONTHDAYSTATE *states)
|
1999-07-10 14:00:04 +02:00
|
|
|
{
|
2010-07-19 19:54:40 +02:00
|
|
|
TRACE("%p %d %p\n", infoPtr, months, states);
|
2011-09-23 10:25:35 +02:00
|
|
|
|
|
|
|
if (!(infoPtr->dwStyle & MCS_DAYSTATE)) return 0;
|
|
|
|
if (months != MONTHCAL_GetMonthRange(infoPtr, GMR_DAYSTATE, 0)) return 0;
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2010-07-19 19:54:40 +02:00
|
|
|
memcpy(infoPtr->monthdayState, states, months*sizeof(MONTHDAYSTATE));
|
1999-07-10 14:00:04 +02:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
static LRESULT
|
2009-09-24 01:02:31 +02:00
|
|
|
MONTHCAL_GetCurSel(const MONTHCAL_INFO *infoPtr, SYSTEMTIME *curSel)
|
1999-07-10 14:00:04 +02:00
|
|
|
{
|
2009-09-24 01:02:31 +02:00
|
|
|
TRACE("%p\n", curSel);
|
|
|
|
if(!curSel) return FALSE;
|
2009-09-08 08:44:55 +02:00
|
|
|
if(infoPtr->dwStyle & MCS_MULTISELECT) return FALSE;
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2010-08-02 07:36:12 +02:00
|
|
|
*curSel = infoPtr->minSel;
|
2009-09-24 01:02:31 +02:00
|
|
|
TRACE("%d/%d/%d\n", curSel->wYear, curSel->wMonth, curSel->wDay);
|
1999-07-10 14:00:04 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
static LRESULT
|
2009-10-10 22:28:51 +02:00
|
|
|
MONTHCAL_SetCurSel(MONTHCAL_INFO *infoPtr, SYSTEMTIME *curSel)
|
1999-07-10 14:00:04 +02:00
|
|
|
{
|
2011-09-23 12:17:14 +02:00
|
|
|
SYSTEMTIME prev = infoPtr->minSel, selection;
|
2011-09-19 08:44:22 +02:00
|
|
|
INT diff;
|
2010-08-02 07:36:12 +02:00
|
|
|
WORD day;
|
2009-10-13 21:35:19 +02:00
|
|
|
|
2009-09-24 01:02:31 +02:00
|
|
|
TRACE("%p\n", curSel);
|
|
|
|
if(!curSel) return FALSE;
|
2009-09-08 08:44:55 +02:00
|
|
|
if(infoPtr->dwStyle & MCS_MULTISELECT) return FALSE;
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2009-09-26 18:06:48 +02:00
|
|
|
if(!MONTHCAL_ValidateDate(curSel)) return FALSE;
|
2009-10-05 21:05:53 +02:00
|
|
|
/* exit earlier if selection equals current */
|
2010-08-02 07:36:12 +02:00
|
|
|
if (MONTHCAL_IsDateEqual(&infoPtr->minSel, curSel)) return TRUE;
|
2009-10-05 21:05:53 +02:00
|
|
|
|
2011-09-23 12:53:47 +02:00
|
|
|
selection = *curSel;
|
|
|
|
selection.wHour = selection.wMinute = selection.wSecond = selection.wMilliseconds = 0;
|
|
|
|
MONTHCAL_CalculateDayOfWeek(&selection, TRUE);
|
|
|
|
|
|
|
|
if(!MONTHCAL_IsDateInValidRange(infoPtr, &selection, FALSE)) return FALSE;
|
2007-03-09 05:48:48 +01:00
|
|
|
|
2011-09-19 08:44:22 +02:00
|
|
|
/* scroll calendars only if we have to */
|
|
|
|
diff = MONTHCAL_MonthDiff(&infoPtr->calendars[MONTHCAL_GetCalCount(infoPtr)-1].month, curSel);
|
|
|
|
if (diff <= 0)
|
|
|
|
{
|
|
|
|
diff = MONTHCAL_MonthDiff(&infoPtr->calendars[0].month, curSel);
|
|
|
|
if (diff > 0) diff = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (diff != 0)
|
|
|
|
{
|
|
|
|
INT i;
|
|
|
|
|
|
|
|
for (i = 0; i < MONTHCAL_GetCalCount(infoPtr); i++)
|
|
|
|
MONTHCAL_GetMonth(&infoPtr->calendars[i].month, diff);
|
|
|
|
}
|
|
|
|
|
2011-09-23 12:53:47 +02:00
|
|
|
/* we need to store time part as it is */
|
2011-09-23 12:17:14 +02:00
|
|
|
selection = *curSel;
|
|
|
|
MONTHCAL_CalculateDayOfWeek(&selection, TRUE);
|
|
|
|
infoPtr->minSel = infoPtr->maxSel = selection;
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2009-10-13 21:35:19 +02:00
|
|
|
/* if selection is still in current month, reduce rectangle */
|
2010-08-02 07:36:12 +02:00
|
|
|
day = prev.wDay;
|
2009-10-13 21:35:19 +02:00
|
|
|
prev.wDay = curSel->wDay;
|
|
|
|
if (MONTHCAL_IsDateEqual(&prev, curSel))
|
|
|
|
{
|
|
|
|
RECT r_prev, r_new;
|
2009-09-25 01:13:38 +02:00
|
|
|
|
2010-08-02 07:36:12 +02:00
|
|
|
prev.wDay = day;
|
2011-09-04 17:48:28 +02:00
|
|
|
MONTHCAL_GetDayRect(infoPtr, &prev, &r_prev, -1);
|
|
|
|
MONTHCAL_GetDayRect(infoPtr, curSel, &r_new, -1);
|
2009-10-13 21:35:19 +02:00
|
|
|
|
|
|
|
InvalidateRect(infoPtr->hwndSelf, &r_prev, FALSE);
|
|
|
|
InvalidateRect(infoPtr->hwndSelf, &r_new, FALSE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
InvalidateRect(infoPtr->hwndSelf, NULL, FALSE);
|
|
|
|
|
1999-07-10 14:00:04 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
static LRESULT
|
2007-03-29 23:09:32 +02:00
|
|
|
MONTHCAL_GetMaxSelCount(const MONTHCAL_INFO *infoPtr)
|
1999-07-10 14:00:04 +02:00
|
|
|
{
|
|
|
|
return infoPtr->maxSelCount;
|
|
|
|
}
|
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
static LRESULT
|
2009-09-25 01:16:51 +02:00
|
|
|
MONTHCAL_SetMaxSelCount(MONTHCAL_INFO *infoPtr, INT max)
|
1999-07-10 14:00:04 +02:00
|
|
|
{
|
2009-09-25 01:16:51 +02:00
|
|
|
TRACE("%d\n", max);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2009-10-01 21:02:56 +02:00
|
|
|
if(!(infoPtr->dwStyle & MCS_MULTISELECT)) return FALSE;
|
|
|
|
if(max <= 0) return FALSE;
|
|
|
|
|
|
|
|
infoPtr->maxSelCount = max;
|
1999-07-10 14:00:04 +02:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
static LRESULT
|
2009-09-24 01:02:31 +02:00
|
|
|
MONTHCAL_GetSelRange(const MONTHCAL_INFO *infoPtr, SYSTEMTIME *range)
|
1999-07-10 14:00:04 +02:00
|
|
|
{
|
2009-09-24 01:02:31 +02:00
|
|
|
TRACE("%p\n", range);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2009-09-24 01:02:31 +02:00
|
|
|
if(!range) return FALSE;
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2009-09-08 08:44:55 +02:00
|
|
|
if(infoPtr->dwStyle & MCS_MULTISELECT)
|
2000-01-04 01:30:21 +01:00
|
|
|
{
|
2009-09-25 21:41:08 +02:00
|
|
|
range[1] = infoPtr->maxSel;
|
|
|
|
range[0] = infoPtr->minSel;
|
2000-01-04 01:30:21 +01:00
|
|
|
TRACE("[min,max]=[%d %d]\n", infoPtr->minSel.wDay, infoPtr->maxSel.wDay);
|
1999-11-21 03:04:09 +01:00
|
|
|
return TRUE;
|
1999-07-10 14:00:04 +02:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-07-10 14:00:04 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
static LRESULT
|
2009-09-24 01:02:31 +02:00
|
|
|
MONTHCAL_SetSelRange(MONTHCAL_INFO *infoPtr, SYSTEMTIME *range)
|
1999-07-10 14:00:04 +02:00
|
|
|
{
|
2011-09-19 08:44:22 +02:00
|
|
|
SYSTEMTIME old_range[2];
|
2011-09-19 09:16:43 +02:00
|
|
|
INT diff;
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2011-09-19 08:44:22 +02:00
|
|
|
TRACE("%p\n", range);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2011-09-19 08:44:22 +02:00
|
|
|
if(!range || !(infoPtr->dwStyle & MCS_MULTISELECT)) return FALSE;
|
2009-10-04 21:17:07 +02:00
|
|
|
|
2011-09-19 08:44:22 +02: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-09-26 18:06:48 +02:00
|
|
|
|
2011-09-19 08:44:22 +02:00
|
|
|
/* maximum range exceeded */
|
|
|
|
if(!MONTHCAL_IsSelRangeValid(infoPtr, &range[0], &range[1], NULL)) return FALSE;
|
2009-10-05 18:29:31 +02:00
|
|
|
|
2011-09-19 08:44:22 +02:00
|
|
|
old_range[0] = infoPtr->minSel;
|
|
|
|
old_range[1] = infoPtr->maxSel;
|
2009-10-04 21:17:07 +02:00
|
|
|
|
2011-09-19 08:44:22 +02: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];
|
|
|
|
}
|
2011-09-19 09:16:43 +02:00
|
|
|
|
|
|
|
diff = MONTHCAL_MonthDiff(&infoPtr->calendars[MONTHCAL_GetCalCount(infoPtr)-1].month, &infoPtr->maxSel);
|
|
|
|
if (diff < 0)
|
|
|
|
{
|
|
|
|
diff = MONTHCAL_MonthDiff(&infoPtr->calendars[0].month, &infoPtr->maxSel);
|
|
|
|
if (diff > 0) diff = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (diff != 0)
|
|
|
|
{
|
|
|
|
INT i;
|
|
|
|
|
|
|
|
for (i = 0; i < MONTHCAL_GetCalCount(infoPtr); i++)
|
|
|
|
MONTHCAL_GetMonth(&infoPtr->calendars[i].month, diff);
|
|
|
|
}
|
2009-09-26 18:06:48 +02:00
|
|
|
|
2011-09-19 08:44:22 +02:00
|
|
|
/* update day of week */
|
|
|
|
MONTHCAL_CalculateDayOfWeek(&infoPtr->minSel, TRUE);
|
|
|
|
MONTHCAL_CalculateDayOfWeek(&infoPtr->maxSel, TRUE);
|
2009-10-04 21:17:07 +02:00
|
|
|
|
2011-09-19 08:44:22 +02: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);
|
1999-07-10 14:00:04 +02:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2011-09-19 08:44:22 +02:00
|
|
|
TRACE("[min,max]=[%d %d]\n", infoPtr->minSel.wDay, infoPtr->maxSel.wDay);
|
|
|
|
return TRUE;
|
1999-07-10 14:00:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
static LRESULT
|
2009-09-24 01:02:31 +02:00
|
|
|
MONTHCAL_GetToday(const MONTHCAL_INFO *infoPtr, SYSTEMTIME *today)
|
1999-07-10 14:00:04 +02:00
|
|
|
{
|
2009-09-24 01:02:31 +02:00
|
|
|
TRACE("%p\n", today);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2009-09-24 01:02:31 +02:00
|
|
|
if(!today) return FALSE;
|
2009-09-25 21:41:08 +02:00
|
|
|
*today = infoPtr->todaysDate;
|
1999-07-10 14:00:04 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2009-10-06 22:58:22 +02: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)
|
|
|
|
{
|
2017-08-27 23:07:51 +02:00
|
|
|
RECT rect;
|
|
|
|
|
|
|
|
if (MONTHCAL_IsDateEqual(today, &infoPtr->todaysDate))
|
|
|
|
return FALSE;
|
2009-10-06 22:58:22 +02:00
|
|
|
|
2017-08-27 23:07:51 +02:00
|
|
|
/* Invalidate old and new today day rectangle, and today label. */
|
2017-08-27 23:07:52 +02:00
|
|
|
if (MONTHCAL_GetDayRect(infoPtr, &infoPtr->todaysDate, &rect, -1))
|
2017-08-27 23:07:51 +02:00
|
|
|
InvalidateRect(infoPtr->hwndSelf, &rect, FALSE);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2017-08-27 23:07:52 +02:00
|
|
|
if (MONTHCAL_GetDayRect(infoPtr, today, &rect, -1))
|
2017-08-27 23:07:51 +02:00
|
|
|
InvalidateRect(infoPtr->hwndSelf, &rect, FALSE);
|
2009-10-06 22:58:22 +02:00
|
|
|
|
2017-08-27 23:07:51 +02:00
|
|
|
infoPtr->todaysDate = *today;
|
2009-10-06 22:58:22 +02:00
|
|
|
|
2017-08-27 23:07:51 +02:00
|
|
|
InvalidateRect(infoPtr->hwndSelf, &infoPtr->todayrect, FALSE);
|
|
|
|
return TRUE;
|
2009-10-06 22:58:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* MCM_SETTODAT handler */
|
2002-06-01 01:06:46 +02:00
|
|
|
static LRESULT
|
2009-10-06 22:58:22 +02:00
|
|
|
MONTHCAL_SetToday(MONTHCAL_INFO *infoPtr, const SYSTEMTIME *today)
|
1999-07-31 13:13:25 +02:00
|
|
|
{
|
2009-09-24 01:02:31 +02:00
|
|
|
TRACE("%p\n", today);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2011-09-23 11:34:37 +02:00
|
|
|
if (today)
|
|
|
|
{
|
|
|
|
/* remember if date was set successfully */
|
|
|
|
if (MONTHCAL_UpdateToday(infoPtr, today)) infoPtr->todaySet = TRUE;
|
|
|
|
}
|
2009-09-25 01:32:18 +02:00
|
|
|
|
2011-09-23 11:34:37 +02:00
|
|
|
return 0;
|
1999-07-10 14:00:04 +02:00
|
|
|
}
|
|
|
|
|
2010-07-18 14:14:56 +02:00
|
|
|
/* returns calendar index containing specified point, or -1 if it's background */
|
|
|
|
static INT MONTHCAL_GetCalendarFromPoint(const MONTHCAL_INFO *infoPtr, const POINT *pt)
|
|
|
|
{
|
|
|
|
RECT r;
|
|
|
|
INT i;
|
|
|
|
|
2011-09-13 19:45:07 +02:00
|
|
|
for (i = 0; i < MONTHCAL_GetCalCount(infoPtr); i++)
|
2010-07-18 14:14:56 +02:00
|
|
|
{
|
|
|
|
/* whole bounding rectangle allows some optimization to compute */
|
|
|
|
r.left = infoPtr->calendars[i].title.left;
|
|
|
|
r.top = infoPtr->calendars[i].title.top;
|
|
|
|
r.bottom = infoPtr->calendars[i].days.bottom;
|
|
|
|
r.right = infoPtr->calendars[i].days.right;
|
|
|
|
|
|
|
|
if (PtInRect(&r, *pt)) return i;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2010-08-07 16:07:03 +02:00
|
|
|
static inline UINT fill_hittest_info(const MCHITTESTINFO *src, MCHITTESTINFO *dest)
|
|
|
|
{
|
|
|
|
dest->uHit = src->uHit;
|
|
|
|
dest->st = src->st;
|
|
|
|
|
|
|
|
if (dest->cbSize == sizeof(MCHITTESTINFO))
|
|
|
|
memcpy(&dest->rc, &src->rc, sizeof(MCHITTESTINFO) - MCHITTESTINFO_V1_SIZE);
|
|
|
|
|
|
|
|
return src->uHit;
|
|
|
|
}
|
|
|
|
|
1999-07-10 14:00:04 +02:00
|
|
|
static LRESULT
|
2009-09-24 01:02:31 +02:00
|
|
|
MONTHCAL_HitTest(const MONTHCAL_INFO *infoPtr, MCHITTESTINFO *lpht)
|
1999-07-10 14:00:04 +02:00
|
|
|
{
|
2010-08-07 16:07:03 +02:00
|
|
|
MCHITTESTINFO htinfo;
|
2011-09-18 20:32:16 +02:00
|
|
|
SYSTEMTIME *ht_month;
|
2011-09-04 17:48:28 +02:00
|
|
|
INT day, calIdx;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2009-09-26 21:26:53 +02:00
|
|
|
if(!lpht || lpht->cbSize < MCHITTESTINFO_V1_SIZE) return -1;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2010-08-07 16:07:03 +02:00
|
|
|
htinfo.st = st_null;
|
|
|
|
|
|
|
|
/* we should preserve passed fields if hit area doesn't need them */
|
|
|
|
if (lpht->cbSize == sizeof(MCHITTESTINFO))
|
|
|
|
memcpy(&htinfo.rc, &lpht->rc, sizeof(MCHITTESTINFO) - MCHITTESTINFO_V1_SIZE);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2010-07-18 14:14:56 +02:00
|
|
|
/* guess in what calendar we are */
|
|
|
|
calIdx = MONTHCAL_GetCalendarFromPoint(infoPtr, &lpht->pt);
|
2010-07-18 14:16:33 +02:00
|
|
|
if (calIdx == -1)
|
|
|
|
{
|
|
|
|
if (PtInRect(&infoPtr->todayrect, lpht->pt))
|
2010-08-07 16:07:03 +02:00
|
|
|
{
|
|
|
|
htinfo.uHit = MCHT_TODAYLINK;
|
|
|
|
htinfo.rc = infoPtr->todayrect;
|
|
|
|
}
|
2010-07-18 14:16:33 +02:00
|
|
|
else
|
|
|
|
/* outside of calendar area? What's left must be background :-) */
|
2010-08-07 16:07:03 +02:00
|
|
|
htinfo.uHit = MCHT_CALENDARBK;
|
2010-07-18 14:16:33 +02:00
|
|
|
|
2010-08-07 16:07:03 +02:00
|
|
|
return fill_hittest_info(&htinfo, lpht);
|
2010-07-18 14:16:33 +02:00
|
|
|
}
|
2010-07-18 14:14:56 +02:00
|
|
|
|
2000-10-15 02:27:28 +02:00
|
|
|
/* are we in the header? */
|
2010-07-18 14:16:33 +02:00
|
|
|
if (PtInRect(&infoPtr->calendars[calIdx].title, lpht->pt)) {
|
2010-07-18 14:14:56 +02:00
|
|
|
/* FIXME: buttons hittesting could be optimized cause maximum
|
|
|
|
two calendars have buttons */
|
2010-07-18 14:16:33 +02:00
|
|
|
if (calIdx == 0 && PtInRect(&infoPtr->titlebtnprev, lpht->pt))
|
|
|
|
{
|
2010-08-07 16:07:03 +02:00
|
|
|
htinfo.uHit = MCHT_TITLEBTNPREV;
|
|
|
|
htinfo.rc = infoPtr->titlebtnprev;
|
1999-11-21 03:04:09 +01:00
|
|
|
}
|
2010-07-18 14:16:33 +02:00
|
|
|
else if (PtInRect(&infoPtr->titlebtnnext, lpht->pt))
|
|
|
|
{
|
2010-08-07 16:07:03 +02:00
|
|
|
htinfo.uHit = MCHT_TITLEBTNNEXT;
|
|
|
|
htinfo.rc = infoPtr->titlebtnnext;
|
1999-11-21 03:04:09 +01:00
|
|
|
}
|
2010-07-18 14:16:33 +02:00
|
|
|
else if (PtInRect(&infoPtr->calendars[calIdx].titlemonth, lpht->pt))
|
|
|
|
{
|
2010-08-07 16:07:03 +02:00
|
|
|
htinfo.uHit = MCHT_TITLEMONTH;
|
|
|
|
htinfo.rc = infoPtr->calendars[calIdx].titlemonth;
|
|
|
|
htinfo.iOffset = calIdx;
|
1999-11-21 03:04:09 +01:00
|
|
|
}
|
2010-07-18 14:16:33 +02:00
|
|
|
else if (PtInRect(&infoPtr->calendars[calIdx].titleyear, lpht->pt))
|
|
|
|
{
|
2010-08-07 16:07:03 +02:00
|
|
|
htinfo.uHit = MCHT_TITLEYEAR;
|
|
|
|
htinfo.rc = infoPtr->calendars[calIdx].titleyear;
|
|
|
|
htinfo.iOffset = calIdx;
|
1999-11-21 03:04:09 +01:00
|
|
|
}
|
2010-07-18 14:16:33 +02:00
|
|
|
else
|
2010-08-07 16:07:03 +02:00
|
|
|
{
|
|
|
|
htinfo.uHit = MCHT_TITLE;
|
|
|
|
htinfo.rc = infoPtr->calendars[calIdx].title;
|
|
|
|
htinfo.iOffset = calIdx;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2010-08-07 16:07:03 +02:00
|
|
|
return fill_hittest_info(&htinfo, lpht);
|
1999-11-21 03:04:09 +01:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2011-09-18 20:32:16 +02:00
|
|
|
ht_month = &infoPtr->calendars[calIdx].month;
|
|
|
|
/* days area (including week days and week numbers) */
|
2011-09-04 17:48:28 +02:00
|
|
|
day = MONTHCAL_GetDayFromPos(infoPtr, lpht->pt, calIdx);
|
2010-07-18 14:16:33 +02:00
|
|
|
if (PtInRect(&infoPtr->calendars[calIdx].wdays, lpht->pt))
|
|
|
|
{
|
2010-08-07 16:07:03 +02:00
|
|
|
htinfo.uHit = MCHT_CALENDARDAY;
|
|
|
|
htinfo.iOffset = calIdx;
|
2011-09-18 20:32:16 +02:00
|
|
|
htinfo.st.wYear = ht_month->wYear;
|
|
|
|
htinfo.st.wMonth = (day < 1) ? ht_month->wMonth -1 : ht_month->wMonth;
|
2010-08-07 16:07:03 +02:00
|
|
|
htinfo.st.wDay = (day < 1) ?
|
2011-09-18 20:32:16 +02:00
|
|
|
MONTHCAL_MonthLength(ht_month->wMonth-1, ht_month->wYear) - day : day;
|
2010-08-07 16:07:03 +02:00
|
|
|
|
2011-09-04 17:48:28 +02:00
|
|
|
MONTHCAL_GetDayPos(infoPtr, &htinfo.st, &htinfo.iCol, &htinfo.iRow, calIdx);
|
1999-11-21 03:04:09 +01:00
|
|
|
}
|
2010-07-18 14:16:33 +02:00
|
|
|
else if(PtInRect(&infoPtr->calendars[calIdx].weeknums, lpht->pt))
|
|
|
|
{
|
2010-08-07 16:07:03 +02:00
|
|
|
htinfo.uHit = MCHT_CALENDARWEEKNUM;
|
2011-09-18 20:32:16 +02:00
|
|
|
htinfo.st.wYear = ht_month->wYear;
|
2010-08-07 16:07:03 +02:00
|
|
|
htinfo.iOffset = calIdx;
|
2010-07-18 14:14:56 +02:00
|
|
|
|
2010-08-04 12:29:27 +02:00
|
|
|
if (day < 1)
|
|
|
|
{
|
2011-09-18 20:32:16 +02:00
|
|
|
htinfo.st.wMonth = ht_month->wMonth - 1;
|
|
|
|
htinfo.st.wDay = MONTHCAL_MonthLength(ht_month->wMonth-1, ht_month->wYear) - day;
|
2010-07-18 14:14:56 +02:00
|
|
|
}
|
2011-09-18 20:32:16 +02:00
|
|
|
else if (day > MONTHCAL_MonthLength(ht_month->wMonth, ht_month->wYear))
|
2010-08-04 12:29:27 +02:00
|
|
|
{
|
2011-09-18 20:32:16 +02:00
|
|
|
htinfo.st.wMonth = ht_month->wMonth + 1;
|
|
|
|
htinfo.st.wDay = day - MONTHCAL_MonthLength(ht_month->wMonth, ht_month->wYear);
|
2010-07-18 14:14:56 +02:00
|
|
|
}
|
|
|
|
else
|
2010-08-04 12:29:27 +02:00
|
|
|
{
|
2011-09-18 20:32:16 +02:00
|
|
|
htinfo.st.wMonth = ht_month->wMonth;
|
2010-08-07 16:07:03 +02:00
|
|
|
htinfo.st.wDay = day;
|
2010-08-04 12:29:27 +02:00
|
|
|
}
|
1999-11-21 03:04:09 +01:00
|
|
|
}
|
2010-07-18 14:16:33 +02:00
|
|
|
else if(PtInRect(&infoPtr->calendars[calIdx].days, lpht->pt))
|
2009-09-29 21:30:49 +02:00
|
|
|
{
|
2010-08-07 16:07:03 +02:00
|
|
|
htinfo.iOffset = calIdx;
|
2017-08-27 23:07:50 +02:00
|
|
|
htinfo.st.wDay = ht_month->wDay;
|
2011-09-18 20:32:16 +02:00
|
|
|
htinfo.st.wYear = ht_month->wYear;
|
|
|
|
htinfo.st.wMonth = ht_month->wMonth;
|
|
|
|
/* previous month only valid for first calendar */
|
|
|
|
if (day < 1 && calIdx == 0)
|
2009-09-29 21:30:49 +02:00
|
|
|
{
|
2010-08-07 16:07:03 +02:00
|
|
|
htinfo.uHit = MCHT_CALENDARDATEPREV;
|
|
|
|
MONTHCAL_GetPrevMonth(&htinfo.st);
|
2011-03-26 02:05:59 +01:00
|
|
|
htinfo.st.wDay = MONTHCAL_MonthLength(htinfo.st.wMonth, htinfo.st.wYear) + day;
|
2009-09-29 21:30:49 +02:00
|
|
|
}
|
2011-09-18 20:32:16 +02:00
|
|
|
/* next month only valid for last calendar */
|
|
|
|
else if (day > MONTHCAL_MonthLength(ht_month->wMonth, ht_month->wYear) &&
|
|
|
|
calIdx == MONTHCAL_GetCalCount(infoPtr)-1)
|
2009-09-29 21:30:49 +02:00
|
|
|
{
|
2010-08-07 16:07:03 +02:00
|
|
|
htinfo.uHit = MCHT_CALENDARDATENEXT;
|
|
|
|
MONTHCAL_GetNextMonth(&htinfo.st);
|
2011-09-18 20:32:16 +02:00
|
|
|
htinfo.st.wDay = day - MONTHCAL_MonthLength(ht_month->wMonth, ht_month->wYear);
|
|
|
|
}
|
|
|
|
/* multiple calendars case - blank areas for previous/next month */
|
|
|
|
else if (day < 1 || day > MONTHCAL_MonthLength(ht_month->wMonth, ht_month->wYear))
|
|
|
|
{
|
|
|
|
htinfo.uHit = MCHT_CALENDARBK;
|
2009-09-29 21:30:49 +02:00
|
|
|
}
|
2010-08-07 16:07:03 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
htinfo.uHit = MCHT_CALENDARDATE;
|
|
|
|
htinfo.st.wDay = day;
|
2000-10-15 02:27:28 +02:00
|
|
|
}
|
2010-07-18 14:16:33 +02:00
|
|
|
|
2011-09-04 17:48:28 +02:00
|
|
|
MONTHCAL_GetDayPos(infoPtr, &htinfo.st, &htinfo.iCol, &htinfo.iRow, calIdx);
|
|
|
|
MONTHCAL_GetDayRectI(infoPtr, &htinfo.rc, htinfo.iCol, htinfo.iRow, calIdx);
|
2009-10-07 01:19:52 +02:00
|
|
|
/* always update day of week */
|
2010-08-07 16:07:03 +02:00
|
|
|
MONTHCAL_CalculateDayOfWeek(&htinfo.st, TRUE);
|
2009-10-07 01:19:52 +02:00
|
|
|
}
|
2010-07-18 14:14:56 +02:00
|
|
|
|
2010-08-07 16:07:03 +02:00
|
|
|
return fill_hittest_info(&htinfo, lpht);
|
1999-07-10 14:00:04 +02:00
|
|
|
}
|
|
|
|
|
2009-09-26 14:03:34 +02:00
|
|
|
/* MCN_GETDAYSTATE notification helper */
|
|
|
|
static void MONTHCAL_NotifyDayState(MONTHCAL_INFO *infoPtr)
|
1999-07-31 13:13:25 +02:00
|
|
|
{
|
2011-09-30 21:41:04 +02:00
|
|
|
MONTHDAYSTATE *state;
|
|
|
|
NMDAYSTATE nmds;
|
1999-07-31 13:13:25 +02:00
|
|
|
|
2011-09-30 21:41:04 +02:00
|
|
|
if (!(infoPtr->dwStyle & MCS_DAYSTATE)) return;
|
1999-07-31 13:13:25 +02:00
|
|
|
|
2011-09-30 21:41:04 +02:00
|
|
|
nmds.nmhdr.hwndFrom = infoPtr->hwndSelf;
|
|
|
|
nmds.nmhdr.idFrom = GetWindowLongPtrW(infoPtr->hwndSelf, GWLP_ID);
|
|
|
|
nmds.nmhdr.code = MCN_GETDAYSTATE;
|
|
|
|
nmds.cDayState = MONTHCAL_GetMonthRange(infoPtr, GMR_DAYSTATE, 0);
|
2018-02-06 06:50:24 +01:00
|
|
|
nmds.prgDayState = state = heap_alloc_zero(nmds.cDayState * sizeof(MONTHDAYSTATE));
|
2008-08-29 18:17:55 +02:00
|
|
|
|
2011-09-30 21:41:04 +02:00
|
|
|
MONTHCAL_GetMinDate(infoPtr, &nmds.stStart);
|
|
|
|
nmds.stStart.wDay = 1;
|
2009-09-26 13:55:27 +02:00
|
|
|
|
2011-09-30 21:41:04 +02:00
|
|
|
SendMessageW(infoPtr->hwndNotify, WM_NOTIFY, nmds.nmhdr.idFrom, (LPARAM)&nmds);
|
|
|
|
memcpy(infoPtr->monthdayState, nmds.prgDayState,
|
|
|
|
MONTHCAL_GetMonthRange(infoPtr, GMR_DAYSTATE, 0)*sizeof(MONTHDAYSTATE));
|
|
|
|
|
2018-02-06 06:50:24 +01:00
|
|
|
heap_free(state);
|
1999-07-31 13:13:25 +02:00
|
|
|
}
|
|
|
|
|
2010-08-08 09:56:06 +02:00
|
|
|
/* no valid range check performed */
|
2016-07-25 23:13:45 +02:00
|
|
|
static void MONTHCAL_Scroll(MONTHCAL_INFO *infoPtr, INT delta, BOOL keep_selection)
|
2010-08-08 09:56:06 +02:00
|
|
|
{
|
|
|
|
INT i, selIdx = -1;
|
|
|
|
|
2011-09-13 19:45:07 +02:00
|
|
|
for(i = 0; i < MONTHCAL_GetCalCount(infoPtr); i++)
|
2010-08-08 09:56:06 +02:00
|
|
|
{
|
|
|
|
/* save selection position to shift it later */
|
|
|
|
if (selIdx == -1 && MONTHCAL_CompareMonths(&infoPtr->minSel, &infoPtr->calendars[i].month) == 0)
|
|
|
|
selIdx = i;
|
|
|
|
|
|
|
|
MONTHCAL_GetMonth(&infoPtr->calendars[i].month, delta);
|
|
|
|
}
|
|
|
|
|
2016-07-25 23:13:45 +02:00
|
|
|
if (keep_selection)
|
|
|
|
return;
|
|
|
|
|
2010-08-08 09:56:06 +02:00
|
|
|
/* selection is always shifted to first calendar */
|
2016-07-25 23:13:45 +02:00
|
|
|
if (infoPtr->dwStyle & MCS_MULTISELECT)
|
2010-08-08 09:56:06 +02:00
|
|
|
{
|
|
|
|
SYSTEMTIME range[2];
|
|
|
|
|
|
|
|
MONTHCAL_GetSelRange(infoPtr, range);
|
|
|
|
MONTHCAL_GetMonth(&range[0], delta - selIdx);
|
|
|
|
MONTHCAL_GetMonth(&range[1], delta - selIdx);
|
|
|
|
MONTHCAL_SetSelRange(infoPtr, range);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SYSTEMTIME st = infoPtr->minSel;
|
|
|
|
|
|
|
|
MONTHCAL_GetMonth(&st, delta - selIdx);
|
|
|
|
MONTHCAL_SetCurSel(infoPtr, &st);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-31 11:25:47 +02:00
|
|
|
static void MONTHCAL_GoToMonth(MONTHCAL_INFO *infoPtr, enum nav_direction direction)
|
2009-09-26 14:03:34 +02:00
|
|
|
{
|
2011-09-13 19:45:07 +02:00
|
|
|
INT delta = infoPtr->delta ? infoPtr->delta : MONTHCAL_GetCalCount(infoPtr);
|
2016-07-25 23:13:45 +02:00
|
|
|
BOOL keep_selection;
|
2010-08-01 12:38:40 +02:00
|
|
|
SYSTEMTIME st;
|
2009-09-26 14:03:34 +02:00
|
|
|
|
2010-07-31 11:25:47 +02:00
|
|
|
TRACE("%s\n", direction == DIRECTION_BACKWARD ? "back" : "fwd");
|
2009-09-26 15:15:17 +02:00
|
|
|
|
2010-08-01 12:38:40 +02:00
|
|
|
/* check if change allowed by range set */
|
|
|
|
if(direction == DIRECTION_BACKWARD)
|
|
|
|
{
|
|
|
|
st = infoPtr->calendars[0].month;
|
|
|
|
MONTHCAL_GetMonth(&st, -delta);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-09-13 19:45:07 +02:00
|
|
|
st = infoPtr->calendars[MONTHCAL_GetCalCount(infoPtr)-1].month;
|
2010-08-01 12:38:40 +02:00
|
|
|
MONTHCAL_GetMonth(&st, delta);
|
|
|
|
}
|
2009-09-26 14:03:34 +02:00
|
|
|
|
2009-10-11 13:33:02 +02:00
|
|
|
if(!MONTHCAL_IsDateInValidRange(infoPtr, &st, FALSE)) return;
|
1999-07-31 13:13:25 +02:00
|
|
|
|
2016-07-25 23:13:45 +02:00
|
|
|
keep_selection = infoPtr->dwStyle & MCS_NOSELCHANGEONNAV;
|
|
|
|
MONTHCAL_Scroll(infoPtr, direction == DIRECTION_BACKWARD ? -delta : delta, keep_selection);
|
2009-09-26 14:03:34 +02:00
|
|
|
MONTHCAL_NotifyDayState(infoPtr);
|
2016-07-25 23:13:45 +02:00
|
|
|
if (!keep_selection)
|
|
|
|
MONTHCAL_NotifySelectionChange(infoPtr);
|
1999-07-31 13:13:25 +02:00
|
|
|
}
|
|
|
|
|
2000-10-15 02:27:28 +02:00
|
|
|
static LRESULT
|
2009-09-28 20:04:41 +02:00
|
|
|
MONTHCAL_RButtonUp(MONTHCAL_INFO *infoPtr, LPARAM lParam)
|
2000-10-15 02:27:28 +02:00
|
|
|
{
|
|
|
|
HMENU hMenu;
|
|
|
|
POINT menupoint;
|
2005-04-11 16:21:00 +02:00
|
|
|
WCHAR buf[32];
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-10-15 02:27:28 +02:00
|
|
|
hMenu = CreatePopupMenu();
|
2018-02-26 23:29:13 +01:00
|
|
|
LoadStringW(COMCTL32_hModule, IDM_GOTODAY, buf, ARRAY_SIZE(buf));
|
2009-09-26 13:33:47 +02:00
|
|
|
AppendMenuW(hMenu, MF_STRING|MF_ENABLED, 1, buf);
|
|
|
|
menupoint.x = (short)LOWORD(lParam);
|
|
|
|
menupoint.y = (short)HIWORD(lParam);
|
2004-11-30 18:35:16 +01:00
|
|
|
ClientToScreen(infoPtr->hwndSelf, &menupoint);
|
2009-09-26 13:33:47 +02:00
|
|
|
if( TrackPopupMenu(hMenu, TPM_RIGHTBUTTON | TPM_NONOTIFY | TPM_RETURNCMD,
|
2004-11-30 18:35:16 +01:00
|
|
|
menupoint.x, menupoint.y, 0, infoPtr->hwndSelf, NULL))
|
2009-09-26 13:33:47 +02:00
|
|
|
{
|
2011-09-23 12:53:47 +02:00
|
|
|
if (infoPtr->dwStyle & MCS_MULTISELECT)
|
|
|
|
{
|
|
|
|
SYSTEMTIME range[2];
|
|
|
|
|
|
|
|
range[0] = range[1] = infoPtr->todaysDate;
|
|
|
|
MONTHCAL_SetSelRange(infoPtr, range);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
MONTHCAL_SetCurSel(infoPtr, &infoPtr->todaysDate);
|
|
|
|
|
|
|
|
MONTHCAL_NotifySelectionChange(infoPtr);
|
|
|
|
MONTHCAL_NotifySelect(infoPtr);
|
2009-09-26 13:33:47 +02:00
|
|
|
}
|
|
|
|
|
2000-10-15 02:27:28 +02:00
|
|
|
return 0;
|
|
|
|
}
|
1999-07-31 13:13:25 +02:00
|
|
|
|
2009-10-10 19:04:16 +02: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-26 01:50:22 +02:00
|
|
|
/* creates updown control and edit box */
|
2010-08-08 13:32:52 +02:00
|
|
|
static void MONTHCAL_EditYear(MONTHCAL_INFO *infoPtr, INT calIdx)
|
2009-09-26 01:50:22 +02:00
|
|
|
{
|
2010-08-08 13:32:52 +02:00
|
|
|
RECT *rc = &infoPtr->calendars[calIdx].titleyear;
|
|
|
|
RECT *title = &infoPtr->calendars[calIdx].title;
|
|
|
|
|
2009-09-26 01:50:22 +02:00
|
|
|
infoPtr->hWndYearEdit =
|
2009-10-07 23:04:08 +02:00
|
|
|
CreateWindowExW(0, WC_EDITW, 0, WS_VISIBLE | WS_CHILD | ES_READONLY,
|
2010-08-08 13:32:52 +02:00
|
|
|
rc->left + 3, (title->bottom + title->top - infoPtr->textHeight) / 2,
|
|
|
|
rc->right - rc->left + 4,
|
2009-09-26 01:50:22 +02:00
|
|
|
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,
|
2010-08-08 13:32:52 +02:00
|
|
|
rc->right + 7, (title->bottom + title->top - infoPtr->textHeight) / 2,
|
2009-09-26 01:50:22 +02:00
|
|
|
18, infoPtr->textHeight, infoPtr->hwndSelf,
|
|
|
|
NULL, NULL, NULL);
|
|
|
|
|
|
|
|
/* attach edit box */
|
2009-10-05 20:37:04 +02:00
|
|
|
SendMessageW(infoPtr->hWndYearUpDown, UDM_SETRANGE, 0,
|
|
|
|
MAKELONG(max_allowed_date.wYear, min_allowed_date.wYear));
|
2009-09-26 01:50:22 +02:00
|
|
|
SendMessageW(infoPtr->hWndYearUpDown, UDM_SETBUDDY, (WPARAM)infoPtr->hWndYearEdit, 0);
|
2010-08-08 13:32:52 +02:00
|
|
|
SendMessageW(infoPtr->hWndYearUpDown, UDM_SETPOS, 0, infoPtr->calendars[calIdx].month.wYear);
|
2009-10-10 19:04:16 +02:00
|
|
|
|
|
|
|
/* subclass edit box */
|
|
|
|
infoPtr->EditWndProc = (WNDPROC)SetWindowLongPtrW(infoPtr->hWndYearEdit,
|
|
|
|
GWLP_WNDPROC, (DWORD_PTR)EditWndProc);
|
|
|
|
|
|
|
|
SetFocus(infoPtr->hWndYearEdit);
|
2009-09-26 01:50:22 +02:00
|
|
|
}
|
|
|
|
|
1999-07-10 14:00:04 +02:00
|
|
|
static LRESULT
|
2004-11-30 18:35:16 +01:00
|
|
|
MONTHCAL_LButtonDown(MONTHCAL_INFO *infoPtr, LPARAM lParam)
|
1999-07-10 14:00:04 +02:00
|
|
|
{
|
1999-11-21 03:04:09 +01:00
|
|
|
MCHITTESTINFO ht;
|
|
|
|
DWORD hit;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2009-10-10 19:04:16 +02: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-26 01:50:22 +02:00
|
|
|
{
|
2009-10-10 19:04:16 +02:00
|
|
|
SetFocus(infoPtr->hwndSelf);
|
|
|
|
return 0;
|
2009-09-26 01:50:22 +02:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2009-10-04 21:16:41 +02:00
|
|
|
SetCapture(infoPtr->hwndSelf);
|
|
|
|
|
2009-09-26 21:26:53 +02:00
|
|
|
ht.cbSize = sizeof(MCHITTESTINFO);
|
2006-10-25 17:41:48 +02:00
|
|
|
ht.pt.x = (short)LOWORD(lParam);
|
|
|
|
ht.pt.y = (short)HIWORD(lParam);
|
2009-09-26 01:50:22 +02:00
|
|
|
|
2009-09-24 01:02:31 +02:00
|
|
|
hit = MONTHCAL_HitTest(infoPtr, &ht);
|
1999-11-21 03:04:09 +01:00
|
|
|
|
2016-11-22 00:38:39 +01:00
|
|
|
TRACE("%x at %s\n", hit, wine_dbgstr_point(&ht.pt));
|
2009-10-04 21:16:41 +02:00
|
|
|
|
2009-09-26 01:50:22 +02:00
|
|
|
switch(hit)
|
|
|
|
{
|
|
|
|
case MCHT_TITLEBTNNEXT:
|
2010-07-31 11:25:47 +02:00
|
|
|
MONTHCAL_GoToMonth(infoPtr, DIRECTION_FORWARD);
|
1999-11-21 03:04:09 +01:00
|
|
|
infoPtr->status = MC_NEXTPRESSED;
|
2009-10-06 22:58:22 +02:00
|
|
|
SetTimer(infoPtr->hwndSelf, MC_PREVNEXTMONTHTIMER, MC_PREVNEXTMONTHDELAY, 0);
|
2004-11-30 18:35:16 +01:00
|
|
|
InvalidateRect(infoPtr->hwndSelf, NULL, FALSE);
|
2007-10-15 02:45:37 +02:00
|
|
|
return 0;
|
2009-09-26 01:50:22 +02:00
|
|
|
|
|
|
|
case MCHT_TITLEBTNPREV:
|
2010-07-31 11:25:47 +02:00
|
|
|
MONTHCAL_GoToMonth(infoPtr, DIRECTION_BACKWARD);
|
2000-01-04 01:30:21 +01:00
|
|
|
infoPtr->status = MC_PREVPRESSED;
|
2009-10-06 22:58:22 +02:00
|
|
|
SetTimer(infoPtr->hwndSelf, MC_PREVNEXTMONTHTIMER, MC_PREVNEXTMONTHDELAY, 0);
|
2004-11-30 18:35:16 +01:00
|
|
|
InvalidateRect(infoPtr->hwndSelf, NULL, FALSE);
|
2007-10-15 02:45:37 +02:00
|
|
|
return 0;
|
1999-11-21 03:04:09 +01:00
|
|
|
|
2009-09-26 01:50:22 +02:00
|
|
|
case MCHT_TITLEMONTH:
|
|
|
|
{
|
|
|
|
HMENU hMenu = CreatePopupMenu();
|
|
|
|
WCHAR buf[32];
|
|
|
|
POINT menupoint;
|
|
|
|
INT i;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2009-09-26 01:50:22 +02:00
|
|
|
for (i = 0; i < 12; i++)
|
|
|
|
{
|
2018-02-26 23:29:13 +01:00
|
|
|
GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SMONTHNAME1+i, buf, ARRAY_SIZE(buf));
|
|
|
|
AppendMenuW(hMenu, MF_STRING|MF_ENABLED, i + 1, buf);
|
2009-09-26 01:50:22 +02:00
|
|
|
}
|
2009-09-28 20:13:56 +02:00
|
|
|
menupoint.x = ht.pt.x;
|
|
|
|
menupoint.y = ht.pt.y;
|
2004-11-30 18:35:16 +01:00
|
|
|
ClientToScreen(infoPtr->hwndSelf, &menupoint);
|
2009-09-26 01:50:22 +02:00
|
|
|
i = TrackPopupMenu(hMenu,TPM_LEFTALIGN | TPM_NONOTIFY | TPM_RIGHTBUTTON | TPM_RETURNCMD,
|
|
|
|
menupoint.x, menupoint.y, 0, infoPtr->hwndSelf, NULL);
|
|
|
|
|
2010-08-08 10:14:32 +02:00
|
|
|
if ((i > 0) && (i < 13) && infoPtr->calendars[ht.iOffset].month.wMonth != i)
|
2009-09-26 01:50:22 +02:00
|
|
|
{
|
2010-08-08 10:14:32 +02:00
|
|
|
INT delta = i - infoPtr->calendars[ht.iOffset].month.wMonth;
|
|
|
|
SYSTEMTIME st;
|
|
|
|
|
|
|
|
/* check if change allowed by range set */
|
|
|
|
st = delta < 0 ? infoPtr->calendars[0].month :
|
2011-09-13 19:45:07 +02:00
|
|
|
infoPtr->calendars[MONTHCAL_GetCalCount(infoPtr)-1].month;
|
2010-08-08 10:14:32 +02:00
|
|
|
MONTHCAL_GetMonth(&st, delta);
|
|
|
|
|
|
|
|
if (MONTHCAL_IsDateInValidRange(infoPtr, &st, FALSE))
|
|
|
|
{
|
2016-07-25 23:13:45 +02:00
|
|
|
MONTHCAL_Scroll(infoPtr, delta, FALSE);
|
2010-08-08 10:14:32 +02:00
|
|
|
MONTHCAL_NotifyDayState(infoPtr);
|
|
|
|
MONTHCAL_NotifySelectionChange(infoPtr);
|
|
|
|
InvalidateRect(infoPtr->hwndSelf, NULL, FALSE);
|
|
|
|
}
|
2009-09-26 01:50:22 +02:00
|
|
|
}
|
2009-09-28 20:13:56 +02:00
|
|
|
return 0;
|
1999-11-21 03:04:09 +01:00
|
|
|
}
|
2009-09-26 01:50:22 +02:00
|
|
|
case MCHT_TITLEYEAR:
|
|
|
|
{
|
2010-08-08 13:32:52 +02:00
|
|
|
MONTHCAL_EditYear(infoPtr, ht.iOffset);
|
2007-10-15 02:45:37 +02:00
|
|
|
return 0;
|
1999-11-21 03:04:09 +01:00
|
|
|
}
|
2009-09-26 01:50:22 +02:00
|
|
|
case MCHT_TODAYLINK:
|
|
|
|
{
|
2011-09-23 12:53:47 +02:00
|
|
|
if (infoPtr->dwStyle & MCS_MULTISELECT)
|
|
|
|
{
|
|
|
|
SYSTEMTIME range[2];
|
|
|
|
|
|
|
|
range[0] = range[1] = infoPtr->todaysDate;
|
|
|
|
MONTHCAL_SetSelRange(infoPtr, range);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
MONTHCAL_SetCurSel(infoPtr, &infoPtr->todaysDate);
|
2007-10-15 03:25:45 +02:00
|
|
|
|
2009-10-01 20:12:21 +02:00
|
|
|
MONTHCAL_NotifySelectionChange(infoPtr);
|
|
|
|
MONTHCAL_NotifySelect(infoPtr);
|
2007-10-15 02:45:37 +02:00
|
|
|
return 0;
|
1999-11-21 03:04:09 +01:00
|
|
|
}
|
2009-10-04 21:16:41 +02:00
|
|
|
case MCHT_CALENDARDATENEXT:
|
|
|
|
case MCHT_CALENDARDATEPREV:
|
2009-09-26 01:50:22 +02:00
|
|
|
case MCHT_CALENDARDATE:
|
|
|
|
{
|
2009-10-11 13:33:02 +02:00
|
|
|
SYSTEMTIME st[2];
|
2009-10-04 21:17:07 +02:00
|
|
|
|
2009-10-11 13:33:02 +02:00
|
|
|
MONTHCAL_CopyDate(&ht.st, &infoPtr->firstSel);
|
2009-10-04 21:17:07 +02:00
|
|
|
|
2009-10-11 13:33:02 +02:00
|
|
|
st[0] = st[1] = ht.st;
|
|
|
|
/* clear selection range */
|
|
|
|
MONTHCAL_SetSelRange(infoPtr, st);
|
2009-10-04 21:17:07 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
infoPtr->status = MC_SEL_LBUTDOWN;
|
2020-01-24 08:25:14 +01:00
|
|
|
if (MONTHCAL_SetDayFocus(infoPtr, &ht.st) && (infoPtr->dwStyle & MCS_MULTISELECT))
|
|
|
|
MONTHCAL_NotifySelectionChange(infoPtr);
|
2007-10-15 02:45:37 +02:00
|
|
|
return 0;
|
2000-01-04 01:30:21 +01:00
|
|
|
}
|
2009-09-26 01:50:22 +02:00
|
|
|
}
|
2000-01-04 01:30:21 +01:00
|
|
|
|
2007-10-15 02:45:37 +02:00
|
|
|
return 1;
|
1999-07-10 14:00:04 +02:00
|
|
|
}
|
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
|
1999-07-10 14:00:04 +02:00
|
|
|
static LRESULT
|
2004-11-30 18:35:16 +01:00
|
|
|
MONTHCAL_LButtonUp(MONTHCAL_INFO *infoPtr, LPARAM lParam)
|
1999-07-10 14:00:04 +02:00
|
|
|
{
|
1999-11-21 03:04:09 +01:00
|
|
|
NMHDR nmhdr;
|
2000-10-15 02:27:28 +02:00
|
|
|
MCHITTESTINFO ht;
|
|
|
|
DWORD hit;
|
2000-01-04 01:30:21 +01:00
|
|
|
|
|
|
|
TRACE("\n");
|
1999-07-31 13:13:25 +02:00
|
|
|
|
2009-10-06 21:23:55 +02:00
|
|
|
if(infoPtr->status & (MC_PREVPRESSED | MC_NEXTPRESSED)) {
|
2009-10-06 23:20:48 +02:00
|
|
|
RECT *r;
|
|
|
|
|
2009-10-06 21:23:55 +02:00
|
|
|
KillTimer(infoPtr->hwndSelf, MC_PREVNEXTMONTHTIMER);
|
2009-10-06 23:20:48 +02:00
|
|
|
r = infoPtr->status & MC_PREVPRESSED ? &infoPtr->titlebtnprev : &infoPtr->titlebtnnext;
|
2009-10-06 21:23:55 +02:00
|
|
|
infoPtr->status &= ~(MC_PREVPRESSED | MC_NEXTPRESSED);
|
2009-10-06 23:20:48 +02:00
|
|
|
|
|
|
|
InvalidateRect(infoPtr->hwndSelf, r, FALSE);
|
2000-01-04 01:30:21 +01:00
|
|
|
}
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2009-10-04 21:16:41 +02:00
|
|
|
ReleaseCapture();
|
|
|
|
|
2009-09-29 22:22:51 +02: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 19:04:16 +02:00
|
|
|
if(!(infoPtr->status & MC_SEL_LBUTDOWN)) return 0;
|
|
|
|
|
2009-09-26 21:26:53 +02:00
|
|
|
ht.cbSize = sizeof(MCHITTESTINFO);
|
2006-10-25 17:41:48 +02:00
|
|
|
ht.pt.x = (short)LOWORD(lParam);
|
|
|
|
ht.pt.y = (short)HIWORD(lParam);
|
2009-09-24 01:02:31 +02:00
|
|
|
hit = MONTHCAL_HitTest(infoPtr, &ht);
|
2000-10-15 02:27:28 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
infoPtr->status = MC_SEL_LBUTUP;
|
2009-10-04 21:16:41 +02:00
|
|
|
MONTHCAL_SetDayFocus(infoPtr, NULL);
|
1999-07-31 13:13:25 +02:00
|
|
|
|
2009-10-06 23:20:48 +02:00
|
|
|
if((hit & MCHT_CALENDARDATE) == MCHT_CALENDARDATE)
|
2009-09-29 22:22:51 +02:00
|
|
|
{
|
2010-08-02 07:36:12 +02:00
|
|
|
SYSTEMTIME sel = infoPtr->minSel;
|
2009-09-29 21:49:08 +02:00
|
|
|
|
2009-10-11 13:33:02 +02:00
|
|
|
/* will be invalidated here */
|
|
|
|
MONTHCAL_SetCurSel(infoPtr, &ht.st);
|
2009-09-29 21:49:08 +02:00
|
|
|
|
2009-09-29 22:22:51 +02:00
|
|
|
/* send MCN_SELCHANGE only if new date selected */
|
|
|
|
if (!MONTHCAL_IsDateEqual(&sel, &ht.st))
|
2009-10-01 20:12:21 +02:00
|
|
|
MONTHCAL_NotifySelectionChange(infoPtr);
|
1999-07-31 13:13:25 +02:00
|
|
|
|
2009-10-01 20:12:21 +02:00
|
|
|
MONTHCAL_NotifySelect(infoPtr);
|
2004-04-22 00:24:09 +02:00
|
|
|
}
|
2009-09-29 22:22:51 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
return 0;
|
1999-07-10 14:00:04 +02:00
|
|
|
}
|
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
|
1999-07-31 13:13:25 +02:00
|
|
|
static LRESULT
|
2009-10-06 21:23:55 +02:00
|
|
|
MONTHCAL_Timer(MONTHCAL_INFO *infoPtr, WPARAM id)
|
1999-07-31 13:13:25 +02:00
|
|
|
{
|
2009-10-06 21:23:55 +02:00
|
|
|
TRACE("%ld\n", id);
|
1999-11-21 03:04:09 +01:00
|
|
|
|
2009-10-06 21:23:55 +02:00
|
|
|
switch(id) {
|
|
|
|
case MC_PREVNEXTMONTHTIMER:
|
2010-07-31 11:25:47 +02:00
|
|
|
if(infoPtr->status & MC_NEXTPRESSED) MONTHCAL_GoToMonth(infoPtr, DIRECTION_FORWARD);
|
|
|
|
if(infoPtr->status & MC_PREVPRESSED) MONTHCAL_GoToMonth(infoPtr, DIRECTION_BACKWARD);
|
2009-10-06 21:23:55 +02:00
|
|
|
InvalidateRect(infoPtr->hwndSelf, NULL, FALSE);
|
1999-11-21 03:04:09 +01:00
|
|
|
break;
|
2009-10-06 22:58:22 +02: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 03:04:09 +01:00
|
|
|
default:
|
2009-10-06 21:23:55 +02:00
|
|
|
ERR("got unknown timer %ld\n", id);
|
2004-11-30 18:35:16 +01:00
|
|
|
break;
|
1999-11-21 03:04:09 +01:00
|
|
|
}
|
1999-07-31 13:13:25 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
return 0;
|
|
|
|
}
|
1999-07-31 13:13:25 +02:00
|
|
|
|
1999-07-10 14:00:04 +02:00
|
|
|
|
|
|
|
static LRESULT
|
2008-09-07 16:20:38 +02:00
|
|
|
MONTHCAL_MouseMove(MONTHCAL_INFO *infoPtr, LPARAM lParam)
|
1999-07-10 14:00:04 +02:00
|
|
|
{
|
1999-11-21 03:04:09 +01:00
|
|
|
MCHITTESTINFO ht;
|
2010-05-02 20:40:05 +02:00
|
|
|
SYSTEMTIME st_ht;
|
2009-10-04 21:17:07 +02:00
|
|
|
INT hit;
|
1999-11-21 03:04:09 +01:00
|
|
|
RECT r;
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
if(!(infoPtr->status & MC_SEL_LBUTDOWN)) return 0;
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2009-09-26 21:26:53 +02:00
|
|
|
ht.cbSize = sizeof(MCHITTESTINFO);
|
2006-10-25 17:41:48 +02:00
|
|
|
ht.pt.x = (short)LOWORD(lParam);
|
|
|
|
ht.pt.y = (short)HIWORD(lParam);
|
2011-09-04 17:48:28 +02:00
|
|
|
ht.iOffset = -1;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2009-09-24 01:02:31 +02:00
|
|
|
hit = MONTHCAL_HitTest(infoPtr, &ht);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
/* not on the calendar date numbers? bail out */
|
2000-01-04 01:30:21 +01:00
|
|
|
TRACE("hit:%x\n",hit);
|
2009-10-04 21:16:41 +02:00
|
|
|
if((hit & MCHT_CALENDARDATE) != MCHT_CALENDARDATE)
|
|
|
|
{
|
|
|
|
MONTHCAL_SetDayFocus(infoPtr, NULL);
|
|
|
|
return 0;
|
|
|
|
}
|
1999-11-21 03:04:09 +01:00
|
|
|
|
2009-10-04 21:17:07 +02:00
|
|
|
st_ht = ht.st;
|
2009-10-05 18:32:15 +02:00
|
|
|
|
|
|
|
/* if pointer is over focused day still there's nothing to do */
|
|
|
|
if(!MONTHCAL_SetDayFocus(infoPtr, &ht.st)) return 0;
|
2009-10-04 21:16:41 +02:00
|
|
|
|
2011-09-04 17:48:28 +02:00
|
|
|
MONTHCAL_GetDayRect(infoPtr, &ht.st, &r, ht.iOffset);
|
1999-11-21 03:04:09 +01:00
|
|
|
|
2009-10-05 18:32:15 +02:00
|
|
|
if(infoPtr->dwStyle & MCS_MULTISELECT) {
|
2009-10-04 21:17:07 +02:00
|
|
|
SYSTEMTIME st[2];
|
|
|
|
|
|
|
|
MONTHCAL_GetSelRange(infoPtr, st);
|
|
|
|
|
2009-10-05 18:32:15 +02: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-06-01 01:06:46 +02:00
|
|
|
|
2009-10-05 18:29:31 +02:00
|
|
|
MONTHCAL_IsSelRangeValid(infoPtr, &st_ht, &infoPtr->firstSel, &st_ht);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2009-10-05 18:32:15 +02:00
|
|
|
st[0] = infoPtr->firstSel;
|
|
|
|
/* we should overwrite timestamp here */
|
|
|
|
MONTHCAL_CopyDate(&st_ht, &st[1]);
|
2009-10-04 21:17:07 +02:00
|
|
|
|
2009-10-05 18:32:15 +02:00
|
|
|
/* bounds will be swapped here if needed */
|
|
|
|
MONTHCAL_SetSelRange(infoPtr, st);
|
|
|
|
|
|
|
|
return 0;
|
1999-11-21 03:04:09 +01:00
|
|
|
}
|
1999-07-10 14:00:04 +02:00
|
|
|
|
|
|
|
done:
|
|
|
|
|
2009-10-05 18:32:15 +02:00
|
|
|
/* FIXME: this should specify a rectangle containing only the days that changed
|
|
|
|
using InvalidateRect */
|
|
|
|
InvalidateRect(infoPtr->hwndSelf, NULL, FALSE);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
return 0;
|
1999-07-10 14:00:04 +02:00
|
|
|
}
|
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
|
1999-07-10 14:00:04 +02:00
|
|
|
static LRESULT
|
2009-09-25 01:43:38 +02:00
|
|
|
MONTHCAL_Paint(MONTHCAL_INFO *infoPtr, HDC hdc_paint)
|
1999-07-10 14:00:04 +02:00
|
|
|
{
|
1999-11-21 03:04:09 +01:00
|
|
|
HDC hdc;
|
|
|
|
PAINTSTRUCT ps;
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2009-09-25 01:43:38 +02:00
|
|
|
if (hdc_paint)
|
2004-11-08 21:27:02 +01:00
|
|
|
{
|
2004-11-30 18:35:16 +01:00
|
|
|
GetClientRect(infoPtr->hwndSelf, &ps.rcPaint);
|
2009-09-25 01:43:38 +02:00
|
|
|
hdc = hdc_paint;
|
2004-11-08 21:27:02 +01:00
|
|
|
}
|
|
|
|
else
|
2004-11-30 18:35:16 +01:00
|
|
|
hdc = BeginPaint(infoPtr->hwndSelf, &ps);
|
2000-05-30 22:06:33 +02:00
|
|
|
|
2004-11-30 18:35:16 +01:00
|
|
|
MONTHCAL_Refresh(infoPtr, hdc, &ps);
|
2009-09-25 01:43:38 +02:00
|
|
|
if (!hdc_paint) EndPaint(infoPtr->hwndSelf, &ps);
|
1999-11-21 03:04:09 +01:00
|
|
|
return 0;
|
1999-07-10 14:00:04 +02:00
|
|
|
}
|
|
|
|
|
2009-10-13 02:16:31 +02:00
|
|
|
static LRESULT
|
|
|
|
MONTHCAL_EraseBkgnd(const MONTHCAL_INFO *infoPtr, HDC hdc)
|
|
|
|
{
|
|
|
|
RECT rc;
|
|
|
|
|
|
|
|
if (!GetClipBox(hdc, &rc)) return FALSE;
|
|
|
|
|
2011-04-02 11:33:48 +02:00
|
|
|
FillRect(hdc, &rc, infoPtr->brushes[BrushBackground]);
|
2009-10-13 02:16:31 +02:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2009-10-13 02:21:27 +02:00
|
|
|
static LRESULT
|
|
|
|
MONTHCAL_PrintClient(MONTHCAL_INFO *infoPtr, HDC hdc, DWORD options)
|
|
|
|
{
|
|
|
|
FIXME("Partial Stub: (hdc=%p options=0x%08x)\n", hdc, options);
|
|
|
|
|
|
|
|
if ((options & PRF_CHECKVISIBLE) && !IsWindowVisible(infoPtr->hwndSelf))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (options & PRF_ERASEBKGND)
|
|
|
|
MONTHCAL_EraseBkgnd(infoPtr, hdc);
|
|
|
|
|
|
|
|
if (options & PRF_CLIENT)
|
|
|
|
MONTHCAL_Paint(infoPtr, hdc);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1999-07-10 14:00:04 +02:00
|
|
|
static LRESULT
|
2007-03-29 23:09:32 +02:00
|
|
|
MONTHCAL_SetFocus(const MONTHCAL_INFO *infoPtr)
|
1999-07-10 14:00:04 +02:00
|
|
|
{
|
2000-01-04 01:30:21 +01:00
|
|
|
TRACE("\n");
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2004-11-30 18:35:16 +01:00
|
|
|
InvalidateRect(infoPtr->hwndSelf, NULL, FALSE);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
return 0;
|
1999-07-10 14:00:04 +02:00
|
|
|
}
|
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
/* sets the size information */
|
2004-11-30 18:35:16 +01:00
|
|
|
static void MONTHCAL_UpdateSize(MONTHCAL_INFO *infoPtr)
|
2000-01-04 01:30:21 +01:00
|
|
|
{
|
2005-04-11 16:21:00 +02:00
|
|
|
static const WCHAR O0W[] = { '0','0',0 };
|
2010-07-18 14:12:41 +02:00
|
|
|
RECT *title=&infoPtr->calendars[0].title;
|
2000-01-04 01:30:21 +01:00
|
|
|
RECT *prev=&infoPtr->titlebtnprev;
|
|
|
|
RECT *next=&infoPtr->titlebtnnext;
|
2010-07-18 14:12:41 +02:00
|
|
|
RECT *titlemonth=&infoPtr->calendars[0].titlemonth;
|
|
|
|
RECT *titleyear=&infoPtr->calendars[0].titleyear;
|
|
|
|
RECT *wdays=&infoPtr->calendars[0].wdays;
|
|
|
|
RECT *weeknumrect=&infoPtr->calendars[0].weeknums;
|
|
|
|
RECT *days=&infoPtr->calendars[0].days;
|
2000-10-15 02:27:28 +02:00
|
|
|
RECT *todayrect=&infoPtr->todayrect;
|
2011-09-22 15:56:40 +02:00
|
|
|
|
|
|
|
INT xdiv, dx, dy, i, j, x, y, c_dx, c_dy;
|
|
|
|
WCHAR buff[80];
|
2005-04-11 16:21:00 +02:00
|
|
|
TEXTMETRICW tm;
|
2016-05-17 20:21:08 +02:00
|
|
|
INT day_width;
|
2011-09-13 19:45:07 +02:00
|
|
|
RECT client;
|
2011-09-22 15:56:40 +02:00
|
|
|
HFONT font;
|
2016-05-17 20:21:08 +02:00
|
|
|
SIZE size;
|
2011-09-22 15:56:40 +02:00
|
|
|
HDC hdc;
|
2000-01-04 01:30:21 +01:00
|
|
|
|
2011-09-13 19:45:07 +02:00
|
|
|
GetClientRect(infoPtr->hwndSelf, &client);
|
2000-01-04 01:30:21 +01:00
|
|
|
|
2011-09-22 15:56:40 +02:00
|
|
|
hdc = GetDC(infoPtr->hwndSelf);
|
|
|
|
font = SelectObject(hdc, infoPtr->hFont);
|
2000-01-04 01:30:21 +01:00
|
|
|
|
|
|
|
/* get the height and width of each day's text */
|
2005-04-11 16:21:00 +02:00
|
|
|
GetTextMetricsW(hdc, &tm);
|
2004-11-08 21:27:02 +01:00
|
|
|
infoPtr->textHeight = tm.tmHeight + tm.tmExternalLeading + tm.tmInternalLeading;
|
2009-09-30 00:15:40 +02:00
|
|
|
|
2016-05-17 20:21:08 +02:00
|
|
|
/* find widest day name for current locale and font */
|
|
|
|
day_width = 0;
|
2009-09-30 00:15:40 +02:00
|
|
|
for (i = 0; i < 7; i++)
|
|
|
|
{
|
2016-05-17 20:21:08 +02:00
|
|
|
SIZE sz;
|
|
|
|
|
2018-02-26 23:29:13 +01:00
|
|
|
if (get_localized_dayname(infoPtr, i, buff, ARRAY_SIZE(buff)))
|
2009-09-30 00:15:40 +02:00
|
|
|
{
|
|
|
|
GetTextExtentPoint32W(hdc, buff, lstrlenW(buff), &sz);
|
2016-05-17 20:21:08 +02:00
|
|
|
if (sz.cx > day_width) day_width = sz.cx;
|
2009-09-30 00:15:40 +02:00
|
|
|
}
|
|
|
|
else /* locale independent fallback on failure */
|
|
|
|
{
|
2016-05-17 20:21:08 +02:00
|
|
|
static const WCHAR sunW[] = { 'S','u','n' };
|
2018-02-26 23:29:13 +01:00
|
|
|
GetTextExtentPoint32W(hdc, sunW, ARRAY_SIZE(sunW), &sz);
|
2016-05-17 20:21:08 +02:00
|
|
|
day_width = sz.cx;
|
2009-09-30 00:15:40 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-17 20:21:08 +02:00
|
|
|
day_width += 2;
|
2000-01-04 01:30:21 +01:00
|
|
|
|
2004-11-08 21:27:02 +01:00
|
|
|
/* recalculate the height and width increments and offsets */
|
2016-05-17 20:21:08 +02:00
|
|
|
size.cx = 0;
|
2005-04-11 16:21:00 +02:00
|
|
|
GetTextExtentPoint32W(hdc, O0W, 2, &size);
|
2000-01-04 01:30:21 +01:00
|
|
|
|
2011-09-22 15:56:40 +02:00
|
|
|
/* restore the originally selected font */
|
|
|
|
SelectObject(hdc, font);
|
|
|
|
ReleaseDC(infoPtr->hwndSelf, hdc);
|
|
|
|
|
2009-09-08 08:44:55 +02:00
|
|
|
xdiv = (infoPtr->dwStyle & MCS_WEEKNUMBERS) ? 8 : 7;
|
2000-01-04 01:30:21 +01:00
|
|
|
|
2016-05-17 20:21:08 +02:00
|
|
|
infoPtr->width_increment = max(day_width, size.cx * 2 + 4);
|
2004-11-08 21:27:02 +01:00
|
|
|
infoPtr->height_increment = infoPtr->textHeight;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
/* calculate title area */
|
2009-09-28 22:44:45 +02:00
|
|
|
title->top = 0;
|
|
|
|
title->bottom = 3 * infoPtr->height_increment / 2;
|
|
|
|
title->left = 0;
|
|
|
|
title->right = infoPtr->width_increment * xdiv;
|
2000-01-04 01:30:21 +01:00
|
|
|
|
|
|
|
/* set the dimensions of the next and previous buttons and center */
|
|
|
|
/* the month text vertically */
|
2004-11-08 21:27:02 +01:00
|
|
|
prev->top = next->top = title->top + 4;
|
|
|
|
prev->bottom = next->bottom = title->bottom - 4;
|
|
|
|
prev->left = title->left + 4;
|
2009-09-28 22:44:45 +02:00
|
|
|
prev->right = prev->left + (title->bottom - title->top);
|
2004-11-08 21:27:02 +01:00
|
|
|
next->right = title->right - 4;
|
2000-10-15 02:27:28 +02:00
|
|
|
next->left = next->right - (title->bottom - title->top);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2011-09-22 15:56:40 +02: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 02:27:28 +02:00
|
|
|
titlemonth->top = titleyear->top = title->top + (infoPtr->height_increment)/2;
|
|
|
|
titlemonth->bottom = titleyear->bottom = title->bottom - (infoPtr->height_increment)/2;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2011-09-22 15:56:40 +02:00
|
|
|
/* week numbers */
|
|
|
|
weeknumrect->left = 0;
|
|
|
|
weeknumrect->right = infoPtr->dwStyle & MCS_WEEKNUMBERS ? prev->right : 0;
|
2009-09-28 22:44:45 +02:00
|
|
|
|
2011-09-22 15:56:40 +02:00
|
|
|
/* days abbreviated names */
|
2000-10-15 02:27:28 +02:00
|
|
|
wdays->left = days->left = weeknumrect->right;
|
|
|
|
wdays->right = days->right = wdays->left + 7 * infoPtr->width_increment;
|
2009-09-28 22:44:45 +02:00
|
|
|
wdays->top = title->bottom;
|
2000-10-15 02:27:28 +02:00
|
|
|
wdays->bottom = wdays->top + infoPtr->height_increment;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2009-09-28 22:44:45 +02:00
|
|
|
days->top = weeknumrect->top = wdays->bottom;
|
2004-11-08 21:27:02 +01:00
|
|
|
days->bottom = weeknumrect->bottom = days->top + 6 * infoPtr->height_increment;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2009-09-28 22:44:45 +02:00
|
|
|
todayrect->left = 0;
|
|
|
|
todayrect->right = title->right;
|
2000-10-15 02:27:28 +02:00
|
|
|
todayrect->top = days->bottom;
|
|
|
|
todayrect->bottom = days->bottom + infoPtr->height_increment;
|
|
|
|
|
2011-09-22 15:56:40 +02:00
|
|
|
/* compute calendar count, update all calendars */
|
|
|
|
x = (client.right + MC_CALENDAR_PADDING) / (title->right - title->left + MC_CALENDAR_PADDING);
|
|
|
|
/* today label affects whole height */
|
|
|
|
if (infoPtr->dwStyle & MCS_NOTODAY)
|
|
|
|
y = (client.bottom + MC_CALENDAR_PADDING) / (days->bottom - title->top + MC_CALENDAR_PADDING);
|
|
|
|
else
|
|
|
|
y = (client.bottom - todayrect->bottom + todayrect->top + MC_CALENDAR_PADDING) /
|
|
|
|
(days->bottom - title->top + MC_CALENDAR_PADDING);
|
|
|
|
|
|
|
|
/* TODO: ensure that count is properly adjusted to fit 12 months constraint */
|
|
|
|
if (x == 0) x = 1;
|
|
|
|
if (y == 0) y = 1;
|
|
|
|
|
2011-09-23 10:25:35 +02:00
|
|
|
if (x*y != MONTHCAL_GetCalCount(infoPtr))
|
|
|
|
{
|
|
|
|
infoPtr->dim.cx = x;
|
|
|
|
infoPtr->dim.cy = y;
|
2018-02-06 06:50:24 +01:00
|
|
|
infoPtr->calendars = heap_realloc(infoPtr->calendars, MONTHCAL_GetCalCount(infoPtr)*sizeof(CALENDAR_INFO));
|
2011-09-23 10:25:35 +02:00
|
|
|
|
2018-02-06 06:50:24 +01:00
|
|
|
infoPtr->monthdayState = heap_realloc(infoPtr->monthdayState,
|
2011-09-23 10:25:35 +02:00
|
|
|
MONTHCAL_GetMonthRange(infoPtr, GMR_DAYSTATE, 0)*sizeof(MONTHDAYSTATE));
|
|
|
|
MONTHCAL_NotifyDayState(infoPtr);
|
2011-10-16 17:19:52 +02:00
|
|
|
|
|
|
|
/* update pointers that we'll need */
|
|
|
|
title = &infoPtr->calendars[0].title;
|
|
|
|
wdays = &infoPtr->calendars[0].wdays;
|
|
|
|
days = &infoPtr->calendars[0].days;
|
2011-09-23 10:25:35 +02:00
|
|
|
}
|
2011-09-22 15:56:40 +02:00
|
|
|
|
|
|
|
for (i = 1; i < MONTHCAL_GetCalCount(infoPtr); i++)
|
|
|
|
{
|
|
|
|
/* set months */
|
|
|
|
infoPtr->calendars[i] = infoPtr->calendars[0];
|
|
|
|
MONTHCAL_GetMonth(&infoPtr->calendars[i].month, i);
|
|
|
|
}
|
|
|
|
|
2009-09-28 22:44:45 +02:00
|
|
|
/* offset all rectangles to center in client area */
|
2011-09-22 15:56:40 +02:00
|
|
|
c_dx = (client.right - x * title->right - MC_CALENDAR_PADDING * (x-1)) / 2;
|
|
|
|
c_dy = (client.bottom - y * todayrect->bottom - MC_CALENDAR_PADDING * (y-1)) / 2;
|
2009-09-28 22:44:45 +02:00
|
|
|
|
|
|
|
/* if calendar doesn't fit client area show it at left/top bounds */
|
2011-09-22 15:56:40 +02:00
|
|
|
if (title->left + c_dx < 0) c_dx = 0;
|
|
|
|
if (title->top + c_dy < 0) c_dy = 0;
|
2009-09-28 22:44:45 +02:00
|
|
|
|
2011-09-22 15:56:40 +02:00
|
|
|
for (i = 0; i < y; i++)
|
2009-09-28 22:44:45 +02:00
|
|
|
{
|
2011-09-22 15:56:40 +02:00
|
|
|
for (j = 0; j < x; j++)
|
|
|
|
{
|
|
|
|
dx = j*(title->right - title->left + MC_CALENDAR_PADDING) + c_dx;
|
|
|
|
dy = i*(days->bottom - title->top + MC_CALENDAR_PADDING) + c_dy;
|
|
|
|
|
|
|
|
OffsetRect(&infoPtr->calendars[i*x+j].title, dx, dy);
|
|
|
|
OffsetRect(&infoPtr->calendars[i*x+j].titlemonth, dx, dy);
|
|
|
|
OffsetRect(&infoPtr->calendars[i*x+j].titleyear, dx, dy);
|
|
|
|
OffsetRect(&infoPtr->calendars[i*x+j].wdays, dx, dy);
|
|
|
|
OffsetRect(&infoPtr->calendars[i*x+j].weeknums, dx, dy);
|
|
|
|
OffsetRect(&infoPtr->calendars[i*x+j].days, dx, dy);
|
|
|
|
}
|
2009-09-28 22:44:45 +02:00
|
|
|
}
|
|
|
|
|
2011-09-22 15:56:40 +02:00
|
|
|
OffsetRect(prev, c_dx, c_dy);
|
|
|
|
OffsetRect(next, (x-1)*(title->right - title->left + MC_CALENDAR_PADDING) + c_dx, c_dy);
|
|
|
|
|
|
|
|
i = infoPtr->dim.cx * infoPtr->dim.cy - infoPtr->dim.cx;
|
|
|
|
todayrect->left = infoPtr->calendars[i].title.left;
|
|
|
|
todayrect->right = infoPtr->calendars[i].title.right;
|
|
|
|
todayrect->top = infoPtr->calendars[i].days.bottom;
|
|
|
|
todayrect->bottom = infoPtr->calendars[i].days.bottom + infoPtr->height_increment;
|
2011-09-13 19:45:07 +02:00
|
|
|
|
2004-11-08 21:27:02 +01:00
|
|
|
TRACE("dx=%d dy=%d client[%s] title[%s] wdays[%s] days[%s] today[%s]\n",
|
2000-10-15 02:27:28 +02:00
|
|
|
infoPtr->width_increment,infoPtr->height_increment,
|
2011-09-13 19:45:07 +02:00
|
|
|
wine_dbgstr_rect(&client),
|
2004-11-08 21:27:02 +01:00
|
|
|
wine_dbgstr_rect(title),
|
|
|
|
wine_dbgstr_rect(wdays),
|
|
|
|
wine_dbgstr_rect(days),
|
|
|
|
wine_dbgstr_rect(todayrect));
|
2000-01-04 01:30:21 +01:00
|
|
|
}
|
|
|
|
|
2004-11-30 18:35:16 +01:00
|
|
|
static LRESULT MONTHCAL_Size(MONTHCAL_INFO *infoPtr, int Width, int Height)
|
2000-01-04 01:30:21 +01:00
|
|
|
{
|
2004-11-30 18:35:16 +01:00
|
|
|
TRACE("(width=%d, height=%d)\n", Width, Height);
|
2000-01-04 01:30:21 +01:00
|
|
|
|
2004-11-30 18:35:16 +01:00
|
|
|
MONTHCAL_UpdateSize(infoPtr);
|
|
|
|
InvalidateRect(infoPtr->hwndSelf, NULL, TRUE);
|
2000-01-04 01:30:21 +01:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2007-03-29 23:09:32 +02:00
|
|
|
static LRESULT MONTHCAL_GetFont(const MONTHCAL_INFO *infoPtr)
|
2004-11-30 18:35:16 +01: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 18:04:52 +02:00
|
|
|
MONTHCAL_UpdateSize(infoPtr);
|
|
|
|
|
2004-11-30 18:35:16 +01:00
|
|
|
if (redraw)
|
|
|
|
InvalidateRect(infoPtr->hwndSelf, NULL, FALSE);
|
|
|
|
|
|
|
|
return (LRESULT)hOldFont;
|
|
|
|
}
|
|
|
|
|
2005-08-11 19:05:00 +02:00
|
|
|
/* update theme after a WM_THEMECHANGED message */
|
2007-03-29 23:09:32 +02:00
|
|
|
static LRESULT theme_changed (const MONTHCAL_INFO* infoPtr)
|
2005-08-11 19:05:00 +02:00
|
|
|
{
|
|
|
|
HTHEME theme = GetWindowTheme (infoPtr->hwndSelf);
|
|
|
|
CloseThemeData (theme);
|
2008-11-20 00:27:51 +01:00
|
|
|
OpenThemeData (infoPtr->hwndSelf, themeClass);
|
2005-08-11 19:05:00 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-09-08 08:44:55 +02: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-07 01:50:02 +02:00
|
|
|
/* make room for week numbers */
|
2016-05-17 20:21:07 +02:00
|
|
|
if ((lpss->styleNew ^ lpss->styleOld) & (MCS_WEEKNUMBERS | MCS_SHORTDAYSOFWEEK))
|
2009-10-07 01:50:02 +02:00
|
|
|
MONTHCAL_UpdateSize(infoPtr);
|
|
|
|
|
2009-09-08 08:44:55 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-10-01 20:49:02 +02: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;
|
|
|
|
}
|
|
|
|
|
2011-09-23 10:25:35 +02:00
|
|
|
/* block MCS_DAYSTATE change */
|
|
|
|
if ((lpss->styleNew ^ lpss->styleOld) & MCS_DAYSTATE)
|
|
|
|
{
|
|
|
|
if (lpss->styleOld & MCS_DAYSTATE)
|
|
|
|
lpss->styleNew |= MCS_DAYSTATE;
|
|
|
|
else
|
|
|
|
lpss->styleNew &= ~MCS_DAYSTATE;
|
|
|
|
}
|
|
|
|
|
2009-10-01 20:49:02 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1999-07-10 14:00:04 +02:00
|
|
|
/* FIXME: check whether dateMin/dateMax need to be adjusted. */
|
1998-11-08 12:30:27 +01:00
|
|
|
static LRESULT
|
2009-09-24 01:02:31 +02:00
|
|
|
MONTHCAL_Create(HWND hwnd, LPCREATESTRUCTW lpcs)
|
1998-11-08 12:30:27 +01:00
|
|
|
{
|
1999-11-21 03:04:09 +01:00
|
|
|
MONTHCAL_INFO *infoPtr;
|
1998-11-08 12:30:27 +01:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
/* allocate memory for info structure */
|
2018-02-06 06:50:24 +01:00
|
|
|
infoPtr = heap_alloc_zero(sizeof(*infoPtr));
|
2004-08-25 19:33:01 +02:00
|
|
|
SetWindowLongPtrW(hwnd, 0, (DWORD_PTR)infoPtr);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2010-07-18 14:12:41 +02:00
|
|
|
if (infoPtr == NULL) {
|
|
|
|
ERR("could not allocate info memory!\n");
|
1999-11-21 03:04:09 +01:00
|
|
|
return 0;
|
|
|
|
}
|
1998-11-08 12:30:27 +01:00
|
|
|
|
2004-11-08 21:27:02 +01:00
|
|
|
infoPtr->hwndSelf = hwnd;
|
2009-09-24 01:02:31 +02:00
|
|
|
infoPtr->hwndNotify = lpcs->hwndParent;
|
2011-09-23 10:25:35 +02:00
|
|
|
infoPtr->dwStyle = GetWindowLongW(hwnd, GWL_STYLE);
|
|
|
|
infoPtr->dim.cx = infoPtr->dim.cy = 1;
|
2018-02-06 06:50:24 +01:00
|
|
|
infoPtr->calendars = heap_alloc_zero(sizeof(CALENDAR_INFO));
|
2010-07-18 14:12:41 +02:00
|
|
|
if (!infoPtr->calendars) goto fail;
|
2018-02-06 06:50:24 +01:00
|
|
|
infoPtr->monthdayState = heap_alloc_zero(3 * sizeof(MONTHDAYSTATE));
|
2011-09-23 10:25:35 +02:00
|
|
|
if (!infoPtr->monthdayState) goto fail;
|
1999-11-21 03:04:09 +01:00
|
|
|
|
|
|
|
/* initialize info structure */
|
2011-05-09 09:03:40 +02:00
|
|
|
/* FIXME: calculate systemtime ->> localtime(subtract timezoneinfo) */
|
1999-11-21 03:04:09 +01:00
|
|
|
|
2005-04-20 14:51:37 +02:00
|
|
|
GetLocalTime(&infoPtr->todaysDate);
|
2009-09-24 01:02:31 +02:00
|
|
|
MONTHCAL_SetFirstDayOfWeek(infoPtr, -1);
|
2009-09-26 15:15:17 +02:00
|
|
|
|
2009-10-01 20:49:02 +02:00
|
|
|
infoPtr->maxSelCount = (infoPtr->dwStyle & MCS_MULTISELECT) ? 7 : 1;
|
2010-07-18 14:12:41 +02:00
|
|
|
|
2010-08-08 14:54:23 +02:00
|
|
|
infoPtr->colors[MCSC_BACKGROUND] = comctl32_color.clrWindow;
|
|
|
|
infoPtr->colors[MCSC_TEXT] = comctl32_color.clrWindowText;
|
|
|
|
infoPtr->colors[MCSC_TITLEBK] = comctl32_color.clrActiveCaption;
|
|
|
|
infoPtr->colors[MCSC_TITLETEXT] = comctl32_color.clrWindow;
|
|
|
|
infoPtr->colors[MCSC_MONTHBK] = comctl32_color.clrWindow;
|
|
|
|
infoPtr->colors[MCSC_TRAILINGTEXT] = comctl32_color.clrGrayText;
|
2009-09-25 23:20:33 +02:00
|
|
|
|
2011-04-02 11:33:48 +02:00
|
|
|
infoPtr->brushes[BrushBackground] = CreateSolidBrush(infoPtr->colors[MCSC_BACKGROUND]);
|
|
|
|
infoPtr->brushes[BrushTitle] = CreateSolidBrush(infoPtr->colors[MCSC_TITLEBK]);
|
|
|
|
infoPtr->brushes[BrushMonth] = CreateSolidBrush(infoPtr->colors[MCSC_MONTHBK]);
|
2011-03-26 13:58:59 +01:00
|
|
|
|
2011-04-02 11:15:42 +02:00
|
|
|
infoPtr->pens[PenRed] = CreatePen(PS_SOLID, 1, RGB(255, 0, 0));
|
|
|
|
infoPtr->pens[PenText] = CreatePen(PS_SOLID, 1, infoPtr->colors[MCSC_TEXT]);
|
|
|
|
|
2009-09-25 23:20:33 +02:00
|
|
|
infoPtr->minSel = infoPtr->todaysDate;
|
|
|
|
infoPtr->maxSel = infoPtr->todaysDate;
|
2010-07-18 14:14:56 +02:00
|
|
|
infoPtr->calendars[0].month = infoPtr->todaysDate;
|
2009-10-15 18:16:27 +02:00
|
|
|
infoPtr->isUnicode = TRUE;
|
2006-12-24 08:43:56 +01:00
|
|
|
|
2011-09-23 10:25:35 +02:00
|
|
|
/* setup control layout and day state data */
|
2004-11-30 18:35:16 +01:00
|
|
|
MONTHCAL_UpdateSize(infoPtr);
|
2009-10-06 22:58:22 +02:00
|
|
|
|
|
|
|
/* today auto update timer, to be freed only on control destruction */
|
|
|
|
SetTimer(infoPtr->hwndSelf, MC_TODAYUPDATETIMER, MC_TODAYUPDATEDELAY, 0);
|
|
|
|
|
2005-08-11 19:05:00 +02:00
|
|
|
OpenThemeData (infoPtr->hwndSelf, themeClass);
|
1999-11-21 03:04:09 +01:00
|
|
|
|
|
|
|
return 0;
|
1998-11-08 12:30:27 +01:00
|
|
|
|
2010-07-18 14:12:41 +02:00
|
|
|
fail:
|
2018-02-06 06:50:24 +01:00
|
|
|
heap_free(infoPtr->monthdayState);
|
|
|
|
heap_free(infoPtr->calendars);
|
|
|
|
heap_free(infoPtr);
|
2010-07-18 14:12:41 +02:00
|
|
|
return 0;
|
|
|
|
}
|
1998-11-08 12:30:27 +01:00
|
|
|
|
|
|
|
static LRESULT
|
2004-11-30 18:35:16 +01:00
|
|
|
MONTHCAL_Destroy(MONTHCAL_INFO *infoPtr)
|
1998-11-08 12:30:27 +01:00
|
|
|
{
|
2011-04-02 11:15:42 +02:00
|
|
|
INT i;
|
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
/* free month calendar info data */
|
2018-02-06 06:50:24 +01:00
|
|
|
heap_free(infoPtr->monthdayState);
|
|
|
|
heap_free(infoPtr->calendars);
|
2004-11-30 18:35:16 +01:00
|
|
|
SetWindowLongPtrW(infoPtr->hwndSelf, 0, 0);
|
2007-02-13 21:18:24 +01:00
|
|
|
|
2005-08-11 19:05:00 +02:00
|
|
|
CloseThemeData (GetWindowTheme (infoPtr->hwndSelf));
|
2011-03-26 13:58:59 +01:00
|
|
|
|
2011-04-02 11:33:48 +02:00
|
|
|
for (i = 0; i < BrushLast; i++) DeleteObject(infoPtr->brushes[i]);
|
|
|
|
for (i = 0; i < PenLast; i++) DeleteObject(infoPtr->pens[i]);
|
2011-04-02 11:15:42 +02:00
|
|
|
|
2018-02-06 06:50:24 +01:00
|
|
|
heap_free(infoPtr);
|
1999-11-21 03:04:09 +01:00
|
|
|
return 0;
|
1998-11-08 12:30:27 +01:00
|
|
|
}
|
|
|
|
|
2009-10-10 19:04:16 +02: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;
|
|
|
|
|
2010-08-08 13:32:52 +02:00
|
|
|
if (hdr->hwndFrom == infoPtr->hWndYearUpDown && nmud->iDelta)
|
2009-10-10 19:04:16 +02:00
|
|
|
{
|
|
|
|
/* year value limits are set up explicitly after updown creation */
|
2016-07-25 23:13:45 +02:00
|
|
|
MONTHCAL_Scroll(infoPtr, 12 * nmud->iDelta, FALSE);
|
2010-08-08 13:32:52 +02:00
|
|
|
MONTHCAL_NotifyDayState(infoPtr);
|
|
|
|
MONTHCAL_NotifySelectionChange(infoPtr);
|
2009-10-10 19:04:16 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
1998-11-08 12:30:27 +01:00
|
|
|
|
2009-10-15 18:16:27 +02:00
|
|
|
static inline BOOL
|
|
|
|
MONTHCAL_SetUnicodeFormat(MONTHCAL_INFO *infoPtr, BOOL isUnicode)
|
|
|
|
{
|
|
|
|
BOOL prev = infoPtr->isUnicode;
|
|
|
|
infoPtr->isUnicode = isUnicode;
|
|
|
|
return prev;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline BOOL
|
|
|
|
MONTHCAL_GetUnicodeFormat(const MONTHCAL_INFO *infoPtr)
|
|
|
|
{
|
|
|
|
return infoPtr->isUnicode;
|
|
|
|
}
|
|
|
|
|
1999-07-31 16:41:43 +02:00
|
|
|
static LRESULT WINAPI
|
2000-01-04 01:30:21 +01:00
|
|
|
MONTHCAL_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
1998-11-08 12:30:27 +01:00
|
|
|
{
|
2010-08-08 13:45:46 +02:00
|
|
|
MONTHCAL_INFO *infoPtr = (MONTHCAL_INFO *)GetWindowLongPtrW(hwnd, 0);
|
2004-11-30 18:35:16 +01:00
|
|
|
|
2007-05-24 16:41:17 +02:00
|
|
|
TRACE("hwnd=%p msg=%x wparam=%lx lparam=%lx\n", hwnd, uMsg, wParam, lParam);
|
2004-11-30 18:35:16 +01:00
|
|
|
|
|
|
|
if (!infoPtr && (uMsg != WM_CREATE))
|
2005-04-11 16:21:00 +02:00
|
|
|
return DefWindowProcW(hwnd, uMsg, wParam, lParam);
|
2000-01-04 01:30:21 +01:00
|
|
|
switch(uMsg)
|
1999-11-21 03:04:09 +01:00
|
|
|
{
|
|
|
|
case MCM_GETCURSEL:
|
2009-09-24 01:02:31 +02:00
|
|
|
return MONTHCAL_GetCurSel(infoPtr, (LPSYSTEMTIME)lParam);
|
1999-07-31 13:13:25 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
case MCM_SETCURSEL:
|
2009-09-24 01:02:31 +02:00
|
|
|
return MONTHCAL_SetCurSel(infoPtr, (LPSYSTEMTIME)lParam);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
case MCM_GETMAXSELCOUNT:
|
2004-11-30 18:35:16 +01:00
|
|
|
return MONTHCAL_GetMaxSelCount(infoPtr);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
case MCM_SETMAXSELCOUNT:
|
2004-11-30 18:35:16 +01:00
|
|
|
return MONTHCAL_SetMaxSelCount(infoPtr, wParam);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
case MCM_GETSELRANGE:
|
2009-09-24 01:02:31 +02:00
|
|
|
return MONTHCAL_GetSelRange(infoPtr, (LPSYSTEMTIME)lParam);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
case MCM_SETSELRANGE:
|
2009-09-24 01:02:31 +02:00
|
|
|
return MONTHCAL_SetSelRange(infoPtr, (LPSYSTEMTIME)lParam);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
case MCM_GETMONTHRANGE:
|
2009-10-04 16:27:21 +02:00
|
|
|
return MONTHCAL_GetMonthRange(infoPtr, wParam, (SYSTEMTIME*)lParam);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
case MCM_SETDAYSTATE:
|
2009-09-24 01:02:31 +02:00
|
|
|
return MONTHCAL_SetDayState(infoPtr, (INT)wParam, (LPMONTHDAYSTATE)lParam);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
case MCM_GETMINREQRECT:
|
2009-09-24 01:02:31 +02:00
|
|
|
return MONTHCAL_GetMinReqRect(infoPtr, (LPRECT)lParam);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
case MCM_GETCOLOR:
|
2004-11-30 18:35:16 +01:00
|
|
|
return MONTHCAL_GetColor(infoPtr, wParam);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
case MCM_SETCOLOR:
|
2009-09-24 01:02:31 +02:00
|
|
|
return MONTHCAL_SetColor(infoPtr, wParam, (COLORREF)lParam);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
case MCM_GETTODAY:
|
2009-09-24 01:02:31 +02:00
|
|
|
return MONTHCAL_GetToday(infoPtr, (LPSYSTEMTIME)lParam);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
case MCM_SETTODAY:
|
2009-09-24 01:02:31 +02:00
|
|
|
return MONTHCAL_SetToday(infoPtr, (LPSYSTEMTIME)lParam);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
case MCM_HITTEST:
|
2009-09-24 01:02:31 +02:00
|
|
|
return MONTHCAL_HitTest(infoPtr, (PMCHITTESTINFO)lParam);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
case MCM_GETFIRSTDAYOFWEEK:
|
2004-11-30 18:35:16 +01:00
|
|
|
return MONTHCAL_GetFirstDayOfWeek(infoPtr);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
case MCM_SETFIRSTDAYOFWEEK:
|
2009-09-24 01:02:31 +02:00
|
|
|
return MONTHCAL_SetFirstDayOfWeek(infoPtr, (INT)lParam);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
case MCM_GETRANGE:
|
2009-09-24 01:02:31 +02:00
|
|
|
return MONTHCAL_GetRange(infoPtr, (LPSYSTEMTIME)lParam);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
case MCM_SETRANGE:
|
2009-09-24 01:02:31 +02:00
|
|
|
return MONTHCAL_SetRange(infoPtr, (SHORT)wParam, (LPSYSTEMTIME)lParam);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
case MCM_GETMONTHDELTA:
|
2004-11-30 18:35:16 +01:00
|
|
|
return MONTHCAL_GetMonthDelta(infoPtr);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
case MCM_SETMONTHDELTA:
|
2004-11-30 18:35:16 +01:00
|
|
|
return MONTHCAL_SetMonthDelta(infoPtr, wParam);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
case MCM_GETMAXTODAYWIDTH:
|
2004-11-30 18:35:16 +01:00
|
|
|
return MONTHCAL_GetMaxTodayWidth(infoPtr);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2009-10-15 18:16:27 +02:00
|
|
|
case MCM_SETUNICODEFORMAT:
|
|
|
|
return MONTHCAL_SetUnicodeFormat(infoPtr, (BOOL)wParam);
|
|
|
|
|
|
|
|
case MCM_GETUNICODEFORMAT:
|
|
|
|
return MONTHCAL_GetUnicodeFormat(infoPtr);
|
|
|
|
|
2011-09-20 07:57:28 +02:00
|
|
|
case MCM_GETCALENDARCOUNT:
|
|
|
|
return MONTHCAL_GetCalCount(infoPtr);
|
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
case WM_GETDLGCODE:
|
|
|
|
return DLGC_WANTARROWS | DLGC_WANTCHARS;
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2009-09-28 20:04:41 +02:00
|
|
|
case WM_RBUTTONUP:
|
|
|
|
return MONTHCAL_RButtonUp(infoPtr, lParam);
|
2000-10-15 02:27:28 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
case WM_LBUTTONDOWN:
|
2004-11-30 18:35:16 +01:00
|
|
|
return MONTHCAL_LButtonDown(infoPtr, lParam);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
case WM_MOUSEMOVE:
|
2008-09-07 16:20:38 +02:00
|
|
|
return MONTHCAL_MouseMove(infoPtr, lParam);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
case WM_LBUTTONUP:
|
2004-11-30 18:35:16 +01:00
|
|
|
return MONTHCAL_LButtonUp(infoPtr, lParam);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
case WM_PAINT:
|
2009-09-25 01:43:38 +02:00
|
|
|
return MONTHCAL_Paint(infoPtr, (HDC)wParam);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2009-10-13 02:21:27 +02:00
|
|
|
case WM_PRINTCLIENT:
|
|
|
|
return MONTHCAL_PrintClient(infoPtr, (HDC)wParam, (DWORD)lParam);
|
|
|
|
|
2009-10-13 02:16:31 +02:00
|
|
|
case WM_ERASEBKGND:
|
|
|
|
return MONTHCAL_EraseBkgnd(infoPtr, (HDC)wParam);
|
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
case WM_SETFOCUS:
|
2004-11-30 18:35:16 +01:00
|
|
|
return MONTHCAL_SetFocus(infoPtr);
|
2000-01-04 01:30:21 +01:00
|
|
|
|
|
|
|
case WM_SIZE:
|
2004-11-30 18:35:16 +01:00
|
|
|
return MONTHCAL_Size(infoPtr, (SHORT)LOWORD(lParam), (SHORT)HIWORD(lParam));
|
1998-11-08 12:30:27 +01:00
|
|
|
|
2009-10-10 19:04:16 +02:00
|
|
|
case WM_NOTIFY:
|
|
|
|
return MONTHCAL_Notify(infoPtr, (NMHDR*)lParam);
|
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
case WM_CREATE:
|
2009-09-24 01:02:31 +02:00
|
|
|
return MONTHCAL_Create(hwnd, (LPCREATESTRUCTW)lParam);
|
1998-11-08 12:30:27 +01:00
|
|
|
|
2004-11-30 18:35:16 +01:00
|
|
|
case WM_SETFONT:
|
|
|
|
return MONTHCAL_SetFont(infoPtr, (HFONT)wParam, (BOOL)lParam);
|
|
|
|
|
|
|
|
case WM_GETFONT:
|
|
|
|
return MONTHCAL_GetFont(infoPtr);
|
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
case WM_TIMER:
|
2004-11-30 18:35:16 +01:00
|
|
|
return MONTHCAL_Timer(infoPtr, wParam);
|
2005-08-11 19:05:00 +02:00
|
|
|
|
|
|
|
case WM_THEMECHANGED:
|
|
|
|
return theme_changed (infoPtr);
|
1999-07-31 13:13:25 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
case WM_DESTROY:
|
2004-11-30 18:35:16 +01:00
|
|
|
return MONTHCAL_Destroy(infoPtr);
|
1998-11-08 12:30:27 +01:00
|
|
|
|
2009-05-18 17:03:40 +02:00
|
|
|
case WM_SYSCOLORCHANGE:
|
|
|
|
COMCTL32_RefreshSysColors();
|
|
|
|
return 0;
|
|
|
|
|
2009-09-08 08:44:55 +02:00
|
|
|
case WM_STYLECHANGED:
|
|
|
|
return MONTHCAL_StyleChanged(infoPtr, wParam, (LPSTYLESTRUCT)lParam);
|
|
|
|
|
2009-10-01 20:49:02 +02:00
|
|
|
case WM_STYLECHANGING:
|
|
|
|
return MONTHCAL_StyleChanging(infoPtr, wParam, (LPSTYLESTRUCT)lParam);
|
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
default:
|
2008-07-22 00:18:09 +02:00
|
|
|
if ((uMsg >= WM_USER) && (uMsg < WM_APP) && !COMCTL32_IsReflectedMessage(uMsg))
|
2007-05-24 16:41:17 +02:00
|
|
|
ERR( "unknown msg %04x wp=%08lx lp=%08lx\n", uMsg, wParam, lParam);
|
2005-04-11 16:21:00 +02:00
|
|
|
return DefWindowProcW(hwnd, uMsg, wParam, lParam);
|
1999-11-21 03:04:09 +01:00
|
|
|
}
|
1998-11-08 12:30:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-07-31 13:13:25 +02:00
|
|
|
void
|
2000-01-04 01:30:21 +01:00
|
|
|
MONTHCAL_Register(void)
|
1998-11-08 12:30:27 +01:00
|
|
|
{
|
2005-04-11 16:21:00 +02:00
|
|
|
WNDCLASSW wndClass;
|
1999-11-21 03:04:09 +01:00
|
|
|
|
2005-04-11 16:21:00 +02:00
|
|
|
ZeroMemory(&wndClass, sizeof(WNDCLASSW));
|
1999-11-21 03:04:09 +01:00
|
|
|
wndClass.style = CS_GLOBALCLASS;
|
2004-11-06 04:49:03 +01:00
|
|
|
wndClass.lpfnWndProc = MONTHCAL_WindowProc;
|
1999-11-21 03:04:09 +01:00
|
|
|
wndClass.cbClsExtra = 0;
|
|
|
|
wndClass.cbWndExtra = sizeof(MONTHCAL_INFO *);
|
2005-04-11 16:21:00 +02:00
|
|
|
wndClass.hCursor = LoadCursorW(0, (LPWSTR)IDC_ARROW);
|
1999-11-21 03:04:09 +01:00
|
|
|
wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
|
2005-04-11 16:21:00 +02:00
|
|
|
wndClass.lpszClassName = MONTHCAL_CLASSW;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2005-04-11 16:21:00 +02:00
|
|
|
RegisterClassW(&wndClass);
|
1998-11-08 12:30:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-07-31 13:13:25 +02:00
|
|
|
void
|
2000-01-04 01:30:21 +01:00
|
|
|
MONTHCAL_Unregister(void)
|
1998-11-08 12:30:27 +01:00
|
|
|
{
|
2005-04-11 16:21:00 +02:00
|
|
|
UnregisterClassW(MONTHCAL_CLASSW, NULL);
|
1998-11-08 12:30:27 +01:00
|
|
|
}
|