Commit 05c788ac authored by Dylan Smith's avatar Dylan Smith Committed by Alexandre Julliard

richedit: Used ITextHost methods to avoid using window handle directly.

The methods in ITextHost are mostly thin wrappers around functions that take a handle to a window as their first parameter. This patch just uses the wrapper functions provided by ITextHost instead of using the functions that require a handle to a window that the editor might now have (for windowless richedit controls).
parent 6c4dda00
......@@ -173,7 +173,7 @@ ME_GetCursorCoordinates(ME_TextEditor *editor, ME_Cursor *pCursor,
ME_DisplayItem *row = ME_FindItemBack(pCursorRun, diStartRowOrParagraph);
if (row) {
HDC hDC = GetDC(editor->hWnd);
HDC hDC = ITextHost_TxGetDC(editor->texthost);
ME_Context c;
ME_DisplayItem *run = pCursorRun;
ME_DisplayItem *para = NULL;
......@@ -217,7 +217,7 @@ ME_GetCursorCoordinates(ME_TextEditor *editor, ME_Cursor *pCursor,
*x = c.rcView.left + run->member.run.pt.x + sz.cx - editor->horz_si.nPos;
*y = c.rcView.top + para->member.para.pt.y + row->member.row.nBaseline
+ run->member.run.pt.y - pSizeRun->member.run.nAscent - editor->vert_si.nPos;
ME_DestroyContext(&c, editor->hWnd);
ME_DestroyContext(&c);
return;
}
}
......@@ -238,8 +238,8 @@ ME_MoveCaret(ME_TextEditor *editor)
if(editor->bHaveFocus && !ME_IsSelection(editor))
{
x = min(x, editor->rcFormat.right-1);
CreateCaret(editor->hWnd, NULL, 0, height);
SetCaretPos(x, y);
ITextHost_TxCreateCaret(editor->texthost, NULL, 0, height);
ITextHost_TxSetCaretPos(editor->texthost, x, y);
}
}
......@@ -248,14 +248,14 @@ void ME_ShowCaret(ME_TextEditor *ed)
{
ME_MoveCaret(ed);
if(ed->bHaveFocus && !ME_IsSelection(ed))
ShowCaret(ed->hWnd);
ITextHost_TxShowCaret(ed->texthost, TRUE);
}
void ME_HideCaret(ME_TextEditor *ed)
{
if(!ed->bHaveFocus || ME_IsSelection(ed))
{
HideCaret(ed->hWnd);
ITextHost_TxShowCaret(ed->texthost, FALSE);
DestroyCaret();
}
}
......@@ -1020,7 +1020,7 @@ int ME_CharFromPos(ME_TextEditor *editor, int x, int y, BOOL *isExact)
RECT rc;
BOOL bResult;
GetClientRect(editor->hWnd, &rc);
ITextHost_TxGetClientRect(editor->texthost, &rc);
if (x < 0 || y < 0 || x >= rc.right || y >= rc.bottom) {
if (isExact) *isExact = FALSE;
return -1;
......@@ -1154,7 +1154,7 @@ void ME_LButtonDown(ME_TextEditor *editor, int x, int y, int clickNum)
}
}
ME_InvalidateSelection(editor);
HideCaret(editor->hWnd);
ITextHost_TxShowCaret(editor->texthost, FALSE);
ME_ShowCaret(editor);
ME_ClearTempStyle(editor);
ME_SendSelChange(editor);
......@@ -1188,7 +1188,7 @@ void ME_MouseMove(ME_TextEditor *editor, int x, int y)
}
ME_InvalidateSelection(editor);
HideCaret(editor->hWnd);
ITextHost_TxShowCaret(editor->texthost, FALSE);
ME_ShowCaret(editor);
ME_SendSelChange(editor);
}
......@@ -1574,7 +1574,7 @@ void ME_SendSelChange(ME_TextEditor *editor)
ME_ClearTempStyle(editor);
editor->notified_cr = sc.chrg;
SendMessageW(GetParent(editor->hWnd), WM_NOTIFY, sc.nmhdr.idFrom, (LPARAM)&sc);
ITextHost_TxNotify(editor->texthost, sc.nmhdr.code, &sc);
}
}
......@@ -1636,7 +1636,7 @@ ME_ArrowKey(ME_TextEditor *editor, int nVKey, BOOL extend, BOOL ctrl)
ME_InvalidateSelection(editor);
ME_Repaint(editor);
HideCaret(editor->hWnd);
ITextHost_TxShowCaret(editor->texthost, FALSE);
ME_EnsureVisible(editor, &tmp_curs);
ME_ShowCaret(editor);
ME_SendSelChange(editor);
......
......@@ -33,8 +33,8 @@ void ME_InitContext(ME_Context *c, ME_TextEditor *editor, HDC hDC)
c->dpi.cy = GetDeviceCaps(hDC, LOGPIXELSY);
}
void ME_DestroyContext(ME_Context *c, HWND hWnd)
void ME_DestroyContext(ME_Context *c)
{
if (hWnd) ReleaseDC(hWnd, c->hDC);
if (c->hDC) ITextHost_TxReleaseDC(c->editor->texthost, c->hDC);
DeleteObject(c->hbrMargin);
}
......@@ -203,7 +203,7 @@ ME_Style *ME_GetSelectionInsertStyle(ME_TextEditor *editor);
/* context.c */
void ME_InitContext(ME_Context *c, ME_TextEditor *editor, HDC hDC);
void ME_DestroyContext(ME_Context *c, HWND release);
void ME_DestroyContext(ME_Context *c);
/* wrap.c */
BOOL ME_WrapMarkedParagraphs(ME_TextEditor *editor);
......
......@@ -116,11 +116,13 @@ void ME_PaintContent(ME_TextEditor *editor, HDC hDC, BOOL bOnlyNew, const RECT *
ME_SendRequestResize(editor, FALSE);
editor->nLastTotalLength = editor->nTotalLength;
editor->nLastTotalWidth = editor->nTotalWidth;
ME_DestroyContext(&c, NULL);
SelectClipRgn(hDC, oldRgn);
if (oldRgn)
DeleteObject(oldRgn);
c.hDC = NULL;
ME_DestroyContext(&c);
}
void ME_Repaint(ME_TextEditor *editor)
......@@ -130,11 +132,9 @@ void ME_Repaint(ME_TextEditor *editor)
ME_UpdateScrollBar(editor);
FIXME("ME_Repaint had to call ME_WrapMarkedParagraphs\n");
}
if (!IsWindowVisible(editor->hWnd))
return;
if (!editor->bEmulateVersion10 || (editor->nEventMask & ENM_UPDATE))
ME_SendOldNotify(editor, EN_UPDATE);
UpdateWindow(editor->hWnd);
ITextHost_TxViewChange(editor->texthost, TRUE);
}
void ME_UpdateRepaint(ME_TextEditor *editor)
......@@ -232,7 +232,8 @@ static void ME_HighlightSpace(ME_Context *c, int x, int y, LPCWSTR szText,
rect.top = ymin;
rect.right = x + selWidth;
rect.bottom = ymin + cy;
hBrush = CreateSolidBrush(GetSysColor(COLOR_HIGHLIGHT));
hBrush = CreateSolidBrush(ITextHost_TxGetSysColor(c->editor->texthost,
COLOR_HIGHLIGHT));
FillRect(hDC, &rect, hBrush);
DeleteObject(hBrush);
}
......@@ -274,7 +275,7 @@ static void ME_DrawTextWithStyle(ME_Context *c, int x, int y, LPCWSTR szText,
if ((s->fmt.dwMask & CFM_LINK) && (s->fmt.dwEffects & CFE_LINK))
rgb = RGB(0,0,255);
else if ((s->fmt.dwMask & CFM_COLOR) && (s->fmt.dwEffects & CFE_AUTOCOLOR))
rgb = GetSysColor(COLOR_WINDOWTEXT);
rgb = ITextHost_TxGetSysColor(c->editor->texthost, COLOR_WINDOWTEXT);
else
rgb = s->fmt.crTextColor;
......@@ -351,8 +352,10 @@ static void ME_DrawTextWithStyle(ME_Context *c, int x, int y, LPCWSTR szText,
dim.bottom = ymin + cy;
dim.left = xSelStart;
dim.right = xSelEnd;
SetTextColor(hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
rgbBackOld = SetBkColor(hDC, GetSysColor(COLOR_HIGHLIGHT));
SetTextColor(hDC, ITextHost_TxGetSysColor(c->editor->texthost,
COLOR_HIGHLIGHTTEXT));
rgbBackOld = SetBkColor(hDC, ITextHost_TxGetSysColor(c->editor->texthost,
COLOR_HIGHLIGHT));
ExtTextOutW(hDC, xSelStart, y-yOffset, ETO_OPAQUE, &dim,
szText+nSelFrom, nSelTo-nSelFrom, lpDx);
if (hPen)
......@@ -625,7 +628,8 @@ static void ME_DrawParaDecoration(ME_Context* c, ME_Paragraph* para, int y, RECT
POINT pt;
if (para->pFmt->wBorders & 64) /* autocolor */
pencr = GetSysColor(COLOR_WINDOWTEXT);
pencr = ITextHost_TxGetSysColor(c->editor->texthost,
COLOR_WINDOWTEXT);
else
pencr = pen_colors[(para->pFmt->wBorders >> 12) & 0xF];
......@@ -1039,7 +1043,7 @@ void ME_ScrollAbs(ME_TextEditor *editor, int x, int y)
if (editor->horz_si.nPos != x) {
x = min(x, editor->horz_si.nMax);
x = max(x, editor->horz_si.nMin);
SetScrollPos(editor->hWnd, SB_HORZ, x, TRUE);
ITextHost_TxSetScrollPos(editor->texthost, SB_HORZ, x, TRUE);
scrollX = editor->horz_si.nPos - x;
editor->horz_si.nPos = x;
}
......@@ -1047,17 +1051,18 @@ void ME_ScrollAbs(ME_TextEditor *editor, int x, int y)
if (editor->vert_si.nPos != y) {
y = min(y, editor->vert_si.nMax - (int)editor->vert_si.nPage);
y = max(y, editor->vert_si.nMin);
SetScrollPos(editor->hWnd, SB_VERT, y, TRUE);
ITextHost_TxSetScrollPos(editor->texthost, SB_VERT, y, TRUE);
scrollY = editor->vert_si.nPos - y;
editor->vert_si.nPos = y;
}
if (abs(scrollX) > editor->sizeWindow.cx ||
abs(scrollY) > editor->sizeWindow.cy)
InvalidateRect(editor->hWnd, NULL, TRUE);
ITextHost_TxInvalidateRect(editor->texthost, NULL, TRUE);
else
ScrollWindowEx(editor->hWnd, scrollX, scrollY, &editor->rcFormat,
&editor->rcFormat, NULL, NULL, SW_INVALIDATE);
ITextHost_TxScrollWindowEx(editor->texthost, scrollX, scrollY,
&editor->rcFormat, &editor->rcFormat,
NULL, NULL, SW_INVALIDATE);
ME_Repaint(editor);
winStyle = GetWindowLongW(editor->hWnd, GWL_STYLE);
......@@ -1065,14 +1070,15 @@ void ME_ScrollAbs(ME_TextEditor *editor, int x, int y)
bScrollBarWillBeVisible = (editor->nTotalWidth > editor->sizeWindow.cx)
|| (editor->styleFlags & ES_DISABLENOSCROLL);
if (bScrollBarIsVisible != bScrollBarWillBeVisible)
ShowScrollBar(editor->hWnd, SB_HORZ, bScrollBarWillBeVisible);
ITextHost_TxShowScrollBar(editor->texthost, SB_HORZ,
bScrollBarWillBeVisible);
bScrollBarIsVisible = (winStyle & WS_VSCROLL) != 0;
bScrollBarWillBeVisible = (editor->nTotalLength > editor->sizeWindow.cy)
|| (editor->styleFlags & ES_DISABLENOSCROLL);
if (bScrollBarIsVisible != bScrollBarWillBeVisible)
ShowScrollBar(editor->hWnd, SB_VERT, bScrollBarWillBeVisible);
ITextHost_TxShowScrollBar(editor->texthost, SB_VERT,
bScrollBarWillBeVisible);
ME_UpdateScrollBar(editor);
}
......@@ -1154,7 +1160,7 @@ void ME_UpdateScrollBar(ME_TextEditor *editor)
bScrollBarWillBeVisible = TRUE;
if (bScrollBarWasVisible != bScrollBarWillBeVisible)
ShowScrollBar(editor->hWnd, SB_HORZ, bScrollBarWillBeVisible);
ITextHost_TxShowScrollBar(editor->texthost, SB_HORZ, bScrollBarWillBeVisible);
/* Update vertical scrollbar */
bScrollBarWasVisible = editor->vert_si.nMax > editor->vert_si.nPage;
......@@ -1188,7 +1194,8 @@ void ME_UpdateScrollBar(ME_TextEditor *editor)
bScrollBarWillBeVisible = TRUE;
if (bScrollBarWasVisible != bScrollBarWillBeVisible)
ShowScrollBar(editor->hWnd, SB_VERT, bScrollBarWillBeVisible);
ITextHost_TxShowScrollBar(editor->texthost, SB_VERT,
bScrollBarWillBeVisible);
}
void ME_EnsureVisible(ME_TextEditor *editor, ME_Cursor *pCursor)
......@@ -1233,7 +1240,7 @@ ME_InvalidateFromOfs(ME_TextEditor *editor, int nCharOfs)
rc.top = y;
rc.bottom = y + height;
rc.right = editor->rcFormat.right;
InvalidateRect(editor->hWnd, &rc, FALSE);
ITextHost_TxInvalidateRect(editor->texthost, &rc, FALSE);
}
......
......@@ -36,7 +36,7 @@ void ME_MakeFirstParagraph(ME_TextEditor *editor)
ME_DisplayItem *run;
ME_Style *style;
ME_InitContext(&c, editor, GetDC(editor->hWnd));
ME_InitContext(&c, editor, ITextHost_TxGetDC(editor->texthost));
hf = GetStockObject(SYSTEM_FONT);
assert(hf);
......@@ -78,7 +78,7 @@ void ME_MakeFirstParagraph(ME_TextEditor *editor)
text->pLast->member.para.nCharOfs = editor->bEmulateVersion10 ? 2 : 1;
ME_DestroyContext(&c, editor->hWnd);
ME_DestroyContext(&c);
}
static void ME_MarkForWrapping(ME_TextEditor *editor, ME_DisplayItem *first, const ME_DisplayItem *last)
......
......@@ -550,12 +550,12 @@ int ME_CharFromPointCursor(ME_TextEditor *editor, int cx, ME_Run *run)
return 0;
return 1;
}
ME_InitContext(&c, editor, GetDC(editor->hWnd));
ME_InitContext(&c, editor, ITextHost_TxGetDC(editor->texthost));
if (run->nFlags & MERF_GRAPHICS)
{
SIZE sz;
ME_GetOLEObjectSize(&c, run, &sz);
ME_DestroyContext(&c, editor->hWnd);
ME_DestroyContext(&c);
if (cx < sz.cx/2)
return 0;
return 1;
......@@ -584,7 +584,7 @@ int ME_CharFromPointCursor(ME_TextEditor *editor, int cx, ME_Run *run)
ME_DestroyString(strRunText);
ME_UnselectStyleFont(&c, run->style, hOldFont);
ME_DestroyContext(&c, editor->hWnd);
ME_DestroyContext(&c);
return fit;
}
......@@ -614,12 +614,12 @@ int ME_PointFromChar(ME_TextEditor *editor, ME_Run *pRun, int nOffset)
ME_String *strRunText;
/* This could point to either the run's real text, or it's masked form in a password control */
ME_InitContext(&c, editor, GetDC(editor->hWnd));
ME_InitContext(&c, editor, ITextHost_TxGetDC(editor->texthost));
if (pRun->nFlags & MERF_GRAPHICS)
{
if (nOffset)
ME_GetOLEObjectSize(&c, pRun, &size);
ReleaseDC(editor->hWnd, c.hDC);
ITextHost_TxReleaseDC(editor->texthost, c.hDC);
return nOffset != 0;
}
......@@ -629,7 +629,7 @@ int ME_PointFromChar(ME_TextEditor *editor, ME_Run *pRun, int nOffset)
strRunText = pRun->strText;
ME_GetTextExtent(&c, strRunText->szData, nOffset, pRun->style, &size);
ReleaseDC(editor->hWnd, c.hDC);
ITextHost_TxReleaseDC(editor->texthost, c.hDC);
if (editor->cPasswordMask)
ME_DestroyString(strRunText);
return size.cx;
......
......@@ -581,7 +581,7 @@ void ME_TabPressedInTable(ME_TextEditor *editor, BOOL bSelectedRow)
}
ME_InvalidateSelection(editor);
ME_Repaint(editor);
HideCaret(editor->hWnd);
ITextHost_TxShowCaret(editor->texthost, FALSE);
ME_ShowCaret(editor);
ME_SendSelChange(editor);
}
......
......@@ -582,7 +582,7 @@ BOOL ME_WrapMarkedParagraphs(ME_TextEditor *editor)
int yStart = -1;
int totalWidth = 0;
ME_InitContext(&c, editor, GetDC(editor->hWnd));
ME_InitContext(&c, editor, ITextHost_TxGetDC(editor->texthost));
c.pt.x = 0;
item = editor->pBuffer->pFirst->next;
while(item != editor->pBuffer->pLast) {
......@@ -723,7 +723,7 @@ BOOL ME_WrapMarkedParagraphs(ME_TextEditor *editor)
editor->pBuffer->pLast->member.para.pt.x = 0;
editor->pBuffer->pLast->member.para.pt.y = c.pt.y;
ME_DestroyContext(&c, editor->hWnd);
ME_DestroyContext(&c);
if (bModified || editor->nTotalLength < editor->nLastTotalLength)
ME_InvalidateMarkedParagraphs(editor);
......@@ -737,7 +737,7 @@ void ME_InvalidateMarkedParagraphs(ME_TextEditor *editor)
int ofs;
ME_DisplayItem *item;
ME_InitContext(&c, editor, GetDC(editor->hWnd));
ME_InitContext(&c, editor, ITextHost_TxGetDC(editor->texthost));
rc = c.rcView;
ofs = editor->vert_si.nPos;
......@@ -748,7 +748,7 @@ void ME_InvalidateMarkedParagraphs(ME_TextEditor *editor)
rc.bottom = max(c.rcView.top + item->member.para.pt.y
+ item->member.para.nHeight - ofs,
c.rcView.bottom);
InvalidateRect(editor->hWnd, &rc, TRUE);
ITextHost_TxInvalidateRect(editor->texthost, &rc, TRUE);
}
item = item->member.para.next_para;
}
......@@ -756,9 +756,9 @@ void ME_InvalidateMarkedParagraphs(ME_TextEditor *editor)
{
rc.top = c.rcView.top + editor->nTotalLength - ofs;
rc.bottom = c.rcView.top + editor->nLastTotalLength - ofs;
InvalidateRect(editor->hWnd, &rc, TRUE);
ITextHost_TxInvalidateRect(editor->texthost, &rc, TRUE);
}
ME_DestroyContext(&c, editor->hWnd);
ME_DestroyContext(&c);
}
......@@ -769,22 +769,19 @@ ME_SendRequestResize(ME_TextEditor *editor, BOOL force)
{
RECT rc;
GetClientRect(editor->hWnd, &rc);
ITextHost_TxGetClientRect(editor->texthost, &rc);
if (force || rc.bottom != editor->nTotalLength)
{
REQRESIZE info;
info.nmhdr.hwndFrom = editor->hWnd;
info.nmhdr.idFrom = GetWindowLongW(editor->hWnd, GWLP_ID);
info.nmhdr.code = EN_REQUESTRESIZE;
info.rc = rc;
info.rc.right = editor->nTotalWidth;
info.rc.bottom = editor->nTotalLength;
editor->nEventMask &= ~ENM_REQUESTRESIZE;
SendMessageW(GetParent(editor->hWnd), WM_NOTIFY,
info.nmhdr.idFrom, (LPARAM)&info);
ITextHost_TxNotify(editor->texthost, info.nmhdr.code, &info);
editor->nEventMask |= ENM_REQUESTRESIZE;
}
}
......
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