diff options
author | George Hazan <ghazan@miranda.im> | 2017-12-26 17:41:34 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2017-12-26 17:41:34 +0300 |
commit | 45373ed8b8906f1a7e715b8c830f91fc1b46649a (patch) | |
tree | a7ea46c2cafe4c3b1c372263a40cfd50b81d5ef5 /plugins/TabSRMM | |
parent | 4ac8a5589cd54abe47f1c80c67b2a8265764528a (diff) |
standard color table exported from core
Diffstat (limited to 'plugins/TabSRMM')
-rw-r--r-- | plugins/TabSRMM/src/utils.cpp | 40 | ||||
-rw-r--r-- | plugins/TabSRMM/src/utils.h | 8 |
2 files changed, 14 insertions, 34 deletions
diff --git a/plugins/TabSRMM/src/utils.cpp b/plugins/TabSRMM/src/utils.cpp index 79d501e4a0..df7dae8015 100644 --- a/plugins/TabSRMM/src/utils.cpp +++ b/plugins/TabSRMM/src/utils.cpp @@ -112,7 +112,7 @@ search_again: c_closing = colorname.GetLength();
const wchar_t *wszColname = colorname.c_str();
if (endmark != -1 && c_closing > 2 && c_closing <= 6 && iswalnum(colorname[0]) && iswalnum(colorname[c_closing - 1])) {
- Utils::RTF_ColorAdd(wszColname, c_closing);
+ Utils::RTF_ColorAdd(wszColname);
if (!was_added) {
clr_was_added = was_added = true;
goto search_again;
@@ -414,48 +414,22 @@ int CTabBaseDlg::FindRTLLocale() /////////////////////////////////////////////////////////////////////////////////////////
// init default color table. the table may grow when using custom colors via bbcodes
-static TRTFColorTable _rtf_ctable[] =
-{
- { L"black", 0 },
- { L"", RGB(0,0,128) },
- { L"", RGB(0,128,128) },
- { L"", RGB(128,0,128) },
- { L"", RGB(0,128,0) },
- { L"", RGB(128,128,0) },
- { L"", RGB(128,0,0) },
- { L"", RGB(128,128,128) },
-
- { L"", RGB(192,192,192) },
- { L"blue", RGB(0, 0, 255) },
- { L"cyan", RGB(0, 255, 255) },
- { L"magenta", RGB(255, 0, 255) },
- { L"green", RGB(0, 255, 0) },
- { L"yellow", RGB(255, 255, 0) },
- { L"red", RGB(255, 0, 0) },
- { L"white", RGB(255, 255, 255) }
-};
-
void Utils::RTF_CTableInit()
{
- for (int i = 0; i < _countof(_rtf_ctable); i++)
- rtf_clrs.insert(new TRTFColorTable(_rtf_ctable[i]));
+ int iTableSize;
+ COLORREF *pTable = Srmm_GetColorTable(&iTableSize);
+ for (int i = 0; i < iTableSize; i++)
+ rtf_clrs.insert(new TRTFColorTable(L"", pTable[i]));
}
/////////////////////////////////////////////////////////////////////////////////////////
// add a color to the global rtf color table
-void Utils::RTF_ColorAdd(const wchar_t *tszColname, size_t length)
+void Utils::RTF_ColorAdd(const wchar_t *tszColname)
{
- TRTFColorTable *p = new TRTFColorTable;
-
wchar_t *stopped;
COLORREF clr = wcstol(tszColname, &stopped, 16);
- mir_snwprintf(p->szName, length + 1, L"%06x", clr);
-
- clr = wcstol(tszColname, &stopped, 16);
- p->clr = (RGB(GetBValue(clr), GetGValue(clr), GetRValue(clr)));
-
- rtf_clrs.insert(p);
+ rtf_clrs.insert(new TRTFColorTable(tszColname, RGB(GetBValue(clr), GetGValue(clr), GetRValue(clr))));
}
/////////////////////////////////////////////////////////////////////////////////////////
diff --git a/plugins/TabSRMM/src/utils.h b/plugins/TabSRMM/src/utils.h index 468c174733..eac7e070e5 100644 --- a/plugins/TabSRMM/src/utils.h +++ b/plugins/TabSRMM/src/utils.h @@ -38,6 +38,12 @@ struct TRTFColorTable
{
+ __forceinline TRTFColorTable(const wchar_t *wszName, COLORREF _clr) :
+ clr(_clr)
+ {
+ mir_wstrncpy(szName, wszName, _countof(szName));
+ }
+
wchar_t szName[10];
COLORREF clr;
};
@@ -50,7 +56,7 @@ public: static char* FilterEventMarkers(char *szText);
static void DoubleAmpersands(wchar_t *pszText, size_t len);
static void RTF_CTableInit();
- static void RTF_ColorAdd(const wchar_t *tszColname, size_t length);
+ static void RTF_ColorAdd(const wchar_t *tszColname);
static int ReadContainerSettingsFromDB(const MCONTACT hContact, TContainerSettings *cs, const char *szKey = 0);
static int WriteContainerSettingsToDB(const MCONTACT hContact, TContainerSettings *cs, const char *szKey = 0);
static void SettingsToContainer(TContainerData *pContainer);
|