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
ab6bb569
Commit
ab6bb569
authored
Feb 14, 2013
by
Huw Davies
Committed by
Alexandre Julliard
Feb 14, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
riched20: Simplify selection painting by drawing a selected run twice with appropriate clipping.
parent
d528e760
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
57 additions
and
55 deletions
+57
-55
paint.c
dlls/riched20/paint.c
+57
-55
No files found.
dlls/riched20/paint.c
View file @
ab6bb569
...
@@ -305,89 +305,91 @@ static void get_selection_rect( ME_Context *c, ME_Run *run, int from, int to, in
...
@@ -305,89 +305,91 @@ static void get_selection_rect( ME_Context *c, ME_Run *run, int from, int to, in
return
;
return
;
}
}
static
void
draw_text
(
ME_Context
*
c
,
ME_Run
*
run
,
int
x
,
int
y
,
const
WCHAR
*
text
,
BOOL
selected
,
RECT
*
sel_rect
)
{
COLORREF
text_color
=
get_text_color
(
c
,
run
->
style
,
selected
);
COLORREF
back_color
=
selected
?
ITextHost_TxGetSysColor
(
c
->
editor
->
texthost
,
COLOR_HIGHLIGHT
)
:
0
;
COLORREF
old_text
,
old_back
;
HPEN
pen
;
old_text
=
SetTextColor
(
c
->
hDC
,
text_color
);
if
(
selected
)
old_back
=
SetBkColor
(
c
->
hDC
,
back_color
);
ExtTextOutW
(
c
->
hDC
,
x
,
y
,
selected
?
ETO_OPAQUE
:
0
,
sel_rect
,
text
,
run
->
len
,
NULL
);
if
(
selected
)
SetBkColor
(
c
->
hDC
,
old_back
);
SetTextColor
(
c
->
hDC
,
old_text
);
get_underline_pen
(
run
->
style
,
text_color
,
&
pen
);
if
(
pen
)
{
HPEN
old_pen
=
SelectObject
(
c
->
hDC
,
pen
);
MoveToEx
(
c
->
hDC
,
x
,
y
+
1
,
NULL
);
LineTo
(
c
->
hDC
,
x
+
run
->
nWidth
,
y
+
1
);
SelectObject
(
c
->
hDC
,
old_pen
);
DeleteObject
(
pen
);
}
return
;
}
static
void
ME_DrawTextWithStyle
(
ME_Context
*
c
,
ME_Run
*
run
,
int
x
,
int
y
,
LPCWSTR
szText
,
static
void
ME_DrawTextWithStyle
(
ME_Context
*
c
,
ME_Run
*
run
,
int
x
,
int
y
,
LPCWSTR
szText
,
int
nSelFrom
,
int
nSelTo
,
int
ymin
,
int
cy
)
int
nSelFrom
,
int
nSelTo
,
int
ymin
,
int
cy
)
{
{
HDC
hDC
=
c
->
hDC
;
HDC
hDC
=
c
->
hDC
;
HGDIOBJ
hOldFont
;
HGDIOBJ
hOldFont
;
COLORREF
rgbOld
;
int
yOffset
=
0
;
int
yOffset
=
0
;
COLORREF
rgb
;
BOOL
selected
=
(
nSelFrom
<
run
->
len
&&
nSelTo
>=
0
HPEN
hPen
=
NULL
,
hOldPen
=
NULL
;
BOOL
bHighlightedText
=
(
nSelFrom
<
run
->
len
&&
nSelTo
>=
0
&&
nSelFrom
<
nSelTo
&&
!
c
->
editor
->
bHideSelection
);
&&
nSelFrom
<
nSelTo
&&
!
c
->
editor
->
bHideSelection
);
BOOL
old_style_selected
=
FALSE
;
RECT
sel_rect
;
RECT
sel_rect
;
HRGN
clip
=
NULL
,
sel_rgn
=
NULL
;
yOffset
=
calc_y_offset
(
c
,
run
->
style
);
yOffset
=
calc_y_offset
(
c
,
run
->
style
);
rgb
=
get_text_color
(
c
,
run
->
style
,
FALSE
);
if
(
selected
)
if
(
bHighlightedText
)
{
{
nSelFrom
=
max
(
0
,
nSelFrom
);
nSelFrom
=
max
(
0
,
nSelFrom
);
nSelTo
=
min
(
run
->
len
,
nSelTo
);
nSelTo
=
min
(
run
->
len
,
nSelTo
);
get_selection_rect
(
c
,
run
,
nSelFrom
,
nSelTo
,
cy
,
&
sel_rect
);
get_selection_rect
(
c
,
run
,
nSelFrom
,
nSelTo
,
cy
,
&
sel_rect
);
OffsetRect
(
&
sel_rect
,
x
,
ymin
);
OffsetRect
(
&
sel_rect
,
x
,
ymin
);
}
hOldFont
=
ME_SelectStyleFont
(
c
,
run
->
style
);
get_underline_pen
(
run
->
style
,
rgb
,
&
hPen
);
if
(
c
->
editor
->
bEmulateVersion10
)
if
(
hPen
)
hOldPen
=
SelectObject
(
hDC
,
hPen
);
rgbOld
=
SetTextColor
(
hDC
,
rgb
);
if
(
bHighlightedText
&&
!
c
->
editor
->
bEmulateVersion10
)
{
COLORREF
rgbBackOld
;
/* FIXME: should use textmetrics info for Descent info */
if
(
hPen
)
MoveToEx
(
hDC
,
x
,
y
-
yOffset
+
1
,
NULL
);
if
(
sel_rect
.
left
>
x
)
{
ExtTextOutW
(
hDC
,
x
,
y
-
yOffset
,
0
,
NULL
,
szText
,
nSelFrom
,
NULL
);
if
(
hPen
)
LineTo
(
hDC
,
sel_rect
.
left
,
y
-
yOffset
+
1
);
}
SetTextColor
(
hDC
,
get_text_color
(
c
,
run
->
style
,
TRUE
)
);
rgbBackOld
=
SetBkColor
(
hDC
,
ITextHost_TxGetSysColor
(
c
->
editor
->
texthost
,
COLOR_HIGHLIGHT
));
ExtTextOutW
(
hDC
,
sel_rect
.
left
,
y
-
yOffset
,
ETO_OPAQUE
,
&
sel_rect
,
szText
+
nSelFrom
,
nSelTo
-
nSelFrom
,
NULL
);
if
(
hPen
)
LineTo
(
hDC
,
sel_rect
.
right
,
y
-
yOffset
+
1
);
SetBkColor
(
hDC
,
rgbBackOld
);
if
(
sel_rect
.
right
<
x
+
run
->
nWidth
)
{
{
SetTextColor
(
hDC
,
rgb
);
old_style_selected
=
TRUE
;
ExtTextOutW
(
hDC
,
sel_rect
.
right
,
y
-
yOffset
,
0
,
NULL
,
szText
+
nSelTo
,
selected
=
FALSE
;
run
->
len
-
nSelTo
,
NULL
);
if
(
hPen
)
LineTo
(
hDC
,
x
+
run
->
nWidth
,
y
-
yOffset
+
1
);
}
}
}
else
else
{
{
ExtTextOutW
(
hDC
,
x
,
y
-
yOffset
,
0
,
NULL
,
szText
,
run
->
len
,
NULL
);
sel_rgn
=
CreateRectRgnIndirect
(
&
sel_rect
);
clip
=
CreateRectRgn
(
0
,
0
,
0
,
0
);
/* FIXME: should use textmetrics info for Descent info */
if
(
GetClipRgn
(
hDC
,
clip
)
!=
1
)
if
(
hPen
)
{
{
MoveToEx
(
hDC
,
x
,
y
-
yOffset
+
1
,
NULL
);
DeleteObject
(
clip
);
LineTo
(
hDC
,
x
+
run
->
nWidth
,
y
-
yOffset
+
1
)
;
clip
=
NULL
;
}
}
if
(
bHighlightedText
)
/* v1.0 inverts the selection */
{
PatBlt
(
hDC
,
sel_rect
.
left
,
ymin
,
sel_rect
.
right
-
sel_rect
.
left
,
cy
,
DSTINVERT
);
}
}
}
}
if
(
hPen
)
hOldFont
=
ME_SelectStyleFont
(
c
,
run
->
style
);
if
(
sel_rgn
)
ExtSelectClipRgn
(
hDC
,
sel_rgn
,
RGN_DIFF
);
draw_text
(
c
,
run
,
x
,
y
-
yOffset
,
szText
,
FALSE
,
NULL
);
if
(
sel_rgn
)
{
{
SelectObject
(
hDC
,
hOldPen
);
ExtSelectClipRgn
(
hDC
,
clip
,
RGN_COPY
);
DeleteObject
(
hPen
);
ExtSelectClipRgn
(
hDC
,
sel_rgn
,
RGN_AND
);
draw_text
(
c
,
run
,
x
,
y
-
yOffset
,
szText
,
TRUE
,
&
sel_rect
);
ExtSelectClipRgn
(
hDC
,
clip
,
RGN_COPY
);
if
(
clip
)
DeleteObject
(
clip
);
DeleteObject
(
sel_rgn
);
}
}
SetTextColor
(
hDC
,
rgbOld
);
if
(
old_style_selected
)
PatBlt
(
hDC
,
sel_rect
.
left
,
ymin
,
sel_rect
.
right
-
sel_rect
.
left
,
cy
,
DSTINVERT
);
ME_UnselectStyleFont
(
c
,
run
->
style
,
hOldFont
);
ME_UnselectStyleFont
(
c
,
run
->
style
,
hOldFont
);
}
}
...
...
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