From b3e8f72f17e9787aa5455977dc5eae05ddecb578 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 27 Mar 2017 14:15:17 +0300 Subject: common code moved to mir_app --- plugins/Scriver/src/chat.h | 3 --- plugins/Scriver/src/chat_window.cpp | 43 ++++++++++++------------------------- 2 files changed, 14 insertions(+), 32 deletions(-) (limited to 'plugins/Scriver') diff --git a/plugins/Scriver/src/chat.h b/plugins/Scriver/src/chat.h index 54de98256a..8d40bbd6f2 100644 --- a/plugins/Scriver/src/chat.h +++ b/plugins/Scriver/src/chat.h @@ -70,9 +70,6 @@ extern GlobalLogSettings g_Settings; void LoadMsgLogBitmaps(void); void FreeMsgLogBitmaps(void); -// window.c -int GetTextPixelSize( wchar_t* pszText, HFONT hFont, BOOL bWidth); - // services.c void ShowRoom(SESSION_INFO *si); diff --git a/plugins/Scriver/src/chat_window.cpp b/plugins/Scriver/src/chat_window.cpp index 0c7398eb55..d431f6a89b 100644 --- a/plugins/Scriver/src/chat_window.cpp +++ b/plugins/Scriver/src/chat_window.cpp @@ -110,31 +110,6 @@ LBL_SkipEnd: } } -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 = { 0 }; - 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) -{ - Thread_SetName("Scriver: phase2"); - - SESSION_INFO *si = (SESSION_INFO*)lParam; - Sleep(30); - if (si && si->pDlg) - si->pDlg->RedrawLog2(); -} - void CChatRoomDlg::FixTabIcons() { HICON hIcon; @@ -404,6 +379,16 @@ void CChatRoomDlg::onChange_Message(CCtrlEdit *pEdit) ///////////////////////////////////////////////////////////////////////////////////////// +static void __cdecl phase2(void *lParam) +{ + Thread_SetName("Scriver: phase2"); + + SESSION_INFO *si = (SESSION_INFO*)lParam; + Sleep(30); + if (si && si->pDlg) + si->pDlg->RedrawLog2(); +} + void CChatRoomDlg::RedrawLog() { m_si->LastTime = 0; @@ -517,8 +502,8 @@ void CChatRoomDlg::UpdateOptions() m_message.SendMsg(EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&cf); { // nicklist - int ih = GetTextPixelSize(L"AQG_glo'", g_Settings.UserListFont, FALSE); - int ih2 = GetTextPixelSize(L"AQG_glo'", g_Settings.UserListHeadingsFont, FALSE); + int ih = Chat_GetTextPixelSize(L"AQG_glo'", g_Settings.UserListFont, false); + int ih2 = Chat_GetTextPixelSize(L"AQG_glo'", g_Settings.UserListHeadingsFont, false); int height = db_get_b(0, CHAT_MODULE, "NicklistRowDist", 12); int font = ih > ih2 ? ih : ih2; // make sure we have space for icon! @@ -971,8 +956,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); // make sure we have space for icon! -- cgit v1.2.3