summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2017-12-26 17:41:34 +0300
committerGeorge Hazan <ghazan@miranda.im>2017-12-26 17:41:34 +0300
commit45373ed8b8906f1a7e715b8c830f91fc1b46649a (patch)
treea7ea46c2cafe4c3b1c372263a40cfd50b81d5ef5
parent4ac8a5589cd54abe47f1c80c67b2a8265764528a (diff)
standard color table exported from core
-rw-r--r--include/m_message.h5
-rw-r--r--libs/win32/mir_app.libbin130706 -> 130940 bytes
-rw-r--r--libs/win64/mir_app.libbin126274 -> 126490 bytes
-rw-r--r--plugins/TabSRMM/src/utils.cpp40
-rw-r--r--plugins/TabSRMM/src/utils.h8
-rw-r--r--src/mir_app/src/colorchooser.cpp40
-rw-r--r--src/mir_app/src/mir_app.def1
-rw-r--r--src/mir_app/src/mir_app64.def1
8 files changed, 42 insertions, 53 deletions
diff --git a/include/m_message.h b/include/m_message.h
index ece398ca66..8e96220ac5 100644
--- a/include/m_message.h
+++ b/include/m_message.h
@@ -299,4 +299,9 @@ struct CustomButtonClickData
DWORD flags; // BBCF_ flags
};
+/////////////////////////////////////////////////////////////////////////////////////////
+// color table for embedded color chooser
+
+EXTERN_C MIR_APP_DLL(COLORREF*) Srmm_GetColorTable(int *pTableSize = nullptr);
+
#endif // M_MESSAGE_H__
diff --git a/libs/win32/mir_app.lib b/libs/win32/mir_app.lib
index 98c7ad2967..1ccbe1750a 100644
--- a/libs/win32/mir_app.lib
+++ b/libs/win32/mir_app.lib
Binary files differ
diff --git a/libs/win64/mir_app.lib b/libs/win64/mir_app.lib
index a24d42c3c8..965d9cf872 100644
--- a/libs/win64/mir_app.lib
+++ b/libs/win64/mir_app.lib
Binary files differ
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);
diff --git a/src/mir_app/src/colorchooser.cpp b/src/mir_app/src/colorchooser.cpp
index e437c4a5a2..3d4f2004bc 100644
--- a/src/mir_app/src/colorchooser.cpp
+++ b/src/mir_app/src/colorchooser.cpp
@@ -32,6 +32,15 @@ static COLORREF colorTable[] =
RGB(0,255,0), RGB(255,255,0), RGB(255,0,0), RGB(255,255,255)
};
+MIR_APP_DLL(COLORREF*) Srmm_GetColorTable(int *pSize)
+{
+ if (pSize != nullptr)
+ *pSize = _countof(colorTable);
+ return colorTable;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
class CColorChooserDlg : public CDlgBase
{
CCtrlBase m_text;
@@ -175,31 +184,26 @@ public:
break;
case WM_MOUSEMOVE:
+ if (iCurrentHotTrack == -2)
+ return 0; // prevent focussing when not drawn yet!
{
HDC hdc = GetDC(m_hwnd);
- POINT pt;
- RECT rect;
- int but;
+ // weird stuff
+ POINT pt;
pt.x = LOWORD(lParam);
pt.y = HIWORD(lParam);
-
- if (iCurrentHotTrack == -2)
- return 0; // prevent focussing when not drawn yet!
-
- but = CalculateCoordinatesToButton(pt);
-
- // weird stuff
+ int but = CalculateCoordinatesToButton(pt);
if (but != iCurrentHotTrack) {
if (iCurrentHotTrack >= 0) {
- rect = CalculateButtonToCoordinates(iCurrentHotTrack);
+ RECT rect = CalculateButtonToCoordinates(iCurrentHotTrack);
DrawFocusRect(hdc, &rect);
iCurrentHotTrack = -1;
}
iCurrentHotTrack = but;
if (iCurrentHotTrack >= 0) {
- rect = CalculateButtonToCoordinates(iCurrentHotTrack);
+ RECT rect = CalculateButtonToCoordinates(iCurrentHotTrack);
DrawFocusRect(hdc, &rect);
}
}
@@ -208,20 +212,18 @@ public:
break;
case WM_PAINT:
+ RECT rc;
+ GetClientRect(m_hwnd, &rc);
+ rc.top += 20;
{
PAINTSTRUCT ps;
- int iThisRow = 1;
- int iThisColumn = 0;
-
- RECT rc;
- GetClientRect(m_hwnd, &rc);
- rc.top += 20;
-
HDC hdc = BeginPaint(m_hwnd, &ps);
// fill background
FillRect(hdc, &rc, GetSysColorBrush(COLOR_WINDOW));
+ int iThisRow = 1;
+ int iThisColumn = 0;
for (int i = 0; i < 16; i++) {
// decide place to draw the color block in the window
iThisColumn++;
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def
index 055c4aa466..983061b83d 100644
--- a/src/mir_app/src/mir_app.def
+++ b/src/mir_app/src/mir_app.def
@@ -488,3 +488,4 @@ Clist_SetStatusMode @464
?MetaSetDefault@MDatabaseCommon@@UAGHPAUDBCachedContact@@@Z @493 NONAME
?EnumResidentSettings@MDatabaseCommon@@UAGHP6AHPBDPAX@Z1@Z @494 NONAME
KillModuleOptions @495
+Srmm_GetColorTable @496
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def
index fa96e4fb75..83a06250da 100644
--- a/src/mir_app/src/mir_app64.def
+++ b/src/mir_app/src/mir_app64.def
@@ -488,3 +488,4 @@ Clist_SetStatusMode @464
?MetaSetDefault@MDatabaseCommon@@UEAAHPEAUDBCachedContact@@@Z @493 NONAME
?EnumResidentSettings@MDatabaseCommon@@UEAAHP6AHPEBDPEAX@Z1@Z @494 NONAME
KillModuleOptions @495
+Srmm_GetColorTable @496