Commit 1a3551b6 authored by Dylan Smith's avatar Dylan Smith Committed by Alexandre Julliard

richedit: Use width from EM_SETTARGETDEVICE for wrapping.

The width for EM_SETTARGETDEVICE is used by some applications to set the wrapping width to a certain distance in twips. This can be used even though the target device is ignored.
parent f20ba244
......@@ -22,7 +22,7 @@
void ME_InitContext(ME_Context *c, ME_TextEditor *editor, HDC hDC)
{
c->nSequence = editor->nSequence++;
c->nSequence = editor->nSequence++;
c->hDC = hDC;
c->editor = editor;
c->pt.x = 0;
......@@ -35,6 +35,10 @@ void ME_InitContext(ME_Context *c, ME_TextEditor *editor, HDC hDC)
} else {
c->dpi.cx = c->dpi.cy = 96;
}
if (editor->nAvailWidth)
c->nAvailWidth = ME_twips2pointsX(c, editor->nAvailWidth);
else
c->nAvailWidth = c->rcView.right - c->rcView.left;
}
void ME_DestroyContext(ME_Context *c)
......
......@@ -4332,14 +4332,23 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
if (wParam == 0)
{
BOOL new = (lParam == 0);
if (editor->bWordWrap != new)
if (editor->nAvailWidth || editor->bWordWrap != new)
{
editor->bWordWrap = new;
editor->nAvailWidth = 0; /* wrap to client area */
ME_RewrapRepaint(editor);
}
} else {
int width = max(0, lParam);
if (!editor->bWordWrap || editor->nAvailWidth != width)
{
editor->nAvailWidth = width;
editor->bWordWrap = TRUE;
ME_RewrapRepaint(editor);
}
FIXME("EM_SETTARGETDEVICE doesn't use non-NULL target devices\n");
}
else FIXME("Unsupported yet non NULL device in EM_SETTARGETDEVICE\n");
break;
return TRUE;
default:
do_default:
*phresult = S_FALSE;
......
......@@ -342,6 +342,7 @@ typedef struct tagME_TextEditor
SIZE sizeWindow;
int nTotalLength, nLastTotalLength;
int nTotalWidth, nLastTotalWidth;
int nAvailWidth; /* 0 = wrap to client area, else wrap width in twips */
int nUDArrowX;
int nSequence;
COLORREF rgbBackColor;
......@@ -396,6 +397,7 @@ typedef struct tagME_Context
RECT rcView;
HBRUSH hbrMargin;
SIZE dpi;
int nAvailWidth;
/* those are valid inside ME_WrapTextParagraph and related */
POINT ptFirstRun;
......@@ -413,9 +415,9 @@ typedef struct tagME_WrapContext
POINT pt;
BOOL bOverflown, bWordWrap;
ME_DisplayItem *pRowStart;
ME_DisplayItem *pLastSplittableRun;
POINT ptLastSplittableRun;
} ME_WrapContext;
} ME_WrapContext;
#endif
......@@ -5939,12 +5939,12 @@ static void test_word_wrap(void)
/* Test the effect of EM_SETTARGETDEVICE on word wrap. */
res = SendMessage(hwnd, EM_SETTARGETDEVICE, 0, 1);
todo_wine ok(res, "EM_SETTARGETDEVICE failed (returned %d).\n", res);
ok(res, "EM_SETTARGETDEVICE failed (returned %d).\n", res);
pos = SendMessage(hwnd, EM_CHARFROMPOS, 0, (LPARAM) &point);
ok(!pos, "pos=%d indicating word wrap when none is expected.\n", pos);
res = SendMessage(hwnd, EM_SETTARGETDEVICE, 0, 0);
todo_wine ok(res, "EM_SETTARGETDEVICE failed (returned %d).\n", res);
ok(res, "EM_SETTARGETDEVICE failed (returned %d).\n", res);
pos = SendMessage(hwnd, EM_CHARFROMPOS, 0, (LPARAM) &point);
ok(pos, "pos=%d indicating no word wrap when it is expected.\n", pos);
DestroyWindow(hwnd);
......
......@@ -77,7 +77,7 @@ static void ME_BeginRow(ME_WrapContext *wc, ME_DisplayItem *para)
- (wc->nRow ? wc->nLeftMargin : wc->nFirstMargin) - wc->nRightMargin;
wc->bWordWrap = TRUE;
} else {
wc->nAvailWidth = wc->context->rcView.right - wc->context->rcView.left
wc->nAvailWidth = wc->context->nAvailWidth
- (wc->nRow ? wc->nLeftMargin : wc->nFirstMargin) - wc->nRightMargin;
}
wc->pt.x = wc->context->pt.x;
......
......@@ -897,12 +897,12 @@ static void test_word_wrap(void)
/* Test the effect of EM_SETTARGETDEVICE on word wrap. */
res = SendMessage(hwnd, EM_SETTARGETDEVICE, 0, 1);
todo_wine ok(res, "EM_SETTARGETDEVICE failed (returned %d).\n", res);
ok(res, "EM_SETTARGETDEVICE failed (returned %d).\n", res);
pos = SendMessage(hwnd, EM_CHARFROMPOS, 0, (LPARAM) &point);
ok(!pos, "pos=%d indicating word wrap when none is expected.\n", pos);
res = SendMessage(hwnd, EM_SETTARGETDEVICE, 0, 0);
todo_wine ok(res, "EM_SETTARGETDEVICE failed (returned %d).\n", res);
ok(res, "EM_SETTARGETDEVICE failed (returned %d).\n", res);
pos = SendMessage(hwnd, EM_CHARFROMPOS, 0, (LPARAM) &point);
ok(pos, "pos=%d indicating no word wrap when it is expected.\n", pos);
DestroyWindow(hwnd);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment