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
564872cd
Commit
564872cd
authored
Jul 25, 2005
by
Frank Richter
Committed by
Alexandre Julliard
Jul 25, 2005
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add theming support for header controls.
parent
bc07b2ac
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
51 additions
and
4 deletions
+51
-4
header.c
dlls/comctl32/header.c
+51
-4
No files found.
dlls/comctl32/header.c
View file @
564872cd
...
@@ -43,6 +43,8 @@
...
@@ -43,6 +43,8 @@
#include "commctrl.h"
#include "commctrl.h"
#include "comctl32.h"
#include "comctl32.h"
#include "imagelist.h"
#include "imagelist.h"
#include "tmschema.h"
#include "uxtheme.h"
#include "wine/debug.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL
(
header
);
WINE_DEFAULT_DEBUG_CHANNEL
(
header
);
...
@@ -94,6 +96,8 @@ typedef struct
...
@@ -94,6 +96,8 @@ typedef struct
#define HEADER_GetInfoPtr(hwnd) ((HEADER_INFO *)GetWindowLongPtrW(hwnd,0))
#define HEADER_GetInfoPtr(hwnd) ((HEADER_INFO *)GetWindowLongPtrW(hwnd,0))
static
const
WCHAR
themeClass
[]
=
{
'H'
,
'e'
,
'a'
,
'd'
,
'e'
,
'r'
,
0
};
inline
static
LRESULT
inline
static
LRESULT
HEADER_IndexToOrder
(
HWND
hwnd
,
INT
iItem
)
HEADER_IndexToOrder
(
HWND
hwnd
,
INT
iItem
)
...
@@ -164,6 +168,7 @@ HEADER_DrawItem (HWND hwnd, HDC hdc, INT iItem, BOOL bHotTrack)
...
@@ -164,6 +168,7 @@ HEADER_DrawItem (HWND hwnd, HDC hdc, INT iItem, BOOL bHotTrack)
HEADER_ITEM
*
phdi
=
&
infoPtr
->
items
[
iItem
];
HEADER_ITEM
*
phdi
=
&
infoPtr
->
items
[
iItem
];
RECT
r
;
RECT
r
;
INT
oldBkMode
,
cxEdge
=
GetSystemMetrics
(
SM_CXEDGE
);
INT
oldBkMode
,
cxEdge
=
GetSystemMetrics
(
SM_CXEDGE
);
HTHEME
theme
=
GetWindowTheme
(
hwnd
);
TRACE
(
"DrawItem(iItem %d bHotTrack %d unicode flag %d)
\n
"
,
iItem
,
bHotTrack
,
infoPtr
->
bUnicode
);
TRACE
(
"DrawItem(iItem %d bHotTrack %d unicode flag %d)
\n
"
,
iItem
,
bHotTrack
,
infoPtr
->
bUnicode
);
...
@@ -174,12 +179,19 @@ HEADER_DrawItem (HWND hwnd, HDC hdc, INT iItem, BOOL bHotTrack)
...
@@ -174,12 +179,19 @@ HEADER_DrawItem (HWND hwnd, HDC hdc, INT iItem, BOOL bHotTrack)
if
(
r
.
right
-
r
.
left
==
0
)
if
(
r
.
right
-
r
.
left
==
0
)
return
phdi
->
rect
.
right
;
return
phdi
->
rect
.
right
;
if
(
theme
!=
NULL
)
{
int
state
=
(
phdi
->
bDown
)
?
HIS_PRESSED
:
(
bHotTrack
?
HIS_HOT
:
HIS_NORMAL
);
DrawThemeBackground
(
theme
,
hdc
,
HP_HEADERITEM
,
state
,
&
r
,
NULL
);
GetThemeBackgroundContentRect
(
theme
,
hdc
,
HP_HEADERITEM
,
state
,
&
r
,
&
r
);
}
else
{
if
(
GetWindowLongW
(
hwnd
,
GWL_STYLE
)
&
HDS_BUTTONS
)
{
if
(
GetWindowLongW
(
hwnd
,
GWL_STYLE
)
&
HDS_BUTTONS
)
{
if
(
phdi
->
bDown
)
{
if
(
phdi
->
bDown
)
{
DrawEdge
(
hdc
,
&
r
,
BDR_RAISEDOUTER
,
DrawEdge
(
hdc
,
&
r
,
BDR_RAISEDOUTER
,
BF_RECT
|
BF_FLAT
|
BF_MIDDLE
|
BF_ADJUST
);
BF_RECT
|
BF_FLAT
|
BF_MIDDLE
|
BF_ADJUST
);
r
.
left
+=
2
;
r
.
top
+=
2
;
}
}
else
else
DrawEdge
(
hdc
,
&
r
,
EDGE_RAISED
,
DrawEdge
(
hdc
,
&
r
,
EDGE_RAISED
,
...
@@ -187,6 +199,11 @@ HEADER_DrawItem (HWND hwnd, HDC hdc, INT iItem, BOOL bHotTrack)
...
@@ -187,6 +199,11 @@ HEADER_DrawItem (HWND hwnd, HDC hdc, INT iItem, BOOL bHotTrack)
}
}
else
else
DrawEdge
(
hdc
,
&
r
,
EDGE_ETCHED
,
BF_BOTTOM
|
BF_RIGHT
|
BF_ADJUST
);
DrawEdge
(
hdc
,
&
r
,
EDGE_ETCHED
,
BF_BOTTOM
|
BF_RIGHT
|
BF_ADJUST
);
}
if
(
phdi
->
bDown
)
{
r
.
left
+=
2
;
r
.
top
+=
2
;
}
r
.
left
-=
cxEdge
;
r
.
left
-=
cxEdge
;
r
.
right
+=
cxEdge
;
r
.
right
+=
cxEdge
;
...
@@ -330,7 +347,7 @@ HEADER_DrawItem (HWND hwnd, HDC hdc, INT iItem, BOOL bHotTrack)
...
@@ -330,7 +347,7 @@ HEADER_DrawItem (HWND hwnd, HDC hdc, INT iItem, BOOL bHotTrack)
HDF_BITMAP_ON_RIGHT
|
HDF_IMAGE
))))
/* no explicit format specified? */
HDF_BITMAP_ON_RIGHT
|
HDF_IMAGE
))))
/* no explicit format specified? */
&&
(
phdi
->
pszText
))
{
&&
(
phdi
->
pszText
))
{
oldBkMode
=
SetBkMode
(
hdc
,
TRANSPARENT
);
oldBkMode
=
SetBkMode
(
hdc
,
TRANSPARENT
);
SetTextColor
(
hdc
,
(
bHotTrack
)
?
COLOR_HIGHLIGHT
:
COLOR_BTNTEXT
);
SetTextColor
(
hdc
,
(
bHotTrack
&&
!
theme
)
?
COLOR_HIGHLIGHT
:
COLOR_BTNTEXT
);
r
.
left
=
tx
;
r
.
left
=
tx
;
r
.
right
=
tx
+
tw
;
r
.
right
=
tx
+
tw
;
DrawTextW
(
hdc
,
phdi
->
pszText
,
-
1
,
DrawTextW
(
hdc
,
phdi
->
pszText
,
-
1
,
...
@@ -353,6 +370,7 @@ HEADER_Refresh (HWND hwnd, HDC hdc)
...
@@ -353,6 +370,7 @@ HEADER_Refresh (HWND hwnd, HDC hdc)
HBRUSH
hbrBk
;
HBRUSH
hbrBk
;
UINT
i
;
UINT
i
;
INT
x
;
INT
x
;
HTHEME
theme
=
GetWindowTheme
(
hwnd
);
/* get rect for the bar, adjusted for the border */
/* get rect for the bar, adjusted for the border */
GetClientRect
(
hwnd
,
&
rect
);
GetClientRect
(
hwnd
,
&
rect
);
...
@@ -361,21 +379,30 @@ HEADER_Refresh (HWND hwnd, HDC hdc)
...
@@ -361,21 +379,30 @@ HEADER_Refresh (HWND hwnd, HDC hdc)
hOldFont
=
SelectObject
(
hdc
,
hFont
);
hOldFont
=
SelectObject
(
hdc
,
hFont
);
/* draw Background */
/* draw Background */
if
(
theme
==
NULL
)
{
hbrBk
=
GetSysColorBrush
(
COLOR_3DFACE
);
hbrBk
=
GetSysColorBrush
(
COLOR_3DFACE
);
FillRect
(
hdc
,
&
rect
,
hbrBk
);
FillRect
(
hdc
,
&
rect
,
hbrBk
);
}
x
=
rect
.
left
;
x
=
rect
.
left
;
for
(
i
=
0
;
i
<
infoPtr
->
uNumItem
;
i
++
)
{
for
(
i
=
0
;
i
<
infoPtr
->
uNumItem
;
i
++
)
{
x
=
HEADER_DrawItem
(
hwnd
,
hdc
,
HEADER_OrderToIndex
(
hwnd
,
i
),
FALSE
);
x
=
HEADER_DrawItem
(
hwnd
,
hdc
,
HEADER_OrderToIndex
(
hwnd
,
i
),
infoPtr
->
iHotItem
==
i
);
}
}
if
((
x
<=
rect
.
right
)
&&
(
infoPtr
->
uNumItem
>
0
))
{
if
((
x
<=
rect
.
right
)
&&
(
infoPtr
->
uNumItem
>
0
))
{
rect
.
left
=
x
;
rect
.
left
=
x
;
if
(
theme
!=
NULL
)
{
DrawThemeBackground
(
theme
,
hdc
,
HP_HEADERITEM
,
HIS_NORMAL
,
&
rect
,
NULL
);
}
else
{
if
(
GetWindowLongW
(
hwnd
,
GWL_STYLE
)
&
HDS_BUTTONS
)
if
(
GetWindowLongW
(
hwnd
,
GWL_STYLE
)
&
HDS_BUTTONS
)
DrawEdge
(
hdc
,
&
rect
,
EDGE_RAISED
,
BF_TOP
|
BF_LEFT
|
BF_BOTTOM
|
BF_SOFT
);
DrawEdge
(
hdc
,
&
rect
,
EDGE_RAISED
,
BF_TOP
|
BF_LEFT
|
BF_BOTTOM
|
BF_SOFT
);
else
else
DrawEdge
(
hdc
,
&
rect
,
EDGE_ETCHED
,
BF_BOTTOM
);
DrawEdge
(
hdc
,
&
rect
,
EDGE_ETCHED
,
BF_BOTTOM
);
}
}
}
SelectObject
(
hdc
,
hOldFont
);
SelectObject
(
hdc
,
hOldFont
);
}
}
...
@@ -1293,6 +1320,7 @@ HEADER_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
...
@@ -1293,6 +1320,7 @@ HEADER_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
TEXTMETRICW
tm
;
TEXTMETRICW
tm
;
HFONT
hOldFont
;
HFONT
hOldFont
;
HDC
hdc
;
HDC
hdc
;
BOOL
themingActive
=
IsAppThemed
()
&&
IsThemeActive
();
infoPtr
=
(
HEADER_INFO
*
)
Alloc
(
sizeof
(
HEADER_INFO
));
infoPtr
=
(
HEADER_INFO
*
)
Alloc
(
sizeof
(
HEADER_INFO
));
SetWindowLongPtrW
(
hwnd
,
0
,
(
DWORD_PTR
)
infoPtr
);
SetWindowLongPtrW
(
hwnd
,
0
,
(
DWORD_PTR
)
infoPtr
);
...
@@ -1322,6 +1350,8 @@ HEADER_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
...
@@ -1322,6 +1350,8 @@ HEADER_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
SelectObject
(
hdc
,
hOldFont
);
SelectObject
(
hdc
,
hOldFont
);
ReleaseDC
(
0
,
hdc
);
ReleaseDC
(
0
,
hdc
);
if
(
themingActive
)
OpenThemeData
(
hwnd
,
themeClass
);
return
0
;
return
0
;
}
}
...
@@ -1332,6 +1362,7 @@ HEADER_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
...
@@ -1332,6 +1362,7 @@ HEADER_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
HEADER_INFO
*
infoPtr
=
HEADER_GetInfoPtr
(
hwnd
);
HEADER_INFO
*
infoPtr
=
HEADER_GetInfoPtr
(
hwnd
);
HEADER_ITEM
*
lpItem
;
HEADER_ITEM
*
lpItem
;
INT
nItem
;
INT
nItem
;
HTHEME
theme
;
if
(
infoPtr
->
items
)
{
if
(
infoPtr
->
items
)
{
lpItem
=
infoPtr
->
items
;
lpItem
=
infoPtr
->
items
;
...
@@ -1347,6 +1378,9 @@ HEADER_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
...
@@ -1347,6 +1378,9 @@ HEADER_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
SetWindowLongPtrW
(
hwnd
,
0
,
0
);
SetWindowLongPtrW
(
hwnd
,
0
,
0
);
Free
(
infoPtr
);
Free
(
infoPtr
);
theme
=
GetWindowTheme
(
hwnd
);
CloseThemeData
(
theme
);
return
0
;
return
0
;
}
}
...
@@ -1707,6 +1741,16 @@ HEADER_SetFont (HWND hwnd, WPARAM wParam, LPARAM lParam)
...
@@ -1707,6 +1741,16 @@ HEADER_SetFont (HWND hwnd, WPARAM wParam, LPARAM lParam)
return
0
;
return
0
;
}
}
/* Update the theme handle after a theme change */
static
LRESULT
HEADER_ThemeChanged
(
HWND
hwnd
)
{
HTHEME
theme
=
GetWindowTheme
(
hwnd
);
CloseThemeData
(
theme
);
OpenThemeData
(
hwnd
,
themeClass
);
InvalidateRect
(
hwnd
,
NULL
,
FALSE
);
return
0
;
}
static
LRESULT
WINAPI
static
LRESULT
WINAPI
HEADER_WindowProc
(
HWND
hwnd
,
UINT
msg
,
WPARAM
wParam
,
LPARAM
lParam
)
HEADER_WindowProc
(
HWND
hwnd
,
UINT
msg
,
WPARAM
wParam
,
LPARAM
lParam
)
...
@@ -1819,6 +1863,9 @@ HEADER_WindowProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
...
@@ -1819,6 +1863,9 @@ HEADER_WindowProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
case
WM_SIZE
:
case
WM_SIZE
:
return
HEADER_Size
(
hwnd
,
wParam
);
return
HEADER_Size
(
hwnd
,
wParam
);
case
WM_THEMECHANGED
:
return
HEADER_ThemeChanged
(
hwnd
);
case
WM_PAINT
:
case
WM_PAINT
:
return
HEADER_Paint
(
hwnd
,
wParam
);
return
HEADER_Paint
(
hwnd
,
wParam
);
...
...
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