Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
30bebfdc
Commit
30bebfdc
authored
Nov 30, 2004
by
Dmitry Timoshkov
Committed by
Alexandre Julliard
Nov 30, 2004
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Pass infoPtr around in month calendar control.
- Add support for WM_SETFONT and WM_GETFONT messages.
parent
88aeb475
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
206 additions
and
212 deletions
+206
-212
monthcal.c
dlls/comctl32/monthcal.c
+206
-212
No files found.
dlls/comctl32/monthcal.c
View file @
30bebfdc
...
...
@@ -279,8 +279,7 @@ static inline void MONTHCAL_CalcPosFromDay(MONTHCAL_INFO *infoPtr,
/* day is the day in the month(1 == 1st of the month) */
/* month is the month value(1 == january, 12 == december) */
static
void
MONTHCAL_CircleDay
(
HDC
hdc
,
MONTHCAL_INFO
*
infoPtr
,
int
day
,
int
month
)
static
void
MONTHCAL_CircleDay
(
MONTHCAL_INFO
*
infoPtr
,
HDC
hdc
,
int
day
,
int
month
)
{
HPEN
hRedPen
=
CreatePen
(
PS_SOLID
,
2
,
RGB
(
255
,
0
,
0
));
HPEN
hOldPen2
=
SelectObject
(
hdc
,
hRedPen
);
...
...
@@ -331,7 +330,7 @@ int month)
}
static
void
MONTHCAL_DrawDay
(
HDC
hdc
,
MONTHCAL_INFO
*
infoPtr
,
int
day
,
int
month
,
static
void
MONTHCAL_DrawDay
(
MONTHCAL_INFO
*
infoPtr
,
HDC
hdc
,
int
day
,
int
month
,
int
x
,
int
y
,
int
bold
)
{
char
buf
[
10
];
...
...
@@ -404,9 +403,8 @@ static void MONTHCAL_DrawDay(HDC hdc, MONTHCAL_INFO *infoPtr, int day, int month
}
static
void
MONTHCAL_Refresh
(
HWND
hwnd
,
HDC
hdc
,
PAINTSTRUCT
*
ps
)
static
void
MONTHCAL_Refresh
(
MONTHCAL_INFO
*
infoPtr
,
HDC
hdc
,
PAINTSTRUCT
*
ps
)
{
MONTHCAL_INFO
*
infoPtr
=
MONTHCAL_GetInfoPtr
(
hwnd
);
RECT
*
title
=&
infoPtr
->
title
;
RECT
*
prev
=&
infoPtr
->
titlebtnprev
;
RECT
*
next
=&
infoPtr
->
titlebtnnext
;
...
...
@@ -420,12 +418,11 @@ static void MONTHCAL_Refresh(HWND hwnd, HDC hdc, PAINTSTRUCT* ps)
SIZE
size
;
HBRUSH
hbr
;
HFONT
currentFont
;
/* LOGFONTA logFont; */
char
buf
[
20
];
char
buf1
[
20
];
char
buf2
[
32
];
COLORREF
oldTextColor
,
oldBkColor
;
DWORD
dwStyle
=
GetWindowLong
A
(
hwnd
,
GWL_STYLE
);
DWORD
dwStyle
=
GetWindowLong
W
(
infoPtr
->
hwndSelf
,
GWL_STYLE
);
RECT
rcTemp
;
RECT
rcDay
;
/* used in MONTHCAL_CalcDayRect() */
SYSTEMTIME
localtime
;
...
...
@@ -563,7 +560,7 @@ static void MONTHCAL_Refresh(HWND hwnd, HDC hdc, PAINTSTRUCT* ps)
MONTHCAL_CalcDayRect
(
infoPtr
,
&
rcDay
,
i
,
0
);
if
(
IntersectRect
(
&
rcTemp
,
&
(
ps
->
rcPaint
),
&
rcDay
))
{
MONTHCAL_DrawDay
(
hdc
,
infoPtr
,
day
,
prevMonth
,
i
,
0
,
MONTHCAL_DrawDay
(
infoPtr
,
hdc
,
day
,
prevMonth
,
i
,
0
,
infoPtr
->
monthdayState
[
m
]
&
mask
);
}
...
...
@@ -587,14 +584,14 @@ static void MONTHCAL_Refresh(HWND hwnd, HDC hdc, PAINTSTRUCT* ps)
if
(
IntersectRect
(
&
rcTemp
,
&
(
ps
->
rcPaint
),
&
rcDay
))
{
MONTHCAL_DrawDay
(
hdc
,
infoPtr
,
day
,
infoPtr
->
currentMonth
,
i
,
0
,
MONTHCAL_DrawDay
(
infoPtr
,
hdc
,
day
,
infoPtr
->
currentMonth
,
i
,
0
,
infoPtr
->
monthdayState
[
m
]
&
mask
);
if
((
infoPtr
->
currentMonth
==
infoPtr
->
todaysDate
.
wMonth
)
&&
(
day
==
infoPtr
->
todaysDate
.
wDay
)
&&
(
infoPtr
->
currentYear
==
infoPtr
->
todaysDate
.
wYear
))
{
if
(
!
(
dwStyle
&
MCS_NOTODAYCIRCLE
))
MONTHCAL_CircleDay
(
hdc
,
infoPtr
,
day
,
infoPtr
->
currentMonth
);
MONTHCAL_CircleDay
(
infoPtr
,
hdc
,
day
,
infoPtr
->
currentMonth
);
}
}
...
...
@@ -609,14 +606,14 @@ static void MONTHCAL_Refresh(HWND hwnd, HDC hdc, PAINTSTRUCT* ps)
MONTHCAL_CalcDayRect
(
infoPtr
,
&
rcDay
,
i
,
j
);
if
(
IntersectRect
(
&
rcTemp
,
&
(
ps
->
rcPaint
),
&
rcDay
))
{
MONTHCAL_DrawDay
(
hdc
,
infoPtr
,
day
,
infoPtr
->
currentMonth
,
i
,
j
,
MONTHCAL_DrawDay
(
infoPtr
,
hdc
,
day
,
infoPtr
->
currentMonth
,
i
,
j
,
infoPtr
->
monthdayState
[
m
]
&
mask
);
if
((
infoPtr
->
currentMonth
==
infoPtr
->
todaysDate
.
wMonth
)
&&
(
day
==
infoPtr
->
todaysDate
.
wDay
)
&&
(
infoPtr
->
currentYear
==
infoPtr
->
todaysDate
.
wYear
))
if
(
!
(
dwStyle
&
MCS_NOTODAYCIRCLE
))
MONTHCAL_CircleDay
(
hdc
,
infoPtr
,
day
,
infoPtr
->
currentMonth
);
MONTHCAL_CircleDay
(
infoPtr
,
hdc
,
day
,
infoPtr
->
currentMonth
);
}
mask
<<=
1
;
day
++
;
...
...
@@ -638,7 +635,7 @@ static void MONTHCAL_Refresh(HWND hwnd, HDC hdc, PAINTSTRUCT* ps)
MONTHCAL_CalcDayRect
(
infoPtr
,
&
rcDay
,
i
,
j
);
if
(
IntersectRect
(
&
rcTemp
,
&
(
ps
->
rcPaint
),
&
rcDay
))
{
MONTHCAL_DrawDay
(
hdc
,
infoPtr
,
day
,
infoPtr
->
currentMonth
+
1
,
i
,
j
,
MONTHCAL_DrawDay
(
infoPtr
,
hdc
,
day
,
infoPtr
->
currentMonth
+
1
,
i
,
j
,
infoPtr
->
monthdayState
[
m
]
&
mask
);
}
...
...
@@ -660,7 +657,7 @@ static void MONTHCAL_Refresh(HWND hwnd, HDC hdc, PAINTSTRUCT* ps)
int
offset
=
0
;
if
(
!
(
dwStyle
&
MCS_NOTODAYCIRCLE
))
{
/*day is the number of days from nextmonth we put on the calendar */
MONTHCAL_CircleDay
(
hdc
,
infoPtr
,
MONTHCAL_CircleDay
(
infoPtr
,
hdc
,
day
+
MONTHCAL_MonthLength
(
infoPtr
->
currentMonth
,
infoPtr
->
currentYear
),
infoPtr
->
currentMonth
);
offset
+=
textWidth
;
...
...
@@ -773,11 +770,11 @@ static void MONTHCAL_Refresh(HWND hwnd, HDC hdc, PAINTSTRUCT* ps)
static
LRESULT
MONTHCAL_GetMinReqRect
(
HWND
hwnd
,
WPARAM
wParam
,
LPARAM
lParam
)
MONTHCAL_GetMinReqRect
(
MONTHCAL_INFO
*
infoPtr
,
LPARAM
lParam
)
{
MONTHCAL_INFO
*
infoPtr
=
MONTHCAL_GetInfoPtr
(
hwnd
);
LPRECT
lpRect
=
(
LPRECT
)
lParam
;
TRACE
(
"%x %lx
\n
"
,
wParam
,
lParam
);
TRACE
(
"rect %p
\n
"
,
lpRect
);
/* validate parameters */
...
...
@@ -787,7 +784,7 @@ MONTHCAL_GetMinReqRect(HWND hwnd, WPARAM wParam, LPARAM lParam)
lpRect
->
top
=
infoPtr
->
title
.
top
;
lpRect
->
right
=
infoPtr
->
title
.
right
;
lpRect
->
bottom
=
infoPtr
->
todayrect
.
bottom
;
AdjustWindowRect
(
lpRect
,
GetWindowLongW
(
hwnd
,
GWL_STYLE
),
FALSE
);
AdjustWindowRect
(
lpRect
,
GetWindowLongW
(
infoPtr
->
hwndSelf
,
GWL_STYLE
),
FALSE
);
TRACE
(
"%s
\n
"
,
wine_dbgstr_rect
(
lpRect
));
...
...
@@ -796,11 +793,9 @@ MONTHCAL_GetMinReqRect(HWND hwnd, WPARAM wParam, LPARAM lParam)
static
LRESULT
MONTHCAL_GetColor
(
HWND
hwnd
,
WPARAM
wParam
,
LPARAM
l
Param
)
MONTHCAL_GetColor
(
MONTHCAL_INFO
*
infoPtr
,
WPARAM
w
Param
)
{
MONTHCAL_INFO
*
infoPtr
=
MONTHCAL_GetInfoPtr
(
hwnd
);
TRACE
(
"%x %lx
\n
"
,
wParam
,
lParam
);
TRACE
(
"
\n
"
);
switch
((
int
)
wParam
)
{
case
MCSC_BACKGROUND
:
...
...
@@ -822,12 +817,11 @@ MONTHCAL_GetColor(HWND hwnd, WPARAM wParam, LPARAM lParam)
static
LRESULT
MONTHCAL_SetColor
(
HWND
hwnd
,
WPARAM
wParam
,
LPARAM
lParam
)
MONTHCAL_SetColor
(
MONTHCAL_INFO
*
infoPtr
,
WPARAM
wParam
,
LPARAM
lParam
)
{
MONTHCAL_INFO
*
infoPtr
=
MONTHCAL_GetInfoPtr
(
hwnd
);
int
prev
=
-
1
;
TRACE
(
"%
x %
lx
\n
"
,
wParam
,
lParam
);
TRACE
(
"%
d: color %08
lx
\n
"
,
wParam
,
lParam
);
switch
((
int
)
wParam
)
{
case
MCSC_BACKGROUND
:
...
...
@@ -856,17 +850,15 @@ MONTHCAL_SetColor(HWND hwnd, WPARAM wParam, LPARAM lParam)
break
;
}
InvalidateRect
(
hwnd
,
NULL
,
FALSE
);
InvalidateRect
(
infoPtr
->
hwndSelf
,
NULL
,
FALSE
);
return
prev
;
}
static
LRESULT
MONTHCAL_GetMonthDelta
(
HWND
hwnd
,
WPARAM
wParam
,
LPARAM
lParam
)
MONTHCAL_GetMonthDelta
(
MONTHCAL_INFO
*
infoPtr
)
{
MONTHCAL_INFO
*
infoPtr
=
MONTHCAL_GetInfoPtr
(
hwnd
);
TRACE
(
"%x %lx
\n
"
,
wParam
,
lParam
);
TRACE
(
"
\n
"
);
if
(
infoPtr
->
delta
)
return
infoPtr
->
delta
;
...
...
@@ -876,12 +868,11 @@ MONTHCAL_GetMonthDelta(HWND hwnd, WPARAM wParam, LPARAM lParam)
static
LRESULT
MONTHCAL_SetMonthDelta
(
HWND
hwnd
,
WPARAM
wParam
,
LPARAM
l
Param
)
MONTHCAL_SetMonthDelta
(
MONTHCAL_INFO
*
infoPtr
,
WPARAM
w
Param
)
{
MONTHCAL_INFO
*
infoPtr
=
MONTHCAL_GetInfoPtr
(
hwnd
);
int
prev
=
infoPtr
->
delta
;
TRACE
(
"
%x %lx
\n
"
,
wParam
,
l
Param
);
TRACE
(
"
delta %d
\n
"
,
w
Param
);
infoPtr
->
delta
=
(
int
)
wParam
;
return
prev
;
...
...
@@ -889,10 +880,8 @@ MONTHCAL_SetMonthDelta(HWND hwnd, WPARAM wParam, LPARAM lParam)
static
LRESULT
MONTHCAL_GetFirstDayOfWeek
(
HWND
hwnd
,
WPARAM
wParam
,
LPARAM
lParam
)
MONTHCAL_GetFirstDayOfWeek
(
MONTHCAL_INFO
*
infoPtr
)
{
MONTHCAL_INFO
*
infoPtr
=
MONTHCAL_GetInfoPtr
(
hwnd
);
return
infoPtr
->
firstDay
;
}
...
...
@@ -902,14 +891,13 @@ MONTHCAL_GetFirstDayOfWeek(HWND hwnd, WPARAM wParam, LPARAM lParam)
/* FIXME: this needs to be implemented properly in MONTHCAL_Refresh() */
/* FIXME: we need more error checking here */
static
LRESULT
MONTHCAL_SetFirstDayOfWeek
(
HWND
hwnd
,
WPARAM
wParam
,
LPARAM
lParam
)
MONTHCAL_SetFirstDayOfWeek
(
MONTHCAL_INFO
*
infoPtr
,
LPARAM
lParam
)
{
MONTHCAL_INFO
*
infoPtr
=
MONTHCAL_GetInfoPtr
(
hwnd
);
int
prev
=
infoPtr
->
firstDay
;
char
buf
[
40
];
int
day
;
TRACE
(
"
%x %lx
\n
"
,
wParam
,
lParam
);
TRACE
(
"
day %ld
\n
"
,
lParam
);
if
((
lParam
>=
0
)
&&
(
lParam
<
7
))
{
infoPtr
->
firstDay
=
(
int
)
lParam
;
...
...
@@ -929,22 +917,17 @@ MONTHCAL_SetFirstDayOfWeek(HWND hwnd, WPARAM wParam, LPARAM lParam)
static
LRESULT
MONTHCAL_GetMonthRange
(
HWND
hwnd
,
WPARAM
wParam
,
LPARAM
lParam
)
MONTHCAL_GetMonthRange
(
MONTHCAL_INFO
*
infoPtr
)
{
MONTHCAL_INFO
*
infoPtr
=
MONTHCAL_GetInfoPtr
(
hwnd
);
TRACE
(
"%x %lx
\n
"
,
wParam
,
lParam
);
FIXME
(
"stub
\n
"
);
TRACE
(
"
\n
"
);
return
infoPtr
->
monthRange
;
}
static
LRESULT
MONTHCAL_GetMaxTodayWidth
(
HWND
hwnd
)
MONTHCAL_GetMaxTodayWidth
(
MONTHCAL_INFO
*
infoPtr
)
{
MONTHCAL_INFO
*
infoPtr
=
MONTHCAL_GetInfoPtr
(
hwnd
);
return
(
infoPtr
->
todayrect
.
right
-
infoPtr
->
todayrect
.
left
);
}
...
...
@@ -956,9 +939,8 @@ MONTHCAL_GetMaxTodayWidth(HWND hwnd)
*/
static
LRESULT
MONTHCAL_SetRange
(
HWND
hwnd
,
WPARAM
wParam
,
LPARAM
lParam
)
MONTHCAL_SetRange
(
MONTHCAL_INFO
*
infoPtr
,
WPARAM
wParam
,
LPARAM
lParam
)
{
MONTHCAL_INFO
*
infoPtr
=
MONTHCAL_GetInfoPtr
(
hwnd
);
SYSTEMTIME
*
lprgSysTimeArray
=
(
SYSTEMTIME
*
)
lParam
;
int
prev
;
...
...
@@ -1013,10 +995,9 @@ MONTHCAL_GetRange(HWND hwnd, WPARAM wParam, LPARAM lParam)
static
LRESULT
MONTHCAL_SetDayState
(
HWND
hwnd
,
WPARAM
wParam
,
LPARAM
lParam
)
MONTHCAL_SetDayState
(
MONTHCAL_INFO
*
infoPtr
,
WPARAM
wParam
,
LPARAM
lParam
)
{
MONTHCAL_INFO
*
infoPtr
=
MONTHCAL_GetInfoPtr
(
hwnd
);
int
i
,
iMonths
=
(
int
)
wParam
;
MONTHDAYSTATE
*
dayStates
=
(
LPMONTHDAYSTATE
)
lParam
;
...
...
@@ -1029,14 +1010,13 @@ MONTHCAL_SetDayState(HWND hwnd, WPARAM wParam, LPARAM lParam)
}
static
LRESULT
MONTHCAL_GetCurSel
(
HWND
hwnd
,
WPARAM
wParam
,
LPARAM
lParam
)
MONTHCAL_GetCurSel
(
MONTHCAL_INFO
*
infoPtr
,
LPARAM
lParam
)
{
MONTHCAL_INFO
*
infoPtr
=
MONTHCAL_GetInfoPtr
(
hwnd
);
SYSTEMTIME
*
lpSel
=
(
SYSTEMTIME
*
)
lParam
;
TRACE
(
"%
x %lx
\n
"
,
wParam
,
lParam
);
TRACE
(
"%
lx
\n
"
,
lParam
);
if
((
infoPtr
==
NULL
)
||
(
lpSel
==
NULL
))
return
FALSE
;
if
(
GetWindowLong
A
(
hwnd
,
GWL_STYLE
)
&
MCS_MULTISELECT
)
return
FALSE
;
if
(
GetWindowLong
W
(
infoPtr
->
hwndSelf
,
GWL_STYLE
)
&
MCS_MULTISELECT
)
return
FALSE
;
MONTHCAL_CopyTime
(
&
infoPtr
->
minSel
,
lpSel
);
TRACE
(
"%d/%d/%d
\n
"
,
lpSel
->
wYear
,
lpSel
->
wMonth
,
lpSel
->
wDay
);
...
...
@@ -1046,14 +1026,13 @@ MONTHCAL_GetCurSel(HWND hwnd, WPARAM wParam, LPARAM lParam)
/* FIXME: if the specified date is not visible, make it visible */
/* FIXME: redraw? */
static
LRESULT
MONTHCAL_SetCurSel
(
HWND
hwnd
,
WPARAM
wParam
,
LPARAM
lParam
)
MONTHCAL_SetCurSel
(
MONTHCAL_INFO
*
infoPtr
,
LPARAM
lParam
)
{
MONTHCAL_INFO
*
infoPtr
=
MONTHCAL_GetInfoPtr
(
hwnd
);
SYSTEMTIME
*
lpSel
=
(
SYSTEMTIME
*
)
lParam
;
TRACE
(
"%
x %lx
\n
"
,
wParam
,
lParam
);
TRACE
(
"%
lx
\n
"
,
lParam
);
if
((
infoPtr
==
NULL
)
||
(
lpSel
==
NULL
))
return
FALSE
;
if
(
GetWindowLong
A
(
hwnd
,
GWL_STYLE
)
&
MCS_MULTISELECT
)
return
FALSE
;
if
(
GetWindowLong
W
(
infoPtr
->
hwndSelf
,
GWL_STYLE
)
&
MCS_MULTISELECT
)
return
FALSE
;
infoPtr
->
currentMonth
=
lpSel
->
wMonth
;
infoPtr
->
currentYear
=
lpSel
->
wYear
;
...
...
@@ -1061,29 +1040,25 @@ MONTHCAL_SetCurSel(HWND hwnd, WPARAM wParam, LPARAM lParam)
MONTHCAL_CopyTime
(
lpSel
,
&
infoPtr
->
minSel
);
MONTHCAL_CopyTime
(
lpSel
,
&
infoPtr
->
maxSel
);
InvalidateRect
(
hwnd
,
NULL
,
FALSE
);
InvalidateRect
(
infoPtr
->
hwndSelf
,
NULL
,
FALSE
);
return
TRUE
;
}
static
LRESULT
MONTHCAL_GetMaxSelCount
(
HWND
hwnd
,
WPARAM
wParam
,
LPARAM
lParam
)
MONTHCAL_GetMaxSelCount
(
MONTHCAL_INFO
*
infoPtr
)
{
MONTHCAL_INFO
*
infoPtr
=
MONTHCAL_GetInfoPtr
(
hwnd
);
TRACE
(
"%x %lx
\n
"
,
wParam
,
lParam
);
return
infoPtr
->
maxSelCount
;
}
static
LRESULT
MONTHCAL_SetMaxSelCount
(
HWND
hwnd
,
WPARAM
wParam
,
LPARAM
l
Param
)
MONTHCAL_SetMaxSelCount
(
MONTHCAL_INFO
*
infoPtr
,
WPARAM
w
Param
)
{
MONTHCAL_INFO
*
infoPtr
=
MONTHCAL_GetInfoPtr
(
hwnd
);
TRACE
(
"%x
\n
"
,
wParam
);
TRACE
(
"%x %lx
\n
"
,
wParam
,
lParam
);
if
(
GetWindowLongA
(
hwnd
,
GWL_STYLE
)
&
MCS_MULTISELECT
)
{
if
(
GetWindowLongW
(
infoPtr
->
hwndSelf
,
GWL_STYLE
)
&
MCS_MULTISELECT
)
{
infoPtr
->
maxSelCount
=
wParam
;
}
...
...
@@ -1092,18 +1067,17 @@ MONTHCAL_SetMaxSelCount(HWND hwnd, WPARAM wParam, LPARAM lParam)
static
LRESULT
MONTHCAL_GetSelRange
(
HWND
hwnd
,
WPARAM
wParam
,
LPARAM
lParam
)
MONTHCAL_GetSelRange
(
MONTHCAL_INFO
*
infoPtr
,
LPARAM
lParam
)
{
MONTHCAL_INFO
*
infoPtr
=
MONTHCAL_GetInfoPtr
(
hwnd
);
SYSTEMTIME
*
lprgSysTimeArray
=
(
SYSTEMTIME
*
)
lParam
;
TRACE
(
"%
x %lx
\n
"
,
wParam
,
lParam
);
TRACE
(
"%
lx
\n
"
,
lParam
);
/* validate parameters */
if
((
infoPtr
==
NULL
)
||
(
lprgSysTimeArray
==
NULL
))
return
FALSE
;
if
(
GetWindowLong
A
(
hwnd
,
GWL_STYLE
)
&
MCS_MULTISELECT
)
if
(
GetWindowLong
W
(
infoPtr
->
hwndSelf
,
GWL_STYLE
)
&
MCS_MULTISELECT
)
{
MONTHCAL_CopyTime
(
&
infoPtr
->
maxSel
,
&
lprgSysTimeArray
[
1
]);
MONTHCAL_CopyTime
(
&
infoPtr
->
minSel
,
&
lprgSysTimeArray
[
0
]);
...
...
@@ -1116,18 +1090,17 @@ MONTHCAL_GetSelRange(HWND hwnd, WPARAM wParam, LPARAM lParam)
static
LRESULT
MONTHCAL_SetSelRange
(
HWND
hwnd
,
WPARAM
wParam
,
LPARAM
lParam
)
MONTHCAL_SetSelRange
(
MONTHCAL_INFO
*
infoPtr
,
LPARAM
lParam
)
{
MONTHCAL_INFO
*
infoPtr
=
MONTHCAL_GetInfoPtr
(
hwnd
);
SYSTEMTIME
*
lprgSysTimeArray
=
(
SYSTEMTIME
*
)
lParam
;
TRACE
(
"%
x %lx
\n
"
,
wParam
,
lParam
);
TRACE
(
"%
lx
\n
"
,
lParam
);
/* validate parameters */
if
((
infoPtr
==
NULL
)
||
(
lprgSysTimeArray
==
NULL
))
return
FALSE
;
if
(
GetWindowLong
A
(
hwnd
,
GWL_STYLE
)
&
MCS_MULTISELECT
)
if
(
GetWindowLong
W
(
infoPtr
->
hwndSelf
,
GWL_STYLE
)
&
MCS_MULTISELECT
)
{
MONTHCAL_CopyTime
(
&
lprgSysTimeArray
[
1
],
&
infoPtr
->
maxSel
);
MONTHCAL_CopyTime
(
&
lprgSysTimeArray
[
0
],
&
infoPtr
->
minSel
);
...
...
@@ -1140,12 +1113,11 @@ MONTHCAL_SetSelRange(HWND hwnd, WPARAM wParam, LPARAM lParam)
static
LRESULT
MONTHCAL_GetToday
(
HWND
hwnd
,
WPARAM
wParam
,
LPARAM
lParam
)
MONTHCAL_GetToday
(
MONTHCAL_INFO
*
infoPtr
,
LPARAM
lParam
)
{
MONTHCAL_INFO
*
infoPtr
=
MONTHCAL_GetInfoPtr
(
hwnd
);
SYSTEMTIME
*
lpToday
=
(
SYSTEMTIME
*
)
lParam
;
TRACE
(
"%
x %lx
\n
"
,
wParam
,
lParam
);
TRACE
(
"%
lx
\n
"
,
lParam
);
/* validate parameters */
...
...
@@ -1156,26 +1128,24 @@ MONTHCAL_GetToday(HWND hwnd, WPARAM wParam, LPARAM lParam)
static
LRESULT
MONTHCAL_SetToday
(
HWND
hwnd
,
WPARAM
wParam
,
LPARAM
lParam
)
MONTHCAL_SetToday
(
MONTHCAL_INFO
*
infoPtr
,
LPARAM
lParam
)
{
MONTHCAL_INFO
*
infoPtr
=
MONTHCAL_GetInfoPtr
(
hwnd
);
SYSTEMTIME
*
lpToday
=
(
SYSTEMTIME
*
)
lParam
;
TRACE
(
"%
x %lx
\n
"
,
wParam
,
lParam
);
TRACE
(
"%
lx
\n
"
,
lParam
);
/* validate parameters */
if
((
infoPtr
==
NULL
)
||
(
lpToday
==
NULL
))
return
FALSE
;
MONTHCAL_CopyTime
(
lpToday
,
&
infoPtr
->
todaysDate
);
InvalidateRect
(
hwnd
,
NULL
,
FALSE
);
InvalidateRect
(
infoPtr
->
hwndSelf
,
NULL
,
FALSE
);
return
TRUE
;
}
static
LRESULT
MONTHCAL_HitTest
(
HWND
hwnd
,
LPARAM
lParam
)
MONTHCAL_HitTest
(
MONTHCAL_INFO
*
infoPtr
,
LPARAM
lParam
)
{
MONTHCAL_INFO
*
infoPtr
=
MONTHCAL_GetInfoPtr
(
hwnd
);
PMCHITTESTINFO
lpht
=
(
PMCHITTESTINFO
)
lParam
;
UINT
x
,
y
;
DWORD
retval
;
...
...
@@ -1291,9 +1261,9 @@ MONTHCAL_HitTest(HWND hwnd, LPARAM lParam)
}
static
void
MONTHCAL_GoToNextMonth
(
HWND
hwnd
,
MONTHCAL_INFO
*
infoPtr
)
static
void
MONTHCAL_GoToNextMonth
(
MONTHCAL_INFO
*
infoPtr
)
{
DWORD
dwStyle
=
GetWindowLong
A
(
hwnd
,
GWL_STYLE
);
DWORD
dwStyle
=
GetWindowLong
W
(
infoPtr
->
hwndSelf
,
GWL_STYLE
);
TRACE
(
"MONTHCAL_GoToNextMonth
\n
"
);
...
...
@@ -1307,8 +1277,8 @@ static void MONTHCAL_GoToNextMonth(HWND hwnd, MONTHCAL_INFO *infoPtr)
NMDAYSTATE
nmds
;
int
i
;
nmds
.
nmhdr
.
hwndFrom
=
hwnd
;
nmds
.
nmhdr
.
idFrom
=
GetWindowLongPtrW
(
hwnd
,
GWLP_ID
);
nmds
.
nmhdr
.
hwndFrom
=
infoPtr
->
hwndSelf
;
nmds
.
nmhdr
.
idFrom
=
GetWindowLongPtrW
(
infoPtr
->
hwndSelf
,
GWLP_ID
);
nmds
.
nmhdr
.
code
=
MCN_GETDAYSTATE
;
nmds
.
cDayState
=
infoPtr
->
monthRange
;
nmds
.
prgDayState
=
Alloc
(
infoPtr
->
monthRange
*
sizeof
(
MONTHDAYSTATE
));
...
...
@@ -1321,11 +1291,11 @@ static void MONTHCAL_GoToNextMonth(HWND hwnd, MONTHCAL_INFO *infoPtr)
}
static
void
MONTHCAL_GoToPrevMonth
(
HWND
hwnd
,
MONTHCAL_INFO
*
infoPtr
)
static
void
MONTHCAL_GoToPrevMonth
(
MONTHCAL_INFO
*
infoPtr
)
{
DWORD
dwStyle
=
GetWindowLong
A
(
hwnd
,
GWL_STYLE
);
DWORD
dwStyle
=
GetWindowLong
W
(
infoPtr
->
hwndSelf
,
GWL_STYLE
);
TRACE
(
"
MONTHCAL_GoToPrevMonth
\n
"
);
TRACE
(
"
\n
"
);
infoPtr
->
currentMonth
--
;
if
(
infoPtr
->
currentMonth
<
1
)
{
...
...
@@ -1337,8 +1307,8 @@ static void MONTHCAL_GoToPrevMonth(HWND hwnd, MONTHCAL_INFO *infoPtr)
NMDAYSTATE
nmds
;
int
i
;
nmds
.
nmhdr
.
hwndFrom
=
hwnd
;
nmds
.
nmhdr
.
idFrom
=
GetWindowLongPtrW
(
hwnd
,
GWLP_ID
);
nmds
.
nmhdr
.
hwndFrom
=
infoPtr
->
hwndSelf
;
nmds
.
nmhdr
.
idFrom
=
GetWindowLongPtrW
(
infoPtr
->
hwndSelf
,
GWLP_ID
);
nmds
.
nmhdr
.
code
=
MCN_GETDAYSTATE
;
nmds
.
cDayState
=
infoPtr
->
monthRange
;
nmds
.
prgDayState
=
Alloc
...
...
@@ -1352,9 +1322,8 @@ static void MONTHCAL_GoToPrevMonth(HWND hwnd, MONTHCAL_INFO *infoPtr)
}
static
LRESULT
MONTHCAL_RButtonDown
(
HWND
hwnd
,
WPARAM
wParam
,
LPARAM
lParam
)
MONTHCAL_RButtonDown
(
MONTHCAL_INFO
*
infoPtr
,
LPARAM
lParam
)
{
MONTHCAL_INFO
*
infoPtr
=
MONTHCAL_GetInfoPtr
(
hwnd
);
HMENU
hMenu
;
POINT
menupoint
;
char
buf
[
32
];
...
...
@@ -1368,21 +1337,20 @@ MONTHCAL_RButtonDown(HWND hwnd, WPARAM wParam, LPARAM lParam)
AppendMenuA
(
hMenu
,
MF_STRING
|
MF_ENABLED
,
1
,
buf
);
menupoint
.
x
=
(
INT
)
LOWORD
(
lParam
);
menupoint
.
y
=
(
INT
)
HIWORD
(
lParam
);
ClientToScreen
(
hwnd
,
&
menupoint
);
ClientToScreen
(
infoPtr
->
hwndSelf
,
&
menupoint
);
if
(
TrackPopupMenu
(
hMenu
,
TPM_RIGHTBUTTON
|
TPM_NONOTIFY
|
TPM_RETURNCMD
,
menupoint
.
x
,
menupoint
.
y
,
0
,
hwnd
,
NULL
))
menupoint
.
x
,
menupoint
.
y
,
0
,
infoPtr
->
hwndSelf
,
NULL
))
{
infoPtr
->
currentMonth
=
infoPtr
->
todaysDate
.
wMonth
;
infoPtr
->
currentYear
=
infoPtr
->
todaysDate
.
wYear
;
InvalidateRect
(
hwnd
,
NULL
,
FALSE
);
InvalidateRect
(
infoPtr
->
hwndSelf
,
NULL
,
FALSE
);
}
return
0
;
}
static
LRESULT
MONTHCAL_LButtonDown
(
HWND
hwnd
,
WPARAM
wParam
,
LPARAM
lParam
)
MONTHCAL_LButtonDown
(
MONTHCAL_INFO
*
infoPtr
,
LPARAM
lParam
)
{
MONTHCAL_INFO
*
infoPtr
=
MONTHCAL_GetInfoPtr
(
hwnd
);
MCHITTESTINFO
ht
;
DWORD
hit
;
HMENU
hMenu
;
...
...
@@ -1390,7 +1358,8 @@ MONTHCAL_LButtonDown(HWND hwnd, WPARAM wParam, LPARAM lParam)
char
buf
[
32
];
int
i
;
POINT
menupoint
;
TRACE
(
"%x %lx
\n
"
,
wParam
,
lParam
);
TRACE
(
"%lx
\n
"
,
lParam
);
if
(
infoPtr
->
hWndYearUpDown
)
{
...
...
@@ -1407,28 +1376,28 @@ MONTHCAL_LButtonDown(HWND hwnd, WPARAM wParam, LPARAM lParam)
}
else
infoPtr
->
hWndYearEdit
=
0
;
InvalidateRect
(
hwnd
,
NULL
,
FALSE
);
InvalidateRect
(
infoPtr
->
hwndSelf
,
NULL
,
FALSE
);
}
ht
.
pt
.
x
=
(
INT
)
LOWORD
(
lParam
);
ht
.
pt
.
y
=
(
INT
)
HIWORD
(
lParam
);
hit
=
MONTHCAL_HitTest
(
hwnd
,
(
LPARAM
)
&
ht
);
hit
=
MONTHCAL_HitTest
(
infoPtr
,
(
LPARAM
)
&
ht
);
/* FIXME: these flags should be checked by */
/*((hit & MCHT_XXX) == MCHT_XXX) b/c some of the flags are */
/* multi-bit */
if
(
hit
==
MCHT_TITLEBTNNEXT
)
{
MONTHCAL_GoToNextMonth
(
hwnd
,
infoPtr
);
MONTHCAL_GoToNextMonth
(
infoPtr
);
infoPtr
->
status
=
MC_NEXTPRESSED
;
SetTimer
(
hwnd
,
MC_NEXTMONTHTIMER
,
MC_NEXTMONTHDELAY
,
0
);
InvalidateRect
(
hwnd
,
NULL
,
FALSE
);
SetTimer
(
infoPtr
->
hwndSelf
,
MC_NEXTMONTHTIMER
,
MC_NEXTMONTHDELAY
,
0
);
InvalidateRect
(
infoPtr
->
hwndSelf
,
NULL
,
FALSE
);
return
TRUE
;
}
if
(
hit
==
MCHT_TITLEBTNPREV
){
MONTHCAL_GoToPrevMonth
(
hwnd
,
infoPtr
);
MONTHCAL_GoToPrevMonth
(
infoPtr
);
infoPtr
->
status
=
MC_PREVPRESSED
;
SetTimer
(
hwnd
,
MC_PREVMONTHTIMER
,
MC_NEXTMONTHDELAY
,
0
);
InvalidateRect
(
hwnd
,
NULL
,
FALSE
);
SetTimer
(
infoPtr
->
hwndSelf
,
MC_PREVMONTHTIMER
,
MC_NEXTMONTHDELAY
,
0
);
InvalidateRect
(
infoPtr
->
hwndSelf
,
NULL
,
FALSE
);
return
TRUE
;
}
...
...
@@ -1443,13 +1412,13 @@ MONTHCAL_LButtonDown(HWND hwnd, WPARAM wParam, LPARAM lParam)
}
menupoint
.
x
=
infoPtr
->
titlemonth
.
right
;
menupoint
.
y
=
infoPtr
->
titlemonth
.
bottom
;
ClientToScreen
(
hwnd
,
&
menupoint
);
ClientToScreen
(
infoPtr
->
hwndSelf
,
&
menupoint
);
i
=
TrackPopupMenu
(
hMenu
,
TPM_LEFTALIGN
|
TPM_NONOTIFY
|
TPM_RIGHTBUTTON
|
TPM_RETURNCMD
,
menupoint
.
x
,
menupoint
.
y
,
0
,
hwnd
,
NULL
);
menupoint
.
x
,
menupoint
.
y
,
0
,
infoPtr
->
hwndSelf
,
NULL
);
if
((
i
>
0
)
&&
(
i
<
13
))
{
infoPtr
->
currentMonth
=
i
;
InvalidateRect
(
hwnd
,
NULL
,
FALSE
);
InvalidateRect
(
infoPtr
->
hwndSelf
,
NULL
,
FALSE
);
}
}
if
(
hit
==
MCHT_TITLEYEAR
)
{
...
...
@@ -1460,7 +1429,7 @@ MONTHCAL_LButtonDown(HWND hwnd, WPARAM wParam, LPARAM lParam)
infoPtr
->
titleyear
.
left
+
3
,
infoPtr
->
titlebtnnext
.
top
,
infoPtr
->
titleyear
.
right
-
infoPtr
->
titleyear
.
left
,
infoPtr
->
textHeight
,
hwnd
,
infoPtr
->
hwndSelf
,
NULL
,
NULL
,
NULL
);
...
...
@@ -1471,7 +1440,7 @@ MONTHCAL_LButtonDown(HWND hwnd, WPARAM wParam, LPARAM lParam)
infoPtr
->
titleyear
.
right
+
6
,
infoPtr
->
titlebtnnext
.
top
,
20
,
infoPtr
->
textHeight
,
hwnd
,
infoPtr
->
hwndSelf
,
NULL
,
NULL
,
NULL
);
...
...
@@ -1484,7 +1453,7 @@ MONTHCAL_LButtonDown(HWND hwnd, WPARAM wParam, LPARAM lParam)
if
(
hit
==
MCHT_TODAYLINK
)
{
infoPtr
->
currentMonth
=
infoPtr
->
todaysDate
.
wMonth
;
infoPtr
->
currentYear
=
infoPtr
->
todaysDate
.
wYear
;
InvalidateRect
(
hwnd
,
NULL
,
FALSE
);
InvalidateRect
(
infoPtr
->
hwndSelf
,
NULL
,
FALSE
);
return
TRUE
;
}
if
(
hit
==
MCHT_CALENDARDATE
)
{
...
...
@@ -1493,11 +1462,11 @@ MONTHCAL_LButtonDown(HWND hwnd, WPARAM wParam, LPARAM lParam)
MONTHCAL_CopyTime
(
&
ht
.
st
,
&
selArray
[
0
]);
MONTHCAL_CopyTime
(
&
ht
.
st
,
&
selArray
[
1
]);
MONTHCAL_SetSelRange
(
hwnd
,
0
,(
LPARAM
)
&
selArray
);
MONTHCAL_SetCurSel
(
hwnd
,
0
,(
LPARAM
)
&
selArray
);
MONTHCAL_SetSelRange
(
infoPtr
,
(
LPARAM
)
&
selArray
);
MONTHCAL_SetCurSel
(
infoPtr
,
(
LPARAM
)
&
selArray
);
TRACE
(
"MCHT_CALENDARDATE
\n
"
);
nmsc
.
nmhdr
.
hwndFrom
=
hwnd
;
nmsc
.
nmhdr
.
idFrom
=
GetWindowLongPtrW
(
hwnd
,
GWLP_ID
);
nmsc
.
nmhdr
.
hwndFrom
=
infoPtr
->
hwndSelf
;
nmsc
.
nmhdr
.
idFrom
=
GetWindowLongPtrW
(
infoPtr
->
hwndSelf
,
GWLP_ID
);
nmsc
.
nmhdr
.
code
=
MCN_SELCHANGE
;
MONTHCAL_CopyTime
(
&
infoPtr
->
minSel
,
&
nmsc
.
stSelStart
);
MONTHCAL_CopyTime
(
&
infoPtr
->
maxSel
,
&
nmsc
.
stSelEnd
);
...
...
@@ -1509,10 +1478,10 @@ MONTHCAL_LButtonDown(HWND hwnd, WPARAM wParam, LPARAM lParam)
/* redraw both old and new days if the selected day changed */
if
(
infoPtr
->
curSelDay
!=
ht
.
st
.
wDay
)
{
MONTHCAL_CalcPosFromDay
(
infoPtr
,
ht
.
st
.
wDay
,
ht
.
st
.
wMonth
,
&
rcDay
);
InvalidateRect
(
hwnd
,
&
rcDay
,
TRUE
);
InvalidateRect
(
infoPtr
->
hwndSelf
,
&
rcDay
,
TRUE
);
MONTHCAL_CalcPosFromDay
(
infoPtr
,
infoPtr
->
curSelDay
,
infoPtr
->
currentMonth
,
&
rcDay
);
InvalidateRect
(
hwnd
,
&
rcDay
,
TRUE
);
InvalidateRect
(
infoPtr
->
hwndSelf
,
&
rcDay
,
TRUE
);
}
infoPtr
->
firstSelDay
=
ht
.
st
.
wDay
;
...
...
@@ -1526,9 +1495,8 @@ MONTHCAL_LButtonDown(HWND hwnd, WPARAM wParam, LPARAM lParam)
static
LRESULT
MONTHCAL_LButtonUp
(
HWND
hwnd
,
WPARAM
wParam
,
LPARAM
lParam
)
MONTHCAL_LButtonUp
(
MONTHCAL_INFO
*
infoPtr
,
LPARAM
lParam
)
{
MONTHCAL_INFO
*
infoPtr
=
MONTHCAL_GetInfoPtr
(
hwnd
);
NMSELCHANGE
nmsc
;
NMHDR
nmhdr
;
BOOL
redraw
=
FALSE
;
...
...
@@ -1538,46 +1506,46 @@ MONTHCAL_LButtonUp(HWND hwnd, WPARAM wParam, LPARAM lParam)
TRACE
(
"
\n
"
);
if
(
infoPtr
->
status
&
MC_NEXTPRESSED
)
{
KillTimer
(
hwnd
,
MC_NEXTMONTHTIMER
);
KillTimer
(
infoPtr
->
hwndSelf
,
MC_NEXTMONTHTIMER
);
infoPtr
->
status
&=
~
MC_NEXTPRESSED
;
redraw
=
TRUE
;
}
if
(
infoPtr
->
status
&
MC_PREVPRESSED
)
{
KillTimer
(
hwnd
,
MC_PREVMONTHTIMER
);
KillTimer
(
infoPtr
->
hwndSelf
,
MC_PREVMONTHTIMER
);
infoPtr
->
status
&=
~
MC_PREVPRESSED
;
redraw
=
TRUE
;
}
ht
.
pt
.
x
=
(
INT
)
LOWORD
(
lParam
);
ht
.
pt
.
y
=
(
INT
)
HIWORD
(
lParam
);
hit
=
MONTHCAL_HitTest
(
hwnd
,
(
LPARAM
)
&
ht
);
hit
=
MONTHCAL_HitTest
(
infoPtr
,
(
LPARAM
)
&
ht
);
infoPtr
->
status
=
MC_SEL_LBUTUP
;
if
(
hit
==
MCHT_CALENDARDATENEXT
)
{
MONTHCAL_GoToNextMonth
(
hwnd
,
infoPtr
);
InvalidateRect
(
hwnd
,
NULL
,
FALSE
);
MONTHCAL_GoToNextMonth
(
infoPtr
);
InvalidateRect
(
infoPtr
->
hwndSelf
,
NULL
,
FALSE
);
return
TRUE
;
}
if
(
hit
==
MCHT_CALENDARDATEPREV
){
MONTHCAL_GoToPrevMonth
(
hwnd
,
infoPtr
);
InvalidateRect
(
hwnd
,
NULL
,
FALSE
);
MONTHCAL_GoToPrevMonth
(
infoPtr
);
InvalidateRect
(
infoPtr
->
hwndSelf
,
NULL
,
FALSE
);
return
TRUE
;
}
nmhdr
.
hwndFrom
=
hwnd
;
nmhdr
.
idFrom
=
GetWindowLongPtrW
(
hwnd
,
GWLP_ID
);
nmhdr
.
hwndFrom
=
infoPtr
->
hwndSelf
;
nmhdr
.
idFrom
=
GetWindowLongPtrW
(
infoPtr
->
hwndSelf
,
GWLP_ID
);
nmhdr
.
code
=
NM_RELEASEDCAPTURE
;
TRACE
(
"Sent notification from %p to %p
\n
"
,
hwnd
,
infoPtr
->
hwndNotify
);
TRACE
(
"Sent notification from %p to %p
\n
"
,
infoPtr
->
hwndSelf
,
infoPtr
->
hwndNotify
);
SendMessageA
(
infoPtr
->
hwndNotify
,
WM_NOTIFY
,
(
WPARAM
)
nmhdr
.
idFrom
,
(
LPARAM
)
&
nmhdr
);
/* redraw if necessary */
if
(
redraw
)
InvalidateRect
(
hwnd
,
NULL
,
FALSE
);
InvalidateRect
(
infoPtr
->
hwndSelf
,
NULL
,
FALSE
);
/* only send MCN_SELECT if currently displayed month's day was selected */
if
(
hit
==
MCHT_CALENDARDATE
)
{
nmsc
.
nmhdr
.
hwndFrom
=
hwnd
;
nmsc
.
nmhdr
.
idFrom
=
GetWindowLongPtrW
(
hwnd
,
GWLP_ID
);
nmsc
.
nmhdr
.
hwndFrom
=
infoPtr
->
hwndSelf
;
nmsc
.
nmhdr
.
idFrom
=
GetWindowLongPtrW
(
infoPtr
->
hwndSelf
,
GWLP_ID
);
nmsc
.
nmhdr
.
code
=
MCN_SELECT
;
MONTHCAL_CopyTime
(
&
infoPtr
->
minSel
,
&
nmsc
.
stSelStart
);
MONTHCAL_CopyTime
(
&
infoPtr
->
maxSel
,
&
nmsc
.
stSelEnd
);
...
...
@@ -1591,39 +1559,37 @@ MONTHCAL_LButtonUp(HWND hwnd, WPARAM wParam, LPARAM lParam)
static
LRESULT
MONTHCAL_Timer
(
HWND
hwnd
,
WPARAM
wParam
,
LPARAM
l
Param
)
MONTHCAL_Timer
(
MONTHCAL_INFO
*
infoPtr
,
WPARAM
w
Param
)
{
MONTHCAL_INFO
*
infoPtr
=
MONTHCAL_GetInfoPtr
(
hwnd
);
BOOL
redraw
=
FALSE
;
TRACE
(
" %d
\n
"
,
wParam
);
if
(
!
infoPtr
)
return
0
;
TRACE
(
"%d
\n
"
,
wParam
);
switch
(
wParam
)
{
case
MC_NEXTMONTHTIMER
:
redraw
=
TRUE
;
MONTHCAL_GoToNextMonth
(
hwnd
,
infoPtr
);
MONTHCAL_GoToNextMonth
(
infoPtr
);
break
;
case
MC_PREVMONTHTIMER
:
redraw
=
TRUE
;
MONTHCAL_GoToPrevMonth
(
hwnd
,
infoPtr
);
MONTHCAL_GoToPrevMonth
(
infoPtr
);
break
;
default:
ERR
(
"got unknown timer
\n
"
);
break
;
}
/* redraw only if necessary */
if
(
redraw
)
InvalidateRect
(
hwnd
,
NULL
,
FALSE
);
InvalidateRect
(
infoPtr
->
hwndSelf
,
NULL
,
FALSE
);
return
0
;
}
static
LRESULT
MONTHCAL_MouseMove
(
HWND
hwnd
,
WPARAM
wParam
,
LPARAM
lParam
)
MONTHCAL_MouseMove
(
MONTHCAL_INFO
*
infoPtr
,
WPARAM
wParam
,
LPARAM
lParam
)
{
MONTHCAL_INFO
*
infoPtr
=
MONTHCAL_GetInfoPtr
(
hwnd
);
MCHITTESTINFO
ht
;
int
oldselday
,
selday
,
hit
;
RECT
r
;
...
...
@@ -1633,7 +1599,7 @@ MONTHCAL_MouseMove(HWND hwnd, WPARAM wParam, LPARAM lParam)
ht
.
pt
.
x
=
LOWORD
(
lParam
);
ht
.
pt
.
y
=
HIWORD
(
lParam
);
hit
=
MONTHCAL_HitTest
(
hwnd
,
(
LPARAM
)
&
ht
);
hit
=
MONTHCAL_HitTest
(
infoPtr
,
(
LPARAM
)
&
ht
);
/* not on the calendar date numbers? bail out */
TRACE
(
"hit:%x
\n
"
,
hit
);
...
...
@@ -1644,11 +1610,11 @@ MONTHCAL_MouseMove(HWND hwnd, WPARAM wParam, LPARAM lParam)
infoPtr
->
curSelDay
=
selday
;
MONTHCAL_CalcPosFromDay
(
infoPtr
,
selday
,
ht
.
st
.
wMonth
,
&
r
);
if
(
GetWindowLong
A
(
hwnd
,
GWL_STYLE
)
&
MCS_MULTISELECT
)
{
if
(
GetWindowLong
W
(
infoPtr
->
hwndSelf
,
GWL_STYLE
)
&
MCS_MULTISELECT
)
{
SYSTEMTIME
selArray
[
2
];
int
i
;
MONTHCAL_GetSelRange
(
hwnd
,
0
,
(
LPARAM
)
&
selArray
);
MONTHCAL_GetSelRange
(
infoPtr
,
(
LPARAM
)
&
selArray
);
i
=
0
;
if
(
infoPtr
->
firstSelDay
==
selArray
[
0
].
wDay
)
i
=
1
;
TRACE
(
"oldRange:%d %d %d %d
\n
"
,
infoPtr
->
firstSelDay
,
selArray
[
0
].
wDay
,
selArray
[
1
].
wDay
,
i
);
...
...
@@ -1678,7 +1644,7 @@ MONTHCAL_MouseMove(HWND hwnd, WPARAM wParam, LPARAM lParam)
selArray
[
0
].
wDay
=
tempday
;
}
MONTHCAL_SetSelRange
(
hwnd
,
0
,
(
LPARAM
)
&
selArray
);
MONTHCAL_SetSelRange
(
infoPtr
,
(
LPARAM
)
&
selArray
);
}
}
...
...
@@ -1688,58 +1654,57 @@ done:
/* FIXME: this should specify a rectangle containing only the days that changed */
/* using InvalidateRect */
if
(
oldselday
!=
infoPtr
->
curSelDay
)
InvalidateRect
(
hwnd
,
NULL
,
FALSE
);
InvalidateRect
(
infoPtr
->
hwndSelf
,
NULL
,
FALSE
);
return
0
;
}
static
LRESULT
MONTHCAL_Paint
(
HWND
hwnd
,
WPARAM
wParam
)
MONTHCAL_Paint
(
MONTHCAL_INFO
*
infoPtr
,
WPARAM
wParam
)
{
HDC
hdc
;
PAINTSTRUCT
ps
;
if
(
wParam
)
{
GetClientRect
(
hwnd
,
&
ps
.
rcPaint
);
GetClientRect
(
infoPtr
->
hwndSelf
,
&
ps
.
rcPaint
);
hdc
=
(
HDC
)
wParam
;
}
else
hdc
=
BeginPaint
(
hwnd
,
&
ps
);
hdc
=
BeginPaint
(
infoPtr
->
hwndSelf
,
&
ps
);
MONTHCAL_Refresh
(
hwnd
,
hdc
,
&
ps
);
if
(
!
wParam
)
EndPaint
(
hwnd
,
&
ps
);
MONTHCAL_Refresh
(
infoPtr
,
hdc
,
&
ps
);
if
(
!
wParam
)
EndPaint
(
infoPtr
->
hwndSelf
,
&
ps
);
return
0
;
}
static
LRESULT
MONTHCAL_KillFocus
(
HWND
hwnd
,
WPARAM
wParam
,
LPARAM
lParam
)
MONTHCAL_KillFocus
(
MONTHCAL_INFO
*
infoPtr
)
{
TRACE
(
"
\n
"
);
InvalidateRect
(
hwnd
,
NULL
,
TRUE
);
InvalidateRect
(
infoPtr
->
hwndSelf
,
NULL
,
TRUE
);
return
0
;
}
static
LRESULT
MONTHCAL_SetFocus
(
HWND
hwnd
,
WPARAM
wParam
,
LPARAM
lParam
)
MONTHCAL_SetFocus
(
MONTHCAL_INFO
*
infoPtr
)
{
TRACE
(
"
\n
"
);
InvalidateRect
(
hwnd
,
NULL
,
FALSE
);
InvalidateRect
(
infoPtr
->
hwndSelf
,
NULL
,
FALSE
);
return
0
;
}
/* sets the size information */
static
void
MONTHCAL_UpdateSize
(
HWND
hwnd
)
static
void
MONTHCAL_UpdateSize
(
MONTHCAL_INFO
*
infoPtr
)
{
HDC
hdc
=
GetDC
(
hwnd
);
MONTHCAL_INFO
*
infoPtr
=
MONTHCAL_GetInfoPtr
(
hwnd
);
HDC
hdc
=
GetDC
(
infoPtr
->
hwndSelf
);
RECT
*
title
=&
infoPtr
->
title
;
RECT
*
prev
=&
infoPtr
->
titlebtnprev
;
RECT
*
next
=&
infoPtr
->
titlebtnnext
;
...
...
@@ -1751,12 +1716,12 @@ static void MONTHCAL_UpdateSize(HWND hwnd)
RECT
*
todayrect
=&
infoPtr
->
todayrect
;
SIZE
size
;
TEXTMETRICA
tm
;
DWORD
dwStyle
=
GetWindowLong
A
(
hwnd
,
GWL_STYLE
);
DWORD
dwStyle
=
GetWindowLong
W
(
infoPtr
->
hwndSelf
,
GWL_STYLE
);
HFONT
currentFont
;
int
xdiv
,
left_offset
;
RECT
rcClient
;
GetClientRect
(
hwnd
,
&
rcClient
);
GetClientRect
(
infoPtr
->
hwndSelf
,
&
rcClient
);
currentFont
=
SelectObject
(
hdc
,
infoPtr
->
hFont
);
...
...
@@ -1827,27 +1792,51 @@ static void MONTHCAL_UpdateSize(HWND hwnd)
/* restore the originally selected font */
SelectObject
(
hdc
,
currentFont
);
ReleaseDC
(
hwnd
,
hdc
);
ReleaseDC
(
infoPtr
->
hwndSelf
,
hdc
);
}
static
LRESULT
MONTHCAL_Size
(
HWND
hwnd
,
int
Width
,
int
Height
)
static
LRESULT
MONTHCAL_Size
(
MONTHCAL_INFO
*
infoPtr
,
int
Width
,
int
Height
)
{
TRACE
(
"(
hwnd=%p, width=%d, height=%d)
\n
"
,
hwnd
,
Width
,
Height
);
TRACE
(
"(
width=%d, height=%d)
\n
"
,
Width
,
Height
);
MONTHCAL_UpdateSize
(
hwnd
);
MONTHCAL_UpdateSize
(
infoPtr
);
/* invalidate client area and erase background */
InvalidateRect
(
hwnd
,
NULL
,
TRUE
);
InvalidateRect
(
infoPtr
->
hwndSelf
,
NULL
,
TRUE
);
return
0
;
}
static
LRESULT
MONTHCAL_GetFont
(
MONTHCAL_INFO
*
infoPtr
)
{
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
;
}
/* FIXME: check whether dateMin/dateMax need to be adjusted. */
static
LRESULT
MONTHCAL_Create
(
HWND
hwnd
,
WPARAM
wParam
,
LPARAM
lParam
)
{
MONTHCAL_INFO
*
infoPtr
;
LOGFONTA
logFont
;
/* allocate memory for info structure */
infoPtr
=
(
MONTHCAL_INFO
*
)
Alloc
(
sizeof
(
MONTHCAL_INFO
));
...
...
@@ -1861,16 +1850,13 @@ MONTHCAL_Create(HWND hwnd, WPARAM wParam, LPARAM lParam)
infoPtr
->
hwndSelf
=
hwnd
;
infoPtr
->
hwndNotify
=
((
LPCREATESTRUCTW
)
lParam
)
->
hwndParent
;
infoPtr
->
hFont
=
GetStockObject
(
DEFAULT_GUI_FONT
);
GetObjectA
(
infoPtr
->
hFont
,
sizeof
(
LOGFONTA
),
&
logFont
);
logFont
.
lfWeight
=
FW_BOLD
;
infoPtr
->
hBoldFont
=
CreateFontIndirectA
(
&
logFont
);
MONTHCAL_SetFont
(
infoPtr
,
GetStockObject
(
DEFAULT_GUI_FONT
),
FALSE
);
/* initialize info structure */
/* FIXME: calculate systemtime ->> localtime(substract timezoneinfo) */
GetSystemTime
(
&
infoPtr
->
todaysDate
);
MONTHCAL_SetFirstDayOfWeek
(
hwnd
,
0
,
(
LPARAM
)
-
1
);
MONTHCAL_SetFirstDayOfWeek
(
infoPtr
,
(
LPARAM
)
-
1
);
infoPtr
->
currentMonth
=
infoPtr
->
todaysDate
.
wMonth
;
infoPtr
->
currentYear
=
infoPtr
->
todaysDate
.
wYear
;
MONTHCAL_CopyTime
(
&
infoPtr
->
todaysDate
,
&
infoPtr
->
minDate
);
...
...
@@ -1890,22 +1876,20 @@ MONTHCAL_Create(HWND hwnd, WPARAM wParam, LPARAM lParam)
/* call MONTHCAL_UpdateSize to set all of the dimensions */
/* of the control */
MONTHCAL_UpdateSize
(
hwnd
);
MONTHCAL_UpdateSize
(
infoPtr
);
return
0
;
}
static
LRESULT
MONTHCAL_Destroy
(
HWND
hwnd
,
WPARAM
wParam
,
LPARAM
lParam
)
MONTHCAL_Destroy
(
MONTHCAL_INFO
*
infoPtr
)
{
MONTHCAL_INFO
*
infoPtr
=
MONTHCAL_GetInfoPtr
(
hwnd
);
/* free month calendar info data */
if
(
infoPtr
->
monthdayState
)
Free
(
infoPtr
->
monthdayState
);
SetWindowLongPtrW
(
infoPtr
->
hwndSelf
,
0
,
0
);
Free
(
infoPtr
);
SetWindowLongPtrW
(
hwnd
,
0
,
0
);
return
0
;
}
...
...
@@ -1913,109 +1897,119 @@ MONTHCAL_Destroy(HWND hwnd, WPARAM wParam, LPARAM lParam)
static
LRESULT
WINAPI
MONTHCAL_WindowProc
(
HWND
hwnd
,
UINT
uMsg
,
WPARAM
wParam
,
LPARAM
lParam
)
{
MONTHCAL_INFO
*
infoPtr
;
TRACE
(
"hwnd=%p msg=%x wparam=%x lparam=%lx
\n
"
,
hwnd
,
uMsg
,
wParam
,
lParam
);
if
(
!
MONTHCAL_GetInfoPtr
(
hwnd
)
&&
(
uMsg
!=
WM_CREATE
))
infoPtr
=
MONTHCAL_GetInfoPtr
(
hwnd
);
if
(
!
infoPtr
&&
(
uMsg
!=
WM_CREATE
))
return
DefWindowProcA
(
hwnd
,
uMsg
,
wParam
,
lParam
);
switch
(
uMsg
)
{
case
MCM_GETCURSEL
:
return
MONTHCAL_GetCurSel
(
hwnd
,
wParam
,
lParam
);
return
MONTHCAL_GetCurSel
(
infoPtr
,
lParam
);
case
MCM_SETCURSEL
:
return
MONTHCAL_SetCurSel
(
hwnd
,
wParam
,
lParam
);
return
MONTHCAL_SetCurSel
(
infoPtr
,
lParam
);
case
MCM_GETMAXSELCOUNT
:
return
MONTHCAL_GetMaxSelCount
(
hwnd
,
wParam
,
lParam
);
return
MONTHCAL_GetMaxSelCount
(
infoPtr
);
case
MCM_SETMAXSELCOUNT
:
return
MONTHCAL_SetMaxSelCount
(
hwnd
,
wParam
,
l
Param
);
return
MONTHCAL_SetMaxSelCount
(
infoPtr
,
w
Param
);
case
MCM_GETSELRANGE
:
return
MONTHCAL_GetSelRange
(
hwnd
,
wParam
,
lParam
);
return
MONTHCAL_GetSelRange
(
infoPtr
,
lParam
);
case
MCM_SETSELRANGE
:
return
MONTHCAL_SetSelRange
(
hwnd
,
wParam
,
lParam
);
return
MONTHCAL_SetSelRange
(
infoPtr
,
lParam
);
case
MCM_GETMONTHRANGE
:
return
MONTHCAL_GetMonthRange
(
hwnd
,
wParam
,
lParam
);
return
MONTHCAL_GetMonthRange
(
infoPtr
);
case
MCM_SETDAYSTATE
:
return
MONTHCAL_SetDayState
(
hwnd
,
wParam
,
lParam
);
return
MONTHCAL_SetDayState
(
infoPtr
,
wParam
,
lParam
);
case
MCM_GETMINREQRECT
:
return
MONTHCAL_GetMinReqRect
(
hwnd
,
wParam
,
lParam
);
return
MONTHCAL_GetMinReqRect
(
infoPtr
,
lParam
);
case
MCM_GETCOLOR
:
return
MONTHCAL_GetColor
(
hwnd
,
wParam
,
l
Param
);
return
MONTHCAL_GetColor
(
infoPtr
,
w
Param
);
case
MCM_SETCOLOR
:
return
MONTHCAL_SetColor
(
hwnd
,
wParam
,
lParam
);
return
MONTHCAL_SetColor
(
infoPtr
,
wParam
,
lParam
);
case
MCM_GETTODAY
:
return
MONTHCAL_GetToday
(
hwnd
,
wParam
,
lParam
);
return
MONTHCAL_GetToday
(
infoPtr
,
lParam
);
case
MCM_SETTODAY
:
return
MONTHCAL_SetToday
(
hwnd
,
wParam
,
lParam
);
return
MONTHCAL_SetToday
(
infoPtr
,
lParam
);
case
MCM_HITTEST
:
return
MONTHCAL_HitTest
(
hwnd
,
lParam
);
return
MONTHCAL_HitTest
(
infoPtr
,
lParam
);
case
MCM_GETFIRSTDAYOFWEEK
:
return
MONTHCAL_GetFirstDayOfWeek
(
hwnd
,
wParam
,
lParam
);
return
MONTHCAL_GetFirstDayOfWeek
(
infoPtr
);
case
MCM_SETFIRSTDAYOFWEEK
:
return
MONTHCAL_SetFirstDayOfWeek
(
hwnd
,
wParam
,
lParam
);
return
MONTHCAL_SetFirstDayOfWeek
(
infoPtr
,
lParam
);
case
MCM_GETRANGE
:
return
MONTHCAL_GetRange
(
hwnd
,
wParam
,
lParam
);
case
MCM_SETRANGE
:
return
MONTHCAL_SetRange
(
hwnd
,
wParam
,
lParam
);
return
MONTHCAL_SetRange
(
infoPtr
,
wParam
,
lParam
);
case
MCM_GETMONTHDELTA
:
return
MONTHCAL_GetMonthDelta
(
hwnd
,
wParam
,
lParam
);
return
MONTHCAL_GetMonthDelta
(
infoPtr
);
case
MCM_SETMONTHDELTA
:
return
MONTHCAL_SetMonthDelta
(
hwnd
,
wParam
,
l
Param
);
return
MONTHCAL_SetMonthDelta
(
infoPtr
,
w
Param
);
case
MCM_GETMAXTODAYWIDTH
:
return
MONTHCAL_GetMaxTodayWidth
(
hwnd
);
return
MONTHCAL_GetMaxTodayWidth
(
infoPtr
);
case
WM_GETDLGCODE
:
return
DLGC_WANTARROWS
|
DLGC_WANTCHARS
;
case
WM_KILLFOCUS
:
return
MONTHCAL_KillFocus
(
hwnd
,
wParam
,
lParam
);
return
MONTHCAL_KillFocus
(
infoPtr
);
case
WM_RBUTTONDOWN
:
return
MONTHCAL_RButtonDown
(
hwnd
,
wParam
,
lParam
);
return
MONTHCAL_RButtonDown
(
infoPtr
,
lParam
);
case
WM_LBUTTONDOWN
:
return
MONTHCAL_LButtonDown
(
hwnd
,
wParam
,
lParam
);
return
MONTHCAL_LButtonDown
(
infoPtr
,
lParam
);
case
WM_MOUSEMOVE
:
return
MONTHCAL_MouseMove
(
hwnd
,
wParam
,
lParam
);
return
MONTHCAL_MouseMove
(
infoPtr
,
wParam
,
lParam
);
case
WM_LBUTTONUP
:
return
MONTHCAL_LButtonUp
(
hwnd
,
wParam
,
lParam
);
return
MONTHCAL_LButtonUp
(
infoPtr
,
lParam
);
case
WM_PAINT
:
return
MONTHCAL_Paint
(
hwnd
,
wParam
);
return
MONTHCAL_Paint
(
infoPtr
,
wParam
);
case
WM_SETFOCUS
:
return
MONTHCAL_SetFocus
(
hwnd
,
wParam
,
lParam
);
return
MONTHCAL_SetFocus
(
infoPtr
);
case
WM_SIZE
:
return
MONTHCAL_Size
(
hwnd
,
(
SHORT
)
LOWORD
(
lParam
),
(
SHORT
)
HIWORD
(
lParam
));
return
MONTHCAL_Size
(
infoPtr
,
(
SHORT
)
LOWORD
(
lParam
),
(
SHORT
)
HIWORD
(
lParam
));
case
WM_CREATE
:
return
MONTHCAL_Create
(
hwnd
,
wParam
,
lParam
);
case
WM_SETFONT
:
return
MONTHCAL_SetFont
(
infoPtr
,
(
HFONT
)
wParam
,
(
BOOL
)
lParam
);
case
WM_GETFONT
:
return
MONTHCAL_GetFont
(
infoPtr
);
case
WM_TIMER
:
return
MONTHCAL_Timer
(
hwnd
,
wParam
,
l
Param
);
return
MONTHCAL_Timer
(
infoPtr
,
w
Param
);
case
WM_DESTROY
:
return
MONTHCAL_Destroy
(
hwnd
,
wParam
,
lParam
);
return
MONTHCAL_Destroy
(
infoPtr
);
default:
if
((
uMsg
>=
WM_USER
)
&&
(
uMsg
<
WM_APP
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment