Skip to content

Commit d7bc86b

Browse files
committed
- basic support for darkmode for AboutDialog
- not adapted sub childs (OK button) of AboutDialog
1 parent 697c41e commit d7bc86b

File tree

7 files changed

+63
-15
lines changed

7 files changed

+63
-15
lines changed

include/Common.h

-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
// You should have received a copy of the GNU General Public License
1515
// along with this program. If not, see <https://www.gnu.org/licenses/>.
1616

17-
// NOTE : Extremely cleaned out, if you need more go to: https://github.com/notepad-plus-plus/notepad-plus-plus/blob/master/PowerEditor/src/MISC/Common/Common.h
18-
1917
#pragma once
2018
#include <vector>
2119
#include <string>

include/NppDarkMode.h

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <string>
2020
#include <windows.h>
2121

22+
2223
namespace NppDarkMode
2324
{
2425
struct Colors

src/AboutDialog/AboutDlg.cpp

+20-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
#include "AboutDlg.h"
2-
#include "PluginInterface.h"
32

43
void AboutDialog::doDialog()
54
{
65
if (!isCreated())
76
create(IDD_ABOUT_DIALOG);
87

9-
goToCenter();
8+
// Adjust the position of AboutBox
9+
moveForDpiChange();
10+
goToCenter(SWP_SHOWWINDOW | SWP_NOSIZE);
1011
}
1112

12-
INT_PTR CALLBACK AboutDialog::run_dlgProc(UINT message, WPARAM wParam, LPARAM /*lParam*/)
13+
intptr_t CALLBACK AboutDialog::run_dlgProc(UINT message, WPARAM wParam, LPARAM /*lParam*/)
1314
{
1415
switch (message) {
1516
case WM_INITDIALOG:
@@ -19,6 +20,22 @@ INT_PTR CALLBACK AboutDialog::run_dlgProc(UINT message, WPARAM wParam, LPARAM /*
1920

2021
return TRUE;
2122
}
23+
24+
case WM_CTLCOLORDLG:
25+
case WM_CTLCOLORSTATIC:
26+
{
27+
return NppDarkMode::onCtlColorDarker(reinterpret_cast<HDC>(wParam));
28+
}
29+
30+
case WM_PRINTCLIENT:
31+
{
32+
if (NppDarkMode::isEnabled())
33+
{
34+
return TRUE;
35+
}
36+
break;
37+
}
38+
2239
case WM_COMMAND:
2340
{
2441
switch (wParam) {

src/AboutDialog/AboutDlg.h

+5-8
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
#ifndef ABOUT_DLG_H
2-
#define ABOUT_DLG_H
1+
#pragma once
32

43
#include "PluginInterface.h"
5-
#include "StaticDialog.h"
64
#include "URLCtrl.h"
75
#include "../resources/resource.h"
6+
#include "StaticDialog.h"
87

98
class AboutDialog : public StaticDialog
109
{
1110
public:
12-
AboutDialog() : StaticDialog() {};
11+
AboutDialog() = default;
1312

1413
void init( HINSTANCE hInst, NppData nppData )
1514
{
@@ -19,13 +18,13 @@ class AboutDialog : public StaticDialog
1918

2019
void doDialog();
2120

22-
virtual void destroy()
21+
void destroy() override
2322
{
2423
_urlNppPlugin.destroy();
2524
};
2625

2726
protected:
28-
virtual INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM /*lParam*/);
27+
intptr_t CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM /*lParam*/) override;
2928

3029
private:
3130
// Handles
@@ -34,5 +33,3 @@ class AboutDialog : public StaticDialog
3433
// Url control
3534
URLCtrl _urlNppPlugin;
3635
};
37-
38-
#endif //ABOUT_DLG_H

src/NppDarkModeDummy.cpp

+23
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ namespace NppDarkMode
2525
return ::CreateSolidBrush(HEXRGB(0x202020));
2626
}
2727

28+
COLORREF getTextColor()
29+
{
30+
return HEXRGB(0xE0E0E0);
31+
}
32+
2833
COLORREF getDarkerTextColor()
2934
{
3035
return HEXRGB(0xC0C0C0);
@@ -35,6 +40,11 @@ namespace NppDarkMode
3540
return HEXRGB(0xFFFF00);
3641
}
3742

43+
COLORREF getDarkerBackgroundColor()
44+
{
45+
return HEXRGB(0x202020);
46+
}
47+
3848
void setDarkTitleBar(HWND /*hwnd*/)
3949
{
4050
}
@@ -43,4 +53,17 @@ namespace NppDarkMode
4353
{
4454
return false;
4555
}
56+
57+
LRESULT onCtlColorDarker(HDC hdc)
58+
{
59+
if (!NppDarkMode::isEnabled())
60+
{
61+
return FALSE;
62+
}
63+
64+
::SetTextColor(hdc, NppDarkMode::getTextColor());
65+
::SetBkColor(hdc, NppDarkMode::getDarkerBackgroundColor());
66+
return reinterpret_cast<LRESULT>(NppDarkMode::getDarkerBackgroundBrush());
67+
}
68+
4669
}

src/StaticDialog.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include <windows.h>
1919
#include "StaticDialog.h"
2020
#include "Common.h"
21-
#include "NppDarkMode.h"
21+
//#include "NppDarkMode.h"
2222

2323
StaticDialog::~StaticDialog()
2424
{

src/URLCtrl.cpp

+13-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,19 @@ LRESULT URLCtrl::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
147147
PAINTSTRUCT ps{};
148148
HDC hdc = ::BeginPaint(hwnd, &ps);
149149

150-
::SetTextColor(hdc, _linkColor);
150+
if ((_linkColor == _visitedColor) || (_linkColor == NppDarkMode::getDarkerTextColor()))
151+
{
152+
_linkColor = NppDarkMode::isEnabled() ? NppDarkMode::getDarkerTextColor() : _visitedColor;
153+
::SetTextColor(hdc, _linkColor);
154+
}
155+
else if (NppDarkMode::isEnabled())
156+
{
157+
::SetTextColor(hdc, NppDarkMode::getLinkTextColor());
158+
}
159+
else
160+
{
161+
::SetTextColor(hdc, _linkColor);
162+
}
151163

152164
::SetBkColor(hdc, getCtrlBgColor(GetParent(hwnd))); ///*::GetSysColor(COLOR_3DFACE)*/);
153165

0 commit comments

Comments
 (0)