[PATCH 3/4 v5] riched20: Support external HDC in ME_WrapMarkedParagraphs().
Jactry Zeng
jzeng at codeweavers.com
Wed Jun 6 04:24:31 CDT 2018
Superseded patch 146572.
Signed-off-by: Jactry Zeng <jzeng at codeweavers.com>
---
dlls/riched20/editor.c | 13 +++++++------
dlls/riched20/editor.h | 2 +-
dlls/riched20/editstr.h | 1 +
dlls/riched20/paint.c | 10 +++++-----
dlls/riched20/table.c | 4 ++--
dlls/riched20/wrap.c | 11 +++++++++--
6 files changed, 25 insertions(+), 16 deletions(-)
diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c
index 820b0380c7..82132761f0 100644
--- a/dlls/riched20/editor.c
+++ b/dlls/riched20/editor.c
@@ -3028,6 +3028,7 @@ ME_TextEditor *ME_MakeEditor(ITextHost *texthost, BOOL bEmulateVersion10)
ed->hWnd = NULL;
ed->hwndParent = NULL;
+ ed->hdcDraw = NULL;
ed->sizeWindow.cx = ed->sizeWindow.cy = 0;
ed->texthost = texthost;
ed->reOle = NULL;
@@ -3494,7 +3495,7 @@ static LRESULT ME_WmCreate(ME_TextEditor *editor, LPARAM lParam, BOOL unicode)
}
ME_CommitUndo(editor);
- ME_WrapMarkedParagraphs(editor);
+ ME_WrapMarkedParagraphs(editor, NULL);
ME_MoveCaret(editor);
return 0;
}
@@ -3645,7 +3646,7 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
cf.yHeight = size * 20; /* convert twips to points */
ME_SetSelectionCharFormat(editor, &cf);
ME_CommitUndo(editor);
- ME_WrapMarkedParagraphs(editor);
+ ME_WrapMarkedParagraphs(editor, NULL);
ME_UpdateScrollBar(editor);
ME_Repaint(editor);
@@ -3934,7 +3935,7 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
ME_CommitUndo(editor);
if (bRepaint)
{
- ME_WrapMarkedParagraphs(editor);
+ ME_WrapMarkedParagraphs(editor, NULL);
ME_UpdateScrollBar(editor);
ME_Repaint(editor);
}
@@ -3959,7 +3960,7 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
case EM_SETPARAFORMAT:
{
BOOL result = ME_SetSelectionParaFormat(editor, (PARAFORMAT2 *)lParam);
- ME_WrapMarkedParagraphs(editor);
+ ME_WrapMarkedParagraphs(editor, NULL);
ME_UpdateScrollBar(editor);
ME_Repaint(editor);
ME_CommitUndo(editor);
@@ -4054,7 +4055,7 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
ME_CommitUndo(editor);
ME_MarkAllForWrapping(editor);
- ME_WrapMarkedParagraphs(editor);
+ ME_WrapMarkedParagraphs(editor, NULL);
ME_UpdateScrollBar(editor);
if (bRepaint)
ME_Repaint(editor);
@@ -4714,7 +4715,7 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
editor->bDefaultFormatRect = TRUE;
}
ME_MarkAllForWrapping(editor);
- ME_WrapMarkedParagraphs(editor);
+ ME_WrapMarkedParagraphs(editor, NULL);
ME_UpdateScrollBar(editor);
if (msg != EM_SETRECTNP)
ME_Repaint(editor);
diff --git a/dlls/riched20/editor.h b/dlls/riched20/editor.h
index 0f0e56ecd1..425a34f0c2 100644
--- a/dlls/riched20/editor.h
+++ b/dlls/riched20/editor.h
@@ -182,7 +182,7 @@ void ME_InitContext(ME_Context *c, ME_TextEditor *editor, HDC hDC) DECLSPEC_HIDD
void ME_DestroyContext(ME_Context *c) DECLSPEC_HIDDEN;
/* wrap.c */
-BOOL ME_WrapMarkedParagraphs(ME_TextEditor *editor) DECLSPEC_HIDDEN;
+BOOL ME_WrapMarkedParagraphs(ME_TextEditor *editor, HDC hdc) DECLSPEC_HIDDEN;
void ME_InvalidateParagraphRange(ME_TextEditor *editor, ME_DisplayItem *start_para, ME_DisplayItem *last_para) DECLSPEC_HIDDEN;
void ME_SendRequestResize(ME_TextEditor *editor, BOOL force) DECLSPEC_HIDDEN;
diff --git a/dlls/riched20/editstr.h b/dlls/riched20/editstr.h
index 206ce85287..1d811e1c2a 100644
--- a/dlls/riched20/editstr.h
+++ b/dlls/riched20/editstr.h
@@ -383,6 +383,7 @@ typedef struct tagME_InStream ME_InStream;
typedef struct tagME_TextEditor
{
HWND hWnd, hwndParent;
+ HDC hdcDraw;
ITextHost *texthost;
IRichEditOle *reOle;
BOOL bEmulateVersion10;
diff --git a/dlls/riched20/paint.c b/dlls/riched20/paint.c
index fcc4e105a3..f2429081fc 100644
--- a/dlls/riched20/paint.c
+++ b/dlls/riched20/paint.c
@@ -105,7 +105,7 @@ void ME_PaintContent(ME_TextEditor *editor, HDC hDC, const RECT *rcUpdate)
void ME_Repaint(ME_TextEditor *editor)
{
- if (ME_WrapMarkedParagraphs(editor))
+ if (ME_WrapMarkedParagraphs(editor, NULL))
{
ME_UpdateScrollBar(editor);
FIXME("ME_Repaint had to call ME_WrapMarkedParagraphs\n");
@@ -118,7 +118,7 @@ void ME_UpdateRepaint(ME_TextEditor *editor, BOOL update_now)
/* Should be called whenever the contents of the control have changed */
BOOL wrappedParagraphs;
- wrappedParagraphs = ME_WrapMarkedParagraphs(editor);
+ wrappedParagraphs = ME_WrapMarkedParagraphs(editor, NULL);
if (wrappedParagraphs)
ME_UpdateScrollBar(editor);
@@ -145,7 +145,7 @@ ME_RewrapRepaint(ME_TextEditor *editor)
* looks, but not content. Like resizing. */
ME_MarkAllForWrapping(editor);
- ME_WrapMarkedParagraphs(editor);
+ ME_WrapMarkedParagraphs(editor, NULL);
ME_UpdateScrollBar(editor);
ME_Repaint(editor);
}
@@ -1163,7 +1163,7 @@ void ME_UpdateScrollBar(ME_TextEditor *editor)
SCROLLINFO si;
BOOL bScrollBarWasVisible, bScrollBarWillBeVisible;
- if (ME_WrapMarkedParagraphs(editor))
+ if (ME_WrapMarkedParagraphs(editor, NULL))
FIXME("ME_UpdateScrollBar had to call ME_WrapMarkedParagraphs\n");
si.cbSize = sizeof(si);
@@ -1336,7 +1336,7 @@ ME_InvalidateSelection(ME_TextEditor *editor)
there's no (inverted) area to be repainted, neither old nor new */
if (nStart == nEnd && editor->nLastSelStart == editor->nLastSelEnd)
return;
- ME_WrapMarkedParagraphs(editor);
+ ME_WrapMarkedParagraphs(editor, NULL);
ME_GetSelectionParas(editor, &sel_start, &sel_end);
assert(sel_start->type == diParagraph);
assert(sel_end->type == diParagraph);
diff --git a/dlls/riched20/table.c b/dlls/riched20/table.c
index 4cd77eb399..5457935dfa 100644
--- a/dlls/riched20/table.c
+++ b/dlls/riched20/table.c
@@ -499,7 +499,7 @@ static void ME_SelectOrInsertNextCell(ME_TextEditor *editor,
editor->pCursors[0].pRun = ME_FindItemFwd(para, diRun);
editor->pCursors[0].nOffset = 0;
editor->pCursors[1] = editor->pCursors[0];
- ME_WrapMarkedParagraphs(editor);
+ ME_WrapMarkedParagraphs(editor, NULL);
return;
}
}
@@ -544,7 +544,7 @@ static void ME_SelectOrInsertNextCell(ME_TextEditor *editor,
editor->pCursors[0].pRun = ME_FindItemFwd(para, diRun);
editor->pCursors[0].nOffset = 0;
editor->pCursors[1] = editor->pCursors[0];
- ME_WrapMarkedParagraphs(editor);
+ ME_WrapMarkedParagraphs(editor, NULL);
return;
}
}
diff --git a/dlls/riched20/wrap.c b/dlls/riched20/wrap.c
index e3a70f07d1..4c92252547 100644
--- a/dlls/riched20/wrap.c
+++ b/dlls/riched20/wrap.c
@@ -980,14 +980,21 @@ static void ME_MarkRepaintEnd(ME_DisplayItem *para,
*repaint_end = para;
}
-BOOL ME_WrapMarkedParagraphs(ME_TextEditor *editor)
+BOOL ME_WrapMarkedParagraphs(ME_TextEditor *editor, HDC hdc)
{
ME_DisplayItem *item;
ME_Context c;
int totalWidth = 0;
ME_DisplayItem *repaint_start = NULL, *repaint_end = NULL;
- ME_InitContext(&c, editor, ITextHost_TxGetDC(editor->texthost));
+ if (!hdc)
+ hdc = ITextHost_TxGetDC(editor->texthost);
+ if (hdc != editor->hdcDraw)
+ {
+ ME_MarkAllForWrapping(editor);
+ editor->hdcDraw = hdc;
+ }
+ ME_InitContext(&c, editor, hdc);
c.pt.x = 0;
item = editor->pBuffer->pFirst->next;
while(item != editor->pBuffer->pLast) {
--
2.17.1
More information about the wine-devel
mailing list