diff options
author | George Hazan <ghazan@miranda.im> | 2023-03-22 20:28:56 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2023-03-22 20:28:56 +0300 |
commit | 6e97fc04aa23723077c138b7cb028a5a8793ddf6 (patch) | |
tree | 95a62c2f2c1f8314e389560cec5a504c2d08f5c3 /plugins/TabSRMM | |
parent | 0ff53148fe18ad476e47eae46e7ed6f3a8b56886 (diff) |
common nick list drawing code removed from DlgProc()
Diffstat (limited to 'plugins/TabSRMM')
-rw-r--r-- | plugins/TabSRMM/src/msgdialog.cpp | 89 | ||||
-rw-r--r-- | plugins/TabSRMM/src/msgdlgother.cpp | 86 | ||||
-rw-r--r-- | plugins/TabSRMM/src/msgs.h | 1 |
3 files changed, 89 insertions, 87 deletions
diff --git a/plugins/TabSRMM/src/msgdialog.cpp b/plugins/TabSRMM/src/msgdialog.cpp index ecab7d8cf4..34bd740ff2 100644 --- a/plugins/TabSRMM/src/msgdialog.cpp +++ b/plugins/TabSRMM/src/msgdialog.cpp @@ -2650,93 +2650,8 @@ INT_PTR CMsgDialog::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) return Menu_DrawItem(lParam);
}
- if (dis->CtlID == IDC_SRMM_NICKLIST) {
- int x_offset = 0;
- int index = dis->itemID;
-
- USERINFO *ui = g_chatApi.UM_FindUserFromIndex(m_si, index);
- if (ui == nullptr)
- return TRUE;
-
- int height = dis->rcItem.bottom - dis->rcItem.top;
- if (height & 1)
- height++;
- int offset = (height == 10) ? 0 : height / 2;
-
- HICON hIcon = g_chatApi.SM_GetStatusIcon(m_si, ui);
- HFONT hFont = g_Settings.UserListFonts[ui->iStatusEx];
- HFONT hOldFont = (HFONT)SelectObject(dis->hDC, hFont);
- SetBkMode(dis->hDC, TRANSPARENT);
-
- int nickIndex = 0;
- for (int i = 0; i < STATUSICONCOUNT; i++) {
- if (hIcon == g_chatApi.hStatusIcons[i]) {
- nickIndex = i;
- break;
- }
- }
-
- if (dis->itemState & ODS_SELECTED) {
- FillRect(dis->hDC, &dis->rcItem, g_Settings.SelectionBGBrush);
- SetTextColor(dis->hDC, g_Settings.nickColors[6]);
- }
- else {
- FillRect(dis->hDC, &dis->rcItem, g_chatApi.hListBkgBrush);
- if (g_Settings.bColorizeNicks && nickIndex != 0)
- SetTextColor(dis->hDC, g_Settings.nickColors[nickIndex - 1]);
- else
- SetTextColor(dis->hDC, g_Settings.UserListColors[ui->iStatusEx]);
- }
- x_offset = 2;
-
- if (g_Settings.bShowContactStatus && g_Settings.bContactStatusFirst && ui->ContactStatus) {
- HICON icon = Skin_LoadProtoIcon(m_si->pszModule, ui->ContactStatus);
- DrawIconEx(dis->hDC, x_offset, dis->rcItem.top + offset - 8, icon, 16, 16, 0, nullptr, DI_NORMAL);
- IcoLib_ReleaseIcon(icon);
- x_offset += 18;
- }
-
- if (g_Settings.bClassicIndicators) {
- char szTemp[3];
- szTemp[1] = 0;
- szTemp[0] = szIndicators[nickIndex];
- if (szTemp[0]) {
- SIZE szUmode;
- GetTextExtentPoint32A(dis->hDC, szTemp, 1, &szUmode);
- TextOutA(dis->hDC, x_offset, dis->rcItem.top, szTemp, 1);
- x_offset += szUmode.cx + 2;
- }
- else x_offset += 8;
- }
- else {
- DrawIconEx(dis->hDC, x_offset, dis->rcItem.top + offset - 5, hIcon, 10, 10, 0, nullptr, DI_NORMAL);
- x_offset += 12;
- }
-
- if (g_Settings.bShowContactStatus && !g_Settings.bContactStatusFirst && ui->ContactStatus) {
- HICON icon = Skin_LoadProtoIcon(m_si->pszModule, ui->ContactStatus);
- DrawIconEx(dis->hDC, x_offset, dis->rcItem.top + offset - 8, icon, 16, 16, 0, nullptr, DI_NORMAL);
- IcoLib_ReleaseIcon(icon);
- x_offset += 18;
- }
-
- SIZE sz;
- if (m_iSearchItem != -1 && m_iSearchItem == index && m_wszSearch[0]) {
- COLORREF clr_orig = GetTextColor(dis->hDC);
- GetTextExtentPoint32(dis->hDC, ui->pszNick, (int)mir_wstrlen(m_wszSearch), &sz);
- SetTextColor(dis->hDC, RGB(250, 250, 0));
- TextOut(dis->hDC, x_offset, (dis->rcItem.top + dis->rcItem.bottom - sz.cy) / 2, ui->pszNick, (int)mir_wstrlen(m_wszSearch));
- SetTextColor(dis->hDC, clr_orig);
- x_offset += sz.cx;
- TextOut(dis->hDC, x_offset, (dis->rcItem.top + dis->rcItem.bottom - sz.cy) / 2, ui->pszNick + mir_wstrlen(m_wszSearch), int(mir_wstrlen(ui->pszNick) - mir_wstrlen(m_wszSearch)));
- }
- else {
- GetTextExtentPoint32(dis->hDC, ui->pszNick, (int)mir_wstrlen(ui->pszNick), &sz);
- TextOut(dis->hDC, x_offset, (dis->rcItem.top + dis->rcItem.bottom - sz.cy) / 2, ui->pszNick, (int)mir_wstrlen(ui->pszNick));
- SelectObject(dis->hDC, hOldFont);
- }
- return TRUE;
- }
+ if (dis->CtlID == IDC_SRMM_NICKLIST)
+ break;
}
return MsgWindowDrawHandler((DRAWITEMSTRUCT *)lParam);
diff --git a/plugins/TabSRMM/src/msgdlgother.cpp b/plugins/TabSRMM/src/msgdlgother.cpp index 1634e5712e..b7dd977c2d 100644 --- a/plugins/TabSRMM/src/msgdlgother.cpp +++ b/plugins/TabSRMM/src/msgdlgother.cpp @@ -433,6 +433,92 @@ BOOL CMsgDialog::DoRtfToTags(CMStringW &pszText) const /////////////////////////////////////////////////////////////////////////////////////////
+void CMsgDialog::DrawNickList(USERINFO *ui, DRAWITEMSTRUCT *dis)
+{
+ int x_offset = 0;
+ int index = dis->itemID;
+
+ int height = dis->rcItem.bottom - dis->rcItem.top;
+ if (height & 1)
+ height++;
+ int offset = (height == 10) ? 0 : height / 2;
+
+ HICON hIcon = g_chatApi.SM_GetStatusIcon(m_si, ui);
+ HFONT hFont = g_Settings.UserListFonts[ui->iStatusEx];
+ HFONT hOldFont = (HFONT)SelectObject(dis->hDC, hFont);
+ SetBkMode(dis->hDC, TRANSPARENT);
+
+ int nickIndex = 0;
+ for (int i = 0; i < STATUSICONCOUNT; i++) {
+ if (hIcon == g_chatApi.hStatusIcons[i]) {
+ nickIndex = i;
+ break;
+ }
+ }
+
+ if (dis->itemState & ODS_SELECTED) {
+ FillRect(dis->hDC, &dis->rcItem, g_Settings.SelectionBGBrush);
+ SetTextColor(dis->hDC, g_Settings.nickColors[6]);
+ }
+ else {
+ FillRect(dis->hDC, &dis->rcItem, g_chatApi.hListBkgBrush);
+ if (g_Settings.bColorizeNicks && nickIndex != 0)
+ SetTextColor(dis->hDC, g_Settings.nickColors[nickIndex - 1]);
+ else
+ SetTextColor(dis->hDC, g_Settings.UserListColors[ui->iStatusEx]);
+ }
+ x_offset = 2;
+
+ if (g_Settings.bShowContactStatus && g_Settings.bContactStatusFirst && ui->ContactStatus) {
+ HICON icon = Skin_LoadProtoIcon(m_si->pszModule, ui->ContactStatus);
+ DrawIconEx(dis->hDC, x_offset, dis->rcItem.top + offset - 8, icon, 16, 16, 0, nullptr, DI_NORMAL);
+ IcoLib_ReleaseIcon(icon);
+ x_offset += 18;
+ }
+
+ if (g_Settings.bClassicIndicators) {
+ char szTemp[3];
+ szTemp[1] = 0;
+ szTemp[0] = szIndicators[nickIndex];
+ if (szTemp[0]) {
+ SIZE szUmode;
+ GetTextExtentPoint32A(dis->hDC, szTemp, 1, &szUmode);
+ TextOutA(dis->hDC, x_offset, dis->rcItem.top, szTemp, 1);
+ x_offset += szUmode.cx + 2;
+ }
+ else x_offset += 8;
+ }
+ else {
+ DrawIconEx(dis->hDC, x_offset, dis->rcItem.top + offset - 5, hIcon, 10, 10, 0, nullptr, DI_NORMAL);
+ x_offset += 12;
+ }
+
+ if (g_Settings.bShowContactStatus && !g_Settings.bContactStatusFirst && ui->ContactStatus) {
+ HICON icon = Skin_LoadProtoIcon(m_si->pszModule, ui->ContactStatus);
+ DrawIconEx(dis->hDC, x_offset, dis->rcItem.top + offset - 8, icon, 16, 16, 0, nullptr, DI_NORMAL);
+ IcoLib_ReleaseIcon(icon);
+ x_offset += 18;
+ }
+
+ SIZE sz;
+ if (m_iSearchItem != -1 && m_iSearchItem == index && m_wszSearch[0]) {
+ COLORREF clr_orig = GetTextColor(dis->hDC);
+ GetTextExtentPoint32(dis->hDC, ui->pszNick, (int)mir_wstrlen(m_wszSearch), &sz);
+ SetTextColor(dis->hDC, RGB(250, 250, 0));
+ TextOut(dis->hDC, x_offset, (dis->rcItem.top + dis->rcItem.bottom - sz.cy) / 2, ui->pszNick, (int)mir_wstrlen(m_wszSearch));
+ SetTextColor(dis->hDC, clr_orig);
+ x_offset += sz.cx;
+ TextOut(dis->hDC, x_offset, (dis->rcItem.top + dis->rcItem.bottom - sz.cy) / 2, ui->pszNick + mir_wstrlen(m_wszSearch), int(mir_wstrlen(ui->pszNick) - mir_wstrlen(m_wszSearch)));
+ }
+ else {
+ GetTextExtentPoint32(dis->hDC, ui->pszNick, (int)mir_wstrlen(ui->pszNick), &sz);
+ TextOut(dis->hDC, x_offset, (dis->rcItem.top + dis->rcItem.bottom - sz.cy) / 2, ui->pszNick, (int)mir_wstrlen(ui->pszNick));
+ SelectObject(dis->hDC, hOldFont);
+ }
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
void CMsgDialog::EnableSendButton(bool bMode) const
{
SendDlgItemMessage(m_hwnd, IDOK, BUTTONSETASNORMAL, bMode, 0);
diff --git a/plugins/TabSRMM/src/msgs.h b/plugins/TabSRMM/src/msgs.h index 15bbd42352..6d05b1a25f 100644 --- a/plugins/TabSRMM/src/msgs.h +++ b/plugins/TabSRMM/src/msgs.h @@ -631,6 +631,7 @@ public: void AddLog() override;
void CloseTab() override;
+ void DrawNickList(USERINFO *ui, DRAWITEMSTRUCT *dis) override;
void EventAdded(MEVENT, const DBEVENTINFO &dbei) override;
bool GetFirstEvent() override;
bool IsActive() const override;
|