summaryrefslogtreecommitdiff
path: root/plugins/Scriver/src/infobar.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/Scriver/src/infobar.cpp')
-rw-r--r--plugins/Scriver/src/infobar.cpp202
1 files changed, 104 insertions, 98 deletions
diff --git a/plugins/Scriver/src/infobar.cpp b/plugins/Scriver/src/infobar.cpp
index c2e53271c8..e096a01886 100644
--- a/plugins/Scriver/src/infobar.cpp
+++ b/plugins/Scriver/src/infobar.cpp
@@ -23,44 +23,45 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "commonheaders.h"
-void SetupInfobar(InfobarWindowData* idat) {
+void SetupInfobar(InfobarWindowData* idat)
+{
HWND hwnd = idat->hWnd;
- CHARFORMAT2 cf2;
+ CHARFORMAT2 cf2;
memset(&cf2, 0, sizeof(cf2));
- LOGFONT lf;
- DWORD colour = db_get_dw(NULL, SRMMMOD, SRMSGSET_INFOBARBKGCOLOUR, SRMSGDEFSET_INFOBARBKGCOLOUR);
- SendDlgItemMessage(hwnd, IDC_INFOBAR_NAME, EM_SETBKGNDCOLOR, 0, colour);
- SendDlgItemMessage(hwnd, IDC_INFOBAR_STATUS, EM_SETBKGNDCOLOR, 0, colour);
- LoadMsgDlgFont(MSGFONTID_INFOBAR_NAME, &lf, &colour);
- cf2.dwMask = CFM_COLOR | CFM_FACE | CFM_CHARSET | CFM_SIZE | CFM_WEIGHT | CFM_BOLD | CFM_ITALIC;
- cf2.cbSize = sizeof(cf2);
- cf2.crTextColor = colour;
- cf2.bCharSet = lf.lfCharSet;
- _tcsncpy(cf2.szFaceName, lf.lfFaceName, LF_FACESIZE);
- cf2.dwEffects = ((lf.lfWeight >= FW_BOLD) ? CFE_BOLD : 0) | (lf.lfItalic ? CFE_ITALIC : 0);
- cf2.wWeight = (WORD)lf.lfWeight;
- cf2.bPitchAndFamily = lf.lfPitchAndFamily;
+ LOGFONT lf;
+ DWORD colour = db_get_dw(NULL, SRMMMOD, SRMSGSET_INFOBARBKGCOLOUR, SRMSGDEFSET_INFOBARBKGCOLOUR);
+ SendDlgItemMessage(hwnd, IDC_INFOBAR_NAME, EM_SETBKGNDCOLOR, 0, colour);
+ SendDlgItemMessage(hwnd, IDC_INFOBAR_STATUS, EM_SETBKGNDCOLOR, 0, colour);
+ LoadMsgDlgFont(MSGFONTID_INFOBAR_NAME, &lf, &colour);
+ cf2.dwMask = CFM_COLOR | CFM_FACE | CFM_CHARSET | CFM_SIZE | CFM_WEIGHT | CFM_BOLD | CFM_ITALIC;
+ cf2.cbSize = sizeof(cf2);
+ cf2.crTextColor = colour;
+ cf2.bCharSet = lf.lfCharSet;
+ _tcsncpy(cf2.szFaceName, lf.lfFaceName, LF_FACESIZE);
+ cf2.dwEffects = ((lf.lfWeight >= FW_BOLD) ? CFE_BOLD : 0) | (lf.lfItalic ? CFE_ITALIC : 0);
+ cf2.wWeight = (WORD)lf.lfWeight;
+ cf2.bPitchAndFamily = lf.lfPitchAndFamily;
cf2.yHeight = abs(lf.lfHeight) * 1440 / g_dat.logPixelSY;
- SendDlgItemMessageA(hwnd, IDC_INFOBAR_NAME, EM_SETCHARFORMAT, 0, (LPARAM)&cf2);
+ SendDlgItemMessageA(hwnd, IDC_INFOBAR_NAME, EM_SETCHARFORMAT, 0, (LPARAM)&cf2);
- LoadMsgDlgFont(MSGFONTID_INFOBAR_STATUS, &lf, &colour);
- cf2.dwMask = CFM_COLOR | CFM_FACE | CFM_CHARSET | CFM_SIZE | CFM_WEIGHT | CFM_BOLD | CFM_ITALIC;
- cf2.cbSize = sizeof(cf2);
- cf2.crTextColor = colour;
- cf2.bCharSet = lf.lfCharSet;
- _tcsncpy(cf2.szFaceName, lf.lfFaceName, LF_FACESIZE);
- cf2.dwEffects = ((lf.lfWeight >= FW_BOLD) ? CFE_BOLD : 0) | (lf.lfItalic ? CFE_ITALIC : 0);
- cf2.wWeight = (WORD)lf.lfWeight;
- cf2.bPitchAndFamily = lf.lfPitchAndFamily;
- cf2.yHeight = abs(lf.lfHeight) * 1440 / g_dat.logPixelSY;
- SendDlgItemMessageA(hwnd, IDC_INFOBAR_STATUS, EM_SETCHARFORMAT, 0, (LPARAM)&cf2);
+ LoadMsgDlgFont(MSGFONTID_INFOBAR_STATUS, &lf, &colour);
+ cf2.dwMask = CFM_COLOR | CFM_FACE | CFM_CHARSET | CFM_SIZE | CFM_WEIGHT | CFM_BOLD | CFM_ITALIC;
+ cf2.cbSize = sizeof(cf2);
+ cf2.crTextColor = colour;
+ cf2.bCharSet = lf.lfCharSet;
+ _tcsncpy(cf2.szFaceName, lf.lfFaceName, LF_FACESIZE);
+ cf2.dwEffects = ((lf.lfWeight >= FW_BOLD) ? CFE_BOLD : 0) | (lf.lfItalic ? CFE_ITALIC : 0);
+ cf2.wWeight = (WORD)lf.lfWeight;
+ cf2.bPitchAndFamily = lf.lfPitchAndFamily;
+ cf2.yHeight = abs(lf.lfHeight) * 1440 / g_dat.logPixelSY;
+ SendDlgItemMessageA(hwnd, IDC_INFOBAR_STATUS, EM_SETCHARFORMAT, 0, (LPARAM)&cf2);
- RefreshInfobar(idat);
+ RefreshInfobar(idat);
}
static HICON GetExtraStatusIcon(InfobarWindowData* idat)
{
- BYTE bXStatus = db_get_b(idat->mwd->windowData.hContact, idat->mwd->szProto, "XStatusId", 0);
+ BYTE bXStatus = db_get_b(idat->mwd->hContact, idat->mwd->szProto, "XStatusId", 0);
if (bXStatus > 0)
return (HICON) CallProtoService(idat->mwd->szProto, PS_GETCUSTOMSTATUSICON, bXStatus, 0);
@@ -71,10 +72,10 @@ void RefreshInfobar(InfobarWindowData* idat)
{
HWND hwnd = idat->hWnd;
SrmmWindowData *dat = idat->mwd;
- TCHAR *szContactName = GetNickname(dat->windowData.hContact, dat->szProto);
- TCHAR *szContactStatusMsg = db_get_tsa(dat->windowData.hContact, "CList", "StatusMsg");
- TCHAR *szXStatusName = db_get_tsa(idat->mwd->windowData.hContact, idat->mwd->szProto, "XStatusName");
- TCHAR *szXStatusMsg = db_get_tsa(idat->mwd->windowData.hContact, idat->mwd->szProto, "XStatusMsg");
+ TCHAR *szContactName = GetNickname(dat->hContact, dat->szProto);
+ TCHAR *szContactStatusMsg = db_get_tsa(dat->hContact, "CList", "StatusMsg");
+ TCHAR *szXStatusName = db_get_tsa(idat->mwd->hContact, idat->mwd->szProto, "XStatusName");
+ TCHAR *szXStatusMsg = db_get_tsa(idat->mwd->hContact, idat->mwd->szProto, "XStatusMsg");
HICON hIcon = GetExtraStatusIcon(idat);
TCHAR szText[2048];
SETTEXTEX st;
@@ -84,8 +85,8 @@ void RefreshInfobar(InfobarWindowData* idat)
_tcsncpy_s(szText, TranslateTS(szXStatusName), _TRUNCATE);
st.flags = ST_DEFAULT;
st.codepage = 1200;
- SendDlgItemMessage(hwnd, IDC_INFOBAR_NAME, EM_SETTEXTEX, (WPARAM) &st, (LPARAM)szContactName);
- SendDlgItemMessage(hwnd, IDC_INFOBAR_STATUS, EM_SETTEXTEX, (WPARAM) &st, (LPARAM)szContactStatusMsg);
+ SendDlgItemMessage(hwnd, IDC_INFOBAR_NAME, EM_SETTEXTEX, (WPARAM)&st, (LPARAM)szContactName);
+ SendDlgItemMessage(hwnd, IDC_INFOBAR_STATUS, EM_SETTEXTEX, (WPARAM)&st, (LPARAM)szContactStatusMsg);
hIcon = (HICON)SendDlgItemMessage(hwnd, IDC_XSTATUSICON, STM_SETICON, (WPARAM)hIcon, 0);
if (hIcon) {
DestroyIcon(hIcon);
@@ -104,62 +105,63 @@ void RefreshInfobar(InfobarWindowData* idat)
static INT_PTR CALLBACK InfobarWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
static BOOL bWasCopy;
- InfobarWindowData* idat = (InfobarWindowData *) GetWindowLongPtr(hwnd, GWLP_USERDATA);
- if (!idat && msg!=WM_INITDIALOG) return FALSE;
+ InfobarWindowData* idat = (InfobarWindowData *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
+ if (!idat && msg != WM_INITDIALOG)
+ return FALSE;
+
switch (msg) {
case WM_INITDIALOG:
+ bWasCopy = FALSE;
+ idat = (InfobarWindowData*)lParam;
+ idat->hWnd = hwnd;
{
- RECT rect = {0};
- bWasCopy = FALSE;
- idat = (InfobarWindowData *) lParam;
- idat->hWnd = hwnd;
+ RECT rect = { 0 };
idat->hXStatusTip = CreateToolTip(hwnd, NULL, NULL, &rect);
SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)idat);
- SendDlgItemMessage(hwnd, IDC_INFOBAR_NAME, EM_AUTOURLDETECT, (WPARAM) TRUE, 0);
+ SendDlgItemMessage(hwnd, IDC_INFOBAR_NAME, EM_AUTOURLDETECT, TRUE, 0);
SendDlgItemMessage(hwnd, IDC_INFOBAR_NAME, EM_SETEVENTMASK, 0, ENM_MOUSEEVENTS | ENM_LINK | ENM_KEYEVENTS);
- SendDlgItemMessage(hwnd, IDC_INFOBAR_STATUS, EM_AUTOURLDETECT, (WPARAM) TRUE, 0);
+ SendDlgItemMessage(hwnd, IDC_INFOBAR_STATUS, EM_AUTOURLDETECT, TRUE, 0);
SendDlgItemMessage(hwnd, IDC_INFOBAR_STATUS, EM_SETEVENTMASK, 0, ENM_MOUSEEVENTS | ENM_LINK | ENM_KEYEVENTS);
SetupInfobar(idat);
}
return TRUE;
case WM_SIZE:
- {
- if (wParam==SIZE_RESTORED || wParam==SIZE_MAXIMIZED) {
- HDWP hdwp;
- RECT rc;
- int dlgWidth, dlgHeight;
- int avatarWidth = 0;
- int avatarHeight = 0;
- GetClientRect(hwnd, &rc);
- dlgWidth = rc.right - rc.left;
- dlgHeight = rc.bottom - rc.top;
- if (idat->mwd->avatarPic && (g_dat.flags&SMF_AVATAR)) {
- BITMAP bminfo;
- GetObject(idat->mwd->avatarPic, sizeof(bminfo), &bminfo);
- if ( bminfo.bmWidth != 0 && bminfo.bmHeight != 0 ) {
- avatarHeight = dlgHeight - 2;
- avatarWidth = bminfo.bmWidth * avatarHeight / bminfo.bmHeight;
- if (avatarWidth > dlgHeight) {
- avatarWidth = dlgHeight - 2;
- avatarHeight = bminfo.bmHeight * avatarWidth / bminfo.bmWidth;
- }
+ if (wParam == SIZE_RESTORED || wParam == SIZE_MAXIMIZED) {
+ int dlgWidth, dlgHeight;
+ int avatarWidth = 0;
+ int avatarHeight = 0;
+
+ RECT rc;
+ GetClientRect(hwnd, &rc);
+ dlgWidth = rc.right - rc.left;
+ dlgHeight = rc.bottom - rc.top;
+ if (idat->mwd->avatarPic && (g_dat.flags&SMF_AVATAR)) {
+ BITMAP bminfo;
+ GetObject(idat->mwd->avatarPic, sizeof(bminfo), &bminfo);
+ if (bminfo.bmWidth != 0 && bminfo.bmHeight != 0) {
+ avatarHeight = dlgHeight - 2;
+ avatarWidth = bminfo.bmWidth * avatarHeight / bminfo.bmHeight;
+ if (avatarWidth > dlgHeight) {
+ avatarWidth = dlgHeight - 2;
+ avatarHeight = bminfo.bmHeight * avatarWidth / bminfo.bmWidth;
}
}
- hdwp = BeginDeferWindowPos(4);
- hdwp = DeferWindowPos(hdwp, GetDlgItem(hwnd, IDC_INFOBAR_NAME), 0, 16, 0, dlgWidth - avatarWidth - 2 - 32, dlgHeight/2, SWP_NOZORDER);
- hdwp = DeferWindowPos(hdwp, GetDlgItem(hwnd, IDC_INFOBAR_STATUS), 0, 16, dlgHeight/2, dlgWidth - avatarWidth - 2 - 32, dlgHeight/2, SWP_NOZORDER);
- hdwp = DeferWindowPos(hdwp, GetDlgItem(hwnd, IDC_AVATAR), 0, dlgWidth - avatarWidth - 2, (dlgHeight - avatarHeight) / 2, avatarWidth, (dlgHeight + avatarHeight - 2) / 2, SWP_NOZORDER);
- hdwp = DeferWindowPos(hdwp, GetDlgItem(hwnd, IDC_XSTATUSICON), 0, dlgWidth - avatarWidth - 2 - 16, dlgHeight/4 - 8, 16, 16, SWP_NOZORDER);
- rc.left = dlgWidth - avatarWidth - 2 - 16;
- rc.top = dlgHeight/4 - 8;
- rc.bottom = rc.top + 20;
- rc.right = rc.left + 16;
- SetToolTipRect(hwnd, idat->hXStatusTip, &rc);
- EndDeferWindowPos(hdwp);
}
- return TRUE;
+ HDWP hdwp = BeginDeferWindowPos(4);
+ hdwp = DeferWindowPos(hdwp, GetDlgItem(hwnd, IDC_INFOBAR_NAME), 0, 16, 0, dlgWidth - avatarWidth - 2 - 32, dlgHeight / 2, SWP_NOZORDER);
+ hdwp = DeferWindowPos(hdwp, GetDlgItem(hwnd, IDC_INFOBAR_STATUS), 0, 16, dlgHeight / 2, dlgWidth - avatarWidth - 2 - 32, dlgHeight / 2, SWP_NOZORDER);
+ hdwp = DeferWindowPos(hdwp, GetDlgItem(hwnd, IDC_AVATAR), 0, dlgWidth - avatarWidth - 2, (dlgHeight - avatarHeight) / 2, avatarWidth, (dlgHeight + avatarHeight - 2) / 2, SWP_NOZORDER);
+ hdwp = DeferWindowPos(hdwp, GetDlgItem(hwnd, IDC_XSTATUSICON), 0, dlgWidth - avatarWidth - 2 - 16, dlgHeight / 4 - 8, 16, 16, SWP_NOZORDER);
+ rc.left = dlgWidth - avatarWidth - 2 - 16;
+ rc.top = dlgHeight / 4 - 8;
+ rc.bottom = rc.top + 20;
+ rc.right = rc.left + 16;
+ SetToolTipRect(hwnd, idat->hXStatusTip, &rc);
+ EndDeferWindowPos(hdwp);
}
+ return TRUE;
+
case WM_CTLCOLORDLG:
case WM_CTLCOLORSTATIC:
return (INT_PTR)g_dat.hInfobarBrush;
@@ -176,32 +178,32 @@ static INT_PTR CALLBACK InfobarWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARA
case IDC_INFOBAR_STATUS:
switch (pNmhdr->code) {
case EN_MSGFILTER:
- switch (((MSGFILTER *) lParam)->msg) {
+ switch (((MSGFILTER*)lParam)->msg) {
case WM_CHAR:
- SendMessage(GetParent(hwnd), ((MSGFILTER *) lParam)->msg, ((MSGFILTER *) lParam)->wParam, ((MSGFILTER *) lParam)->lParam);
+ SendMessage(GetParent(hwnd), ((MSGFILTER *)lParam)->msg, ((MSGFILTER *)lParam)->wParam, ((MSGFILTER *)lParam)->lParam);
SetWindowLongPtr(hwnd, DWLP_MSGRESULT, TRUE);
return TRUE;
+
case WM_LBUTTONUP:
- {
- CHARRANGE sel;
- SendDlgItemMessage(hwnd, pNmhdr->idFrom, EM_EXGETSEL, 0, (LPARAM)&sel);
- bWasCopy = FALSE;
- if (sel.cpMin != sel.cpMax) {
- SendDlgItemMessage(hwnd, pNmhdr->idFrom, WM_COPY, 0, 0);
- sel.cpMin = sel.cpMax ;
- SendDlgItemMessage(hwnd, pNmhdr->idFrom, EM_EXSETSEL, 0, (LPARAM)&sel);
- bWasCopy = TRUE;
- }
- SetFocus(GetParent(hwnd));
+ CHARRANGE sel;
+ SendDlgItemMessage(hwnd, pNmhdr->idFrom, EM_EXGETSEL, 0, (LPARAM)&sel);
+ bWasCopy = FALSE;
+ if (sel.cpMin != sel.cpMax) {
+ SendDlgItemMessage(hwnd, pNmhdr->idFrom, WM_COPY, 0, 0);
+ sel.cpMin = sel.cpMax;
+ SendDlgItemMessage(hwnd, pNmhdr->idFrom, EM_EXSETSEL, 0, (LPARAM)&sel);
+ bWasCopy = TRUE;
}
+ SetFocus(GetParent(hwnd));
}
break;
+
case EN_LINK:
- switch (((ENLINK *) lParam)->msg) {
+ switch (((ENLINK*)lParam)->msg) {
case WM_RBUTTONDOWN:
case WM_LBUTTONUP:
if (!bWasCopy) {
- if (HandleLinkClick(g_hInst, hwnd, GetDlgItem(GetParent(hwnd), IDC_MESSAGE),(ENLINK*)lParam)) {
+ if (HandleLinkClick(g_hInst, hwnd, GetDlgItem(GetParent(hwnd), IDC_MESSAGE), (ENLINK*)lParam)) {
SetWindowLongPtr(hwnd, DWLP_MSGRESULT, TRUE);
return TRUE;
}
@@ -212,8 +214,8 @@ static INT_PTR CALLBACK InfobarWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARA
}
break;
}
- break;
}
+ break;
case WM_DRAWITEM:
{
@@ -224,7 +226,7 @@ static INT_PTR CALLBACK InfobarWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARA
int itemWidth = dis->rcItem.right - dis->rcItem.left + 1;
int itemHeight = dis->rcItem.bottom - dis->rcItem.top + 1;
HBITMAP hbmMem = CreateCompatibleBitmap(dis->hDC, itemWidth, itemHeight);
- hbmMem = (HBITMAP) SelectObject(hdcMem, hbmMem);
+ hbmMem = (HBITMAP)SelectObject(hdcMem, hbmMem);
rect.top = 0;
rect.left = 0;
rect.right = itemWidth - 1;
@@ -242,7 +244,7 @@ static INT_PTR CALLBACK InfobarWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARA
}
AVATARDRAWREQUEST adr = { sizeof(adr) };
- adr.hContact = idat->mwd->windowData.hContact;
+ adr.hContact = idat->mwd->hContact;
adr.hTargetDC = hdcMem;
adr.rcDraw.right = avatarWidth - 1;
adr.rcDraw.bottom = avatarHeight - 1;
@@ -251,25 +253,29 @@ static INT_PTR CALLBACK InfobarWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARA
}
}
BitBlt(dis->hDC, 0, 0, itemWidth, itemHeight, hdcMem, 0, 0, SRCCOPY);
- hbmMem = (HBITMAP) SelectObject(hdcMem, hbmMem);
+ hbmMem = (HBITMAP)SelectObject(hdcMem, hbmMem);
DeleteObject(hbmMem);
DeleteDC(hdcMem);
return TRUE;
}
- return CallService(MS_CLIST_MENUDRAWITEM, wParam, lParam);
}
+ return CallService(MS_CLIST_MENUDRAWITEM, wParam, lParam);
+
case WM_LBUTTONDOWN:
SendMessage(idat->mwd->hwnd, WM_LBUTTONDOWN, wParam, lParam);
return TRUE;
+
case WM_RBUTTONUP:
{
+ HMENU hMenu = (HMENU)CallService(MS_CLIST_MENUBUILDCONTACT, idat->mwd->hContact, 0);
+
POINT pt;
- HMENU hMenu = (HMENU) CallService(MS_CLIST_MENUBUILDCONTACT, (WPARAM) idat->mwd->windowData.hContact, 0);
GetCursorPos(&pt);
TrackPopupMenu(hMenu, 0, pt.x, pt.y, 0, GetParent(hwnd), NULL);
DestroyMenu(hMenu);
}
break;
+
case WM_DESTROY:
if (idat->hXStatusTip != NULL) {
DestroyWindow(idat->hXStatusTip);
@@ -280,9 +286,9 @@ static INT_PTR CALLBACK InfobarWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARA
return FALSE;
}
-InfobarWindowData *CreateInfobar(HWND hParent, SrmmWindowData *dat)
+InfobarWindowData* CreateInfobar(HWND hParent, SrmmWindowData *dat)
{
- InfobarWindowData *idat = (InfobarWindowData *) mir_alloc(sizeof(InfobarWindowData));
+ InfobarWindowData *idat = (InfobarWindowData*)mir_alloc(sizeof(InfobarWindowData));
idat->mwd = dat;
idat->hWnd = CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_INFOBAR), hParent, InfobarWndProc, (LPARAM)idat);
RichUtil_SubClass(idat->hWnd);