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>
|
1998-11-08 12:30:27 +01:00
|
|
|
*
|
|
|
|
* TODO:
|
1999-07-10 14:00:04 +02:00
|
|
|
* - Notifications.
|
|
|
|
*
|
1998-11-08 12:30:27 +01:00
|
|
|
*
|
1999-07-10 14:00:04 +02:00
|
|
|
* FIXME: handle resources better (doesn't work now); also take care
|
|
|
|
of internationalization.
|
1999-07-31 13:13:25 +02:00
|
|
|
* FIXME: keyboard handling.
|
1998-11-08 12:30:27 +01:00
|
|
|
*/
|
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
#include <math.h>
|
2000-02-10 20:03:02 +01:00
|
|
|
#include <stdio.h>
|
1999-11-21 03:04:09 +01:00
|
|
|
|
1999-03-16 11:53:11 +01:00
|
|
|
#include "winbase.h"
|
2000-02-10 20:03:02 +01:00
|
|
|
#include "windef.h"
|
|
|
|
#include "wingdi.h"
|
1999-07-10 14:00:04 +02:00
|
|
|
#include "winuser.h"
|
|
|
|
#include "win.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"
|
1999-06-12 17:45:58 +02:00
|
|
|
#include "debugtools.h"
|
1998-11-08 12:30:27 +01:00
|
|
|
|
2000-02-10 20:03:02 +01:00
|
|
|
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 */
|
|
|
|
#define MC_PREVMONTHTIMER 2
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
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 left_offset;
|
|
|
|
int top_offset;
|
|
|
|
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 */
|
|
|
|
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;
|
|
|
|
|
|
|
|
RECT rcClient; /* rect for whole client area */
|
|
|
|
RECT rcDraw; /* rect for drawable portion of client area */
|
|
|
|
RECT title; /* rect for the header above the calendar */
|
|
|
|
RECT titlebtnnext; /* the `next month' button in the header */
|
|
|
|
RECT titlebtnprev; /* the `prev month' button in the header */
|
|
|
|
RECT titlemonth; /* the `month name' txt in the header */
|
|
|
|
RECT titleyear; /* the `year number' txt in the header */
|
|
|
|
RECT prevmonth; /* day numbers of the previous month */
|
|
|
|
RECT nextmonth; /* day numbers of the next month */
|
|
|
|
RECT days; /* week numbers at left side */
|
|
|
|
RECT weeknums; /* week numbers at left side */
|
|
|
|
RECT today; /* `today: xx/xx/xx' text rect */
|
|
|
|
} MONTHCAL_INFO, *LPMONTHCAL_INFO;
|
|
|
|
|
|
|
|
|
1999-07-10 14:00:04 +02:00
|
|
|
/* take #days/month from ole/parsedt.c;
|
|
|
|
* we want full month-names, and abbreviated weekdays, so these are
|
|
|
|
* defined here */
|
|
|
|
|
2000-02-03 01:48:39 +01:00
|
|
|
const int mdays[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 0};
|
2000-01-04 01:30:21 +01:00
|
|
|
|
2000-01-12 06:01:02 +01:00
|
|
|
const char * const monthtxt[] = {"January", "February", "March", "April", "May",
|
1999-07-10 14:00:04 +02:00
|
|
|
"June", "July", "August", "September", "October",
|
|
|
|
"November", "December"};
|
2000-08-09 02:41:17 +02:00
|
|
|
static const char * const daytxt[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
|
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
|
|
|
|
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
#define MONTHCAL_GetInfoPtr(hwnd) ((MONTHCAL_INFO *)GetWindowLongA(hwnd, 0))
|
1998-11-08 12:30:27 +01:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
/* helper functions */
|
|
|
|
|
|
|
|
/* returns the number of days in any given month */
|
|
|
|
/* january is 1, december is 12 */
|
|
|
|
static int MONTHCAL_MonthLength(int month, int year)
|
|
|
|
{
|
|
|
|
/* 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 */
|
2000-01-04 01:30:21 +01:00
|
|
|
static int MONTHCAL_ValidateTime(SYSTEMTIME time)
|
1999-07-10 14:00:04 +02:00
|
|
|
{
|
2000-01-04 01:30:21 +01:00
|
|
|
if(time.wMonth > 12) return FALSE;
|
|
|
|
if(time.wDayOfWeek > 6) return FALSE;
|
|
|
|
if(time.wDay > MONTHCAL_MonthLength(time.wMonth, time.wYear))
|
|
|
|
return FALSE;
|
|
|
|
if(time.wHour > 23) return FALSE;
|
|
|
|
if(time.wMinute > 59) return FALSE;
|
|
|
|
if(time.wSecond > 59) return FALSE;
|
|
|
|
if(time.wMilliseconds > 999) return FALSE;
|
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
return TRUE;
|
1999-07-10 14:00:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
void MONTHCAL_CopyTime(const SYSTEMTIME *from, SYSTEMTIME *to)
|
1999-07-10 14:00:04 +02:00
|
|
|
{
|
2000-01-04 01:30:21 +01:00
|
|
|
to->wYear = from->wYear;
|
|
|
|
to->wMonth = from->wMonth;
|
|
|
|
to->wDayOfWeek = from->wDayOfWeek;
|
|
|
|
to->wDay = from->wDay;
|
|
|
|
to->wHour = from->wHour;
|
|
|
|
to->wMinute = from->wMinute;
|
|
|
|
to->wSecond = from->wSecond;
|
|
|
|
to->wMilliseconds = from->wMilliseconds;
|
1999-07-10 14:00:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Note:Depending on DST, this may be offset by a day.
|
|
|
|
Need to find out if we're on a DST place & adjust the clock accordingly.
|
|
|
|
Above function assumes we have a valid data.
|
1999-11-21 03:04:09 +01:00
|
|
|
Valid for year>1752; 1 <= d <= 31, 1 <= m <= 12.
|
|
|
|
0 = Monday.
|
1999-07-10 14:00:04 +02:00
|
|
|
*/
|
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
/* returns the day in the week(0 == sunday, 6 == saturday) */
|
|
|
|
/* 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
|
|
|
|
|
|
|
return((year + year/4 - year/100 + year/400 +
|
|
|
|
DayOfWeekTable[month-1] + day - 1 ) % 7);
|
1999-07-10 14:00:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
static int MONTHCAL_CalcDayFromPos(MONTHCAL_INFO *infoPtr, int x, int y)
|
1999-07-10 14:00:04 +02:00
|
|
|
{
|
2000-01-04 01:30:21 +01:00
|
|
|
int daypos, weekpos, retval, firstDay;
|
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
|
|
|
|
it at the boundry */
|
|
|
|
if(x > (infoPtr->width_increment * 7.0)) {
|
|
|
|
x = infoPtr->rcClient.right - infoPtr->rcClient.left - infoPtr->left_offset;
|
|
|
|
}
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
daypos = (x -(infoPtr->prevmonth.left + infoPtr->left_offset)) / infoPtr->width_increment;
|
1999-11-21 03:04:09 +01:00
|
|
|
weekpos = (y - infoPtr->days.bottom - infoPtr->rcClient.top) / infoPtr->height_increment;
|
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
firstDay = MONTHCAL_CalculateDayOfWeek(1, infoPtr->currentMonth, infoPtr->currentYear);
|
1999-11-21 03:04:09 +01:00
|
|
|
retval = daypos + (7 * weekpos) - firstDay;
|
2000-01-04 01:30:21 +01:00
|
|
|
TRACE("%d %d %d\n", daypos, weekpos, retval);
|
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-01-04 01:30:21 +01:00
|
|
|
/* x == day, y == week where(0,0) == sunday, 1st week */
|
|
|
|
static void MONTHCAL_CalcDayXY(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-01-04 01:30:21 +01:00
|
|
|
firstDay = MONTHCAL_CalculateDayOfWeek(1, infoPtr->currentMonth, infoPtr->currentYear);
|
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;
|
|
|
|
|
|
|
|
*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) */
|
2000-01-04 01:30:21 +01:00
|
|
|
static void MONTHCAL_CalcDayRect(MONTHCAL_INFO *infoPtr, RECT *r, int x, int y)
|
1999-07-10 14:00:04 +02:00
|
|
|
{
|
1999-11-21 03:04:09 +01:00
|
|
|
r->left = infoPtr->prevmonth.left + x * infoPtr->width_increment + infoPtr->left_offset;
|
|
|
|
r->right = r->left + infoPtr->width_increment;
|
|
|
|
r->top = infoPtr->height_increment * y + infoPtr->days.bottom + infoPtr->top_offset;
|
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) */
|
2000-01-04 01:30:21 +01:00
|
|
|
static inline void MONTHCAL_CalcPosFromDay(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) */
|
2000-01-04 01:30:21 +01:00
|
|
|
static void MONTHCAL_CircleDay(HDC hdc, MONTHCAL_INFO *infoPtr, int day,
|
1999-11-21 03:04:09 +01:00
|
|
|
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
|
|
|
|
|
|
|
/* use prevmonth to calculate position because it contains the extra width
|
|
|
|
* from MCS_WEEKNUMBERS
|
|
|
|
*/
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
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;
|
|
|
|
points[3].y = y + 0.5 * infoPtr->textHeight;
|
|
|
|
|
|
|
|
points[4].x = x + infoPtr->width_increment;
|
|
|
|
points[4].y = y + 0.9 * infoPtr->textHeight;
|
|
|
|
points[5].x = x + 0.6 * infoPtr->width_increment;
|
|
|
|
points[5].y = y + 0.9 * infoPtr->textHeight;
|
|
|
|
points[6].x = x + 0.5 * infoPtr->width_increment;
|
|
|
|
points[6].y = y + 0.9 * infoPtr->textHeight; /* bring the bottom up just
|
|
|
|
a hair to fit inside the day rectangle */
|
|
|
|
|
|
|
|
points[7].x = x + 0.2 * infoPtr->width_increment;
|
|
|
|
points[7].y = y + 0.8 * infoPtr->textHeight;
|
|
|
|
points[8].x = x + 0.1 * infoPtr->width_increment;
|
|
|
|
points[8].y = y + 0.8 * infoPtr->textHeight;
|
|
|
|
points[9].x = x;
|
|
|
|
points[9].y = y + 0.5 * infoPtr->textHeight;
|
|
|
|
|
|
|
|
points[10].x = x + 0.1 * infoPtr->width_increment;
|
|
|
|
points[10].y = y + 0.2 * infoPtr->textHeight;
|
|
|
|
points[11].x = x + 0.2 * infoPtr->width_increment;
|
|
|
|
points[11].y = y + 0.3 * infoPtr->textHeight;
|
|
|
|
points[12].x = x + 0.5 * infoPtr->width_increment;
|
|
|
|
points[12].y = y + 0.3 * infoPtr->textHeight;
|
|
|
|
|
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
|
|
|
|
|
|
|
|
2000-05-30 22:06:33 +02:00
|
|
|
static void MONTHCAL_DrawDay(HDC hdc, MONTHCAL_INFO *infoPtr, int day, int month,
|
|
|
|
int x, int y, int bold)
|
1999-07-10 14:00:04 +02:00
|
|
|
{
|
|
|
|
char buf[10];
|
|
|
|
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;
|
|
|
|
HPEN hNewPen, hOldPen = 0;
|
|
|
|
COLORREF oldCol = 0;
|
|
|
|
COLORREF oldBk = 0;
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
sprintf(buf, "%d", day);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
|
|
|
/* No need to check styles: when selection is not valid, it is set to zero.
|
|
|
|
* 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);
|
|
|
|
TRACE("%d %d %d %d\n", r.left, r.top, r.right, r.bottom);
|
|
|
|
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-08-14 16:41:19 +02:00
|
|
|
DrawTextA(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 */
|
2000-01-04 01:30:21 +01:00
|
|
|
if((day==infoPtr->curSelDay) && (month==infoPtr->currentMonth)) {
|
1999-11-21 03:04:09 +01:00
|
|
|
hNewPen = CreatePen(PS_DOT, 0, GetSysColor(COLOR_WINDOWTEXT) );
|
2000-01-04 01:30:21 +01:00
|
|
|
hbr = GetSysColorBrush(COLOR_WINDOWTEXT);
|
|
|
|
FrameRect(hdc, &r, hbr);
|
|
|
|
SelectObject(hdc, hOldPen);
|
1999-07-10 14:00:04 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* CHECKME: For `todays date', do we need to check the locale?*/
|
2000-05-30 22:06:33 +02:00
|
|
|
static void MONTHCAL_Refresh(HWND hwnd, HDC hdc, PAINTSTRUCT* ps)
|
1999-07-10 14:00:04 +02:00
|
|
|
{
|
1999-11-21 03:04:09 +01:00
|
|
|
MONTHCAL_INFO *infoPtr=MONTHCAL_GetInfoPtr(hwnd);
|
|
|
|
RECT *rcClient=&infoPtr->rcClient;
|
2000-01-04 01:30:21 +01:00
|
|
|
RECT *rcDraw=&infoPtr->rcDraw;
|
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;
|
|
|
|
RECT *prevmonth=&infoPtr->prevmonth;
|
|
|
|
RECT *nextmonth=&infoPtr->nextmonth;
|
2000-01-04 01:30:21 +01:00
|
|
|
RECT dayrect;
|
|
|
|
RECT *days=&dayrect;
|
1999-11-21 03:04:09 +01:00
|
|
|
RECT *weeknums=&infoPtr->weeknums;
|
|
|
|
RECT *rtoday=&infoPtr->today;
|
|
|
|
int i, j, m, mask, day, firstDay, weeknum, 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;
|
|
|
|
/* LOGFONTA logFont; */
|
2000-01-12 06:01:02 +01:00
|
|
|
char buf[20];
|
|
|
|
const char *thisMonthtxt;
|
2000-01-04 01:30:21 +01:00
|
|
|
COLORREF oldTextColor, oldBkColor;
|
|
|
|
DWORD dwStyle = GetWindowLongA(hwnd, GWL_STYLE);
|
2000-05-30 22:06:33 +02:00
|
|
|
RECT rcTemp;
|
|
|
|
RECT rcDay; /* used in MONTHCAL_CalcDayRect() */
|
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);
|
|
|
|
FillRect(hdc, rcClient, hbr);
|
|
|
|
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
|
|
|
}
|
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))
|
|
|
|
{
|
|
|
|
if((infoPtr->status & MC_PREVPRESSED))
|
|
|
|
DrawFrameControl(hdc, prev, DFC_SCROLL,
|
|
|
|
DFCS_SCROLLLEFT | DFCS_PUSHED |
|
|
|
|
(dwStyle & WS_DISABLED ? DFCS_INACTIVE : 0));
|
|
|
|
else /* if the previous button is pressed draw it depressed */
|
1999-11-21 03:04:09 +01:00
|
|
|
DrawFrameControl(hdc, prev, DFC_SCROLL,
|
2000-01-04 01:30:21 +01:00
|
|
|
DFCS_SCROLLLEFT |(dwStyle & WS_DISABLED ? DFCS_INACTIVE : 0));
|
2000-05-30 22:06:33 +02:00
|
|
|
}
|
1999-11-21 03:04:09 +01:00
|
|
|
|
|
|
|
/* if next button is depressed draw it depressed */
|
2000-05-30 22:06:33 +02:00
|
|
|
if(IntersectRect(&rcTemp, &(ps->rcPaint), next))
|
|
|
|
{
|
|
|
|
if((infoPtr->status & MC_NEXTPRESSED))
|
|
|
|
DrawFrameControl(hdc, next, DFC_SCROLL,
|
1999-11-21 03:04:09 +01:00
|
|
|
DFCS_SCROLLRIGHT | DFCS_PUSHED |
|
2000-05-30 22:06:33 +02:00
|
|
|
(dwStyle & WS_DISABLED ? DFCS_INACTIVE : 0));
|
|
|
|
else /* if the next button is pressed draw it depressed */
|
|
|
|
DrawFrameControl(hdc, next, DFC_SCROLL,
|
|
|
|
DFCS_SCROLLRIGHT |(dwStyle & WS_DISABLED ? DFCS_INACTIVE : 0));
|
|
|
|
}
|
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
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
/* titlemonth->left and right are set in MONTHCAL_UpdateSize */
|
|
|
|
titlemonth->left = title->left;
|
|
|
|
titlemonth->right = title->right;
|
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
thisMonthtxt = monthtxt[infoPtr->currentMonth - 1];
|
2000-01-04 01:30:21 +01:00
|
|
|
sprintf(buf, "%s %ld", thisMonthtxt, infoPtr->currentYear);
|
2000-05-30 22:06:33 +02:00
|
|
|
|
|
|
|
if(IntersectRect(&rcTemp, &(ps->rcPaint), titlemonth))
|
|
|
|
{
|
|
|
|
DrawTextA(hdc, buf, strlen(buf), titlemonth,
|
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
|
|
|
SelectObject(hdc, infoPtr->hFont);
|
1999-07-10 14:00:04 +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.
|
2000-01-04 01:30:21 +01:00
|
|
|
*(no, we can't draw them separately; the whole text is centered)
|
1999-07-10 14:00:04 +02:00
|
|
|
*/
|
2000-08-14 16:41:19 +02:00
|
|
|
GetTextExtentPoint32A(hdc, buf, strlen(buf), &size);
|
2000-01-04 01:30:21 +01:00
|
|
|
titlemonth->left = title->right / 2 - size.cx / 2;
|
|
|
|
titleyear->right = title->right / 2 + size.cx / 2;
|
2000-08-14 16:41:19 +02:00
|
|
|
GetTextExtentPoint32A(hdc, thisMonthtxt, strlen(thisMonthtxt), &size);
|
2000-01-04 01:30:21 +01:00
|
|
|
titlemonth->right = titlemonth->left + size.cx;
|
1999-11-21 03:04:09 +01:00
|
|
|
titleyear->right = titlemonth->right;
|
2000-01-04 01:30:21 +01:00
|
|
|
|
1999-07-10 14:00:04 +02:00
|
|
|
/* draw line under day abbreviatons */
|
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
if(dwStyle & MCS_WEEKNUMBERS)
|
|
|
|
MoveToEx(hdc, rcDraw->left + textWidth + 3, title->bottom + textHeight + 2, NULL);
|
1999-11-21 03:04:09 +01:00
|
|
|
else
|
2000-01-04 01:30:21 +01:00
|
|
|
MoveToEx(hdc, rcDraw->left + 3, title->bottom + textHeight + 2, NULL);
|
1999-11-21 03:04:09 +01:00
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
LineTo(hdc, rcDraw->right - 3, title->bottom + textHeight + 2);
|
2000-07-08 13:43:57 +02:00
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
/* draw day abbreviations */
|
1999-07-10 14:00:04 +02:00
|
|
|
|
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 */
|
|
|
|
days->left = infoPtr->days.left;
|
|
|
|
days->right = infoPtr->days.right;
|
|
|
|
days->top = infoPtr->days.top;
|
|
|
|
days->bottom = infoPtr->days.bottom;
|
|
|
|
|
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++) {
|
|
|
|
DrawTextA(hdc, daytxt[i], strlen(daytxt[i]), days,
|
1999-07-10 14:00:04 +02:00
|
|
|
DT_CENTER | DT_VCENTER | DT_SINGLELINE );
|
1999-11-21 03:04:09 +01:00
|
|
|
i = (i + 1) % 7;
|
|
|
|
days->left+=infoPtr->width_increment;
|
|
|
|
days->right+=infoPtr->width_increment;
|
|
|
|
}
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
days->left = rcDraw->left + j;
|
|
|
|
if(dwStyle & MCS_WEEKNUMBERS) days->left+=textWidth;
|
1999-11-21 03:04:09 +01:00
|
|
|
/* FIXME: this may need to be changed now 11/10/99 CMM */
|
2000-01-04 01:30:21 +01:00
|
|
|
days->right = rcDraw->left + (j+1) * textWidth - 2;
|
1999-07-10 14:00:04 +02:00
|
|
|
|
|
|
|
/* draw day numbers; first, the previous month */
|
1999-11-21 03:04:09 +01:00
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
firstDay = MONTHCAL_CalculateDayOfWeek(1, infoPtr->currentMonth, infoPtr->currentYear);
|
|
|
|
|
|
|
|
prevMonth = infoPtr->currentMonth - 1;
|
|
|
|
if(prevMonth == 0) /* if currentMonth is january(1) prevMonth is */
|
1999-11-21 03:04:09 +01:00
|
|
|
prevMonth = 12; /* december(12) of the previous year */
|
|
|
|
|
|
|
|
day = MONTHCAL_MonthLength(prevMonth, infoPtr->currentYear) - firstDay;
|
|
|
|
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))
|
|
|
|
{
|
|
|
|
MONTHCAL_DrawDay(hdc, infoPtr, 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++;
|
|
|
|
}
|
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
prevmonth->left = 0;
|
|
|
|
if(dwStyle & MCS_WEEKNUMBERS) prevmonth->left = textWidth;
|
2000-05-30 22:06:33 +02:00
|
|
|
prevmonth->right = prevmonth->left + (i * infoPtr->width_increment) +
|
|
|
|
infoPtr->left_offset;
|
2000-01-04 01:30:21 +01:00
|
|
|
prevmonth->top = days->bottom;
|
|
|
|
prevmonth->bottom = prevmonth->top + textHeight;
|
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))
|
|
|
|
{
|
|
|
|
|
|
|
|
MONTHCAL_DrawDay(hdc, infoPtr, 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)) {
|
|
|
|
MONTHCAL_CircleDay(hdc, infoPtr, day, infoPtr->currentMonth);
|
|
|
|
}
|
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 */
|
2000-01-04 01:30:21 +01: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))
|
|
|
|
{
|
|
|
|
MONTHCAL_DrawDay(hdc, infoPtr, 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) &&
|
|
|
|
(infoPtr->currentYear == infoPtr->todaysDate.wYear))
|
|
|
|
MONTHCAL_CircleDay(hdc, infoPtr, day, infoPtr->currentMonth);
|
|
|
|
}
|
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 */
|
|
|
|
|
|
|
|
/* note: the nextmonth rect only hints for the `half-week' that needs to be
|
|
|
|
* drawn to complete the current week. An eventual next week that needs to
|
|
|
|
* be drawn to complete the month calendar is not taken into account in
|
|
|
|
* this rect -- HitTest knows about this.*/
|
2000-05-30 22:06:33 +02:00
|
|
|
nextmonth->left = rcDraw->left + (i * infoPtr->width_increment) +
|
|
|
|
infoPtr->left_offset;
|
2000-01-04 01:30:21 +01:00
|
|
|
nextmonth->right = rcDraw->right;
|
|
|
|
nextmonth->top = days->bottom + (j+1) * textHeight;
|
1999-11-21 03:04:09 +01:00
|
|
|
nextmonth->bottom = nextmonth->top + textHeight;
|
|
|
|
|
|
|
|
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))
|
|
|
|
{
|
|
|
|
MONTHCAL_DrawDay(hdc, infoPtr, 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++;
|
|
|
|
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)) {
|
|
|
|
day = MONTHCAL_CalcDayFromPos(infoPtr, 0, nextmonth->bottom + textHeight);
|
|
|
|
MONTHCAL_CircleDay(hdc, infoPtr, day, infoPtr->currentMonth);
|
1999-11-21 03:04:09 +01:00
|
|
|
offset+=textWidth;
|
|
|
|
}
|
2000-05-30 22:06:33 +02:00
|
|
|
MONTHCAL_CalcDayRect(infoPtr, rtoday, 1, 6);
|
2000-01-04 01:30:21 +01:00
|
|
|
sprintf(buf, "Today: %d/%d/%d", infoPtr->todaysDate.wMonth,
|
2000-05-30 22:06:33 +02:00
|
|
|
infoPtr->todaysDate.wDay, infoPtr->todaysDate.wYear);
|
|
|
|
rtoday->left = rtoday->left + 3; /* move text slightly away from circle */
|
2000-01-04 01:30:21 +01:00
|
|
|
rtoday->right = rcDraw->right;
|
|
|
|
SelectObject(hdc, infoPtr->hBoldFont);
|
2000-05-30 22:06:33 +02:00
|
|
|
|
|
|
|
if(IntersectRect(&rcTemp, &(ps->rcPaint), rtoday))
|
|
|
|
{
|
2000-08-14 16:41:19 +02:00
|
|
|
DrawTextA(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
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
if(dwStyle & MCS_WEEKNUMBERS) {
|
1999-11-21 03:04:09 +01:00
|
|
|
/* display weeknumbers*/
|
|
|
|
weeknums->left = 0;
|
|
|
|
weeknums->right = textWidth;
|
|
|
|
weeknums->top = days->bottom + 2;
|
|
|
|
weeknums->bottom = days->bottom + 2 + textHeight;
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
weeknum = 0;
|
|
|
|
for(i=0; i<infoPtr->currentMonth-1; i++)
|
1999-11-21 03:04:09 +01:00
|
|
|
weeknum+=MONTHCAL_MonthLength(i, infoPtr->currentYear);
|
|
|
|
|
|
|
|
weeknum/=7;
|
2000-01-04 01:30:21 +01:00
|
|
|
for(i=0; i<6; i++) {
|
|
|
|
sprintf(buf, "%d", weeknum + i);
|
2000-08-14 16:41:19 +02:00
|
|
|
DrawTextA(hdc, buf, -1, weeknums, DT_CENTER | DT_BOTTOM | DT_SINGLELINE );
|
2000-01-04 01:30:21 +01:00
|
|
|
weeknums->top+=textHeight * 1.25;
|
|
|
|
weeknums->bottom+=textHeight * 1.25;
|
1999-11-21 03:04:09 +01:00
|
|
|
}
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
MoveToEx(hdc, weeknums->right, days->bottom + 5 , NULL);
|
|
|
|
LineTo(hdc, weeknums->right, weeknums->bottom - 1.25 * textHeight - 5);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
}
|
1999-07-10 14:00:04 +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);
|
|
|
|
SelectObject(hdc, currentFont);
|
|
|
|
SetTextColor(hdc, oldTextColor);
|
1999-07-10 14:00:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static LRESULT
|
2000-01-04 01:30:21 +01:00
|
|
|
MONTHCAL_GetMinReqRect(HWND hwnd, WPARAM wParam, LPARAM lParam)
|
1999-07-10 14:00:04 +02:00
|
|
|
{
|
2000-01-04 01:30:21 +01:00
|
|
|
MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd);
|
|
|
|
LPRECT lpRect = (LPRECT) lParam;
|
|
|
|
TRACE("%x %lx\n", wParam, lParam);
|
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
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
lpRect->left = infoPtr->rcClient.left;
|
|
|
|
lpRect->right = infoPtr->rcClient.right;
|
|
|
|
lpRect->top = infoPtr->rcClient.top;
|
|
|
|
lpRect->bottom = infoPtr->rcClient.bottom;
|
|
|
|
return TRUE;
|
1999-07-10 14:00:04 +02:00
|
|
|
}
|
|
|
|
|
2000-05-30 22:06:33 +02:00
|
|
|
|
1999-07-10 14:00:04 +02:00
|
|
|
static LRESULT
|
2000-01-04 01:30:21 +01:00
|
|
|
MONTHCAL_GetColor(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);
|
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
TRACE("%x %lx\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:
|
|
|
|
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
|
|
|
|
1999-07-10 14:00:04 +02:00
|
|
|
static LRESULT
|
2000-01-04 01:30:21 +01:00
|
|
|
MONTHCAL_SetColor(HWND hwnd, WPARAM wParam, LPARAM lParam)
|
1999-07-10 14:00:04 +02:00
|
|
|
{
|
2000-01-04 01:30:21 +01:00
|
|
|
MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd);
|
|
|
|
int prev = -1;
|
1999-11-21 03:04:09 +01:00
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
TRACE("%x %lx\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;
|
|
|
|
}
|
|
|
|
|
|
|
|
return prev;
|
1999-07-10 14:00:04 +02:00
|
|
|
}
|
|
|
|
|
2000-05-30 22:06:33 +02:00
|
|
|
|
1999-07-10 14:00:04 +02:00
|
|
|
static LRESULT
|
2000-01-04 01:30:21 +01:00
|
|
|
MONTHCAL_GetMonthDelta(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);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
TRACE("%x %lx\n", wParam, lParam);
|
1999-11-21 03:04:09 +01: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
|
|
|
|
1999-07-10 14:00:04 +02:00
|
|
|
static LRESULT
|
2000-01-04 01:30:21 +01:00
|
|
|
MONTHCAL_SetMonthDelta(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);
|
|
|
|
int prev = infoPtr->delta;
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
TRACE("%x %lx\n", wParam, lParam);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
infoPtr->delta = (int)wParam;
|
|
|
|
return prev;
|
1999-07-10 14:00:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static LRESULT
|
2000-01-04 01:30:21 +01:00
|
|
|
MONTHCAL_GetFirstDayOfWeek(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);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
return infoPtr->firstDay;
|
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 */
|
|
|
|
/* 0 == Monday, 6 == Sunday */
|
|
|
|
/* FIXME: this needs to be implemented properly in MONTHCAL_Refresh() */
|
|
|
|
/* FIXME: we need more error checking here */
|
1999-07-10 14:00:04 +02:00
|
|
|
static LRESULT
|
2000-01-04 01:30:21 +01:00
|
|
|
MONTHCAL_SetFirstDayOfWeek(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);
|
|
|
|
int prev = infoPtr->firstDay;
|
|
|
|
char buf[40];
|
|
|
|
int day;
|
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
TRACE("%x %lx\n", wParam, lParam);
|
1999-11-21 03:04:09 +01:00
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
if((lParam >= 0) && (lParam < 7)) {
|
1999-11-21 03:04:09 +01:00
|
|
|
infoPtr->firstDay = (int)lParam;
|
|
|
|
GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_IFIRSTDAYOFWEEK,
|
|
|
|
buf, sizeof(buf));
|
2000-01-04 01:30:21 +01:00
|
|
|
TRACE("%s %d\n", buf, strlen(buf));
|
|
|
|
if((sscanf(buf, "%d", &day) == 1) &&(infoPtr->firstDay != day))
|
1999-11-21 03:04:09 +01:00
|
|
|
infoPtr->firstDay = day;
|
|
|
|
}
|
|
|
|
return prev;
|
1999-07-10 14:00:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* FIXME: fill this in */
|
|
|
|
static LRESULT
|
2000-01-04 01:30:21 +01:00
|
|
|
MONTHCAL_GetMonthRange(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);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
TRACE("%x %lx\n", wParam, lParam);
|
1999-11-21 03:04:09 +01:00
|
|
|
FIXME("stub\n");
|
|
|
|
|
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
|
2000-01-04 01:30:21 +01:00
|
|
|
MONTHCAL_GetMaxTodayWidth(HWND hwnd)
|
1999-07-10 14:00:04 +02:00
|
|
|
{
|
1999-11-21 03:04:09 +01:00
|
|
|
MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
return(infoPtr->today.right - infoPtr->today.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
|
|
|
/* FIXME: are validated times taken from current date/time or simply
|
|
|
|
* copied?
|
|
|
|
* FIXME: check whether MCM_GETMONTHRANGE shows correct result after
|
|
|
|
* adjusting range with MCM_SETRANGE
|
|
|
|
*/
|
|
|
|
|
|
|
|
static LRESULT
|
2000-01-04 01:30:21 +01:00
|
|
|
MONTHCAL_SetRange(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);
|
1999-07-10 14:00:04 +02:00
|
|
|
SYSTEMTIME lprgSysTimeArray[1];
|
|
|
|
int prev;
|
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
TRACE("%x %lx\n", wParam, lParam);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
if(wParam & GDTR_MAX) {
|
|
|
|
if(MONTHCAL_ValidateTime(lprgSysTimeArray[1])){
|
|
|
|
MONTHCAL_CopyTime(&lprgSysTimeArray[1], &infoPtr->maxDate);
|
1999-11-21 03:04:09 +01:00
|
|
|
infoPtr->rangeValid|=GDTR_MAX;
|
|
|
|
} else {
|
2000-01-04 01:30:21 +01:00
|
|
|
GetSystemTime(&infoPtr->todaysDate);
|
|
|
|
MONTHCAL_CopyTime(&infoPtr->todaysDate, &infoPtr->maxDate);
|
1999-11-21 03:04:09 +01:00
|
|
|
}
|
|
|
|
}
|
2000-01-04 01:30:21 +01:00
|
|
|
if(wParam & GDTR_MIN) {
|
|
|
|
if(MONTHCAL_ValidateTime(lprgSysTimeArray[0])) {
|
|
|
|
MONTHCAL_CopyTime(&lprgSysTimeArray[0], &infoPtr->maxDate);
|
1999-11-21 03:04:09 +01:00
|
|
|
infoPtr->rangeValid|=GDTR_MIN;
|
|
|
|
} else {
|
2000-01-04 01:30:21 +01:00
|
|
|
GetSystemTime(&infoPtr->todaysDate);
|
|
|
|
MONTHCAL_CopyTime(&infoPtr->todaysDate, &infoPtr->maxDate);
|
1999-11-21 03:04:09 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
prev = infoPtr->monthRange;
|
2000-01-04 01:30:21 +01:00
|
|
|
infoPtr->monthRange = infoPtr->maxDate.wMonth - infoPtr->minDate.wMonth;
|
1999-11-21 03:04:09 +01:00
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
if(infoPtr->monthRange!=prev) {
|
|
|
|
COMCTL32_ReAlloc(infoPtr->monthdayState,
|
|
|
|
infoPtr->monthRange * sizeof(MONTHDAYSTATE));
|
1999-11-21 03:04:09 +01:00
|
|
|
}
|
1999-07-10 14:00:04 +02:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
1998-11-08 12:30:27 +01:00
|
|
|
|
1999-07-10 14:00:04 +02:00
|
|
|
/* CHECKME: At the moment, we copy ranges anyway,regardless of
|
|
|
|
* infoPtr->rangeValid; a invalid range is simply filled with zeros in
|
|
|
|
* SetRange. Is this the right behavior?
|
|
|
|
*/
|
|
|
|
|
|
|
|
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
|
2000-01-04 01:30:21 +01:00
|
|
|
MONTHCAL_SetDayState(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);
|
|
|
|
int i, iMonths = (int)wParam;
|
|
|
|
MONTHDAYSTATE *dayStates = (LPMONTHDAYSTATE)lParam;
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
TRACE("%x %lx\n", wParam, lParam);
|
|
|
|
if(iMonths!=infoPtr->monthRange) return 0;
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
for(i=0; i<iMonths; i++)
|
|
|
|
infoPtr->monthdayState[i] = dayStates[i];
|
1999-07-10 14:00:04 +02:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
|
1999-07-10 14:00:04 +02:00
|
|
|
static LRESULT
|
2000-01-04 01:30:21 +01:00
|
|
|
MONTHCAL_GetCurSel(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 *lpSel = (SYSTEMTIME *) lParam;
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
TRACE("%x %lx\n", wParam, lParam);
|
|
|
|
if((infoPtr==NULL) ||(lpSel==NULL)) return FALSE;
|
|
|
|
if(GetWindowLongA(hwnd, 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);
|
1999-07-10 14:00:04 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* FIXME: if the specified date is not visible, make it visible */
|
|
|
|
/* FIXME: redraw? */
|
|
|
|
static LRESULT
|
2000-01-04 01:30:21 +01:00
|
|
|
MONTHCAL_SetCurSel(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);
|
2000-01-04 01:30:21 +01:00
|
|
|
SYSTEMTIME *lpSel = (SYSTEMTIME *)lParam;
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
TRACE("%x %lx\n", wParam, lParam);
|
|
|
|
if((infoPtr==NULL) ||(lpSel==NULL)) return FALSE;
|
|
|
|
if(GetWindowLongA(hwnd, GWL_STYLE) & MCS_MULTISELECT) return FALSE;
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
TRACE("%d %d\n", lpSel->wMonth, lpSel->wDay);
|
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
|
|
|
|
2000-05-30 22:06:33 +02:00
|
|
|
InvalidateRect(hwnd, NULL, FALSE);
|
|
|
|
|
1999-07-10 14:00:04 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
|
1999-07-10 14:00:04 +02:00
|
|
|
static LRESULT
|
2000-01-04 01:30:21 +01:00
|
|
|
MONTHCAL_GetMaxSelCount(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);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
TRACE("%x %lx\n", wParam, lParam);
|
1999-07-10 14:00:04 +02:00
|
|
|
return infoPtr->maxSelCount;
|
|
|
|
}
|
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
|
1999-07-10 14:00:04 +02:00
|
|
|
static LRESULT
|
2000-01-04 01:30:21 +01:00
|
|
|
MONTHCAL_SetMaxSelCount(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);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
TRACE("%x %lx\n", wParam, lParam);
|
|
|
|
if(GetWindowLongA(hwnd, 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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static LRESULT
|
2000-01-04 01:30:21 +01:00
|
|
|
MONTHCAL_GetSelRange(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
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
TRACE("%x %lx\n", wParam, 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
|
|
|
if(GetWindowLongA(hwnd, GWL_STYLE) & MCS_MULTISELECT)
|
|
|
|
{
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
|
1999-07-10 14:00:04 +02:00
|
|
|
static LRESULT
|
2000-01-04 01:30:21 +01:00
|
|
|
MONTHCAL_SetSelRange(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
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
TRACE("%x %lx\n", wParam, 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
|
|
|
if(GetWindowLongA( hwnd, GWL_STYLE) & MCS_MULTISELECT)
|
|
|
|
{
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static LRESULT
|
2000-01-04 01:30:21 +01:00
|
|
|
MONTHCAL_GetToday(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 *lpToday = (SYSTEMTIME *) lParam;
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
TRACE("%x %lx\n", wParam, 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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-07-31 13:13:25 +02:00
|
|
|
static LRESULT
|
2000-01-04 01:30:21 +01:00
|
|
|
MONTHCAL_SetToday(HWND hwnd, WPARAM wParam, LPARAM lParam)
|
1999-07-31 13:13:25 +02:00
|
|
|
{
|
1999-11-21 03:04:09 +01:00
|
|
|
MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd);
|
|
|
|
SYSTEMTIME *lpToday = (SYSTEMTIME *) lParam;
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
TRACE("%x %lx\n", wParam, 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);
|
1999-07-31 13:13:25 +02:00
|
|
|
return TRUE;
|
1999-07-10 14:00:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static LRESULT
|
2000-01-04 01:30:21 +01:00
|
|
|
MONTHCAL_HitTest(HWND hwnd, LPARAM lParam)
|
1999-07-10 14:00:04 +02:00
|
|
|
{
|
1999-11-21 03:04:09 +01:00
|
|
|
MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd);
|
2000-01-04 01:30:21 +01:00
|
|
|
PMCHITTESTINFO lpht = (PMCHITTESTINFO)lParam;
|
1999-07-10 14:00:04 +02:00
|
|
|
UINT x,y;
|
|
|
|
DWORD retval;
|
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
x = lpht->pt.x;
|
|
|
|
y = lpht->pt.y;
|
|
|
|
retval = MCHT_NOWHERE;
|
1999-07-10 14:00:04 +02:00
|
|
|
|
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
/* are we in the header? */
|
1999-07-10 14:00:04 +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;
|
|
|
|
}
|
|
|
|
|
|
|
|
retval = MCHT_TITLE;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
if(PtInRect(&infoPtr->days, lpht->pt)) {
|
1999-11-21 03:04:09 +01:00
|
|
|
retval = MCHT_CALENDARDAY; /* FIXME: find out which day we're on */
|
|
|
|
goto done;
|
|
|
|
}
|
2000-01-04 01:30:21 +01:00
|
|
|
if(PtInRect(&infoPtr->weeknums, lpht->pt)) {
|
1999-11-21 03:04:09 +01:00
|
|
|
retval = MCHT_CALENDARWEEKNUM; /* FIXME: find out which day we're on */
|
|
|
|
goto done;
|
|
|
|
}
|
2000-01-04 01:30:21 +01:00
|
|
|
if(PtInRect(&infoPtr->prevmonth, lpht->pt)) {
|
1999-11-21 03:04:09 +01:00
|
|
|
retval = MCHT_CALENDARDATEPREV;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
if(PtInRect(&infoPtr->nextmonth, lpht->pt) ||
|
2000-05-30 22:06:33 +02:00
|
|
|
((y > infoPtr->nextmonth.bottom) && (y < infoPtr->nextmonth.bottom +
|
|
|
|
infoPtr->height_increment) && (x < infoPtr->rcClient.right) &&
|
|
|
|
(x > infoPtr->rcDraw.left))) {
|
1999-11-21 03:04:09 +01:00
|
|
|
retval = MCHT_CALENDARDATENEXT;
|
|
|
|
goto done;
|
|
|
|
}
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
if(PtInRect(&infoPtr->today, lpht->pt)) {
|
1999-11-21 03:04:09 +01:00
|
|
|
retval = MCHT_TODAYLINK;
|
|
|
|
goto done;
|
|
|
|
}
|
1999-07-10 14:00:04 +02:00
|
|
|
|
|
|
|
/* MCHT_CALENDARDATE determination: since the next & previous month have
|
2000-01-04 01:30:21 +01:00
|
|
|
* been handled already(MCHT_CALENDARDATEPREV/NEXT), we only have to check
|
1999-07-10 14:00:04 +02:00
|
|
|
* whether we're in the calendar area. infoPtr->prevMonth.left handles the
|
|
|
|
* MCS_WEEKNUMBERS style nicely.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
TRACE("%d %d [%d %d %d %d] [%d %d %d %d]\n", x, y,
|
1999-07-10 14:00:04 +02:00
|
|
|
infoPtr->prevmonth.left, infoPtr->prevmonth.right,
|
|
|
|
infoPtr->prevmonth.top, infoPtr->prevmonth.bottom,
|
|
|
|
infoPtr->nextmonth.left, infoPtr->nextmonth.right,
|
|
|
|
infoPtr->nextmonth.top, infoPtr->nextmonth.bottom);
|
2000-05-30 22:06:33 +02:00
|
|
|
if((x > infoPtr->rcClient.left) && (x < infoPtr->rcClient.right) &&
|
|
|
|
(y > infoPtr->rcClient.top) && (y < infoPtr->nextmonth.bottom)) {
|
1999-11-21 03:04:09 +01:00
|
|
|
lpht->st.wYear = infoPtr->currentYear;
|
|
|
|
lpht->st.wMonth = infoPtr->currentMonth;
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
lpht->st.wDay = MONTHCAL_CalcDayFromPos(infoPtr, x, y);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
TRACE("day hit: %d\n", lpht->st.wDay);
|
1999-11-21 03:04:09 +01:00
|
|
|
retval = MCHT_CALENDARDATE;
|
|
|
|
goto done;
|
1999-07-10 14:00:04 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
}
|
1999-07-10 14:00:04 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
/* Hit nothing special? What's left must be background :-) */
|
1999-07-10 14:00:04 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
retval = MCHT_CALENDARBK;
|
1999-07-10 14:00:04 +02:00
|
|
|
done:
|
1999-11-21 03:04:09 +01:00
|
|
|
lpht->uHit = retval;
|
1999-07-10 14:00:04 +02:00
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
static void MONTHCAL_GoToNextMonth(HWND hwnd, MONTHCAL_INFO *infoPtr)
|
1999-07-31 13:13:25 +02:00
|
|
|
{
|
2000-01-04 01:30:21 +01:00
|
|
|
DWORD dwStyle = GetWindowLongA(hwnd, 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
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
nmds.nmhdr.hwndFrom = hwnd;
|
2000-01-04 01:30:21 +01:00
|
|
|
nmds.nmhdr.idFrom = GetWindowLongA(hwnd, GWL_ID);
|
1999-11-21 03:04:09 +01:00
|
|
|
nmds.nmhdr.code = MCN_GETDAYSTATE;
|
|
|
|
nmds.cDayState = infoPtr->monthRange;
|
2000-01-04 01:30:21 +01:00
|
|
|
nmds.prgDayState = COMCTL32_Alloc(infoPtr->monthRange * sizeof(MONTHDAYSTATE));
|
1999-07-31 13:13:25 +02:00
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
SendMessageA(GetParent(hwnd), WM_NOTIFY,
|
|
|
|
(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
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
static void MONTHCAL_GoToPrevMonth(HWND hwnd, MONTHCAL_INFO *infoPtr)
|
1999-07-31 13:13:25 +02:00
|
|
|
{
|
2000-01-04 01:30:21 +01:00
|
|
|
DWORD dwStyle = GetWindowLongA(hwnd, GWL_STYLE);
|
1999-11-21 03:04:09 +01:00
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
TRACE("MONTHCAL_GoToPrevMonth\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;
|
|
|
|
|
|
|
|
nmds.nmhdr.hwndFrom = hwnd;
|
2000-01-04 01:30:21 +01:00
|
|
|
nmds.nmhdr.idFrom = GetWindowLongA(hwnd, GWL_ID);
|
1999-11-21 03:04:09 +01:00
|
|
|
nmds.nmhdr.code = MCN_GETDAYSTATE;
|
|
|
|
nmds.cDayState = infoPtr->monthRange;
|
|
|
|
nmds.prgDayState = COMCTL32_Alloc
|
2000-01-04 01:30:21 +01:00
|
|
|
(infoPtr->monthRange * sizeof(MONTHDAYSTATE));
|
1999-11-21 03:04:09 +01:00
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
SendMessageA(GetParent(hwnd), WM_NOTIFY,
|
|
|
|
(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
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-07-10 14:00:04 +02:00
|
|
|
static LRESULT
|
2000-01-04 01:30:21 +01:00
|
|
|
MONTHCAL_LButtonDown(HWND hwnd, WPARAM wParam, LPARAM lParam)
|
1999-07-10 14:00:04 +02:00
|
|
|
{
|
2000-01-04 01:30:21 +01:00
|
|
|
MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd);
|
1999-11-21 03:04:09 +01:00
|
|
|
MCHITTESTINFO ht;
|
|
|
|
DWORD hit;
|
|
|
|
HMENU hMenu;
|
|
|
|
HWND retval;
|
2000-01-04 01:30:21 +01:00
|
|
|
BOOL redraw = FALSE;
|
2000-05-30 22:06:33 +02:00
|
|
|
RECT rcDay; /* used in determining area to invalidate */
|
1998-11-08 12:30:27 +01:00
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
TRACE("%x %lx\n", wParam, lParam);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
ht.pt.x = (INT)LOWORD(lParam);
|
|
|
|
ht.pt.y = (INT)HIWORD(lParam);
|
2000-01-04 01:30:21 +01:00
|
|
|
hit = MONTHCAL_HitTest(hwnd, (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-01-04 01:30:21 +01:00
|
|
|
if(hit & MCHT_NEXT) {
|
|
|
|
redraw = TRUE;
|
|
|
|
MONTHCAL_GoToNextMonth(hwnd, infoPtr);
|
1999-11-21 03:04:09 +01:00
|
|
|
infoPtr->status = MC_NEXTPRESSED;
|
2000-01-04 01:30:21 +01:00
|
|
|
SetTimer(hwnd, MC_NEXTMONTHTIMER, MC_NEXTMONTHDELAY, 0);
|
2000-05-30 22:06:33 +02:00
|
|
|
InvalidateRect(hwnd, NULL, FALSE);
|
1999-11-21 03:04:09 +01:00
|
|
|
}
|
2000-01-04 01:30:21 +01:00
|
|
|
if(hit & MCHT_PREV) {
|
|
|
|
redraw = TRUE;
|
|
|
|
MONTHCAL_GoToPrevMonth(hwnd, infoPtr);
|
|
|
|
infoPtr->status = MC_PREVPRESSED;
|
|
|
|
SetTimer(hwnd, MC_PREVMONTHTIMER, MC_NEXTMONTHDELAY, 0);
|
2000-05-30 22:06:33 +02:00
|
|
|
InvalidateRect(hwnd, NULL, FALSE);
|
1999-11-21 03:04:09 +01:00
|
|
|
}
|
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
if(hit == MCHT_TITLEMONTH) {
|
1999-07-10 14:00:04 +02:00
|
|
|
/*
|
1999-11-21 03:04:09 +01:00
|
|
|
HRSRC hrsrc = FindResourceA( COMCTL32_hModule, MAKEINTRESOURCEA(IDD_MCMONTHMENU), RT_MENUA );
|
2000-01-04 01:30:21 +01:00
|
|
|
if(!hrsrc) {
|
|
|
|
TRACE("returning zero\n");
|
1999-11-21 03:04:09 +01:00
|
|
|
return 0;
|
|
|
|
}
|
2000-01-04 01:30:21 +01:00
|
|
|
TRACE("resource is:%x\n",hrsrc);
|
|
|
|
hMenu = LoadMenuIndirectA((LPCVOID)LoadResource( COMCTL32_hModule, hrsrc ));
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
TRACE("menu is:%x\n",hMenu);
|
1999-07-10 14:00:04 +02:00
|
|
|
*/
|
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
hMenu = CreateMenu();
|
|
|
|
AppendMenuA(hMenu, MF_STRING,IDM_JAN, "January");
|
|
|
|
AppendMenuA(hMenu, MF_STRING,IDM_FEB, "February");
|
|
|
|
AppendMenuA(hMenu, MF_STRING,IDM_MAR, "March");
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
retval = CreateWindowA(POPUPMENU_CLASS_ATOM, NULL,
|
|
|
|
WS_CHILD | WS_VISIBLE, 0, 0 ,100 , 220,
|
|
|
|
hwnd, hMenu, GetWindowLongA(hwnd, GWL_HINSTANCE), NULL);
|
|
|
|
TRACE("hwnd returned:%x\n", retval);
|
1999-11-21 03:04:09 +01:00
|
|
|
|
|
|
|
}
|
2000-01-04 01:30:21 +01:00
|
|
|
if(hit == MCHT_TITLEYEAR) {
|
|
|
|
FIXME("create updown for yearselection\n");
|
1999-11-21 03:04:09 +01:00
|
|
|
}
|
2000-01-04 01:30:21 +01:00
|
|
|
if(hit == MCHT_TODAYLINK) {
|
|
|
|
FIXME("set currentday\n");
|
1999-11-21 03:04:09 +01:00
|
|
|
}
|
2000-01-04 01:30:21 +01:00
|
|
|
if(hit == MCHT_CALENDARDATE) {
|
1999-11-21 03:04:09 +01:00
|
|
|
SYSTEMTIME selArray[2];
|
|
|
|
NMSELCHANGE nmsc;
|
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
TRACE("\n");
|
1999-11-21 03:04:09 +01:00
|
|
|
nmsc.nmhdr.hwndFrom = hwnd;
|
2000-01-04 01:30:21 +01:00
|
|
|
nmsc.nmhdr.idFrom = GetWindowLongA(hwnd, GWL_ID);
|
1999-11-21 03:04:09 +01:00
|
|
|
nmsc.nmhdr.code = MCN_SELCHANGE;
|
2000-01-04 01:30:21 +01:00
|
|
|
MONTHCAL_CopyTime(&nmsc.stSelStart, &infoPtr->minSel);
|
|
|
|
MONTHCAL_CopyTime(&nmsc.stSelEnd, &infoPtr->maxSel);
|
1999-07-31 13:13:25 +02:00
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
SendMessageA(GetParent(hwnd), WM_NOTIFY,
|
|
|
|
(WPARAM)nmsc.nmhdr.idFrom,(LPARAM)&nmsc);
|
1999-07-31 13:13:25 +02:00
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
MONTHCAL_CopyTime(&ht.st, &selArray[0]);
|
|
|
|
MONTHCAL_CopyTime(&ht.st, &selArray[1]);
|
|
|
|
MONTHCAL_SetSelRange(hwnd,0,(LPARAM) &selArray);
|
|
|
|
|
2000-05-30 22:06:33 +02:00
|
|
|
/* FIXME: for some reason if RedrawWindow has a NULL instead of zero it gives */
|
|
|
|
/* a compiler warning */
|
|
|
|
/* 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);
|
|
|
|
RedrawWindow(hwnd, &rcDay, 0, RDW_ERASE|RDW_INVALIDATE);
|
|
|
|
|
|
|
|
MONTHCAL_CalcPosFromDay(infoPtr, infoPtr->curSelDay, infoPtr->currentMonth, &rcDay);
|
|
|
|
RedrawWindow(hwnd, &rcDay, 0, RDW_ERASE|RDW_INVALIDATE);
|
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-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
|
2000-01-04 01:30:21 +01:00
|
|
|
MONTHCAL_LButtonUp(HWND hwnd, WPARAM wParam, LPARAM lParam)
|
1999-07-10 14:00:04 +02:00
|
|
|
{
|
2000-01-04 01:30:21 +01:00
|
|
|
MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd);
|
1999-11-21 03:04:09 +01:00
|
|
|
NMSELCHANGE nmsc;
|
|
|
|
NMHDR nmhdr;
|
2000-01-04 01:30:21 +01:00
|
|
|
BOOL redraw = FALSE;
|
|
|
|
|
|
|
|
TRACE("\n");
|
1999-07-31 13:13:25 +02:00
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
if(infoPtr->status & MC_NEXTPRESSED) {
|
|
|
|
KillTimer(hwnd, MC_NEXTMONTHTIMER);
|
|
|
|
redraw = TRUE;
|
|
|
|
}
|
|
|
|
if(infoPtr->status & MC_PREVPRESSED) {
|
|
|
|
KillTimer(hwnd, MC_PREVMONTHTIMER);
|
|
|
|
redraw = TRUE;
|
|
|
|
}
|
1999-07-10 14:00:04 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
infoPtr->status = MC_SEL_LBUTUP;
|
1999-07-31 13:13:25 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
nmhdr.hwndFrom = hwnd;
|
|
|
|
nmhdr.idFrom = GetWindowLongA( hwnd, GWL_ID);
|
|
|
|
nmhdr.code = NM_RELEASEDCAPTURE;
|
2000-01-04 01:30:21 +01:00
|
|
|
TRACE("Sent notification from %x to %x\n", hwnd, GetParent(hwnd));
|
1999-07-31 13:13:25 +02:00
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
SendMessageA(GetParent(hwnd), WM_NOTIFY,
|
|
|
|
(WPARAM)nmhdr.idFrom, (LPARAM)&nmhdr);
|
1999-07-31 13:13:25 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
nmsc.nmhdr.hwndFrom = hwnd;
|
2000-01-04 01:30:21 +01:00
|
|
|
nmsc.nmhdr.idFrom = GetWindowLongA(hwnd, GWL_ID);
|
1999-11-21 03:04:09 +01:00
|
|
|
nmsc.nmhdr.code = MCN_SELECT;
|
2000-01-04 01:30:21 +01:00
|
|
|
MONTHCAL_CopyTime(&nmsc.stSelStart, &infoPtr->minSel);
|
|
|
|
MONTHCAL_CopyTime(&nmsc.stSelEnd, &infoPtr->maxSel);
|
1999-07-31 13:13:25 +02:00
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
SendMessageA(GetParent(hwnd), WM_NOTIFY,
|
|
|
|
(WPARAM)nmsc.nmhdr.idFrom, (LPARAM)&nmsc);
|
|
|
|
|
|
|
|
/* redraw if necessary */
|
2000-05-30 22:06:33 +02:00
|
|
|
if(redraw)
|
|
|
|
InvalidateRect(hwnd, NULL, FALSE);
|
1999-07-31 13:13:25 +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
|
2000-01-04 01:30:21 +01:00
|
|
|
MONTHCAL_Timer(HWND hwnd, WPARAM wParam, LPARAM lParam)
|
1999-07-31 13:13:25 +02:00
|
|
|
{
|
2000-01-04 01:30:21 +01:00
|
|
|
MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd);
|
|
|
|
BOOL redraw = FALSE;
|
1999-11-21 03:04:09 +01:00
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
TRACE(" %d\n", wParam);
|
|
|
|
if(!infoPtr) return 0;
|
1999-11-21 03:04:09 +01:00
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
switch(wParam) {
|
1999-11-21 03:04:09 +01:00
|
|
|
case MC_NEXTMONTHTIMER:
|
2000-01-04 01:30:21 +01:00
|
|
|
redraw = TRUE;
|
|
|
|
MONTHCAL_GoToNextMonth(hwnd, infoPtr);
|
1999-11-21 03:04:09 +01:00
|
|
|
break;
|
|
|
|
case MC_PREVMONTHTIMER:
|
2000-01-04 01:30:21 +01:00
|
|
|
redraw = TRUE;
|
|
|
|
MONTHCAL_GoToPrevMonth(hwnd, infoPtr);
|
1999-11-21 03:04:09 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ERR("got unknown timer\n");
|
|
|
|
}
|
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)
|
|
|
|
InvalidateRect(hwnd, 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
|
2000-01-04 01:30:21 +01:00
|
|
|
MONTHCAL_MouseMove(HWND hwnd, WPARAM wParam, LPARAM lParam)
|
1999-07-10 14:00:04 +02:00
|
|
|
{
|
2000-01-04 01:30:21 +01:00
|
|
|
MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd);
|
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
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
ht.pt.x = LOWORD(lParam);
|
|
|
|
ht.pt.y = HIWORD(lParam);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
hit = MONTHCAL_HitTest(hwnd, (LPARAM)&ht);
|
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
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
if(GetWindowLongA(hwnd, GWL_STYLE) & MCS_MULTISELECT) {
|
1999-11-21 03:04:09 +01:00
|
|
|
SYSTEMTIME selArray[2];
|
|
|
|
int i;
|
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
MONTHCAL_GetSelRange(hwnd, 0, (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);
|
|
|
|
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
|
|
|
}
|
1999-07-10 14:00:04 +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;
|
|
|
|
}
|
1999-07-10 14:00:04 +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);
|
1999-07-10 14:00:04 +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
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
MONTHCAL_SetSelRange(hwnd, 0, (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 */
|
|
|
|
/* using RedrawWindow */
|
|
|
|
if(oldselday != infoPtr->curSelDay)
|
|
|
|
InvalidateRect(hwnd, 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
|
2000-01-04 01:30:21 +01:00
|
|
|
MONTHCAL_Paint(HWND hwnd, WPARAM wParam)
|
1999-07-10 14:00:04 +02:00
|
|
|
{
|
2000-05-30 22:06:33 +02:00
|
|
|
MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd);
|
1999-11-21 03:04:09 +01:00
|
|
|
HDC hdc;
|
|
|
|
PAINTSTRUCT ps;
|
1999-07-10 14:00:04 +02:00
|
|
|
|
2000-05-30 22:06:33 +02:00
|
|
|
/* fill ps.rcPaint with a default rect */
|
|
|
|
memcpy(&(ps.rcPaint), &(infoPtr->rcClient), sizeof(infoPtr->rcClient));
|
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
hdc = (wParam==0 ? BeginPaint(hwnd, &ps) : (HDC)wParam);
|
2000-05-30 22:06:33 +02:00
|
|
|
MONTHCAL_Refresh(hwnd, hdc, &ps);
|
2000-01-04 01:30:21 +01:00
|
|
|
if(!wParam) EndPaint(hwnd, &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
|
2000-01-04 01:30:21 +01:00
|
|
|
MONTHCAL_KillFocus(HWND hwnd, WPARAM wParam, LPARAM lParam)
|
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
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
InvalidateRect(hwnd, 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
|
2000-01-04 01:30:21 +01:00
|
|
|
MONTHCAL_SetFocus(HWND hwnd, WPARAM wParam, LPARAM lParam)
|
1999-07-10 14:00:04 +02:00
|
|
|
{
|
2000-01-04 01:30:21 +01:00
|
|
|
TRACE("\n");
|
2000-05-30 22:06:33 +02:00
|
|
|
|
|
|
|
InvalidateRect(hwnd, 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 */
|
|
|
|
static void MONTHCAL_UpdateSize(HWND hwnd)
|
|
|
|
{
|
|
|
|
HDC hdc = GetDC(hwnd);
|
|
|
|
MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd);
|
|
|
|
RECT *rcClient=&infoPtr->rcClient;
|
|
|
|
RECT *rcDraw=&infoPtr->rcDraw;
|
|
|
|
RECT *title=&infoPtr->title;
|
|
|
|
RECT *prev=&infoPtr->titlebtnprev;
|
|
|
|
RECT *next=&infoPtr->titlebtnnext;
|
|
|
|
RECT *titlemonth=&infoPtr->titlemonth;
|
|
|
|
RECT *titleyear=&infoPtr->titleyear;
|
|
|
|
RECT *days=&infoPtr->days;
|
|
|
|
SIZE size;
|
|
|
|
TEXTMETRICA tm;
|
|
|
|
DWORD dwStyle = GetWindowLongA(hwnd, GWL_STYLE);
|
|
|
|
HFONT currentFont;
|
|
|
|
|
|
|
|
currentFont = SelectObject(hdc, infoPtr->hFont);
|
|
|
|
|
|
|
|
/* FIXME: need a way to determine current font, without setting it */
|
|
|
|
/*
|
|
|
|
if(infoPtr->hFont!=currentFont) {
|
|
|
|
SelectObject(hdc, currentFont);
|
|
|
|
infoPtr->hFont=currentFont;
|
|
|
|
GetObjectA(currentFont, sizeof(LOGFONTA), &logFont);
|
|
|
|
logFont.lfWeight=FW_BOLD;
|
|
|
|
infoPtr->hBoldFont = CreateFontIndirectA(&logFont);
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* get the height and width of each day's text */
|
|
|
|
GetTextMetricsA(hdc, &tm);
|
|
|
|
infoPtr->textHeight = tm.tmHeight + tm.tmExternalLeading;
|
|
|
|
GetTextExtentPoint32A(hdc, "Sun", 3, &size);
|
|
|
|
infoPtr->textWidth = size.cx + 2;
|
|
|
|
|
|
|
|
/* retrieve the controls client rectangle info infoPtr->rcClient */
|
|
|
|
GetClientRect(hwnd, rcClient);
|
|
|
|
|
|
|
|
if(dwStyle & MCS_WEEKNUMBERS)
|
|
|
|
infoPtr->rcClient.right+=infoPtr->textWidth;
|
|
|
|
|
|
|
|
/* rcDraw is the rectangle the control is drawn in */
|
|
|
|
rcDraw->left = rcClient->left;
|
|
|
|
rcDraw->right = rcClient->right;
|
|
|
|
rcDraw->top = rcClient->top;
|
|
|
|
rcDraw->bottom = rcClient->bottom;
|
|
|
|
|
|
|
|
/* this is correct, the control does NOT expand vertically */
|
|
|
|
/* like it does horizontally */
|
|
|
|
/* make sure we don't move the controls bottom out of the client */
|
|
|
|
/* area */
|
|
|
|
if((rcDraw->top + 8 * infoPtr->textHeight + 5) < rcDraw->bottom) {
|
|
|
|
rcDraw->bottom = rcDraw->top + 8 * infoPtr->textHeight + 5;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* calculate title area */
|
2000-07-08 13:43:57 +02:00
|
|
|
title->top = rcClient->top;
|
2000-01-04 01:30:21 +01:00
|
|
|
title->bottom = title->top + 2 * infoPtr->textHeight + 4;
|
2000-07-08 13:43:57 +02:00
|
|
|
title->left = rcClient->left;
|
|
|
|
title->right = rcClient->right;
|
2000-01-04 01:30:21 +01:00
|
|
|
|
|
|
|
/* recalculate the height and width increments and offsets */
|
|
|
|
infoPtr->width_increment = (infoPtr->rcDraw.right - infoPtr->rcDraw.left) / 7.0;
|
|
|
|
infoPtr->height_increment = (infoPtr->rcDraw.bottom - infoPtr->rcDraw.top) / 7.0;
|
|
|
|
infoPtr->left_offset = (infoPtr->rcDraw.right - infoPtr->rcDraw.left) - (infoPtr->width_increment * 7.0);
|
|
|
|
infoPtr->top_offset = (infoPtr->rcDraw.bottom - infoPtr->rcDraw.top) - (infoPtr->height_increment * 7.0);
|
|
|
|
|
|
|
|
/* set the dimensions of the next and previous buttons and center */
|
|
|
|
/* the month text vertically */
|
|
|
|
prev->top = next->top = title->top + 6;
|
|
|
|
prev->bottom = next->bottom = title->top + 2 * infoPtr->textHeight - 3;
|
|
|
|
prev->right = title->left + 28;
|
|
|
|
prev->left = title->left + 4;
|
|
|
|
next->left = title->right - 28;
|
|
|
|
next->right = title->right - 4;
|
|
|
|
|
|
|
|
/* 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 */
|
|
|
|
titlemonth->bottom = titleyear->bottom = prev->top + 2 * infoPtr->textHeight - 3;
|
|
|
|
titlemonth->top = titleyear->top = title->top;
|
|
|
|
|
|
|
|
/* setup the dimensions of the rectangle we draw the names of the */
|
|
|
|
/* days of the week in */
|
|
|
|
days->left = infoPtr->left_offset;
|
|
|
|
if(dwStyle & MCS_WEEKNUMBERS) days->left+=infoPtr->textWidth;
|
|
|
|
days->right = days->left + infoPtr->width_increment;
|
|
|
|
days->top = title->bottom + 2;
|
|
|
|
days->bottom = title->bottom + infoPtr->textHeight + 2;
|
|
|
|
|
|
|
|
/* restore the originally selected font */
|
|
|
|
SelectObject(hdc, currentFont);
|
|
|
|
|
|
|
|
ReleaseDC(hwnd, hdc);
|
|
|
|
}
|
|
|
|
|
|
|
|
static LRESULT MONTHCAL_Size(HWND hwnd, int Width, int Height)
|
|
|
|
{
|
|
|
|
TRACE("(hwnd=%x, width=%d, height=%d)\n", hwnd, Width, Height);
|
|
|
|
|
|
|
|
MONTHCAL_UpdateSize(hwnd);
|
|
|
|
|
|
|
|
/* invalidate client area and erase background */
|
|
|
|
InvalidateRect(hwnd, NULL, TRUE);
|
|
|
|
|
|
|
|
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;
|
|
|
|
LOGFONTA logFont;
|
1998-11-08 12:30:27 +01:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
/* allocate memory for info structure */
|
2000-01-04 01:30:21 +01:00
|
|
|
infoPtr =(MONTHCAL_INFO*)COMCTL32_Alloc(sizeof(MONTHCAL_INFO));
|
|
|
|
SetWindowLongA(hwnd, 0, (DWORD)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;
|
|
|
|
}
|
2000-01-04 01:30:21 +01:00
|
|
|
if((MONTHCAL_INFO*)GetWindowLongA(hwnd, 0) != infoPtr) {
|
|
|
|
ERR( "pointer assignment error!\n");
|
1999-11-21 03:04:09 +01:00
|
|
|
return 0;
|
|
|
|
}
|
1998-11-08 12:30:27 +01:00
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
infoPtr->hFont = GetStockObject(DEFAULT_GUI_FONT);
|
|
|
|
GetObjectA(infoPtr->hFont, sizeof(LOGFONTA), &logFont);
|
1999-11-21 03:04:09 +01:00
|
|
|
logFont.lfWeight = FW_BOLD;
|
2000-01-04 01:30:21 +01:00
|
|
|
infoPtr->hBoldFont = CreateFontIndirectA(&logFont);
|
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
|
|
|
|
|
|
|
GetSystemTime(&infoPtr->todaysDate);
|
|
|
|
infoPtr->firstDay = 0;
|
|
|
|
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);
|
1999-11-21 03:04:09 +01:00
|
|
|
infoPtr->maxSelCount = 6;
|
|
|
|
infoPtr->monthRange = 3;
|
2000-01-04 01:30:21 +01:00
|
|
|
infoPtr->monthdayState = COMCTL32_Alloc
|
|
|
|
(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);
|
|
|
|
|
|
|
|
/* call MONTHCAL_UpdateSize to set all of the dimensions */
|
|
|
|
/* of the control */
|
|
|
|
MONTHCAL_UpdateSize(hwnd);
|
1999-11-21 03:04:09 +01:00
|
|
|
|
|
|
|
return 0;
|
1998-11-08 12:30:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static LRESULT
|
2000-01-04 01:30:21 +01:00
|
|
|
MONTHCAL_Destroy(HWND hwnd, WPARAM wParam, LPARAM lParam)
|
1998-11-08 12:30:27 +01:00
|
|
|
{
|
2000-01-04 01:30:21 +01:00
|
|
|
MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd);
|
1998-11-08 12:30:27 +01:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
/* free month calendar info data */
|
2000-01-04 01:30:21 +01:00
|
|
|
COMCTL32_Free(infoPtr);
|
2000-05-10 03:34:53 +02:00
|
|
|
SetWindowLongA(hwnd, 0, 0);
|
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
|
|
|
{
|
2000-05-10 03:34:53 +02:00
|
|
|
TRACE("hwnd=%x msg=%x wparam=%x lparam=%lx\n", hwnd, uMsg, wParam, lParam);
|
|
|
|
if (!MONTHCAL_GetInfoPtr(hwnd) && (uMsg != WM_CREATE))
|
|
|
|
return DefWindowProcA(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:
|
2000-01-04 01:30:21 +01:00
|
|
|
return MONTHCAL_GetCurSel(hwnd, wParam, lParam);
|
1999-07-31 13:13:25 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
case MCM_SETCURSEL:
|
2000-01-04 01:30:21 +01:00
|
|
|
return MONTHCAL_SetCurSel(hwnd, wParam, lParam);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
case MCM_GETMAXSELCOUNT:
|
2000-01-04 01:30:21 +01:00
|
|
|
return MONTHCAL_GetMaxSelCount(hwnd, wParam, lParam);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
case MCM_SETMAXSELCOUNT:
|
2000-01-04 01:30:21 +01:00
|
|
|
return MONTHCAL_SetMaxSelCount(hwnd, wParam, lParam);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
case MCM_GETSELRANGE:
|
2000-01-04 01:30:21 +01:00
|
|
|
return MONTHCAL_GetSelRange(hwnd, wParam, lParam);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
case MCM_SETSELRANGE:
|
2000-01-04 01:30:21 +01:00
|
|
|
return MONTHCAL_SetSelRange(hwnd, wParam, lParam);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
case MCM_GETMONTHRANGE:
|
2000-01-04 01:30:21 +01:00
|
|
|
return MONTHCAL_GetMonthRange(hwnd, wParam, lParam);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
case MCM_SETDAYSTATE:
|
2000-01-04 01:30:21 +01:00
|
|
|
return MONTHCAL_SetDayState(hwnd, wParam, lParam);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
case MCM_GETMINREQRECT:
|
2000-01-04 01:30:21 +01:00
|
|
|
return MONTHCAL_GetMinReqRect(hwnd, wParam, lParam);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
case MCM_GETCOLOR:
|
2000-01-04 01:30:21 +01:00
|
|
|
return MONTHCAL_GetColor(hwnd, wParam, lParam);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
case MCM_SETCOLOR:
|
2000-01-04 01:30:21 +01:00
|
|
|
return MONTHCAL_SetColor(hwnd, wParam, lParam);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
case MCM_GETTODAY:
|
2000-01-04 01:30:21 +01:00
|
|
|
return MONTHCAL_GetToday(hwnd, wParam, lParam);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
case MCM_SETTODAY:
|
2000-01-04 01:30:21 +01:00
|
|
|
return MONTHCAL_SetToday(hwnd, wParam, lParam);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
case MCM_HITTEST:
|
2000-01-04 01:30:21 +01:00
|
|
|
return MONTHCAL_HitTest(hwnd,lParam);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
case MCM_GETFIRSTDAYOFWEEK:
|
2000-01-04 01:30:21 +01:00
|
|
|
return MONTHCAL_GetFirstDayOfWeek(hwnd, wParam, lParam);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
case MCM_SETFIRSTDAYOFWEEK:
|
2000-01-04 01:30:21 +01:00
|
|
|
return MONTHCAL_SetFirstDayOfWeek(hwnd, wParam, 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:
|
2000-01-04 01:30:21 +01:00
|
|
|
return MONTHCAL_SetRange(hwnd, wParam, lParam);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
case MCM_GETMONTHDELTA:
|
2000-01-04 01:30:21 +01:00
|
|
|
return MONTHCAL_GetMonthDelta(hwnd, wParam, lParam);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
case MCM_SETMONTHDELTA:
|
2000-01-04 01:30:21 +01:00
|
|
|
return MONTHCAL_SetMonthDelta(hwnd, wParam, lParam);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
case MCM_GETMAXTODAYWIDTH:
|
2000-01-04 01:30:21 +01:00
|
|
|
return MONTHCAL_GetMaxTodayWidth(hwnd);
|
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:
|
2000-01-04 01:30:21 +01:00
|
|
|
return MONTHCAL_KillFocus(hwnd, wParam, lParam);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
case WM_LBUTTONDOWN:
|
2000-01-04 01:30:21 +01:00
|
|
|
return MONTHCAL_LButtonDown(hwnd, wParam, lParam);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
case WM_MOUSEMOVE:
|
2000-01-04 01:30:21 +01:00
|
|
|
return MONTHCAL_MouseMove(hwnd, wParam, lParam);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
case WM_LBUTTONUP:
|
2000-01-04 01:30:21 +01:00
|
|
|
return MONTHCAL_LButtonUp(hwnd, wParam, lParam);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
case WM_PAINT:
|
2000-01-04 01:30:21 +01:00
|
|
|
return MONTHCAL_Paint(hwnd, wParam);
|
1999-07-10 14:00:04 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
case WM_SETFOCUS:
|
2000-01-04 01:30:21 +01:00
|
|
|
return MONTHCAL_SetFocus(hwnd, wParam, lParam);
|
|
|
|
|
|
|
|
case WM_SIZE:
|
|
|
|
return MONTHCAL_Size(hwnd, (int)SLOWORD(lParam), (int)SHIWORD(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
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
case WM_TIMER:
|
2000-01-04 01:30:21 +01:00
|
|
|
return MONTHCAL_Timer(hwnd, wParam, lParam);
|
1999-07-31 13:13:25 +02:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
case WM_DESTROY:
|
2000-01-04 01:30:21 +01:00
|
|
|
return MONTHCAL_Destroy(hwnd, wParam, lParam);
|
1998-11-08 12:30:27 +01:00
|
|
|
|
1999-11-21 03:04:09 +01:00
|
|
|
default:
|
2000-01-04 01:30:21 +01:00
|
|
|
if(uMsg >= WM_USER)
|
|
|
|
ERR( "unknown msg %04x wp=%08x lp=%08lx\n", uMsg, wParam, lParam);
|
|
|
|
return DefWindowProcA(hwnd, uMsg, wParam, lParam);
|
1999-11-21 03:04:09 +01:00
|
|
|
}
|
|
|
|
return 0;
|
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
|
|
|
{
|
1999-11-21 03:04:09 +01:00
|
|
|
WNDCLASSA wndClass;
|
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
ZeroMemory(&wndClass, sizeof(WNDCLASSA));
|
1999-11-21 03:04:09 +01:00
|
|
|
wndClass.style = CS_GLOBALCLASS;
|
|
|
|
wndClass.lpfnWndProc = (WNDPROC)MONTHCAL_WindowProc;
|
|
|
|
wndClass.cbClsExtra = 0;
|
|
|
|
wndClass.cbWndExtra = sizeof(MONTHCAL_INFO *);
|
2000-01-04 01:30:21 +01:00
|
|
|
wndClass.hCursor = LoadCursorA(0, IDC_ARROWA);
|
1999-11-21 03:04:09 +01:00
|
|
|
wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
|
|
|
|
wndClass.lpszClassName = MONTHCAL_CLASSA;
|
1998-11-08 12:30:27 +01:00
|
|
|
|
2000-01-04 01:30:21 +01:00
|
|
|
RegisterClassA(&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
|
|
|
{
|
2000-01-04 01:30:21 +01:00
|
|
|
UnregisterClassA(MONTHCAL_CLASSA, (HINSTANCE)NULL);
|
1998-11-08 12:30:27 +01:00
|
|
|
}
|