Skip to content

Commit

Permalink
Add "Rendering Technology" Settings menu to switch between GDI and Di…
Browse files Browse the repository at this point in the history
  • Loading branch information
zufuliu committed Jul 28, 2018
1 parent 4b8e693 commit b7ad639
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Edit.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ extern int iLineEndings[3];
extern BOOL bFixLineEndings;
extern BOOL bAutoStripBlanks;

extern int iRenderingTechnology;
// Default Codepage and Character Set
extern int iDefaultCodePage;
//extern int iDefaultCharSet;
Expand Down Expand Up @@ -82,6 +83,7 @@ HWND EditCreate(HWND hwndParent) {
g_hInstance,
NULL);

SendMessage(hwnd, SCI_SETTECHNOLOGY, iRenderingTechnology, 0);
SendMessage(hwnd, SCI_SETCODEPAGE, iDefaultCodePage, 0);
SendMessage(hwnd, SCI_SETEOLMODE, SC_EOL_CRLF, 0);
SendMessage(hwnd, SCI_SETPASTECONVERTENDINGS, 1, 0);
Expand Down
18 changes: 18 additions & 0 deletions src/Notepad2.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ int iEscFunction;
BOOL bAlwaysOnTop;
BOOL bMinimizeToTray;
BOOL bTransparentMode;
int iRenderingTechnology;
BOOL bShowToolbar;
BOOL bShowStatusbar;

Expand Down Expand Up @@ -1421,6 +1422,8 @@ LRESULT MsgCreate(HWND hwnd, WPARAM wParam, LPARAM lParam) {
hwndEdit = EditCreate(hwnd);
InitScintillaHandle(hwndEdit);

iRenderingTechnology = (int)SendMessage(hwndEdit, SCI_GETTECHNOLOGY, 0, 0);

SendMessage(hwndEdit, SCI_SETZOOM, iZoomLevel, 0);
// Tabs
SendMessage(hwndEdit, SCI_SETUSETABS, !bTabsAsSpaces, 0);
Expand Down Expand Up @@ -2249,6 +2252,9 @@ void MsgInitMenu(HWND hwnd, WPARAM wParam, LPARAM lParam) {
CheckCmd(hmenu, IDM_VIEW_TRANSPARENT, bTransparentMode && i);
EnableCmd(hmenu, IDM_VIEW_TRANSPARENT, i);

i = IDM_SET_RENDER_TECH_DEFAULT + iRenderingTechnology;
CheckMenuRadioItem(hmenu, IDM_SET_RENDER_TECH_DEFAULT, IDM_SET_RENDER_TECH_D2DDC, i, MF_BYCOMMAND);

CheckCmd(hmenu, IDM_VIEW_NOSAVERECENT, bSaveRecentFiles);
CheckCmd(hmenu, IDM_VIEW_NOSAVEFINDREPL, bSaveFindReplace);
CheckCmd(hmenu, IDM_VIEW_SAVEBEFORERUNNINGTOOLS, bSaveBeforeRunningTools);
Expand Down Expand Up @@ -4122,6 +4128,14 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) {
SetWindowTransparentMode(hwnd, bTransparentMode);
break;

case IDM_SET_RENDER_TECH_DEFAULT:
case IDM_SET_RENDER_TECH_D2D:
case IDM_SET_RENDER_TECH_D2DRETAIN:
case IDM_SET_RENDER_TECH_D2DDC:
SendMessage(hwndEdit, SCI_SETTECHNOLOGY, LOWORD(wParam) - IDM_SET_RENDER_TECH_DEFAULT, 0);
iRenderingTechnology = (int)SendMessage(hwndEdit, SCI_GETTECHNOLOGY, 0, 0);
break;

case IDM_VIEW_SHOWFILENAMEONLY:
iPathNameFormat = 0;
lstrcpy(szTitleExcerpt, L"");
Expand Down Expand Up @@ -5333,6 +5347,9 @@ void LoadSettings(void) {
bMinimizeToTray = IniSectionGetBool(pIniSection, L"MinimizeToTray", 0);
bTransparentMode = IniSectionGetBool(pIniSection, L"TransparentMode", 0);

iRenderingTechnology = IniSectionGetInt(pIniSection, L"RenderingTechnology", 0);
iRenderingTechnology = clamp_i(iRenderingTechnology, SC_TECHNOLOGY_DEFAULT, SC_TECHNOLOGY_DIRECTWRITEDC);

IniSectionGetString(pIniSection, L"ToolbarButtons", L"", tchToolbarButtons, COUNTOF(tchToolbarButtons));

bShowToolbar = IniSectionGetBool(pIniSection, L"ShowToolbar", 1);
Expand Down Expand Up @@ -5562,6 +5579,7 @@ void SaveSettings(BOOL bSaveSettingsNow) {
IniSectionSetBool(pIniSection, L"AlwaysOnTop", bAlwaysOnTop);
IniSectionSetBool(pIniSection, L"MinimizeToTray", bMinimizeToTray);
IniSectionSetBool(pIniSection, L"TransparentMode", bTransparentMode);
IniSectionSetInt(pIniSection, L"RenderingTechnology", iRenderingTechnology);
Toolbar_GetButtons(hwndToolbar, IDT_FILE_NEW, tchToolbarButtons, COUNTOF(tchToolbarButtons));
IniSectionSetString(pIniSection, L"ToolbarButtons", tchToolbarButtons);
IniSectionSetBool(pIniSection, L"ShowToolbar", bShowToolbar);
Expand Down
7 changes: 7 additions & 0 deletions src/Notepad2.rc
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,13 @@ BEGIN
MENUITEM "&Always On Top\tAlt+Shift+T", IDM_VIEW_ALWAYSONTOP
MENUITEM "Minimi&ze to Tray", IDM_VIEW_MINTOTRAY
MENUITEM "Transparent &Mode\tCtrl+0", IDM_VIEW_TRANSPARENT
POPUP "Rendering Technology"
BEGIN
MENUITEM "Default GDI", IDM_SET_RENDER_TECH_DEFAULT
MENUITEM "Direct2D", IDM_SET_RENDER_TECH_D2D
MENUITEM "Direct2D Retain", IDM_SET_RENDER_TECH_D2DRETAIN
MENUITEM "Direct2D GDI DC", IDM_SET_RENDER_TECH_D2DDC
END
MENUITEM SEPARATOR
MENUITEM "Single &File Instance", IDM_VIEW_SINGLEFILEINSTANCE
MENUITEM "File &Change Notification...\tAlt+F5", IDM_VIEW_CHANGENOTIFY
Expand Down
5 changes: 5 additions & 0 deletions src/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,11 @@
#define IDM_VIEW_AUTOCWITHDOCWORDS 40466
#define IDM_VIEW_FOLD_CURRENT 40467 // Alt+C
#define IDM_VIEW_SHOWCALLTIPS 40047
#define IDM_SET_RENDER_TECH_DEFAULT 40048
#define IDM_SET_RENDER_TECH_D2D 40049
#define IDM_SET_RENDER_TECH_D2DRETAIN 40050
#define IDM_SET_RENDER_TECH_D2DDC 40051

#define IDM_LANG_DEFAULT 41000
#define IDM_LANG_NULL 41060

Expand Down

1 comment on commit b7ad639

@zufuliu
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.