summaryrefslogtreecommitdiff
path: root/src/mir_app
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2017-10-16 22:47:10 +0300
committerGeorge Hazan <ghazan@miranda.im>2017-10-16 22:47:10 +0300
commit53ff16b147c30de05cd21e3f97b0ae0106dd9566 (patch)
tree9afbb24421d8282dee04878ef0476547dc4d4f1c /src/mir_app
parent472296cacaa7f230f6d99c7d1b6e44003de749af (diff)
the whole idea of customizable colors in chat considered totally useless
Diffstat (limited to 'src/mir_app')
-rw-r--r--src/mir_app/src/chat.h4
-rw-r--r--src/mir_app/src/chat_log.cpp5
-rw-r--r--src/mir_app/src/chat_manager.cpp16
-rw-r--r--src/mir_app/src/chat_svc.cpp10
-rw-r--r--src/mir_app/src/chat_tools.cpp42
-rw-r--r--src/mir_app/src/clc.h6
-rw-r--r--src/mir_app/src/clcutils.cpp4
-rw-r--r--src/mir_app/src/colorchooser.cpp60
-rw-r--r--src/mir_app/src/srmm_base.cpp18
9 files changed, 44 insertions, 121 deletions
diff --git a/src/mir_app/src/chat.h b/src/mir_app/src/chat.h
index 290f4f6efa..6e773a0efb 100644
--- a/src/mir_app/src/chat.h
+++ b/src/mir_app/src/chat.h
@@ -54,7 +54,7 @@ void FreeMsgLogBitmaps(void);
void ValidateFilename (wchar_t *filename);
wchar_t* MakeTimeStamp(wchar_t *pszStamp, time_t time);
wchar_t* GetChatLogsFilename(SESSION_INFO *si, time_t tTime);
-char* Log_CreateRtfHeader(MODULEINFO *mi);
+char* Log_CreateRtfHeader();
char* Log_CreateRTF(LOGSTREAMDATA *streamData);
char* Log_SetStyle(int style);
@@ -105,8 +105,6 @@ void UnloadChatModule(void);
int DoRtfToTags(CMStringW &pszText, int iNumColors, COLORREF *pColors);
wchar_t *RemoveFormatting(const wchar_t* pszText);
BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT *gce, BOOL bHighlight, int bManyFix);
-int GetColorIndex(const char *pszModule, COLORREF cr);
-void CheckColorsInModule(const char *pszModule);
int GetRichTextLength(HWND hwnd);
bool IsHighlighted(SESSION_INFO *si, GCEVENT *pszText);
BOOL IsEventSupported(int eventType);
diff --git a/src/mir_app/src/chat_log.cpp b/src/mir_app/src/chat_log.cpp
index d60428a28b..5b6f1a79f8 100644
--- a/src/mir_app/src/chat_log.cpp
+++ b/src/mir_app/src/chat_log.cpp
@@ -382,7 +382,7 @@ char* Log_CreateRTF(LOGSTREAMDATA *streamData)
return buf.Detach();
}
-char* Log_CreateRtfHeader(MODULEINFO *mi)
+char* Log_CreateRtfHeader()
{
// guesstimate amount of memory for the RTF header
CMStringA buf;
@@ -406,9 +406,6 @@ char* Log_CreateRtfHeader(MODULEINFO *mi)
for (int i = 0; i < OPTIONS_FONTCOUNT; i++)
buf.AppendFormat("\\red%u\\green%u\\blue%u;", GetRValue(chatApi.aFonts[i].color), GetGValue(chatApi.aFonts[i].color), GetBValue(chatApi.aFonts[i].color));
- for (int i = 0; i < mi->nColorCount; i++)
- buf.AppendFormat("\\red%u\\green%u\\blue%u;", GetRValue(mi->crColors[i]), GetGValue(mi->crColors[i]), GetBValue(mi->crColors[i]));
-
// new paragraph
buf.Append("}\\pard");
diff --git a/src/mir_app/src/chat_manager.cpp b/src/mir_app/src/chat_manager.cpp
index 93f9ebe728..b61eadf7ff 100644
--- a/src/mir_app/src/chat_manager.cpp
+++ b/src/mir_app/src/chat_manager.cpp
@@ -183,7 +183,7 @@ BOOL SM_SetOffline(const char *pszModule, SESSION_INFO *si)
return TRUE;
}
-static HICON SM_GetStatusIcon(SESSION_INFO *si, USERINFO * ui)
+static HICON SM_GetStatusIcon(SESSION_INFO *si, USERINFO *ui)
{
if (!ui || !si)
return nullptr;
@@ -575,7 +575,7 @@ static void MM_FontsChanged()
{
for (int i = 0; i < g_arModules.getCount(); i++) {
MODULEINFO *mi = g_arModules[i];
- mi->pszHeader = chatApi.Log_CreateRtfHeader(mi);
+ mi->pszHeader = chatApi.Log_CreateRtfHeader();
}
}
@@ -587,15 +587,6 @@ static MODULEINFO* MM_FindModule(const char *pszModule)
return g_arModules.find((MODULEINFO*)&pszModule);
}
-// stupid thing..
-static void MM_FixColors()
-{
- for (int i = 0; i < g_arModules.getCount(); i++) {
- MODULEINFO *mi = g_arModules[i];
- CheckColorsInModule(mi->pszModule);
- }
-}
-
static BOOL MM_RemoveAll(void)
{
for (int i = 0; i < g_arModules.getCount(); i++) {
@@ -606,7 +597,6 @@ static BOOL MM_RemoveAll(void)
mir_free(mi->pszModule);
mir_free(mi->ptszModDispName);
mir_free(mi->pszHeader);
- mir_free(mi->crColors);
mir_free(mi);
}
return TRUE;
@@ -1059,7 +1049,6 @@ MIR_APP_DLL(CHAT_MANAGER*) Chat_GetInterface(CHAT_MANAGER_INITDATA *pInit, int _
chatApi.MM_AddModule = MM_AddModule;
chatApi.MM_FindModule = MM_FindModule;
- chatApi.MM_FixColors = MM_FixColors;
chatApi.MM_FontsChanged = MM_FontsChanged;
chatApi.MM_IconsChanged = MM_IconsChanged;
chatApi.MM_RemoveAll = MM_RemoveAll;
@@ -1104,7 +1093,6 @@ MIR_APP_DLL(CHAT_MANAGER*) Chat_GetInterface(CHAT_MANAGER_INITDATA *pInit, int _
chatApi.ShowPopup = ShowPopup;
chatApi.LogToFile = LogToFile;
chatApi.GetChatLogsFilename = GetChatLogsFilename;
- chatApi.GetColorIndex = GetColorIndex;
chatApi.Log_SetStyle = Log_SetStyle;
chatApi.IsHighlighted = IsHighlighted;
diff --git a/src/mir_app/src/chat_svc.cpp b/src/mir_app/src/chat_svc.cpp
index 2b4458593d..c9c6653c1f 100644
--- a/src/mir_app/src/chat_svc.cpp
+++ b/src/mir_app/src/chat_svc.cpp
@@ -88,7 +88,6 @@ static int FontsChanged(WPARAM, LPARAM)
g_Settings->bLogIndentEnabled = (db_get_b(0, CHAT_MODULE, "LogIndentEnabled", 1) != 0) ? TRUE : FALSE;
chatApi.MM_FontsChanged();
- chatApi.MM_FixColors();
Chat_UpdateOptions();
return 0;
}
@@ -175,15 +174,8 @@ MIR_APP_DLL(int) Chat_Register(const GCREGISTER *gcr)
mi->bAckMsg = (gcr->dwFlags & GC_ACKMSG) != 0;
mi->bChanMgr = (gcr->dwFlags & GC_CHANMGR) != 0;
mi->iMaxText = gcr->iMaxText;
- mi->nColorCount = gcr->nColors;
- if (gcr->nColors > 0) {
- mi->crColors = (COLORREF *)mir_alloc(sizeof(COLORREF)* gcr->nColors);
- memcpy(mi->crColors, gcr->pColors, sizeof(COLORREF)* gcr->nColors);
- }
-
- mi->pszHeader = chatApi.Log_CreateRtfHeader(mi);
+ mi->pszHeader = chatApi.Log_CreateRtfHeader();
- CheckColorsInModule((char*)gcr->pszModule);
chatApi.SetAllOffline(TRUE, gcr->pszModule);
return 0;
}
diff --git a/src/mir_app/src/chat_tools.cpp b/src/mir_app/src/chat_tools.cpp
index e3869a7097..a2293e6d84 100644
--- a/src/mir_app/src/chat_tools.cpp
+++ b/src/mir_app/src/chat_tools.cpp
@@ -358,48 +358,6 @@ BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT *gce, BOOL bHighlight
return TRUE;
}
-int GetColorIndex(const char *pszModule, COLORREF cr)
-{
- MODULEINFO *pMod = chatApi.MM_FindModule(pszModule);
- int i = 0;
-
- if (!pMod || pMod->nColorCount == 0)
- return -1;
-
- for (i = 0; i < pMod->nColorCount; i++)
- if (pMod->crColors[i] == cr)
- return i;
-
- return -1;
-}
-
-// obscure function that is used to make sure that any of the colors
-// passed by the protocol is used as fore- or background color
-// in the messagebox. THis is to vvercome limitations in the richedit
-// that I do not know currently how to fix
-
-void CheckColorsInModule(const char *pszModule)
-{
- MODULEINFO *pMod = chatApi.MM_FindModule(pszModule);
- if (!pMod)
- return;
-
- int i = 0;
- COLORREF crFG;
- COLORREF crBG = (COLORREF)db_get_dw(0, CHAT_MODULE, "ColorMessageBG", GetSysColor(COLOR_WINDOW));
-
- LoadMsgDlgFont(17, nullptr, &crFG);
-
- for (i = 0; i < pMod->nColorCount; i++) {
- if (pMod->crColors[i] == crFG || pMod->crColors[i] == crBG) {
- if (pMod->crColors[i] == RGB(255, 255, 255))
- pMod->crColors[i]--;
- else
- pMod->crColors[i]++;
- }
- }
-}
-
const wchar_t* my_strstri(const wchar_t* s1, const wchar_t* s2)
{
int i, j, k;
diff --git a/src/mir_app/src/clc.h b/src/mir_app/src/clc.h
index 47656c78b1..29a8ceb0f6 100644
--- a/src/mir_app/src/clc.h
+++ b/src/mir_app/src/clc.h
@@ -89,8 +89,8 @@ int fnClcStatusToPf2(int status);
int fnIsHiddenMode(struct ClcData *dat, int status);
void fnHideInfoTip(HWND hwnd, struct ClcData *dat);
void fnNotifyNewContact(HWND hwnd, MCONTACT hContact);
-void fnGetDefaultFontSetting(int i, LOGFONT* lf, COLORREF* colour);
-void fnGetFontSetting(int i, LOGFONT* lf, COLORREF* colour);
+void fnGetDefaultFontSetting(int i, LOGFONT *lf, COLORREF *colour);
+void fnGetFontSetting(int i, LOGFONT *lf, COLORREF *colour);
void fnLoadClcOptions(HWND hwnd, struct ClcData *dat, BOOL bFirst);
void fnRecalculateGroupCheckboxes(HWND hwnd, struct ClcData *dat);
void fnSetGroupChildCheckboxes(ClcGroup *group, int checked);
@@ -119,7 +119,7 @@ void RebuildMenuOrder(void);
/* clistsettings.c */
wchar_t* fnGetContactDisplayName(MCONTACT hContact, int mode);
-void fnGetDefaultFontSetting(int i, LOGFONT* lf, COLORREF * colour);
+void fnGetDefaultFontSetting(int i, LOGFONT *lf, COLORREF * colour);
void fnInvalidateDisplayNameCacheEntry(MCONTACT hContact);
ClcCacheEntry* fnGetCacheEntry(MCONTACT hContact);
diff --git a/src/mir_app/src/clcutils.cpp b/src/mir_app/src/clcutils.cpp
index 2ba391576b..c38203642f 100644
--- a/src/mir_app/src/clcutils.cpp
+++ b/src/mir_app/src/clcutils.cpp
@@ -674,7 +674,7 @@ DWORD fnGetDefaultExStyle(void)
#define DBFONTF_ITALIC 2
#define DBFONTF_UNDERLINE 4
-void fnGetDefaultFontSetting(int i, LOGFONT* lf, COLORREF* colour)
+void fnGetDefaultFontSetting(int i, LOGFONT *lf, COLORREF *colour)
{
SystemParametersInfo(SPI_GETICONTITLELOGFONT, sizeof(LOGFONT), lf, FALSE);
*colour = GetSysColor(COLOR_WINDOWTEXT);
@@ -698,7 +698,7 @@ void fnGetDefaultFontSetting(int i, LOGFONT* lf, COLORREF* colour)
}
}
-void fnGetFontSetting(int i, LOGFONT* lf, COLORREF* colour)
+void fnGetFontSetting(int i, LOGFONT *lf, COLORREF *colour)
{
cli.pfnGetDefaultFontSetting(i, lf, colour);
diff --git a/src/mir_app/src/colorchooser.cpp b/src/mir_app/src/colorchooser.cpp
index 311f61ea69..e437c4a5a2 100644
--- a/src/mir_app/src/colorchooser.cpp
+++ b/src/mir_app/src/colorchooser.cpp
@@ -24,12 +24,19 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "chat.h"
+static COLORREF colorTable[] =
+{
+ RGB(0,0,0), RGB(0,0,128), RGB(0,128,128), RGB(128,0,128),
+ RGB(0,128,0), RGB(128,128,0), RGB(128,0,0), RGB(128,128,128),
+ RGB(192,192,192), RGB(0,0,255), RGB(0,255,255), RGB(255,0,255),
+ RGB(0,255,0), RGB(255,255,0), RGB(255,0,0), RGB(255,255,255)
+};
+
class CColorChooserDlg : public CDlgBase
{
CCtrlBase m_text;
- GCSessionInfoBase *m_si;
- MODULEINFO *m_pModule;
+ CSrmmBaseDialog *m_pDlg;
int m_xPosition, m_yPosition;
int iCurrentHotTrack, iRows, iColumns;
@@ -38,14 +45,14 @@ class CColorChooserDlg : public CDlgBase
int CalculateCoordinatesToButton(POINT pt)
{
- int iSquareRoot = (int)sqrt(static_cast<float>(m_pModule->nColorCount));
- int nCols = iSquareRoot * iSquareRoot < m_pModule->nColorCount ? iSquareRoot + 1 : iSquareRoot;
+ int iSquareRoot = (int)sqrt(static_cast<float>(16));
+ int nCols = iSquareRoot * iSquareRoot < 16 ? iSquareRoot + 1 : iSquareRoot;
int col = pt.x / 25;
int row = (pt.y - 20) / 20;
int pos = nCols * row + col;
- if (pt.y < 20 && pos >= m_pModule->nColorCount)
+ if (pt.y < 20 && pos >= 16)
pos = -1;
return pos;
@@ -53,8 +60,8 @@ class CColorChooserDlg : public CDlgBase
RECT CalculateButtonToCoordinates(int buttonPosition)
{
- int iSquareRoot = (int)sqrt(static_cast<float>(m_pModule->nColorCount));
- int nCols = iSquareRoot * iSquareRoot < m_pModule->nColorCount ? iSquareRoot + 1 : iSquareRoot;
+ int iSquareRoot = (int)sqrt(static_cast<float>(16));
+ int nCols = iSquareRoot * iSquareRoot < 16 ? iSquareRoot + 1 : iSquareRoot;
int row = buttonPosition / nCols;
int col = buttonPosition % nCols;
@@ -69,9 +76,13 @@ class CColorChooserDlg : public CDlgBase
}
public:
- CColorChooserDlg(SESSION_INFO *si, BOOL bFG, HWND hwndDlg, HWND hwndTarget, HWND hwndChooser) :
+ CColorChooserDlg(CSrmmBaseDialog *pDlg, BOOL bFG, HWND hwndDlg, HWND hwndTarget, HWND hwndChooser) :
CDlgBase(g_hInst, IDD_COLORCHOOSER),
m_text(this, IDC_COLORTEXT),
+ m_pDlg(pDlg),
+ m_hwndTarget(hwndTarget),
+ m_hwndChooser(hwndChooser),
+ m_bForeground(bFG),
iCurrentHotTrack(-2),
bChoosing(false)
{
@@ -81,20 +92,15 @@ public:
m_text.UseSystemColors();
m_hwndParent = hwndDlg;
- m_hwndTarget = hwndTarget;
- m_pModule = chatApi.MM_FindModule(si->pszModule);
m_xPosition = rc.left + 3;
m_yPosition = IsWindowVisible(hwndChooser) ? rc.top - 1 : rc.top + 20;
- m_bForeground = bFG;
- m_hwndChooser = hwndChooser;
- m_si = si;
}
virtual void OnInitDialog() override
{
- int iSquareRoot = (int)sqrt(static_cast<float>(m_pModule->nColorCount));
+ int iSquareRoot = (int)sqrt(static_cast<float>(16));
- iColumns = iSquareRoot * iSquareRoot == m_pModule->nColorCount ? iSquareRoot : iSquareRoot + 1;
+ iColumns = iSquareRoot * iSquareRoot == 16 ? iSquareRoot : iSquareRoot + 1;
iRows = iSquareRoot;
RECT rc;
@@ -130,7 +136,7 @@ public:
break;
case WM_LBUTTONUP:
- if (iCurrentHotTrack >= 0 && iCurrentHotTrack < m_pModule->nColorCount && m_hwndTarget != nullptr) {
+ if (iCurrentHotTrack >= 0 && iCurrentHotTrack < 16 && m_hwndTarget != nullptr) {
CHARFORMAT2 cf;
cf.cbSize = sizeof(CHARFORMAT2);
cf.dwMask = 0;
@@ -140,20 +146,20 @@ public:
int ctrlId = GetDlgCtrlID(m_hwndChooser);
if (m_bForeground) {
- m_si->pDlg->m_bFGSet = true;
- m_si->pDlg->m_iFG = iCurrentHotTrack;
+ m_pDlg->m_bFGSet = true;
+ m_pDlg->m_iFG = colorTable[iCurrentHotTrack];
if (IsDlgButtonChecked(hWindow, ctrlId)) {
cf.dwMask = CFM_COLOR;
- cf.crTextColor = m_pModule->crColors[iCurrentHotTrack];
+ cf.crTextColor = colorTable[iCurrentHotTrack];
SendMessage(m_hwndTarget, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf);
}
}
else {
- m_si->pDlg->m_bBGSet = true;
- m_si->pDlg->m_iBG = iCurrentHotTrack;
+ m_pDlg->m_bBGSet = true;
+ m_pDlg->m_iBG = colorTable[iCurrentHotTrack];
if (IsDlgButtonChecked(hWindow, ctrlId)) {
cf.dwMask = CFM_BACKCOLOR;
- cf.crBackColor = m_pModule->crColors[iCurrentHotTrack];
+ cf.crBackColor = colorTable[iCurrentHotTrack];
SendMessage(m_hwndTarget, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf);
}
}
@@ -216,7 +222,7 @@ public:
// fill background
FillRect(hdc, &rc, GetSysColorBrush(COLOR_WINDOW));
- for (int i = 0; i < m_pModule->nColorCount; i++) {
+ for (int i = 0; i < 16; i++) {
// decide place to draw the color block in the window
iThisColumn++;
if (iThisColumn > iColumns) {
@@ -224,7 +230,7 @@ public:
iThisRow++;
}
- if (m_bForeground && m_si->pDlg->m_bFGSet && m_si->pDlg->m_iFG == i || !m_bForeground && m_si->pDlg->m_bBGSet && m_si->pDlg->m_iBG == i) {
+ if (m_bForeground && m_pDlg->m_bFGSet && m_pDlg->m_iFG == i || !m_bForeground && m_pDlg->m_bBGSet && m_pDlg->m_iBG == i) {
rc.top = (iThisRow - 1) * 20 + 1 + 20;
rc.left = (iThisColumn - 1) * 25 + 1 + 1;
rc.bottom = iThisRow * 20 - 1 + 20;
@@ -237,16 +243,14 @@ public:
rc.left = (iThisColumn - 1) * 25 + 3 + 1;
rc.bottom = iThisRow * 20 - 3 + 20;
rc.right = iThisColumn * 25 - 3;
-
FillRect(hdc, &rc, (HBRUSH)GetStockObject(BLACK_BRUSH));
- HBRUSH hbr = CreateSolidBrush(m_pModule->crColors[i]);
-
rc.top = (iThisRow - 1) * 20 + 4 + 20;
rc.left = (iThisColumn - 1) * 25 + 4 + 1;
rc.bottom = iThisRow * 20 - 4 + 20;
rc.right = iThisColumn * 25 - 4;
+ HBRUSH hbr = CreateSolidBrush(colorTable[i]);
FillRect(hdc, &rc, hbr);
DeleteObject(hbr);
}
@@ -267,6 +271,6 @@ public:
void CSrmmBaseDialog::ShowColorChooser(int iCtrlId)
{
- CColorChooserDlg *pDialog = new CColorChooserDlg(m_si, iCtrlId == IDC_SRMM_COLOR, m_hwnd, m_message.GetHwnd(), GetDlgItem(m_hwnd, iCtrlId));
+ CColorChooserDlg *pDialog = new CColorChooserDlg(this, iCtrlId == IDC_SRMM_COLOR, m_hwnd, m_message.GetHwnd(), GetDlgItem(m_hwnd, iCtrlId));
pDialog->Show();
}
diff --git a/src/mir_app/src/srmm_base.cpp b/src/mir_app/src/srmm_base.cpp
index 77e611242e..41b854e354 100644
--- a/src/mir_app/src/srmm_base.cpp
+++ b/src/mir_app/src/srmm_base.cpp
@@ -759,7 +759,7 @@ void CSrmmBaseDialog::onClick_Color(CCtrlButton *pButton)
return;
}
if (m_bFGSet)
- cf.crTextColor = chatApi.MM_FindModule(m_si->pszModule)->crColors[m_iFG];
+ cf.crTextColor = m_iFG;
}
else cf.crTextColor = m_clrInputFG;
@@ -782,7 +782,7 @@ void CSrmmBaseDialog::onClick_BkColor(CCtrlButton *pButton)
return;
}
if (m_bBGSet)
- cf.crBackColor = chatApi.MM_FindModule(m_si->pszModule)->crColors[m_iBG];
+ cf.crBackColor = m_iBG;
}
else cf.crBackColor = m_clrInputBG;
@@ -942,14 +942,7 @@ void CSrmmBaseDialog::RefreshButtonStatus(void)
return;
if (mi->bColor) {
- int index = GetColorIndex(m_si->pszModule, cf.crTextColor);
bool bState = m_btnColor.IsPushed();
-
- if (index >= 0) {
- m_bFGSet = true;
- m_iFG = index;
- }
-
if (!bState && cf.crTextColor != m_clrInputFG)
m_btnColor.Push(true);
else if (bState && cf.crTextColor == m_clrInputFG)
@@ -957,14 +950,7 @@ void CSrmmBaseDialog::RefreshButtonStatus(void)
}
if (mi->bBkgColor) {
- int index = GetColorIndex(m_si->pszModule, cf.crBackColor);
bool bState = m_btnBkColor.IsPushed();
-
- if (index >= 0) {
- m_bBGSet = true;
- m_iBG = index;
- }
-
if (!bState && cf.crBackColor != m_clrInputBG)
m_btnBkColor.Push(true);
else if (bState && cf.crBackColor == m_clrInputBG)