diff options
author | George Hazan <ghazan@miranda.im> | 2023-03-31 14:11:53 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2023-03-31 14:11:53 +0300 |
commit | 0f69954107905dc6ea5ebd4005fceea945e5021a (patch) | |
tree | 13a40193219895e1654833bee2b836102b2a801a | |
parent | 0106b105c7ac842eec10c5683be41cb50fd2e26c (diff) |
StdMsg: code cleaning
-rw-r--r-- | src/core/stdmsg/res/resource.rc | 2 | ||||
-rw-r--r-- | src/core/stdmsg/src/msgdialog.cpp | 94 | ||||
-rw-r--r-- | src/core/stdmsg/src/msglog.cpp | 9 | ||||
-rw-r--r-- | src/core/stdmsg/src/msgs.h | 2 |
4 files changed, 39 insertions, 68 deletions
diff --git a/src/core/stdmsg/res/resource.rc b/src/core/stdmsg/res/resource.rc index caf2ea092c..791d51b84f 100644 --- a/src/core/stdmsg/res/resource.rc +++ b/src/core/stdmsg/res/resource.rc @@ -86,7 +86,7 @@ BEGIN CONTROL "",IDC_SPLITTERX,"Static",SS_ENHMETAFILE,172,23,10,73
CONTROL "",IDC_SPLITTERY,"Static",SS_ENHMETAFILE,0,108,251,2
LISTBOX IDC_SRMM_NICKLIST,182,2,69,94,LBS_OWNERDRAWFIXED | LBS_NOINTEGRALHEIGHT | LBS_NODATA | NOT WS_BORDER | WS_VSCROLL | WS_TABSTOP,WS_EX_STATICEDGE
- CONTROL "",IDC_AVATAR,"Button",BS_OWNERDRAW | NOT WS_VISIBLE,1,127,6,13
+ CONTROL "",IDC_AVATAR,"Static",SS_OWNERDRAW | NOT WS_VISIBLE,1,127,6,13
END
IDD_OPT_MSGLOG DIALOGEX 0, 0, 311, 171
diff --git a/src/core/stdmsg/src/msgdialog.cpp b/src/core/stdmsg/src/msgdialog.cpp index d7d4a14e25..c0ef59b205 100644 --- a/src/core/stdmsg/src/msgdialog.cpp +++ b/src/core/stdmsg/src/msgdialog.cpp @@ -131,7 +131,6 @@ bool CMsgDialog::OnInitDialog() GetWindowRect(m_message.GetHwnd(), &m_minEditInit);
m_iSplitterY = g_plugin.getDword(g_plugin.bSavePerContact ? m_hContact : 0, "splitterPos", m_minEditInit.bottom - m_minEditInit.top);
- UpdateSizeBar();
m_message.SendMsg(EM_SETEVENTMASK, 0, ENM_MOUSEEVENTS | ENM_CHANGE);
@@ -490,8 +489,8 @@ LBL_CalcBottom: case IDC_AVATAR:
urc->rcItem.top = underTB + (urc->dlgNewSize.cy - underTB - m_avatarHeight)/2;
- urc->rcItem.bottom = urc->rcItem.top + m_avatarHeight + 2;
- urc->rcItem.right = urc->rcItem.left + (m_avatarWidth + 2);
+ urc->rcItem.bottom = urc->rcItem.top + m_avatarHeight;
+ urc->rcItem.right = urc->rcItem.left + m_avatarWidth;
return RD_ANCHORX_LEFT | RD_ANCHORY_CUSTOM;
}
@@ -528,7 +527,7 @@ INT_PTR CMsgDialog::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) return FALSE;
case HM_AVATARACK:
- ShowAvatar();
+ UpdateAvatar();
break;
case DM_OPTIONSAPPLIED:
@@ -1335,21 +1334,6 @@ void CMsgDialog::RemakeLog() m_pLog->LogEvents(m_hDbEventFirst, -1, false);
}
-void CMsgDialog::ShowAvatar()
-{
- if (g_plugin.bShowAvatar) {
- AVATARCACHEENTRY *ace = (AVATARCACHEENTRY *)CallService(MS_AV_GETAVATARBITMAP, getActiveContact(), 0);
- if (ace && (INT_PTR)ace != CALLSERVICE_NOTFOUND && (ace->dwFlags & AVS_BITMAP_VALID) && !(ace->dwFlags & AVS_HIDEONCLIST))
- m_avatarPic = ace->hbmPic;
- else
- m_avatarPic = nullptr;
- }
- else m_avatarPic = nullptr;
-
- UpdateSizeBar();
- Resize();
-}
-
void CMsgDialog::ShowTime(bool bForce)
{
if (!m_hTimeZone)
@@ -1403,12 +1387,41 @@ void CMsgDialog::SetStatusText(const wchar_t *wszText, HICON hIcon) void CMsgDialog::UpdateAvatar()
{
- PROTO_AVATAR_INFORMATION ai = {};
- ai.hContact = m_hContact;
- CallProtoService(m_szProto, PS_GETAVATARINFO, GAIF_FORCE, (LPARAM)&ai);
+ m_avatarPic = nullptr;
+ if (g_plugin.bShowAvatar) {
+ AVATARCACHEENTRY *ace = (AVATARCACHEENTRY *)CallService(MS_AV_GETAVATARBITMAP, getActiveContact(), 0);
+ if (ace && (INT_PTR)ace != CALLSERVICE_NOTFOUND && (ace->dwFlags & AVS_BITMAP_VALID) && !(ace->dwFlags & AVS_HIDEONCLIST))
+ m_avatarPic = ace->hbmPic;
+ }
+
+ m_minEditBoxSize.cx = m_minEditInit.right - m_minEditInit.left;
+ m_minEditBoxSize.cy = m_minEditInit.bottom - m_minEditInit.top;
+
+ if (m_avatarPic == nullptr) {
+ m_avatarWidth = 50;
+ m_avatarHeight = 50;
+ m_avatar.Hide();
+ return;
+ }
+
+ BITMAP bminfo;
+ GetObject(m_avatarPic, sizeof(bminfo), &bminfo);
+ m_avatarWidth = bminfo.bmWidth;
+ m_avatarHeight = bminfo.bmHeight;
+ if (m_limitAvatarH && m_avatarHeight > m_limitAvatarH) {
+ m_avatarWidth = bminfo.bmWidth * m_limitAvatarH / bminfo.bmHeight;
+ m_avatarHeight = m_limitAvatarH;
+ }
+ m_avatar.Show();
+
+ if (m_avatarPic && m_minEditBoxSize.cy <= m_avatarHeight) {
+ m_minEditBoxSize.cy = m_avatarHeight;
+ if (m_iSplitterY < m_minEditBoxSize.cy + m_iBBarHeight) {
+ m_iSplitterY = m_minEditBoxSize.cy + m_iBBarHeight;
+ }
+ }
- ShowAvatar();
- SetWindowLongPtr(m_hwnd, DWLP_MSGRESULT, 1);
+ Resize();
}
void CMsgDialog::UpdateIcon(WPARAM wParam)
@@ -1454,39 +1467,6 @@ void CMsgDialog::UpdateReadChars() }
}
-void CMsgDialog::UpdateSizeBar()
-{
- m_minEditBoxSize.cx = m_minEditInit.right - m_minEditInit.left;
- m_minEditBoxSize.cy = m_minEditInit.bottom - m_minEditInit.top;
- if (g_plugin.bShowAvatar) {
- if (m_avatarPic == nullptr || !g_plugin.bShowAvatar) {
- m_avatarWidth = 50;
- m_avatarHeight = 50;
- m_avatar.Hide();
- return;
- }
- else {
- BITMAP bminfo;
- GetObject(m_avatarPic, sizeof(bminfo), &bminfo);
- m_avatarWidth = bminfo.bmWidth + 2;
- m_avatarHeight = bminfo.bmHeight + 2;
- if (m_limitAvatarH && m_avatarHeight > m_limitAvatarH) {
- m_avatarWidth = bminfo.bmWidth * m_limitAvatarH / bminfo.bmHeight + 2;
- m_avatarHeight = m_limitAvatarH + 2;
- }
- m_avatar.Show();
- }
-
- if (m_avatarPic && m_minEditBoxSize.cy <= m_avatarHeight) {
- m_minEditBoxSize.cy = m_avatarHeight;
- if (m_iSplitterY < m_minEditBoxSize.cy) {
- m_iSplitterY = m_minEditBoxSize.cy;
- Resize();
- }
- }
- }
-}
-
void CMsgDialog::UpdateTitle()
{
wchar_t newtitle[256];
diff --git a/src/core/stdmsg/src/msglog.cpp b/src/core/stdmsg/src/msglog.cpp index 149b4ef18a..2b501c487b 100644 --- a/src/core/stdmsg/src/msglog.cpp +++ b/src/core/stdmsg/src/msglog.cpp @@ -475,14 +475,7 @@ void CLogWindow::LogEvents(MEVENT hDbEventFirst, int count, bool bAppend) stream.dwCookie = (DWORD_PTR)&streamData;
if (!streamData.isEmpty) {
- bottomScroll = (GetFocus() != m_rtf.GetHwnd());
- if (bottomScroll && (GetWindowLongPtr(m_rtf.GetHwnd(), GWL_STYLE) & WS_VSCROLL)) {
- SCROLLINFO si = {};
- si.cbSize = sizeof(si);
- si.fMask = SIF_PAGE | SIF_RANGE | SIF_POS;
- GetScrollInfo(m_rtf.GetHwnd(), SB_VERT, &si);
- bottomScroll = (si.nPos + (int)si.nPage) >= si.nMax;
- }
+ bottomScroll = GetFocus() != m_rtf.GetHwnd() && AtBottom();
if (!bottomScroll)
m_rtf.SendMsg(EM_GETSCROLLPOS, 0, (LPARAM)&scrollPos);
}
diff --git a/src/core/stdmsg/src/msgs.h b/src/core/stdmsg/src/msgs.h index aa6e028f74..59458e220a 100644 --- a/src/core/stdmsg/src/msgs.h +++ b/src/core/stdmsg/src/msgs.h @@ -57,12 +57,10 @@ class CMsgDialog : public CSrmmBaseDialog void Init(void);
void NotifyTyping(int mode);
void SetButtonsPos(void);
- void ShowAvatar(void);
void ShowTime(bool bForce);
void SetupStatusBar(void);
void UpdateIcon(WPARAM wParam);
void UpdateLastMessage(void);
- void UpdateSizeBar(void);
static INT_PTR CALLBACK FilterWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
|