+ add: custom ChooseColor resource definition

This commit is contained in:
Rainer Kottenhoff 2021-04-28 12:11:41 +02:00
parent 27db568436
commit 58b507d3bd
9 changed files with 236 additions and 36 deletions

63
language/ColorDlg.h Normal file
View File

@ -0,0 +1,63 @@
/*++
Copyright (c) 1990-1999, Microsoft Corporation All rights reserved.
Module Name:
colordlg.h
Abstract:
This module contains the header information for the Win32 color dialog.
Revision History:
--*/
#if _MSC_VER > 1000
#pragma once
#endif
#ifndef _INC_COLORDLG
#define _INC_COLORDLG
#define DLG_COLOR 10
#define COLOR_HUESCROLL 700 /* color dialog */
#define COLOR_SATSCROLL 701
#define COLOR_LUMSCROLL 702
#define COLOR_HUE 703
#define COLOR_SAT 704
#define COLOR_LUM 705
#define COLOR_RED 706
#define COLOR_GREEN 707
#define COLOR_BLUE 708
#define COLOR_CURRENT 709
#define COLOR_RAINBOW 710
#define COLOR_SAVE 711
#define COLOR_ADD 712
#define COLOR_SOLID 713
#define COLOR_TUNE 714
#define COLOR_SCHEMES 715
#define COLOR_ELEMENT 716
#define COLOR_SAMPLES 717
#define COLOR_PALETTE 718
#define COLOR_MIX 719
#define COLOR_BOX1 720
#define COLOR_CUSTOM1 721
#define COLOR_HUEACCEL 723
#define COLOR_SATACCEL 724
#define COLOR_LUMACCEL 725
#define COLOR_REDACCEL 726
#define COLOR_GREENACCEL 727
#define COLOR_BLUEACCEL 728
#define COLOR_SOLID_LEFT 730
#define COLOR_SOLID_RIGHT 731
#define NUM_BASIC_COLORS 48
#define NUM_CUSTOM_COLORS 16
#endif /* !_INC_COLORDLG */

View File

@ -5,6 +5,8 @@
#ifndef _COMMON_RES_H_
#define _COMMON_RES_H_
#include "ColorDlg.h"
// undefined Sub-Language
#define SUBLANG_SPANISH_LATIN_AMERICA 0x16
@ -316,6 +318,7 @@
#define IDD_MUI_CMDLINEHELP 17037
#define IDD_MUI_SYSFONT_WITHLINK 17038
#define IDD_MUI_SYSCOLOR_DLG 17039
#define IDC_COMMANDLINE 18000
#define IDC_SEARCHEXE 18001

View File

@ -747,6 +747,67 @@ PUSHBUTTON "&Hilfe", pshHelp, 43, 215, 45, 14, WS_GROUP
END
//
// ChooseColor Dialog (copied from Color.dlg).
//
IDD_MUI_SYSCOLOR_DLG DIALOGEX LOADONCALL MOVEABLE DISCARDABLE 2, 0, 298, 184
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Wähle eine Farbe"
FONT 9, "Segoe UI", 0, 0, 0x0
BEGIN
LTEXT "&Basis Farben:", -1, 4, 4, 140, 9
CONTROL "", COLOR_BOX1, "static",
SS_SIMPLE | WS_CHILD | WS_TABSTOP | WS_GROUP,
4, 14, 140, 86
LTEXT "&Eigene Farben:", -1, 4, 106, 140, 9
CONTROL "", COLOR_CUSTOM1, "static",
SS_SIMPLE | WS_CHILD | WS_TABSTOP | WS_GROUP,
4, 116, 140, 28
PUSHBUTTON "&Defiere Eigene Farben >>" COLOR_MIX, 4, 150, 138, 14,
WS_TABSTOP | WS_GROUP
DEFPUSHBUTTON "OK", IDOK, 4, 166, 44, 14, WS_GROUP | WS_TABSTOP
PUSHBUTTON "Abbrechen", IDCANCEL, 52, 166, 44, 14, WS_GROUP | WS_TABSTOP
PUSHBUTTON "&Hilfe", pshHelp, 100, 166, 44, 14, WS_GROUP | WS_TABSTOP
CONTROL "", COLOR_RAINBOW, "static",
SS_SIMPLE | WS_CHILD, 152, 4, 118, 116
CONTROL "", COLOR_LUMSCROLL, "static",
SS_SIMPLE | WS_CHILD, 280, 4, 8, 116
CONTROL "", COLOR_CURRENT, "static",
SS_SIMPLE | WS_CHILD, 152, 124, 40, 26
PUSHBUTTON "&o", COLOR_SOLID, 300, 200, 4, 14, WS_GROUP
RTEXT "Farbe", COLOR_SOLID_LEFT, 152, 151, 20, 9
LTEXT "|S&olid", COLOR_SOLID_RIGHT, 172, 151, 20, 9
RTEXT "To&n:", COLOR_HUEACCEL, 194, 126, 20, 9
EDITTEXT, COLOR_HUE, 216, 124, 18, 12, WS_GROUP | WS_TABSTOP
RTEXT "&Sät:", COLOR_SATACCEL, 194, 140, 20, 9
EDITTEXT, COLOR_SAT, 216, 138, 18, 12, WS_GROUP | WS_TABSTOP
RTEXT "&Leu:", COLOR_LUMACCEL, 194, 154, 20, 9
EDITTEXT, COLOR_LUM, 216, 152, 18, 12, WS_GROUP | WS_TABSTOP
RTEXT "&Rot:", COLOR_REDACCEL, 243, 126, 24, 9
EDITTEXT, COLOR_RED, 269, 124, 18, 12, WS_GROUP | WS_TABSTOP
RTEXT "&Grün:", COLOR_GREENACCEL, 243, 140, 24, 9
EDITTEXT, COLOR_GREEN, 269, 138, 18, 12, WS_GROUP | WS_TABSTOP
RTEXT "Bla&u:", COLOR_BLUEACCEL, 243, 154, 24, 9
EDITTEXT, COLOR_BLUE, 269, 152, 18, 12, WS_GROUP | WS_TABSTOP
PUSHBUTTON "&Füge Eigenen Farben hinzu", COLOR_ADD, 152, 166, 142, 14,
WS_GROUP | WS_TABSTOP
END
/////////////////////////////////////////////////////////////////////////////
//

View File

@ -747,6 +747,68 @@ BEGIN
END
//
// ChooseColor Dialog (copied from Color.dlg).
//
IDD_MUI_SYSCOLOR_DLG DIALOGEX LOADONCALL MOVEABLE DISCARDABLE 2, 0, 298, 184
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Choose Color"
FONT 9, "Segoe UI", 0, 0, 0x0
BEGIN
LTEXT "&Basic colors:", -1, 4, 4, 140, 9
CONTROL "", COLOR_BOX1, "static",
SS_SIMPLE | WS_CHILD | WS_TABSTOP | WS_GROUP,
4, 14, 140, 86
LTEXT "&Custom colors:", -1, 4, 106, 140, 9
CONTROL "", COLOR_CUSTOM1, "static",
SS_SIMPLE | WS_CHILD | WS_TABSTOP | WS_GROUP,
4, 116, 140, 28
PUSHBUTTON "&Define Custom Colors >>" COLOR_MIX, 4, 150, 138, 14,
WS_TABSTOP | WS_GROUP
DEFPUSHBUTTON "OK", IDOK, 4, 166, 44, 14, WS_GROUP | WS_TABSTOP
PUSHBUTTON "Cancel", IDCANCEL, 52, 166, 44, 14, WS_GROUP | WS_TABSTOP
PUSHBUTTON "&Help", pshHelp, 100, 166, 44, 14, WS_GROUP | WS_TABSTOP
CONTROL "", COLOR_RAINBOW, "static",
SS_SIMPLE | WS_CHILD, 152, 4, 118, 116
CONTROL "", COLOR_LUMSCROLL, "static",
SS_SIMPLE | WS_CHILD, 280, 4, 8, 116
CONTROL "", COLOR_CURRENT, "static",
SS_SIMPLE | WS_CHILD, 152, 124, 40, 26
PUSHBUTTON "&o", COLOR_SOLID, 300, 200, 4, 14, WS_GROUP
RTEXT "Color", COLOR_SOLID_LEFT, 152, 151, 20, 9
LTEXT "|S&olid", COLOR_SOLID_RIGHT, 172, 151, 20, 9
RTEXT "Hu&e:", COLOR_HUEACCEL, 194, 126, 20, 9
EDITTEXT, COLOR_HUE, 216, 124, 18, 12, WS_GROUP | WS_TABSTOP
RTEXT "&Sat:", COLOR_SATACCEL, 194, 140, 20, 9
EDITTEXT, COLOR_SAT, 216, 138, 18, 12, WS_GROUP | WS_TABSTOP
RTEXT "&Lum:", COLOR_LUMACCEL, 194, 154, 20, 9
EDITTEXT, COLOR_LUM, 216, 152, 18, 12, WS_GROUP | WS_TABSTOP
RTEXT "&Red:", COLOR_REDACCEL, 243, 126, 24, 9
EDITTEXT, COLOR_RED, 269, 124, 18, 12, WS_GROUP | WS_TABSTOP
RTEXT "&Green:", COLOR_GREENACCEL, 243, 140, 24, 9
EDITTEXT, COLOR_GREEN, 269, 138, 18, 12, WS_GROUP | WS_TABSTOP
RTEXT "Bl&ue:", COLOR_BLUEACCEL, 243, 154, 24, 9
EDITTEXT, COLOR_BLUE, 269, 152, 18, 12, WS_GROUP | WS_TABSTOP
PUSHBUTTON "&Add to Custom Colors", COLOR_ADD, 152, 166, 142, 14,
WS_GROUP | WS_TABSTOP
END
/////////////////////////////////////////////////////////////////////////////
//

View File

@ -43,7 +43,6 @@
#include "SciCall.h"
//#include "win/ColorDlg.h" // Color Dialog API infos
#include "Dialogs.h"
//=============================================================================
@ -5232,30 +5231,32 @@ void ResizeDlg_Destroy(HWND hwnd, int* cxFrame, int* cyFrame)
void ResizeDlg_Size(HWND hwnd, LPARAM lParam, int* cx, int* cy)
{
PRESIZEDLG pm = (PRESIZEDLG)GetProp(hwnd, RESIZEDLG_PROP_KEY);
const int cxClient = LOWORD(lParam);
const int cyClient = HIWORD(lParam);
if (pm) {
const int cxClient = LOWORD(lParam);
const int cyClient = HIWORD(lParam);
#if NP3_ENABLE_RESIZEDLG_TEMP_FIX
const UINT dpi = Scintilla_GetWindowDPI(hwnd);
const UINT old = pm->dpi;
if (cx) {
*cx = cxClient - MulDiv(pm->cxClient, dpi, old);
}
if (cy) {
*cy = cyClient - MulDiv(pm->cyClient, dpi, old);
}
// store in original DPI.
pm->cxClient = MulDiv(cxClient, old, dpi);
pm->cyClient = MulDiv(cyClient, old, dpi);
const UINT dpi = Scintilla_GetWindowDPI(hwnd);
const UINT old = pm->dpi;
if (cx) {
*cx = cxClient - MulDiv(pm->cxClient, dpi, old);
}
if (cy) {
*cy = cyClient - MulDiv(pm->cyClient, dpi, old);
}
// store in original DPI.
pm->cxClient = MulDiv(cxClient, old, dpi);
pm->cyClient = MulDiv(cyClient, old, dpi);
#else
if (cx) {
*cx = cxClient - pm->cxClient;
}
if (cy) {
*cy = cyClient - pm->cyClient;
}
pm->cxClient = cxClient;
pm->cyClient = cyClient;
if (cx) {
*cx = cxClient - pm->cxClient;
}
if (cy) {
*cy = cyClient - pm->cyClient;
}
pm->cxClient = cxClient;
pm->cyClient = cyClient;
#endif
}
}
void ResizeDlg_GetMinMaxInfo(HWND hwnd, LPARAM lParam)
@ -6080,7 +6081,7 @@ INT_PTR CALLBACK FontDialogHookProc(
//SetExplorerTheme(GetDlgItem(hwnd, IDC_RESIZEGRIP));
int const ctl[] = { grp1, grp2, chx1, chx2, cmb1, cmb2, cmb3, cmb4, cmb5, stc1, stc2, stc3, stc4, stc5, stc6, stc7 };
for (int i = 0; i < COUNTOF(ctl); ++i) {
SetWindowTheme(GetDlgItem(hdlg, ctl[i]), L"", L""); // remove theme for BS_AUTORADIOBUTTON
SetWindowTheme(GetDlgItem(hdlg, ctl[i]), L"", L""); // remove theme
}
}
#endif
@ -6145,8 +6146,7 @@ INT_PTR CALLBACK FontDialogHookProc(
UpdateWindowLayoutForDPI(hdlg, (RECT *)lParam, 0);
int const ctl[] = { cmb1, cmb2, cmb3, cmb4, cmb5 };
for (int i = 0; i < COUNTOF(ctl); ++i) {
//HFONT const hFont = (HFONT)SendMessage(GetDlgItem(hdlg, ctl[i]), WM_GETFONT, 0, 0);
HFONT const hFont = 0;
HFONT const hFont = (HFONT)SendMessage(GetDlgItem(hdlg, ctl[i]), WM_GETFONT, 0, 0);
SendMessage(GetDlgItem(hdlg, ctl[i]), WM_SETFONT, (WPARAM)hFont, MAKELPARAM(TRUE, 0));
}
return TRUE;
@ -6188,10 +6188,12 @@ INT_PTR CALLBACK ColorDialogHookProc(
if (UseDarkMode()) {
SetExplorerTheme(GetDlgItem(hdlg, IDOK));
SetExplorerTheme(GetDlgItem(hdlg, IDCANCEL));
SetExplorerTheme(GetDlgItem(hdlg, COLOR_ADD));
SetExplorerTheme(GetDlgItem(hdlg, COLOR_MIX));
//SetExplorerTheme(GetDlgItem(hwnd, IDC_RESIZEGRIP));
int const ctl[] = { IDC_STATIC };
int const ctl[] = { COLOR_RAINBOW, COLOR_LUMSCROLL, COLOR_CURRENT, IDC_STATIC };
for (int i = 0; i < COUNTOF(ctl); ++i) {
SetWindowTheme(GetDlgItem(hdlg, ctl[i]), L"", L""); // remove theme for BS_AUTORADIOBUTTON
SetWindowTheme(GetDlgItem(hdlg, ctl[i]), L"", L""); // remove theme
}
}
#endif
@ -6228,7 +6230,7 @@ INT_PTR CALLBACK ColorDialogHookProc(
bool const darkModeEnabled = CheckDarkModeEnabled();
AllowDarkModeForWindowEx(hdlg, darkModeEnabled);
RefreshTitleBarThemeColor(hdlg);
int const buttons[] = { /*COLOR_MIX,*/ IDOK, IDCANCEL };
int const buttons[] = { IDOK, IDCANCEL };
for (int id = 0; id < COUNTOF(buttons); ++id) {
HWND const hBtn = GetDlgItem(hdlg, buttons[id]);
AllowDarkModeForWindowEx(hBtn, darkModeEnabled);
@ -6244,12 +6246,11 @@ INT_PTR CALLBACK ColorDialogHookProc(
dpi = LOWORD(wParam);
//dpi.y = HIWORD(wParam);
UpdateWindowLayoutForDPI(hdlg, (RECT *)lParam, 0);
//int const ctl[] = { cmb1, cmb2, cmb3, cmb4, cmb5 };
//for (int i = 0; i < COUNTOF(ctl); ++i) {
// //HFONT const hFont = (HFONT)SendMessage(GetDlgItem(hdlg, ctl[i]), WM_GETFONT, 0, 0);
// HFONT const hFont = 0;
// SendMessage(GetDlgItem(hdlg, ctl[i]), WM_SETFONT, (WPARAM)hFont, MAKELPARAM(TRUE, 0));
//}
int const ctl[] = { COLOR_ADD, COLOR_MIX, IDOK, IDCANCEL };
for (int i = 0; i < COUNTOF(ctl); ++i) {
HFONT const hFont = (HFONT)SendMessage(GetDlgItem(hdlg, ctl[i]), WM_GETFONT, 0, 0);
SendMessage(GetDlgItem(hdlg, ctl[i]), WM_SETFONT, (WPARAM)hFont, MAKELPARAM(TRUE, 0));
}
return TRUE;
default:

View File

@ -7096,6 +7096,7 @@ void HandleColorDefClicked(HWND hwnd, const DocPos position)
CHOOSECOLOR cc = { sizeof(CHOOSECOLOR) };
cc.hwndOwner = hwnd;
cc.hInstance = (HWND)Globals.hLngResContainer; // Globals.hInstance;
cc.rgbResult = rgbCur;
cc.lpCustColors = &g_colorCustom[0];
cc.Flags = CC_FULLOPEN | CC_RGBINIT | CC_ANYCOLOR;
@ -7110,6 +7111,10 @@ void HandleColorDefClicked(HWND hwnd, const DocPos position)
pt.y = wi.y + SciCall_PointYFromPosition(SciCall_GetCurrentPos()) + offset;
cc.lCustData = (LPARAM)&pt;
// Color.dlg resource template
cc.Flags |= CC_ENABLETEMPLATE | CC_ENABLETEMPLATEHANDLE;
cc.lpTemplateName = MAKEINTRESOURCEW(IDD_MUI_SYSCOLOR_DLG);
if (!ChooseColor(&cc)) {
return;
}

View File

@ -752,6 +752,7 @@
<ClCompile Include="Styles.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\language\ColorDlg.h" />
<ClInclude Include="crypto\crypto.h" />
<ClInclude Include="crypto\rijndael-alg-fst.h" />
<ClInclude Include="crypto\rijndael-api-fst.h" />
@ -823,7 +824,6 @@
<ClInclude Include="TypeDefs.h" />
<ClInclude Include="Version.h" />
<ClInclude Include="VersionEx.h" />
<ClInclude Include="win\ColorDlg.h" />
<ClInclude Include="win\dlgs.h" />
</ItemGroup>
<ItemGroup>

View File

@ -590,7 +590,7 @@
<ClInclude Include="win\dlgs.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="win\ColorDlg.h">
<ClInclude Include="..\language\ColorDlg.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>

View File

@ -3525,6 +3525,7 @@ bool Style_SelectColor(HWND hwnd,bool bForeGround,LPWSTR lpszStyle,int cchStyle,
CHOOSECOLOR cc = { sizeof(CHOOSECOLOR) };
cc.hwndOwner = hwnd;
cc.hInstance = (HWND)Globals.hLngResContainer; // Globals.hInstance;
cc.rgbResult = dRGBResult;
cc.lpCustColors = &g_colorCustom[0];
cc.Flags = CC_FULLOPEN | CC_RGBINIT | CC_SOLIDCOLOR;
@ -3534,6 +3535,10 @@ bool Style_SelectColor(HWND hwnd,bool bForeGround,LPWSTR lpszStyle,int cchStyle,
cc.lpfnHook = (LPCCHOOKPROC)ColorDialogHookProc;
cc.lCustData = (LPARAM)NULL;
// Color.dlg resource template
cc.Flags |= CC_ENABLETEMPLATE | CC_ENABLETEMPLATEHANDLE;
cc.lpTemplateName = MAKEINTRESOURCEW(IDD_MUI_SYSCOLOR_DLG);
if (!ChooseColor(&cc)) {
return false;
}