nim_duilib/duilib/Utils/DpiManager.h
jiajia_deng 4933d1f2bc Remove dependency on shared
Signed-off-by: jiajia_deng <2894220@gmail.com>
2019-09-20 16:27:58 +08:00

114 lines
2.2 KiB
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef UI_UTILS_DPIMANAGER_H_
#define UI_UTILS_DPIMANAGER_H_
#pragma once
namespace ui
{
/** @class DpiManager
* @brief DPI适配管理类
* @copyright (c) 2016, NetEase Inc. All rights reserved
* @author Redrain
* @date 2016/10/10
*/
class UILIB_API DpiManager
{
public:
static DpiManager* GetInstance();
/**
* @brief 获取系统DPI开启DPI感知后有效
* @return UINT DPI
*/
static UINT GetSystemDPI();
/**
* @brief 获取某个显示器的DPI开启DPI感知后有效
* @param[in] HMONITOR句柄
* @return UINT DPI
*/
static UINT GetMonitorDPI(HMONITOR hMonitor);
/**
* @brief 获取主显示器DPI开启DPI感知后有效
* @return UINT DPI
*/
static UINT GetMainMonitorDPI();
/**
* @brief 从注册表获取DPI不开启DPI感知也有效
* @return UINT DPI
*/
static UINT GetDPIFromRegistry();
/**
* @brief 是否程序自己适配DPI缩放效果
* @return bool true 是false 否
*/
bool IsAdaptDPI();
/**
* @brief 设置是否程序自己适配DPI缩放默认不自己适配
* @return bool true 设置成功false 设置失败
*/
bool SetAdaptDPI();
/**
* @brief 获取当前界面缩放比
* @return UINT 缩放比
*/
UINT GetScale();
/**
* @brief 根据DPI值设置界面缩放比只有程序自己处理DPI缩放时才有效
* @param[in] uDPI DPI值
* @return void 无返回值
*/
void SetScale(UINT uDPI);
/**
* @brief 根据界面缩放比来缩放整数只有程序自己处理DPI缩放时才有效
* @param[in] iValue 整数
* @return int 缩放后的值
*/
int ScaleInt(int &iValue);
/**
* @brief 根据界面缩放比来缩放SIZE只有程序自己处理DPI缩放时才有效
* @param[in] pSize SIZE指针
* @return void 无返回值
*/
void ScaleSize(SIZE &size);
void ScaleSize(CSize &size);
/**
* @brief 根据界面缩放比来缩放POINT只有程序自己处理DPI缩放时才有效
* @param[in] pSize SIZE指针
* @return void 无返回值
*/
void ScalePoint(POINT &point);
void ScalePoint(CPoint &point);
/**
* @brief 根据界面缩放比来缩放RECT只有程序自己处理DPI缩放时才有效
* @param[in] pSize SIZE指针
* @return void 无返回值
*/
void ScaleRect(RECT &rect);
void ScaleRect(UiRect &rect);
private:
DpiManager();
~DpiManager() {};
DpiManager(const DpiManager&) = delete;
DpiManager& operator = (const DpiManager&) = delete;
private:
int m_nScaleFactor;
bool m_bAdaptDPI;
};
}
#endif //UI_UTILS_DPIMANAGER_H_