summaryrefslogtreecommitdiff
path: root/src/core/stdmsg
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2017-03-27 14:15:17 +0300
committerGeorge Hazan <ghazan@miranda.im>2017-03-27 14:15:17 +0300
commitb3e8f72f17e9787aa5455977dc5eae05ddecb578 (patch)
tree0fb22846efd334599b9a8a774153e98aca3c97cb /src/core/stdmsg
parent54928843e7fcd6d42be6d8d5d1127830fda97eca (diff)
common code moved to mir_app
Diffstat (limited to 'src/core/stdmsg')
-rw-r--r--src/core/stdmsg/src/chat_window.cpp48
-rw-r--r--src/core/stdmsg/src/stdafx.h2
2 files changed, 18 insertions, 32 deletions
diff --git a/src/core/stdmsg/src/chat_window.cpp b/src/core/stdmsg/src/chat_window.cpp
index c0b40134fe..51f5ab8a98 100644
--- a/src/core/stdmsg/src/chat_window.cpp
+++ b/src/core/stdmsg/src/chat_window.cpp
@@ -26,28 +26,6 @@ static HKL hkl = nullptr;
static wchar_t szTrimString[] = L":;,.!?\'\"><()[]- \r\n";
-int GetTextPixelSize(wchar_t *pszText, HFONT hFont, BOOL bWidth)
-{
- if (!pszText || !hFont)
- return 0;
-
- HDC hdc = GetDC(nullptr);
- HFONT hOldFont = (HFONT)SelectObject(hdc, hFont);
- RECT rc = {};
- DrawText(hdc, pszText, -1, &rc, DT_CALCRECT);
- SelectObject(hdc, hOldFont);
- ReleaseDC(nullptr, hdc);
- return bWidth ? rc.right - rc.left : rc.bottom - rc.top;
-}
-
-static void __cdecl phase2(void *lParam)
-{
- SESSION_INFO *si = (SESSION_INFO*)lParam;
- Sleep(30);
- if (si && si->pDlg)
- si->pDlg->RedrawLog2();
-}
-
/////////////////////////////////////////////////////////////////////////////////////////
CChatRoomDlg::CChatRoomDlg(SESSION_INFO *si) :
@@ -306,6 +284,16 @@ void CChatRoomDlg::LoadSettings()
m_clrInputFG = g_Settings.MessageAreaColor;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
+static void __cdecl phase2(void *lParam)
+{
+ SESSION_INFO *si = (SESSION_INFO*)lParam;
+ Sleep(30);
+ if (si && si->pDlg)
+ si->pDlg->RedrawLog2();
+}
+
void CChatRoomDlg::RedrawLog()
{
m_si->LastTime = 0;
@@ -329,6 +317,8 @@ void CChatRoomDlg::RedrawLog()
else ClearLog();
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
void CChatRoomDlg::ScrollToBottom()
{
if ((GetWindowLongPtr(m_log.GetHwnd(), GWL_STYLE) & WS_VSCROLL) == 0)
@@ -409,8 +399,8 @@ void CChatRoomDlg::UpdateOptions()
m_message.SendMsg(EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&cf);
// nicklist
- int ih = GetTextPixelSize(L"AQGglo", g_Settings.UserListFont, FALSE);
- int ih2 = GetTextPixelSize(L"AQGglo", g_Settings.UserListHeadingsFont, FALSE);
+ int ih = Chat_GetTextPixelSize(L"AQGglo", g_Settings.UserListFont, FALSE);
+ int ih2 = Chat_GetTextPixelSize(L"AQGglo", g_Settings.UserListHeadingsFont, FALSE);
int height = db_get_b(0, CHAT_MODULE, "NicklistRowDist", 12);
int font = ih > ih2 ? ih : ih2;
@@ -430,7 +420,7 @@ void CChatRoomDlg::UpdateStatusBar()
MODULEINFO *mi = pci->MM_FindModule(m_si->pszModule);
wchar_t *ptszDispName = mi->ptszModDispName;
int x = 12;
- x += GetTextPixelSize(ptszDispName, (HFONT)SendMessage(m_hwndStatus, WM_GETFONT, 0, 0), TRUE);
+ x += Chat_GetTextPixelSize(ptszDispName, (HFONT)SendMessage(m_hwndStatus, WM_GETFONT, 0, 0), TRUE);
x += GetSystemMetrics(SM_CXSMICON);
int iStatusbarParts[2] = { x, -1 };
SendMessage(m_hwndStatus, SB_SETPARTS, 2, (LPARAM)&iStatusbarParts);
@@ -478,14 +468,12 @@ void CChatRoomDlg::UpdateTitle()
int CChatRoomDlg::Resizer(UTILRESIZECONTROL *urc)
{
- SESSION_INFO *si = m_si;
-
RECT rc;
bool bControl = db_get_b(0, CHAT_MODULE, "ShowTopButtons", 1) != 0;
bool bFormat = db_get_b(0, CHAT_MODULE, "ShowFormatButtons", 1) != 0;
bool bToolbar = bFormat || bControl;
bool bSend = db_get_b(0, CHAT_MODULE, "ShowSend", 0) != 0;
- bool bNick = si->iType != GCW_SERVER && m_bNicklistEnabled;
+ bool bNick = m_si->iType != GCW_SERVER && m_bNicklistEnabled;
switch (urc->wId) {
case IDOK:
@@ -1049,8 +1037,8 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
if (mis->CtlType == ODT_MENU)
return Menu_MeasureItem(lParam);
- int ih = GetTextPixelSize(L"AQGgl'", g_Settings.UserListFont, FALSE);
- int ih2 = GetTextPixelSize(L"AQGg'", g_Settings.UserListHeadingsFont, FALSE);
+ int ih = Chat_GetTextPixelSize(L"AQGgl'", g_Settings.UserListFont, FALSE);
+ int ih2 = Chat_GetTextPixelSize(L"AQGg'", g_Settings.UserListHeadingsFont, FALSE);
int font = ih > ih2 ? ih : ih2;
int height = db_get_b(0, CHAT_MODULE, "NicklistRowDist", 12);
diff --git a/src/core/stdmsg/src/stdafx.h b/src/core/stdmsg/src/stdafx.h
index b0e71e7644..7d7e196839 100644
--- a/src/core/stdmsg/src/stdafx.h
+++ b/src/core/stdmsg/src/stdafx.h
@@ -129,8 +129,6 @@ void ValidateFilename(wchar_t *filename);
char* Log_CreateRtfHeader(MODULEINFO *mi);
// window.cpp
-int GetTextPixelSize(wchar_t* pszText, HFONT hFont, BOOL bWidth);
-
SESSION_INFO* SM_GetPrevWindow(SESSION_INFO *si);
SESSION_INFO* SM_GetNextWindow(SESSION_INFO *si);