You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
git_read/NppDarkMode.h

251 lines
8.7 KiB

// This file is part of Notepad++ project
// Copyright (c) 2021 adzm / Adam D. Walling
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// at your option any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#pragma once
#include <windows.h>
#include "Common.h" // for generic_string
//<2F><><EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EBB6A8><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>ΪNppDarkMode<64><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ռ<D5BC><E4A3AC><EFBFBD>а<EFBFBD><D0B0><EFBFBD><EFBFBD><EFBFBD>һЩ<D2BB><EFBFBD><E1B9B9><EFBFBD>ͺ<EFBFBD><CDBA><EFBFBD><EFBFBD><EFBFBD>
namespace NppDarkMode
{
struct Colors
{
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ<EFBFBD><EFBFBD><E1B9B9>Colors<72><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD><EFBFBD>ͱ<EFBFBD><CDB1><EFBFBD><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD>ȵ㱳<C8B5><E3B1B3><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD><EFBFBD>󱳾<EFBFBD><F3B1B3BE><EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD>ı<EFBFBD><C4B1><EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD>ɫ<EFBFBD>ı<EFBFBD><C4B1><EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><C4B1><EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><C4B1><EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD>Ե<EFBFBD><D4B5>ɫ<EFBFBD><C9AB><EFBFBD>ȵ<EFBFBD><C8B5><EFBFBD>Ե<EFBFBD><D4B5>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD><EFBFBD>ñ<EFBFBD>Ե<EFBFBD><D4B5>ɫ
COLORREF background = 0;
COLORREF softerBackground = 0;
COLORREF hotBackground = 0;
COLORREF pureBackground = 0;
COLORREF errorBackground = 0;
COLORREF text = 0;
COLORREF darkerText = 0;
COLORREF disabledText = 0;
COLORREF linkText = 0;
COLORREF edge = 0;
COLORREF hotEdge = 0;
COLORREF disabledEdge = 0;
};
struct Options
{
// <20><><EFBFBD><EFBFBD>Options<6E><EFBFBD><EFBFBD><E5A3AC><EFBFBD>ڴ洢<DAB4><E6B4A2><EFBFBD><EFBFBD>ģʽ<C4A3><CABD>ѡ<EFBFBD><D1A1>
bool enable = false;
bool enableMenubar = false;
bool enablePlugin = false;
};
struct NppDarkModeParams
{
// <20><><EFBFBD><EFBFBD>NppDarkModeParams<6D><EFBFBD><EFBFBD><E5A3AC><EFBFBD>ڴ洢<DAB4><E6B4A2><EFBFBD><EFBFBD>ģʽ<C4A3>IJ<EFBFBD><C4B2><EFBFBD>
const wchar_t* _themeClassName = nullptr;
bool _subclass = false;
bool _theme = false;
};
enum class ToolTipsType
{
// <20><><EFBFBD><EFBFBD>ToolTipsTypeö<65>٣<EFBFBD><D9A3><EFBFBD><EFBFBD>ڱ<EFBFBD>ʶ<EFBFBD><CAB6>ͬ<EFBFBD><CDAC><EFBFBD>͵Ĺ<CDB5><C4B9><EFBFBD><EFBFBD><EFBFBD>ʾ
tooltip,
toolbar,
listview,
treeview,
tabbar
};
enum ColorTone {
// <20><><EFBFBD><EFBFBD>ColorToneö<65>٣<EFBFBD><D9A3><EFBFBD><EFBFBD>ڱ<EFBFBD>ʶ<EFBFBD><CAB6>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB>
blackTone = 0,
redTone = 1,
greenTone = 2,
blueTone = 3,
purpleTone = 4,
cyanTone = 5,
oliveTone = 6,
customizedTone = 32
};
enum class TreeViewStyle
{
// <20><><EFBFBD><EFBFBD>TreeViewStyleö<65>٣<EFBFBD><D9A3><EFBFBD><EFBFBD>ڱ<EFBFBD>ʶ<EFBFBD><CAB6>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>ʽ
classic = 0,
light = 1,
dark = 2
};
struct AdvOptDefaults
{
// <20><><EFBFBD><EFBFBD>AdvOptDefaults<74><EFBFBD><EFBFBD><E5A3AC><EFBFBD>ڴ洢<DAB4>߼<EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>Ĭ<EFBFBD><C4AC>ֵ
generic_string _xmlFileName;
int _toolBarIconSet = -1;
int _tabIconSet = -1;
bool _tabUseTheme = false;
};
struct AdvancedOptions
{
// <20><><EFBFBD><EFBFBD>AdvancedOptions<6E><EFBFBD><EFBFBD><E5A3AC><EFBFBD>ڴ洢<DAB4>߼<EFBFBD>ѡ<EFBFBD><D1A1>
bool _enableWindowsMode = false;
NppDarkMode::AdvOptDefaults _darkDefaults{ L"DarkModeDefault.xml", 0, 2, false };
NppDarkMode::AdvOptDefaults _lightDefaults{ L"", 4, 0, true };
};
void initDarkMode(); // <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ<C4A3><CABD><EFBFBD><EFBFBD>NppParameters<72>л<EFBFBD>ȡѡ<C8A1><D1A1>
void refreshDarkMode(HWND hwnd, bool forceRefresh = false); // <20><><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD>µ<EFBFBD>ѡ<EFBFBD><EFBFBD><EEA3AC><EFBFBD><EFBFBD>NPPM_INTERNAL_REFRESHDARKMODE<44><45>Ϣ<EFBFBD><CFA2>hwnd<6E>Ķ<EFBFBD><C4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void initAdvancedOptions(); // <20><>ʼ<EFBFBD><CABC><EFBFBD>߼<EFBFBD>ѡ<EFBFBD><D1A1>
bool isEnabled(); // <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>ģʽ<C4A3>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>õ<EFBFBD>״̬
bool isDarkMenuEnabled(); // <20><>ȡ<EFBFBD>˵<EFBFBD><CBB5><EFBFBD><EFBFBD>Ƿ<EFBFBD>ʹ<EFBFBD>ð<EFBFBD><C3B0><EFBFBD>ģʽ<C4A3><CABD>״̬
bool isEnabledForPlugins(); // <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD>ʹ<EFBFBD>ð<EFBFBD><C3B0><EFBFBD>ģʽ<C4A3><CABD>״̬
bool isExperimentalActive(); // <20><>ȡʵ<C8A1><CAB5><EFBFBD>԰<EFBFBD><D4B0><EFBFBD>ģʽ<C4A3>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>õ<EFBFBD>״̬
bool isExperimentalSupported(); // <20><>ȡʵ<C8A1><CAB5><EFBFBD>԰<EFBFBD><D4B0><EFBFBD>ģʽ<C4A3>Ƿ<EFBFBD><C7B7><EFBFBD>֧<EFBFBD>ֵ<EFBFBD>״̬
bool isWindowsModeEnabled(); // <20><>ȡWindowsģʽ<C4A3>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>õ<EFBFBD>״̬
void setWindowsMode(bool enable); // <20><><EFBFBD><EFBFBD>Windowsģʽ<C4A3>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
generic_string getThemeName(); // <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void setThemeName(const generic_string& newThemeName); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int getToolBarIconSet(bool useDark); // <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD>
void setToolBarIconSet(int state2Set, bool useDark); // <20><><EFBFBD>ù<EFBFBD><C3B9><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD>
int getTabIconSet(bool useDark); // <20><>ȡѡ<C8A1>ͼ<EEBFA8>
void setTabIconSet(bool useAltIcons, bool useDark); // <20><><EFBFBD><EFBFBD>ѡ<EFBFBD>ͼ<EEBFA8>
bool useTabTheme(); // <20><>ȡѡ<C8A1><EFBFBD><EEBFA8><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
void setAdvancedOptions(); // <20><><EFBFBD>ø߼<C3B8>ѡ<EFBFBD><D1A1>
bool isWindows10(); // <20><>ȡWindows<77>Ƿ<EFBFBD>Ϊ10<31>
bool isWindows11(); // <20><>ȡWindows<77>Ƿ<EFBFBD>Ϊ11<31>
DWORD getWindowsBuildNumber(); // <20><>ȡWindows<77>Ĺ<EFBFBD><C4B9><EFBFBD><EFBFBD><EFBFBD><E6B1BE>
COLORREF invertLightness(COLORREF c); // <20><>ת<EFBFBD><D7AA>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
COLORREF invertLightnessSofter(COLORREF c); // <20><>ת<EFBFBD><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
double calculatePerceivedLighness(COLORREF c); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void setDarkTone(ColorTone colorToneChoice); // <20><><EFBFBD>ð<EFBFBD><C3B0><EFBFBD>ģʽ<C4A3><CABD><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB>
COLORREF getBackgroundColor(); // <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ
COLORREF getSofterBackgroundColor(); // <20><>ȡ<EFBFBD><C8A1><EFBFBD>ͱ<EFBFBD><CDB1><EFBFBD><EFBFBD><EFBFBD>ɫ
COLORREF getHotBackgroundColor(); // <20><>ȡ<EFBFBD>ȵ㱳<C8B5><E3B1B3><EFBFBD><EFBFBD>ɫ
COLORREF getDarkerBackgroundColor(); // <20><>ȡ<EFBFBD><C8A1>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ
COLORREF getErrorBackgroundColor(); // <20><>ȡ<EFBFBD><C8A1><EFBFBD>󱳾<EFBFBD><F3B1B3BE><EFBFBD>ɫ
COLORREF getTextColor(); // <20><>ȡ<EFBFBD>ı<EFBFBD><C4B1><EFBFBD>ɫ
COLORREF getDarkerTextColor(); // <20><>ȡ<EFBFBD><C8A1>ɫ<EFBFBD>ı<EFBFBD><C4B1><EFBFBD>ɫ
COLORREF getDisabledTextColor(); // <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><C4B1><EFBFBD>ɫ
COLORREF getLinkTextColor(); // <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><C4B1><EFBFBD>ɫ
COLORREF getEdgeColor(); // <20><>ȡ<EFBFBD><C8A1>Ե<EFBFBD><D4B5>ɫ
COLORREF getHotEdgeColor(); // <20><>ȡ<EFBFBD>ȵ<EFBFBD><C8B5><EFBFBD>Ե<EFBFBD><D4B5>ɫ
COLORREF getDisabledEdgeColor(); // <20><>ȡ<EFBFBD><C8A1><EFBFBD>ñ<EFBFBD>Ե<EFBFBD><D4B5>ɫ
HBRUSH getBackgroundBrush(); // <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˢ
HBRUSH getDarkerBackgroundBrush(); // <20><>ȡ<EFBFBD><C8A1>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˢ
HBRUSH getSofterBackgroundBrush(); // <20><>ȡ<EFBFBD><C8A1><EFBFBD>ͱ<EFBFBD><CDB1><EFBFBD><EFBFBD><EFBFBD>ˢ
HBRUSH getHotBackgroundBrush(); // <20><>ȡ<EFBFBD>ȵ㱳<C8B5><E3B1B3><EFBFBD><EFBFBD>ˢ
HBRUSH getErrorBackgroundBrush(); // <20><>ȡ<EFBFBD><C8A1><EFBFBD>󱳾<EFBFBD><F3B1B3BE><EFBFBD>ˢ
HBRUSH getEdgeBrush(); // <20><>ȡ<EFBFBD><C8A1>Ե<EFBFBD><D4B5>ˢ
HBRUSH getHotEdgeBrush(); // <20><>ȡ<EFBFBD>ȵ<EFBFBD><C8B5><EFBFBD>Ե<EFBFBD><D4B5>ˢ
HBRUSH getDisabledEdgeBrush(); // <20><>ȡ<EFBFBD><C8A1><EFBFBD>ñ<EFBFBD>Ե<EFBFBD><D4B5>ˢ
COLORREF getIndividualTabColour(int colourIndex, bool themeDependant, bool saturated);
void setBackgroundColor(COLORREF c);
void setSofterBackgroundColor(COLORREF c);
void setHotBackgroundColor(COLORREF c);
void setDarkerBackgroundColor(COLORREF c);
void setErrorBackgroundColor(COLORREF c);
void setTextColor(COLORREF c);
void setDarkerTextColor(COLORREF c);
void setDisabledTextColor(COLORREF c);
void setLinkTextColor(COLORREF c);
void setEdgeColor(COLORREF c);
void setHotEdgeColor(COLORREF c);
void setDisabledEdgeColor(COLORREF c);
Colors getDarkModeDefaultColors();
void changeCustomTheme(const Colors& colors);
// handle events
void handleSettingChange(HWND hwnd, LPARAM lParam, bool isFromBtn = false);
bool isDarkModeReg();
// processes messages related to UAH / custom menubar drawing.
// return true if handled, false to continue with normal processing in your wndproc
bool runUAHWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, LRESULT* lr);
void drawUAHMenuNCBottomLine(HWND hWnd);
// from DarkMode.h
void initExperimentalDarkMode();
void setDarkMode(bool useDark, bool fixDarkScrollbar);
void allowDarkModeForApp(bool allow);
bool allowDarkModeForWindow(HWND hWnd, bool allow);
void setTitleBarThemeColor(HWND hWnd);
// enhancements to DarkMode.h
void enableDarkScrollBarForWindowAndChildren(HWND hwnd);
inline void paintRoundFrameRect(HDC hdc, const RECT rect, const HPEN hpen, int width = 0, int height = 0);
void subclassButtonControl(HWND hwnd);
void subclassGroupboxControl(HWND hwnd);
void subclassTabControl(HWND hwnd);
void subclassComboBoxControl(HWND hwnd);
bool subclassTabUpDownControl(HWND hwnd);
void subclassAndThemeButton(HWND hwnd, NppDarkModeParams p);
void subclassAndThemeComboBox(HWND hwnd, NppDarkModeParams p);
void subclassAndThemeListBoxOrEditControl(HWND hwnd, NppDarkModeParams p, bool isListBox);
void subclassAndThemeListView(HWND hwnd, NppDarkModeParams p);
void themeTreeView(HWND hwnd, NppDarkModeParams p);
void themeToolbar(HWND hwnd, NppDarkModeParams p);
void themeRichEdit(HWND hwnd, NppDarkModeParams p);
void autoSubclassAndThemeChildControls(HWND hwndParent, bool subclass = true, bool theme = true);
void autoThemeChildControls(HWND hwndParent);
LRESULT darkToolBarNotifyCustomDraw(LPARAM lParam);
LRESULT darkListViewNotifyCustomDraw(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, bool isPlugin);
LRESULT darkTreeViewNotifyCustomDraw(LPARAM lParam);
void autoSubclassAndThemePluginDockWindow(HWND hwnd);
ULONG autoSubclassAndThemePlugin(HWND hwnd, ULONG dmFlags);
void autoSubclassAndThemeWindowNotify(HWND hwnd);
void setDarkTitleBar(HWND hwnd);
void setDarkExplorerTheme(HWND hwnd);
void setDarkScrollBar(HWND hwnd);
void setDarkTooltips(HWND hwnd, ToolTipsType type);
void setDarkLineAbovePanelToolbar(HWND hwnd);
void setDarkListView(HWND hwnd);
void disableVisualStyle(HWND hwnd, bool doDisable);
void calculateTreeViewStyle();
void setTreeViewStyle(HWND hwnd);
bool isThemeDark();
void setBorder(HWND hwnd, bool border = true);
BOOL CALLBACK enumAutocompleteProc(HWND hwnd, LPARAM lParam);
void setDarkAutoCompletion();
LRESULT onCtlColor(HDC hdc);
LRESULT onCtlColorSofter(HDC hdc);
LRESULT onCtlColorDarker(HDC hdc);
LRESULT onCtlColorError(HDC hdc);
LRESULT onCtlColorDarkerBGStaticText(HDC hdc, bool isTextEnabled);
INT_PTR onCtlColorListbox(WPARAM wParam, LPARAM lParam);
}
//<2F><>Щ<EFBFBD><D0A9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD>ڳ<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD>͹<EFBFBD><CDB9><EFBFBD>Notepad++<2B>İ<EFBFBD><C4B0><EFBFBD>ģʽ<C4A3><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD>á<EFBFBD><C3A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD>ڿؼ<DABF><D8BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȹ<EFBFBD><C8B9>ܡ<EFBFBD>