diff options
Diffstat (limited to 'src/modules/utils/hyperlink.cpp')
-rw-r--r-- | src/modules/utils/hyperlink.cpp | 64 |
1 files changed, 32 insertions, 32 deletions
diff --git a/src/modules/utils/hyperlink.cpp b/src/modules/utils/hyperlink.cpp index 7ed16f6857..cb7a117845 100644 --- a/src/modules/utils/hyperlink.cpp +++ b/src/modules/utils/hyperlink.cpp @@ -43,16 +43,16 @@ static LRESULT CALLBACK HyperlinkWndProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM switch(msg) {
case WM_NCCREATE:
dat=(struct HyperlinkWndData*)mir_calloc(sizeof(struct HyperlinkWndData));
- if(dat==NULL) return FALSE; /* fail creation */
+ if (dat==NULL) return FALSE; /* fail creation */
SetWindowLongPtr(hwnd,0,(LONG_PTR)dat); /* always succeeds */
/* fall thru */
case WM_SYSCOLORCHANGE:
- if(!(dat->flags&HLKF_HASENABLECOLOR)) {
- if(GetSysColorBrush(COLOR_HOTLIGHT)==NULL) dat->enableColor=RGB(0,0,255);
+ if (!(dat->flags&HLKF_HASENABLECOLOR)) {
+ if (GetSysColorBrush(COLOR_HOTLIGHT)==NULL) dat->enableColor=RGB(0,0,255);
else dat->enableColor=GetSysColor(COLOR_HOTLIGHT);
dat->focusColor = RGB(GetRValue(dat->enableColor) / 2, GetGValue(dat->enableColor) / 2, GetBValue(dat->enableColor) / 2);
}
- if(!(dat->flags&HLKF_HASDISABLECOLOR))
+ if (!(dat->flags&HLKF_HASDISABLECOLOR))
dat->disableColor=GetSysColor(COLOR_GRAYTEXT);
break;
@@ -101,24 +101,24 @@ static LRESULT CALLBACK HyperlinkWndProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM case WM_LBUTTONDOWN:
{ POINT pt;
POINTSTOPOINT(pt,MAKEPOINTS(lParam));
- if(!PtInRect(&dat->rcText,pt)) break;
+ if (!PtInRect(&dat->rcText,pt)) break;
SendMessage(GetParent(hwnd),WM_COMMAND,MAKEWPARAM(GetDlgCtrlID(hwnd),STN_CLICKED),(LPARAM)hwnd);
return 0;
}
case WM_SETFONT:
{ LOGFONT lf;
HFONT hFont;
- if((HFONT)wParam==NULL) { /* use default system color */
+ if ((HFONT)wParam==NULL) { /* use default system color */
dat->hEnableFont=dat->hDisableFont=NULL;
return 0;
}
- if(GetObject((HFONT)wParam,sizeof(lf),&lf)) {
+ if (GetObject((HFONT)wParam,sizeof(lf),&lf)) {
lf.lfUnderline=1;
hFont=CreateFontIndirect(&lf);
- if(hFont!=NULL) {
+ if (hFont!=NULL) {
dat->hEnableFont=hFont;
dat->hDisableFont=(HFONT)wParam;
- if(LOWORD(lParam)) SendMessage(hwnd,HLK_INVALIDATE,0,0);
+ if (LOWORD(lParam)) SendMessage(hwnd,HLK_INVALIDATE,0,0);
SendMessage(hwnd,HLK_MEASURETEXT,0,0);
}
}
@@ -131,12 +131,12 @@ static LRESULT CALLBACK HyperlinkWndProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM { RECT rcWnd;
POINT pt;
HWND hwndParent;
- if(!GetWindowRect(hwnd,&rcWnd)) break;
+ if (!GetWindowRect(hwnd,&rcWnd)) break;
pt.x=rcWnd.left;
pt.y=rcWnd.top;
hwndParent=GetParent(hwnd);
- if(hwndParent==NULL) hwndParent=hwnd;
- if(!ScreenToClient(hwndParent,&pt)) break;
+ if (hwndParent==NULL) hwndParent=hwnd;
+ if (!ScreenToClient(hwndParent,&pt)) break;
rcWnd.right=pt.x+(rcWnd.right-rcWnd.left);
rcWnd.bottom=pt.y+(rcWnd.bottom-rcWnd.top);
rcWnd.left=pt.x;
@@ -149,7 +149,7 @@ static LRESULT CALLBACK HyperlinkWndProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM case WM_CREATE:
case HLK_MEASURETEXT:
{ TCHAR szText[256];
- if(!GetWindowText(hwnd,szText,SIZEOF(szText))) return 0;
+ if (!GetWindowText(hwnd,szText,SIZEOF(szText))) return 0;
lParam=(LPARAM)szText;
/* fall thru */
case WM_SETTEXT:
@@ -160,34 +160,34 @@ static LRESULT CALLBACK HyperlinkWndProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM LONG style;
BOOL fMeasured=FALSE;
hdc=GetDC(hwnd);
- if(hdc==NULL) return 0; /* text change failed */
- if(dat->hEnableFont!=NULL) hPrevFont=(HFONT)SelectObject(hdc,dat->hEnableFont);
- if(dat->hEnableFont==NULL || hPrevFont!=NULL) /* select failed? */
- if(GetTextExtentPoint32(hdc,(TCHAR*)lParam,lstrlen((TCHAR*)lParam),&textSize))
- if(GetClientRect(hwnd,&rc)) {
+ if (hdc==NULL) return 0; /* text change failed */
+ if (dat->hEnableFont!=NULL) hPrevFont=(HFONT)SelectObject(hdc,dat->hEnableFont);
+ if (dat->hEnableFont==NULL || hPrevFont!=NULL) /* select failed? */
+ if (GetTextExtentPoint32(hdc,(TCHAR*)lParam,lstrlen((TCHAR*)lParam),&textSize))
+ if (GetClientRect(hwnd,&rc)) {
dat->rcText.top=0;
dat->rcText.bottom=dat->rcText.top+textSize.cy;
style=GetWindowLongPtr(hwnd,GWL_STYLE);
- if(style&SS_CENTER) dat->rcText.left=(rc.right-textSize.cx)/2;
- else if(style&SS_RIGHT) dat->rcText.left=rc.right-textSize.cx;
+ if (style&SS_CENTER) dat->rcText.left=(rc.right-textSize.cx)/2;
+ else if (style&SS_RIGHT) dat->rcText.left=rc.right-textSize.cx;
else dat->rcText.left=0;
dat->rcText.right=dat->rcText.left+textSize.cx;
fMeasured=TRUE;
}
- if(dat->hEnableFont!=NULL && hPrevFont!=NULL) SelectObject(hdc,hPrevFont);
+ if (dat->hEnableFont!=NULL && hPrevFont!=NULL) SelectObject(hdc,hPrevFont);
ReleaseDC(hwnd,hdc);
- if(!fMeasured) return 0; /* text change failed */
+ if (!fMeasured) return 0; /* text change failed */
SendMessage(hwnd,HLK_INVALIDATE,0,0);
break;
}}
case WM_SETCURSOR:
{ POINT pt;
HCURSOR hCursor;
- if(!GetCursorPos(&pt)) return FALSE;
- if(!ScreenToClient(hwnd,&pt)) return FALSE;
- if(PtInRect(&dat->rcText,pt)) {
+ if (!GetCursorPos(&pt)) return FALSE;
+ if (!ScreenToClient(hwnd,&pt)) return FALSE;
+ if (PtInRect(&dat->rcText,pt)) {
hCursor=(HCURSOR)GetClassLongPtr(hwnd,GCLP_HCURSOR);
- if(hCursor==NULL) hCursor=LoadCursor(NULL,IDC_HAND); /* Win2000+ */
+ if (hCursor==NULL) hCursor=LoadCursor(NULL,IDC_HAND); /* Win2000+ */
}
else hCursor=LoadCursor(NULL,IDC_ARROW);
SetCursor(hCursor);
@@ -218,15 +218,15 @@ static LRESULT CALLBACK HyperlinkWndProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM HDC hdc;
hdc=BeginPaint(hwnd,&ps);
- if(hdc!=NULL) {
- if(IsWindowEnabled(hwnd)) {
+ if (hdc!=NULL) {
+ if (IsWindowEnabled(hwnd)) {
hPrevFont=(HFONT)SelectObject(hdc,dat->hEnableFont);
textColor = (GetFocus() == hwnd) ? dat->focusColor : dat->enableColor;
} else {
hPrevFont=(HFONT)SelectObject(hdc,dat->hDisableFont);
textColor=dat->disableColor;
}
- if(GetClientRect(hwnd,&rc) && GetWindowText(hwnd,szText,SIZEOF(szText))) {
+ if (GetClientRect(hwnd,&rc) && GetWindowText(hwnd,szText,SIZEOF(szText))) {
if (drawThemeParentBackground && IsWinVerXPPlus())
{
BOOL fSmoothing;
@@ -241,13 +241,13 @@ static LRESULT CALLBACK HyperlinkWndProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM alignFlag=(GetWindowLongPtr(hwnd,GWL_STYLE)&(SS_CENTER|SS_RIGHT|SS_LEFT));
DrawText(hdc,szText,-1,&rc,alignFlag|DT_NOPREFIX|DT_SINGLELINE|DT_TOP);
}
- if(hPrevFont!=NULL) SelectObject(hdc,hPrevFont);
+ if (hPrevFont!=NULL) SelectObject(hdc,hPrevFont);
EndPaint(hwnd,&ps);
}
return 0;
}
case WM_NCDESTROY:
- if(dat->hEnableFont!=NULL) DeleteObject(dat->hEnableFont);
+ if (dat->hEnableFont!=NULL) DeleteObject(dat->hEnableFont);
mir_free(dat);
break;
}
@@ -262,7 +262,7 @@ int InitHyperlink(void) wcl.cbClsExtra=0;
wcl.cbWndExtra=sizeof(struct HyperlinkWndData*);
wcl.hInstance=hMirandaInst;
- if(IsWinVer2000Plus()) wcl.hCursor=NULL;
+ if (IsWinVer2000Plus()) wcl.hCursor=NULL;
else wcl.hCursor=LoadCursor(wcl.hInstance,MAKEINTRESOURCE(IDC_HYPERLINKHAND));
wcl.lpszClassName=WNDCLASS_HYPERLINK;
wcl.hbrBackground=NULL;
|