diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 000000000..c94e34111
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,39 @@
+# EditorConfig is awesome: https://EditorConfig.org
+#
+# VisualStudio: https://docs.microsoft.com/en-us/visualstudio/ide/create-portable-custom-editor-options?view=vs-2017
+
+# top-most EditorConfig file
+root = true
+
+# Windows-style newlines with a newline ending every file
+[*]
+charset = utf-8
+end_of_line = crlf
+insert_final_newline = true
+trim_trailing_whitespace = false
+
+# Matches multiple files with brace expansion notation
+[*.{h,c,cpp,hpp,cxx}]
+# Set default charset
+charset = utf-8-bom
+# 2 space indentation
+indent_style = space
+indent_size = 2
+tab_width = 2
+
+[*.rc]
+charset = utf-8
+
+[language/**.h]
+charset = utf-8
+
+[minipath/language/**.h]
+charset = utf-8
+
+[scintilla/**.{h,c,cpp,hpp,cxx}]
+charset = utf-8
+# tab (w=4) indentation
+indent_style = tab
+indent_size = 4
+tab_width = 4
+
diff --git a/Version_PAPPS.cmd b/Version_PAPPS.cmd
index 9a5bed708..ac748fe78 100644
--- a/Version_PAPPS.cmd
+++ b/Version_PAPPS.cmd
@@ -1,6 +1,6 @@
@echo off
setlocal
-set _VERPATCH_=Dev_Test_1
+set _VERPATCH_=Dev_Test_2
echo "%_VERPATCH_%" > .\np3portableapp\_buildname.txt
Version -VerPatch "%_VERPATCH_%"
endlocal
diff --git a/Versions/build.txt b/Versions/build.txt
index ede42cd0f..06415b870 100644
--- a/Versions/build.txt
+++ b/Versions/build.txt
@@ -1 +1 @@
-1436
+1437
diff --git a/language/common_res.h b/language/common_res.h
index 30a3babd8..9087d8c03 100644
--- a/language/common_res.h
+++ b/language/common_res.h
@@ -194,7 +194,7 @@
#define IDD_MUI_ENCODING 17030
#define IDD_MUI_ALIGN 17031
#define IDD_MUI_CHOOSEFONT 17032
-
+#define IDD_MUI_CMDLINEHELP 17033
#define IDC_COMMANDLINE 18000
#define IDC_SEARCHEXE 18001
@@ -296,6 +296,7 @@
#define IDC_TAB_INDENTS 18097
#define IDC_BACKTAB_INDENTS 18098
#define IDC_WARN_INCONSISTENT_INDENTS 18099
+#define IDC_CMDLINEHELP 18100
#define CMD_ESCAPE 20000
#define CMD_SHIFTESC 20001
diff --git a/language/np3_en_us/dialogs_en_us.rc b/language/np3_en_us/dialogs_en_us.rc
index ffedd00b0..77506bcd2 100644
--- a/language/np3_en_us/dialogs_en_us.rc
+++ b/language/np3_en_us/dialogs_en_us.rc
@@ -71,6 +71,19 @@ BEGIN
CONTROL "",IDC_RICHEDITABOUT,RICHEDIT_CONTROL_VER,WS_VSCROLL | WS_HSCROLL | WS_TABSTOP | 0x29c4,20,80,360,168
END
+
+IDD_MUI_CMDLINEHELP DIALOGEX 0, 0, 280, 160
+STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Command Line Help"
+FONT 8, "MS Shell Dlg", 0, 0, 0x0
+BEGIN
+ICON IDI_MUI_RUN, IDC_STATIC, 10, 7, 20, 20
+DEFPUSHBUTTON "OK", IDOK, 220, 137, 55, 16
+//LTEXT "_place_holder_", IDC_CMDLINEHELP, 40, 7, 226, 290
+EDITTEXT IDC_CMDLINEHELP, 36, 7, 230, 120, ES_MULTILINE | ES_READONLY | WS_VSCROLL | NOT WS_BORDER
+END
+
+
IDD_MUI_FIND DIALOGEX 0, 0, 273, 142
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_NOFAILCREATE | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Find Text"
diff --git a/language/np3_en_us/strings_en_us.rc b/language/np3_en_us/strings_en_us.rc
index a76b8c37a..2960c6f22 100644
--- a/language/np3_en_us/strings_en_us.rc
+++ b/language/np3_en_us/strings_en_us.rc
@@ -189,7 +189,7 @@ END
STRINGTABLE
BEGIN
IDS_MUI_TRANSL_AUTHOR "(en-US) English(amer.) text by Flo Balmer et al."
- IDS_MUI_CMDLINEHELP "Command Line Help\n\nfile\tMust be the last argument,\n\tno quoted spaces by default.\n+\tAccept multiple file arguments (with quoted spaces).\n-\tAccept single file argument (without quoted spaces).\n…\tEncoding\n\t(/ansi, /unicode, /unicodebe, /utf8, /utf8sig).\n…\tLine ending mode (/crlf, /cr, /lf).\n/e\tFile source encoding.\n/g\tJump to specified position (/g -1 end of file).\n/m\tMatch specified text\n\t(/m- last, /mr regex, /mb backslash).\n/l\tAuto-reload modified files.\n/q\tForce creation of new files without prompt.\n/s\tSelect specified syntax scheme.\n/d\tSelect default text scheme.\n/h\tSelect Web Source Code scheme.\n/x\tSelect XML Document scheme.\n/c\tOpen new window and paste clipboard contents.\n/b\tOpen new paste board to collect clipboard entries.\n/n\tAlways open a new window (/ns single file instance).\n/r\tReuse window (/rs single file instance).\n/p\tSet window position and size (/p0, /ps, /pf,l,t,r,b,m).\n/t\tSet window title.\n/i\tStart as tray icon.\n/o\tKeep window on top.\n/f\tSpecify ini-file (/f0 no ini-file).\n/u\tLaunch with elevated privileges.\n/v\tPrint file immediately and quit.\n/vd\tPrint file (open printer dialog).\n/z\tSkip next\n\t(usable for registry-based Notepad replacement)."
+ IDS_MUI_CMDLINEHELP "Command Line Help\r\n\r\nfile\tMust be the last argument,\r\n\tno quoted spaces by default.\r\n+\tAccept multiple file arguments (with quoted spaces).\r\n-\tAccept single file argument (without quoted spaces).\r\n…\tEncoding\r\n\t(/ansi, /unicode, /unicodebe, /utf8, /utf8sig).\r\n…\tLine ending mode (/crlf, /cr, /lf).\r\n/e\tFile source encoding.\r\n/g\tJump to specified position (/g -1 end of file).\r\n/m\tMatch specified text\r\n\t(/m- last, /mr regex, /mb backslash).\r\n/l\tAuto-reload modified files.\r\n/q\tForce creation of new files without prompt.\r\n/s\tSelect specified syntax scheme.\r\n/d\tSelect default text scheme.\r\n/h\tSelect Web Source Code scheme.\r\n/x\tSelect XML Document scheme.\r\n/c\tOpen new window and paste clipboard contents.\r\n/b\tOpen new paste board to collect clipboard entries.\r\n/n\tAlways open a new window (/ns single file instance).\r\n/r\tReuse window (/rs single file instance).\r\n/p\tSet window position and size (/p0, /ps, /pf,l,t,r,b,m).\r\n/t\tSet window title.\r\n/i\tStart as tray icon.\r\n/o\tKeep window on top.\r\n/f\tSpecify ini-file (/f0 no ini-file).\r\n/u\tLaunch with elevated privileges.\r\n/v\tPrint file immediately and quit.\r\n/vd\tPrint file (open printer dialog).\r\n/z\tSkip next\r\n\t(usable for registry-based Notepad replacement)."
IDS_MUI_EXAMPLE_TEXT "The quick brown fox jumps over the lazy dog, 0123456789."
IDS_MUI_ZERO_LEN_MATCH "^ Zero-Length Match"
END
diff --git a/minipath/License.txt b/minipath/License.txt
index 6df01d1ea..a1da379dd 100644
--- a/minipath/License.txt
+++ b/minipath/License.txt
@@ -1,7 +1,7 @@
-MiniPath Copyright © 2008-2016 Rizonesoft, All rights reserved.
+MiniPath Copyright © 2008-2016 Rizonesoft, All rights reserved.
https://rizonesoft.com
-metapath Copyright © 2004-2011 Florian Balmer
+metapath Copyright © 2004-2011 Florian Balmer
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
diff --git a/minipath/Readme.txt b/minipath/Readme.txt
index 77462ac3a..d14a38baf 100644
--- a/minipath/Readme.txt
+++ b/minipath/Readme.txt
@@ -1,4 +1,4 @@
-
+
=======================================================================
= =
= =
diff --git a/minipath/metapath.txt b/minipath/metapath.txt
index 5b0212afb..50cb2cd51 100644
--- a/minipath/metapath.txt
+++ b/minipath/metapath.txt
@@ -1,4 +1,4 @@
-
+
=======================================================================
= =
= =
diff --git a/np3portableapp/_buildname.txt b/np3portableapp/_buildname.txt
index ec9870689..2bb514739 100644
--- a/np3portableapp/_buildname.txt
+++ b/np3portableapp/_buildname.txt
@@ -1 +1 @@
-"Dev_Test_1"
+"Dev_Test_2"
diff --git a/res/Notepad3.exe.manifest.conf b/res/Notepad3.exe.manifest.conf
index a1d93ee73..30a1fe2cd 100644
--- a/res/Notepad3.exe.manifest.conf
+++ b/res/Notepad3.exe.manifest.conf
@@ -3,8 +3,8 @@
- Notepad3 Dev_Test_1
+ Notepad3 Dev_Test_2
diff --git a/src/ChooseFont/ChooseFont.cpp b/src/ChooseFont/ChooseFont.cpp
index c01f8e672..faf430ee4 100644
--- a/src/ChooseFont/ChooseFont.cpp
+++ b/src/ChooseFont/ChooseFont.cpp
@@ -1,4 +1,4 @@
-// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
+// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
@@ -49,39 +49,39 @@ class ChooseFontDialog
{
public:
- explicit ChooseFontDialog(HWND hParent, const WCHAR* localeName, DPI_T dpi, LPCHOOSEFONT lpCFGDI);
- virtual ~ChooseFontDialog();
- ChooseFontDialog() = delete;
+ explicit ChooseFontDialog(HWND hParent, const WCHAR* localeName, DPI_T dpi, LPCHOOSEFONT lpCFGDI);
+ virtual ~ChooseFontDialog();
+ ChooseFontDialog() = delete;
- HRESULT GetTextFormat(IDWriteTextFormat** textFormat);
- HRESULT GetTextFormat(IDWriteTextFormat* textFormatIn, IDWriteTextFormat** textFormatOut);
+ HRESULT GetTextFormat(IDWriteTextFormat** textFormat);
+ HRESULT GetTextFormat(IDWriteTextFormat* textFormatIn, IDWriteTextFormat** textFormatOut);
private:
- HWND m_parent;
- HWND m_dialog;
- WCHAR m_localeName[LOCALE_NAME_MAX_LENGTH];
- DPI_T m_currentDPI;
- LPCHOOSEFONT m_chooseFontStruct;
- IDWriteFontCollection* m_fontCollection;
- IDWriteTextFormat* m_currentTextFormat;
- IDWriteTextFormat* m_renderTextFormat;
-
- HRESULT OnFontFamilySelect();
- HRESULT OnFontFaceSelect();
- HRESULT OnFontSizeSelect();
+ HWND m_parent;
+ HWND m_dialog;
+ WCHAR m_localeName[LOCALE_NAME_MAX_LENGTH];
+ DPI_T m_currentDPI;
+ LPCHOOSEFONT m_chooseFontStruct;
+ IDWriteFontCollection* m_fontCollection;
+ IDWriteTextFormat* m_currentTextFormat;
+ IDWriteTextFormat* m_renderTextFormat;
- HRESULT OnFontFamilyNameEdit(HWND hwndFontFamilies);
- HRESULT OnFontFaceNameEdit(HWND hwndFontFaces);
- HRESULT OnFontSizeNameEdit(HWND hwndFontSizes);
+ HRESULT OnFontFamilySelect();
+ HRESULT OnFontFaceSelect();
+ HRESULT OnFontSizeSelect();
- HRESULT DrawSampleText(HDC sampleDC);
+ HRESULT OnFontFamilyNameEdit(HWND hwndFontFamilies);
+ HRESULT OnFontFaceNameEdit(HWND hwndFontFaces);
+ HRESULT OnFontSizeNameEdit(HWND hwndFontSizes);
- static INT_PTR CALLBACK CFDialogProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
+ HRESULT DrawSampleText(HDC sampleDC);
- BOOL OnInitDialog(HWND dialog, HWND hwndFocus, LPARAM lParam);
- void OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify);
- void OnDrawItem(HWND hwnd, const DRAWITEMSTRUCT* lpDrawItem);
+ static INT_PTR CALLBACK CFDialogProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
+
+ BOOL OnInitDialog(HWND dialog, HWND hwndFocus, LPARAM lParam);
+ void OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify);
+ void OnDrawItem(HWND hwnd, const DRAWITEMSTRUCT* lpDrawItem);
};
@@ -123,9 +123,9 @@ ChooseFontDialog::ChooseFontDialog(HWND hParent, const WCHAR* localeName, const
ChooseFontDialog::~ChooseFontDialog()
{
- SafeRelease(&m_fontCollection);
- SafeRelease(&m_currentTextFormat);
- SafeRelease(&m_renderTextFormat);
+ SafeRelease(&m_fontCollection);
+ SafeRelease(&m_currentTextFormat);
+ SafeRelease(&m_renderTextFormat);
}
@@ -139,53 +139,51 @@ ChooseFontDialog::~ChooseFontDialog()
HRESULT ChooseFontDialog::GetTextFormat(IDWriteTextFormat** textFormat)
{
- HRESULT hr = S_OK;
+ HRESULT hr = S_OK;
- *textFormat = nullptr;
-
- // Default to the system font collection
- SafeRelease(&m_fontCollection);
- hr = g_dwrite->GetSystemFontCollection(&m_fontCollection);
+ *textFormat = nullptr;
- // Create a default text format
- if (SUCCEEDED(hr))
- {
- SafeRelease(&m_currentTextFormat);
+ // Default to the system font collection
+ SafeRelease(&m_fontCollection);
+ hr = g_dwrite->GetSystemFontCollection(&m_fontCollection);
- const WCHAR* const fontFamilyName = m_chooseFontStruct->lpLogFont->lfFaceName;
- float const pointSize = static_cast(m_chooseFontStruct->iPointSize) / 10.0f;
- auto const fontWeight = static_cast(m_chooseFontStruct->lpLogFont->lfWeight); // TODO: mapping?
- DWRITE_FONT_STYLE const fontStyle = (m_chooseFontStruct->lpLogFont->lfItalic ?
- DWRITE_FONT_STYLE_ITALIC : DWRITE_FONT_STYLE_NORMAL);
- DWRITE_FONT_STRETCH const fontStretch = DWRITE_FONT_STRETCH_NORMAL;
+ // Create a default text format
+ if (SUCCEEDED(hr)) {
+ SafeRelease(&m_currentTextFormat);
- hr = g_dwrite->CreateTextFormat(
- fontFamilyName,
- m_fontCollection,
- fontWeight,
- fontStyle,
- fontStretch,
- pointSize,
- m_localeName,
- &m_currentTextFormat);
+ const WCHAR* const fontFamilyName = m_chooseFontStruct->lpLogFont->lfFaceName;
+ float const pointSize = static_cast(m_chooseFontStruct->iPointSize) / 10.0f;
+ auto const fontWeight = static_cast(m_chooseFontStruct->lpLogFont->lfWeight); // TODO: mapping?
+ DWRITE_FONT_STYLE const fontStyle = (m_chooseFontStruct->lpLogFont->lfItalic ?
+ DWRITE_FONT_STYLE_ITALIC : DWRITE_FONT_STYLE_NORMAL);
+ DWRITE_FONT_STRETCH const fontStretch = DWRITE_FONT_STRETCH_NORMAL;
+
+ hr = g_dwrite->CreateTextFormat(
+ fontFamilyName,
+ m_fontCollection,
+ fontWeight,
+ fontStyle,
+ fontStretch,
+ pointSize,
+ m_localeName,
+ &m_currentTextFormat);
+ }
+
+ // Open the dialog
+ if (SUCCEEDED(hr)) {
+ if (Globals.hLngResContainer) {
+ hr = static_cast(DialogBoxParam(Globals.hLngResContainer, MAKEINTRESOURCE(IDD_MUI_CHOOSEFONT), m_parent, CFDialogProc, reinterpret_cast(this)));
}
-
- // Open the dialog
- if (SUCCEEDED(hr))
- {
- if (Globals.hLngResContainer) {
- hr = static_cast(DialogBoxParam(Globals.hLngResContainer, MAKEINTRESOURCE(IDD_MUI_CHOOSEFONT), m_parent, CFDialogProc, reinterpret_cast(this)));
- }
- else {
- hr = static_cast(DialogBoxParam(g_hInstanceNP3, MAKEINTRESOURCE(IDD_MUI_CHOOSEFONT), m_parent, CFDialogProc, reinterpret_cast(this)));
- }
+ else {
+ hr = static_cast(DialogBoxParam(g_hInstanceNP3, MAKEINTRESOURCE(IDD_MUI_CHOOSEFONT), m_parent, CFDialogProc, reinterpret_cast(this)));
}
+ }
- // If all went well, and the user didn't cancel, return the new format.
- if (hr == S_OK) {
- *textFormat = SafeDetach(&m_currentTextFormat);
- }
- return hr;
+ // If all went well, and the user didn't cancel, return the new format.
+ if (hr == S_OK) {
+ *textFormat = SafeDetach(&m_currentTextFormat);
+ }
+ return hr;
}
@@ -200,37 +198,35 @@ HRESULT ChooseFontDialog::GetTextFormat(IDWriteTextFormat** textFormat)
HRESULT ChooseFontDialog::GetTextFormat(IDWriteTextFormat* textFormatIn, IDWriteTextFormat** textFormatOut)
{
- HRESULT hr = S_OK;
+ HRESULT hr = S_OK;
- *textFormatOut = nullptr;
+ *textFormatOut = nullptr;
- SafeSet(&m_currentTextFormat, textFormatIn);
+ SafeSet(&m_currentTextFormat, textFormatIn);
- // Pull out the input font attributes
- SafeRelease(&m_fontCollection);
- hr = m_currentTextFormat->GetFontCollection(&m_fontCollection);
-
- if (SUCCEEDED(hr))
- {
- hr = m_currentTextFormat->GetLocaleName(&m_localeName[0], _ARRAYSIZE(m_localeName));
+ // Pull out the input font attributes
+ SafeRelease(&m_fontCollection);
+ hr = m_currentTextFormat->GetFontCollection(&m_fontCollection);
+
+ if (SUCCEEDED(hr)) {
+ hr = m_currentTextFormat->GetLocaleName(&m_localeName[0], _ARRAYSIZE(m_localeName));
+ }
+
+ // Open the dialog
+ if (SUCCEEDED(hr)) {
+ if (Globals.hLngResContainer) {
+ hr = static_cast(DialogBoxParam(Globals.hLngResContainer, MAKEINTRESOURCE(IDD_MUI_CHOOSEFONT), m_parent, CFDialogProc, reinterpret_cast(this)));
}
-
- // Open the dialog
- if (SUCCEEDED(hr))
- {
- if (Globals.hLngResContainer) {
- hr = static_cast(DialogBoxParam(Globals.hLngResContainer, MAKEINTRESOURCE(IDD_MUI_CHOOSEFONT), m_parent, CFDialogProc, reinterpret_cast(this)));
- }
- else {
- hr = static_cast(DialogBoxParam(g_hInstanceNP3, MAKEINTRESOURCE(IDD_MUI_CHOOSEFONT), m_parent, CFDialogProc, reinterpret_cast(this)));
- }
+ else {
+ hr = static_cast(DialogBoxParam(g_hInstanceNP3, MAKEINTRESOURCE(IDD_MUI_CHOOSEFONT), m_parent, CFDialogProc, reinterpret_cast(this)));
}
+ }
- // If all went well, and the user didn't cancel, return the new format.
- if (hr == S_OK) {
- *textFormatOut = SafeDetach(&m_currentTextFormat);
- }
- return hr;
+ // If all went well, and the user didn't cancel, return the new format.
+ if (hr == S_OK) {
+ *textFormatOut = SafeDetach(&m_currentTextFormat);
+ }
+ return hr;
}
@@ -244,84 +240,76 @@ HRESULT ChooseFontDialog::GetTextFormat(IDWriteTextFormat* textFormatIn, IDWrite
HRESULT ChooseFontDialog::OnFontFamilySelect()
{
- HRESULT hr = S_OK;
+ HRESULT hr = S_OK;
- HWND hwndFontFamilyNames = GetDlgItem(m_dialog, IDC_FONT_FAMILY_NAMES);
- HWND hwndFontFaceNames = GetDlgItem(m_dialog, IDC_FONT_FACE_NAMES);
- int currentSelection = ComboBox_GetCurSel(hwndFontFamilyNames);
+ HWND hwndFontFamilyNames = GetDlgItem(m_dialog, IDC_FONT_FAMILY_NAMES);
+ HWND hwndFontFaceNames = GetDlgItem(m_dialog, IDC_FONT_FACE_NAMES);
+ int currentSelection = ComboBox_GetCurSel(hwndFontFamilyNames);
- // Get the font family name
- WCHAR fontFamilyName[100];
+ // Get the font family name
+ WCHAR fontFamilyName[100];
- UINT32 fontFamilyNameLength = ComboBox_GetLBTextLen(hwndFontFamilyNames, currentSelection) + 1;
- if (fontFamilyNameLength > _ARRAYSIZE(fontFamilyName))
- hr = E_NOT_SUFFICIENT_BUFFER;
+ UINT32 fontFamilyNameLength = ComboBox_GetLBTextLen(hwndFontFamilyNames, currentSelection) + 1;
+ if (fontFamilyNameLength > _ARRAYSIZE(fontFamilyName))
+ hr = E_NOT_SUFFICIENT_BUFFER;
- if (SUCCEEDED(hr))
- {
- ComboBox_GetLBText(hwndFontFamilyNames, currentSelection, &fontFamilyName[0]);
+ if (SUCCEEDED(hr)) {
+ ComboBox_GetLBText(hwndFontFamilyNames, currentSelection, &fontFamilyName[0]);
+ }
+
+ // Get the face names for the new font family
+ IDWriteFontFamily* fontFamily = nullptr;
+ std::vector fonts;
+
+ // Get the font variants for this family
+ if (currentSelection != CB_ERR)
+ hr = GetFonts(m_fontCollection, fontFamilyName, fonts);
+
+ // Initialize the face name list
+ std::vector fontFaceInfo;
+ if (SUCCEEDED(hr)) {
+ ComboBox_ResetContent(hwndFontFaceNames);
+ GetFontFaceInfo(fonts, m_localeName, fontFaceInfo);
+ }
+
+ if (SUCCEEDED(hr)) {
+ for (size_t i = 0; i != fontFaceInfo.size(); ++i) {
+ int fontFaceIndex = ComboBox_AddString(hwndFontFaceNames, fontFaceInfo[i].fontFaceName);
+ ComboBox_SetItemData(hwndFontFaceNames, fontFaceIndex, fontFaceInfo[i].PackedFontAttributes());
+ }
+ }
+
+ // Select the best fit font face for the current attributes
+ if (SUCCEEDED(hr)) {
+ FontFaceInfo desiredAttributes(
+ L"",
+ m_currentTextFormat->GetFontWeight(),
+ m_currentTextFormat->GetFontStyle(),
+ m_currentTextFormat->GetFontStretch());
+
+ int selectedFontFaceName = 0;
+ ULONG bestFitAttributes = GetBestFontAttributes(m_fontCollection, fontFamilyName, desiredAttributes);
+
+ int fontFaceCount = ComboBox_GetCount(hwndFontFaceNames);
+
+ for (int i = 0; i != fontFaceCount; ++i) {
+ if (static_cast(ComboBox_GetItemData(hwndFontFaceNames, i)) == bestFitAttributes) {
+ selectedFontFaceName = i;
+ break;
+ }
}
- // Get the face names for the new font family
- IDWriteFontFamily* fontFamily = nullptr;
- std::vector fonts;
+ ComboBox_SetCurSel(hwndFontFaceNames, selectedFontFaceName);
+ OnFontFaceSelect();
+ }
- // Get the font variants for this family
- if (currentSelection != CB_ERR)
- hr = GetFonts(m_fontCollection, fontFamilyName, fonts);
+ // Release the held font list.
+ for (auto& font : fonts) {
+ SafeRelease(&font);
+ }
+ SafeRelease(&fontFamily);
- // Initialize the face name list
- std::vector fontFaceInfo;
- if (SUCCEEDED(hr))
- {
- ComboBox_ResetContent(hwndFontFaceNames);
- GetFontFaceInfo(fonts, m_localeName, fontFaceInfo);
- }
-
- if (SUCCEEDED(hr))
- {
- for (size_t i = 0; i != fontFaceInfo.size(); ++i)
- {
- int fontFaceIndex = ComboBox_AddString(hwndFontFaceNames, fontFaceInfo[i].fontFaceName);
- ComboBox_SetItemData(hwndFontFaceNames, fontFaceIndex, fontFaceInfo[i].PackedFontAttributes());
- }
- }
-
- // Select the best fit font face for the current attributes
- if (SUCCEEDED(hr))
- {
- FontFaceInfo desiredAttributes(
- L"",
- m_currentTextFormat->GetFontWeight(),
- m_currentTextFormat->GetFontStyle(),
- m_currentTextFormat->GetFontStretch());
-
- int selectedFontFaceName = 0;
- ULONG bestFitAttributes = GetBestFontAttributes(m_fontCollection, fontFamilyName, desiredAttributes);
-
- int fontFaceCount = ComboBox_GetCount(hwndFontFaceNames);
-
- for (int i = 0; i != fontFaceCount; ++i)
- {
- if (static_cast(ComboBox_GetItemData(hwndFontFaceNames, i)) == bestFitAttributes)
- {
- selectedFontFaceName = i;
- break;
- }
- }
-
- ComboBox_SetCurSel(hwndFontFaceNames, selectedFontFaceName);
- OnFontFaceSelect();
- }
-
- // Release the held font list.
- for (auto& font : fonts)
- {
- SafeRelease(&font);
- }
- SafeRelease(&fontFamily);
-
- return hr;
+ return hr;
}
@@ -335,12 +323,12 @@ HRESULT ChooseFontDialog::OnFontFamilySelect()
HRESULT ChooseFontDialog::OnFontFaceSelect()
{
- HRESULT hr = S_OK;
+ HRESULT hr = S_OK;
- // Signal the sample text window to redraw itself.
- InvalidateRect(GetDlgItem(m_dialog, IDC_SAMPLE_BOX), nullptr, false);
+ // Signal the sample text window to redraw itself.
+ InvalidateRect(GetDlgItem(m_dialog, IDC_SAMPLE_BOX), nullptr, false);
- return hr;
+ return hr;
}
@@ -354,12 +342,12 @@ HRESULT ChooseFontDialog::OnFontFaceSelect()
HRESULT ChooseFontDialog::OnFontSizeSelect()
{
- HRESULT hr = S_OK;
+ HRESULT hr = S_OK;
- // Signal the sample text window to redraw itself.
- InvalidateRect(GetDlgItem(m_dialog, IDC_SAMPLE_BOX), nullptr, false);
+ // Signal the sample text window to redraw itself.
+ InvalidateRect(GetDlgItem(m_dialog, IDC_SAMPLE_BOX), nullptr, false);
- return hr;
+ return hr;
}
@@ -378,69 +366,64 @@ HRESULT ChooseFontDialog::OnFontSizeSelect()
HRESULT ChooseFontDialog::OnFontFamilyNameEdit(HWND hwndFontFamilies)
{
- HRESULT hr = S_OK;
+ HRESULT hr = S_OK;
- // Save the state of the edit box selection
- DWORD editSelection = ComboBox_GetEditSel(hwndFontFamilies);
- int editSelectionBegin = LOWORD(editSelection);
- int editSelectionEnd = HIWORD(editSelection);
+ // Save the state of the edit box selection
+ DWORD editSelection = ComboBox_GetEditSel(hwndFontFamilies);
+ int editSelectionBegin = LOWORD(editSelection);
+ int editSelectionEnd = HIWORD(editSelection);
- // Get the text in the edit portion of the combo
- WCHAR fontFamilyName[100];
- ComboBox_GetText(hwndFontFamilies, &fontFamilyName[0], _ARRAYSIZE(fontFamilyName));
+ // Get the text in the edit portion of the combo
+ WCHAR fontFamilyName[100];
+ ComboBox_GetText(hwndFontFamilies, &fontFamilyName[0], _ARRAYSIZE(fontFamilyName));
- // Try to find an exact match (case-insensitive)
- int matchingFontFamily = ComboBox_FindStringExact(hwndFontFamilies, -1, fontFamilyName);
- bool usedAltMatch = false;
+ // Try to find an exact match (case-insensitive)
+ int matchingFontFamily = ComboBox_FindStringExact(hwndFontFamilies, -1, fontFamilyName);
+ bool usedAltMatch = false;
- if (matchingFontFamily == CB_ERR)
- {
- // If a match isn't found, scan all for alternate forms in the font
- // collection.
- IDWriteFontFamily* fontFamily = nullptr;
- hr = GetFontFamily(m_fontCollection, fontFamilyName, &fontFamily);
+ if (matchingFontFamily == CB_ERR) {
+ // If a match isn't found, scan all for alternate forms in the font
+ // collection.
+ IDWriteFontFamily* fontFamily = nullptr;
+ hr = GetFontFamily(m_fontCollection, fontFamilyName, &fontFamily);
- if (hr == S_OK)
- {
- // If a match is found, get the family name localized to the locale
- // we're using in the combo box and match against that.
- usedAltMatch = true;
+ if (hr == S_OK) {
+ // If a match is found, get the family name localized to the locale
+ // we're using in the combo box and match against that.
+ usedAltMatch = true;
- std::wstring localFontFamilyName;
- hr = GetFontFamilyName(fontFamily, m_localeName, localFontFamilyName);
+ std::wstring localFontFamilyName;
+ hr = GetFontFamilyName(fontFamily, m_localeName, localFontFamilyName);
- if (SUCCEEDED(hr))
- {
- matchingFontFamily = ComboBox_FindStringExact(hwndFontFamilies, -1, localFontFamilyName.c_str());
- }
- }
- else if (hr == DWRITE_E_NOFONT)
- {
- // Ignore DWRITE_E_NOFONT errors
- hr = S_OK;
- }
-
- SafeRelease(&fontFamily);
+ if (SUCCEEDED(hr)) {
+ matchingFontFamily = ComboBox_FindStringExact(hwndFontFamilies, -1, localFontFamilyName.c_str());
+ }
+ }
+ else if (hr == DWRITE_E_NOFONT) {
+ // Ignore DWRITE_E_NOFONT errors
+ hr = S_OK;
}
- // Process the match, if any
- if (SUCCEEDED(hr) && matchingFontFamily != CB_ERR)
- {
- ComboBox_SetCurSel(hwndFontFamilies, matchingFontFamily);
+ SafeRelease(&fontFamily);
+ }
- // SetCurSel will update the edit text to match the text of the
- // selected item. If we matched against an alternate name put that
- // name back.
- if (usedAltMatch)
- ComboBox_SetText(hwndFontFamilies, fontFamilyName);
+ // Process the match, if any
+ if (SUCCEEDED(hr) && matchingFontFamily != CB_ERR) {
+ ComboBox_SetCurSel(hwndFontFamilies, matchingFontFamily);
- // Reset the edit selection to what is was before SetCurSel.
- ComboBox_SetEditSel(hwndFontFamilies, editSelectionBegin, editSelectionEnd);
+ // SetCurSel will update the edit text to match the text of the
+ // selected item. If we matched against an alternate name put that
+ // name back.
+ if (usedAltMatch)
+ ComboBox_SetText(hwndFontFamilies, fontFamilyName);
- hr = OnFontFamilySelect();
- }
+ // Reset the edit selection to what is was before SetCurSel.
+ ComboBox_SetEditSel(hwndFontFamilies, editSelectionBegin, editSelectionEnd);
- return hr;
+ hr = OnFontFamilySelect();
+ }
+
+ return hr;
}
@@ -455,29 +438,28 @@ HRESULT ChooseFontDialog::OnFontFamilyNameEdit(HWND hwndFontFamilies)
HRESULT ChooseFontDialog::OnFontFaceNameEdit(HWND hwnd)
{
- HRESULT hr = S_OK;
+ HRESULT hr = S_OK;
- // Save the state of the edit box selection
- DWORD editSelection = ComboBox_GetEditSel(hwnd);
- int editSelectionBegin = LOWORD(editSelection);
- int editSelectionEnd = HIWORD(editSelection);
+ // Save the state of the edit box selection
+ DWORD editSelection = ComboBox_GetEditSel(hwnd);
+ int editSelectionBegin = LOWORD(editSelection);
+ int editSelectionEnd = HIWORD(editSelection);
- // Try to find the currently typed text
- WCHAR text[100];
- ComboBox_GetText(hwnd, &text[0], _ARRAYSIZE(text));
+ // Try to find the currently typed text
+ WCHAR text[100];
+ ComboBox_GetText(hwnd, &text[0], _ARRAYSIZE(text));
- int selectedItem = ComboBox_FindStringExact(hwnd, -1, text);
- if (selectedItem != CB_ERR)
- {
- // If text is found, select the corresponding list item, put the
- // selection state back to what it was originally, and redraw the
- // sample text
- ComboBox_SetCurSel(hwnd, selectedItem);
- ComboBox_SetEditSel(hwnd, editSelectionBegin, editSelectionEnd);
- hr = OnFontFaceSelect();
- }
+ int selectedItem = ComboBox_FindStringExact(hwnd, -1, text);
+ if (selectedItem != CB_ERR) {
+ // If text is found, select the corresponding list item, put the
+ // selection state back to what it was originally, and redraw the
+ // sample text
+ ComboBox_SetCurSel(hwnd, selectedItem);
+ ComboBox_SetEditSel(hwnd, editSelectionBegin, editSelectionEnd);
+ hr = OnFontFaceSelect();
+ }
- return hr;
+ return hr;
}
@@ -492,29 +474,28 @@ HRESULT ChooseFontDialog::OnFontFaceNameEdit(HWND hwnd)
HRESULT ChooseFontDialog::OnFontSizeNameEdit(HWND hwnd)
{
- HRESULT hr = S_OK;
+ HRESULT hr = S_OK;
- // Save the state of the edit box selection
- DWORD editSelection = ComboBox_GetEditSel(hwnd);
- int editSelectionBegin = LOWORD(editSelection);
- int editSelectionEnd = HIWORD(editSelection);
+ // Save the state of the edit box selection
+ DWORD editSelection = ComboBox_GetEditSel(hwnd);
+ int editSelectionBegin = LOWORD(editSelection);
+ int editSelectionEnd = HIWORD(editSelection);
- // Try to find the currently typed text
- WCHAR text[100];
- ComboBox_GetText(hwnd, &text[0], _ARRAYSIZE(text));
+ // Try to find the currently typed text
+ WCHAR text[100];
+ ComboBox_GetText(hwnd, &text[0], _ARRAYSIZE(text));
- int selectedItem = ComboBox_FindStringExact(hwnd, -1, text);
- if (selectedItem != CB_ERR)
- {
- // If text is found, select the corresponding list item, put the
- // selection state back to what it was originally, and redraw the
- // sample text
- ComboBox_SetCurSel(hwnd, selectedItem);
- ComboBox_SetEditSel(hwnd, editSelectionBegin, editSelectionEnd);
- }
- hr = OnFontSizeSelect();
+ int selectedItem = ComboBox_FindStringExact(hwnd, -1, text);
+ if (selectedItem != CB_ERR) {
+ // If text is found, select the corresponding list item, put the
+ // selection state back to what it was originally, and redraw the
+ // sample text
+ ComboBox_SetCurSel(hwnd, selectedItem);
+ ComboBox_SetEditSel(hwnd, editSelectionBegin, editSelectionEnd);
+ }
+ hr = OnFontSizeSelect();
- return hr;
+ return hr;
}
@@ -526,124 +507,121 @@ HRESULT ChooseFontDialog::OnFontSizeNameEdit(HWND hwnd)
HRESULT ChooseFontDialog::DrawSampleText(HDC sampleDC)
{
- static WCHAR sampleText[256] = { L'\0' };
- if (sampleText[0] == L'\0') {
- LoadLngStringW(IDS_MUI_EXAMPLE_TEXT, sampleText, _ARRAYSIZE(sampleText));
- }
+ static WCHAR sampleText[256] = { L'\0' };
+ if (sampleText[0] == L'\0') {
+ LoadLngStringW(IDS_MUI_EXAMPLE_TEXT, sampleText, _ARRAYSIZE(sampleText));
+ }
- HRESULT hr = S_OK;
+ HRESULT hr = S_OK;
- HWND hwndFontFamilies = GetDlgItem(m_dialog, IDC_FONT_FAMILY_NAMES);
- HWND hwndFontFaces = GetDlgItem(m_dialog, IDC_FONT_FACE_NAMES);
- HWND hwndFontSizes = GetDlgItem(m_dialog, IDC_FONT_SIZE);
- HWND hwndSampleBox = GetDlgItem(m_dialog, IDC_SAMPLE_BOX);
+ HWND hwndFontFamilies = GetDlgItem(m_dialog, IDC_FONT_FAMILY_NAMES);
+ HWND hwndFontFaces = GetDlgItem(m_dialog, IDC_FONT_FACE_NAMES);
+ HWND hwndFontSizes = GetDlgItem(m_dialog, IDC_FONT_SIZE);
+ HWND hwndSampleBox = GetDlgItem(m_dialog, IDC_SAMPLE_BOX);
- // Get the currently selected font family. If there isn't one, then just
- // don't update the text format and continue to use whatever we had before
- int selectedFontFamily = ComboBox_GetCurSel(hwndFontFamilies);
+ // Get the currently selected font family. If there isn't one, then just
+ // don't update the text format and continue to use whatever we had before
+ int selectedFontFamily = ComboBox_GetCurSel(hwndFontFamilies);
- if (selectedFontFamily != CB_ERR)
- {
- // Get the font family name
- WCHAR fontFamilyName[100];
- GetWindowText(hwndFontFamilies, &fontFamilyName[0], _ARRAYSIZE(fontFamilyName));
+ if (selectedFontFamily != CB_ERR) {
+ // Get the font family name
+ WCHAR fontFamilyName[100];
+ GetWindowText(hwndFontFamilies, &fontFamilyName[0], _ARRAYSIZE(fontFamilyName));
- // Get the font face attributes
- int selectedFontFace = ComboBox_GetCurSel(hwndFontFaces);
- auto packedAttributes = static_cast(ComboBox_GetItemData(hwndFontFaces, selectedFontFace));
+ // Get the font face attributes
+ int selectedFontFace = ComboBox_GetCurSel(hwndFontFaces);
+ auto packedAttributes = static_cast(ComboBox_GetItemData(hwndFontFaces, selectedFontFace));
- // Get the font size
- WCHAR fontSizeText[100];
- GetWindowText(hwndFontSizes, &fontSizeText[0], _ARRAYSIZE(fontSizeText));
+ // Get the font size
+ WCHAR fontSizeText[100];
+ GetWindowText(hwndFontSizes, &fontSizeText[0], _ARRAYSIZE(fontSizeText));
- auto pointSize = static_cast(wcstod(fontSizeText, nullptr));
- if (pointSize <= 0.0f) { pointSize = 10.0f; }
+ auto pointSize = static_cast(wcstod(fontSizeText, nullptr));
+ if (pointSize <= 0.0f) { pointSize = 10.0f; }
- FontFaceInfo fontFaceInfo(fontFamilyName, packedAttributes);
+ FontFaceInfo fontFaceInfo(fontFamilyName, packedAttributes);
- // Recreate current text format object
- SafeRelease(&m_currentTextFormat);
- hr = g_dwrite->CreateTextFormat(
- fontFamilyName,
- m_fontCollection,
- fontFaceInfo.fontWeight,
- fontFaceInfo.fontStyle,
- fontFaceInfo.fontStretch,
- pointSize,
- m_localeName,
- &m_currentTextFormat);
+ // Recreate current text format object
+ SafeRelease(&m_currentTextFormat);
+ hr = g_dwrite->CreateTextFormat(
+ fontFamilyName,
+ m_fontCollection,
+ fontFaceInfo.fontWeight,
+ fontFaceInfo.fontStyle,
+ fontFaceInfo.fontStretch,
+ pointSize,
+ m_localeName,
+ &m_currentTextFormat);
- // Create the rendering text format object
- float dipSize = (pointSize * m_currentDPI.y) / 72.0f;
+ // Create the rendering text format object
+ float dipSize = (pointSize * m_currentDPI.y) / 72.0f;
- SafeRelease(&m_renderTextFormat);
- hr = g_dwrite->CreateTextFormat(
- fontFamilyName,
- m_fontCollection,
- fontFaceInfo.fontWeight,
- fontFaceInfo.fontStyle,
- fontFaceInfo.fontStretch,
- dipSize,
- m_localeName,
- &m_renderTextFormat);
- }
- // Get the size of the sample box
- RECT sampleBounds = {};
- GetClientRect(hwndSampleBox, &sampleBounds);
+ SafeRelease(&m_renderTextFormat);
+ hr = g_dwrite->CreateTextFormat(
+ fontFamilyName,
+ m_fontCollection,
+ fontFaceInfo.fontWeight,
+ fontFaceInfo.fontStyle,
+ fontFaceInfo.fontStretch,
+ dipSize,
+ m_localeName,
+ &m_renderTextFormat);
+ }
+ // Get the size of the sample box
+ RECT sampleBounds = {};
+ GetClientRect(hwndSampleBox, &sampleBounds);
- UINT width = sampleBounds.right - sampleBounds.left;
- UINT height = sampleBounds.bottom - sampleBounds.top;
+ UINT width = sampleBounds.right - sampleBounds.left;
+ UINT height = sampleBounds.bottom - sampleBounds.top;
- // Layout the sample text using the text format and UI bounds (converted to DIPs)
- IDWriteTextLayout* textLayout = nullptr;
- if (SUCCEEDED(hr)) {
- hr = g_dwrite->CreateTextLayout(
- sampleText,
- _ARRAYSIZE(sampleText) - 1,
- m_renderTextFormat,
- static_cast((width * m_currentDPI.x) / GetDeviceCaps(sampleDC, LOGPIXELSX)),
- static_cast((height * m_currentDPI.y) / GetDeviceCaps(sampleDC, LOGPIXELSY)),
- &textLayout);
- }
+ // Layout the sample text using the text format and UI bounds (converted to DIPs)
+ IDWriteTextLayout* textLayout = nullptr;
+ if (SUCCEEDED(hr)) {
+ hr = g_dwrite->CreateTextLayout(
+ sampleText,
+ _ARRAYSIZE(sampleText) - 1,
+ m_renderTextFormat,
+ static_cast((width * m_currentDPI.x) / GetDeviceCaps(sampleDC, LOGPIXELSX)),
+ static_cast((height * m_currentDPI.y) / GetDeviceCaps(sampleDC, LOGPIXELSY)),
+ &textLayout);
+ }
- // Create a DWrite surface to render to
- GdiTextRenderer* textRenderer = nullptr;
- if (SUCCEEDED(hr))
- {
- textRenderer = SafeAcquire(new(std::nothrow) GdiTextRenderer());
- if (textRenderer != nullptr)
- hr = textRenderer->Initialize(m_dialog, sampleDC, width, height);
- else
- hr = E_FAIL;
- }
+ // Create a DWrite surface to render to
+ GdiTextRenderer* textRenderer = nullptr;
+ if (SUCCEEDED(hr)) {
+ textRenderer = SafeAcquire(new(std::nothrow) GdiTextRenderer());
+ if (textRenderer != nullptr)
+ hr = textRenderer->Initialize(m_dialog, sampleDC, width, height);
+ else
+ hr = E_FAIL;
+ }
- if (SUCCEEDED(hr))
- {
- // Fill the DWrite surface with the background color
- HDC dwriteDC = textRenderer->GetDC();
- SetDCBrushColor(dwriteDC, GetSysColor(COLOR_BTNFACE));
- FillRect(dwriteDC, &sampleBounds, GetStockBrush(DC_BRUSH));
+ if (SUCCEEDED(hr)) {
+ // Fill the DWrite surface with the background color
+ HDC dwriteDC = textRenderer->GetDC();
+ SetDCBrushColor(dwriteDC, GetSysColor(COLOR_BTNFACE));
+ FillRect(dwriteDC, &sampleBounds, GetStockBrush(DC_BRUSH));
- // Draw the text onto the DWrite surface
- hr = textLayout->Draw(nullptr, textRenderer, 0, 0);
+ // Draw the text onto the DWrite surface
+ hr = textLayout->Draw(nullptr, textRenderer, 0, 0);
- // Copy the DWrite surface to the sample on screen
- BitBlt(
- sampleDC,
- 0,
- 0,
- width,
- height,
- dwriteDC,
- 0,
- 0,
- SRCCOPY | NOMIRRORBITMAP);
- }
+ // Copy the DWrite surface to the sample on screen
+ BitBlt(
+ sampleDC,
+ 0,
+ 0,
+ width,
+ height,
+ dwriteDC,
+ 0,
+ 0,
+ SRCCOPY | NOMIRRORBITMAP);
+ }
- SafeRelease(&textRenderer);
- SafeRelease(&textLayout);
+ SafeRelease(&textRenderer);
+ SafeRelease(&textLayout);
- return hr;
+ return hr;
}
@@ -657,24 +635,22 @@ HRESULT ChooseFontDialog::DrawSampleText(HDC sampleDC)
INT_PTR CALLBACK ChooseFontDialog::CFDialogProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
- if (message == WM_INITDIALOG) {
- SetWindowLongPtr(hWnd, GWLP_USERDATA, lParam);
+ if (message == WM_INITDIALOG) {
+ SetWindowLongPtr(hWnd, GWLP_USERDATA, lParam);
+ }
+ auto this_ = reinterpret_cast(GetWindowLongPtr(hWnd, GWLP_USERDATA));
+ if (this_ != nullptr) {
+ LPCFHOOKPROC hookFct = this_->m_chooseFontStruct->lpfnHook;
+ if (hookFct) {
+ (*hookFct)(hWnd, message, wParam, reinterpret_cast(this_->m_chooseFontStruct));
}
- auto this_ = reinterpret_cast(GetWindowLongPtr(hWnd, GWLP_USERDATA));
- if (this_ != nullptr)
- {
- LPCFHOOKPROC hookFct = this_->m_chooseFontStruct->lpfnHook;
- if (hookFct) {
- (*hookFct)(hWnd, message, wParam, reinterpret_cast(this_->m_chooseFontStruct));
- }
- switch (message)
- {
- HANDLE_MSG(hWnd, WM_INITDIALOG, this_->OnInitDialog);
- HANDLE_MSG(hWnd, WM_COMMAND, this_->OnCommand);
- HANDLE_MSG(hWnd, WM_DRAWITEM, this_->OnDrawItem);
- }
+ switch (message) {
+ HANDLE_MSG(hWnd, WM_INITDIALOG, this_->OnInitDialog);
+ HANDLE_MSG(hWnd, WM_COMMAND, this_->OnCommand);
+ HANDLE_MSG(hWnd, WM_DRAWITEM, this_->OnDrawItem);
}
- return FALSE;
+ }
+ return FALSE;
}
@@ -689,64 +665,62 @@ INT_PTR CALLBACK ChooseFontDialog::CFDialogProc(HWND hWnd, UINT message, WPARAM
BOOL ChooseFontDialog::OnInitDialog(HWND dialog, HWND hwndFocus, LPARAM lParam)
{
- m_dialog = dialog;
+ m_dialog = dialog;
- HWND hwndFamilyNames = GetDlgItem(dialog, IDC_FONT_FAMILY_NAMES);
- HWND hwndSizes = GetDlgItem(dialog, IDC_FONT_SIZE);
+ HWND hwndFamilyNames = GetDlgItem(dialog, IDC_FONT_FAMILY_NAMES);
+ HWND hwndSizes = GetDlgItem(dialog, IDC_FONT_SIZE);
- // Fill in the font family name list.
+ // Fill in the font family name list.
- std::vector fontFamilyNames;
- if (FAILED(GetFontFamilyNames(m_fontCollection, m_localeName, fontFamilyNames)))
- return FALSE;
+ std::vector fontFamilyNames;
+ if (FAILED(GetFontFamilyNames(m_fontCollection, m_localeName, fontFamilyNames)))
+ return FALSE;
- for (size_t i = 0; i != fontFamilyNames.size(); ++i)
- ComboBox_AddString(hwndFamilyNames, fontFamilyNames[i].c_str());
-
- // Fill in the hardcoded font sizes
+ for (size_t i = 0; i != fontFamilyNames.size(); ++i)
+ ComboBox_AddString(hwndFamilyNames, fontFamilyNames[i].c_str());
- static const float FontSizes[] = {
- 1.5, 2.5, 3.5, 4.5, 5, 5.5, 6, 6.5, 7, 7.5,
- 8, 8.5, 9, 9.5, 10, 10.5, 11, 11.5, 12, 12.5,
- 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
- 26, 28, 30, 36, 48, 60, 72, 84, 96
- };
+ // Fill in the hardcoded font sizes
- WCHAR sizeName[100];
- sizeName[0] = '\0';
+ static const float FontSizes[] = {
+ 1.5, 2.5, 3.5, 4.5, 5, 5.5, 6, 6.5, 7, 7.5,
+ 8, 8.5, 9, 9.5, 10, 10.5, 11, 11.5, 12, 12.5,
+ 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
+ 26, 28, 30, 36, 48, 60, 72, 84, 96
+ };
- for (int i = 0; i != _ARRAYSIZE(FontSizes); ++i)
- {
- StringCchPrintf(sizeName, _ARRAYSIZE(sizeName), L"%.3G", FontSizes[i]);
- ComboBox_AddString(hwndSizes, sizeName);
- }
+ WCHAR sizeName[100];
+ sizeName[0] = '\0';
- // Select the current size
- FLOAT fCurFontSize = round(m_currentTextFormat->GetFontSize() * 10.0f) / 10.0f;
- StringCchPrintf(sizeName, _ARRAYSIZE(sizeName), L"%.3G", fCurFontSize);
+ for (int i = 0; i != _ARRAYSIZE(FontSizes); ++i) {
+ StringCchPrintf(sizeName, _ARRAYSIZE(sizeName), L"%.3G", FontSizes[i]);
+ ComboBox_AddString(hwndSizes, sizeName);
+ }
+ // Select the current size
+ FLOAT fCurFontSize = round(m_currentTextFormat->GetFontSize() * 10.0f) / 10.0f;
+ StringCchPrintf(sizeName, _ARRAYSIZE(sizeName), L"%.3G", fCurFontSize);
+
+ SetWindowText(hwndSizes, sizeName);
+ if (CB_ERR == ComboBox_SelectString(hwndSizes, -1, sizeName))
SetWindowText(hwndSizes, sizeName);
- if (CB_ERR == ComboBox_SelectString(hwndSizes, -1, sizeName))
- SetWindowText(hwndSizes, sizeName);
- // Select the font family specified in the input text format.
+ // Select the font family specified in the input text format.
- int selectedFontFamily = CB_ERR;
- std::wstring fontFamilyName;
-
- if (SUCCEEDED(GetFontFamilyNameFromFormat(m_currentTextFormat, fontFamilyName)))
- {
- selectedFontFamily = ComboBox_SelectString(hwndFamilyNames, -1, fontFamilyName.c_str());
- }
+ int selectedFontFamily = CB_ERR;
+ std::wstring fontFamilyName;
- if (selectedFontFamily == CB_ERR)
- SetWindowText(hwndFamilyNames, fontFamilyName.c_str());
+ if (SUCCEEDED(GetFontFamilyNameFromFormat(m_currentTextFormat, fontFamilyName))) {
+ selectedFontFamily = ComboBox_SelectString(hwndFamilyNames, -1, fontFamilyName.c_str());
+ }
- OnFontFamilySelect();
+ if (selectedFontFamily == CB_ERR)
+ SetWindowText(hwndFamilyNames, fontFamilyName.c_str());
- CenterDlgInParent(m_dialog);
+ OnFontFamilySelect();
- return TRUE;
+ CenterDlgInParent(m_dialog);
+
+ return TRUE;
}
@@ -760,29 +734,29 @@ BOOL ChooseFontDialog::OnInitDialog(HWND dialog, HWND hwndFocus, LPARAM lParam)
void ChooseFontDialog::OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
{
- if (id == IDCANCEL && codeNotify == BN_CLICKED)
- EndDialog(hwnd, S_FALSE);
+ if (id == IDCANCEL && codeNotify == BN_CLICKED)
+ EndDialog(hwnd, S_FALSE);
- else if (id == IDOK && codeNotify == BN_CLICKED)
- EndDialog(hwnd, S_OK);
+ else if (id == IDOK && codeNotify == BN_CLICKED)
+ EndDialog(hwnd, S_OK);
- else if (id == IDC_FONT_FAMILY_NAMES && codeNotify == CBN_SELCHANGE)
- OnFontFamilySelect();
+ else if (id == IDC_FONT_FAMILY_NAMES && codeNotify == CBN_SELCHANGE)
+ OnFontFamilySelect();
- else if (id == IDC_FONT_FAMILY_NAMES && codeNotify == CBN_EDITCHANGE)
- OnFontFamilyNameEdit(hwndCtl);
+ else if (id == IDC_FONT_FAMILY_NAMES && codeNotify == CBN_EDITCHANGE)
+ OnFontFamilyNameEdit(hwndCtl);
- else if (id == IDC_FONT_FACE_NAMES && codeNotify == CBN_SELCHANGE)
- OnFontFaceSelect();
+ else if (id == IDC_FONT_FACE_NAMES && codeNotify == CBN_SELCHANGE)
+ OnFontFaceSelect();
- else if (id == IDC_FONT_FACE_NAMES && codeNotify == CBN_EDITCHANGE)
- OnFontFaceNameEdit(hwndCtl);
+ else if (id == IDC_FONT_FACE_NAMES && codeNotify == CBN_EDITCHANGE)
+ OnFontFaceNameEdit(hwndCtl);
- else if (id == IDC_FONT_SIZE && codeNotify == CBN_SELCHANGE)
- OnFontSizeSelect();
+ else if (id == IDC_FONT_SIZE && codeNotify == CBN_SELCHANGE)
+ OnFontSizeSelect();
- else if (id == IDC_FONT_SIZE && codeNotify == CBN_EDITCHANGE)
- OnFontSizeNameEdit(hwndCtl);
+ else if (id == IDC_FONT_SIZE && codeNotify == CBN_EDITCHANGE)
+ OnFontSizeNameEdit(hwndCtl);
}
@@ -796,7 +770,7 @@ void ChooseFontDialog::OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotif
void ChooseFontDialog::OnDrawItem(HWND hwnd, const DRAWITEMSTRUCT* lpDrawItem)
{
- DrawSampleText(lpDrawItem->hDC);
+ DrawSampleText(lpDrawItem->hDC);
}
// ############################################################################
@@ -804,11 +778,10 @@ void ChooseFontDialog::OnDrawItem(HWND hwnd, const DRAWITEMSTRUCT* lpDrawItem)
static void SetChosenFontFromTextFormat(
- IDWriteTextFormat* textFormat,
+ IDWriteTextFormat* textFormat,
LPCHOOSEFONT lpCF, const DPI_T dpi)
{
- if (textFormat != nullptr)
- {
+ if (textFormat != nullptr) {
WCHAR fontFamilyName[100];
HDC hdc = GetDC(lpCF->hwndOwner);
@@ -822,7 +795,7 @@ static void SetChosenFontFromTextFormat(
lpCF->iPointSize = static_cast(lround(pointSize * 10.0f));
lpCF->lpLogFont->lfWeight = static_cast(fontWeight);
lpCF->lpLogFont->lfItalic = static_cast((((fontStyle == DWRITE_FONT_STYLE_ITALIC) ||
- (fontStyle == DWRITE_FONT_STYLE_OBLIQUE)) ? TRUE : FALSE));
+ (fontStyle == DWRITE_FONT_STYLE_OBLIQUE)) ? TRUE : FALSE));
lpCF->lpLogFont->lfQuality = static_cast(CLEARTYPE_QUALITY);
ReleaseDC(lpCF->hwndOwner, hdc);
@@ -832,29 +805,29 @@ static void SetChosenFontFromTextFormat(
extern "C" bool ChooseFontDirectWrite(HWND hwnd, const WCHAR* localeName, DPI_T dpi, LPCHOOSEFONT lpCFGDI)
{
- if (!lpCFGDI) { return false; }
+ if (!lpCFGDI) { return false; }
- // The Microsoft Security Development Lifecycle recommends that all
- // applications include the following call to ensure that heap corruptions
- // do not go unnoticed and therefore do not introduce opportunities
- // for security exploits.
- HeapSetInformation(nullptr, HeapEnableTerminationOnCorruption, nullptr, 0);
+ // The Microsoft Security Development Lifecycle recommends that all
+ // applications include the following call to ensure that heap corruptions
+ // do not go unnoticed and therefore do not introduce opportunities
+ // for security exploits.
+ HeapSetInformation(nullptr, HeapEnableTerminationOnCorruption, nullptr, 0);
- if (dpi.x == 0) { dpi.x = dpi.y = USER_DEFAULT_SCREEN_DPI; }
+ if (dpi.x == 0) { dpi.x = dpi.y = USER_DEFAULT_SCREEN_DPI; }
- g_hInstanceNP3 = lpCFGDI->hInstance;
+ g_hInstanceNP3 = lpCFGDI->hInstance;
- DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED, __uuidof(IDWriteFactory), (IUnknown **) &g_dwrite);
+ DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED, __uuidof(IDWriteFactory), (IUnknown **)&g_dwrite);
- IDWriteTextFormat* textFormatOut = nullptr;
- ChooseFontDialog chooseFont(hwnd, localeName, dpi, lpCFGDI);
- chooseFont.GetTextFormat(&textFormatOut);
+ IDWriteTextFormat* textFormatOut = nullptr;
+ ChooseFontDialog chooseFont(hwnd, localeName, dpi, lpCFGDI);
+ chooseFont.GetTextFormat(&textFormatOut);
- SetChosenFontFromTextFormat(textFormatOut, lpCFGDI, dpi);
+ SetChosenFontFromTextFormat(textFormatOut, lpCFGDI, dpi);
- SafeRelease(&textFormatOut);
- SafeRelease(&g_dwrite);
- return true;
+ SafeRelease(&textFormatOut);
+ SafeRelease(&g_dwrite);
+ return true;
}
// ############################################################################
diff --git a/src/ChooseFont/ChooseFont.h b/src/ChooseFont/ChooseFont.h
index afb22ff20..91bf61a44 100644
--- a/src/ChooseFont/ChooseFont.h
+++ b/src/ChooseFont/ChooseFont.h
@@ -1,4 +1,4 @@
-// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
+// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
diff --git a/src/ChooseFont/FontEnumeration.cpp b/src/ChooseFont/FontEnumeration.cpp
index 552d5d40d..8d35bfd13 100644
--- a/src/ChooseFont/FontEnumeration.cpp
+++ b/src/ChooseFont/FontEnumeration.cpp
@@ -1,4 +1,4 @@
-// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
+// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
diff --git a/src/ChooseFont/FontEnumeration.h b/src/ChooseFont/FontEnumeration.h
index b0822f2dc..45f6d8dea 100644
--- a/src/ChooseFont/FontEnumeration.h
+++ b/src/ChooseFont/FontEnumeration.h
@@ -1,4 +1,4 @@
-// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
+// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
diff --git a/src/ChooseFont/GdiTextRenderer.cpp b/src/ChooseFont/GdiTextRenderer.cpp
index 51db547f7..c32efce38 100644
--- a/src/ChooseFont/GdiTextRenderer.cpp
+++ b/src/ChooseFont/GdiTextRenderer.cpp
@@ -1,4 +1,4 @@
-// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
+// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
diff --git a/src/ChooseFont/GdiTextRenderer.h b/src/ChooseFont/GdiTextRenderer.h
index 798b70d93..ac73132cd 100644
--- a/src/ChooseFont/GdiTextRenderer.h
+++ b/src/ChooseFont/GdiTextRenderer.h
@@ -1,4 +1,4 @@
-// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
+// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
diff --git a/src/Dialogs.c b/src/Dialogs.c
index 78180ed7b..b33cbacf2 100644
--- a/src/Dialogs.c
+++ b/src/Dialogs.c
@@ -250,6 +250,7 @@ INT_PTR InfoBoxLng(int iType, LPCWSTR lpstrSetting, int uidMessage, ...)
//
// DisplayCmdLineHelp()
//
+#if 0
void DisplayCmdLineHelp(HWND hwnd)
{
WCHAR szTitle[32] = { L'\0' };
@@ -276,7 +277,57 @@ void DisplayCmdLineHelp(HWND hwnd)
MessageBoxIndirect(&mbp);
//MsgBoxLng(MBINFO, IDS_MUI_CMDLINEHELP);
}
+#else
+INT_PTR CALLBACK CmdLineHelpProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
+{
+ UNUSED(lParam);
+
+ switch (umsg) {
+ case WM_INITDIALOG:
+ {
+ WCHAR szTitle[80] = { L'\0' };
+ WCHAR szText[2048] = { L'\0' };
+ GetLngString(IDS_MUI_APPTITLE, szTitle, COUNTOF(szTitle));
+ GetLngString(IDS_MUI_CMDLINEHELP, szText, COUNTOF(szText));
+ SetWindowText(hwnd, szTitle);
+ SetDlgItemText(hwnd, IDC_CMDLINEHELP, szText);
+ //SendMessage(hwnd, WM_NEXTDLGCTL, (WPARAM)IDC_CMDLINEHELP, TRUE);
+ }
+ break;
+
+ case WM_COMMAND:
+ switch (LOWORD(wParam)) {
+ case IDOK:
+ case IDCANCEL:
+ case IDYES:
+ case IDNO:
+ EndDialog(hwnd, LOWORD(wParam));
+ break;
+ }
+ return true;
+
+ default:
+ break;
+ }
+ return false;
+}
+
+INT_PTR DisplayCmdLineHelp(HWND hwnd)
+{
+ return ThemedDialogBoxParam(Globals.hLngResContainer, MAKEINTRESOURCE(IDD_MUI_CMDLINEHELP), hwnd, CmdLineHelpProc, (LPARAM)L"");
+
+ //if (!hwnd) {
+ // // text to std-out
+ // //RedirectIOToConsole();
+ // //fwprintf(stdout, L"\n!!! blahblub ???\n");
+ // //fflush(stdout);
+ // //SleepEx(5000,FALSE);
+ //}
+ //return(0);
+}
+
+#endif
//=============================================================================
//
diff --git a/src/Dialogs.h b/src/Dialogs.h
index 023a603a6..1db188421 100644
--- a/src/Dialogs.h
+++ b/src/Dialogs.h
@@ -19,7 +19,7 @@
#include "TypeDefs.h"
int MsgBoxLng(int iType, UINT uIdMsg, ...);
-void DisplayCmdLineHelp(HWND hwnd);
+INT_PTR DisplayCmdLineHelp(HWND hwnd);
bool GetDirectory(HWND hwndParent,int uiTitle,LPWSTR pszFolder,LPCWSTR pszBase,bool);
INT_PTR CALLBACK AboutDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam);
INT_PTR RunDlg(HWND hwnd,LPCWSTR lpstrDefault);
diff --git a/src/Helpers.h b/src/Helpers.h
index 742f1e293..ca351fffa 100644
--- a/src/Helpers.h
+++ b/src/Helpers.h
@@ -354,6 +354,9 @@ bool GetDoAnimateMinimize(VOID);
VOID MinimizeWndToTray(HWND hWnd);
VOID RestoreWndFromTray(HWND hWnd);
+// console helper from Print.cpp
+//void RedirectIOToConsole();
+
//==== StrCut methods ===================
CHAR* StrCutIA(CHAR* s,const CHAR* pattern);
diff --git a/src/Notepad3.rc b/src/Notepad3.rc
index b3fac607c..92501dc3f 100644
--- a/src/Notepad3.rc
+++ b/src/Notepad3.rc
@@ -44,7 +44,6 @@ END
#endif // APSTUDIO_INVOKED
-
/////////////////////////////////////////////////////////////////////////////
//
// Icon
@@ -68,15 +67,12 @@ IDB_PICK BITMAP "Pick.bmp"
IDB_ENCODING BITMAP "Encoding.bmp"
-
-
-
/////////////////////////////////////////////////////////////////////////////
// English (United States) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
-
+#pragma code_page(65001) // UTF-8
/////////////////////////////////////////////////////////////////////////////
//
diff --git a/src/Notepad3.ver b/src/Notepad3.ver
index 47f60aade..d81ee40ed 100644
--- a/src/Notepad3.ver
+++ b/src/Notepad3.ver
@@ -1,4 +1,4 @@
-/******************************************************************************
+/******************************************************************************
* *
* *
* Notepad3 *
diff --git a/src/Print.cpp b/src/Print.cpp
index 1a3dca5ab..cd7c15a5a 100644
--- a/src/Print.cpp
+++ b/src/Print.cpp
@@ -592,5 +592,50 @@ static void EditPrintInit()
}
}
+#if 0
+#include
+#include
+//#include
+//#include
+
+void RedirectIOToConsole()
+{
+ int hConHandle;
+ intptr_t lStdHandle;
+ CONSOLE_SCREEN_BUFFER_INFO coninfo;
+ FILE *fp;
+
+ // allocate a console for this app
+ AllocConsole();
+ // set the screen buffer to be big enough to let us scroll text
+ GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &coninfo);
+ coninfo.dwSize.Y = 500;
+ SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE), coninfo.dwSize);
+
+ // redirect unbuffered STDOUT to the console
+ lStdHandle = (intptr_t)GetStdHandle(STD_OUTPUT_HANDLE);
+ hConHandle = _open_osfhandle(lStdHandle, _O_TEXT);
+ fp = _fdopen(hConHandle, "w");
+ *stdout = *fp;
+ setvbuf(stdout, NULL, _IONBF, 0);
+
+ // redirect unbuffered STDIN to the console
+ lStdHandle = (intptr_t)GetStdHandle(STD_INPUT_HANDLE);
+ hConHandle = _open_osfhandle(lStdHandle, _O_TEXT);
+ fp = _fdopen(hConHandle, "r");
+ *stdin = *fp;
+ setvbuf(stdin, NULL, _IONBF, 0);
+
+ // redirect unbuffered STDERR to the console
+ lStdHandle = (intptr_t)GetStdHandle(STD_ERROR_HANDLE);
+ hConHandle = _open_osfhandle(lStdHandle, _O_TEXT);
+ fp = _fdopen(hConHandle, "w");
+ *stderr = *fp;
+ setvbuf(stderr, NULL, _IONBF, 0);
+
+ // make cout, wcout, cin, wcin, wcerr, cerr, wclog and clog point to console as well
+ std::ios::sync_with_stdio();
+}
+#endif
// End of Print.cpp
diff --git a/src/Version.h b/src/Version.h
index 7fb572840..8140b70c5 100644
Binary files a/src/Version.h and b/src/Version.h differ
diff --git a/src/VersionEx.h b/src/VersionEx.h
index a197ac474..ea08e2099 100644
--- a/src/VersionEx.h
+++ b/src/VersionEx.h
@@ -6,8 +6,8 @@
#define APPNAME "Notepad3"
#define VERSION_MAJOR 5
#define VERSION_MINOR 18
-#define VERSION_REV 1108
-#define VERSION_BUILD 1436
+#define VERSION_REV 1115
+#define VERSION_BUILD 1437
#define SCINTILLA_VER 412
#define ONIGMO_REGEX_VER 6.1.3
-#define VERSION_PATCH "Dev_Test_1"
+#define VERSION_PATCH "Dev_Test_2"