2021-07-24 04:18:43 +02:00
// 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/>.
2021-02-22 14:55:45 +01:00
# pragma once
# include <Windows.h>
2021-05-10 04:32:35 +02:00
constexpr COLORREF HEXRGB ( DWORD rrggbb ) {
// from 0xRRGGBB like natural #RRGGBB
// to the little-endian 0xBBGGRR
return
( ( rrggbb & 0xFF0000 ) > > 16 ) |
( ( rrggbb & 0x00FF00 ) ) |
( ( rrggbb & 0x0000FF ) < < 16 ) ;
}
2021-02-22 14:55:45 +01:00
namespace NppDarkMode
{
2021-07-11 21:26:48 +02:00
struct Colors
{
COLORREF background = 0 ;
COLORREF softerBackground = 0 ;
COLORREF hotBackground = 0 ;
COLORREF pureBackground = 0 ;
COLORREF errorBackground = 0 ;
COLORREF text = 0 ;
COLORREF darkerText = 0 ;
COLORREF disabledText = 0 ;
2021-07-22 18:45:28 +02:00
COLORREF linkText = 0 ;
2021-07-11 21:26:48 +02:00
COLORREF edge = 0 ;
2022-04-23 17:10:22 +02:00
COLORREF hotEdge = 0 ;
2022-06-01 18:33:14 +02:00
COLORREF disabledEdge = 0 ;
2021-07-11 21:26:48 +02:00
} ;
2021-02-22 14:55:45 +01:00
struct Options
{
bool enable = false ;
bool enableMenubar = false ;
2022-05-22 10:18:23 +02:00
bool enablePlugin = false ;
2021-02-22 14:55:45 +01:00
} ;
2021-07-16 21:32:53 +02:00
2021-06-07 19:47:24 +02:00
enum class ToolTipsType
{
tooltip ,
toolbar ,
listview ,
2021-06-23 17:27:44 +02:00
treeview ,
tabbar
2021-06-07 19:47:24 +02:00
} ;
2021-02-22 14:55:45 +01:00
2021-07-09 03:51:48 +02:00
enum ColorTone {
blackTone = 0 ,
redTone = 1 ,
greenTone = 2 ,
blueTone = 3 ,
purpleTone = 4 ,
cyanTone = 5 ,
2021-07-11 21:26:48 +02:00
oliveTone = 6 ,
customizedTone = 32
2021-07-09 03:51:48 +02:00
} ;
2021-08-01 09:32:01 +02:00
enum class TreeViewStyle
{
classic = 0 ,
light = 1 ,
dark = 2
} ;
2021-02-22 14:55:45 +01:00
void initDarkMode ( ) ; // pulls options from NppParameters
void refreshDarkMode ( HWND hwnd , bool forceRefresh = false ) ; // attempts to apply new options from NppParameters, sends NPPM_INTERNAL_REFRESHDARKMODE to hwnd's top level parent
bool isEnabled ( ) ;
bool isDarkMenuEnabled ( ) ;
2022-05-22 10:18:23 +02:00
bool isEnabledForPlugins ( ) ;
2021-07-08 20:11:55 +02:00
bool isExperimentalSupported ( ) ;
2021-02-22 14:55:45 +01:00
2021-10-17 14:03:59 +02:00
bool isWindows11 ( ) ;
2021-02-22 14:55:45 +01:00
COLORREF invertLightness ( COLORREF c ) ;
COLORREF invertLightnessSofter ( COLORREF c ) ;
2021-08-01 09:32:01 +02:00
double calculatePerceivedLighness ( COLORREF c ) ;
2021-02-22 14:55:45 +01:00
2021-07-09 03:51:48 +02:00
void setDarkTone ( ColorTone colorToneChoice ) ;
2021-02-22 14:55:45 +01:00
COLORREF getBackgroundColor ( ) ;
COLORREF getSofterBackgroundColor ( ) ;
COLORREF getHotBackgroundColor ( ) ;
2021-05-10 04:32:35 +02:00
COLORREF getDarkerBackgroundColor ( ) ;
COLORREF getErrorBackgroundColor ( ) ;
2021-02-22 14:55:45 +01:00
COLORREF getTextColor ( ) ;
COLORREF getDarkerTextColor ( ) ;
2021-05-28 21:40:28 +02:00
COLORREF getDisabledTextColor ( ) ;
2021-07-22 18:45:28 +02:00
COLORREF getLinkTextColor ( ) ;
2021-02-22 14:55:45 +01:00
COLORREF getEdgeColor ( ) ;
2022-04-23 17:10:22 +02:00
COLORREF getHotEdgeColor ( ) ;
2022-06-01 18:33:14 +02:00
COLORREF getDisabledEdgeColor ( ) ;
2021-02-22 14:55:45 +01:00
HBRUSH getBackgroundBrush ( ) ;
2021-05-10 04:32:35 +02:00
HBRUSH getDarkerBackgroundBrush ( ) ;
2021-02-22 14:55:45 +01:00
HBRUSH getSofterBackgroundBrush ( ) ;
HBRUSH getHotBackgroundBrush ( ) ;
HBRUSH getErrorBackgroundBrush ( ) ;
2022-04-23 17:10:22 +02:00
HBRUSH getEdgeBrush ( ) ;
HBRUSH getHotEdgeBrush ( ) ;
2022-06-01 18:33:14 +02:00
HBRUSH getDisabledEdgeBrush ( ) ;
2022-04-23 17:10:22 +02:00
2021-07-20 18:41:25 +02:00
HPEN getDarkerTextPen ( ) ;
2021-07-15 21:29:27 +02:00
HPEN getEdgePen ( ) ;
2022-04-23 17:10:22 +02:00
HPEN getHotEdgePen ( ) ;
2022-06-01 18:33:14 +02:00
HPEN getDisabledEdgePen ( ) ;
2021-07-15 21:29:27 +02:00
2021-07-11 21:26:48 +02:00
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 ) ;
2021-07-22 18:45:28 +02:00
void setLinkTextColor ( COLORREF c ) ;
2021-07-11 21:26:48 +02:00
void setEdgeColor ( COLORREF c ) ;
2022-05-05 16:17:48 +02:00
void setHotEdgeColor ( COLORREF c ) ;
2022-06-01 18:33:14 +02:00
void setDisabledEdgeColor ( COLORREF c ) ;
2021-07-11 21:26:48 +02:00
Colors getDarkModeDefaultColors ( ) ;
void changeCustomTheme ( const Colors & colors ) ;
2021-02-22 14:55:45 +01:00
// handle events
2021-04-26 08:15:16 +02:00
void handleSettingChange ( HWND hwnd , LPARAM lParam ) ;
2021-02-22 14:55:45 +01:00
// 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 ) ;
2021-06-10 02:13:10 +02:00
void drawUAHMenuNCBottomLine ( HWND hWnd ) ;
2021-02-22 14:55:45 +01:00
// from DarkMode.h
2021-07-08 20:11:55 +02:00
void initExperimentalDarkMode ( ) ;
void setDarkMode ( bool useDark , bool fixDarkScrollbar ) ;
2021-02-22 14:55:45 +01:00
void allowDarkModeForApp ( bool allow ) ;
bool allowDarkModeForWindow ( HWND hWnd , bool allow ) ;
2021-07-08 20:11:55 +02:00
void setTitleBarThemeColor ( HWND hWnd ) ;
2021-02-22 14:55:45 +01:00
// enhancements to DarkMode.h
void enableDarkScrollBarForWindowAndChildren ( HWND hwnd ) ;
2022-06-01 18:33:14 +02:00
inline void paintRoundFrameRect ( HDC hdc , const RECT rect , const HPEN hpen , int width = 0 , int height = 0 ) ;
2021-02-22 14:55:45 +01:00
void subclassButtonControl ( HWND hwnd ) ;
2021-04-23 23:41:11 +02:00
void subclassGroupboxControl ( HWND hwnd ) ;
void subclassTabControl ( HWND hwnd ) ;
2021-07-16 21:32:53 +02:00
void subclassComboBoxControl ( HWND hwnd ) ;
2021-04-26 08:15:16 +02:00
void autoSubclassAndThemeChildControls ( HWND hwndParent , bool subclass = true , bool theme = true ) ;
void autoThemeChildControls ( HWND hwndParent ) ;
2021-02-22 14:55:45 +01:00
2022-05-22 10:18:23 +02:00
LRESULT darkToolBarNotifyCustomDraw ( LPARAM lParam ) ;
LRESULT darkListViewNotifyCustomDraw ( LPARAM lParam ) ;
LRESULT darkTreeViewNotifyCustomDraw ( LPARAM lParam ) ;
void autoSubclassAndThemePluginDockWindow ( HWND hwnd ) ;
void autoSubclassAndThemeWindowNotify ( HWND hwnd ) ;
2022-05-17 08:17:11 +02:00
bool subclassTabUpDownControl ( HWND hwnd ) ;
2022-04-19 16:25:50 +02:00
2021-06-17 16:02:14 +02:00
void setDarkTitleBar ( HWND hwnd ) ;
2021-06-29 16:24:52 +02:00
void setDarkExplorerTheme ( HWND hwnd ) ;
void setDarkScrollBar ( HWND hwnd ) ;
2021-06-07 19:47:24 +02:00
void setDarkTooltips ( HWND hwnd , ToolTipsType type ) ;
2021-06-20 23:54:24 +02:00
void setDarkLineAbovePanelToolbar ( HWND hwnd ) ;
2021-07-05 11:29:10 +02:00
void setDarkListView ( HWND hwnd ) ;
2021-06-22 14:44:53 +02:00
2021-07-08 20:11:55 +02:00
void disableVisualStyle ( HWND hwnd , bool doDisable ) ;
2021-08-01 09:32:01 +02:00
void calculateTreeViewStyle ( ) ;
2021-07-11 12:07:57 +02:00
void setTreeViewStyle ( HWND hwnd ) ;
2021-07-24 14:17:40 +02:00
void setBorder ( HWND hwnd , bool border = true ) ;
2021-07-16 21:32:53 +02:00
2022-04-13 08:41:53 +02:00
BOOL CALLBACK enumAutocompleteProc ( HWND hwnd , LPARAM lParam ) ;
2022-04-11 19:19:58 +02:00
void setDarkAutoCompletion ( ) ;
2021-07-16 21:32:53 +02:00
LRESULT onCtlColor ( HDC hdc ) ;
LRESULT onCtlColorSofter ( HDC hdc ) ;
2021-07-21 21:23:08 +02:00
LRESULT onCtlColorDarker ( HDC hdc ) ;
2021-07-16 21:32:53 +02:00
LRESULT onCtlColorError ( HDC hdc ) ;
2022-04-07 19:49:32 +02:00
LRESULT onCtlColorDarkerBGStaticText ( HDC hdc , bool isTextEnabled ) ;
2022-06-01 18:33:14 +02:00
INT_PTR onCtlColorListbox ( WPARAM wParam , LPARAM lParam ) ;
2021-06-07 19:47:24 +02:00
}