[PATCH 4/5 v2] riched20: Support external HDC in ME_WrapMarkedParagraphs().
Huw Davies
huw at codeweavers.com
Wed May 23 03:49:15 CDT 2018
On Tue, May 22, 2018 at 04:32:31PM +0800, Jactry Zeng wrote:
> Superseded patch 146218.
>
> Signed-off-by: Jactry Zeng <jzeng at codeweavers.com>
> ---
> dlls/riched20/editor.c | 12 ++++++------
> dlls/riched20/editor.h | 2 +-
> dlls/riched20/paint.c | 10 +++++-----
> dlls/riched20/table.c | 4 ++--
> dlls/riched20/wrap.c | 6 ++++--
> 5 files changed, 18 insertions(+), 16 deletions(-)
>
> diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c
> index 820b0380c7..0501c606b1 100644
> --- a/dlls/riched20/editor.c
> +++ b/dlls/riched20/editor.c
> @@ -3494,7 +3494,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 +3645,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 +3934,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 +3959,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 +4054,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 +4714,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/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..38ba8acc9c 100644
> --- a/dlls/riched20/wrap.c
> +++ b/dlls/riched20/wrap.c
> @@ -980,14 +980,16 @@ 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);
> + ME_InitContext(&c, editor, hdc);
> c.pt.x = 0;
> item = editor->pBuffer->pFirst->next;
> while(item != editor->pBuffer->pLast) {
You'll need to mark the whole text for rewrapping if the new dc is
different from the one which was previously used to wrap.
Huw.
More information about the wine-devel
mailing list