summaryrefslogtreecommitdiff
path: root/plugins
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 /plugins
parent54928843e7fcd6d42be6d8d5d1127830fda97eca (diff)
common code moved to mir_app
Diffstat (limited to 'plugins')
-rw-r--r--plugins/Scriver/src/chat.h3
-rw-r--r--plugins/Scriver/src/chat_window.cpp43
-rw-r--r--plugins/TabSRMM/src/chat.h3
-rw-r--r--plugins/TabSRMM/src/chat_log.cpp2
-rw-r--r--plugins/TabSRMM/src/chat_main.cpp4
-rw-r--r--plugins/TabSRMM/src/chat_window.cpp22
6 files changed, 18 insertions, 59 deletions
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!
diff --git a/plugins/TabSRMM/src/chat.h b/plugins/TabSRMM/src/chat.h
index e9f7b1ce0c..a18054cc5e 100644
--- a/plugins/TabSRMM/src/chat.h
+++ b/plugins/TabSRMM/src/chat.h
@@ -101,9 +101,6 @@ extern TMUCSettings g_Settings;
char* Log_CreateRtfHeader(MODULEINFO *mi);
char* Log_CreateRTF(LOGSTREAMDATA *streamData);
-// window.c
-int GetTextPixelSize(wchar_t* pszText, HFONT hFont, bool bWidth);
-
// options.c
enum { FONTSECTION_AUTO, FONTSECTION_IM, FONTSECTION_IP };
void LoadMsgDlgFont(int section, int i, LOGFONT *lf, COLORREF *colour, char *szModule);
diff --git a/plugins/TabSRMM/src/chat_log.cpp b/plugins/TabSRMM/src/chat_log.cpp
index 78831bd9ac..037d457fd7 100644
--- a/plugins/TabSRMM/src/chat_log.cpp
+++ b/plugins/TabSRMM/src/chat_log.cpp
@@ -674,7 +674,7 @@ char* Log_CreateRtfHeader(MODULEINFO *mi)
szString[0] = 0x28;
pci->LoadMsgDlgFont(17, &lf, nullptr);
HFONT hFont = CreateFontIndirect(&lf);
- int iText = GetTextPixelSize(szString, hFont, true) + 3;
+ int iText = Chat_GetTextPixelSize(szString, hFont, true) + 3;
DeleteObject(hFont);
iIndent += (iText * 1440) / pci->logPixelSX;
str.AppendFormat("\\tx%u", iIndent);
diff --git a/plugins/TabSRMM/src/chat_main.cpp b/plugins/TabSRMM/src/chat_main.cpp
index 3961448ba6..d461209b05 100644
--- a/plugins/TabSRMM/src/chat_main.cpp
+++ b/plugins/TabSRMM/src/chat_main.cpp
@@ -129,8 +129,8 @@ static void OnLoadSettings()
pci->LoadMsgDlgFont(5, &lf, nullptr);
g_Settings.UserListFonts[CHAT_STATUS_OFFLINE] = CreateFontIndirect(&lf);
- int ih = GetTextPixelSize(L"AQGglo", g_Settings.UserListFonts[CHAT_STATUS_NORMAL], false);
- int ih2 = GetTextPixelSize(L"AQGglo", g_Settings.UserListFonts[CHAT_STATUS_AWAY], false);
+ int ih = Chat_GetTextPixelSize(L"AQGglo", g_Settings.UserListFonts[CHAT_STATUS_NORMAL], false);
+ int ih2 = Chat_GetTextPixelSize(L"AQGglo", g_Settings.UserListFonts[CHAT_STATUS_AWAY], false);
g_Settings.iNickListFontHeight = max(M.GetByte(CHAT_MODULE, "NicklistRowDist", 12), (ih > ih2 ? ih : ih2));
for (int i = 0; i < 5; i++) {
diff --git a/plugins/TabSRMM/src/chat_window.cpp b/plugins/TabSRMM/src/chat_window.cpp
index 70e6fff18a..77574de5a7 100644
--- a/plugins/TabSRMM/src/chat_window.cpp
+++ b/plugins/TabSRMM/src/chat_window.cpp
@@ -455,26 +455,6 @@ LBL_SkipEnd:
return false;
}
-/////////////////////////////////////////////////////////////////////////////////////////
-// calculate the required rectangle for a string using the given font. This is more
-// precise than using GetTextExtentPoint...()
-
-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("TabSRMM: phase2");
@@ -915,7 +895,7 @@ void CChatRoomDlg::UpdateStatusBar()
return;
int x = 12;
- x += GetTextPixelSize(mi->ptszModDispName, (HFONT)SendMessage(m_pContainer->hwndStatus, WM_GETFONT, 0, 0), TRUE);
+ x += Chat_GetTextPixelSize(mi->ptszModDispName, (HFONT)SendMessage(m_pContainer->hwndStatus, WM_GETFONT, 0, 0), true);
x += GetSystemMetrics(SM_CXSMICON);
wchar_t szFinalStatusBarText[512];