mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-07-30 09:14:39 +02:00
[NEW_FEATURE] Make Notepad++ DPI-aware.
git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@1172 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
parent
35c160ddff
commit
7edbd55348
@ -253,7 +253,8 @@ LRESULT Notepad_plus::init(HWND hwnd)
|
|||||||
|
|
||||||
int tabBarStatus = nppGUI._tabStatus;
|
int tabBarStatus = nppGUI._tabStatus;
|
||||||
_toReduceTabBar = ((tabBarStatus & TAB_REDUCE) != 0);
|
_toReduceTabBar = ((tabBarStatus & TAB_REDUCE) != 0);
|
||||||
_docTabIconList.create(_toReduceTabBar?13:20, _pPublicInterface->getHinst(), docTabIconIDs, sizeof(docTabIconIDs)/sizeof(int));
|
int iconDpiDynamicalSize = NppParameters::getInstance()->_dpiManager.scaleY(_toReduceTabBar?13:20);
|
||||||
|
_docTabIconList.create(iconDpiDynamicalSize, _pPublicInterface->getHinst(), docTabIconIDs, sizeof(docTabIconIDs)/sizeof(int));
|
||||||
|
|
||||||
_mainDocTab.init(_pPublicInterface->getHinst(), hwnd, &_mainEditView, &_docTabIconList);
|
_mainDocTab.init(_pPublicInterface->getHinst(), hwnd, &_mainEditView, &_docTabIconList);
|
||||||
_subDocTab.init(_pPublicInterface->getHinst(), hwnd, &_subEditView, &_docTabIconList);
|
_subDocTab.init(_pPublicInterface->getHinst(), hwnd, &_subEditView, &_docTabIconList);
|
||||||
@ -345,8 +346,9 @@ LRESULT Notepad_plus::init(HWND hwnd)
|
|||||||
::SendMessage(_mainDocTab.getHSelf(), WM_SETFONT, (WPARAM)hf, MAKELPARAM(TRUE, 0));
|
::SendMessage(_mainDocTab.getHSelf(), WM_SETFONT, (WPARAM)hf, MAKELPARAM(TRUE, 0));
|
||||||
::SendMessage(_subDocTab.getHSelf(), WM_SETFONT, (WPARAM)hf, MAKELPARAM(TRUE, 0));
|
::SendMessage(_subDocTab.getHSelf(), WM_SETFONT, (WPARAM)hf, MAKELPARAM(TRUE, 0));
|
||||||
}
|
}
|
||||||
TabCtrl_SetItemSize(_mainDocTab.getHSelf(), 45, 20);
|
int tabDpiDynamicalHeight = NppParameters::getInstance()->_dpiManager.scaleY(20);
|
||||||
TabCtrl_SetItemSize(_subDocTab.getHSelf(), 45, 20);
|
TabCtrl_SetItemSize(_mainDocTab.getHSelf(), 45, tabDpiDynamicalHeight);
|
||||||
|
TabCtrl_SetItemSize(_subDocTab.getHSelf(), 45, tabDpiDynamicalHeight);
|
||||||
}
|
}
|
||||||
_mainDocTab.display();
|
_mainDocTab.display();
|
||||||
|
|
||||||
|
@ -34,6 +34,8 @@
|
|||||||
#include "VerticalFileSwitcher.h"
|
#include "VerticalFileSwitcher.h"
|
||||||
#include "documentMap.h"
|
#include "documentMap.h"
|
||||||
|
|
||||||
|
#define WM_DPICHANGED 0x02E0
|
||||||
|
|
||||||
struct SortTaskListPred
|
struct SortTaskListPred
|
||||||
{
|
{
|
||||||
DocTabView *_views[2];
|
DocTabView *_views[2];
|
||||||
@ -1966,6 +1968,13 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case WM_DPICHANGED:
|
||||||
|
{
|
||||||
|
//printInt(LOWORD(wParam));
|
||||||
|
//printInt(HIWORD(wParam));
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
if (Message == WDN_NOTIFY)
|
if (Message == WDN_NOTIFY)
|
||||||
|
@ -1256,13 +1256,13 @@ void Notepad_plus::command(int id)
|
|||||||
_toReduceTabBar = !_toReduceTabBar;
|
_toReduceTabBar = !_toReduceTabBar;
|
||||||
|
|
||||||
//Resize the icon
|
//Resize the icon
|
||||||
int iconSize = _toReduceTabBar?12:18;
|
int iconDpiDynamicalSize = NppParameters::getInstance()->_dpiManager.scaleY(_toReduceTabBar?12:18);
|
||||||
|
|
||||||
//Resize the tab height
|
//Resize the tab height
|
||||||
int tabHeight = _toReduceTabBar?20:25;
|
int tabDpiDynamicalHeight = NppParameters::getInstance()->_dpiManager.scaleY(_toReduceTabBar?20:25);
|
||||||
TabCtrl_SetItemSize(_mainDocTab.getHSelf(), 45, tabHeight);
|
TabCtrl_SetItemSize(_mainDocTab.getHSelf(), 45, tabDpiDynamicalHeight);
|
||||||
TabCtrl_SetItemSize(_subDocTab.getHSelf(), 45, tabHeight);
|
TabCtrl_SetItemSize(_subDocTab.getHSelf(), 45, tabDpiDynamicalHeight);
|
||||||
_docTabIconList.setIconSize(iconSize);
|
_docTabIconList.setIconSize(iconDpiDynamicalSize);
|
||||||
|
|
||||||
//change the font
|
//change the font
|
||||||
int stockedFont = _toReduceTabBar?DEFAULT_GUI_FONT:SYSTEM_FONT;
|
int stockedFont = _toReduceTabBar?DEFAULT_GUI_FONT:SYSTEM_FONT;
|
||||||
@ -1309,10 +1309,10 @@ void Notepad_plus::command(int id)
|
|||||||
TabBarPlus::setDrawTabCloseButton(!TabBarPlus::drawTabCloseButton());
|
TabBarPlus::setDrawTabCloseButton(!TabBarPlus::drawTabCloseButton());
|
||||||
|
|
||||||
// This part is just for updating (redraw) the tabs
|
// This part is just for updating (redraw) the tabs
|
||||||
{
|
{
|
||||||
int tabHeight = TabBarPlus::drawTabCloseButton()?21:20;
|
int tabDpiDynamicalHeight = NppParameters::getInstance()->_dpiManager.scaleY(TabBarPlus::drawTabCloseButton()?21:20);
|
||||||
TabCtrl_SetItemSize(_mainDocTab.getHSelf(), 45, tabHeight);
|
TabCtrl_SetItemSize(_mainDocTab.getHSelf(), 45, tabDpiDynamicalHeight);
|
||||||
TabCtrl_SetItemSize(_subDocTab.getHSelf(), 45, tabHeight);
|
TabCtrl_SetItemSize(_subDocTab.getHSelf(), 45, tabDpiDynamicalHeight);
|
||||||
}
|
}
|
||||||
::SendMessage(_pPublicInterface->getHSelf(), WM_SIZE, 0, 0);
|
::SendMessage(_pPublicInterface->getHSelf(), WM_SIZE, 0, 0);
|
||||||
break;
|
break;
|
||||||
|
@ -61,9 +61,14 @@
|
|||||||
#include "shortcut.h"
|
#include "shortcut.h"
|
||||||
#endif //SHORTCUTS_H
|
#endif //SHORTCUTS_H
|
||||||
|
|
||||||
#ifndef CONTEXTMENU
|
#ifndef CONTEXTMENU_H
|
||||||
#include "ContextMenu.h"
|
#include "ContextMenu.h"
|
||||||
#endif //CONTEXTMENU
|
#endif //CONTEXTMENU_H
|
||||||
|
|
||||||
|
#ifndef DPIMANAGER_H
|
||||||
|
#include "dpiManager.h"
|
||||||
|
#endif //DPIMANAGER_H
|
||||||
|
|
||||||
|
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
|
|
||||||
@ -1521,6 +1526,8 @@ public:
|
|||||||
return _userPath;
|
return _userPath;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
DPIManager _dpiManager;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
NppParameters();
|
NppParameters();
|
||||||
~NppParameters();
|
~NppParameters();
|
||||||
|
@ -26,8 +26,8 @@
|
|||||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
|
||||||
|
|
||||||
#ifndef CONTEXTMENU
|
#ifndef CONTEXTMENU_H
|
||||||
#define CONTEXTMENU
|
#define CONTEXTMENU_H
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
@ -73,4 +73,4 @@ private:
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //CONTEXTMENU
|
#endif //CONTEXTMENU_H
|
||||||
|
@ -847,7 +847,7 @@ void DockingCont::drawTabItem(DRAWITEMSTRUCT *pDrawItemStruct)
|
|||||||
::DeleteObject((HGDIOBJ)hBrush);
|
::DeleteObject((HGDIOBJ)hBrush);
|
||||||
|
|
||||||
// draw orange bar
|
// draw orange bar
|
||||||
if ((_bDrawOgLine == TRUE) && (isSelected))
|
if (_bDrawOgLine && isSelected)
|
||||||
{
|
{
|
||||||
RECT barRect = rc;
|
RECT barRect = rc;
|
||||||
barRect.top += rc.bottom - 4;
|
barRect.top += rc.bottom - 4;
|
||||||
@ -871,16 +871,25 @@ void DockingCont::drawTabItem(DRAWITEMSTRUCT *pDrawItemStruct)
|
|||||||
RECT & imageRect = info.rcImage;
|
RECT & imageRect = info.rcImage;
|
||||||
|
|
||||||
ImageList_GetImageInfo(hImageList, iPosImage, &info);
|
ImageList_GetImageInfo(hImageList, iPosImage, &info);
|
||||||
ImageList_Draw(hImageList, iPosImage, hDc, rc.left + 3, 2, ILD_NORMAL);
|
int dpiDynamicalSetting = NppParameters::getInstance()->_dpiManager.getDPIX();
|
||||||
|
int iconDpiDynamicalY = 2; // By default, dpi == 96
|
||||||
|
if (dpiDynamicalSetting == 120)
|
||||||
|
iconDpiDynamicalY = 5;
|
||||||
|
else if (dpiDynamicalSetting == 144)
|
||||||
|
iconDpiDynamicalY = 11;
|
||||||
|
else if (dpiDynamicalSetting == 192)
|
||||||
|
iconDpiDynamicalY = 17;
|
||||||
|
|
||||||
if (isSelected == true)
|
ImageList_Draw(hImageList, iPosImage, hDc, rc.left + 3, iconDpiDynamicalY, ILD_NORMAL);
|
||||||
|
|
||||||
|
if (isSelected)
|
||||||
{
|
{
|
||||||
rc.left += imageRect.right - imageRect.left + 5;
|
rc.left += imageRect.right - imageRect.left + 5;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isSelected == true)
|
if (isSelected)
|
||||||
{
|
{
|
||||||
COLORREF _unselectedColor = RGB(0, 0, 0);
|
COLORREF _unselectedColor = RGB(0, 0, 0);
|
||||||
::SetTextColor(hDc, _unselectedColor);
|
::SetTextColor(hDc, _unselectedColor);
|
||||||
@ -925,7 +934,9 @@ BOOL CALLBACK DockingCont::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPara
|
|||||||
_hDefaultTabProc = reinterpret_cast<WNDPROC>(::SetWindowLongPtr(_hContTab, GWLP_WNDPROC, (LONG_PTR)wndTabProc));
|
_hDefaultTabProc = reinterpret_cast<WNDPROC>(::SetWindowLongPtr(_hContTab, GWLP_WNDPROC, (LONG_PTR)wndTabProc));
|
||||||
|
|
||||||
// set min tab width
|
// set min tab width
|
||||||
::SendMessage(_hContTab, TCM_SETMINTABWIDTH, 0, (LPARAM)MIN_TABWIDTH);
|
int tabDpiDynamicalMinWidth = NppParameters::getInstance()->_dpiManager.scaleY(24);
|
||||||
|
::SendMessage(_hContTab, TCM_SETMINTABWIDTH, 0, tabDpiDynamicalMinWidth);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case WM_NCCALCSIZE:
|
case WM_NCCALCSIZE:
|
||||||
@ -1013,6 +1024,7 @@ void DockingCont::onSize()
|
|||||||
if (iItemCnt >= 1)
|
if (iItemCnt >= 1)
|
||||||
{
|
{
|
||||||
// resize to docked window
|
// resize to docked window
|
||||||
|
int tabDpiDynamicalHeight = NppParameters::getInstance()->_dpiManager.scaleY(24);
|
||||||
if (_isFloating == false)
|
if (_isFloating == false)
|
||||||
{
|
{
|
||||||
// draw caption
|
// draw caption
|
||||||
@ -1034,9 +1046,9 @@ void DockingCont::onSize()
|
|||||||
// resize tab and plugin control if tabs exceeds one
|
// resize tab and plugin control if tabs exceeds one
|
||||||
// resize tab
|
// resize tab
|
||||||
rcTemp = rc;
|
rcTemp = rc;
|
||||||
rcTemp.top = (rcTemp.bottom + rcTemp.top) - (HIGH_TAB+CAPTION_GAP);
|
rcTemp.top = (rcTemp.bottom + rcTemp.top) - (tabDpiDynamicalHeight + CAPTION_GAP);
|
||||||
rcTemp.bottom = HIGH_TAB;
|
rcTemp.bottom = tabDpiDynamicalHeight;
|
||||||
iTabOff = HIGH_TAB;
|
iTabOff = tabDpiDynamicalHeight;
|
||||||
|
|
||||||
::SetWindowPos(_hContTab, NULL,
|
::SetWindowPos(_hContTab, NULL,
|
||||||
rcTemp.left, rcTemp.top, rcTemp.right, rcTemp.bottom,
|
rcTemp.left, rcTemp.top, rcTemp.right, rcTemp.bottom,
|
||||||
@ -1079,8 +1091,8 @@ void DockingCont::onSize()
|
|||||||
{
|
{
|
||||||
// resize tab if size of elements exceeds one
|
// resize tab if size of elements exceeds one
|
||||||
rcTemp = rc;
|
rcTemp = rc;
|
||||||
rcTemp.top = rcTemp.bottom - (HIGH_TAB+CAPTION_GAP);
|
rcTemp.top = rcTemp.bottom - (tabDpiDynamicalHeight + CAPTION_GAP);
|
||||||
rcTemp.bottom = HIGH_TAB;
|
rcTemp.bottom = tabDpiDynamicalHeight;
|
||||||
|
|
||||||
::SetWindowPos(_hContTab, NULL,
|
::SetWindowPos(_hContTab, NULL,
|
||||||
rcTemp.left, rcTemp.top, rcTemp.right, rcTemp.bottom,
|
rcTemp.left, rcTemp.top, rcTemp.right, rcTemp.bottom,
|
||||||
@ -1089,7 +1101,7 @@ void DockingCont::onSize()
|
|||||||
|
|
||||||
// resize client area for plugin
|
// resize client area for plugin
|
||||||
rcTemp = rc;
|
rcTemp = rc;
|
||||||
rcTemp.bottom -= ((iItemCnt == 1)?0:HIGH_TAB);
|
rcTemp.bottom -= ((iItemCnt == 1)?0:tabDpiDynamicalHeight);
|
||||||
|
|
||||||
::SetWindowPos(::GetDlgItem(_hSelf, IDC_CLIENT_TAB), NULL,
|
::SetWindowPos(::GetDlgItem(_hSelf, IDC_CLIENT_TAB), NULL,
|
||||||
rcTemp.left, rcTemp.top, rcTemp.right, rcTemp.bottom,
|
rcTemp.left, rcTemp.top, rcTemp.right, rcTemp.bottom,
|
||||||
@ -1111,7 +1123,7 @@ void DockingCont::onSize()
|
|||||||
::SetWindowPos(((tTbData*)tcItem.lParam)->hClient, NULL,
|
::SetWindowPos(((tTbData*)tcItem.lParam)->hClient, NULL,
|
||||||
0, 0, rcTemp.right, rcTemp.bottom,
|
0, 0, rcTemp.right, rcTemp.bottom,
|
||||||
SWP_NOZORDER);
|
SWP_NOZORDER);
|
||||||
//::SendMessage(((tTbData*)tcItem.lParam)->hClient, WM_SIZE, 0, MAKELONG(rcTemp.right, rcTemp.bottom));
|
|
||||||
// Notify switch in
|
// Notify switch in
|
||||||
NMHDR nmhdr;
|
NMHDR nmhdr;
|
||||||
nmhdr.code = DMN_FLOATDROPPED;
|
nmhdr.code = DMN_FLOATDROPPED;
|
||||||
|
@ -37,6 +37,7 @@
|
|||||||
#include "Docking.h"
|
#include "Docking.h"
|
||||||
#endif //DOCKING_H
|
#endif //DOCKING_H
|
||||||
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
|
||||||
@ -46,8 +47,6 @@ using namespace std;
|
|||||||
#define CHILD_STYLES (WS_CHILD)
|
#define CHILD_STYLES (WS_CHILD)
|
||||||
#define CHILD_EXSTYLES (0x00000000L)
|
#define CHILD_EXSTYLES (0x00000000L)
|
||||||
|
|
||||||
#define MIN_TABWIDTH 24
|
|
||||||
|
|
||||||
|
|
||||||
enum eMousePos {
|
enum eMousePos {
|
||||||
posOutside,
|
posOutside,
|
||||||
@ -57,7 +56,6 @@ enum eMousePos {
|
|||||||
|
|
||||||
// some fix modify values for GUI
|
// some fix modify values for GUI
|
||||||
#define HIGH_CAPTION 18
|
#define HIGH_CAPTION 18
|
||||||
#define HIGH_TAB 20
|
|
||||||
#define CAPTION_GAP 2
|
#define CAPTION_GAP 2
|
||||||
#define CLOSEBTN_POS_LEFT 3
|
#define CLOSEBTN_POS_LEFT 3
|
||||||
#define CLOSEBTN_POS_TOP 3
|
#define CLOSEBTN_POS_TOP 3
|
||||||
@ -226,7 +224,6 @@ private:
|
|||||||
// for moving and reordering
|
// for moving and reordering
|
||||||
UINT _prevItem;
|
UINT _prevItem;
|
||||||
BOOL _beginDrag;
|
BOOL _beginDrag;
|
||||||
HIMAGELIST _hImageList;
|
|
||||||
|
|
||||||
// Is tooltip
|
// Is tooltip
|
||||||
BOOL _bTabTTHover;
|
BOOL _bTabTTHover;
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
#include "DockingSplitter.h"
|
#include "DockingSplitter.h"
|
||||||
#include "DockingCont.h"
|
#include "DockingCont.h"
|
||||||
#include "Gripper.h"
|
#include "Gripper.h"
|
||||||
|
#include "parameters.h"
|
||||||
|
|
||||||
|
|
||||||
BOOL DockingManager::_isRegistered = FALSE;
|
BOOL DockingManager::_isRegistered = FALSE;
|
||||||
@ -560,7 +561,8 @@ void DockingManager::createDockableDlg(tTbData data, int iCont, bool isVisible)
|
|||||||
// create image list if not exist
|
// create image list if not exist
|
||||||
if (_hImageList == NULL)
|
if (_hImageList == NULL)
|
||||||
{
|
{
|
||||||
_hImageList = ::ImageList_Create(14,14,ILC_COLOR8, 0, 0);
|
int iconDpiDynamicalSize = NppParameters::getInstance()->_dpiManager.scaleY(14);
|
||||||
|
_hImageList = ::ImageList_Create(iconDpiDynamicalSize,iconDpiDynamicalSize,ILC_COLOR8, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// add icon
|
// add icon
|
||||||
|
@ -12,6 +12,7 @@ Modified by Don HO <don.h@free.fr>
|
|||||||
|
|
||||||
#include "precompiledHeaders.h"
|
#include "precompiledHeaders.h"
|
||||||
#include "babygrid.h"
|
#include "babygrid.h"
|
||||||
|
#include "Parameters.h"
|
||||||
|
|
||||||
#define MAX_GRIDS 20
|
#define MAX_GRIDS 20
|
||||||
|
|
||||||
@ -2961,12 +2962,13 @@ LRESULT CALLBACK GridProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|||||||
GetWindowPlacement(hWnd,&wp);
|
GetWindowPlacement(hWnd,&wp);
|
||||||
crect=wp.rcNormalPosition;
|
crect=wp.rcNormalPosition;
|
||||||
crect.bottom=intout;
|
crect.bottom=intout;
|
||||||
|
//crect.bottom = NppParameters::getInstance()->_dpiManager.ScaleY(intout);
|
||||||
crect.right=savewidth;
|
crect.right=savewidth;
|
||||||
BGHS[SI].SIZING = TRUE;
|
BGHS[SI].SIZING = TRUE;
|
||||||
|
|
||||||
BGHS[SI].wannabeheight = HIWORD(lParam);
|
BGHS[SI].wannabeheight = HIWORD(lParam);
|
||||||
BGHS[SI].wannabewidth = LOWORD(lParam);
|
BGHS[SI].wannabewidth = LOWORD(lParam);
|
||||||
|
//NppParameters::getInstance()->_dpiManager.ScaleRect(&crect);
|
||||||
MoveWindow(hWnd,crect.left,crect.top,crect.right,crect.bottom,TRUE);
|
MoveWindow(hWnd,crect.left,crect.top,crect.right,crect.bottom,TRUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
#include "ShortcutMapper.h"
|
#include "ShortcutMapper.h"
|
||||||
#include "Notepad_plus.h"
|
#include "Notepad_plus.h"
|
||||||
|
|
||||||
|
|
||||||
void ShortcutMapper::initTabs() {
|
void ShortcutMapper::initTabs() {
|
||||||
HWND hTab = _hTabCtrl = ::GetDlgItem(_hSelf, IDC_BABYGRID_TABBAR);
|
HWND hTab = _hTabCtrl = ::GetDlgItem(_hSelf, IDC_BABYGRID_TABBAR);
|
||||||
TCITEM tie;
|
TCITEM tie;
|
||||||
@ -59,7 +60,7 @@ void ShortcutMapper::initBabyGrid() {
|
|||||||
getClientRect(rect);
|
getClientRect(rect);
|
||||||
|
|
||||||
_babygrid.init(_hInst, _hSelf, IDD_BABYGRID_ID1);
|
_babygrid.init(_hInst, _hSelf, IDD_BABYGRID_ID1);
|
||||||
//_babygrid.reSizeTo(rect);
|
|
||||||
_babygrid.reSizeToWH(rect);
|
_babygrid.reSizeToWH(rect);
|
||||||
_babygrid.hideCursor();
|
_babygrid.hideCursor();
|
||||||
_babygrid.makeColAutoWidth();
|
_babygrid.makeColAutoWidth();
|
||||||
|
@ -41,9 +41,9 @@
|
|||||||
#include "shortcut.h"
|
#include "shortcut.h"
|
||||||
#endif// SHORTCUTS_H
|
#endif// SHORTCUTS_H
|
||||||
|
|
||||||
#ifndef CONTEXTMENU
|
#ifndef CONTEXTMENU_H
|
||||||
#include "ContextMenu.h"
|
#include "ContextMenu.h"
|
||||||
#endif// CONTEXTMENU
|
#endif// CONTEXTMENU_H
|
||||||
|
|
||||||
enum GridState {STATE_MENU, STATE_MACRO, STATE_USER, STATE_PLUGIN, STATE_SCINTILLA};
|
enum GridState {STATE_MENU, STATE_MACRO, STATE_USER, STATE_PLUGIN, STATE_SCINTILLA};
|
||||||
|
|
||||||
|
@ -28,11 +28,7 @@
|
|||||||
|
|
||||||
#include "precompiledHeaders.h"
|
#include "precompiledHeaders.h"
|
||||||
#include "TabBar.h"
|
#include "TabBar.h"
|
||||||
|
#include "Parameters.h"
|
||||||
const COLORREF blue = RGB(0, 0, 0xFF);
|
|
||||||
const COLORREF black = RGB(0, 0, 0);
|
|
||||||
const COLORREF white = RGB(0xFF, 0xFF, 0xFF);
|
|
||||||
const COLORREF grey = RGB(128, 128, 128);
|
|
||||||
|
|
||||||
#define IDC_DRAG_TAB 1404
|
#define IDC_DRAG_TAB 1404
|
||||||
#define IDC_DRAG_INTERDIT_TAB 1405
|
#define IDC_DRAG_INTERDIT_TAB 1405
|
||||||
@ -734,8 +730,10 @@ void TabBarPlus::drawItem(DRAWITEMSTRUCT *pDrawItemStruct)
|
|||||||
else
|
else
|
||||||
rect.right = closeButtonRect.left;
|
rect.right = closeButtonRect.left;
|
||||||
|
|
||||||
|
int bmDpiDynamicalWidth = NppParameters::getInstance()->_dpiManager.scaleX(bmp.bmWidth);
|
||||||
|
int bmDpiDynamicalHeight = NppParameters::getInstance()->_dpiManager.scaleY(bmp.bmHeight);
|
||||||
::SelectObject(hdcMemory, hBmp);
|
::SelectObject(hdcMemory, hBmp);
|
||||||
::BitBlt(hDC, closeButtonRect.left, closeButtonRect.top, bmp.bmWidth, bmp.bmHeight, hdcMemory, 0, 0, SRCCOPY);
|
::BitBlt(hDC, closeButtonRect.left, closeButtonRect.top, bmDpiDynamicalWidth, bmDpiDynamicalHeight, hdcMemory, 0, 0, SRCCOPY);
|
||||||
::DeleteDC(hdcMemory);
|
::DeleteDC(hdcMemory);
|
||||||
::DeleteObject(hBmp);
|
::DeleteObject(hBmp);
|
||||||
}
|
}
|
||||||
@ -941,6 +939,7 @@ void TabBarPlus::exchangeItemData(POINT point)
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CloseButtonZone::isHit(int x, int y, const RECT & testZone) const
|
bool CloseButtonZone::isHit(int x, int y, const RECT & testZone) const
|
||||||
{
|
{
|
||||||
if (((x + _width + _fromRight) < testZone.right) || (x > (testZone.right - _fromRight)))
|
if (((x + _width + _fromRight) < testZone.right) || (x > (testZone.right - _fromRight)))
|
||||||
|
@ -108,7 +108,7 @@ bool ToolBar::init( HINSTANCE hInst, HWND hPere, toolBarStatusType type,
|
|||||||
{
|
{
|
||||||
Window::init(hInst, hPere);
|
Window::init(hInst, hPere);
|
||||||
_state = type;
|
_state = type;
|
||||||
int iconSize = (_state == TB_LARGE?32:16);
|
int iconSize = NppParameters::getInstance()->_dpiManager.scaleX(_state == TB_LARGE?32:16);
|
||||||
|
|
||||||
_toolBarIcons.init(buttonUnitArray, arraySize);
|
_toolBarIcons.init(buttonUnitArray, arraySize);
|
||||||
_toolBarIcons.create(_hInst, iconSize);
|
_toolBarIcons.create(_hInst, iconSize);
|
||||||
@ -202,10 +202,46 @@ int ToolBar::getHeight() const {
|
|||||||
DWORD size = (DWORD)SendMessage(_hSelf, TB_GETBUTTONSIZE, 0, 0);
|
DWORD size = (DWORD)SendMessage(_hSelf, TB_GETBUTTONSIZE, 0, 0);
|
||||||
DWORD padding = (DWORD)SendMessage(_hSelf, TB_GETPADDING, 0,0);
|
DWORD padding = (DWORD)SendMessage(_hSelf, TB_GETPADDING, 0,0);
|
||||||
int totalHeight = HIWORD(size) + HIWORD(padding);
|
int totalHeight = HIWORD(size) + HIWORD(padding);
|
||||||
|
|
||||||
return totalHeight;
|
return totalHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ToolBar::reduce()
|
||||||
|
{
|
||||||
|
if (_state == TB_SMALL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
int iconDpiDynamicalSize = NppParameters::getInstance()->_dpiManager.scaleX(16);
|
||||||
|
_toolBarIcons.resizeIcon(iconDpiDynamicalSize);
|
||||||
|
bool recreate = (_state == TB_STANDARD);
|
||||||
|
setState(TB_SMALL);
|
||||||
|
reset(recreate); //recreate toolbar if std icons were used
|
||||||
|
Window::redraw();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ToolBar::enlarge()
|
||||||
|
{
|
||||||
|
if (_state == TB_LARGE)
|
||||||
|
return;
|
||||||
|
|
||||||
|
int iconDpiDynamicalSize = NppParameters::getInstance()->_dpiManager.scaleX(32);
|
||||||
|
_toolBarIcons.resizeIcon(iconDpiDynamicalSize);
|
||||||
|
bool recreate = (_state == TB_STANDARD);
|
||||||
|
setState(TB_LARGE);
|
||||||
|
reset(recreate); //recreate toolbar if std icons were used
|
||||||
|
Window::redraw();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ToolBar::setToUglyIcons()
|
||||||
|
{
|
||||||
|
if (_state == TB_STANDARD)
|
||||||
|
return;
|
||||||
|
bool recreate = true;
|
||||||
|
setState(TB_STANDARD);
|
||||||
|
reset(recreate); //must recreate toolbar if setting to internal bitmaps
|
||||||
|
Window::redraw();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void ToolBar::reset(bool create)
|
void ToolBar::reset(bool create)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -253,14 +289,22 @@ void ToolBar::reset(bool create)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
//Else set the internal imagelist with standard bitmaps
|
//Else set the internal imagelist with standard bitmaps
|
||||||
TBADDBITMAP addbmp = {_hInst, 0};
|
int iconDpiDynamicalSize = NppParameters::getInstance()->_dpiManager.scaleX(16);;
|
||||||
|
::SendMessage(_hSelf, TB_SETBITMAPSIZE, 0, MAKELPARAM(iconDpiDynamicalSize, iconDpiDynamicalSize));
|
||||||
|
|
||||||
|
//TBADDBITMAP addbmp = {_hInst, 0};
|
||||||
|
TBADDBITMAP addbmp = {0, 0};
|
||||||
TBADDBITMAP addbmpdyn = {0, 0};
|
TBADDBITMAP addbmpdyn = {0, 0};
|
||||||
for (size_t i = 0 ; i < _nrButtons ; ++i)
|
for (size_t i = 0 ; i < _nrButtons ; ++i)
|
||||||
{
|
{
|
||||||
addbmp.nID = _toolBarIcons.getStdIconAt(i);
|
HBITMAP hBmp = (HBITMAP)::LoadImage(_hInst, MAKEINTRESOURCE(_toolBarIcons.getStdIconAt(i)), IMAGE_BITMAP, iconDpiDynamicalSize, iconDpiDynamicalSize, LR_LOADMAP3DCOLORS | LR_LOADTRANSPARENT);
|
||||||
|
addbmp.nID = (UINT_PTR)hBmp;
|
||||||
|
|
||||||
|
//addbmp.nID = _toolBarIcons.getStdIconAt(i);
|
||||||
::SendMessage(_hSelf, TB_ADDBITMAP, 1, (LPARAM)&addbmp);
|
::SendMessage(_hSelf, TB_ADDBITMAP, 1, (LPARAM)&addbmp);
|
||||||
}
|
}
|
||||||
if (_nrDynButtons > 0) {
|
if (_nrDynButtons > 0)
|
||||||
|
{
|
||||||
for (size_t j = 0; j < _nrDynButtons; ++j)
|
for (size_t j = 0; j < _nrDynButtons; ++j)
|
||||||
{
|
{
|
||||||
addbmpdyn.nID = (UINT_PTR)_vDynBtnReg.at(j).hBmp;
|
addbmpdyn.nID = (UINT_PTR)_vDynBtnReg.at(j).hBmp;
|
||||||
@ -284,7 +328,7 @@ void ToolBar::reset(bool create)
|
|||||||
_rbBand.hwndChild = getHSelf();
|
_rbBand.hwndChild = getHSelf();
|
||||||
_rbBand.cxMinChild = 0;
|
_rbBand.cxMinChild = 0;
|
||||||
_rbBand.cyIntegral = 1;
|
_rbBand.cyIntegral = 1;
|
||||||
_rbBand.cyMinChild = _rbBand.cyMaxChild = getHeight();
|
_rbBand.cyMinChild = _rbBand.cyMaxChild = getHeight();
|
||||||
_rbBand.cxIdeal = getWidth();
|
_rbBand.cxIdeal = getWidth();
|
||||||
|
|
||||||
_pRebar->reNew(REBAR_BAR_TOOLBAR, &_rbBand);
|
_pRebar->reNew(REBAR_BAR_TOOLBAR, &_rbBand);
|
||||||
|
@ -85,34 +85,9 @@ public :
|
|||||||
int getWidth() const;
|
int getWidth() const;
|
||||||
int getHeight() const;
|
int getHeight() const;
|
||||||
|
|
||||||
void reduce() {
|
void reduce();
|
||||||
if (_state == TB_SMALL)
|
void enlarge();
|
||||||
return;
|
void setToUglyIcons();
|
||||||
|
|
||||||
_toolBarIcons.resizeIcon(16);
|
|
||||||
bool recreate = (_state == TB_STANDARD);
|
|
||||||
setState(TB_SMALL);
|
|
||||||
reset(recreate); //recreate toolbar if std icons were used
|
|
||||||
Window::redraw();
|
|
||||||
};
|
|
||||||
void enlarge() {
|
|
||||||
if (_state == TB_LARGE)
|
|
||||||
return;
|
|
||||||
|
|
||||||
_toolBarIcons.resizeIcon(32);
|
|
||||||
bool recreate = (_state == TB_STANDARD);
|
|
||||||
setState(TB_LARGE);
|
|
||||||
reset(recreate); //recreate toolbar if std icons were used
|
|
||||||
Window::redraw();
|
|
||||||
};
|
|
||||||
void setToUglyIcons() {
|
|
||||||
if (_state == TB_STANDARD)
|
|
||||||
return;
|
|
||||||
bool recreate = true;
|
|
||||||
setState(TB_STANDARD);
|
|
||||||
reset(recreate); //must recreate toolbar if setting to internal bitmaps
|
|
||||||
Window::redraw();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool getCheckState(int ID2Check) const {
|
bool getCheckState(int ID2Check) const {
|
||||||
return bool(::SendMessage(_hSelf, TB_GETSTATE, (WPARAM)ID2Check, 0) & TBSTATE_CHECKED);
|
return bool(::SendMessage(_hSelf, TB_GETSTATE, (WPARAM)ID2Check, 0) & TBSTATE_CHECKED);
|
||||||
|
124
PowerEditor/src/dpiManager.h
Normal file
124
PowerEditor/src/dpiManager.h
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
// This file is part of Notepad++ project
|
||||||
|
// Copyright (C)2003 Don HO <don.h@free.fr>
|
||||||
|
//
|
||||||
|
// 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 2 of the License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// Note that the GPL places important restrictions on "derived works", yet
|
||||||
|
// it does not provide a detailed definition of that term. To avoid
|
||||||
|
// misunderstandings, we consider an application to constitute a
|
||||||
|
// "derivative work" for the purpose of this license if it does any of the
|
||||||
|
// following:
|
||||||
|
// 1. Integrates source code from Notepad++.
|
||||||
|
// 2. Integrates/includes/aggregates Notepad++ into a proprietary executable
|
||||||
|
// installer, such as those produced by InstallShield.
|
||||||
|
// 3. Links to a library or executes a program that does any of the above.
|
||||||
|
//
|
||||||
|
// 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, write to the Free Software
|
||||||
|
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
|
||||||
|
#ifndef DPIMANAGER_H
|
||||||
|
#define DPIMANAGER_H
|
||||||
|
|
||||||
|
class DPIManager
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DPIManager() {
|
||||||
|
init();
|
||||||
|
};
|
||||||
|
|
||||||
|
// Get screen DPI.
|
||||||
|
int getDPIX() { return _dpiX; };
|
||||||
|
int getDPIY() { return _dpiY; };
|
||||||
|
|
||||||
|
// Convert between raw pixels and relative pixels.
|
||||||
|
int scaleX(int x) { return MulDiv(x, _dpiX, 96); };
|
||||||
|
int scaleY(int y) { return MulDiv(y, _dpiY, 96); };
|
||||||
|
int unscaleX(int x) { return MulDiv(x, 96, _dpiX); };
|
||||||
|
int unscaleY(int y) { return MulDiv(y, 96, _dpiY); };
|
||||||
|
|
||||||
|
// Determine the screen dimensions in relative pixels.
|
||||||
|
int scaledScreenWidth() { return scaledSystemMetricX(SM_CXSCREEN); }
|
||||||
|
int scaledScreenHeight() { return scaledSystemMetricY(SM_CYSCREEN); }
|
||||||
|
|
||||||
|
// Scale rectangle from raw pixels to relative pixels.
|
||||||
|
void scaleRect(__inout RECT *pRect) {
|
||||||
|
pRect->left = scaleX(pRect->left);
|
||||||
|
pRect->right = scaleX(pRect->right);
|
||||||
|
pRect->top = scaleY(pRect->top);
|
||||||
|
pRect->bottom = scaleY(pRect->bottom);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Scale Point from raw pixels to relative pixels.
|
||||||
|
void scalePoint(__inout POINT *pPoint)
|
||||||
|
{
|
||||||
|
pPoint->x = scaleX(pPoint->x);
|
||||||
|
pPoint->y = scaleY(pPoint->y);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Scale Size from raw pixels to relative pixels.
|
||||||
|
void scaleSize(__inout SIZE *pSize)
|
||||||
|
{
|
||||||
|
pSize->cx = scaleX(pSize->cx);
|
||||||
|
pSize->cy = scaleY(pSize->cy);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Determine if screen resolution meets minimum requirements in relative pixels.
|
||||||
|
bool isResolutionAtLeast(int cxMin, int cyMin)
|
||||||
|
{
|
||||||
|
return (scaledScreenWidth() >= cxMin) && (scaledScreenHeight() >= cyMin);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convert a point size (1/72 of an inch) to raw pixels.
|
||||||
|
int pointsToPixels(int pt) { return MulDiv(pt, _dpiY, 72); };
|
||||||
|
|
||||||
|
// Invalidate any cached metrics.
|
||||||
|
void Invalidate() { init(); };
|
||||||
|
|
||||||
|
private:
|
||||||
|
// X and Y DPI values are provided, though to date all
|
||||||
|
// Windows OS releases have equal X and Y scale values
|
||||||
|
int _dpiX;
|
||||||
|
int _dpiY;
|
||||||
|
|
||||||
|
|
||||||
|
void init() {
|
||||||
|
HDC hdc = GetDC(NULL);
|
||||||
|
if (hdc)
|
||||||
|
{
|
||||||
|
// Initialize the DPIManager member variable
|
||||||
|
// This will correspond to the DPI setting
|
||||||
|
// With all Windows OS's to date the X and Y DPI will be identical
|
||||||
|
_dpiX = GetDeviceCaps(hdc, LOGPIXELSX);
|
||||||
|
_dpiY = GetDeviceCaps(hdc, LOGPIXELSY);
|
||||||
|
ReleaseDC(NULL, hdc);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// This returns a 96-DPI scaled-down equivalent value for nIndex
|
||||||
|
// For example, the value 120 at 120 DPI setting gets scaled down to 96
|
||||||
|
// X and Y versions are provided, though to date all Windows OS releases
|
||||||
|
// have equal X and Y scale values
|
||||||
|
int scaledSystemMetricX(int nIndex) {
|
||||||
|
return MulDiv(GetSystemMetrics(nIndex), 96, _dpiX);
|
||||||
|
};
|
||||||
|
|
||||||
|
// This returns a 96-DPI scaled-down equivalent value for nIndex
|
||||||
|
// For example, the value 120 at 120 DPI setting gets scaled down to 96
|
||||||
|
// X and Y versions are provided, though to date all Windows OS releases
|
||||||
|
// have equal X and Y scale values
|
||||||
|
int scaledSystemMetricY(int nIndex)
|
||||||
|
{
|
||||||
|
return MulDiv(GetSystemMetrics(nIndex), 96, _dpiY);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //DPIMANAGER_H
|
@ -85,6 +85,7 @@
|
|||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCManifestTool"
|
Name="VCManifestTool"
|
||||||
|
AdditionalManifestFiles="..\src\dpiAware.manifest"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCXDCMakeTool"
|
Name="VCXDCMakeTool"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user