From 8e116c496a0c0310f4621d469b35e46285ba6529 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 6 Feb 2019 18:34:58 +0300 Subject: fixes #1786 (Clist Modern constantly checks if the status message has been updated even if there's no need to do that) --- plugins/Clist_modern/src/init.cpp | 25 ++++ plugins/Clist_modern/src/modern_cache_funcs.h | 2 - plugins/Clist_modern/src/modern_cachefuncs.cpp | 34 ++--- plugins/Clist_modern/src/modern_clc.cpp | 2 +- plugins/Clist_modern/src/modern_clc.h | 25 ++-- plugins/Clist_modern/src/modern_clcopts.cpp | 2 + plugins/Clist_modern/src/modern_clcpaint.cpp | 28 ++-- plugins/Clist_modern/src/modern_clcutils.cpp | 40 ------ plugins/Clist_modern/src/modern_clistopts.cpp | 141 ++++++++++----------- plugins/Clist_modern/src/modern_clistsettings.cpp | 5 +- .../Clist_modern/src/modern_rowheight_funcs.cpp | 32 ++--- plugins/Clist_modern/src/stdafx.h | 20 ++- 12 files changed, 167 insertions(+), 189 deletions(-) (limited to 'plugins/Clist_modern/src') diff --git a/plugins/Clist_modern/src/init.cpp b/plugins/Clist_modern/src/init.cpp index aa7d618efe..7df2165ec6 100644 --- a/plugins/Clist_modern/src/init.cpp +++ b/plugins/Clist_modern/src/init.cpp @@ -109,6 +109,31 @@ int CMPlugin::Unload(void) ///////////////////////////////////////////////////////////////////////////////////////// +void CMPlugin::ReadSettings() +{ + wcsncpy_s(secondLine.text, getMStringW("SecondLineText"), _TRUNCATE); + secondLine.iType = getWord("SecondLineType", SETTING_SECONDLINE_TYPE_DEFAULT); + secondLine.bActive = getBool("SecondLineShow", SETTING_SECONDLINE_SHOW_DEFAULT); + secondLine.iTopSpace = getWord("SecondLineTopSpace", SETTING_SECONDLINE_TOPSPACE_DEFAULT); + secondLine.bDrawSmilies = getBool("SecondLineDrawSmileys", SETTING_SECONDLINE_SMILEYS_DEFAULT); + secondLine.bXstatusHasPriority = getBool("SecondLineXStatusHasPriority", SETTING_SECONDLINE_XSTATUS_DEFAULT); + secondLine.bShowStatusIfNoAway = getBool("SecondLineShowStatusIfNoAway", SETTING_SECONDLINE_STATUSIFNOAWAY_DEFAULT); + secondLine.bShowListeningIfNoAway = getBool("SecondLineShowListeningIfNoAway", SETTING_SECONDLINE_LISTENINGIFNOAWAY_DEFAULT); + secondLine.bUseNameAndMessageForXstatus = getBool("SecondLineUseNameAndMessageForXStatus", SETTING_SECONDLINE_XSTATUSNAMETEXT_DEFAULT); + + wcsncpy_s(thirdLine.text, getMStringW("ThirdLineText"), _TRUNCATE); + thirdLine.iType = getWord("ThirdLineType", SETTING_THIRDLINE_TYPE_DEFAULT); + thirdLine.bActive = getBool("ThirdLineShow", SETTING_THIRDLINE_SHOW_DEFAULT); + thirdLine.iTopSpace = getWord("ThirdLineTopSpace", SETTING_THIRDLINE_TOPSPACE_DEFAULT); + thirdLine.bDrawSmilies = getBool("ThirdLineDrawSmileys", SETTING_THIRDLINE_SMILEYS_DEFAULT); + thirdLine.bXstatusHasPriority = getBool("ThirdLineXStatusHasPriority", SETTING_THIRDLINE_XSTATUS_DEFAULT); + thirdLine.bShowStatusIfNoAway = getBool("ThirdLineShowStatusIfNoAway", SETTING_THIRDLINE_STATUSIFNOAWAY_DEFAULT); + thirdLine.bShowListeningIfNoAway = getBool("ThirdLineShowListeningIfNoAway", SETTING_THIRDLINE_LISTENINGIFNOAWAY_DEFAULT); + thirdLine.bUseNameAndMessageForXstatus = getBool("ThirdLineUseNameAndMessageForXStatus", SETTING_THIRDLINE_XSTATUSNAMETEXT_DEFAULT); +} + +///////////////////////////////////////////////////////////////////////////////////////// + static int cliShowHideStub() { return cliShowHide(false); } static HRESULT SubclassClistInterface() diff --git a/plugins/Clist_modern/src/modern_cache_funcs.h b/plugins/Clist_modern/src/modern_cache_funcs.h index 9dc21a46c2..3476972238 100644 --- a/plugins/Clist_modern/src/modern_cache_funcs.h +++ b/plugins/Clist_modern/src/modern_cache_funcs.h @@ -36,6 +36,4 @@ void Cache_GetAvatar(ClcData *dat, ClcContact *contact); void Cache_GetTimezone(ClcData *dat, MCONTACT hContact); int Cache_GetLineText(ClcCacheEntry *pdnce, int type, LPTSTR text, int text_size, ClcLineInfo &line); -void amRequestAwayMsg(MCONTACT hContact); - #endif // __CACHE_FUNCS_H__ diff --git a/plugins/Clist_modern/src/modern_cachefuncs.cpp b/plugins/Clist_modern/src/modern_cachefuncs.cpp index 77640cce7a..e0d6444fbe 100644 --- a/plugins/Clist_modern/src/modern_cachefuncs.cpp +++ b/plugins/Clist_modern/src/modern_cachefuncs.cpp @@ -64,9 +64,9 @@ void Cache_GetText(ClcData *dat, ClcContact *contact) Cache_GetFirstLineText(dat, contact); if (!dat->bForceInDialog) { - if (dat->secondLine.show) + if (g_plugin.secondLine.bActive) Cache_GetNthLineText(dat, contact->pce, 2); - if (dat->thirdLine.show) + if (g_plugin.thirdLine.bActive) Cache_GetNthLineText(dat, contact->pce, 3); } } @@ -270,7 +270,7 @@ void CSmileyString::ReplaceSmileys(ClcData *dat, ClcCacheEntry *pdnce, wchar_t * // Getting Status name // returns -1 for XStatus, 1 for Status // -int GetStatusName(wchar_t *text, int text_size, ClcCacheEntry *pdnce, BOOL xstatus_has_priority) +int GetStatusName(wchar_t *text, int text_size, ClcCacheEntry *pdnce, BOOL bXstatusHasPriority) { BOOL noAwayMsg = FALSE; BOOL noXstatus = FALSE; @@ -280,7 +280,7 @@ int GetStatusName(wchar_t *text, int text_size, ClcCacheEntry *pdnce, BOOL xstat if (nStatus == ID_STATUS_OFFLINE || nStatus == 0) noXstatus = TRUE; text[0] = '\0'; // Get XStatusName - if (!noAwayMsg && !noXstatus && xstatus_has_priority && pdnce->hContact && pdnce->szProto) { + if (!noAwayMsg && !noXstatus && bXstatusHasPriority && pdnce->hContact && pdnce->szProto) { DBVARIANT dbv = { 0 }; if (!db_get_ws(pdnce->hContact, pdnce->szProto, "XStatusName", &dbv)) { CopySkipUnprintableChars(text, dbv.pwszVal, text_size - 1); @@ -299,7 +299,7 @@ int GetStatusName(wchar_t *text, int text_size, ClcCacheEntry *pdnce, BOOL xstat } // Get XStatusName - if (!noAwayMsg && !noXstatus && !xstatus_has_priority && pdnce->hContact && pdnce->szProto) { + if (!noAwayMsg && !noXstatus && !bXstatusHasPriority && pdnce->hContact && pdnce->szProto) { DBVARIANT dbv = { 0 }; if (!db_get_ws(pdnce->hContact, pdnce->szProto, "XStatusName", &dbv)) { CopySkipUnprintableChars(text, dbv.pwszVal, text_size - 1); @@ -332,7 +332,7 @@ void GetListeningTo(wchar_t *text, int text_size, ClcCacheEntry *pdnce) // Getting Status message(Away message) // returns -1 for XStatus, 1 for Status // -int GetStatusMessage(wchar_t *text, int text_size, ClcCacheEntry *pdnce, BOOL xstatus_has_priority) +int GetStatusMessage(wchar_t *text, int text_size, ClcCacheEntry *pdnce, BOOL bXstatusHasPriority) { BOOL noAwayMsg = FALSE; WORD wStatus = pdnce->getStatus(); @@ -343,7 +343,7 @@ int GetStatusMessage(wchar_t *text, int text_size, ClcCacheEntry *pdnce, BOOL xs noAwayMsg = TRUE; // Get XStatusMsg - if (!noAwayMsg && xstatus_has_priority && pdnce->hContact && pdnce->szProto) { + if (!noAwayMsg && bXstatusHasPriority && pdnce->hContact && pdnce->szProto) { ptrW tszXStatusMsg(db_get_wsa(pdnce->hContact, pdnce->szProto, "XStatusMsg")); if (tszXStatusMsg != nullptr) { CopySkipUnprintableChars(text, tszXStatusMsg, text_size - 1); @@ -374,7 +374,7 @@ int GetStatusMessage(wchar_t *text, int text_size, ClcCacheEntry *pdnce, BOOL xs } // Get XStatusMsg - if (!noAwayMsg && !xstatus_has_priority && pdnce->hContact && pdnce->szProto && text[0] == '\0') { + if (!noAwayMsg && !bXstatusHasPriority && pdnce->hContact && pdnce->szProto && text[0] == '\0') { // Try to get XStatusMsg ptrW tszXStatusMsg(db_get_wsa(pdnce->hContact, pdnce->szProto, "XStatusMsg")); if (tszXStatusMsg != nullptr) { @@ -399,7 +399,7 @@ int Cache_GetLineText(ClcCacheEntry *pdnce, int type, LPTSTR text, int text_size switch (type) { case TEXT_STATUS: LBL_Status: - if (GetStatusName(text, text_size, pdnce, line.xstatus_has_priority) == -1 && line.use_name_and_message_for_xstatus) { + if (GetStatusName(text, text_size, pdnce, line.bXstatusHasPriority) == -1 && line.bUseNameAndMessageForXstatus) { // Try to get XStatusMsg ptrW tszXStatusMsg(db_get_wsa(pdnce->hContact, pdnce->szProto, "XStatusMsg")); if (tszXStatusMsg != nullptr && tszXStatusMsg[0] != 0) { @@ -421,7 +421,7 @@ LBL_Status: return TEXT_NICKNAME; case TEXT_STATUS_MESSAGE: - if (GetStatusMessage(text, text_size, pdnce, line.xstatus_has_priority) == -1 && line.use_name_and_message_for_xstatus) { + if (GetStatusMessage(text, text_size, pdnce, line.bXstatusHasPriority) == -1 && line.bUseNameAndMessageForXstatus) { // Try to get XStatusName ptrW tszXStatusName(db_get_wsa(pdnce->hContact, pdnce->szProto, "XStatusName")); if (tszXStatusName != nullptr && tszXStatusName[0] != 0) { @@ -430,7 +430,7 @@ LBL_Status: CopySkipUnprintableChars(text, text, text_size - 1); } } - else if (line.use_name_and_message_for_xstatus && line.xstatus_has_priority) { + else if (line.bUseNameAndMessageForXstatus && line.bXstatusHasPriority) { // Try to get XStatusName ptrW tszXStatusName(db_get_wsa(pdnce->hContact, pdnce->szProto, "XStatusName")); if (tszXStatusName != nullptr && tszXStatusName[0] != 0) { @@ -440,13 +440,13 @@ LBL_Status: } if (text[0] == '\0') { - if (line.show_listening_if_no_away) { + if (line.bShowListeningIfNoAway) { GetListeningTo(text, text_size, pdnce); if (text[0] != '\0') return TEXT_LISTENING_TO; } - if (line.show_status_if_no_away) // re-request status if no away + if (line.bShowStatusIfNoAway) // re-request status if no away goto LBL_Status; } return TEXT_STATUS_MESSAGE; @@ -512,16 +512,16 @@ void Cache_GetFirstLineText(ClcData *dat, ClcContact *contact) void Cache_GetNthLineText(ClcData *dat, ClcCacheEntry *pdnce, int n) { wchar_t Text[240 - EXTRA_ICON_COUNT]; Text[0] = 0; - ClcLineInfo &line = (n == 2) ? dat->secondLine : dat->thirdLine; + ClcLineInfo &line = (n == 2) ? g_plugin.secondLine : g_plugin.thirdLine; wchar_t* &szText = (n == 2) ? pdnce->szSecondLineText : pdnce->szThirdLineText; // in most cases replaceStrW does nothing - if (!line.show) { + if (!line.bActive) { replaceStrW(szText, nullptr); return; } - int type = Cache_GetLineText(pdnce, line.type, Text, _countof(Text), line); + int type = Cache_GetLineText(pdnce, line.iType, Text, _countof(Text), line); if (Text[0] == 0) { replaceStrW(szText, nullptr); return; @@ -534,7 +534,7 @@ void Cache_GetNthLineText(ClcData *dat, ClcCacheEntry *pdnce, int n) if (type == TEXT_LISTENING_TO && szText[0] != '\0') ss.AddListeningToIcon(dat, szText); else - ss.ReplaceSmileys(dat, pdnce, szText, line.draw_smileys); + ss.ReplaceSmileys(dat, pdnce, szText, line.bDrawSmilies); } ///////////////////////////////////////////////////////////////////////////////////////// diff --git a/plugins/Clist_modern/src/modern_clc.cpp b/plugins/Clist_modern/src/modern_clc.cpp index be37c637b9..ef4e3da383 100644 --- a/plugins/Clist_modern/src/modern_clc.cpp +++ b/plugins/Clist_modern/src/modern_clc.cpp @@ -302,7 +302,7 @@ static LRESULT clcOnCreate(ClcData *dat, HWND hwnd, UINT msg, WPARAM wParam, LPA dat->menuOwnerType = CLCIT_INVALID; corecli.pfnContactListControlWndProc(hwnd, msg, wParam, lParam); - if (dat->contact_time_show || dat->secondLine.type == TEXT_CONTACT_TIME || dat->thirdLine.type == TEXT_CONTACT_TIME) + if (dat->contact_time_show || g_plugin.secondLine.iType == TEXT_CONTACT_TIME || g_plugin.thirdLine.iType == TEXT_CONTACT_TIME) CLUI_SafeSetTimer(hwnd, TIMERID_INVALIDATE, 5000, nullptr); else KillTimer(hwnd, TIMERID_INVALIDATE); diff --git a/plugins/Clist_modern/src/modern_clc.h b/plugins/Clist_modern/src/modern_clc.h index cfda8d706f..b40cb9c8f3 100644 --- a/plugins/Clist_modern/src/modern_clc.h +++ b/plugins/Clist_modern/src/modern_clc.h @@ -132,8 +132,6 @@ void clcSetDelayTimer(UINT_PTR uIDEvent, HWND hwnd, int nDelay = -1); #define TEXT_CONTACT_TIME 4 #define TEXT_LISTENING_TO 5 -#define TEXT_TEXT_MAX_LENGTH 1024 - typedef struct tagClcContactTextPiece { int type; @@ -210,15 +208,19 @@ struct ClcContact : public ClcContactBase struct ClcLineInfo { - BOOL show; - int top_space; - BOOL draw_smileys; - int type; + bool bActive; + bool bDrawSmilies; + int iType; + int iTopSpace; + bool bXstatusHasPriority; + bool bShowStatusIfNoAway; + bool bShowListeningIfNoAway; + bool bUseNameAndMessageForXstatus; wchar_t text[TEXT_TEXT_MAX_LENGTH]; - BOOL xstatus_has_priority; - BOOL show_status_if_no_away; - BOOL show_listening_if_no_away; - BOOL use_name_and_message_for_xstatus; + + int getType() const + { return (bActive) ? iType : -1; + } }; struct ClcModernFontInfo { @@ -299,9 +301,6 @@ struct ClcData : public ClcDataBase BOOL first_line_draw_smileys; BOOL first_line_append_nick; - // Second & third line - ClcLineInfo secondLine, thirdLine; - ClcModernFontInfo fontModernInfo[FONTID_MODERN_MAX + 1]; HWND hWnd; BYTE menuOwnerType; diff --git a/plugins/Clist_modern/src/modern_clcopts.cpp b/plugins/Clist_modern/src/modern_clcopts.cpp index 2146ce9f38..9058bf6e4c 100644 --- a/plugins/Clist_modern/src/modern_clcopts.cpp +++ b/plugins/Clist_modern/src/modern_clcopts.cpp @@ -758,6 +758,8 @@ static INT_PTR CALLBACK DlgProcTrayOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L void ClcOptionsChanged(void) { + g_plugin.ReadSettings(); + Clist_Broadcast(INTM_RELOADOPTIONS, 0, 0); Clist_Broadcast(INTM_INVALIDATE, 0, 0); } diff --git a/plugins/Clist_modern/src/modern_clcpaint.cpp b/plugins/Clist_modern/src/modern_clcpaint.cpp index e3b9de8bb4..a06a0c4b2a 100644 --- a/plugins/Clist_modern/src/modern_clcpaint.cpp +++ b/plugins/Clist_modern/src/modern_clcpaint.cpp @@ -1029,7 +1029,7 @@ void CLCPaint::_PaintRowItemsEx(HDC hdcMem, ClcData *dat, ClcContact *Drawing, R // Select font UINT uTextFormat = (dat->text_rtl ? DT_RTLREADING : 0); - if (dat->secondLine.show && dat->secondLine.type == TEXT_CONTACT_TIME && pdnce->hTimeZone) { + if (g_plugin.secondLine.bActive && g_plugin.secondLine.iType == TEXT_CONTACT_TIME && pdnce->hTimeZone) { // Get contact time wchar_t buf[70] = L""; mir_free_and_nil(pdnce->szSecondLineText); @@ -1057,7 +1057,7 @@ void CLCPaint::_PaintRowItemsEx(HDC hdcMem, ClcData *dat, ClcContact *Drawing, R // Select font UINT uTextFormat = (dat->text_rtl ? DT_RTLREADING : 0); - if (dat->thirdLine.show && dat->thirdLine.type == TEXT_CONTACT_TIME && pdnce->hTimeZone) { + if (g_plugin.thirdLine.bActive && g_plugin.thirdLine.iType == TEXT_CONTACT_TIME && pdnce->hTimeZone) { // Get contact time wchar_t buf[70] = L""; mir_free(pdnce->szThirdLineText); @@ -2211,15 +2211,15 @@ void CLCPaint::_CalcItemsPos(HDC hdcMem, ClcData *dat, ClcContact *Drawing, RECT } } else if (Drawing->type == CLCIT_CONTACT && !CheckMiniMode(dat, selected)) { - if (dat->secondLine.show) { - if (dat->secondLine.type == TEXT_CONTACT_TIME && pdnce->hTimeZone) { + if (g_plugin.secondLine.bActive) { + if (g_plugin.secondLine.iType == TEXT_CONTACT_TIME && pdnce->hTimeZone) { // Get contact time wchar_t buf[70] = L""; TimeZone_PrintDateTime(pdnce->hTimeZone, L"t", buf, _countof(buf), 0); replaceStrW(pdnce->szSecondLineText, buf); } - if (pdnce->szSecondLineText && pdnce->szSecondLineText[0] && free_height > dat->secondLine.top_space) { + if (pdnce->szSecondLineText && pdnce->szSecondLineText[0] && free_height > g_plugin.secondLine.iTopSpace) { ChangeToFont(hdcMem, dat, FONTID_SECONDLINE, nullptr); // Get sizes @@ -2227,7 +2227,7 @@ void CLCPaint::_CalcItemsPos(HDC hdcMem, ClcData *dat, ClcContact *Drawing, RECT uTextFormat, dat->text_resize_smileys ? 0 : pdnce->ssSecondLine.iMaxSmileyHeight); // Get rect - int tmp = min(free_height, dat->secondLine.top_space + second_line_text_size.cy); + int tmp = min(free_height, g_plugin.secondLine.iTopSpace + second_line_text_size.cy); free_height -= tmp; text_rc.top = free_row_rc.top + (free_height >> 1); @@ -2241,17 +2241,17 @@ void CLCPaint::_CalcItemsPos(HDC hdcMem, ClcData *dat, ClcContact *Drawing, RECT selection_text_rc.top = text_rc.top; selection_text_rc.bottom = min(selection_text_rc.bottom, selection_text_rc.top + text_size.cy); - max_bottom_selection_border = min(max_bottom_selection_border, dat->secondLine.top_space / 2); + max_bottom_selection_border = min(max_bottom_selection_border, g_plugin.secondLine.iTopSpace / 2); } } - if (dat->thirdLine.show) { - if (dat->thirdLine.type == TEXT_CONTACT_TIME && pdnce->hTimeZone) { + if (g_plugin.thirdLine.bActive) { + if (g_plugin.thirdLine.iType == TEXT_CONTACT_TIME && pdnce->hTimeZone) { // Get contact time wchar_t buf[70] = L""; TimeZone_PrintDateTime(pdnce->hTimeZone, L"t", buf, _countof(buf), 0); replaceStrW(pdnce->szThirdLineText, buf); } - if (pdnce->szThirdLineText != nullptr && pdnce->szThirdLineText[0] && free_height > dat->thirdLine.top_space) { + if (pdnce->szThirdLineText != nullptr && pdnce->szThirdLineText[0] && free_height > g_plugin.thirdLine.iTopSpace) { ChangeToFont(hdcMem, dat, FONTID_THIRDLINE, nullptr); // Get sizes @@ -2259,7 +2259,7 @@ void CLCPaint::_CalcItemsPos(HDC hdcMem, ClcData *dat, ClcContact *Drawing, RECT uTextFormat, dat->text_resize_smileys ? 0 : pdnce->ssThirdLine.iMaxSmileyHeight); // Get rect - int tmp = min(free_height, dat->thirdLine.top_space + third_line_text_size.cy); + int tmp = min(free_height, g_plugin.thirdLine.iTopSpace + third_line_text_size.cy); free_height -= tmp; text_rc.top = free_row_rc.top + (free_height >> 1); @@ -2273,7 +2273,7 @@ void CLCPaint::_CalcItemsPos(HDC hdcMem, ClcData *dat, ClcContact *Drawing, RECT selection_text_rc.top = text_rc.top; selection_text_rc.bottom = min(selection_text_rc.bottom, selection_text_rc.top + text_size.cy); - max_bottom_selection_border = min(max_bottom_selection_border, dat->thirdLine.top_space / 2); + max_bottom_selection_border = min(max_bottom_selection_border, g_plugin.thirdLine.iTopSpace / 2); } } @@ -2372,7 +2372,7 @@ void CLCPaint::_CalcItemsPos(HDC hdcMem, ClcData *dat, ClcContact *Drawing, RECT } uTextFormat &= ~DT_VCENTER; if (second_line_text_size.cx > 0 && free_rc.bottom > free_rc.top) { - free_rc.top += dat->secondLine.top_space; + free_rc.top += g_plugin.secondLine.iTopSpace; if (free_rc.bottom > free_rc.top) { RECT rc = free_rc; @@ -2390,7 +2390,7 @@ void CLCPaint::_CalcItemsPos(HDC hdcMem, ClcData *dat, ClcContact *Drawing, RECT } if (third_line_text_size.cx > 0 && free_rc.bottom > free_rc.top) { - free_rc.top += dat->thirdLine.top_space; + free_rc.top += g_plugin.thirdLine.iTopSpace; if (free_rc.bottom > free_rc.top) { RECT rc = free_rc; diff --git a/plugins/Clist_modern/src/modern_clcutils.cpp b/plugins/Clist_modern/src/modern_clcutils.cpp index 57a6be4572..e1760c824f 100644 --- a/plugins/Clist_modern/src/modern_clcutils.cpp +++ b/plugins/Clist_modern/src/modern_clcutils.cpp @@ -558,46 +558,6 @@ void cli_LoadCLCOptions(HWND hwnd, ClcData *dat, BOOL bFirst) dat->first_line_append_nick = g_plugin.getByte("FirstLineAppendNick", SETTING_FIRSTLINE_APPENDNICK_DEFAULT); gl_TrimText = g_plugin.getByte("TrimText", SETTING_FIRSTLINE_TRIMTEXT_DEFAULT); - // Second line - if (g_clistApi.hwndContactTree == hwnd || g_clistApi.hwndContactTree == nullptr) { - dat->secondLine.show = g_plugin.getByte("SecondLineShow", SETTING_SECONDLINE_SHOW_DEFAULT); - dat->secondLine.top_space = g_plugin.getWord("SecondLineTopSpace", SETTING_SECONDLINE_TOPSPACE_DEFAULT); - dat->secondLine.draw_smileys = g_plugin.getByte("SecondLineDrawSmileys", SETTING_SECONDLINE_SMILEYS_DEFAULT); - dat->secondLine.type = g_plugin.getWord("SecondLineType", SETTING_SECONDLINE_TYPE_DEFAULT); - - ptrW tszLineText(g_plugin.getWStringA("SecondLineText")); - if (tszLineText) - wcsncpy_s(dat->secondLine.text, tszLineText, _TRUNCATE); - else - dat->secondLine.text[0] = '\0'; - - dat->secondLine.xstatus_has_priority = g_plugin.getByte("SecondLineXStatusHasPriority", SETTING_SECONDLINE_XSTATUS_DEFAULT); - dat->secondLine.show_status_if_no_away = g_plugin.getByte("SecondLineShowStatusIfNoAway", SETTING_SECONDLINE_STATUSIFNOAWAY_DEFAULT); - dat->secondLine.show_listening_if_no_away = g_plugin.getByte("SecondLineShowListeningIfNoAway", SETTING_SECONDLINE_LISTENINGIFNOAWAY_DEFAULT); - dat->secondLine.use_name_and_message_for_xstatus = g_plugin.getByte("SecondLineUseNameAndMessageForXStatus", SETTING_SECONDLINE_XSTATUSNAMETEXT_DEFAULT); - } - else memset(&dat->secondLine, 0, sizeof(dat->secondLine)); - - // Third line - if (g_clistApi.hwndContactTree == hwnd || g_clistApi.hwndContactTree == nullptr) { - dat->thirdLine.show = g_plugin.getByte("ThirdLineShow", SETTING_THIRDLINE_SHOW_DEFAULT); - dat->thirdLine.top_space = g_plugin.getWord("ThirdLineTopSpace", SETTING_THIRDLINE_TOPSPACE_DEFAULT); - dat->thirdLine.draw_smileys = g_plugin.getByte("ThirdLineDrawSmileys", SETTING_THIRDLINE_SMILEYS_DEFAULT); - dat->thirdLine.type = g_plugin.getWord("ThirdLineType", SETTING_THIRDLINE_TYPE_DEFAULT); - - ptrW tszLineText(g_plugin.getWStringA("ThirdLineText")); - if (tszLineText) - wcsncpy_s(dat->thirdLine.text, tszLineText, _TRUNCATE); - else - dat->thirdLine.text[0] = '\0'; - - dat->thirdLine.xstatus_has_priority = g_plugin.getByte("ThirdLineXStatusHasPriority", SETTING_THIRDLINE_XSTATUS_DEFAULT); - dat->thirdLine.show_status_if_no_away = g_plugin.getByte("ThirdLineShowStatusIfNoAway", SETTING_THIRDLINE_STATUSIFNOAWAY_DEFAULT); - dat->thirdLine.show_listening_if_no_away = g_plugin.getByte("ThirdLineShowListeningIfNoAway", SETTING_THIRDLINE_LISTENINGIFNOAWAY_DEFAULT); - dat->thirdLine.use_name_and_message_for_xstatus = g_plugin.getByte("ThirdLineUseNameAndMessageForXStatus", SETTING_THIRDLINE_XSTATUSNAMETEXT_DEFAULT); - } - else memset(&dat->thirdLine, 0, sizeof(dat->thirdLine)); - dat->rightMargin = db_get_b(0, "CLC", "RightMargin", CLCDEFAULT_RIGHTMARGIN); dat->topMargin = db_get_b(0, "CLC", "TopMargin", 0); dat->bottomMargin = db_get_b(0, "CLC", "BottomMargin", 0); diff --git a/plugins/Clist_modern/src/modern_clistopts.cpp b/plugins/Clist_modern/src/modern_clistopts.cpp index fc36bc0776..b9b6252dd5 100644 --- a/plugins/Clist_modern/src/modern_clistopts.cpp +++ b/plugins/Clist_modern/src/modern_clistopts.cpp @@ -37,11 +37,11 @@ static INT_PTR CALLBACK DlgProcItemRowOpts(HWND hwndDlg, UINT msg, WPARAM wParam SendDlgItemMessage(hwndDlg, IDC_ROW_BORDER_SPIN, UDM_SETRANGE, 0, MAKELONG(255, 0)); SendDlgItemMessage(hwndDlg, IDC_ROW_BORDER_SPIN, UDM_SETPOS, 0, MAKELONG(g_plugin.getWord("RowBorder", SETTING_ROWBORDER_DEFAULT), 0)); - CheckDlgButton(hwndDlg, IDC_VARIABLE_ROW_HEIGHT, g_plugin.getByte("VariableRowHeight", SETTING_VARIABLEROWHEIGHT_DEFAULT) == 1 ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_ALIGN_TO_LEFT, g_plugin.getByte("AlignLeftItemsToLeft", SETTING_ALIGNLEFTTOLEFT_DEFAULT) == 1 ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_ALIGN_TO_RIGHT, g_plugin.getByte("AlignRightItemsToRight", SETTING_ALIGNRIGHTORIGHT_DEFAULT) == 1 ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_VARIABLE_ROW_HEIGHT, g_plugin.getByte("VariableRowHeight", SETTING_VARIABLEROWHEIGHT_DEFAULT) == 1); + CheckDlgButton(hwndDlg, IDC_ALIGN_TO_LEFT, g_plugin.getByte("AlignLeftItemsToLeft", SETTING_ALIGNLEFTTOLEFT_DEFAULT) == 1); + CheckDlgButton(hwndDlg, IDC_ALIGN_TO_RIGHT, g_plugin.getByte("AlignRightItemsToRight", SETTING_ALIGNRIGHTORIGHT_DEFAULT) == 1); - CheckDlgButton(hwndDlg, IDC_MINIMODE, db_get_b(0, "CLC", "CompactMode", SETTING_COMPACTMODE_DEFAULT) == 1 ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_MINIMODE, db_get_b(0, "CLC", "CompactMode", SETTING_COMPACTMODE_DEFAULT) == 1); SendDlgItemMessage(hwndDlg, IDC_LEFTMARGINSPIN, UDM_SETBUDDY, (WPARAM)GetDlgItem(hwndDlg, IDC_LEFTMARGIN), 0); // set buddy SendDlgItemMessage(hwndDlg, IDC_LEFTMARGINSPIN, UDM_SETRANGE, 0, MAKELONG(64, 0)); @@ -224,14 +224,14 @@ static INT_PTR CALLBACK DlgProcItemAvatarOpts(HWND hwndDlg, UINT msg, WPARAM wPa switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); - CheckDlgButton(hwndDlg, IDC_SHOW_AVATARS, g_plugin.getByte("AvatarsShow", SETTINGS_SHOWAVATARS_DEFAULT) == 1 ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_SHOW_AVATARS, g_plugin.getByte("AvatarsShow", SETTINGS_SHOWAVATARS_DEFAULT) == 1); CheckDlgButton(hwndDlg, IDC_SHOW_ANIAVATARS, g_plugin.getByte("AvatarsAnimated", BST_CHECKED)); - CheckDlgButton(hwndDlg, IDC_AVATAR_FASTDRAW, g_plugin.getByte("AvatarsInSeparateWnd", SETTINGS_AVATARINSEPARATE_DEFAULT) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_AVATAR_DRAW_BORDER, g_plugin.getByte("AvatarsDrawBorders", SETTINGS_AVATARDRAWBORDER_DEFAULT) == 1 ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_AVATAR_ROUND_CORNERS, g_plugin.getByte("AvatarsRoundCorners", SETTINGS_AVATARROUNDCORNERS_DEFAULT) == 1 ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_AVATAR_CUSTOM_CORNER_SIZE_CHECK, g_plugin.getByte("AvatarsUseCustomCornerSize", SETTINGS_AVATARUSECUTOMCORNERSIZE_DEFAULT) == 1 ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_AVATAR_IGNORE_SIZE, g_plugin.getByte("AvatarsIgnoreSizeForRow", SETTINGS_AVATARIGNORESIZEFORROW_DEFAULT) == 1 ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_AVATAR_OVERLAY_ICONS, g_plugin.getByte("AvatarsDrawOverlay", SETTINGS_AVATARDRAWOVERLAY_DEFAULT) == 1 ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_AVATAR_FASTDRAW, g_plugin.getByte("AvatarsInSeparateWnd", SETTINGS_AVATARINSEPARATE_DEFAULT)); + CheckDlgButton(hwndDlg, IDC_AVATAR_DRAW_BORDER, g_plugin.getByte("AvatarsDrawBorders", SETTINGS_AVATARDRAWBORDER_DEFAULT) == 1); + CheckDlgButton(hwndDlg, IDC_AVATAR_ROUND_CORNERS, g_plugin.getByte("AvatarsRoundCorners", SETTINGS_AVATARROUNDCORNERS_DEFAULT) == 1); + CheckDlgButton(hwndDlg, IDC_AVATAR_CUSTOM_CORNER_SIZE_CHECK, g_plugin.getByte("AvatarsUseCustomCornerSize", SETTINGS_AVATARUSECUTOMCORNERSIZE_DEFAULT) == 1); + CheckDlgButton(hwndDlg, IDC_AVATAR_IGNORE_SIZE, g_plugin.getByte("AvatarsIgnoreSizeForRow", SETTINGS_AVATARIGNORESIZEFORROW_DEFAULT) == 1); + CheckDlgButton(hwndDlg, IDC_AVATAR_OVERLAY_ICONS, g_plugin.getByte("AvatarsDrawOverlay", SETTINGS_AVATARDRAWOVERLAY_DEFAULT) == 1); switch (g_plugin.getByte("AvatarsOverlayType", SETTINGS_AVATAROVERLAYTYPE_DEFAULT)) { case SETTING_AVATAR_OVERLAY_TYPE_NORMAL: @@ -413,14 +413,14 @@ static INT_PTR CALLBACK DlgProcItemIconOpts(HWND hwndDlg, UINT msg, WPARAM wPara switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); - CheckDlgButton(hwndDlg, IDC_HIDE_ICON_ON_AVATAR, g_plugin.getByte("IconHideOnAvatar", SETTING_HIDEICONONAVATAR_DEFAULT) == 1 ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_DRAW_ON_AVATAR_SPACE, g_plugin.getByte("IconDrawOnAvatarSpace", SETTING_ICONONAVATARPLACE_DEFAULT) == 1 ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_ICONBLINK, g_plugin.getByte("NoIconBlink", SETTING_NOICONBLINF_DEFAULT) == 1 ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_HIDE_GROUPSICON, g_plugin.getByte("HideGroupsIcon", SETTING_HIDEGROUPSICON_DEFAULT) == 1 ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_NOTCHECKICONSIZE, g_plugin.getByte("IconIgnoreSizeForRownHeight", SETTING_ICONIGNORESIZE_DEFAULT) == 1 ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_ALWAYS_VISIBLEICON, g_plugin.getByte("AlwaysShowAlwaysVisIcon", SETTING_ALWAYSVISICON_DEFAULT) == 1 ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_USEXSTATUS, (db_get_b(0, "CLC", "DrawOverlayedStatus", SETTING_DRAWOVERLAYEDSTATUS_DEFAULT) & 1) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_DRAWSTATUSOVERLAY, (db_get_b(0, "CLC", "DrawOverlayedStatus", SETTING_DRAWOVERLAYEDSTATUS_DEFAULT) & 2) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_HIDE_ICON_ON_AVATAR, g_plugin.getByte("IconHideOnAvatar", SETTING_HIDEICONONAVATAR_DEFAULT) == 1); + CheckDlgButton(hwndDlg, IDC_DRAW_ON_AVATAR_SPACE, g_plugin.getByte("IconDrawOnAvatarSpace", SETTING_ICONONAVATARPLACE_DEFAULT) == 1); + CheckDlgButton(hwndDlg, IDC_ICONBLINK, g_plugin.getByte("NoIconBlink", SETTING_NOICONBLINF_DEFAULT) == 1); + CheckDlgButton(hwndDlg, IDC_HIDE_GROUPSICON, g_plugin.getByte("HideGroupsIcon", SETTING_HIDEGROUPSICON_DEFAULT) == 1); + CheckDlgButton(hwndDlg, IDC_NOTCHECKICONSIZE, g_plugin.getByte("IconIgnoreSizeForRownHeight", SETTING_ICONIGNORESIZE_DEFAULT) == 1); + CheckDlgButton(hwndDlg, IDC_ALWAYS_VISIBLEICON, g_plugin.getByte("AlwaysShowAlwaysVisIcon", SETTING_ALWAYSVISICON_DEFAULT) == 1); + CheckDlgButton(hwndDlg, IDC_USEXSTATUS, (db_get_b(0, "CLC", "DrawOverlayedStatus", SETTING_DRAWOVERLAYEDSTATUS_DEFAULT) & 1)); + CheckDlgButton(hwndDlg, IDC_DRAWSTATUSOVERLAY, (db_get_b(0, "CLC", "DrawOverlayedStatus", SETTING_DRAWOVERLAYEDSTATUS_DEFAULT) & 2)); EnableWindow(GetDlgItem(hwndDlg, IDC_DRAWSTATUSOVERLAY), IsDlgButtonChecked(hwndDlg, IDC_USEXSTATUS)); if (BST_UNCHECKED == IsDlgButtonChecked(hwndDlg, IDC_HIDE_ICON_ON_AVATAR)) @@ -472,8 +472,8 @@ static INT_PTR CALLBACK DlgProcItemContactTimeOpts(HWND hwndDlg, UINT msg, WPARA switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); - CheckDlgButton(hwndDlg, IDC_SHOW, g_plugin.getByte("ContactTimeShow", SETTING_SHOWTIME_DEFAULT) == 1 ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_SHOW_ONLY_IF_DIFFERENT, g_plugin.getByte("ContactTimeShowOnlyIfDifferent", SETTING_SHOWTIMEIFDIFF_DEFAULT) == 1 ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_SHOW, g_plugin.getByte("ContactTimeShow", SETTING_SHOWTIME_DEFAULT) == 1); + CheckDlgButton(hwndDlg, IDC_SHOW_ONLY_IF_DIFFERENT, g_plugin.getByte("ContactTimeShowOnlyIfDifferent", SETTING_SHOWTIMEIFDIFF_DEFAULT) == 1); break; case WM_COMMAND: @@ -504,7 +504,7 @@ static INT_PTR CALLBACK DlgProcItemTextOpts(HWND hwndDlg, UINT msg, WPARAM wPara switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); - CheckDlgButton(hwndDlg, IDC_RTL, g_plugin.getByte("TextRTL", SETTING_TEXT_RTL_DEFAULT) == 1 ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_RTL, g_plugin.getByte("TextRTL", SETTING_TEXT_RTL_DEFAULT) == 1); { int item; wchar_t *align[] = { LPGENW("Left align group names"), LPGENW("Center group names"), LPGENW("Right align group names") }; @@ -512,15 +512,15 @@ static INT_PTR CALLBACK DlgProcItemTextOpts(HWND hwndDlg, UINT msg, WPARAM wPara item = SendDlgItemMessage(hwndDlg, IDC_ALIGNGROUPCOMBO, CB_ADDSTRING, 0, (LPARAM)TranslateW(align[i])); SendDlgItemMessage(hwndDlg, IDC_ALIGNGROUPCOMBO, CB_SETCURSEL, g_plugin.getByte("AlignGroupCaptions", SETTING_ALIGNGROPCAPTION_DEFAULT), 0); } - CheckDlgButton(hwndDlg, IDC_ALIGN_RIGHT, g_plugin.getByte("TextAlignToRight", SETTING_TEXT_RIGHTALIGN_DEFAULT) == 1 ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_REPLACE_SMILEYS, g_plugin.getByte("TextReplaceSmileys", SETTING_TEXT_SMILEY_DEFAULT) == 1 ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_RESIZE_SMILEYS, g_plugin.getByte("TextResizeSmileys", SETTING_TEXT_RESIZESMILEY_DEFAULT) == 1 ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_USE_PROTOCOL_SMILEYS, g_plugin.getByte("TextUseProtocolSmileys", SETTING_TEXT_PROTOSMILEY_DEFAULT) == 1 ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_IGNORE_SIZE, g_plugin.getByte("TextIgnoreSizeForRownHeight", SETTING_TEXT_IGNORESIZE_DEFAULT) == 1 ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_ALIGN_RIGHT, g_plugin.getByte("TextAlignToRight", SETTING_TEXT_RIGHTALIGN_DEFAULT) == 1); + CheckDlgButton(hwndDlg, IDC_REPLACE_SMILEYS, g_plugin.getByte("TextReplaceSmileys", SETTING_TEXT_SMILEY_DEFAULT) == 1); + CheckDlgButton(hwndDlg, IDC_RESIZE_SMILEYS, g_plugin.getByte("TextResizeSmileys", SETTING_TEXT_RESIZESMILEY_DEFAULT) == 1); + CheckDlgButton(hwndDlg, IDC_USE_PROTOCOL_SMILEYS, g_plugin.getByte("TextUseProtocolSmileys", SETTING_TEXT_PROTOSMILEY_DEFAULT) == 1); + CheckDlgButton(hwndDlg, IDC_IGNORE_SIZE, g_plugin.getByte("TextIgnoreSizeForRownHeight", SETTING_TEXT_IGNORESIZE_DEFAULT) == 1); - CheckDlgButton(hwndDlg, IDC_DRAW_SMILEYS_ON_FIRST_LINE, g_plugin.getByte("FirstLineDrawSmileys", SETTING_FIRSTLINE_SMILEYS_DEFAULT) == 1 ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_APPEND_NICK, g_plugin.getByte("FirstLineAppendNick", SETTING_FIRSTLINE_APPENDNICK_DEFAULT) == 1 ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_TRIM_TEXT, g_plugin.getByte("TrimText", SETTING_FIRSTLINE_TRIMTEXT_DEFAULT) == 1 ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_DRAW_SMILEYS_ON_FIRST_LINE, g_plugin.getByte("FirstLineDrawSmileys", SETTING_FIRSTLINE_SMILEYS_DEFAULT) == 1); + CheckDlgButton(hwndDlg, IDC_APPEND_NICK, g_plugin.getByte("FirstLineAppendNick", SETTING_FIRSTLINE_APPENDNICK_DEFAULT) == 1); + CheckDlgButton(hwndDlg, IDC_TRIM_TEXT, g_plugin.getByte("TrimText", SETTING_FIRSTLINE_TRIMTEXT_DEFAULT) == 1); { bool smileAddPresent = ServiceExists(MS_SMILEYADD_BATCHPARSE) != 0; CLUI_ShowWindowMod(GetDlgItem(hwndDlg, IDC_REPLACE_SMILEYS), smileAddPresent ? SW_SHOW : SW_HIDE); @@ -574,32 +574,27 @@ static INT_PTR CALLBACK DlgProcItemSecondLineOpts(HWND hwndDlg, UINT msg, WPARAM switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); - CheckDlgButton(hwndDlg, IDC_SHOW, g_plugin.getByte("SecondLineShow", SETTING_SECONDLINE_SHOW_DEFAULT) == 1 ? BST_CHECKED : BST_UNCHECKED); SendDlgItemMessage(hwndDlg, IDC_TOP_SPACE_SPIN, UDM_SETBUDDY, (WPARAM)GetDlgItem(hwndDlg, IDC_TOP_SPACE), 0); // set buddy SendDlgItemMessage(hwndDlg, IDC_TOP_SPACE_SPIN, UDM_SETRANGE, 0, MAKELONG(255, 0)); - SendDlgItemMessage(hwndDlg, IDC_TOP_SPACE_SPIN, UDM_SETPOS, 0, MAKELONG(g_plugin.getWord("SecondLineTopSpace", SETTING_SECONDLINE_TOPSPACE_DEFAULT), 0)); + SendDlgItemMessage(hwndDlg, IDC_TOP_SPACE_SPIN, UDM_SETPOS, 0, MAKELONG(g_plugin.secondLine.iTopSpace, 0)); - CheckDlgButton(hwndDlg, IDC_DRAW_SMILEYS, g_plugin.getByte("SecondLineDrawSmileys", SETTING_SECONDLINE_SMILEYS_DEFAULT) == 1 ? BST_CHECKED : BST_UNCHECKED); - { - ptrW tszText(g_plugin.getWStringA("SecondLineText")); - if (tszText) - SetDlgItemText(hwndDlg, IDC_VARIABLE_TEXT, tszText); - } + SetDlgItemText(hwndDlg, IDC_VARIABLE_TEXT, g_plugin.secondLine.text); SendDlgItemMessage(hwndDlg, IDC_VARIABLE_TEXT, EM_SETLIMITTEXT, TEXT_TEXT_MAX_LENGTH, 0); - { - int radio = g_plugin.getWord("SecondLineType", TEXT_STATUS_MESSAGE); - CheckDlgButton(hwndDlg, IDC_STATUS, radio == TEXT_STATUS ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_NICKNAME, radio == TEXT_NICKNAME ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_STATUS_MESSAGE, radio == TEXT_STATUS_MESSAGE ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_LISTENING_TO, radio == TEXT_LISTENING_TO ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_CONTACT_TIME, radio == TEXT_CONTACT_TIME ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_TEXT, radio == TEXT_TEXT ? BST_CHECKED : BST_UNCHECKED); - } - CheckDlgButton(hwndDlg, IDC_XSTATUS_HAS_PRIORITY, g_plugin.getByte("SecondLineXStatusHasPriority", SETTING_SECONDLINE_XSTATUS_DEFAULT) == 1 ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_SHOW_STATUS_IF_NOAWAY, g_plugin.getByte("SecondLineShowStatusIfNoAway", SETTING_SECONDLINE_STATUSIFNOAWAY_DEFAULT) == 1 ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_SHOW_LISTENING_IF_NOAWAY, g_plugin.getByte("SecondLineShowListeningIfNoAway", SETTING_SECONDLINE_LISTENINGIFNOAWAY_DEFAULT) == 1 ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_USE_NAME_AND_MESSAGE, g_plugin.getByte("SecondLineUseNameAndMessageForXStatus", SETTING_SECONDLINE_XSTATUSNAMETEXT_DEFAULT) == 1 ? BST_CHECKED : BST_UNCHECKED); + + CheckDlgButton(hwndDlg, IDC_TEXT, g_plugin.secondLine.iType == TEXT_TEXT); + CheckDlgButton(hwndDlg, IDC_STATUS, g_plugin.secondLine.iType == TEXT_STATUS); + CheckDlgButton(hwndDlg, IDC_NICKNAME, g_plugin.secondLine.iType == TEXT_NICKNAME); + CheckDlgButton(hwndDlg, IDC_LISTENING_TO, g_plugin.secondLine.iType == TEXT_LISTENING_TO); + CheckDlgButton(hwndDlg, IDC_CONTACT_TIME, g_plugin.secondLine.iType == TEXT_CONTACT_TIME); + CheckDlgButton(hwndDlg, IDC_STATUS_MESSAGE, g_plugin.secondLine.iType == TEXT_STATUS_MESSAGE); + + CheckDlgButton(hwndDlg, IDC_SHOW, g_plugin.secondLine.bActive); + CheckDlgButton(hwndDlg, IDC_DRAW_SMILEYS, g_plugin.secondLine.bDrawSmilies); + CheckDlgButton(hwndDlg, IDC_USE_NAME_AND_MESSAGE, g_plugin.secondLine.bUseNameAndMessageForXstatus); + CheckDlgButton(hwndDlg, IDC_XSTATUS_HAS_PRIORITY, g_plugin.secondLine.bXstatusHasPriority); + CheckDlgButton(hwndDlg, IDC_SHOW_STATUS_IF_NOAWAY, g_plugin.secondLine.bShowStatusIfNoAway); + CheckDlgButton(hwndDlg, IDC_SHOW_LISTENING_IF_NOAWAY, g_plugin.secondLine.bShowListeningIfNoAway); if (BST_UNCHECKED == IsDlgButtonChecked(hwndDlg, IDC_SHOW)) { EnableWindow(GetDlgItem(hwndDlg, IDC_USE_PROTOCOL_SMILEYS), FALSE); @@ -699,7 +694,7 @@ static INT_PTR CALLBACK DlgProcItemSecondLineOpts(HWND hwndDlg, UINT msg, WPARAM g_plugin.setWord("SecondLineTopSpace", (WORD)SendDlgItemMessage(hwndDlg, IDC_TOP_SPACE_SPIN, UDM_GETPOS, 0, 0)); g_plugin.setByte("SecondLineDrawSmileys", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_DRAW_SMILEYS)); - int radio; + WORD radio; if (IsDlgButtonChecked(hwndDlg, IDC_STATUS)) radio = TEXT_STATUS; else if (IsDlgButtonChecked(hwndDlg, IDC_NICKNAME)) @@ -712,7 +707,7 @@ static INT_PTR CALLBACK DlgProcItemSecondLineOpts(HWND hwndDlg, UINT msg, WPARAM radio = TEXT_LISTENING_TO; else radio = TEXT_STATUS_MESSAGE; - g_plugin.setWord("SecondLineType", (WORD)radio); + g_plugin.setWord("SecondLineType", radio); wchar_t t[TEXT_TEXT_MAX_LENGTH]; GetDlgItemText(hwndDlg, IDC_VARIABLE_TEXT, t, _countof(t)); @@ -739,35 +734,27 @@ static INT_PTR CALLBACK DlgProcItemThirdLineOpts(HWND hwndDlg, UINT msg, WPARAM switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); - CheckDlgButton(hwndDlg, IDC_SHOW, g_plugin.getByte("ThirdLineShow", SETTING_THIRDLINE_SHOW_DEFAULT) == 1 ? BST_CHECKED : BST_UNCHECKED); SendDlgItemMessage(hwndDlg, IDC_TOP_SPACE_SPIN, UDM_SETBUDDY, (WPARAM)GetDlgItem(hwndDlg, IDC_TOP_SPACE), 0); // set buddy SendDlgItemMessage(hwndDlg, IDC_TOP_SPACE_SPIN, UDM_SETRANGE, 0, MAKELONG(255, 0)); - SendDlgItemMessage(hwndDlg, IDC_TOP_SPACE_SPIN, UDM_SETPOS, 0, MAKELONG(g_plugin.getWord("ThirdLineTopSpace", SETTING_THIRDLINE_TOPSPACE_DEFAULT), 0)); + SendDlgItemMessage(hwndDlg, IDC_TOP_SPACE_SPIN, UDM_SETPOS, 0, MAKELONG(g_plugin.thirdLine.iTopSpace, 0)); - CheckDlgButton(hwndDlg, IDC_DRAW_SMILEYS, g_plugin.getByte("ThirdLineDrawSmileys", SETTING_THIRDLINE_SMILEYS_DEFAULT) == 1 ? BST_CHECKED : BST_UNCHECKED); - { - DBVARIANT dbv; - if (!g_plugin.getWString("ThirdLineText", &dbv)) { - SetDlgItemText(hwndDlg, IDC_VARIABLE_TEXT, dbv.pwszVal); - db_free(&dbv); - } - } + SetDlgItemText(hwndDlg, IDC_VARIABLE_TEXT, g_plugin.thirdLine.text); SendDlgItemMessage(hwndDlg, IDC_VARIABLE_TEXT, EM_SETLIMITTEXT, TEXT_TEXT_MAX_LENGTH, 0); - { - int radio = g_plugin.getWord("ThirdLineType", SETTING_THIRDLINE_TYPE_DEFAULT); - CheckDlgButton(hwndDlg, IDC_STATUS, radio == TEXT_STATUS ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_NICKNAME, radio == TEXT_NICKNAME ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_STATUS_MESSAGE, radio == TEXT_STATUS_MESSAGE ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_LISTENING_TO, radio == TEXT_LISTENING_TO ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_CONTACT_TIME, radio == TEXT_CONTACT_TIME ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_TEXT, radio == TEXT_TEXT ? BST_CHECKED : BST_UNCHECKED); - } - - CheckDlgButton(hwndDlg, IDC_XSTATUS_HAS_PRIORITY, g_plugin.getByte("ThirdLineXStatusHasPriority", SETTING_THIRDLINE_XSTATUS_DEFAULT) == 1 ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_SHOW_STATUS_IF_NOAWAY, g_plugin.getByte("ThirdLineShowStatusIfNoAway", SETTING_THIRDLINE_STATUSIFNOAWAY_DEFAULT) == 1 ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_SHOW_LISTENING_IF_NOAWAY, g_plugin.getByte("ThirdLineShowListeningIfNoAway", SETTING_THIRDLINE_LISTENINGIFNOAWAY_DEFAULT) == 1 ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_USE_NAME_AND_MESSAGE, g_plugin.getByte("ThirdLineUseNameAndMessageForXStatus", SETTING_THIRDLINE_XSTATUSNAMETEXT_DEFAULT) == 1 ? BST_CHECKED : BST_UNCHECKED); + + CheckDlgButton(hwndDlg, IDC_TEXT, g_plugin.thirdLine.iType == TEXT_TEXT); + CheckDlgButton(hwndDlg, IDC_STATUS, g_plugin.thirdLine.iType == TEXT_STATUS); + CheckDlgButton(hwndDlg, IDC_NICKNAME, g_plugin.thirdLine.iType == TEXT_NICKNAME); + CheckDlgButton(hwndDlg, IDC_STATUS_MESSAGE, g_plugin.thirdLine.iType == TEXT_STATUS_MESSAGE); + CheckDlgButton(hwndDlg, IDC_LISTENING_TO, g_plugin.thirdLine.iType == TEXT_LISTENING_TO); + CheckDlgButton(hwndDlg, IDC_CONTACT_TIME, g_plugin.thirdLine.iType == TEXT_CONTACT_TIME); + + CheckDlgButton(hwndDlg, IDC_SHOW, g_plugin.thirdLine.bActive); + CheckDlgButton(hwndDlg, IDC_DRAW_SMILEYS, g_plugin.thirdLine.bDrawSmilies); + CheckDlgButton(hwndDlg, IDC_XSTATUS_HAS_PRIORITY, g_plugin.thirdLine.bXstatusHasPriority); + CheckDlgButton(hwndDlg, IDC_SHOW_STATUS_IF_NOAWAY, g_plugin.thirdLine.bShowStatusIfNoAway); + CheckDlgButton(hwndDlg, IDC_SHOW_LISTENING_IF_NOAWAY, g_plugin.thirdLine.bShowListeningIfNoAway); + CheckDlgButton(hwndDlg, IDC_USE_NAME_AND_MESSAGE, g_plugin.thirdLine.bUseNameAndMessageForXstatus); if (BST_UNCHECKED == IsDlgButtonChecked(hwndDlg, IDC_SHOW)) { EnableWindow(GetDlgItem(hwndDlg, IDC_USE_PROTOCOL_SMILEYS), FALSE); diff --git a/plugins/Clist_modern/src/modern_clistsettings.cpp b/plugins/Clist_modern/src/modern_clistsettings.cpp index abaf656e64..ee3efc9b7a 100644 --- a/plugins/Clist_modern/src/modern_clistsettings.cpp +++ b/plugins/Clist_modern/src/modern_clistsettings.cpp @@ -23,6 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "stdafx.h" +#include "modern_awaymsg.h" CMStringW UnknownConctactTranslatedName; @@ -134,7 +135,7 @@ int ContactSettingChanged(WPARAM hContact, LPARAM lParam) if (g_CluiData.bRemoveAwayMessageForOffline) g_plugin.setString(hContact, "StatusMsg", ""); - if ((g_plugin.getWord("SecondLineType", 0) == TEXT_STATUS_MESSAGE || g_plugin.getWord("ThirdLineType", 0) == TEXT_STATUS_MESSAGE) && pdnce->hContact && pdnce->szProto) + if ((g_plugin.secondLine.getType() == TEXT_STATUS_MESSAGE || g_plugin.thirdLine.getType() == TEXT_STATUS_MESSAGE) && pdnce->hContact && pdnce->szProto) amRequestAwayMsg(hContact); Clist_Broadcast(INTM_STATUSCHANGED, hContact, 0); @@ -143,7 +144,7 @@ int ContactSettingChanged(WPARAM hContact, LPARAM lParam) if (g_clistApi.hwndContactTree && g_flag_bOnModulesLoadedCalled) Clist_InitAutoRebuild(g_clistApi.hwndContactTree); - if ((g_plugin.getWord("SecondLineType", SETTING_SECONDLINE_TYPE_DEFAULT) == TEXT_STATUS_MESSAGE || g_plugin.getWord("ThirdLineType", SETTING_THIRDLINE_TYPE_DEFAULT) == TEXT_STATUS_MESSAGE) && pdnce->hContact && pdnce->szProto) + if ((g_plugin.secondLine.getType() == TEXT_STATUS_MESSAGE || g_plugin.thirdLine.getType() == TEXT_STATUS_MESSAGE) && pdnce->hContact && pdnce->szProto) amRequestAwayMsg(hContact); } else if (!strcmp(cws->szSetting, "ApparentMode")) diff --git a/plugins/Clist_modern/src/modern_rowheight_funcs.cpp b/plugins/Clist_modern/src/modern_rowheight_funcs.cpp index 4acd4e02b1..abf02a353d 100644 --- a/plugins/Clist_modern/src/modern_rowheight_funcs.cpp +++ b/plugins/Clist_modern/src/modern_rowheight_funcs.cpp @@ -130,9 +130,9 @@ int RowHeight_CalcRowHeight(ClcData *dat, ClcContact *contact, int item) break; case TC_TEXT2: - if (dat->secondLine.show && pdnce->szSecondLineText && pdnce->szSecondLineText[0]) { + if (g_plugin.secondLine.bActive && pdnce->szSecondLineText && pdnce->szSecondLineText[0]) { pCell->h = dat->fontModernInfo[FONTID_SECONDLINE].fontHeight; - if (dat->text_replace_smileys && dat->secondLine.draw_smileys && !dat->text_resize_smileys) + if (dat->text_replace_smileys && g_plugin.secondLine.bDrawSmilies && !dat->text_resize_smileys) pCell->h = max(pCell->h, pdnce->ssSecondLine.iMaxSmileyHeight); if (item == -1) { // calculate text width here @@ -150,9 +150,9 @@ int RowHeight_CalcRowHeight(ClcData *dat, ClcContact *contact, int item) break; case TC_TEXT3: - if (dat->thirdLine.show && pdnce->szThirdLineText && pdnce->szThirdLineText[0]) { + if (g_plugin.thirdLine.bActive && pdnce->szThirdLineText && pdnce->szThirdLineText[0]) { pCell->h = dat->fontModernInfo[FONTID_THIRDLINE].fontHeight; - if (dat->text_replace_smileys && dat->thirdLine.draw_smileys && !dat->text_resize_smileys) + if (dat->text_replace_smileys && g_plugin.thirdLine.bDrawSmilies && !dat->text_resize_smileys) pCell->h = max(pCell->h, pdnce->ssThirdLine.iMaxSmileyHeight); if (item == -1) { //calculate text width here @@ -358,18 +358,18 @@ int RowHeights_GetMaxRowHeight(ClcData *dat, HWND hwnd) max_height += tmp; - if (dat->secondLine.show) { + if (g_plugin.secondLine.bActive) { tmp = dat->fontModernInfo[FONTID_SECONDLINE].fontHeight; - if (dat->text_replace_smileys && dat->secondLine.draw_smileys && !dat->text_resize_smileys) + if (dat->text_replace_smileys && g_plugin.secondLine.bDrawSmilies && !dat->text_resize_smileys) tmp = max(tmp, dat->text_smiley_height); - max_height += dat->secondLine.top_space + tmp; + max_height += g_plugin.secondLine.iTopSpace + tmp; } - if (dat->thirdLine.show) { + if (g_plugin.thirdLine.bActive) { tmp = dat->fontModernInfo[FONTID_THIRDLINE].fontHeight; - if (dat->text_replace_smileys && dat->thirdLine.draw_smileys && !dat->text_resize_smileys) + if (dat->text_replace_smileys && g_plugin.thirdLine.bDrawSmilies && !dat->text_resize_smileys) tmp = max(tmp, dat->text_smiley_height); - max_height += dat->thirdLine.top_space + tmp; + max_height += g_plugin.thirdLine.iTopSpace + tmp; } // Get other font sizes @@ -490,18 +490,18 @@ int RowHeights_GetRowHeight(ClcData *dat, HWND hwnd, ClcContact *contact, int it height += tmp; if (pdnce && !minimalistic) { - if (dat->secondLine.show && pdnce->szSecondLineText && pdnce->szSecondLineText[0]) { + if (g_plugin.secondLine.bActive && pdnce->szSecondLineText && pdnce->szSecondLineText[0]) { tmp = dat->fontModernInfo[FONTID_SECONDLINE].fontHeight; - if (dat->text_replace_smileys && dat->secondLine.draw_smileys && !dat->text_resize_smileys) + if (dat->text_replace_smileys && g_plugin.secondLine.bDrawSmilies && !dat->text_resize_smileys) tmp = max(tmp, pdnce->ssSecondLine.iMaxSmileyHeight); - height += dat->secondLine.top_space + tmp; + height += g_plugin.secondLine.iTopSpace + tmp; } - if (dat->thirdLine.show && pdnce->szThirdLineText && pdnce->szThirdLineText[0]) { + if (g_plugin.thirdLine.bActive && pdnce->szThirdLineText && pdnce->szThirdLineText[0]) { tmp = dat->fontModernInfo[FONTID_THIRDLINE].fontHeight; - if (dat->text_replace_smileys && dat->thirdLine.draw_smileys && !dat->text_resize_smileys) + if (dat->text_replace_smileys && g_plugin.thirdLine.bDrawSmilies && !dat->text_resize_smileys) tmp = max(tmp, pdnce->ssThirdLine.iMaxSmileyHeight); - height += dat->thirdLine.top_space + tmp; + height += g_plugin.thirdLine.iTopSpace + tmp; } } } diff --git a/plugins/Clist_modern/src/stdafx.h b/plugins/Clist_modern/src/stdafx.h index 1fe3af4871..2c0977b17f 100644 --- a/plugins/Clist_modern/src/stdafx.h +++ b/plugins/Clist_modern/src/stdafx.h @@ -103,13 +103,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include -struct CMPlugin : public PLUGIN -{ - CMPlugin(); - - int Load() override; - int Unload() override; -}; +#define TEXT_TEXT_MAX_LENGTH 1024 #include "modern_global_structure.h" #include "modern_defsettings.h" @@ -127,6 +121,18 @@ struct CMPlugin : public PLUGIN #include "resource.h" +struct CMPlugin : public PLUGIN +{ + CMPlugin(); + + ClcLineInfo secondLine, thirdLine; + + void ReadSettings(); + + int Load() override; + int Unload() override; +}; + #define DEFAULT_SKIN_FOLDER "Skins\\Modern contact list" extern wchar_t SkinsFolder[MAX_PATH]; -- cgit v1.2.3