From 50691aaecfc2e3206271825403d1a0d3338c6b4d Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 3 Nov 2023 13:28:25 +0300 Subject: =?UTF-8?q?fixes=20#3778=20(NewStory:=20=D0=B2=20=D0=BF=D1=80?= =?UTF-8?q?=D0=B5=D0=B4=D0=BF=D1=80=D0=BE=D1=81=D0=BC=D0=BE=D1=82=D1=80?= =?UTF-8?q?=D0=B5=20=D1=88=D0=B0=D0=B1=D0=BB=D0=BE=D0=BD=D0=BE=D0=B2=20?= =?UTF-8?q?=D0=B7=D0=B0=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=D0=BB=20=D1=86?= =?UTF-8?q?=D0=B2=D0=B5=D1=82=20=D1=82=D0=B5=D0=BA=D1=81=D1=82=D0=B0,=20?= =?UTF-8?q?=D0=BD=D0=BE=20=D0=BD=D0=B5=20=D1=84=D0=BE=D0=BD=D0=B0)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/mTextControl/src/textcontrol.cpp | 24 +++++++++++++++++++----- plugins/ExternalAPI/m_text.h | 5 +++++ plugins/NewStory/src/options.cpp | 15 +++++++++++++++ 3 files changed, 39 insertions(+), 5 deletions(-) diff --git a/libs/mTextControl/src/textcontrol.cpp b/libs/mTextControl/src/textcontrol.cpp index 5a871d42e5..2391ecc1ac 100644 --- a/libs/mTextControl/src/textcontrol.cpp +++ b/libs/mTextControl/src/textcontrol.cpp @@ -24,6 +24,7 @@ struct TextControlData HANDLE htu; wchar_t *text; struct TextObject *mtext; + COLORREF clBack = -1; }; /// Paint //////////////////////////////////// @@ -32,17 +33,25 @@ static LRESULT MTextControl_OnPaint(HWND hwnd) { PAINTSTRUCT ps; HDC hdc = BeginPaint(hwnd, &ps); + + // Find the text to draw + TextControlData *data = (TextControlData *)GetWindowLongPtr(hwnd, GWLP_USERDATA); + + SetTextColor(hdc, RGB(0, 0, 0)); + SetBkMode(hdc, TRANSPARENT); { RECT rc; GetClientRect(hwnd, &rc); + + if (data->clBack != -1) { + HBRUSH hbr = CreateSolidBrush(data->clBack); + FillRect(hdc, &rc, hbr); + DeleteObject(hbr); + } + FrameRect(hdc, &rc, (HBRUSH)GetStockObject(BLACK_BRUSH)); } - SetTextColor(hdc, RGB(0, 0, 0)); - SetBkMode(hdc, TRANSPARENT); - - // Find the text to draw - TextControlData *data = (TextControlData *)GetWindowLongPtr(hwnd, GWLP_USERDATA); if (data->mtext) { HFONT hfntSave = nullptr; HFONT hfnt = (HFONT)SendMessage(hwnd, WM_GETFONT, 0, 0); @@ -109,6 +118,11 @@ static LRESULT CALLBACK MTextControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, InvalidateRect(hwnd, nullptr, TRUE); return TRUE; + case MTM_SETBKCOLOR: + data->clBack = wParam; + InvalidateRect(hwnd, nullptr, TRUE); + return TRUE; + case MTM_UPDATEEX: if (data->text) { delete[] data->text; diff --git a/plugins/ExternalAPI/m_text.h b/plugins/ExternalAPI/m_text.h index d2165802ac..9bb349d8a8 100644 --- a/plugins/ExternalAPI/m_text.h +++ b/plugins/ExternalAPI/m_text.h @@ -12,6 +12,11 @@ // lParam = (void*)text #define MTM_UPDATEEX (WM_USER+2) +// sets background color for a control +// wParam = (COLORREF)clBack +// lParam = 0 (ignored) +#define MTM_SETBKCOLOR (WM_USER+3) + typedef struct TextObject *HText; #ifdef MTEXTCONTROL_EXPORTS diff --git a/plugins/NewStory/src/options.cpp b/plugins/NewStory/src/options.cpp index cf73b767e2..98cb365020 100644 --- a/plugins/NewStory/src/options.cpp +++ b/plugins/NewStory/src/options.cpp @@ -78,6 +78,16 @@ class CTemplateOptsDlg : public CBaseOptsDlg CCtrlMButton btnDiscard, bthVarHelp, btnReset; CCtrlTreeView m_tree; + UI_MESSAGE_MAP(CTemplateOptsDlg, CBaseOptsDlg); + UI_MESSAGE(UM_REDRAWLISTH, OnColorChanged); + UI_MESSAGE_MAP_END(); + + LRESULT OnColorChanged(UINT, WPARAM, LPARAM) + { + gpreview.SendMsg(MTM_SETBKCOLOR, g_colorTable[COLOR_BACK].cl, 0); + return 0; + } + public: CTemplateOptsDlg() : CBaseOptsDlg(IDD_OPT_TEMPLATES), @@ -148,6 +158,9 @@ public: m_tree.SelectItem(hFirst); m_tree.EnsureVisible(hFirst); + + WindowList_Add(g_hNewstoryWindows, m_hwnd); + OnColorChanged(0, 0, 0); return true; } @@ -170,6 +183,8 @@ public: void OnDestroy() override { + WindowList_Remove(g_hNewstoryWindows, m_hwnd); + for (auto &it : templates) replaceStrW(it.tmpValue, nullptr); } -- cgit v1.2.3