1999-07-31 13:13:25 +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>
|
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
|
|
|
*
|
2004-10-21 21:52:28 +02:00
|
|
|
* NOTE
|
|
|
|
*
|
|
|
|
* This code was audited for completeness against the documented features
|
|
|
|
* of Comctl32.dll version 6.0 on Oct. 20, 2004, by Dimitrie O. Paun.
|
|
|
|
*
|
|
|
|
* Unless otherwise noted, we believe this code to be complete, as per
|
|
|
|
* the specification mentioned above.
|
|
|
|
* If you discover missing features, or bugs, please note them below.
|
|
|
|
*
|
1998-11-08 12:30:27 +01:00
|
|
|
* TODO:
|
2004-10-21 21:52:28 +02:00
|
|
|
* -- MCM_[GS]ETUNICODEFORMAT
|
|
|
|
* -- MONTHCAL_GetMonthRange
|
|
|
|
* -- handle resources better (doesn't work now);
|
|
|
|
* -- take care of internationalization.
|
|
|
|
* -- keyboard handling.
|
|
|
|
* -- GetRange: At the moment, we copy ranges anyway, regardless of
|
2005-03-23 14:15:18 +01:00
|
|
|
* infoPtr->rangeValid; an invalid range is simply filled
|
2004-10-21 21:52:28 +02:00
|
|
|
* with zeros in SetRange. Is this the right behavior?
|
|
|
|
* -- 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"
|
|
|
|
#include "tmschema.h"
|
2005-04-11 16:21:00 +02:00
|
|
|
#include "wine/unicode.h"
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.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 */
|
|
|
|
#define MC_NEXTMONTHDELAY 350 /* when continuously pressing `next */
|
|
|
|
/* month', wait 500 ms before going */
|
|
|
|
/* to the next month */
|
|
|
|
#define MC_NEXTMONTHTIMER 1 /* Timer ID's */
|
2002-06-01 01:06:46 +02:00
|
|
|
#define MC_PREVMONTHTIMER 2
|
2000-08-09 02:41:17 +02:00
|
|
|
|
2005-04-11 16:21:00 +02:00
|
|
|
#define countof(arr) (sizeof(arr)/sizeof(arr[0]))
|
|
|
|
|
2000-08-09 02:41:17 +02:00
|
|
|
typedef struct
|
|
|
|
{
|
2004-11-08 21:27:02 +01:00
|
|
|
HWND hwndSelf;
|
2000-08-09 02:41:17 +02:00
|
|
|
COLORREF bk;
|
|
|
|
COLORREF txt;
|
|
|
|
COLORREF titlebk;
|
|
|
|
COLORREF titletxt;
|
|
|
|
COLORREF monthbk;
|
|
|
|
COLORREF trailingtxt;
|
|
|
|
HFONT hFont;
|
|
|
|
HFONT hBoldFont;
|
|
|
|
int textHeight;
|
|
|
|
int textWidth;
|
|
|
|
int height_increment;
|
|
|
|
int width_increment;
|
|
|
|
int firstDayplace; /* place of the first day of the current month */
|
|
|
|
int delta; /* scroll rate; # of months that the */
|
|
|
|
/* control moves when user clicks a scroll button */
|
|
|
|
int visible; /* # of months visible */
|
|
|
|
int firstDay; /* Start month calendar with firstDay's day */
|
2007-04-10 03:25:41 +02:00
|
|
|
int firstDayHighWord; /* High word only used externally */
|
2000-08-09 02:41:17 +02:00
|
|
|
int monthRange;
|
|
|
|
MONTHDAYSTATE *monthdayState;
|
|
|
|
SYSTEMTIME todaysDate;
|
|
|
|
DWORD currentMonth;
|
|
|
|
DWORD currentYear;
|
|
|
|
int status; /* See MC_SEL flags */
|
|
|
|
int curSelDay; /* current selected day */
|
|
|
|
int firstSelDay; /* first selected day */
|
|
|
|
int maxSelCount;
|
|
|
|
SYSTEMTIME minSel;
|
|
|
|
SYSTEMTIME maxSel;
|
|
|
|
DWORD rangeValid;
|
|
|
|
SYSTEMTIME minDate;
|
|
|
|
SYSTEMTIME maxDate;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-08-09 02:41:17 +02:00
|
|
|
RECT title; /* rect for the header above the calendar */
|
|
|
|
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-08-09 02:41:17 +02:00
|
|
|
RECT titlemonth; /* the `month name' txt in the header */
|
|
|
|
RECT titleyear; /* the `year number' txt in the header */
|
2000-10-15 02:27:28 +02:00
|
|
|
RECT wdays; /* week days at top */
|
|
|
|
RECT days; /* calendar area */
|
2000-08-09 02:41:17 +02:00
|
|
|
RECT weeknums; /* week numbers at left side */
|
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 */
|
2000-08-09 02:41:17 +02:00
|
|
|
} MONTHCAL_INFO, *LPMONTHCAL_INFO;
|
|
|
|
|
|
|
|
|
2005-04-14 13:31:17 +02:00
|
|
|
/* Offsets of days in the week to the weekday of january 1 in a leap year */
|
2000-01-12 06:01:02 +01:00
|
|
|
static const int DayOfWeekTable[] = {0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4};
|
1999-07-10 14:00:04 +02:00
|
|
|
|
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
|
|
|
|
2004-08-25 19:33:01 +02:00
|
|
|
#define MONTHCAL_GetInfoPtr(hwnd) ((MONTHCAL_INFO *)GetWindowLongPtrW(hwnd, 0))
|
1998-11-08 12:30:27 +01:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
/* helper functions */
|
|
|
|
|
2000-10-15 02:27:28 +02:00
|
|
|
/* returns the number of days in any given month, checking for leap days */
|
1999-11-21 03:04:09 +01: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
|
|
|
{
|
2005-06-09 11:50:56 +02:00
|
|
|
const int mdays[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 0};
|
2001-05-18 23:01:38 +02:00
|
|
|
/*Wrap around, this eases handling*/
|
2000-10-15 02:27:28 +02:00
|
|
|
if(month == 0)
|
|
|
|
month = 12;
|
|
|
|
if(month == 13)
|
|
|
|
month = 1;
|
|
|
|
|
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
|
|
|
|
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
/* make sure that time is valid */
|
2002-06-01 01:06:46 +02:00
|
|
|
static int MONTHCAL_ValidateTime(SYSTEMTIME time)
|
1999-07-10 14:00:04 +02:00
|
|
|
{
|
2006-02-14 17:12:45 +01:00
|
|
|
if(time.wMonth < 1 || time.wMonth > 12 ) return FALSE;
|
2000-01-04 01:30:21 +01:00
|
|
|
if(time.wDayOfWeek > 6) return FALSE;
|
|
|
|
if(time.wDay > MONTHCAL_MonthLength(time.wMonth, time.wYear))
|
|
|
|
return FALSE;
|
|
|
|
|
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
|
|
|
/* 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
|
|
|
*/
|
|
|
|
|
2005-04-14 13:31:17 +02:00
|
|
|
/* returns the day in the week(0 == sunday, 6 == saturday) */
|
1999-11-21 03:04:09 +01:00
|
|
|
/* day(1 == 1st, 2 == 2nd... etc), year is the year value */
|
2000-08-09 02:41:17 +02:00
|
|
|
static int MONTHCAL_CalculateDayOfWeek(DWORD day, DWORD month, DWORD year)
|
1999-07-10 14:00:04 +02:00
|
|
|
{
|
2000-01-04 01:30:21 +01:00
|
|
|
year-=(month < 3);
|
1999-11-21 03:04:09 +01:00
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
return((year + year/4 - year/100 + year/400 +
|
2005-04-14 13:31:17 +02:00
|
|
|
DayOfWeekTable[month-1] + day ) % 7);
|
1999-07-10 14:00:04 +02:00
|
|
|
}
|
|
|
|
|
2000-10-15 02:27:28 +02:00
|
|
|
/* From a given point, calculate the row (weekpos), column(daypos)
|
|
|
|
and day in the calendar. day== 0 mean the last day of tha last month
|
|
|
|
*/
|
2007-03-29 23:09:32 +02:00
|
|
|
static int MONTHCAL_CalcDayFromPos(const MONTHCAL_INFO *infoPtr, int x, int y,
|
2002-06-01 01:06:46 +02:00
|
|
|
int *daypos,int *weekpos)
|
1999-07-10 14:00:04 +02:00
|
|
|
{
|
2000-10-15 02:27:28 +02:00
|
|
|
int retval, firstDay;
|
2004-11-08 21:27:02 +01:00
|
|
|
RECT rcClient;
|
|
|
|
|
|
|
|
GetClientRect(infoPtr->hwndSelf, &rcClient);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
/* if the point is outside the x bounds of the window put
|
2005-05-30 11:56:56 +02:00
|
|
|
it at the boundary */
|
2004-11-08 21:27:02 +01:00
|
|
|
if (x > rcClient.right)
|
|
|
|
x = rcClient.right;
|
|
|
|
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2000-10-15 02:27:28 +02:00
|
|
|
*daypos = (x - infoPtr->days.left ) / infoPtr->width_increment;
|
|
|
|
*weekpos = (y - infoPtr->days.top ) / infoPtr->height_increment;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-10-15 02:27:28 +02:00
|
|
|
firstDay = (MONTHCAL_CalculateDayOfWeek(1, infoPtr->currentMonth, infoPtr->currentYear)+6 - infoPtr->firstDay)%7;
|
|
|
|
retval = *daypos + (7 * *weekpos) - firstDay;
|
1999-11-21 03:04:09 +01:00
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* day is the day of the month, 1 == 1st day of the month */
|
|
|
|
/* sets x and y to be the position of the day */
|
2000-10-15 02:27:28 +02:00
|
|
|
/* x == day, y == week where(0,0) == firstDay, 1st week */
|
2007-03-29 23:09:32 +02:00
|
|
|
static void MONTHCAL_CalcDayXY(const MONTHCAL_INFO *infoPtr, int day, int month,
|
1999-07-10 14:00:04 +02:00
|
|
|
int *x, int *y)
|
|
|
|
{
|
2000-01-04 01:30:21 +01:00
|
|
|
int firstDay, prevMonth;
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2000-10-15 02:27:28 +02:00
|
|
|
firstDay = (MONTHCAL_CalculateDayOfWeek(1, infoPtr->currentMonth, infoPtr->currentYear) +6 - infoPtr->firstDay)%7;
|
1999-11-21 03:04:09 +01:00
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
if(month==infoPtr->currentMonth) {
|
1999-11-21 03:04:09 +01:00
|
|
|
*x = (day + firstDay) % 7;
|
|
|
|
*y = (day + firstDay - *x) / 7;
|
|
|
|
return;
|
|
|
|
}
|
2000-01-04 01:30:21 +01:00
|
|
|
if(month < infoPtr->currentMonth) {
|
1999-11-21 03:04:09 +01:00
|
|
|
prevMonth = month - 1;
|
2000-01-04 01:30:21 +01:00
|
|
|
if(prevMonth==0)
|
1999-11-21 03:04:09 +01:00
|
|
|
prevMonth = 12;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
*x = (MONTHCAL_MonthLength(prevMonth, infoPtr->currentYear) - firstDay) % 7;
|
|
|
|
*y = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
*y = MONTHCAL_MonthLength(month, infoPtr->currentYear - 1) / 7;
|
|
|
|
*x = (day + firstDay + MONTHCAL_MonthLength(month,
|
|
|
|
infoPtr->currentYear)) % 7;
|
1999-07-10 14:00:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
/* x: column(day), y: row(week) */
|
2007-03-29 23:09:32 +02:00
|
|
|
static void MONTHCAL_CalcDayRect(const MONTHCAL_INFO *infoPtr, RECT *r, int x, int y)
|
1999-07-10 14:00:04 +02:00
|
|
|
{
|
2000-10-15 02:27:28 +02:00
|
|
|
r->left = infoPtr->days.left + x * infoPtr->width_increment;
|
1999-11-21 03:04:09 +01:00
|
|
|
r->right = r->left + infoPtr->width_increment;
|
2000-10-15 02:27:28 +02:00
|
|
|
r->top = infoPtr->days.top + y * infoPtr->height_increment;
|
1999-07-10 14:00:04 +02:00
|
|
|
r->bottom = r->top + infoPtr->textHeight;
|
|
|
|
}
|
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
|
|
|
|
/* sets the RECT struct r to the rectangle around the day and month */
|
|
|
|
/* day is the day value of the month(1 == 1st), month is the month */
|
|
|
|
/* value(january == 1, december == 12) */
|
2007-03-29 23:09:32 +02:00
|
|
|
static inline void MONTHCAL_CalcPosFromDay(const MONTHCAL_INFO *infoPtr,
|
1999-07-10 14:00:04 +02:00
|
|
|
int day, int month, RECT *r)
|
|
|
|
{
|
2000-01-04 01:30:21 +01:00
|
|
|
int x, y;
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
MONTHCAL_CalcDayXY(infoPtr, day, month, &x, &y);
|
|
|
|
MONTHCAL_CalcDayRect(infoPtr, r, x, y);
|
1999-07-10 14:00:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
/* day is the day in the month(1 == 1st of the month) */
|
|
|
|
/* month is the month value(1 == january, 12 == december) */
|
2007-03-29 23:09:32 +02:00
|
|
|
static void MONTHCAL_CircleDay(const MONTHCAL_INFO *infoPtr, HDC hdc, int day, int month)
|
1999-07-10 14:00:04 +02:00
|
|
|
{
|
2000-01-04 01:30:21 +01:00
|
|
|
HPEN hRedPen = CreatePen(PS_SOLID, 2, RGB(255, 0, 0));
|
|
|
|
HPEN hOldPen2 = SelectObject(hdc, hRedPen);
|
1999-11-21 03:04:09 +01:00
|
|
|
POINT points[13];
|
2000-01-04 01:30:21 +01:00
|
|
|
int x, y;
|
1999-11-21 03:04:09 +01:00
|
|
|
RECT day_rect;
|
1999-07-10 14:00:04 +02:00
|
|
|
|
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
MONTHCAL_CalcPosFromDay(infoPtr, day, month, &day_rect);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
x = day_rect.left;
|
|
|
|
y = day_rect.top;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
points[0].x = x;
|
|
|
|
points[0].y = y - 1;
|
|
|
|
points[1].x = x + 0.8 * infoPtr->width_increment;
|
|
|
|
points[1].y = y - 1;
|
|
|
|
points[2].x = x + 0.9 * infoPtr->width_increment;
|
|
|
|
points[2].y = y;
|
|
|
|
points[3].x = x + infoPtr->width_increment;
|
2000-10-15 02:27:28 +02:00
|
|
|
points[3].y = y + 0.5 * infoPtr->height_increment;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
points[4].x = x + infoPtr->width_increment;
|
2000-10-15 02:27:28 +02:00
|
|
|
points[4].y = y + 0.9 * infoPtr->height_increment;
|
1999-11-21 03:04:09 +01:00
|
|
|
points[5].x = x + 0.6 * infoPtr->width_increment;
|
2000-10-15 02:27:28 +02:00
|
|
|
points[5].y = y + 0.9 * infoPtr->height_increment;
|
1999-11-21 03:04:09 +01:00
|
|
|
points[6].x = x + 0.5 * infoPtr->width_increment;
|
2000-10-15 02:27:28 +02:00
|
|
|
points[6].y = y + 0.9 * infoPtr->height_increment; /* bring the bottom up just
|
1999-11-21 03:04:09 +01:00
|
|
|
a hair to fit inside the day rectangle */
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
points[7].x = x + 0.2 * infoPtr->width_increment;
|
2000-10-15 02:27:28 +02:00
|
|
|
points[7].y = y + 0.8 * infoPtr->height_increment;
|
1999-11-21 03:04:09 +01:00
|
|
|
points[8].x = x + 0.1 * infoPtr->width_increment;
|
2000-10-15 02:27:28 +02:00
|
|
|
points[8].y = y + 0.8 * infoPtr->height_increment;
|
1999-11-21 03:04:09 +01:00
|
|
|
points[9].x = x;
|
2000-10-15 02:27:28 +02:00
|
|
|
points[9].y = y + 0.5 * infoPtr->height_increment;
|
1999-11-21 03:04:09 +01:00
|
|
|
|
|
|
|
points[10].x = x + 0.1 * infoPtr->width_increment;
|
2000-10-15 02:27:28 +02:00
|
|
|
points[10].y = y + 0.2 * infoPtr->height_increment;
|
1999-11-21 03:04:09 +01:00
|
|
|
points[11].x = x + 0.2 * infoPtr->width_increment;
|
2000-10-15 02:27:28 +02:00
|
|
|
points[11].y = y + 0.3 * infoPtr->height_increment;
|
|
|
|
points[12].x = x + 0.4 * infoPtr->width_increment;
|
|
|
|
points[12].y = y + 0.2 * infoPtr->height_increment;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
PolyBezier(hdc, points, 13);
|
|
|
|
DeleteObject(hRedPen);
|
|
|
|
SelectObject(hdc, hOldPen2);
|
1999-11-21 03:04:09 +01:00
|
|
|
}
|
1999-07-10 14:00:04 +02:00
|
|
|
|
|
|
|
|
2007-03-29 23:09:32 +02:00
|
|
|
static void MONTHCAL_DrawDay(const MONTHCAL_INFO *infoPtr, HDC hdc, int day, int month,
|
2000-05-30 22:06:33 +02:00
|
|
|
int x, int y, int bold)
|
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];
|
1999-07-10 14:00:04 +02:00
|
|
|
RECT r;
|
2000-01-04 01:30:21 +01:00
|
|
|
static int haveBoldFont, haveSelectedDay = FALSE;
|
1999-11-21 03:04:09 +01:00
|
|
|
HBRUSH hbr;
|
|
|
|
COLORREF oldCol = 0;
|
|
|
|
COLORREF oldBk = 0;
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2005-04-11 16:21:00 +02:00
|
|
|
wsprintfW(buf, fmtW, day);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
/* No need to check styles: when selection is not valid, it is set to zero.
|
1999-07-10 14:00:04 +02:00
|
|
|
* 1<day<31, so evertyhing's OK.
|
|
|
|
*/
|
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
MONTHCAL_CalcDayRect(infoPtr, &r, x, y);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
if((day>=infoPtr->minSel.wDay) && (day<=infoPtr->maxSel.wDay)
|
1999-11-21 03:04:09 +01:00
|
|
|
&& (month==infoPtr->currentMonth)) {
|
|
|
|
HRGN hrgn;
|
|
|
|
RECT r2;
|
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
TRACE("%d %d %d\n",day, infoPtr->minSel.wDay, infoPtr->maxSel.wDay);
|
2006-10-13 15:34:21 +02:00
|
|
|
TRACE("%d %d %d %d\n", r.left, r.top, r.right, r.bottom);
|
2000-01-04 01:30:21 +01:00
|
|
|
oldCol = SetTextColor(hdc, infoPtr->monthbk);
|
|
|
|
oldBk = SetBkColor(hdc, infoPtr->trailingtxt);
|
|
|
|
hbr = GetSysColorBrush(COLOR_GRAYTEXT);
|
|
|
|
hrgn = CreateEllipticRgn(r.left, r.top, r.right, r.bottom);
|
|
|
|
FillRgn(hdc, hrgn, hbr);
|
1999-11-21 03:04:09 +01:00
|
|
|
|
|
|
|
/* FIXME: this may need to be changed now b/c of the other
|
|
|
|
drawing changes 11/3/99 CMM */
|
|
|
|
r2.left = r.left - 0.25 * infoPtr->textWidth;
|
|
|
|
r2.top = r.top;
|
|
|
|
r2.right = r.left + 0.5 * infoPtr->textWidth;
|
|
|
|
r2.bottom = r.bottom;
|
2000-01-04 01:30:21 +01:00
|
|
|
if(haveSelectedDay) FillRect(hdc, &r2, hbr);
|
1999-11-21 03:04:09 +01:00
|
|
|
haveSelectedDay = TRUE;
|
|
|
|
} else {
|
|
|
|
haveSelectedDay = FALSE;
|
|
|
|
}
|
1999-07-10 14:00:04 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
/* need to add some code for multiple selections */
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
if((bold) &&(!haveBoldFont)) {
|
|
|
|
SelectObject(hdc, infoPtr->hBoldFont);
|
1999-11-21 03:04:09 +01:00
|
|
|
haveBoldFont = TRUE;
|
|
|
|
}
|
2000-01-04 01:30:21 +01:00
|
|
|
if((!bold) &&(haveBoldFont)) {
|
|
|
|
SelectObject(hdc, infoPtr->hFont);
|
1999-11-21 03:04:09 +01:00
|
|
|
haveBoldFont = FALSE;
|
|
|
|
}
|
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
if(haveSelectedDay) {
|
1999-11-21 03:04:09 +01:00
|
|
|
SetTextColor(hdc, oldCol);
|
|
|
|
SetBkColor(hdc, oldBk);
|
|
|
|
}
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2000-10-15 02:27:28 +02:00
|
|
|
SetBkMode(hdc,TRANSPARENT);
|
2005-04-11 16:21:00 +02:00
|
|
|
DrawTextW(hdc, buf, -1, &r, DT_CENTER | DT_VCENTER | DT_SINGLELINE );
|
1999-07-10 14:00:04 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
/* draw a rectangle around the currently selected days text */
|
2005-01-11 11:43:03 +01:00
|
|
|
if((day==infoPtr->curSelDay) && (month==infoPtr->currentMonth))
|
|
|
|
DrawFocusRect(hdc, &r);
|
1999-07-10 14:00:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-03-29 23:09:32 +02:00
|
|
|
static void paint_button (const MONTHCAL_INFO *infoPtr, HDC hdc, BOOL btnNext,
|
2005-08-11 19:05:00 +02:00
|
|
|
BOOL pressed, RECT* r)
|
|
|
|
{
|
|
|
|
HTHEME theme = GetWindowTheme (infoPtr->hwndSelf);
|
|
|
|
|
|
|
|
if (theme)
|
|
|
|
{
|
|
|
|
static const int states[] = {
|
|
|
|
/* Prev button */
|
|
|
|
ABS_LEFTNORMAL, ABS_LEFTPRESSED, ABS_LEFTDISABLED,
|
|
|
|
/* Next button */
|
|
|
|
ABS_RIGHTNORMAL, ABS_RIGHTPRESSED, ABS_RIGHTDISABLED
|
|
|
|
};
|
|
|
|
int stateNum = btnNext ? 3 : 0;
|
|
|
|
if (pressed)
|
|
|
|
stateNum += 1;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DWORD dwStyle = GetWindowLongW(infoPtr->hwndSelf, GWL_STYLE);
|
|
|
|
if (dwStyle & WS_DISABLED) stateNum += 2;
|
|
|
|
}
|
|
|
|
DrawThemeBackground (theme, hdc, SBP_ARROWBTN, states[stateNum], r, NULL);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int style = btnNext ? DFCS_SCROLLRIGHT : DFCS_SCROLLLEFT;
|
|
|
|
if (pressed)
|
|
|
|
style |= DFCS_PUSHED;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DWORD dwStyle = GetWindowLongW(infoPtr->hwndSelf, GWL_STYLE);
|
|
|
|
if (dwStyle & WS_DISABLED) style |= DFCS_INACTIVE;
|
|
|
|
}
|
|
|
|
|
|
|
|
DrawFrameControl(hdc, r, DFC_SCROLL, style);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-03-29 23:09:32 +02:00
|
|
|
static void MONTHCAL_Refresh(MONTHCAL_INFO *infoPtr, HDC hdc, const PAINTSTRUCT *ps)
|
1999-07-10 14:00:04 +02:00
|
|
|
{
|
2005-04-11 16:21:00 +02:00
|
|
|
static const WCHAR todayW[] = { 'T','o','d','a','y',':',0 };
|
|
|
|
static const WCHAR fmt1W[] = { '%','s',' ','%','l','d',0 };
|
|
|
|
static const WCHAR fmt2W[] = { '%','s',' ','%','s',0 };
|
|
|
|
static const WCHAR fmt3W[] = { '%','d',0 };
|
1999-11-21 03:04:09 +01:00
|
|
|
RECT *title=&infoPtr->title;
|
|
|
|
RECT *prev=&infoPtr->titlebtnprev;
|
|
|
|
RECT *next=&infoPtr->titlebtnnext;
|
|
|
|
RECT *titlemonth=&infoPtr->titlemonth;
|
|
|
|
RECT *titleyear=&infoPtr->titleyear;
|
2000-01-04 01:30:21 +01:00
|
|
|
RECT dayrect;
|
|
|
|
RECT *days=&dayrect;
|
2000-10-15 02:27:28 +02:00
|
|
|
RECT rtoday;
|
|
|
|
int i, j, m, mask, day, firstDay, weeknum, weeknum1,prevMonth;
|
2000-01-04 01:30:21 +01:00
|
|
|
int textHeight = infoPtr->textHeight, textWidth = infoPtr->textWidth;
|
1999-11-21 03:04:09 +01:00
|
|
|
SIZE size;
|
|
|
|
HBRUSH hbr;
|
|
|
|
HFONT currentFont;
|
2005-04-11 16:21:00 +02:00
|
|
|
WCHAR buf[20];
|
|
|
|
WCHAR buf1[20];
|
|
|
|
WCHAR buf2[32];
|
2000-01-04 01:30:21 +01:00
|
|
|
COLORREF oldTextColor, oldBkColor;
|
2004-11-30 18:35:16 +01:00
|
|
|
DWORD dwStyle = GetWindowLongW(infoPtr->hwndSelf, GWL_STYLE);
|
2000-05-30 22:06:33 +02:00
|
|
|
RECT rcTemp;
|
|
|
|
RECT rcDay; /* used in MONTHCAL_CalcDayRect() */
|
2000-10-15 02:27:28 +02:00
|
|
|
SYSTEMTIME localtime;
|
|
|
|
int startofprescal;
|
1999-11-21 03:04:09 +01:00
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
oldTextColor = SetTextColor(hdc, GetSysColor(COLOR_WINDOWTEXT));
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2000-07-08 13:43:57 +02:00
|
|
|
/* fill background */
|
|
|
|
hbr = CreateSolidBrush (infoPtr->bk);
|
2004-11-08 21:27:02 +01:00
|
|
|
FillRect(hdc, &ps->rcPaint, hbr);
|
2002-06-01 01:06:46 +02:00
|
|
|
DeleteObject(hbr);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
/* draw header */
|
2000-05-30 22:06:33 +02:00
|
|
|
if(IntersectRect(&rcTemp, &(ps->rcPaint), title))
|
|
|
|
{
|
|
|
|
hbr = CreateSolidBrush(infoPtr->titlebk);
|
|
|
|
FillRect(hdc, title, hbr);
|
2000-07-08 13:43:57 +02:00
|
|
|
DeleteObject(hbr);
|
2000-05-30 22:06:33 +02:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
/* if the previous button is pressed draw it depressed */
|
2000-05-30 22:06:33 +02:00
|
|
|
if(IntersectRect(&rcTemp, &(ps->rcPaint), prev))
|
2005-08-11 19:05:00 +02:00
|
|
|
paint_button (infoPtr, hdc, FALSE, infoPtr->status & MC_PREVPRESSED, prev);
|
1999-11-21 03:04:09 +01:00
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
/* if next button is depressed draw it depressed */
|
2000-05-30 22:06:33 +02:00
|
|
|
if(IntersectRect(&rcTemp, &(ps->rcPaint), next))
|
2005-08-11 19:05:00 +02:00
|
|
|
paint_button (infoPtr, hdc, TRUE, infoPtr->status & MC_NEXTPRESSED, next);
|
1999-11-21 03:04:09 +01:00
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
oldBkColor = SetBkColor(hdc, infoPtr->titlebk);
|
1999-11-21 03:04:09 +01:00
|
|
|
SetTextColor(hdc, infoPtr->titletxt);
|
2000-01-04 01:30:21 +01:00
|
|
|
currentFont = SelectObject(hdc, infoPtr->hBoldFont);
|
1999-11-21 03:04:09 +01:00
|
|
|
|
2005-04-11 16:21:00 +02:00
|
|
|
GetLocaleInfoW( LOCALE_USER_DEFAULT,LOCALE_SMONTHNAME1+infoPtr->currentMonth -1,
|
|
|
|
buf1,countof(buf1));
|
|
|
|
wsprintfW(buf, fmt1W, buf1, infoPtr->currentYear);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2005-04-20 14:51:37 +02:00
|
|
|
if(IntersectRect(&rcTemp, &(ps->rcPaint), title))
|
2000-05-30 22:06:33 +02:00
|
|
|
{
|
2005-04-20 14:51:37 +02:00
|
|
|
DrawTextW(hdc, buf, strlenW(buf), title,
|
2000-01-04 01:30:21 +01:00
|
|
|
DT_CENTER | DT_VCENTER | DT_SINGLELINE);
|
2000-05-30 22:06:33 +02:00
|
|
|
}
|
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
/* titlemonth left/right contained rect for whole titletxt('June 1999')
|
1999-07-10 14:00:04 +02:00
|
|
|
* MCM_HitTestInfo wants month & year rects, so prepare these now.
|
2002-06-01 01:06:46 +02:00
|
|
|
*(no, we can't draw them separately; the whole text is centered)
|
1999-07-10 14:00:04 +02:00
|
|
|
*/
|
2005-04-11 16:21:00 +02:00
|
|
|
GetTextExtentPoint32W(hdc, buf, strlenW(buf), &size);
|
2005-04-20 14:51:37 +02:00
|
|
|
titlemonth->left = title->right / 2 + title->left / 2 - size.cx / 2;
|
|
|
|
titleyear->right = title->right / 2 + title->left / 2 + size.cx / 2;
|
2005-04-11 16:21:00 +02:00
|
|
|
GetTextExtentPoint32W(hdc, buf1, strlenW(buf1), &size);
|
2000-01-04 01:30:21 +01:00
|
|
|
titlemonth->right = titlemonth->left + size.cx;
|
2000-10-15 02:27:28 +02:00
|
|
|
titleyear->left = titlemonth->right;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-10-15 02:27:28 +02:00
|
|
|
/* draw month area */
|
|
|
|
rcTemp.top=infoPtr->wdays.top;
|
|
|
|
rcTemp.left=infoPtr->wdays.left;
|
|
|
|
rcTemp.bottom=infoPtr->todayrect.bottom;
|
|
|
|
rcTemp.right =infoPtr->todayrect.right;
|
|
|
|
if(IntersectRect(&rcTemp, &(ps->rcPaint), &rcTemp))
|
|
|
|
{
|
|
|
|
hbr = CreateSolidBrush(infoPtr->monthbk);
|
|
|
|
FillRect(hdc, &rcTemp, hbr);
|
|
|
|
DeleteObject(hbr);
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-07-10 14:00:04 +02:00
|
|
|
/* draw line under day abbreviatons */
|
|
|
|
|
2000-10-15 02:27:28 +02:00
|
|
|
MoveToEx(hdc, infoPtr->days.left + 3, title->bottom + textHeight + 1, NULL);
|
2004-11-08 21:27:02 +01:00
|
|
|
LineTo(hdc, infoPtr->days.right - 3, title->bottom + textHeight + 1);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-10-15 02:27:28 +02:00
|
|
|
prevMonth = infoPtr->currentMonth - 1;
|
|
|
|
if(prevMonth == 0) /* if currentMonth is january(1) prevMonth is */
|
|
|
|
prevMonth = 12; /* december(12) of the previous year */
|
|
|
|
|
|
|
|
infoPtr->wdays.left = infoPtr->days.left = infoPtr->weeknums.right;
|
2000-01-04 01:30:21 +01:00
|
|
|
/* draw day abbreviations */
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2005-04-20 14:51:37 +02:00
|
|
|
SelectObject(hdc, infoPtr->hFont);
|
2000-01-04 01:30:21 +01:00
|
|
|
SetBkColor(hdc, infoPtr->monthbk);
|
1999-11-21 03:04:09 +01:00
|
|
|
SetTextColor(hdc, infoPtr->trailingtxt);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
/* copy this rect so we can change the values without changing */
|
|
|
|
/* the original version */
|
2000-10-15 02:27:28 +02:00
|
|
|
days->left = infoPtr->wdays.left;
|
|
|
|
days->right = days->left + infoPtr->width_increment;
|
|
|
|
days->top = infoPtr->wdays.top;
|
|
|
|
days->bottom = infoPtr->wdays.bottom;
|
2000-01-04 01:30:21 +01:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
i = infoPtr->firstDay;
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
for(j=0; j<7; j++) {
|
2005-04-14 13:31:17 +02:00
|
|
|
GetLocaleInfoW( LOCALE_USER_DEFAULT,LOCALE_SABBREVDAYNAME1 + (i+j+6)%7, buf, countof(buf));
|
2005-04-11 16:21:00 +02:00
|
|
|
DrawTextW(hdc, buf, strlenW(buf), days, DT_CENTER | DT_VCENTER | DT_SINGLELINE );
|
1999-11-21 03:04:09 +01:00
|
|
|
days->left+=infoPtr->width_increment;
|
|
|
|
days->right+=infoPtr->width_increment;
|
|
|
|
}
|
1999-07-10 14:00:04 +02:00
|
|
|
|
|
|
|
/* draw day numbers; first, the previous month */
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
firstDay = MONTHCAL_CalculateDayOfWeek(1, infoPtr->currentMonth, infoPtr->currentYear);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
|
|
|
day = MONTHCAL_MonthLength(prevMonth, infoPtr->currentYear) +
|
2000-10-15 02:27:28 +02:00
|
|
|
(infoPtr->firstDay + 7 - firstDay)%7 + 1;
|
|
|
|
if (day > MONTHCAL_MonthLength(prevMonth, infoPtr->currentYear))
|
|
|
|
day -=7;
|
|
|
|
startofprescal = day;
|
1999-11-21 03:04:09 +01:00
|
|
|
mask = 1<<(day-1);
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
m = 0;
|
2000-01-04 01:30:21 +01:00
|
|
|
while(day <= MONTHCAL_MonthLength(prevMonth, infoPtr->currentYear)) {
|
2000-05-30 22:06:33 +02:00
|
|
|
MONTHCAL_CalcDayRect(infoPtr, &rcDay, i, 0);
|
|
|
|
if(IntersectRect(&rcTemp, &(ps->rcPaint), &rcDay))
|
|
|
|
{
|
2004-11-30 18:35:16 +01:00
|
|
|
MONTHCAL_DrawDay(infoPtr, hdc, day, prevMonth, i, 0,
|
1999-11-21 03:04:09 +01:00
|
|
|
infoPtr->monthdayState[m] & mask);
|
2000-05-30 22:06:33 +02:00
|
|
|
}
|
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
mask<<=1;
|
|
|
|
day++;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
1999-07-10 14:00:04 +02:00
|
|
|
/* draw `current' month */
|
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
day = 1; /* start at the beginning of the current month */
|
|
|
|
|
|
|
|
infoPtr->firstDayplace = i;
|
|
|
|
SetTextColor(hdc, infoPtr->txt);
|
|
|
|
m++;
|
|
|
|
mask = 1;
|
|
|
|
|
|
|
|
/* draw the first week of the current month */
|
2000-01-04 01:30:21 +01:00
|
|
|
while(i<7) {
|
2000-05-30 22:06:33 +02:00
|
|
|
MONTHCAL_CalcDayRect(infoPtr, &rcDay, i, 0);
|
|
|
|
if(IntersectRect(&rcTemp, &(ps->rcPaint), &rcDay))
|
|
|
|
{
|
|
|
|
|
2004-11-30 18:35:16 +01:00
|
|
|
MONTHCAL_DrawDay(infoPtr, hdc, day, infoPtr->currentMonth, i, 0,
|
1999-11-21 03:04:09 +01:00
|
|
|
infoPtr->monthdayState[m] & mask);
|
|
|
|
|
2000-05-30 22:06:33 +02:00
|
|
|
if((infoPtr->currentMonth==infoPtr->todaysDate.wMonth) &&
|
|
|
|
(day==infoPtr->todaysDate.wDay) &&
|
|
|
|
(infoPtr->currentYear == infoPtr->todaysDate.wYear)) {
|
2000-10-15 02:27:28 +02:00
|
|
|
if(!(dwStyle & MCS_NOTODAYCIRCLE))
|
2004-11-30 18:35:16 +01:00
|
|
|
MONTHCAL_CircleDay(infoPtr, hdc, day, infoPtr->currentMonth);
|
2000-05-30 22:06:33 +02:00
|
|
|
}
|
1999-11-21 03:04:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
mask<<=1;
|
|
|
|
day++;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
j = 1; /* move to the 2nd week of the current month */
|
|
|
|
i = 0; /* move back to sunday */
|
2002-06-01 01:06:46 +02:00
|
|
|
while(day <= MONTHCAL_MonthLength(infoPtr->currentMonth, infoPtr->currentYear)) {
|
2000-05-30 22:06:33 +02:00
|
|
|
MONTHCAL_CalcDayRect(infoPtr, &rcDay, i, j);
|
|
|
|
if(IntersectRect(&rcTemp, &(ps->rcPaint), &rcDay))
|
|
|
|
{
|
2004-11-30 18:35:16 +01:00
|
|
|
MONTHCAL_DrawDay(infoPtr, hdc, day, infoPtr->currentMonth, i, j,
|
1999-11-21 03:04:09 +01:00
|
|
|
infoPtr->monthdayState[m] & mask);
|
|
|
|
|
2000-05-30 22:06:33 +02:00
|
|
|
if((infoPtr->currentMonth==infoPtr->todaysDate.wMonth) &&
|
|
|
|
(day==infoPtr->todaysDate.wDay) &&
|
2002-06-01 01:06:46 +02:00
|
|
|
(infoPtr->currentYear == infoPtr->todaysDate.wYear))
|
|
|
|
if(!(dwStyle & MCS_NOTODAYCIRCLE))
|
2004-11-30 18:35:16 +01:00
|
|
|
MONTHCAL_CircleDay(infoPtr, hdc, day, infoPtr->currentMonth);
|
2000-05-30 22:06:33 +02:00
|
|
|
}
|
1999-11-21 03:04:09 +01:00
|
|
|
mask<<=1;
|
|
|
|
day++;
|
|
|
|
i++;
|
2000-01-04 01:30:21 +01:00
|
|
|
if(i>6) { /* past saturday, goto the next weeks sunday */
|
1999-11-21 03:04:09 +01:00
|
|
|
i = 0;
|
|
|
|
j++;
|
|
|
|
}
|
|
|
|
}
|
1999-07-10 14:00:04 +02:00
|
|
|
|
|
|
|
/* draw `next' month */
|
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
day = 1; /* start at the first day of the next month */
|
|
|
|
m++;
|
|
|
|
mask = 1;
|
|
|
|
|
|
|
|
SetTextColor(hdc, infoPtr->trailingtxt);
|
2000-01-04 01:30:21 +01:00
|
|
|
while((i<7) &&(j<6)) {
|
2000-05-30 22:06:33 +02:00
|
|
|
MONTHCAL_CalcDayRect(infoPtr, &rcDay, i, j);
|
|
|
|
if(IntersectRect(&rcTemp, &(ps->rcPaint), &rcDay))
|
2002-06-01 01:06:46 +02:00
|
|
|
{
|
2004-11-30 18:35:16 +01:00
|
|
|
MONTHCAL_DrawDay(infoPtr, hdc, day, infoPtr->currentMonth + 1, i, j,
|
1999-11-21 03:04:09 +01:00
|
|
|
infoPtr->monthdayState[m] & mask);
|
2000-05-30 22:06:33 +02:00
|
|
|
}
|
1999-11-21 03:04:09 +01:00
|
|
|
|
|
|
|
mask<<=1;
|
|
|
|
day++;
|
2002-06-01 01:06:46 +02:00
|
|
|
i++;
|
2000-01-04 01:30:21 +01:00
|
|
|
if(i==7) { /* past saturday, go to next week's sunday */
|
1999-11-21 03:04:09 +01:00
|
|
|
i = 0;
|
|
|
|
j++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SetTextColor(hdc, infoPtr->txt);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
|
|
|
|
|
|
|
/* draw `today' date if style allows it, and draw a circle before today's
|
1999-11-21 03:04:09 +01:00
|
|
|
* date if necessary */
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
if(!(dwStyle & MCS_NOTODAY)) {
|
1999-11-21 03:04:09 +01:00
|
|
|
int offset = 0;
|
2000-05-30 22:06:33 +02:00
|
|
|
if(!(dwStyle & MCS_NOTODAYCIRCLE)) {
|
2000-10-15 02:27:28 +02:00
|
|
|
/*day is the number of days from nextmonth we put on the calendar */
|
2004-11-30 18:35:16 +01:00
|
|
|
MONTHCAL_CircleDay(infoPtr, hdc,
|
2002-06-01 01:06:46 +02:00
|
|
|
day+MONTHCAL_MonthLength(infoPtr->currentMonth,infoPtr->currentYear),
|
2000-10-15 02:27:28 +02:00
|
|
|
infoPtr->currentMonth);
|
1999-11-21 03:04:09 +01:00
|
|
|
offset+=textWidth;
|
|
|
|
}
|
2005-04-11 16:21:00 +02:00
|
|
|
if (!LoadStringW(COMCTL32_hModule,IDM_TODAY,buf1,countof(buf1)))
|
2000-10-15 02:27:28 +02:00
|
|
|
{
|
|
|
|
WARN("Can't load resource\n");
|
2005-04-11 16:21:00 +02:00
|
|
|
strcpyW(buf1, todayW);
|
2000-10-15 02:27:28 +02:00
|
|
|
}
|
|
|
|
MONTHCAL_CalcDayRect(infoPtr, &rtoday, 1, 6);
|
|
|
|
MONTHCAL_CopyTime(&infoPtr->todaysDate,&localtime);
|
2005-04-11 16:21:00 +02:00
|
|
|
GetDateFormatW(LOCALE_USER_DEFAULT,DATE_SHORTDATE,&localtime,NULL,buf2,countof(buf2));
|
|
|
|
wsprintfW(buf, fmt2W, buf1, buf2);
|
2000-01-04 01:30:21 +01:00
|
|
|
SelectObject(hdc, infoPtr->hBoldFont);
|
2000-05-30 22:06:33 +02:00
|
|
|
|
2005-04-20 14:51:37 +02:00
|
|
|
DrawTextW(hdc, buf, -1, &rtoday, DT_CALCRECT | DT_LEFT | DT_VCENTER | DT_SINGLELINE);
|
2000-10-15 02:27:28 +02:00
|
|
|
if(IntersectRect(&rcTemp, &(ps->rcPaint), &rtoday))
|
2000-05-30 22:06:33 +02:00
|
|
|
{
|
2005-04-11 16:21:00 +02:00
|
|
|
DrawTextW(hdc, buf, -1, &rtoday, DT_LEFT | DT_VCENTER | DT_SINGLELINE);
|
2000-05-30 22:06:33 +02:00
|
|
|
}
|
2000-01-04 01:30:21 +01:00
|
|
|
SelectObject(hdc, infoPtr->hFont);
|
1999-11-21 03:04:09 +01:00
|
|
|
}
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
/*eventually draw week numbers*/
|
2000-01-04 01:30:21 +01:00
|
|
|
if(dwStyle & MCS_WEEKNUMBERS) {
|
1999-11-21 03:04:09 +01:00
|
|
|
/* display weeknumbers*/
|
2000-10-15 02:27:28 +02:00
|
|
|
int mindays;
|
|
|
|
|
|
|
|
/* Rules what week to call the first week of a new year:
|
|
|
|
LOCALE_IFIRSTWEEKOFYEAR == 0 (e.g US?):
|
|
|
|
The week containing Jan 1 is the first week of year
|
2002-06-01 01:06:46 +02:00
|
|
|
LOCALE_IFIRSTWEEKOFYEAR == 2 (e.g. Germany):
|
2000-10-15 02:27:28 +02:00
|
|
|
First week of year must contain 4 days of the new year
|
|
|
|
LOCALE_IFIRSTWEEKOFYEAR == 1 (what contries?)
|
|
|
|
The first week of the year must contain only days of the new year
|
|
|
|
*/
|
2005-04-11 16:21:00 +02:00
|
|
|
GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_IFIRSTWEEKOFYEAR, buf, countof(buf));
|
|
|
|
weeknum = atoiW(buf);
|
2000-10-15 02:27:28 +02:00
|
|
|
switch (weeknum)
|
|
|
|
{
|
|
|
|
case 1: mindays = 6;
|
|
|
|
break;
|
|
|
|
case 2: mindays = 3;
|
|
|
|
break;
|
|
|
|
case 0:
|
|
|
|
default:
|
|
|
|
mindays = 0;
|
|
|
|
}
|
|
|
|
if (infoPtr->currentMonth < 2)
|
|
|
|
{
|
|
|
|
/* calculate all those exceptions for january */
|
|
|
|
weeknum1=MONTHCAL_CalculateDayOfWeek(1,1,infoPtr->currentYear);
|
2002-06-01 01:06:46 +02:00
|
|
|
if ((infoPtr->firstDay +7 - weeknum1)%7 > mindays)
|
2000-10-15 02:27:28 +02:00
|
|
|
weeknum =1;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
weeknum = 0;
|
2002-06-01 01:06:46 +02:00
|
|
|
for(i=0; i<11; i++)
|
2000-10-15 02:27:28 +02:00
|
|
|
weeknum+=MONTHCAL_MonthLength(i+1, infoPtr->currentYear-1);
|
|
|
|
weeknum +=startofprescal+ 7;
|
|
|
|
weeknum /=7;
|
|
|
|
weeknum1=MONTHCAL_CalculateDayOfWeek(1,1,infoPtr->currentYear-1);
|
|
|
|
if ((infoPtr->firstDay + 7 - weeknum1)%7 > mindays)
|
|
|
|
weeknum++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
weeknum = 0;
|
2002-06-01 01:06:46 +02:00
|
|
|
for(i=0; i<prevMonth-1; i++)
|
2000-10-15 02:27:28 +02:00
|
|
|
weeknum+=MONTHCAL_MonthLength(i+1, infoPtr->currentYear);
|
|
|
|
weeknum +=startofprescal+ 7;
|
|
|
|
weeknum /=7;
|
|
|
|
weeknum1=MONTHCAL_CalculateDayOfWeek(1,1,infoPtr->currentYear);
|
|
|
|
if ((infoPtr->firstDay + 7 - weeknum1)%7 > mindays)
|
|
|
|
weeknum++;
|
|
|
|
}
|
|
|
|
days->left = infoPtr->weeknums.left;
|
|
|
|
days->right = infoPtr->weeknums.right;
|
|
|
|
days->top = infoPtr->weeknums.top;
|
|
|
|
days->bottom = days->top +infoPtr->height_increment;
|
2000-01-04 01:30:21 +01:00
|
|
|
for(i=0; i<6; i++) {
|
2000-10-15 02:27:28 +02:00
|
|
|
if((i==0)&&(weeknum>50))
|
|
|
|
{
|
2005-04-11 16:21:00 +02:00
|
|
|
wsprintfW(buf, fmt3W, weeknum);
|
2000-10-15 02:27:28 +02:00
|
|
|
weeknum=0;
|
|
|
|
}
|
|
|
|
else if((i==5)&&(weeknum>47))
|
|
|
|
{
|
2005-04-11 16:21:00 +02:00
|
|
|
wsprintfW(buf, fmt3W, 1);
|
2000-10-15 02:27:28 +02:00
|
|
|
}
|
|
|
|
else
|
2005-04-11 16:21:00 +02:00
|
|
|
wsprintfW(buf, fmt3W, weeknum + i);
|
|
|
|
DrawTextW(hdc, buf, -1, days, DT_CENTER | DT_VCENTER | DT_SINGLELINE );
|
2000-10-15 02:27:28 +02:00
|
|
|
days->top+=infoPtr->height_increment;
|
|
|
|
days->bottom+=infoPtr->height_increment;
|
1999-11-21 03:04:09 +01:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-10-15 02:27:28 +02:00
|
|
|
MoveToEx(hdc, infoPtr->weeknums.right, infoPtr->weeknums.top + 3 , NULL);
|
|
|
|
LineTo(hdc, infoPtr->weeknums.right, infoPtr->weeknums.bottom );
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
}
|
|
|
|
/* currentFont was font at entering Refresh */
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
SetBkColor(hdc, oldBkColor);
|
2002-06-01 01:06:46 +02:00
|
|
|
SelectObject(hdc, currentFont);
|
2000-01-04 01:30:21 +01:00
|
|
|
SetTextColor(hdc, oldTextColor);
|
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_GetMinReqRect(const MONTHCAL_INFO *infoPtr, LPARAM lParam)
|
1999-07-10 14:00:04 +02:00
|
|
|
{
|
2000-01-04 01:30:21 +01:00
|
|
|
LPRECT lpRect = (LPRECT) lParam;
|
2004-11-30 18:35:16 +01:00
|
|
|
|
|
|
|
TRACE("rect %p\n", lpRect);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-07-10 14:00:04 +02:00
|
|
|
/* validate parameters */
|
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
if((infoPtr==NULL) ||(lpRect == NULL) ) return FALSE;
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2004-11-08 21:27:02 +01:00
|
|
|
lpRect->left = infoPtr->title.left;
|
|
|
|
lpRect->top = infoPtr->title.top;
|
|
|
|
lpRect->right = infoPtr->title.right;
|
|
|
|
lpRect->bottom = infoPtr->todayrect.bottom;
|
2004-11-30 18:35:16 +01:00
|
|
|
AdjustWindowRect(lpRect, GetWindowLongW(infoPtr->hwndSelf, GWL_STYLE), FALSE);
|
2004-11-08 21:27:02 +01:00
|
|
|
|
|
|
|
TRACE("%s\n", wine_dbgstr_rect(lpRect));
|
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
return TRUE;
|
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
|
2007-03-29 23:09:32 +02:00
|
|
|
MONTHCAL_GetColor(const MONTHCAL_INFO *infoPtr, WPARAM wParam)
|
1999-07-10 14:00:04 +02:00
|
|
|
{
|
2004-11-30 18:35:16 +01:00
|
|
|
TRACE("\n");
|
1999-11-21 03:04:09 +01:00
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
switch((int)wParam) {
|
1999-11-21 03:04:09 +01:00
|
|
|
case MCSC_BACKGROUND:
|
|
|
|
return infoPtr->bk;
|
|
|
|
case MCSC_TEXT:
|
|
|
|
return infoPtr->txt;
|
|
|
|
case MCSC_TITLEBK:
|
|
|
|
return infoPtr->titlebk;
|
|
|
|
case MCSC_TITLETEXT:
|
|
|
|
return infoPtr->titletxt;
|
|
|
|
case MCSC_MONTHBK:
|
|
|
|
return infoPtr->monthbk;
|
|
|
|
case MCSC_TRAILINGTEXT:
|
|
|
|
return infoPtr->trailingtxt;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
1999-07-10 14:00:04 +02:00
|
|
|
}
|
|
|
|
|
2000-05-30 22:06:33 +02:00
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
static LRESULT
|
2004-11-30 18:35:16 +01:00
|
|
|
MONTHCAL_SetColor(MONTHCAL_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
|
1999-07-10 14:00:04 +02:00
|
|
|
{
|
2000-01-04 01:30:21 +01:00
|
|
|
int prev = -1;
|
1999-11-21 03:04:09 +01:00
|
|
|
|
2007-05-24 16:41:17 +02:00
|
|
|
TRACE("%ld: color %08lx\n", wParam, lParam);
|
1999-11-21 03:04:09 +01:00
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
switch((int)wParam) {
|
1999-11-21 03:04:09 +01:00
|
|
|
case MCSC_BACKGROUND:
|
|
|
|
prev = infoPtr->bk;
|
|
|
|
infoPtr->bk = (COLORREF)lParam;
|
|
|
|
break;
|
|
|
|
case MCSC_TEXT:
|
|
|
|
prev = infoPtr->txt;
|
|
|
|
infoPtr->txt = (COLORREF)lParam;
|
|
|
|
break;
|
|
|
|
case MCSC_TITLEBK:
|
|
|
|
prev = infoPtr->titlebk;
|
|
|
|
infoPtr->titlebk = (COLORREF)lParam;
|
|
|
|
break;
|
|
|
|
case MCSC_TITLETEXT:
|
|
|
|
prev=infoPtr->titletxt;
|
|
|
|
infoPtr->titletxt = (COLORREF)lParam;
|
|
|
|
break;
|
|
|
|
case MCSC_MONTHBK:
|
|
|
|
prev = infoPtr->monthbk;
|
|
|
|
infoPtr->monthbk = (COLORREF)lParam;
|
|
|
|
break;
|
|
|
|
case MCSC_TRAILINGTEXT:
|
|
|
|
prev = infoPtr->trailingtxt;
|
|
|
|
infoPtr->trailingtxt = (COLORREF)lParam;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2004-11-30 18:35:16 +01:00
|
|
|
InvalidateRect(infoPtr->hwndSelf, NULL, FALSE);
|
1999-11-21 03:04:09 +01:00
|
|
|
return prev;
|
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
|
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;
|
|
|
|
else
|
|
|
|
return infoPtr->visible;
|
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
|
2004-11-30 18:35:16 +01:00
|
|
|
MONTHCAL_SetMonthDelta(MONTHCAL_INFO *infoPtr, WPARAM wParam)
|
1999-07-10 14:00:04 +02:00
|
|
|
{
|
1999-11-21 03:04:09 +01:00
|
|
|
int prev = infoPtr->delta;
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2007-05-24 16:41:17 +02:00
|
|
|
TRACE("delta %ld\n", wParam);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
infoPtr->delta = (int)wParam;
|
|
|
|
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_GetFirstDayOfWeek(const MONTHCAL_INFO *infoPtr)
|
1999-07-10 14:00:04 +02:00
|
|
|
{
|
2007-04-10 03:25:41 +02:00
|
|
|
return MAKELONG(infoPtr->firstDay, infoPtr->firstDayHighWord);
|
1999-07-10 14:00:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
/* sets the first day of the week that will appear in the control */
|
2005-04-14 13:31:17 +02:00
|
|
|
/* 0 == Sunday, 6 == Saturday */
|
1999-11-21 03:04:09 +01: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
|
2004-11-30 18:35:16 +01:00
|
|
|
MONTHCAL_SetFirstDayOfWeek(MONTHCAL_INFO *infoPtr, LPARAM lParam)
|
1999-07-10 14:00:04 +02:00
|
|
|
{
|
2007-04-10 03:25:41 +02:00
|
|
|
int prev = MAKELONG(infoPtr->firstDay, infoPtr->firstDayHighWord);
|
2007-03-16 08:34:36 +01:00
|
|
|
int localFirstDay;
|
2005-04-11 16:21:00 +02:00
|
|
|
WCHAR buf[40];
|
1999-11-21 03:04:09 +01:00
|
|
|
|
2004-11-30 18:35:16 +01:00
|
|
|
TRACE("day %ld\n", lParam);
|
1999-11-21 03:04:09 +01:00
|
|
|
|
2007-03-16 08:34:36 +01:00
|
|
|
GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_IFIRSTDAYOFWEEK, buf, countof(buf));
|
|
|
|
TRACE("%s %d\n", debugstr_w(buf), strlenW(buf));
|
|
|
|
|
|
|
|
localFirstDay = atoiW(buf);
|
|
|
|
|
|
|
|
if(lParam == -1)
|
2007-04-10 03:25:41 +02:00
|
|
|
{
|
|
|
|
infoPtr->firstDay = localFirstDay;
|
|
|
|
infoPtr->firstDayHighWord = FALSE;
|
|
|
|
}
|
2007-03-16 08:34:36 +01:00
|
|
|
else if(lParam >= 7)
|
2007-04-10 03:25:41 +02:00
|
|
|
{
|
|
|
|
infoPtr->firstDay = localFirstDay;
|
|
|
|
infoPtr->firstDayHighWord = TRUE;
|
|
|
|
}
|
2000-10-15 02:27:28 +02:00
|
|
|
else
|
2007-04-10 03:25:41 +02:00
|
|
|
{
|
|
|
|
infoPtr->firstDay = lParam;
|
|
|
|
infoPtr->firstDayHighWord = TRUE;
|
|
|
|
}
|
2007-03-16 08:34:36 +01:00
|
|
|
|
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_GetMonthRange(const MONTHCAL_INFO *infoPtr)
|
1999-07-10 14:00:04 +02:00
|
|
|
{
|
2004-11-30 18:35:16 +01:00
|
|
|
TRACE("\n");
|
1999-11-21 03:04:09 +01:00
|
|
|
|
1999-07-10 14:00:04 +02:00
|
|
|
return infoPtr->monthRange;
|
|
|
|
}
|
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
|
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
|
|
|
}
|
|
|
|
|
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_SetRange(MONTHCAL_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
|
1999-07-10 14:00:04 +02:00
|
|
|
{
|
2006-02-14 17:12:45 +01:00
|
|
|
SYSTEMTIME *lprgSysTimeArray=(SYSTEMTIME *)lParam;
|
2006-02-16 12:19:36 +01:00
|
|
|
FILETIME ft_min, ft_max;
|
2006-02-14 17:12:45 +01:00
|
|
|
|
2007-05-24 16:41:17 +02:00
|
|
|
TRACE("%lx %lx\n", wParam, lParam);
|
2006-02-14 17:12:45 +01:00
|
|
|
|
|
|
|
if ((wParam & GDTR_MIN && !MONTHCAL_ValidateTime(lprgSysTimeArray[0])) ||
|
|
|
|
(wParam & GDTR_MAX && !MONTHCAL_ValidateTime(lprgSysTimeArray[1])))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (wParam & GDTR_MIN)
|
|
|
|
{
|
|
|
|
MONTHCAL_CopyTime(&lprgSysTimeArray[0], &infoPtr->minDate);
|
|
|
|
infoPtr->rangeValid |= GDTR_MIN;
|
1999-11-21 03:04:09 +01:00
|
|
|
}
|
2006-02-14 17:12:45 +01:00
|
|
|
if (wParam & GDTR_MAX)
|
|
|
|
{
|
|
|
|
MONTHCAL_CopyTime(&lprgSysTimeArray[1], &infoPtr->maxDate);
|
|
|
|
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;
|
|
|
|
|
|
|
|
SystemTimeToFileTime(&infoPtr->maxDate, &ft_max);
|
|
|
|
SystemTimeToFileTime(&infoPtr->minDate, &ft_min);
|
|
|
|
|
|
|
|
if (CompareFileTime(&ft_min, &ft_max) > 0)
|
|
|
|
{
|
|
|
|
if ((wParam & (GDTR_MIN | GDTR_MAX)) == (GDTR_MIN | GDTR_MAX))
|
|
|
|
{
|
|
|
|
/* Native swaps limits only when both limits are being set. */
|
|
|
|
SYSTEMTIME st_tmp = infoPtr->minDate;
|
|
|
|
infoPtr->minDate = infoPtr->maxDate;
|
|
|
|
infoPtr->maxDate = st_tmp;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Reset the other limit. */
|
|
|
|
/* FIXME: native sets date&time to 0. Should we do this too? */
|
|
|
|
infoPtr->rangeValid &= wParam & GDTR_MIN ? ~GDTR_MAX : ~GDTR_MIN ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
2000-01-04 01:30:21 +01:00
|
|
|
MONTHCAL_GetRange(HWND hwnd, WPARAM wParam, LPARAM lParam)
|
1999-07-10 14:00:04 +02:00
|
|
|
{
|
1999-11-21 03:04:09 +01:00
|
|
|
MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd);
|
|
|
|
SYSTEMTIME *lprgSysTimeArray = (SYSTEMTIME *)lParam;
|
1999-07-10 14:00:04 +02:00
|
|
|
|
|
|
|
/* validate parameters */
|
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
if((infoPtr==NULL) || (lprgSysTimeArray==NULL)) return FALSE;
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
MONTHCAL_CopyTime(&infoPtr->maxDate, &lprgSysTimeArray[1]);
|
|
|
|
MONTHCAL_CopyTime(&infoPtr->minDate, &lprgSysTimeArray[0]);
|
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
|
2007-03-29 23:09:32 +02:00
|
|
|
MONTHCAL_SetDayState(const MONTHCAL_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
|
1999-07-10 14:00:04 +02:00
|
|
|
|
|
|
|
{
|
1999-11-21 03:04:09 +01:00
|
|
|
int i, iMonths = (int)wParam;
|
|
|
|
MONTHDAYSTATE *dayStates = (LPMONTHDAYSTATE)lParam;
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2007-05-24 16:41:17 +02:00
|
|
|
TRACE("%lx %lx\n", wParam, lParam);
|
2000-01-04 01:30:21 +01:00
|
|
|
if(iMonths!=infoPtr->monthRange) return 0;
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
for(i=0; i<iMonths; i++)
|
2000-01-04 01:30:21 +01:00
|
|
|
infoPtr->monthdayState[i] = dayStates[i];
|
1999-07-10 14:00:04 +02:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
static LRESULT
|
2007-03-29 23:09:32 +02:00
|
|
|
MONTHCAL_GetCurSel(const MONTHCAL_INFO *infoPtr, LPARAM lParam)
|
1999-07-10 14:00:04 +02:00
|
|
|
{
|
1999-11-21 03:04:09 +01:00
|
|
|
SYSTEMTIME *lpSel = (SYSTEMTIME *) lParam;
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2004-11-30 18:35:16 +01:00
|
|
|
TRACE("%lx\n", lParam);
|
2000-01-04 01:30:21 +01:00
|
|
|
if((infoPtr==NULL) ||(lpSel==NULL)) return FALSE;
|
2004-11-30 18:35:16 +01:00
|
|
|
if(GetWindowLongW(infoPtr->hwndSelf, GWL_STYLE) & MCS_MULTISELECT) return FALSE;
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
MONTHCAL_CopyTime(&infoPtr->minSel, lpSel);
|
2004-04-22 00:24:09 +02:00
|
|
|
TRACE("%d/%d/%d\n", lpSel->wYear, lpSel->wMonth, lpSel->wDay);
|
1999-07-10 14:00:04 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* FIXME: if the specified date is not visible, make it visible */
|
|
|
|
/* FIXME: redraw? */
|
2002-06-01 01:06:46 +02:00
|
|
|
static LRESULT
|
2004-11-30 18:35:16 +01:00
|
|
|
MONTHCAL_SetCurSel(MONTHCAL_INFO *infoPtr, LPARAM lParam)
|
1999-07-10 14:00:04 +02:00
|
|
|
{
|
2000-01-04 01:30:21 +01:00
|
|
|
SYSTEMTIME *lpSel = (SYSTEMTIME *)lParam;
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2004-11-30 18:35:16 +01:00
|
|
|
TRACE("%lx\n", lParam);
|
2000-01-04 01:30:21 +01:00
|
|
|
if((infoPtr==NULL) ||(lpSel==NULL)) return FALSE;
|
2004-11-30 18:35:16 +01:00
|
|
|
if(GetWindowLongW(infoPtr->hwndSelf, GWL_STYLE) & MCS_MULTISELECT) return FALSE;
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2007-03-09 05:48:48 +01:00
|
|
|
if(!MONTHCAL_ValidateTime(*lpSel)) return FALSE;
|
|
|
|
|
2004-04-22 00:24:09 +02:00
|
|
|
infoPtr->currentMonth=lpSel->wMonth;
|
|
|
|
infoPtr->currentYear=lpSel->wYear;
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
MONTHCAL_CopyTime(lpSel, &infoPtr->minSel);
|
|
|
|
MONTHCAL_CopyTime(lpSel, &infoPtr->maxSel);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2004-11-30 18:35:16 +01:00
|
|
|
InvalidateRect(infoPtr->hwndSelf, NULL, FALSE);
|
2000-05-30 22:06:33 +02:00
|
|
|
|
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
|
2004-11-30 18:35:16 +01:00
|
|
|
MONTHCAL_SetMaxSelCount(MONTHCAL_INFO *infoPtr, WPARAM wParam)
|
1999-07-10 14:00:04 +02:00
|
|
|
{
|
2007-05-24 16:41:17 +02:00
|
|
|
TRACE("%lx\n", wParam);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2004-11-30 18:35:16 +01:00
|
|
|
if(GetWindowLongW(infoPtr->hwndSelf, GWL_STYLE) & MCS_MULTISELECT) {
|
1999-11-21 03:04:09 +01:00
|
|
|
infoPtr->maxSelCount = wParam;
|
1999-07-10 14:00:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
static LRESULT
|
2007-03-29 23:09:32 +02:00
|
|
|
MONTHCAL_GetSelRange(const MONTHCAL_INFO *infoPtr, LPARAM lParam)
|
1999-07-10 14:00:04 +02:00
|
|
|
{
|
1999-11-21 03:04:09 +01:00
|
|
|
SYSTEMTIME *lprgSysTimeArray = (SYSTEMTIME *) lParam;
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2004-11-30 18:35:16 +01:00
|
|
|
TRACE("%lx\n", lParam);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
|
|
|
/* validate parameters */
|
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
if((infoPtr==NULL) ||(lprgSysTimeArray==NULL)) return FALSE;
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2004-11-30 18:35:16 +01:00
|
|
|
if(GetWindowLongW(infoPtr->hwndSelf, GWL_STYLE) & MCS_MULTISELECT)
|
2000-01-04 01:30:21 +01:00
|
|
|
{
|
|
|
|
MONTHCAL_CopyTime(&infoPtr->maxSel, &lprgSysTimeArray[1]);
|
|
|
|
MONTHCAL_CopyTime(&infoPtr->minSel, &lprgSysTimeArray[0]);
|
|
|
|
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
|
2004-11-30 18:35:16 +01:00
|
|
|
MONTHCAL_SetSelRange(MONTHCAL_INFO *infoPtr, LPARAM lParam)
|
1999-07-10 14:00:04 +02:00
|
|
|
{
|
1999-11-21 03:04:09 +01:00
|
|
|
SYSTEMTIME *lprgSysTimeArray = (SYSTEMTIME *) lParam;
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2004-11-30 18:35:16 +01:00
|
|
|
TRACE("%lx\n", lParam);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
|
|
|
/* validate parameters */
|
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
if((infoPtr==NULL) ||(lprgSysTimeArray==NULL)) return FALSE;
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2004-11-30 18:35:16 +01:00
|
|
|
if(GetWindowLongW(infoPtr->hwndSelf, GWL_STYLE) & MCS_MULTISELECT)
|
2000-01-04 01:30:21 +01:00
|
|
|
{
|
|
|
|
MONTHCAL_CopyTime(&lprgSysTimeArray[1], &infoPtr->maxSel);
|
|
|
|
MONTHCAL_CopyTime(&lprgSysTimeArray[0], &infoPtr->minSel);
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
static LRESULT
|
2007-03-29 23:09:32 +02:00
|
|
|
MONTHCAL_GetToday(const MONTHCAL_INFO *infoPtr, LPARAM lParam)
|
1999-07-10 14:00:04 +02:00
|
|
|
{
|
1999-11-21 03:04:09 +01:00
|
|
|
SYSTEMTIME *lpToday = (SYSTEMTIME *) lParam;
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2004-11-30 18:35:16 +01:00
|
|
|
TRACE("%lx\n", lParam);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
|
|
|
/* validate parameters */
|
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
if((infoPtr==NULL) || (lpToday==NULL)) return FALSE;
|
|
|
|
MONTHCAL_CopyTime(&infoPtr->todaysDate, lpToday);
|
1999-07-10 14:00:04 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
static LRESULT
|
2004-11-30 18:35:16 +01:00
|
|
|
MONTHCAL_SetToday(MONTHCAL_INFO *infoPtr, LPARAM lParam)
|
1999-07-31 13:13:25 +02:00
|
|
|
{
|
1999-11-21 03:04:09 +01:00
|
|
|
SYSTEMTIME *lpToday = (SYSTEMTIME *) lParam;
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2004-11-30 18:35:16 +01:00
|
|
|
TRACE("%lx\n", lParam);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
1999-07-31 13:13:25 +02:00
|
|
|
/* validate parameters */
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
if((infoPtr==NULL) ||(lpToday==NULL)) return FALSE;
|
|
|
|
MONTHCAL_CopyTime(lpToday, &infoPtr->todaysDate);
|
2004-11-30 18:35:16 +01:00
|
|
|
InvalidateRect(infoPtr->hwndSelf, NULL, FALSE);
|
1999-07-31 13:13:25 +02:00
|
|
|
return TRUE;
|
1999-07-10 14:00:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static LRESULT
|
2007-03-29 23:09:32 +02:00
|
|
|
MONTHCAL_HitTest(const MONTHCAL_INFO *infoPtr, LPARAM lParam)
|
1999-07-10 14:00:04 +02:00
|
|
|
{
|
2000-10-15 02:27:28 +02:00
|
|
|
PMCHITTESTINFO lpht = (PMCHITTESTINFO)lParam;
|
|
|
|
UINT x,y;
|
|
|
|
DWORD retval;
|
|
|
|
int day,wday,wnum;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
|
|
|
|
2000-10-15 02:27:28 +02:00
|
|
|
x = lpht->pt.x;
|
|
|
|
y = lpht->pt.y;
|
|
|
|
retval = MCHT_NOWHERE;
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2005-04-11 14:57:57 +02:00
|
|
|
ZeroMemory(&lpht->st, sizeof(lpht->st));
|
2002-06-01 01:06:46 +02:00
|
|
|
|
|
|
|
/* Comment in for debugging...
|
|
|
|
TRACE("%d %d wd[%d %d %d %d] d[%d %d %d %d] t[%d %d %d %d] wn[%d %d %d %d]\n", x, y,
|
2000-10-15 02:27:28 +02:00
|
|
|
infoPtr->wdays.left, infoPtr->wdays.right,
|
|
|
|
infoPtr->wdays.top, infoPtr->wdays.bottom,
|
|
|
|
infoPtr->days.left, infoPtr->days.right,
|
|
|
|
infoPtr->days.top, infoPtr->days.bottom,
|
|
|
|
infoPtr->todayrect.left, infoPtr->todayrect.right,
|
|
|
|
infoPtr->todayrect.top, infoPtr->todayrect.bottom,
|
|
|
|
infoPtr->weeknums.left, infoPtr->weeknums.right,
|
|
|
|
infoPtr->weeknums.top, infoPtr->weeknums.bottom);
|
|
|
|
*/
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2000-10-15 02:27:28 +02:00
|
|
|
/* are we in the header? */
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
if(PtInRect(&infoPtr->title, lpht->pt)) {
|
|
|
|
if(PtInRect(&infoPtr->titlebtnprev, lpht->pt)) {
|
1999-11-21 03:04:09 +01:00
|
|
|
retval = MCHT_TITLEBTNPREV;
|
|
|
|
goto done;
|
|
|
|
}
|
2000-01-04 01:30:21 +01:00
|
|
|
if(PtInRect(&infoPtr->titlebtnnext, lpht->pt)) {
|
1999-11-21 03:04:09 +01:00
|
|
|
retval = MCHT_TITLEBTNNEXT;
|
|
|
|
goto done;
|
|
|
|
}
|
2000-01-04 01:30:21 +01:00
|
|
|
if(PtInRect(&infoPtr->titlemonth, lpht->pt)) {
|
1999-11-21 03:04:09 +01:00
|
|
|
retval = MCHT_TITLEMONTH;
|
|
|
|
goto done;
|
|
|
|
}
|
2000-01-04 01:30:21 +01:00
|
|
|
if(PtInRect(&infoPtr->titleyear, lpht->pt)) {
|
1999-11-21 03:04:09 +01:00
|
|
|
retval = MCHT_TITLEYEAR;
|
|
|
|
goto done;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
retval = MCHT_TITLE;
|
|
|
|
goto done;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-10-15 02:27:28 +02:00
|
|
|
day = MONTHCAL_CalcDayFromPos(infoPtr,x,y,&wday,&wnum);
|
|
|
|
if(PtInRect(&infoPtr->wdays, lpht->pt)) {
|
|
|
|
retval = MCHT_CALENDARDAY;
|
|
|
|
lpht->st.wYear = infoPtr->currentYear;
|
|
|
|
lpht->st.wMonth = (day < 1)? infoPtr->currentMonth -1 : infoPtr->currentMonth;
|
2002-06-01 01:06:46 +02:00
|
|
|
lpht->st.wDay = (day < 1)?
|
2000-10-15 02:27:28 +02:00
|
|
|
MONTHCAL_MonthLength(infoPtr->currentMonth-1,infoPtr->currentYear) -day : day;
|
1999-11-21 03:04:09 +01:00
|
|
|
goto done;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
if(PtInRect(&infoPtr->weeknums, lpht->pt)) {
|
|
|
|
retval = MCHT_CALENDARWEEKNUM;
|
2000-10-15 02:27:28 +02:00
|
|
|
lpht->st.wYear = infoPtr->currentYear;
|
2002-06-01 01:06:46 +02:00
|
|
|
lpht->st.wMonth = (day < 1) ? infoPtr->currentMonth -1 :
|
|
|
|
(day > MONTHCAL_MonthLength(infoPtr->currentMonth,infoPtr->currentYear)) ?
|
2000-10-15 02:27:28 +02:00
|
|
|
infoPtr->currentMonth +1 :infoPtr->currentMonth;
|
2002-06-01 01:06:46 +02:00
|
|
|
lpht->st.wDay = (day < 1 ) ?
|
|
|
|
MONTHCAL_MonthLength(infoPtr->currentMonth-1,infoPtr->currentYear) -day :
|
|
|
|
(day > MONTHCAL_MonthLength(infoPtr->currentMonth,infoPtr->currentYear)) ?
|
2000-10-15 02:27:28 +02:00
|
|
|
day - MONTHCAL_MonthLength(infoPtr->currentMonth,infoPtr->currentYear) : day;
|
2002-06-01 01:06:46 +02:00
|
|
|
goto done;
|
1999-11-21 03:04:09 +01:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
if(PtInRect(&infoPtr->days, lpht->pt))
|
2000-10-15 02:27:28 +02:00
|
|
|
{
|
|
|
|
lpht->st.wYear = infoPtr->currentYear;
|
2002-06-01 01:06:46 +02:00
|
|
|
if ( day < 1)
|
2000-10-15 02:27:28 +02:00
|
|
|
{
|
|
|
|
retval = MCHT_CALENDARDATEPREV;
|
|
|
|
lpht->st.wMonth = infoPtr->currentMonth - 1;
|
|
|
|
if (lpht->st.wMonth <1)
|
|
|
|
{
|
|
|
|
lpht->st.wMonth = 12;
|
|
|
|
lpht->st.wYear--;
|
|
|
|
}
|
|
|
|
lpht->st.wDay = MONTHCAL_MonthLength(lpht->st.wMonth,lpht->st.wYear) -day;
|
|
|
|
}
|
|
|
|
else if (day > MONTHCAL_MonthLength(infoPtr->currentMonth,infoPtr->currentYear))
|
|
|
|
{
|
|
|
|
retval = MCHT_CALENDARDATENEXT;
|
|
|
|
lpht->st.wMonth = infoPtr->currentMonth + 1;
|
|
|
|
if (lpht->st.wMonth <12)
|
|
|
|
{
|
|
|
|
lpht->st.wMonth = 1;
|
|
|
|
lpht->st.wYear++;
|
|
|
|
}
|
|
|
|
lpht->st.wDay = day - MONTHCAL_MonthLength(infoPtr->currentMonth,infoPtr->currentYear) ;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
retval = MCHT_CALENDARDATE;
|
|
|
|
lpht->st.wMonth = infoPtr->currentMonth;
|
|
|
|
lpht->st.wDay = day;
|
2005-04-14 13:31:17 +02:00
|
|
|
lpht->st.wDayOfWeek = MONTHCAL_CalculateDayOfWeek(day,lpht->st.wMonth,lpht->st.wYear);
|
2000-10-15 02:27:28 +02:00
|
|
|
}
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
if(PtInRect(&infoPtr->todayrect, lpht->pt)) {
|
2002-06-01 01:06:46 +02:00
|
|
|
retval = MCHT_TODAYLINK;
|
1999-11-21 03:04:09 +01:00
|
|
|
goto done;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
/* Hit nothing special? What's left must be background :-) */
|
2002-06-01 01:06:46 +02:00
|
|
|
|
|
|
|
retval = MCHT_CALENDARBK;
|
|
|
|
done:
|
1999-11-21 03:04:09 +01:00
|
|
|
lpht->uHit = retval;
|
1999-07-10 14:00:04 +02:00
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-11-30 18:35:16 +01:00
|
|
|
static void MONTHCAL_GoToNextMonth(MONTHCAL_INFO *infoPtr)
|
1999-07-31 13:13:25 +02:00
|
|
|
{
|
2004-11-30 18:35:16 +01:00
|
|
|
DWORD dwStyle = GetWindowLongW(infoPtr->hwndSelf, GWL_STYLE);
|
1999-07-31 13:13:25 +02:00
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
TRACE("MONTHCAL_GoToNextMonth\n");
|
1999-07-31 13:13:25 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
infoPtr->currentMonth++;
|
2000-01-04 01:30:21 +01:00
|
|
|
if(infoPtr->currentMonth > 12) {
|
1999-11-21 03:04:09 +01:00
|
|
|
infoPtr->currentYear++;
|
|
|
|
infoPtr->currentMonth = 1;
|
|
|
|
}
|
1999-07-31 13:13:25 +02:00
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
if(dwStyle & MCS_DAYSTATE) {
|
1999-11-21 03:04:09 +01:00
|
|
|
NMDAYSTATE nmds;
|
|
|
|
int i;
|
1999-07-31 13:13:25 +02:00
|
|
|
|
2004-11-30 18:35:16 +01:00
|
|
|
nmds.nmhdr.hwndFrom = infoPtr->hwndSelf;
|
|
|
|
nmds.nmhdr.idFrom = GetWindowLongPtrW(infoPtr->hwndSelf, GWLP_ID);
|
1999-11-21 03:04:09 +01:00
|
|
|
nmds.nmhdr.code = MCN_GETDAYSTATE;
|
|
|
|
nmds.cDayState = infoPtr->monthRange;
|
2003-09-22 23:32:33 +02:00
|
|
|
nmds.prgDayState = Alloc(infoPtr->monthRange * sizeof(MONTHDAYSTATE));
|
1999-07-31 13:13:25 +02:00
|
|
|
|
2005-04-11 16:21:00 +02:00
|
|
|
SendMessageW(infoPtr->hwndNotify, WM_NOTIFY,
|
2000-01-04 01:30:21 +01:00
|
|
|
(WPARAM)nmds.nmhdr.idFrom, (LPARAM)&nmds);
|
|
|
|
for(i=0; i<infoPtr->monthRange; i++)
|
1999-11-21 03:04:09 +01:00
|
|
|
infoPtr->monthdayState[i] = nmds.prgDayState[i];
|
|
|
|
}
|
1999-07-31 13:13:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-11-30 18:35:16 +01:00
|
|
|
static void MONTHCAL_GoToPrevMonth(MONTHCAL_INFO *infoPtr)
|
1999-07-31 13:13:25 +02:00
|
|
|
{
|
2004-11-30 18:35:16 +01:00
|
|
|
DWORD dwStyle = GetWindowLongW(infoPtr->hwndSelf, GWL_STYLE);
|
1999-11-21 03:04:09 +01:00
|
|
|
|
2004-11-30 18:35:16 +01:00
|
|
|
TRACE("\n");
|
1999-11-21 03:04:09 +01:00
|
|
|
|
|
|
|
infoPtr->currentMonth--;
|
2000-01-04 01:30:21 +01:00
|
|
|
if(infoPtr->currentMonth < 1) {
|
1999-11-21 03:04:09 +01:00
|
|
|
infoPtr->currentYear--;
|
|
|
|
infoPtr->currentMonth = 12;
|
|
|
|
}
|
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
if(dwStyle & MCS_DAYSTATE) {
|
1999-11-21 03:04:09 +01:00
|
|
|
NMDAYSTATE nmds;
|
|
|
|
int i;
|
|
|
|
|
2004-11-30 18:35:16 +01:00
|
|
|
nmds.nmhdr.hwndFrom = infoPtr->hwndSelf;
|
|
|
|
nmds.nmhdr.idFrom = GetWindowLongPtrW(infoPtr->hwndSelf, GWLP_ID);
|
1999-11-21 03:04:09 +01:00
|
|
|
nmds.nmhdr.code = MCN_GETDAYSTATE;
|
|
|
|
nmds.cDayState = infoPtr->monthRange;
|
2003-09-22 23:32:33 +02:00
|
|
|
nmds.prgDayState = Alloc
|
2000-01-04 01:30:21 +01:00
|
|
|
(infoPtr->monthRange * sizeof(MONTHDAYSTATE));
|
1999-11-21 03:04:09 +01:00
|
|
|
|
2005-04-11 16:21:00 +02:00
|
|
|
SendMessageW(infoPtr->hwndNotify, WM_NOTIFY,
|
2000-01-04 01:30:21 +01:00
|
|
|
(WPARAM)nmds.nmhdr.idFrom, (LPARAM)&nmds);
|
|
|
|
for(i=0; i<infoPtr->monthRange; i++)
|
|
|
|
infoPtr->monthdayState[i] = nmds.prgDayState[i];
|
1999-11-21 03:04:09 +01:00
|
|
|
}
|
1999-07-31 13:13:25 +02:00
|
|
|
}
|
|
|
|
|
2000-10-15 02:27:28 +02:00
|
|
|
static LRESULT
|
2004-11-30 18:35:16 +01:00
|
|
|
MONTHCAL_RButtonDown(MONTHCAL_INFO *infoPtr, LPARAM lParam)
|
2000-10-15 02:27:28 +02:00
|
|
|
{
|
2005-04-11 16:21:00 +02:00
|
|
|
static const WCHAR todayW[] = { 'G','o',' ','t','o',' ','T','o','d','a','y',':',0 };
|
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();
|
2005-04-11 16:21:00 +02:00
|
|
|
if (!LoadStringW(COMCTL32_hModule,IDM_GOTODAY,buf,countof(buf)))
|
2000-10-15 02:27:28 +02:00
|
|
|
{
|
|
|
|
WARN("Can't load resource\n");
|
2005-04-11 16:21:00 +02:00
|
|
|
strcpyW(buf, todayW);
|
2000-10-15 02:27:28 +02:00
|
|
|
}
|
2005-04-11 16:21:00 +02:00
|
|
|
AppendMenuW(hMenu, MF_STRING|MF_ENABLED,1, buf);
|
2006-10-25 17:41:48 +02:00
|
|
|
menupoint.x=(short)LOWORD(lParam);
|
|
|
|
menupoint.y=(short)HIWORD(lParam);
|
2004-11-30 18:35:16 +01:00
|
|
|
ClientToScreen(infoPtr->hwndSelf, &menupoint);
|
2000-10-15 02:27:28 +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))
|
2000-10-15 02:27:28 +02:00
|
|
|
{
|
|
|
|
infoPtr->currentMonth=infoPtr->todaysDate.wMonth;
|
|
|
|
infoPtr->currentYear=infoPtr->todaysDate.wYear;
|
2004-11-30 18:35:16 +01:00
|
|
|
InvalidateRect(infoPtr->hwndSelf, NULL, FALSE);
|
2002-06-01 01:06:46 +02:00
|
|
|
}
|
2000-10-15 02:27:28 +02:00
|
|
|
return 0;
|
|
|
|
}
|
1999-07-31 13:13:25 +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
|
|
|
{
|
2005-04-11 16:21:00 +02:00
|
|
|
static const WCHAR EditW[] = { 'E','D','I','T',0 };
|
1999-11-21 03:04:09 +01:00
|
|
|
MCHITTESTINFO ht;
|
|
|
|
DWORD hit;
|
|
|
|
HMENU hMenu;
|
2000-05-30 22:06:33 +02:00
|
|
|
RECT rcDay; /* used in determining area to invalidate */
|
2005-04-11 16:21:00 +02:00
|
|
|
WCHAR buf[32];
|
2000-10-15 02:27:28 +02:00
|
|
|
int i;
|
|
|
|
POINT menupoint;
|
2004-11-30 18:35:16 +01:00
|
|
|
|
|
|
|
TRACE("%lx\n", lParam);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-10-15 02:27:28 +02:00
|
|
|
if (infoPtr->hWndYearUpDown)
|
|
|
|
{
|
2005-04-11 16:21:00 +02:00
|
|
|
infoPtr->currentYear=SendMessageW( infoPtr->hWndYearUpDown, UDM_SETPOS, (WPARAM) 0,(LPARAM)0);
|
2000-10-15 02:27:28 +02:00
|
|
|
if(!DestroyWindow(infoPtr->hWndYearUpDown))
|
|
|
|
{
|
|
|
|
FIXME("Can't destroy Updown Control\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
infoPtr->hWndYearUpDown=0;
|
|
|
|
if(!DestroyWindow(infoPtr->hWndYearEdit))
|
|
|
|
{
|
|
|
|
FIXME("Can't destroy Updown Control\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
infoPtr->hWndYearEdit=0;
|
2004-11-30 18:35:16 +01:00
|
|
|
InvalidateRect(infoPtr->hwndSelf, NULL, FALSE);
|
2000-10-15 02:27:28 +02:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2006-10-25 17:41:48 +02:00
|
|
|
ht.pt.x = (short)LOWORD(lParam);
|
|
|
|
ht.pt.y = (short)HIWORD(lParam);
|
2004-11-30 18:35:16 +01:00
|
|
|
hit = MONTHCAL_HitTest(infoPtr, (LPARAM)&ht);
|
1999-11-21 03:04:09 +01:00
|
|
|
|
|
|
|
/* FIXME: these flags should be checked by */
|
2000-01-04 01:30:21 +01:00
|
|
|
/*((hit & MCHT_XXX) == MCHT_XXX) b/c some of the flags are */
|
1999-11-21 03:04:09 +01:00
|
|
|
/* multi-bit */
|
2000-10-15 02:27:28 +02:00
|
|
|
if(hit ==MCHT_TITLEBTNNEXT) {
|
2004-11-30 18:35:16 +01:00
|
|
|
MONTHCAL_GoToNextMonth(infoPtr);
|
1999-11-21 03:04:09 +01:00
|
|
|
infoPtr->status = MC_NEXTPRESSED;
|
2004-11-30 18:35:16 +01:00
|
|
|
SetTimer(infoPtr->hwndSelf, MC_NEXTMONTHTIMER, MC_NEXTMONTHDELAY, 0);
|
|
|
|
InvalidateRect(infoPtr->hwndSelf, NULL, FALSE);
|
2000-10-15 02:27:28 +02:00
|
|
|
return TRUE;
|
1999-11-21 03:04:09 +01:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
if(hit == MCHT_TITLEBTNPREV){
|
2004-11-30 18:35:16 +01:00
|
|
|
MONTHCAL_GoToPrevMonth(infoPtr);
|
2000-01-04 01:30:21 +01:00
|
|
|
infoPtr->status = MC_PREVPRESSED;
|
2004-11-30 18:35:16 +01:00
|
|
|
SetTimer(infoPtr->hwndSelf, MC_PREVMONTHTIMER, MC_NEXTMONTHDELAY, 0);
|
|
|
|
InvalidateRect(infoPtr->hwndSelf, NULL, FALSE);
|
2000-10-15 02:27:28 +02:00
|
|
|
return TRUE;
|
1999-11-21 03:04:09 +01:00
|
|
|
}
|
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
if(hit == MCHT_TITLEMONTH) {
|
2000-10-15 02:27:28 +02:00
|
|
|
hMenu = CreatePopupMenu();
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-10-15 02:27:28 +02:00
|
|
|
for (i=0; i<12;i++)
|
|
|
|
{
|
2005-04-11 16:21:00 +02:00
|
|
|
GetLocaleInfoW(LOCALE_USER_DEFAULT,LOCALE_SMONTHNAME1+i, buf,countof(buf));
|
|
|
|
AppendMenuW(hMenu, MF_STRING|MF_ENABLED,i+1, buf);
|
2000-10-15 02:27:28 +02:00
|
|
|
}
|
|
|
|
menupoint.x=infoPtr->titlemonth.right;
|
|
|
|
menupoint.y=infoPtr->titlemonth.bottom;
|
2004-11-30 18:35:16 +01:00
|
|
|
ClientToScreen(infoPtr->hwndSelf, &menupoint);
|
2000-10-15 02:27:28 +02:00
|
|
|
i= TrackPopupMenu(hMenu,TPM_LEFTALIGN | TPM_NONOTIFY | TPM_RIGHTBUTTON | TPM_RETURNCMD,
|
2004-11-30 18:35:16 +01:00
|
|
|
menupoint.x, menupoint.y, 0, infoPtr->hwndSelf, NULL);
|
2000-10-15 02:27:28 +02:00
|
|
|
if ((i>0) && (i<13))
|
|
|
|
{
|
|
|
|
infoPtr->currentMonth=i;
|
2004-11-30 18:35:16 +01:00
|
|
|
InvalidateRect(infoPtr->hwndSelf, NULL, FALSE);
|
2000-10-15 02:27:28 +02:00
|
|
|
}
|
1999-11-21 03:04:09 +01:00
|
|
|
}
|
2000-01-04 01:30:21 +01:00
|
|
|
if(hit == MCHT_TITLEYEAR) {
|
2005-04-11 16:21:00 +02:00
|
|
|
infoPtr->hWndYearEdit=CreateWindowExW(0,
|
|
|
|
EditW,
|
2000-10-15 02:27:28 +02:00
|
|
|
0,
|
|
|
|
WS_VISIBLE | WS_CHILD |UDS_SETBUDDYINT,
|
|
|
|
infoPtr->titleyear.left+3,infoPtr->titlebtnnext.top,
|
2005-04-20 14:51:37 +02:00
|
|
|
infoPtr->titleyear.right-infoPtr->titleyear.left+4,
|
2000-10-15 02:27:28 +02:00
|
|
|
infoPtr->textHeight,
|
2004-11-30 18:35:16 +01:00
|
|
|
infoPtr->hwndSelf,
|
2002-12-02 19:10:57 +01:00
|
|
|
NULL,
|
|
|
|
NULL,
|
2000-10-15 02:27:28 +02:00
|
|
|
NULL);
|
2005-04-20 14:51:37 +02:00
|
|
|
SendMessageW( infoPtr->hWndYearEdit, WM_SETFONT, (WPARAM) infoPtr->hBoldFont, (LPARAM)TRUE);
|
2005-04-11 16:21:00 +02:00
|
|
|
infoPtr->hWndYearUpDown=CreateWindowExW(0,
|
|
|
|
UPDOWN_CLASSW,
|
2000-10-15 02:27:28 +02:00
|
|
|
0,
|
|
|
|
WS_VISIBLE | WS_CHILD |UDS_SETBUDDYINT|UDS_NOTHOUSANDS|UDS_ARROWKEYS,
|
2005-04-20 14:51:37 +02:00
|
|
|
infoPtr->titleyear.right+7,infoPtr->titlebtnnext.top,
|
|
|
|
18,
|
2000-10-15 02:27:28 +02:00
|
|
|
infoPtr->textHeight,
|
2004-11-30 18:35:16 +01:00
|
|
|
infoPtr->hwndSelf,
|
2002-12-02 19:10:57 +01:00
|
|
|
NULL,
|
|
|
|
NULL,
|
2000-10-15 02:27:28 +02:00
|
|
|
NULL);
|
2005-04-11 16:21:00 +02:00
|
|
|
SendMessageW( infoPtr->hWndYearUpDown, UDM_SETRANGE, (WPARAM) 0, MAKELONG (9999, 1753));
|
|
|
|
SendMessageW( infoPtr->hWndYearUpDown, UDM_SETBUDDY, (WPARAM) infoPtr->hWndYearEdit, (LPARAM)0 );
|
|
|
|
SendMessageW( infoPtr->hWndYearUpDown, UDM_SETPOS, (WPARAM) 0,(LPARAM)infoPtr->currentYear );
|
2000-10-15 02:27:28 +02:00
|
|
|
return TRUE;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
}
|
2000-01-04 01:30:21 +01:00
|
|
|
if(hit == MCHT_TODAYLINK) {
|
2000-10-15 02:27:28 +02:00
|
|
|
infoPtr->currentMonth=infoPtr->todaysDate.wMonth;
|
|
|
|
infoPtr->currentYear=infoPtr->todaysDate.wYear;
|
2004-11-30 18:35:16 +01:00
|
|
|
InvalidateRect(infoPtr->hwndSelf, NULL, FALSE);
|
2000-10-15 02:27:28 +02:00
|
|
|
return TRUE;
|
1999-11-21 03:04:09 +01:00
|
|
|
}
|
2004-04-22 00:24:09 +02:00
|
|
|
if(hit == MCHT_CALENDARDATE) {
|
1999-11-21 03:04:09 +01:00
|
|
|
SYSTEMTIME selArray[2];
|
|
|
|
NMSELCHANGE nmsc;
|
|
|
|
|
2004-04-22 00:24:09 +02:00
|
|
|
MONTHCAL_CopyTime(&ht.st, &selArray[0]);
|
|
|
|
MONTHCAL_CopyTime(&ht.st, &selArray[1]);
|
2004-11-30 18:35:16 +01:00
|
|
|
MONTHCAL_SetSelRange(infoPtr, (LPARAM)&selArray);
|
|
|
|
MONTHCAL_SetCurSel(infoPtr, (LPARAM)&selArray);
|
2000-10-15 02:27:28 +02:00
|
|
|
TRACE("MCHT_CALENDARDATE\n");
|
2004-11-30 18:35:16 +01:00
|
|
|
nmsc.nmhdr.hwndFrom = infoPtr->hwndSelf;
|
|
|
|
nmsc.nmhdr.idFrom = GetWindowLongPtrW(infoPtr->hwndSelf, GWLP_ID);
|
1999-11-21 03:04:09 +01:00
|
|
|
nmsc.nmhdr.code = MCN_SELCHANGE;
|
2004-04-22 00:24:09 +02:00
|
|
|
MONTHCAL_CopyTime(&infoPtr->minSel,&nmsc.stSelStart);
|
|
|
|
MONTHCAL_CopyTime(&infoPtr->maxSel,&nmsc.stSelEnd);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2005-04-11 16:21:00 +02:00
|
|
|
SendMessageW(infoPtr->hwndNotify, WM_NOTIFY,
|
2000-01-04 01:30:21 +01:00
|
|
|
(WPARAM)nmsc.nmhdr.idFrom,(LPARAM)&nmsc);
|
1999-07-31 13:13:25 +02:00
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
|
2000-05-30 22:06:33 +02:00
|
|
|
/* redraw both old and new days if the selected day changed */
|
2000-01-04 01:30:21 +01:00
|
|
|
if(infoPtr->curSelDay != ht.st.wDay) {
|
2000-05-30 22:06:33 +02:00
|
|
|
MONTHCAL_CalcPosFromDay(infoPtr, ht.st.wDay, ht.st.wMonth, &rcDay);
|
2004-11-30 18:35:16 +01:00
|
|
|
InvalidateRect(infoPtr->hwndSelf, &rcDay, TRUE);
|
2000-05-30 22:06:33 +02:00
|
|
|
|
|
|
|
MONTHCAL_CalcPosFromDay(infoPtr, infoPtr->curSelDay, infoPtr->currentMonth, &rcDay);
|
2004-11-30 18:35:16 +01:00
|
|
|
InvalidateRect(infoPtr->hwndSelf, &rcDay, TRUE);
|
2000-01-04 01:30:21 +01:00
|
|
|
}
|
1999-07-10 14:00:04 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
infoPtr->firstSelDay = ht.st.wDay;
|
|
|
|
infoPtr->curSelDay = ht.st.wDay;
|
|
|
|
infoPtr->status = MC_SEL_LBUTDOWN;
|
2000-10-15 02:27:28 +02:00
|
|
|
return TRUE;
|
2000-01-04 01:30:21 +01: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
|
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
|
|
|
NMSELCHANGE nmsc;
|
|
|
|
NMHDR nmhdr;
|
2000-01-04 01:30:21 +01:00
|
|
|
BOOL redraw = FALSE;
|
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
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
if(infoPtr->status & MC_NEXTPRESSED) {
|
2004-11-30 18:35:16 +01:00
|
|
|
KillTimer(infoPtr->hwndSelf, MC_NEXTMONTHTIMER);
|
2004-04-22 00:24:09 +02:00
|
|
|
infoPtr->status &= ~MC_NEXTPRESSED;
|
2000-01-04 01:30:21 +01:00
|
|
|
redraw = TRUE;
|
|
|
|
}
|
|
|
|
if(infoPtr->status & MC_PREVPRESSED) {
|
2004-11-30 18:35:16 +01:00
|
|
|
KillTimer(infoPtr->hwndSelf, MC_PREVMONTHTIMER);
|
2004-04-22 00:24:09 +02:00
|
|
|
infoPtr->status &= ~MC_PREVPRESSED;
|
2000-01-04 01:30:21 +01:00
|
|
|
redraw = TRUE;
|
|
|
|
}
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2006-10-25 17:41:48 +02:00
|
|
|
ht.pt.x = (short)LOWORD(lParam);
|
|
|
|
ht.pt.y = (short)HIWORD(lParam);
|
2004-11-30 18:35:16 +01:00
|
|
|
hit = MONTHCAL_HitTest(infoPtr, (LPARAM)&ht);
|
2000-10-15 02:27:28 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
infoPtr->status = MC_SEL_LBUTUP;
|
1999-07-31 13:13:25 +02:00
|
|
|
|
2000-10-15 02:27:28 +02:00
|
|
|
if(hit ==MCHT_CALENDARDATENEXT) {
|
2004-11-30 18:35:16 +01:00
|
|
|
MONTHCAL_GoToNextMonth(infoPtr);
|
|
|
|
InvalidateRect(infoPtr->hwndSelf, NULL, FALSE);
|
2000-10-15 02:27:28 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
if(hit == MCHT_CALENDARDATEPREV){
|
2004-11-30 18:35:16 +01:00
|
|
|
MONTHCAL_GoToPrevMonth(infoPtr);
|
|
|
|
InvalidateRect(infoPtr->hwndSelf, NULL, FALSE);
|
2000-10-15 02:27:28 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
2004-11-30 18:35:16 +01:00
|
|
|
nmhdr.hwndFrom = infoPtr->hwndSelf;
|
|
|
|
nmhdr.idFrom = GetWindowLongPtrW(infoPtr->hwndSelf, GWLP_ID);
|
1999-11-21 03:04:09 +01:00
|
|
|
nmhdr.code = NM_RELEASEDCAPTURE;
|
2004-11-30 18:35:16 +01:00
|
|
|
TRACE("Sent notification from %p to %p\n", infoPtr->hwndSelf, infoPtr->hwndNotify);
|
1999-07-31 13:13:25 +02:00
|
|
|
|
2005-04-11 16:21:00 +02:00
|
|
|
SendMessageW(infoPtr->hwndNotify, WM_NOTIFY, (WPARAM)nmhdr.idFrom, (LPARAM)&nmhdr);
|
2000-01-04 01:30:21 +01:00
|
|
|
/* redraw if necessary */
|
2000-05-30 22:06:33 +02:00
|
|
|
if(redraw)
|
2004-11-30 18:35:16 +01:00
|
|
|
InvalidateRect(infoPtr->hwndSelf, NULL, FALSE);
|
2004-04-22 00:24:09 +02:00
|
|
|
/* only send MCN_SELECT if currently displayed month's day was selected */
|
|
|
|
if(hit == MCHT_CALENDARDATE) {
|
2004-11-30 18:35:16 +01:00
|
|
|
nmsc.nmhdr.hwndFrom = infoPtr->hwndSelf;
|
|
|
|
nmsc.nmhdr.idFrom = GetWindowLongPtrW(infoPtr->hwndSelf, GWLP_ID);
|
2004-04-22 00:24:09 +02:00
|
|
|
nmsc.nmhdr.code = MCN_SELECT;
|
|
|
|
MONTHCAL_CopyTime(&infoPtr->minSel, &nmsc.stSelStart);
|
|
|
|
MONTHCAL_CopyTime(&infoPtr->maxSel, &nmsc.stSelEnd);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2005-04-11 16:21:00 +02:00
|
|
|
SendMessageW(infoPtr->hwndNotify, WM_NOTIFY, (WPARAM)nmsc.nmhdr.idFrom, (LPARAM)&nmsc);
|
2004-04-22 00:24:09 +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
|
2004-11-30 18:35:16 +01:00
|
|
|
MONTHCAL_Timer(MONTHCAL_INFO *infoPtr, WPARAM wParam)
|
1999-07-31 13:13:25 +02:00
|
|
|
{
|
2000-01-04 01:30:21 +01:00
|
|
|
BOOL redraw = FALSE;
|
1999-11-21 03:04:09 +01:00
|
|
|
|
2007-05-24 16:41:17 +02:00
|
|
|
TRACE("%ld\n", wParam);
|
1999-11-21 03:04:09 +01:00
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
switch(wParam) {
|
2002-06-01 01:06:46 +02:00
|
|
|
case MC_NEXTMONTHTIMER:
|
2000-01-04 01:30:21 +01:00
|
|
|
redraw = TRUE;
|
2004-11-30 18:35:16 +01:00
|
|
|
MONTHCAL_GoToNextMonth(infoPtr);
|
1999-11-21 03:04:09 +01:00
|
|
|
break;
|
|
|
|
case MC_PREVMONTHTIMER:
|
2000-01-04 01:30:21 +01:00
|
|
|
redraw = TRUE;
|
2004-11-30 18:35:16 +01:00
|
|
|
MONTHCAL_GoToPrevMonth(infoPtr);
|
1999-11-21 03:04:09 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ERR("got unknown timer\n");
|
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
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
/* redraw only if necessary */
|
2000-05-30 22:06:33 +02:00
|
|
|
if(redraw)
|
2004-11-30 18:35:16 +01:00
|
|
|
InvalidateRect(infoPtr->hwndSelf, NULL, FALSE);
|
2000-01-04 01:30:21 +01: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
|
2004-11-30 18:35:16 +01:00
|
|
|
MONTHCAL_MouseMove(MONTHCAL_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
|
1999-07-10 14:00:04 +02:00
|
|
|
{
|
1999-11-21 03:04:09 +01:00
|
|
|
MCHITTESTINFO ht;
|
|
|
|
int oldselday, selday, hit;
|
|
|
|
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
|
|
|
|
2006-10-25 17:41:48 +02:00
|
|
|
ht.pt.x = (short)LOWORD(lParam);
|
|
|
|
ht.pt.y = (short)HIWORD(lParam);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2004-11-30 18:35:16 +01:00
|
|
|
hit = MONTHCAL_HitTest(infoPtr, (LPARAM)&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);
|
|
|
|
if((hit & MCHT_CALENDARDATE) != MCHT_CALENDARDATE) return 0;
|
1999-11-21 03:04:09 +01:00
|
|
|
|
|
|
|
selday = ht.st.wDay;
|
|
|
|
oldselday = infoPtr->curSelDay;
|
|
|
|
infoPtr->curSelDay = selday;
|
2000-01-04 01:30:21 +01:00
|
|
|
MONTHCAL_CalcPosFromDay(infoPtr, selday, ht.st. wMonth, &r);
|
1999-11-21 03:04:09 +01:00
|
|
|
|
2004-11-30 18:35:16 +01:00
|
|
|
if(GetWindowLongW(infoPtr->hwndSelf, GWL_STYLE) & MCS_MULTISELECT) {
|
1999-11-21 03:04:09 +01:00
|
|
|
SYSTEMTIME selArray[2];
|
|
|
|
int i;
|
|
|
|
|
2004-11-30 18:35:16 +01:00
|
|
|
MONTHCAL_GetSelRange(infoPtr, (LPARAM)&selArray);
|
1999-11-21 03:04:09 +01:00
|
|
|
i = 0;
|
2000-01-04 01:30:21 +01:00
|
|
|
if(infoPtr->firstSelDay==selArray[0].wDay) i=1;
|
|
|
|
TRACE("oldRange:%d %d %d %d\n", infoPtr->firstSelDay, selArray[0].wDay, selArray[1].wDay, i);
|
2002-06-01 01:06:46 +02:00
|
|
|
if(infoPtr->firstSelDay==selArray[1].wDay) {
|
1999-11-21 03:04:09 +01:00
|
|
|
/* 1st time we get here: selArray[0]=selArray[1]) */
|
|
|
|
/* if we're still at the first selected date, return */
|
2000-01-04 01:30:21 +01:00
|
|
|
if(infoPtr->firstSelDay==selday) goto done;
|
|
|
|
if(selday<infoPtr->firstSelDay) i = 0;
|
1999-11-21 03:04:09 +01:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
if(abs(infoPtr->firstSelDay - selday) >= infoPtr->maxSelCount) {
|
|
|
|
if(selday>infoPtr->firstSelDay)
|
1999-11-21 03:04:09 +01:00
|
|
|
selday = infoPtr->firstSelDay + infoPtr->maxSelCount;
|
|
|
|
else
|
|
|
|
selday = infoPtr->firstSelDay - infoPtr->maxSelCount;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
if(selArray[i].wDay!=selday) {
|
|
|
|
TRACE("newRange:%d %d %d %d\n", infoPtr->firstSelDay, selArray[0].wDay, selArray[1].wDay, i);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
selArray[i].wDay = selday;
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
if(selArray[0].wDay>selArray[1].wDay) {
|
1999-11-21 03:04:09 +01:00
|
|
|
DWORD tempday;
|
|
|
|
tempday = selArray[1].wDay;
|
|
|
|
selArray[1].wDay = selArray[0].wDay;
|
|
|
|
selArray[0].wDay = tempday;
|
|
|
|
}
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2004-11-30 18:35:16 +01:00
|
|
|
MONTHCAL_SetSelRange(infoPtr, (LPARAM)&selArray);
|
1999-11-21 03:04:09 +01:00
|
|
|
}
|
|
|
|
}
|
1999-07-10 14:00:04 +02:00
|
|
|
|
|
|
|
done:
|
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
/* only redraw if the currently selected day changed */
|
2000-05-30 22:06:33 +02:00
|
|
|
/* FIXME: this should specify a rectangle containing only the days that changed */
|
2000-09-22 22:49:12 +02:00
|
|
|
/* using InvalidateRect */
|
2000-05-30 22:06:33 +02:00
|
|
|
if(oldselday != infoPtr->curSelDay)
|
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
|
|
|
}
|
|
|
|
|
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_Paint(MONTHCAL_INFO *infoPtr, WPARAM wParam)
|
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
|
|
|
|
2004-11-08 21:27:02 +01:00
|
|
|
if (wParam)
|
|
|
|
{
|
2004-11-30 18:35:16 +01:00
|
|
|
GetClientRect(infoPtr->hwndSelf, &ps.rcPaint);
|
2004-11-08 21:27:02 +01:00
|
|
|
hdc = (HDC)wParam;
|
|
|
|
}
|
|
|
|
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);
|
|
|
|
if (!wParam) EndPaint(infoPtr->hwndSelf, &ps);
|
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
|
2007-03-29 23:09:32 +02:00
|
|
|
MONTHCAL_KillFocus(const MONTHCAL_INFO *infoPtr)
|
1999-07-10 14:00:04 +02:00
|
|
|
{
|
2000-01-04 01:30:21 +01:00
|
|
|
TRACE("\n");
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2004-11-30 18:35:16 +01:00
|
|
|
InvalidateRect(infoPtr->hwndSelf, NULL, TRUE);
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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 SunW[] = { 'S','u','n',0 };
|
|
|
|
static const WCHAR O0W[] = { '0','0',0 };
|
2004-11-30 18:35:16 +01:00
|
|
|
HDC hdc = GetDC(infoPtr->hwndSelf);
|
2000-01-04 01:30:21 +01:00
|
|
|
RECT *title=&infoPtr->title;
|
|
|
|
RECT *prev=&infoPtr->titlebtnprev;
|
|
|
|
RECT *next=&infoPtr->titlebtnnext;
|
|
|
|
RECT *titlemonth=&infoPtr->titlemonth;
|
|
|
|
RECT *titleyear=&infoPtr->titleyear;
|
2000-10-15 02:27:28 +02:00
|
|
|
RECT *wdays=&infoPtr->wdays;
|
|
|
|
RECT *weeknumrect=&infoPtr->weeknums;
|
2000-01-04 01:30:21 +01:00
|
|
|
RECT *days=&infoPtr->days;
|
2000-10-15 02:27:28 +02:00
|
|
|
RECT *todayrect=&infoPtr->todayrect;
|
2000-01-04 01:30:21 +01:00
|
|
|
SIZE size;
|
2005-04-11 16:21:00 +02:00
|
|
|
TEXTMETRICW tm;
|
2004-11-30 18:35:16 +01:00
|
|
|
DWORD dwStyle = GetWindowLongW(infoPtr->hwndSelf, GWL_STYLE);
|
2000-01-04 01:30:21 +01:00
|
|
|
HFONT currentFont;
|
2004-11-08 21:27:02 +01:00
|
|
|
int xdiv, left_offset;
|
|
|
|
RECT rcClient;
|
2000-01-04 01:30:21 +01:00
|
|
|
|
2004-11-30 18:35:16 +01:00
|
|
|
GetClientRect(infoPtr->hwndSelf, &rcClient);
|
2000-01-04 01:30:21 +01:00
|
|
|
|
2004-11-08 21:27:02 +01:00
|
|
|
currentFont = 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;
|
2005-04-11 16:21:00 +02:00
|
|
|
GetTextExtentPoint32W(hdc, SunW, 3, &size);
|
2000-01-04 01:30:21 +01:00
|
|
|
infoPtr->textWidth = size.cx + 2;
|
|
|
|
|
2004-11-08 21:27:02 +01:00
|
|
|
/* recalculate the height and width increments and offsets */
|
2005-04-11 16:21:00 +02:00
|
|
|
GetTextExtentPoint32W(hdc, O0W, 2, &size);
|
2000-01-04 01:30:21 +01:00
|
|
|
|
2004-11-08 21:27:02 +01:00
|
|
|
xdiv = (dwStyle & MCS_WEEKNUMBERS) ? 8 : 7;
|
2000-01-04 01:30:21 +01:00
|
|
|
|
2005-04-20 14:51:37 +02:00
|
|
|
infoPtr->width_increment = size.cx * 2 + 4;
|
2004-11-08 21:27:02 +01:00
|
|
|
infoPtr->height_increment = infoPtr->textHeight;
|
|
|
|
left_offset = (rcClient.right - rcClient.left) - (infoPtr->width_increment * xdiv);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
/* calculate title area */
|
2004-11-08 21:27:02 +01:00
|
|
|
title->top = rcClient.top;
|
|
|
|
title->bottom = title->top + 3 * infoPtr->height_increment / 2;
|
|
|
|
title->left = left_offset;
|
|
|
|
title->right = rcClient.right;
|
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;
|
2000-10-15 02:27:28 +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
|
|
|
|
2000-01-04 01:30:21 +01: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
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
/* setup the dimensions of the rectangle we draw the names of the */
|
|
|
|
/* days of the week in */
|
2004-11-08 21:27:02 +01:00
|
|
|
weeknumrect->left = left_offset;
|
2002-06-01 01:06:46 +02:00
|
|
|
if(dwStyle & MCS_WEEKNUMBERS)
|
2000-10-15 02:27:28 +02:00
|
|
|
weeknumrect->right=prev->right;
|
|
|
|
else
|
|
|
|
weeknumrect->right=weeknumrect->left;
|
|
|
|
wdays->left = days->left = weeknumrect->right;
|
|
|
|
wdays->right = days->right = wdays->left + 7 * infoPtr->width_increment;
|
|
|
|
wdays->top = title->bottom ;
|
|
|
|
wdays->bottom = wdays->top + infoPtr->height_increment;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-10-15 02:27:28 +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
|
|
|
|
2004-11-08 21:27:02 +01:00
|
|
|
todayrect->left = rcClient.left;
|
|
|
|
todayrect->right = rcClient.right;
|
2000-10-15 02:27:28 +02:00
|
|
|
todayrect->top = days->bottom;
|
|
|
|
todayrect->bottom = days->bottom + infoPtr->height_increment;
|
|
|
|
|
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,
|
2004-11-08 21:27:02 +01:00
|
|
|
wine_dbgstr_rect(&rcClient),
|
|
|
|
wine_dbgstr_rect(title),
|
|
|
|
wine_dbgstr_rect(wdays),
|
|
|
|
wine_dbgstr_rect(days),
|
|
|
|
wine_dbgstr_rect(todayrect));
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
/* restore the originally selected font */
|
2002-06-01 01:06:46 +02:00
|
|
|
SelectObject(hdc, currentFont);
|
2000-01-04 01:30:21 +01:00
|
|
|
|
2004-11-30 18:35:16 +01:00
|
|
|
ReleaseDC(infoPtr->hwndSelf, hdc);
|
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);
|
2000-01-04 01:30:21 +01:00
|
|
|
|
|
|
|
/* invalidate client area and erase background */
|
2004-11-30 18:35:16 +01:00
|
|
|
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);
|
|
|
|
|
|
|
|
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);
|
|
|
|
theme = OpenThemeData (infoPtr->hwndSelf, themeClass);
|
|
|
|
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
|
2000-01-04 01:30:21 +01:00
|
|
|
MONTHCAL_Create(HWND hwnd, WPARAM wParam, LPARAM lParam)
|
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 */
|
2003-09-22 23:32:33 +02:00
|
|
|
infoPtr =(MONTHCAL_INFO*)Alloc(sizeof(MONTHCAL_INFO));
|
2004-08-25 19:33:01 +02:00
|
|
|
SetWindowLongPtrW(hwnd, 0, (DWORD_PTR)infoPtr);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2000-01-04 01:30:21 +01: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;
|
2003-11-20 23:04:13 +01:00
|
|
|
infoPtr->hwndNotify = ((LPCREATESTRUCTW)lParam)->hwndParent;
|
|
|
|
|
2004-11-30 18:35:16 +01:00
|
|
|
MONTHCAL_SetFont(infoPtr, GetStockObject(DEFAULT_GUI_FONT), FALSE);
|
1999-11-21 03:04:09 +01:00
|
|
|
|
|
|
|
/* initialize info structure */
|
2000-01-04 01:30:21 +01:00
|
|
|
/* FIXME: calculate systemtime ->> localtime(substract timezoneinfo) */
|
1999-11-21 03:04:09 +01:00
|
|
|
|
2005-04-20 14:51:37 +02:00
|
|
|
GetLocalTime(&infoPtr->todaysDate);
|
2007-04-10 03:25:41 +02:00
|
|
|
infoPtr->firstDayHighWord = FALSE;
|
2004-11-30 18:35:16 +01:00
|
|
|
MONTHCAL_SetFirstDayOfWeek(infoPtr, (LPARAM)-1);
|
1999-11-21 03:04:09 +01:00
|
|
|
infoPtr->currentMonth = infoPtr->todaysDate.wMonth;
|
|
|
|
infoPtr->currentYear = infoPtr->todaysDate.wYear;
|
2000-01-04 01:30:21 +01:00
|
|
|
MONTHCAL_CopyTime(&infoPtr->todaysDate, &infoPtr->minDate);
|
|
|
|
MONTHCAL_CopyTime(&infoPtr->todaysDate, &infoPtr->maxDate);
|
2004-04-22 00:24:09 +02:00
|
|
|
infoPtr->maxDate.wYear=2050;
|
|
|
|
infoPtr->minDate.wYear=1950;
|
2000-10-15 02:27:28 +02:00
|
|
|
infoPtr->maxSelCount = 7;
|
1999-11-21 03:04:09 +01:00
|
|
|
infoPtr->monthRange = 3;
|
2003-09-22 23:32:33 +02:00
|
|
|
infoPtr->monthdayState = Alloc
|
2000-01-04 01:30:21 +01:00
|
|
|
(infoPtr->monthRange * sizeof(MONTHDAYSTATE));
|
|
|
|
infoPtr->titlebk = GetSysColor(COLOR_ACTIVECAPTION);
|
|
|
|
infoPtr->titletxt = GetSysColor(COLOR_WINDOW);
|
|
|
|
infoPtr->monthbk = GetSysColor(COLOR_WINDOW);
|
|
|
|
infoPtr->trailingtxt = GetSysColor(COLOR_GRAYTEXT);
|
|
|
|
infoPtr->bk = GetSysColor(COLOR_WINDOW);
|
|
|
|
infoPtr->txt = GetSysColor(COLOR_WINDOWTEXT);
|
|
|
|
|
2006-12-24 08:43:56 +01:00
|
|
|
/* set the current day for highlighing */
|
|
|
|
infoPtr->minSel.wDay = infoPtr->todaysDate.wDay;
|
|
|
|
infoPtr->maxSel.wDay = infoPtr->todaysDate.wDay;
|
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
/* call MONTHCAL_UpdateSize to set all of the dimensions */
|
|
|
|
/* of the control */
|
2004-11-30 18:35:16 +01:00
|
|
|
MONTHCAL_UpdateSize(infoPtr);
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static LRESULT
|
2004-11-30 18:35:16 +01:00
|
|
|
MONTHCAL_Destroy(MONTHCAL_INFO *infoPtr)
|
1998-11-08 12:30:27 +01:00
|
|
|
{
|
1999-11-21 03:04:09 +01:00
|
|
|
/* free month calendar info data */
|
2007-02-13 21:18:24 +01:00
|
|
|
Free(infoPtr->monthdayState);
|
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));
|
|
|
|
|
2003-09-22 23:32:33 +02:00
|
|
|
Free(infoPtr);
|
1999-11-21 03:04:09 +01:00
|
|
|
return 0;
|
1998-11-08 12:30:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
{
|
2004-11-30 18:35:16 +01:00
|
|
|
MONTHCAL_INFO *infoPtr;
|
|
|
|
|
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
|
|
|
|
|
|
|
infoPtr = MONTHCAL_GetInfoPtr(hwnd);
|
|
|
|
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:
|
2004-11-30 18:35:16 +01:00
|
|
|
return MONTHCAL_GetCurSel(infoPtr, lParam);
|
1999-07-31 13:13:25 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
case MCM_SETCURSEL:
|
2004-11-30 18:35:16 +01:00
|
|
|
return MONTHCAL_SetCurSel(infoPtr, 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:
|
2004-11-30 18:35:16 +01:00
|
|
|
return MONTHCAL_GetSelRange(infoPtr, lParam);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
case MCM_SETSELRANGE:
|
2004-11-30 18:35:16 +01:00
|
|
|
return MONTHCAL_SetSelRange(infoPtr, lParam);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
case MCM_GETMONTHRANGE:
|
2004-11-30 18:35:16 +01:00
|
|
|
return MONTHCAL_GetMonthRange(infoPtr);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
case MCM_SETDAYSTATE:
|
2004-11-30 18:35:16 +01:00
|
|
|
return MONTHCAL_SetDayState(infoPtr, wParam, lParam);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
case MCM_GETMINREQRECT:
|
2004-11-30 18:35:16 +01:00
|
|
|
return MONTHCAL_GetMinReqRect(infoPtr, 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:
|
2004-11-30 18:35:16 +01:00
|
|
|
return MONTHCAL_SetColor(infoPtr, wParam, lParam);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
case MCM_GETTODAY:
|
2004-11-30 18:35:16 +01:00
|
|
|
return MONTHCAL_GetToday(infoPtr, lParam);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
case MCM_SETTODAY:
|
2004-11-30 18:35:16 +01:00
|
|
|
return MONTHCAL_SetToday(infoPtr, lParam);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
case MCM_HITTEST:
|
2004-11-30 18:35:16 +01:00
|
|
|
return MONTHCAL_HitTest(infoPtr, 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:
|
2004-11-30 18:35:16 +01:00
|
|
|
return MONTHCAL_SetFirstDayOfWeek(infoPtr, lParam);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
case MCM_GETRANGE:
|
2000-01-04 01:30:21 +01:00
|
|
|
return MONTHCAL_GetRange(hwnd, wParam, lParam);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
case MCM_SETRANGE:
|
2004-11-30 18:35:16 +01:00
|
|
|
return MONTHCAL_SetRange(infoPtr, wParam, 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
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
case WM_GETDLGCODE:
|
|
|
|
return DLGC_WANTARROWS | DLGC_WANTCHARS;
|
1999-07-10 14:00:04 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
case WM_KILLFOCUS:
|
2004-11-30 18:35:16 +01:00
|
|
|
return MONTHCAL_KillFocus(infoPtr);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2000-10-15 02:27:28 +02:00
|
|
|
case WM_RBUTTONDOWN:
|
2004-11-30 18:35:16 +01:00
|
|
|
return MONTHCAL_RButtonDown(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:
|
2004-11-30 18:35:16 +01:00
|
|
|
return MONTHCAL_MouseMove(infoPtr, wParam, 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
|
|
|
|
2005-11-08 13:52:35 +01:00
|
|
|
case WM_PRINTCLIENT:
|
1999-11-21 03:04:09 +01:00
|
|
|
case WM_PAINT:
|
2004-11-30 18:35:16 +01:00
|
|
|
return MONTHCAL_Paint(infoPtr, wParam);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
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
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
case WM_CREATE:
|
2000-01-04 01:30:21 +01:00
|
|
|
return MONTHCAL_Create(hwnd, wParam, 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
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
default:
|
2002-07-16 03:23:59 +02:00
|
|
|
if ((uMsg >= WM_USER) && (uMsg < WM_APP))
|
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
|
|
|
}
|