Commit e73890a7 authored by Matt Finnicum's avatar Matt Finnicum Committed by Alexandre Julliard

riched20: Send EN_LINK notifications. Properly underline / color links.

parent c4d5becd
...@@ -2298,16 +2298,20 @@ LRESULT WINAPI RichEditANSIWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lP ...@@ -2298,16 +2298,20 @@ LRESULT WINAPI RichEditANSIWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lP
SetFocus(hWnd); SetFocus(hWnd);
ME_LButtonDown(editor, (short)LOWORD(lParam), (short)HIWORD(lParam)); ME_LButtonDown(editor, (short)LOWORD(lParam), (short)HIWORD(lParam));
SetCapture(hWnd); SetCapture(hWnd);
ME_LinkNotify(editor,msg,wParam,lParam);
break; break;
case WM_MOUSEMOVE: case WM_MOUSEMOVE:
if (GetCapture() == hWnd) if (GetCapture() == hWnd)
ME_MouseMove(editor, (short)LOWORD(lParam), (short)HIWORD(lParam)); ME_MouseMove(editor, (short)LOWORD(lParam), (short)HIWORD(lParam));
break; break;
ME_LinkNotify(editor,msg,wParam,lParam);
case WM_LBUTTONUP: case WM_LBUTTONUP:
if (GetCapture() == hWnd) if (GetCapture() == hWnd)
ReleaseCapture(); ReleaseCapture();
ME_LinkNotify(editor,msg,wParam,lParam);
break; break;
case WM_LBUTTONDBLCLK: case WM_LBUTTONDBLCLK:
ME_LinkNotify(editor,msg,wParam,lParam);
ME_SelectWord(editor); ME_SelectWord(editor);
break; break;
case WM_CONTEXTMENU: case WM_CONTEXTMENU:
...@@ -2612,6 +2616,37 @@ void ME_SendOldNotify(ME_TextEditor *editor, int nCode) ...@@ -2612,6 +2616,37 @@ void ME_SendOldNotify(ME_TextEditor *editor, int nCode)
SendMessageA(GetParent(hWnd), WM_COMMAND, (nCode<<16)|GetWindowLongW(hWnd, GWLP_ID), (LPARAM)hWnd); SendMessageA(GetParent(hWnd), WM_COMMAND, (nCode<<16)|GetWindowLongW(hWnd, GWLP_ID), (LPARAM)hWnd);
} }
void ME_LinkNotify(ME_TextEditor *editor, UINT msg, WPARAM wParam, LPARAM lParam)
{
int x,y;
ME_Cursor tmpCursor;
ME_Run *tmpRun;
BOOL bNothing;
ENLINK info;
x = (short)LOWORD(lParam);
y = (short)HIWORD(lParam);
ME_FindPixelPos(editor, x, y, &tmpCursor, &bNothing);
tmpRun = &tmpCursor.pRun->member.run;
if (tmpRun->style->fmt.dwMask & CFM_UNDERLINE)
FIXME("CFM_UNDERLINE! GASP!\n");
if (tmpRun->style->fmt.dwEffects & CFE_UNDERLINE)
FIXME("CFE_UNDERLINE! GASP!\n");
if ((tmpRun->style->fmt.dwMask & CFM_LINK)
&& (tmpRun->style->fmt.dwEffects & CFE_LINK))
{ /* The clicked run has CFE_LINK set */
info.nmhdr.hwndFrom = editor->hWnd;
info.nmhdr.idFrom = GetWindowLongW(editor->hWnd, GWLP_ID);
info.nmhdr.code = EN_LINK;
info.msg = msg;
info.wParam = wParam;
info.lParam = lParam;
info.chrg.cpMin = ME_CharOfsFromRunOfs(editor,tmpCursor.pRun,0);
info.chrg.cpMax = info.chrg.cpMin + ME_StrVLen(tmpRun->strText);
SendMessageW(GetParent(editor->hWnd), WM_NOTIFY,info.nmhdr.idFrom, (LPARAM)&info);
}
}
int ME_CountParagraphsBetween(ME_TextEditor *editor, int from, int to) int ME_CountParagraphsBetween(ME_TextEditor *editor, int from, int to)
{ {
ME_DisplayItem *item = ME_FindItemFwd(editor->pBuffer->pFirst, diParagraph); ME_DisplayItem *item = ME_FindItemFwd(editor->pBuffer->pFirst, diParagraph);
...@@ -2840,9 +2875,8 @@ int ME_AutoURLDetect(ME_TextEditor *editor, WCHAR curChar) ...@@ -2840,9 +2875,8 @@ int ME_AutoURLDetect(ME_TextEditor *editor, WCHAR curChar)
RichEditANSIWndProc(editor->hWnd, EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM) &cur_format); RichEditANSIWndProc(editor->hWnd, EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM) &cur_format);
RichEditANSIWndProc(editor->hWnd, EM_GETCHARFORMAT, SCF_DEFAULT, (LPARAM) &default_format); RichEditANSIWndProc(editor->hWnd, EM_GETCHARFORMAT, SCF_DEFAULT, (LPARAM) &default_format);
link.cbSize = sizeof(link); link.cbSize = sizeof(link);
link.dwMask = CFM_LINK | CFM_COLOR | CFM_UNDERLINE; link.dwMask = CFM_LINK;
link.dwEffects = CFE_LINK | CFE_UNDERLINE; link.dwEffects = CFE_LINK;
link.crTextColor = RGB(0,0,255);
curf_ef = cur_format.dwEffects & link.dwEffects; curf_ef = cur_format.dwEffects & link.dwEffects;
def_ef = default_format.dwEffects & link.dwEffects; def_ef = default_format.dwEffects & link.dwEffects;
link_ef = link.dwEffects & link.dwEffects; link_ef = link.dwEffects & link.dwEffects;
......
...@@ -247,6 +247,7 @@ void ME_RegisterEditorClass(HINSTANCE hInstance); ...@@ -247,6 +247,7 @@ void ME_RegisterEditorClass(HINSTANCE hInstance);
ME_TextEditor *ME_MakeEditor(HWND hWnd); ME_TextEditor *ME_MakeEditor(HWND hWnd);
void ME_DestroyEditor(ME_TextEditor *editor); void ME_DestroyEditor(ME_TextEditor *editor);
void ME_SendOldNotify(ME_TextEditor *editor, int nCode); void ME_SendOldNotify(ME_TextEditor *editor, int nCode);
void ME_LinkNotify(ME_TextEditor *editor, UINT msg, WPARAM wParam, LPARAM lParam);
ME_UndoItem *ME_AddUndoItem(ME_TextEditor *editor, ME_DIType type, ME_DisplayItem *di); ME_UndoItem *ME_AddUndoItem(ME_TextEditor *editor, ME_DIType type, ME_DisplayItem *di);
void ME_CommitUndo(ME_TextEditor *editor); void ME_CommitUndo(ME_TextEditor *editor);
void ME_Undo(ME_TextEditor *editor); void ME_Undo(ME_TextEditor *editor);
......
...@@ -138,7 +138,9 @@ static void ME_DrawTextWithStyle(ME_Context *c, int x, int y, LPCWSTR szText, in ...@@ -138,7 +138,9 @@ static void ME_DrawTextWithStyle(ME_Context *c, int x, int y, LPCWSTR szText, in
int yOffset = 0, yTwipsOffset = 0; int yOffset = 0, yTwipsOffset = 0;
hOldFont = ME_SelectStyleFont(c->editor, hDC, s); hOldFont = ME_SelectStyleFont(c->editor, hDC, s);
rgbBack = ME_GetBackColor(c->editor); rgbBack = ME_GetBackColor(c->editor);
if ((s->fmt.dwMask & CFM_COLOR) && (s->fmt.dwEffects & CFE_AUTOCOLOR)) if ((s->fmt.dwMask & CFM_LINK) && (s->fmt.dwEffects & CFE_LINK))
rgbOld = SetTextColor(hDC, RGB(0,0,255));
else if ((s->fmt.dwMask & CFM_COLOR) && (s->fmt.dwEffects & CFE_AUTOCOLOR))
rgbOld = SetTextColor(hDC, GetSysColor(COLOR_WINDOWTEXT)); rgbOld = SetTextColor(hDC, GetSysColor(COLOR_WINDOWTEXT));
else else
rgbOld = SetTextColor(hDC, s->fmt.crTextColor); rgbOld = SetTextColor(hDC, s->fmt.crTextColor);
......
...@@ -275,7 +275,7 @@ ME_LogFontFromStyle(HDC hDC, LOGFONTW *lf, ME_Style *s, int nZoomNumerator, int ...@@ -275,7 +275,7 @@ ME_LogFontFromStyle(HDC hDC, LOGFONTW *lf, ME_Style *s, int nZoomNumerator, int
lf->lfWeight = s->fmt.wWeight; lf->lfWeight = s->fmt.wWeight;
if (s->fmt.dwEffects & s->fmt.dwMask & CFM_ITALIC) if (s->fmt.dwEffects & s->fmt.dwMask & CFM_ITALIC)
lf->lfItalic = 1; lf->lfItalic = 1;
if (s->fmt.dwEffects & s->fmt.dwMask & CFM_UNDERLINE) if (s->fmt.dwEffects & s->fmt.dwMask & (CFM_UNDERLINE | CFE_LINK))
lf->lfUnderline = 1; lf->lfUnderline = 1;
if (s->fmt.dwEffects & s->fmt.dwMask & CFM_STRIKEOUT) if (s->fmt.dwEffects & s->fmt.dwMask & CFM_STRIKEOUT)
lf->lfStrikeOut = 1; lf->lfStrikeOut = 1;
...@@ -301,6 +301,8 @@ void ME_CharFormatFromLogFont(HDC hDC, LOGFONTW *lf, CHARFORMAT2W *fmt) ...@@ -301,6 +301,8 @@ void ME_CharFormatFromLogFont(HDC hDC, LOGFONTW *lf, CHARFORMAT2W *fmt)
if (lf->lfWeight>400) fmt->dwEffects |= CFM_BOLD; if (lf->lfWeight>400) fmt->dwEffects |= CFM_BOLD;
if (lf->lfItalic) fmt->dwEffects |= CFM_ITALIC; if (lf->lfItalic) fmt->dwEffects |= CFM_ITALIC;
if (lf->lfUnderline) fmt->dwEffects |= CFM_UNDERLINE; if (lf->lfUnderline) fmt->dwEffects |= CFM_UNDERLINE;
/* notice that if a logfont was created with underline due to CFM_LINK, this
would add an erronious CFM_UNDERLINE. This isn't currently ever a problem */
if (lf->lfStrikeOut) fmt->dwEffects |= CFM_STRIKEOUT; if (lf->lfStrikeOut) fmt->dwEffects |= CFM_STRIKEOUT;
fmt->bPitchAndFamily = lf->lfPitchAndFamily; fmt->bPitchAndFamily = lf->lfPitchAndFamily;
fmt->bCharSet = lf->lfCharSet; fmt->bCharSet = lf->lfCharSet;
......
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