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

This commit is contained in:
Matt Finnicum 2006-08-16 22:29:17 -04:00 committed by Alexandre Julliard
parent c4d5becd6f
commit e73890a72c
4 changed files with 44 additions and 5 deletions

View file

@ -2298,16 +2298,20 @@ LRESULT WINAPI RichEditANSIWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lP
SetFocus(hWnd);
ME_LButtonDown(editor, (short)LOWORD(lParam), (short)HIWORD(lParam));
SetCapture(hWnd);
ME_LinkNotify(editor,msg,wParam,lParam);
break;
case WM_MOUSEMOVE:
if (GetCapture() == hWnd)
ME_MouseMove(editor, (short)LOWORD(lParam), (short)HIWORD(lParam));
break;
ME_LinkNotify(editor,msg,wParam,lParam);
case WM_LBUTTONUP:
if (GetCapture() == hWnd)
ReleaseCapture();
ME_LinkNotify(editor,msg,wParam,lParam);
break;
case WM_LBUTTONDBLCLK:
ME_LinkNotify(editor,msg,wParam,lParam);
ME_SelectWord(editor);
break;
case WM_CONTEXTMENU:
@ -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);
}
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)
{
ME_DisplayItem *item = ME_FindItemFwd(editor->pBuffer->pFirst, diParagraph);
@ -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_DEFAULT, (LPARAM) &default_format);
link.cbSize = sizeof(link);
link.dwMask = CFM_LINK | CFM_COLOR | CFM_UNDERLINE;
link.dwEffects = CFE_LINK | CFE_UNDERLINE;
link.crTextColor = RGB(0,0,255);
link.dwMask = CFM_LINK;
link.dwEffects = CFE_LINK;
curf_ef = cur_format.dwEffects & link.dwEffects;
def_ef = default_format.dwEffects & link.dwEffects;
link_ef = link.dwEffects & link.dwEffects;

View file

@ -247,6 +247,7 @@ void ME_RegisterEditorClass(HINSTANCE hInstance);
ME_TextEditor *ME_MakeEditor(HWND hWnd);
void ME_DestroyEditor(ME_TextEditor *editor);
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);
void ME_CommitUndo(ME_TextEditor *editor);
void ME_Undo(ME_TextEditor *editor);

View file

@ -138,7 +138,9 @@ static void ME_DrawTextWithStyle(ME_Context *c, int x, int y, LPCWSTR szText, in
int yOffset = 0, yTwipsOffset = 0;
hOldFont = ME_SelectStyleFont(c->editor, hDC, s);
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));
else
rgbOld = SetTextColor(hDC, s->fmt.crTextColor);

View file

@ -275,7 +275,7 @@ ME_LogFontFromStyle(HDC hDC, LOGFONTW *lf, ME_Style *s, int nZoomNumerator, int
lf->lfWeight = s->fmt.wWeight;
if (s->fmt.dwEffects & s->fmt.dwMask & CFM_ITALIC)
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;
if (s->fmt.dwEffects & s->fmt.dwMask & CFM_STRIKEOUT)
lf->lfStrikeOut = 1;
@ -301,6 +301,8 @@ void ME_CharFormatFromLogFont(HDC hDC, LOGFONTW *lf, CHARFORMAT2W *fmt)
if (lf->lfWeight>400) fmt->dwEffects |= CFM_BOLD;
if (lf->lfItalic) fmt->dwEffects |= CFM_ITALIC;
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;
fmt->bPitchAndFamily = lf->lfPitchAndFamily;
fmt->bCharSet = lf->lfCharSet;