Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
52992a99
Commit
52992a99
authored
Mar 04, 2021
by
Zhiyi Zhang
Committed by
Alexandre Julliard
Mar 04, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
comctl32/datetime: Implement themed painting.
Signed-off-by:
Zhiyi Zhang
<
zzhang@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
e392e0ac
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
136 additions
and
1 deletion
+136
-1
datetime.c
dlls/comctl32/datetime.c
+136
-1
No files found.
dlls/comctl32/datetime.c
View file @
52992a99
...
@@ -43,6 +43,8 @@
...
@@ -43,6 +43,8 @@
#include "winnls.h"
#include "winnls.h"
#include "commctrl.h"
#include "commctrl.h"
#include "comctl32.h"
#include "comctl32.h"
#include "uxtheme.h"
#include "vsstyle.h"
#include "wine/debug.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL
(
datetime
);
WINE_DEFAULT_DEBUG_CHANNEL
(
datetime
);
...
@@ -62,6 +64,7 @@ typedef struct
...
@@ -62,6 +64,7 @@ typedef struct
RECT
checkbox
;
/* checkbox allowing the control to be enabled/disabled */
RECT
checkbox
;
/* checkbox allowing the control to be enabled/disabled */
RECT
calbutton
;
/* button that toggles the dropdown of the monthcal control */
RECT
calbutton
;
/* button that toggles the dropdown of the monthcal control */
BOOL
bCalDepressed
;
/* TRUE = cal button is depressed */
BOOL
bCalDepressed
;
/* TRUE = cal button is depressed */
BOOL
bCalHot
;
/* TRUE if calendar button is hovered */
BOOL
bDropdownEnabled
;
BOOL
bDropdownEnabled
;
int
select
;
int
select
;
WCHAR
charsEntered
[
4
];
WCHAR
charsEntered
[
4
];
...
@@ -128,6 +131,7 @@ static BOOL DATETIME_SendSimpleNotify (const DATETIME_INFO *infoPtr, UINT code);
...
@@ -128,6 +131,7 @@ static BOOL DATETIME_SendSimpleNotify (const DATETIME_INFO *infoPtr, UINT code);
static
BOOL
DATETIME_SendDateTimeChangeNotify
(
const
DATETIME_INFO
*
infoPtr
);
static
BOOL
DATETIME_SendDateTimeChangeNotify
(
const
DATETIME_INFO
*
infoPtr
);
static
const
WCHAR
allowedformatchars
[]
=
L"dhHmMstyX"
;
static
const
WCHAR
allowedformatchars
[]
=
L"dhHmMstyX"
;
static
const
int
maxrepetition
[]
=
{
4
,
2
,
2
,
2
,
4
,
2
,
2
,
4
,
-
1
};
static
const
int
maxrepetition
[]
=
{
4
,
2
,
2
,
2
,
4
,
2
,
2
,
4
,
-
1
};
static
const
WCHAR
*
themeClass
=
WC_SCROLLBARW
;
/* valid date limits */
/* valid date limits */
static
const
SYSTEMTIME
max_allowed_date
=
{
.
wYear
=
9999
,
.
wMonth
=
12
,
.
wDayOfWeek
=
0
,
.
wDay
=
31
};
static
const
SYSTEMTIME
max_allowed_date
=
{
.
wYear
=
9999
,
.
wMonth
=
12
,
.
wDayOfWeek
=
0
,
.
wDay
=
31
};
...
@@ -708,6 +712,9 @@ static int DATETIME_GetFieldWidth (const DATETIME_INFO *infoPtr, HDC hdc, int co
...
@@ -708,6 +712,9 @@ static int DATETIME_GetFieldWidth (const DATETIME_INFO *infoPtr, HDC hdc, int co
static
void
static
void
DATETIME_Refresh
(
DATETIME_INFO
*
infoPtr
,
HDC
hdc
)
DATETIME_Refresh
(
DATETIME_INFO
*
infoPtr
,
HDC
hdc
)
{
{
HTHEME
theme
;
int
state
;
TRACE
(
"
\n
"
);
TRACE
(
"
\n
"
);
if
(
infoPtr
->
dateValid
)
{
if
(
infoPtr
->
dateValid
)
{
...
@@ -771,7 +778,27 @@ DATETIME_Refresh (DATETIME_INFO *infoPtr, HDC hdc)
...
@@ -771,7 +778,27 @@ DATETIME_Refresh (DATETIME_INFO *infoPtr, HDC hdc)
SelectObject
(
hdc
,
oldFont
);
SelectObject
(
hdc
,
oldFont
);
}
}
if
(
!
(
infoPtr
->
dwStyle
&
DTS_UPDOWN
))
{
if
(
infoPtr
->
dwStyle
&
DTS_UPDOWN
)
return
;
theme
=
GetWindowTheme
(
infoPtr
->
hwndSelf
);
if
(
theme
)
{
if
(
infoPtr
->
dwStyle
&
WS_DISABLED
)
state
=
ABS_DOWNDISABLED
;
else
if
(
infoPtr
->
bCalDepressed
)
state
=
ABS_DOWNPRESSED
;
else
if
(
infoPtr
->
bCalHot
)
state
=
ABS_DOWNHOT
;
else
state
=
ABS_DOWNNORMAL
;
if
(
IsThemeBackgroundPartiallyTransparent
(
theme
,
SBP_ARROWBTN
,
state
))
DrawThemeParentBackground
(
infoPtr
->
hwndSelf
,
hdc
,
&
infoPtr
->
calbutton
);
DrawThemeBackground
(
theme
,
hdc
,
SBP_ARROWBTN
,
state
,
&
infoPtr
->
calbutton
,
NULL
);
}
else
{
DrawFrameControl
(
hdc
,
&
infoPtr
->
calbutton
,
DFC_SCROLL
,
DrawFrameControl
(
hdc
,
&
infoPtr
->
calbutton
,
DFC_SCROLL
,
DFCS_SCROLLDOWN
|
(
infoPtr
->
bCalDepressed
?
DFCS_PUSHED
:
0
)
|
DFCS_SCROLLDOWN
|
(
infoPtr
->
bCalDepressed
?
DFCS_PUSHED
:
0
)
|
(
infoPtr
->
dwStyle
&
WS_DISABLED
?
DFCS_INACTIVE
:
0
)
);
(
infoPtr
->
dwStyle
&
WS_DISABLED
?
DFCS_INACTIVE
:
0
)
);
...
@@ -1280,6 +1307,85 @@ DATETIME_NCCreate (HWND hwnd, const CREATESTRUCTW *lpcs)
...
@@ -1280,6 +1307,85 @@ DATETIME_NCCreate (HWND hwnd, const CREATESTRUCTW *lpcs)
return
1
;
return
1
;
}
}
static
LRESULT
DATETIME_NCPaint
(
HWND
hwnd
,
HRGN
region
)
{
INT
cxEdge
,
cyEdge
;
HRGN
clipRgn
;
HTHEME
theme
;
LONG
exStyle
;
RECT
r
;
HDC
dc
;
theme
=
OpenThemeData
(
NULL
,
WC_EDITW
);
if
(
!
theme
)
return
DefWindowProcW
(
hwnd
,
WM_NCPAINT
,
(
WPARAM
)
region
,
0
);
exStyle
=
GetWindowLongW
(
hwnd
,
GWL_EXSTYLE
);
if
(
!
(
exStyle
&
WS_EX_CLIENTEDGE
))
{
CloseThemeData
(
theme
);
return
DefWindowProcW
(
hwnd
,
WM_NCPAINT
,
(
WPARAM
)
region
,
0
);
}
cxEdge
=
GetSystemMetrics
(
SM_CXEDGE
);
cyEdge
=
GetSystemMetrics
(
SM_CYEDGE
);
GetWindowRect
(
hwnd
,
&
r
);
/* New clipping region passed to default proc to exclude border */
clipRgn
=
CreateRectRgn
(
r
.
left
+
cxEdge
,
r
.
top
+
cyEdge
,
r
.
right
-
cxEdge
,
r
.
bottom
-
cyEdge
);
if
(
region
!=
(
HRGN
)
1
)
CombineRgn
(
clipRgn
,
clipRgn
,
region
,
RGN_AND
);
OffsetRect
(
&
r
,
-
r
.
left
,
-
r
.
top
);
dc
=
GetDCEx
(
hwnd
,
region
,
DCX_WINDOW
|
DCX_INTERSECTRGN
);
if
(
IsThemeBackgroundPartiallyTransparent
(
theme
,
0
,
0
))
DrawThemeParentBackground
(
hwnd
,
dc
,
&
r
);
DrawThemeBackground
(
theme
,
dc
,
0
,
0
,
&
r
,
0
);
ReleaseDC
(
hwnd
,
dc
);
CloseThemeData
(
theme
);
/* Call default proc to get the scrollbars etc. also painted */
DefWindowProcW
(
hwnd
,
WM_NCPAINT
,
(
WPARAM
)
clipRgn
,
0
);
DeleteObject
(
clipRgn
);
return
0
;
}
static
LRESULT
DATETIME_MouseMove
(
DATETIME_INFO
*
infoPtr
,
LONG
x
,
LONG
y
)
{
TRACKMOUSEEVENT
event
;
POINT
point
;
BOOL
hot
;
point
.
x
=
x
;
point
.
y
=
y
;
hot
=
PtInRect
(
&
infoPtr
->
calbutton
,
point
);
if
(
hot
!=
infoPtr
->
bCalHot
)
{
infoPtr
->
bCalHot
=
hot
;
RedrawWindow
(
infoPtr
->
hwndSelf
,
&
infoPtr
->
calbutton
,
0
,
RDW_INVALIDATE
|
RDW_UPDATENOW
);
}
if
(
!
hot
)
return
0
;
event
.
cbSize
=
sizeof
(
TRACKMOUSEEVENT
);
event
.
dwFlags
=
TME_QUERY
;
if
(
!
TrackMouseEvent
(
&
event
)
||
event
.
hwndTrack
!=
infoPtr
->
hwndSelf
||
!
(
event
.
dwFlags
&
TME_LEAVE
))
{
event
.
hwndTrack
=
infoPtr
->
hwndSelf
;
event
.
dwFlags
=
TME_LEAVE
;
TrackMouseEvent
(
&
event
);
}
return
0
;
}
static
LRESULT
DATETIME_MouseLeave
(
DATETIME_INFO
*
infoPtr
)
{
infoPtr
->
bCalHot
=
FALSE
;
RedrawWindow
(
infoPtr
->
hwndSelf
,
&
infoPtr
->
calbutton
,
0
,
RDW_INVALIDATE
|
RDW_UPDATENOW
);
return
0
;
}
static
LRESULT
static
LRESULT
DATETIME_SetFocus
(
DATETIME_INFO
*
infoPtr
,
HWND
lostFocus
)
DATETIME_SetFocus
(
DATETIME_INFO
*
infoPtr
,
HWND
lostFocus
)
...
@@ -1430,6 +1536,16 @@ DATETIME_StyleChanged(DATETIME_INFO *infoPtr, WPARAM wStyleType, const STYLESTRU
...
@@ -1430,6 +1536,16 @@ DATETIME_StyleChanged(DATETIME_INFO *infoPtr, WPARAM wStyleType, const STYLESTRU
return
0
;
return
0
;
}
}
static
LRESULT
DATETIME_ThemeChanged
(
DATETIME_INFO
*
infoPtr
)
{
HTHEME
theme
;
theme
=
GetWindowTheme
(
infoPtr
->
hwndSelf
);
CloseThemeData
(
theme
);
OpenThemeData
(
infoPtr
->
hwndSelf
,
themeClass
);
return
0
;
}
static
BOOL
DATETIME_GetIdealSize
(
DATETIME_INFO
*
infoPtr
,
SIZE
*
size
)
static
BOOL
DATETIME_GetIdealSize
(
DATETIME_INFO
*
infoPtr
,
SIZE
*
size
)
{
{
SIZE
field_size
;
SIZE
field_size
;
...
@@ -1508,6 +1624,7 @@ DATETIME_Create (HWND hwnd, const CREATESTRUCTW *lpcs)
...
@@ -1508,6 +1624,7 @@ DATETIME_Create (HWND hwnd, const CREATESTRUCTW *lpcs)
infoPtr
->
hwndNotify
=
lpcs
->
hwndParent
;
infoPtr
->
hwndNotify
=
lpcs
->
hwndParent
;
infoPtr
->
select
=
-
1
;
/* initially, nothing is selected */
infoPtr
->
select
=
-
1
;
/* initially, nothing is selected */
infoPtr
->
bDropdownEnabled
=
TRUE
;
infoPtr
->
bDropdownEnabled
=
TRUE
;
infoPtr
->
bCalHot
=
FALSE
;
DATETIME_StyleChanged
(
infoPtr
,
GWL_STYLE
,
&
ss
);
DATETIME_StyleChanged
(
infoPtr
,
GWL_STYLE
,
&
ss
);
DATETIME_SetFormatW
(
infoPtr
,
0
);
DATETIME_SetFormatW
(
infoPtr
,
0
);
...
@@ -1522,6 +1639,7 @@ DATETIME_Create (HWND hwnd, const CREATESTRUCTW *lpcs)
...
@@ -1522,6 +1639,7 @@ DATETIME_Create (HWND hwnd, const CREATESTRUCTW *lpcs)
infoPtr
->
hFont
=
GetStockObject
(
DEFAULT_GUI_FONT
);
infoPtr
->
hFont
=
GetStockObject
(
DEFAULT_GUI_FONT
);
SetWindowLongPtrW
(
hwnd
,
0
,
(
DWORD_PTR
)
infoPtr
);
SetWindowLongPtrW
(
hwnd
,
0
,
(
DWORD_PTR
)
infoPtr
);
OpenThemeData
(
hwnd
,
themeClass
);
return
0
;
return
0
;
}
}
...
@@ -1531,6 +1649,11 @@ DATETIME_Create (HWND hwnd, const CREATESTRUCTW *lpcs)
...
@@ -1531,6 +1649,11 @@ DATETIME_Create (HWND hwnd, const CREATESTRUCTW *lpcs)
static
LRESULT
static
LRESULT
DATETIME_Destroy
(
DATETIME_INFO
*
infoPtr
)
DATETIME_Destroy
(
DATETIME_INFO
*
infoPtr
)
{
{
HTHEME
theme
;
theme
=
GetWindowTheme
(
infoPtr
->
hwndSelf
);
CloseThemeData
(
theme
);
if
(
infoPtr
->
hwndCheckbut
)
if
(
infoPtr
->
hwndCheckbut
)
DestroyWindow
(
infoPtr
->
hwndCheckbut
);
DestroyWindow
(
infoPtr
->
hwndCheckbut
);
if
(
infoPtr
->
hUpdown
)
if
(
infoPtr
->
hUpdown
)
...
@@ -1656,6 +1779,15 @@ DATETIME_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
...
@@ -1656,6 +1779,15 @@ DATETIME_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
case
WM_NCCREATE
:
case
WM_NCCREATE
:
return
DATETIME_NCCreate
(
hwnd
,
(
LPCREATESTRUCTW
)
lParam
);
return
DATETIME_NCCreate
(
hwnd
,
(
LPCREATESTRUCTW
)
lParam
);
case
WM_NCPAINT
:
return
DATETIME_NCPaint
(
hwnd
,
(
HRGN
)
wParam
);
case
WM_MOUSEMOVE
:
return
DATETIME_MouseMove
(
infoPtr
,
(
SHORT
)
LOWORD
(
lParam
),
(
SHORT
)
HIWORD
(
lParam
));
case
WM_MOUSELEAVE
:
return
DATETIME_MouseLeave
(
infoPtr
);
case
WM_SETFOCUS
:
case
WM_SETFOCUS
:
return
DATETIME_SetFocus
(
infoPtr
,
(
HWND
)
wParam
);
return
DATETIME_SetFocus
(
infoPtr
,
(
HWND
)
wParam
);
...
@@ -1686,6 +1818,9 @@ DATETIME_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
...
@@ -1686,6 +1818,9 @@ DATETIME_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
case
WM_STYLECHANGED
:
case
WM_STYLECHANGED
:
return
DATETIME_StyleChanged
(
infoPtr
,
wParam
,
(
LPSTYLESTRUCT
)
lParam
);
return
DATETIME_StyleChanged
(
infoPtr
,
wParam
,
(
LPSTYLESTRUCT
)
lParam
);
case
WM_THEMECHANGED
:
return
DATETIME_ThemeChanged
(
infoPtr
);
case
WM_SETFONT
:
case
WM_SETFONT
:
return
DATETIME_SetFont
(
infoPtr
,
(
HFONT
)
wParam
,
(
BOOL
)
lParam
);
return
DATETIME_SetFont
(
infoPtr
,
(
HFONT
)
wParam
,
(
BOOL
)
lParam
);
...
...
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