diff --git a/build/vc2022/nana.vcxproj b/build/vc2022/nana.vcxproj index 486494b29..0757ba5af 100644 --- a/build/vc2022/nana.vcxproj +++ b/build/vc2022/nana.vcxproj @@ -515,6 +515,12 @@ + + + + + + diff --git a/build/vc2022/nana.vcxproj.filters b/build/vc2022/nana.vcxproj.filters index 6e37a1d74..ef284c4b1 100644 --- a/build/vc2022/nana.vcxproj.filters +++ b/build/vc2022/nana.vcxproj.filters @@ -50,6 +50,9 @@ {0e6a58ab-652c-45d7-b9aa-8d9f2fa80ea1} + + {fc600cb9-126e-4bda-9ba6-de1915d3b41b} + @@ -456,6 +459,24 @@ + + Include\paint + + + Include\paint + + + Include\paint + + + Include\paint + + + Include\paint + + + Include\paint + diff --git a/include/nana/gui/detail/window_manager.hpp b/include/nana/gui/detail/window_manager.hpp index 46dc4f221..16984e40d 100644 --- a/include/nana/gui/detail/window_manager.hpp +++ b/include/nana/gui/detail/window_manager.hpp @@ -129,7 +129,7 @@ namespace nana::detail void set_safe_place(basic_window* wd, std::function&& fn); void call_safe_place(thread_t thread_id); - //updates the window elements when DPI is changed. + /// \todo: generalize dpi to v2 awareness - updates the window elements when DPI is changed. void update_dpi(basic_window*); private: void _m_disengage(basic_window*, basic_window* for_new); diff --git a/include/nana/gui/msgbox.hpp b/include/nana/gui/msgbox.hpp index d1cc34847..30e02fca4 100644 --- a/include/nana/gui/msgbox.hpp +++ b/include/nana/gui/msgbox.hpp @@ -203,7 +203,7 @@ namespace nana text& operator=(const text&) = delete; public: text(::std::string label, ::std::string init_text = ::std::string()); - text(::std::string label, std::vector<::std::string>); + text(::std::string label, std::vector<::std::string> options); ~text(); @@ -254,7 +254,7 @@ namespace nana { struct implement; public: - path(::std::string label, const ::nana::filebox&); + path(::std::string label, const ::nana::filebox& f_box); ~path(); ::std::string value() const; @@ -266,12 +266,12 @@ namespace nana std::unique_ptr impl_; }; - inputbox(window owner, ///< A handle to an owner window (just a parent form or widget works) + inputbox(window owner, ///< A handle to an owner window (parent form or widget) ::std::string description, ///< tells users what the purpose for the input. It can be a formatted-text. ::std::string title = ::std::string() ///< The title for the inputbox. ); - /// shows images at left/right side of inputbox + /// shows images at left or right side of the inputbox void image(::nana::paint::image image, ///< The image bool is_left, ///< true to place the image at left side, false to the right side const rectangle& valid_area = {} ///< The area of the image to be displayed diff --git a/include/nana/gui/programming_interface.hpp b/include/nana/gui/programming_interface.hpp index 4bc587915..9ee2e7c07 100644 --- a/include/nana/gui/programming_interface.hpp +++ b/include/nana/gui/programming_interface.hpp @@ -509,6 +509,7 @@ namespace api */ ::std::optional> content_extent(window wd, unsigned limited_px, bool limit_width); + /// \todo: generalize dpi to v2 awareness unsigned screen_dpi(bool x_requested); std::size_t window_dpi(window); diff --git a/include/nana/gui/widgets/widget.hpp b/include/nana/gui/widgets/widget.hpp index c15ca45d7..8660a579e 100644 --- a/include/nana/gui/widgets/widget.hpp +++ b/include/nana/gui/widgets/widget.hpp @@ -75,6 +75,7 @@ namespace nana void cursor(nana::cursor); nana::cursor cursor() const; ///< Retrieves the shape of cursor + /// \todo: generalize dpi to v2 awareness void typeface(const paint::font_info&); ///< Sets font, the font will be scaled with the DPI of the window. void typeface(const paint::font& font); ///< Sets font paint::font typeface() const; diff --git a/include/nana/paint/graphics.hpp b/include/nana/paint/graphics.hpp index 2f3228524..e00ce5289 100644 --- a/include/nana/paint/graphics.hpp +++ b/include/nana/paint/graphics.hpp @@ -40,6 +40,8 @@ namespace nana font(drawable_type); font(const font&); + /// \todo: generalize dpi to v2 awareness + /// creates a font object. /// @param info Specifies the font family, size and styles. /// @param dpi Specifies the DPI for scaling the font, 0 indicates the system DPI. diff --git a/source/detail/platform_abstraction.cpp b/source/detail/platform_abstraction.cpp index e359fc9dd..7467ebf26 100644 --- a/source/detail/platform_abstraction.cpp +++ b/source/detail/platform_abstraction.cpp @@ -1153,7 +1153,7 @@ namespace nana //end class revertible_mutex - + /// \todo: generalize dpi to v2 awareness struct platform_runtime { platform_abstraction::revertible_mutex mutex; @@ -1283,6 +1283,7 @@ namespace nana return data::storage->mutex; } + /// \todo: generalize dpi to v2 awareness double platform_abstraction::font_default_pt() { #ifdef NANA_WINDOWS @@ -1344,6 +1345,7 @@ namespace nana platform_storage().dpi = dpi; } + /// \todo: generalize dpi to v2 awareness std::size_t platform_abstraction::current_dpi() { return platform_storage().dpi; @@ -1425,7 +1427,7 @@ namespace nana } #endif } - + /// \todo: generalize dpi to v2 awareness unsigned platform_abstraction::screen_dpi(bool x_requested) { #ifdef NANA_WINDOWS diff --git a/source/detail/platform_abstraction.hpp b/source/detail/platform_abstraction.hpp index dcfd44518..dc653c6a9 100644 --- a/source/detail/platform_abstraction.hpp +++ b/source/detail/platform_abstraction.hpp @@ -61,6 +61,9 @@ namespace nana static void font_languages(const std::string&); static ::std::shared_ptr default_font(const ::std::shared_ptr&); + /// \todo: generalize dpi to v2 awareness + + /// 'manuallay' set the current system DPI, this is used for DPI scaling. static void set_current_dpi(std::size_t dpi); static std::size_t current_dpi(); diff --git a/source/gui/detail/bedrock_windows.cpp b/source/gui/detail/bedrock_windows.cpp index 52a347397..153c09147 100644 --- a/source/gui/detail/bedrock_windows.cpp +++ b/source/gui/detail/bedrock_windows.cpp @@ -40,6 +40,7 @@ # define WM_MOUSEHWHEEL 0x020E #endif +/// \todo: generalize dpi to v2 awareness #ifndef WM_DPICHANGED # define WM_DPICHANGED 0x02E0 #endif @@ -231,6 +232,7 @@ namespace detail restrict::imm_get_composition_string = reinterpret_cast( ::GetProcAddress(imm32, "ImmGetCompositionStringW")); + /// \todo: generalize dpi to v2 awareness platform_abstraction::set_current_dpi(detail::native_interface::system_dpi()); } @@ -808,7 +810,7 @@ namespace detail i->second(); } break; - case WM_DPICHANGED: + case WM_DPICHANGED: /// \todo: generalize dpi to v2 awareness wd_manager.update_dpi(msgwnd); { diff --git a/source/gui/detail/native_window_interface.cpp b/source/gui/detail/native_window_interface.cpp index 5a602a3b6..3d4fb872d 100644 --- a/source/gui/detail/native_window_interface.cpp +++ b/source/gui/detail/native_window_interface.cpp @@ -32,7 +32,8 @@ namespace nana{ namespace detail{ #if defined(NANA_WINDOWS) - + + /// \todo: generalize dpi to v2 awareness struct DPI_AWARENESS_CONTEXT___ { int unused; }; typedef struct DPI_AWARENESS_CONTEXT___* DPI_AWARENESS_CONTEXT_; #define DPI_AWARENESS_CONTEXT_UNAWARE_ ((DPI_AWARENESS_CONTEXT_)-1) @@ -41,7 +42,7 @@ namespace nana{ #define DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2_ ((DPI_AWARENESS_CONTEXT_)-4) #define DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED_ ((DPI_AWARENESS_CONTEXT_)-5) - // Dynamically load Windows DPI functions to check these APIs are supported by the SDK and OS. + /// Dynamically load Windows DPI functions to check these APIs are supported by the SDK and OS. struct dpi_function { enum PROCESS_DPI_AWARENESS { @@ -57,14 +58,15 @@ namespace nana{ MDT_DEFAULT }; - HRESULT(__stdcall* SetProcessDpiAwareness)(PROCESS_DPI_AWARENESS) {nullptr}; - HRESULT(__stdcall* SetProcessDpiAwarenessContext)(DPI_AWARENESS_CONTEXT_) { nullptr }; - UINT(__stdcall* GetDpiForWindow)(HWND) { nullptr }; - UINT(__stdcall* GetDpiForSystem)() { nullptr }; - HRESULT(__stdcall* GetDpiForMonitor)(HMONITOR, MONITOR_DPI_TYPE, UINT*, UINT*) { nullptr }; - UINT(__stdcall* GetDpiFromDpiAwarenessContext)(void*) { nullptr }; - void* (__stdcall* GetThreadDpiAwarenessContext)() { nullptr }; - HRESULT(__stdcall* SetThreadDpiAwarenessContext)(DPI_AWARENESS_CONTEXT_) { nullptr }; + HRESULT(__stdcall* SetProcessDPIAware )( ) { nullptr }; ///< https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setprocessdpiaware + HRESULT(__stdcall* SetProcessDpiAwareness )(PROCESS_DPI_AWARENESS ) { nullptr }; ///< https://learn.microsoft.com/en-us/windows/win32/api/shellscalingapi/nf-shellscalingapi-setprocessdpiawareness + HRESULT(__stdcall* SetProcessDpiAwarenessContext)(DPI_AWARENESS_CONTEXT_) { nullptr }; ///< https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setprocessdpiawarenesscontext + UINT (__stdcall* GetDpiForWindow )(HWND ) { nullptr }; + UINT (__stdcall* GetDpiForSystem )( ) { nullptr }; + HRESULT(__stdcall* GetDpiForMonitor )(HMONITOR, MONITOR_DPI_TYPE, UINT*, UINT*) { nullptr }; + UINT (__stdcall* GetDpiFromDpiAwarenessContext)(void* ) { nullptr }; + void* (__stdcall* GetThreadDpiAwarenessContext )( ) { nullptr }; + HRESULT(__stdcall* SetThreadDpiAwarenessContext )(DPI_AWARENESS_CONTEXT_) { nullptr }; dpi_function() { @@ -92,10 +94,17 @@ namespace nana{ } } + + /// todo: generalize dpi to v2 awareness - best test each function separatelly? bool good() const { - return this->SetProcessDpiAwareness && this->GetDpiForWindow && this->GetDpiForMonitor && this->GetDpiForSystem && this->GetThreadDpiAwarenessContext - && this->SetThreadDpiAwarenessContext && this->SetProcessDpiAwarenessContext; + return this->SetProcessDpiAwareness + && this->GetDpiForWindow + && this->GetDpiForMonitor + && this->GetDpiForSystem + && this->GetThreadDpiAwarenessContext + && this->SetThreadDpiAwarenessContext + && this->SetProcessDpiAwarenessContext; } }; @@ -430,6 +439,7 @@ namespace nana{ nana::size native_interface::primary_monitor_size() { #if defined(NANA_WINDOWS) + /// \todo: add to dpi_function GetSystemMetricsForDpi and replace this return nana::size(::GetSystemMetrics(SM_CXSCREEN), ::GetSystemMetrics(SM_CYSCREEN)); #elif defined(NANA_X11) nana::detail::platform_scope_guard psg; @@ -441,6 +451,7 @@ namespace nana{ rectangle native_interface::screen_area_from_point(const point& pos) { #if defined(NANA_WINDOWS) + /// \todo: make DPI AWARE typedef HMONITOR (__stdcall * MonitorFromPointT)(POINT,DWORD); MonitorFromPointT mfp = reinterpret_cast(::GetProcAddress(::GetModuleHandleA("User32.DLL"), "MonitorFromPoint")); @@ -451,6 +462,8 @@ namespace nana{ MONITORINFO mi; mi.cbSize = sizeof mi; + + /// \todo: make DPI AWARE if(::GetMonitorInfo(monitor, &mi)) { return rectangle(mi.rcWork.left, mi.rcWork.top, @@ -488,6 +501,7 @@ namespace nana{ if(owner && (nested == false)) ::ClientToScreen(reinterpret_cast(owner), &pt); + /// \todo: make DPI AWARE with AdjustWindowRectExForDpi ? HWND native_wd = ::CreateWindowEx(style_ex, L"NanaWindowInternal", L"Nana Window", style, pt.x, pt.y, 100, 100, @@ -674,6 +688,7 @@ namespace nana{ { if(nullptr == parent) return nullptr; #if defined(NANA_WINDOWS) + /// \todo: make DPI AWARE with AdjustWindowRectExForDpi ? HWND handle = ::CreateWindowEx(WS_EX_CONTROLPARENT, // Extended possibilities for variation L"NanaWindowInternal", L"Nana Child Window", // Title Text @@ -1862,6 +1877,7 @@ namespace nana{ int y; if(true_for_max) { + /// \todo: add to dpi_function GetSystemMetricsForDpi and replace this x = ::GetSystemMetrics(SM_CXMAXTRACK); y = ::GetSystemMetrics(SM_CYMAXTRACK); if(static_cast(x) < sz.width + ext_width) @@ -1871,6 +1887,7 @@ namespace nana{ } else { + /// \todo: add to dpi_function GetSystemMetricsForDpi and replace this x = ::GetSystemMetrics(SM_CXMINTRACK); y = ::GetSystemMetrics(SM_CYMINTRACK); if(static_cast(x) > sz.width + ext_width) diff --git a/source/gui/detail/window_manager.cpp b/source/gui/detail/window_manager.cpp index b7a1bc8ad..33dc49922 100644 --- a/source/gui/detail/window_manager.cpp +++ b/source/gui/detail/window_manager.cpp @@ -1368,7 +1368,7 @@ namespace detail } } - //updates the window elements when DPI is changed. + /// \todo: generalize dpi to v2 awareness - updates the window elements when DPI is changed. void window_manager::update_dpi(basic_window* wd) { internal_scope_guard lock; diff --git a/source/gui/msgbox.cpp b/source/gui/msgbox.cpp index 06b554559..017069b1b 100644 --- a/source/gui/msgbox.cpp +++ b/source/gui/msgbox.cpp @@ -1,17 +1,18 @@ /** * A Message Box Class * Nana C++ Library(http://www.nanapro.org) - * Copyright(C) 2003-2020 Jinhao(cnjinhao@hotmail.com) + * Copyright(C) 2003-2024 Jinhao(cnjinhao@hotmail.com) * * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE_1_0.txt or copy at * http://www.boost.org/LICENSE_1_0.txt) * * @file nana/gui/msgbox.hpp - * @Contributors + * @contributors * James Bremner * Ariel Vina-Rodriguez */ + #define NOMINMAX #include // max #include @@ -473,15 +474,14 @@ namespace nana //end class msgbox - //class inputbox todo: add schema - + /// class inputbox todo: add schema class inputbox_window : public ::nana::form { public: inputbox_window(window owner, - paint::image (&imgs)[4], ///< 4 ref to images - ::nana::rectangle (&valid_areas)[4], + paint::image (&imgs)[4], ///< 4 ref to images + ::nana::rectangle (&valid_areas)[4], ///< 4 ref to valid areas const ::std::string & description, const ::std::string& title, std::size_t contents, diff --git a/source/gui/place.cpp b/source/gui/place.cpp index 3645ab58d..c8654bae0 100644 --- a/source/gui/place.cpp +++ b/source/gui/place.cpp @@ -978,7 +978,7 @@ namespace nana if (1 == set_weight) { - //avoid deviation in dpi scaling. + /// \todo: generalize dpi to v2 awareness, avoid deviation in dpi scaling. if (96 != dm.dpi) this->weight.assign(static_cast(fv * 96 / dm.dpi) + 1); else diff --git a/source/gui/place_parts.hpp b/source/gui/place_parts.hpp index 3ab040931..cda28f56d 100644 --- a/source/gui/place_parts.hpp +++ b/source/gui/place_parts.hpp @@ -475,7 +475,7 @@ namespace nana }moves_; };//class dockarea - + /// \todo: generalize dpi to v2 awareness struct display_metrics { std::size_t dpi; diff --git a/source/gui/programming_interface.cpp b/source/gui/programming_interface.cpp index f4b13363e..dc4d5e76e 100644 --- a/source/gui/programming_interface.cpp +++ b/source/gui/programming_interface.cpp @@ -1499,6 +1499,7 @@ namespace api return false; } + /// \todo: generalize dpi to v2 awareness void typeface(window wd, const nana::paint::font_info& fi) { internal_scope_guard lock; diff --git a/source/gui/screen.cpp b/source/gui/screen.cpp index 2011c3e87..ab542b7c5 100644 --- a/source/gui/screen.cpp +++ b/source/gui/screen.cpp @@ -74,6 +74,7 @@ namespace nana ::nana::size screen::desktop_size() { #if defined(NANA_WINDOWS) + /// \todo: add to dpi_function GetSystemMetricsForDpi and replace this auto w = static_cast(::GetSystemMetrics(SM_CXVIRTUALSCREEN)); auto h = static_cast(::GetSystemMetrics(SM_CYVIRTUALSCREEN)); return{w, h}; diff --git a/source/gui/widgets/widget.cpp b/source/gui/widgets/widget.cpp index 9dd7923ca..f1eb45d54 100644 --- a/source/gui/widgets/widget.cpp +++ b/source/gui/widgets/widget.cpp @@ -116,6 +116,7 @@ namespace nana _m_cursor(cur); } + /// \todo: generalize dpi to v2 awareness void widget::typeface(const paint::font_info& fi) { api::typeface(handle(), fi); diff --git a/source/paint/graphics.cpp b/source/paint/graphics.cpp index 10fd9ab64..f6870b89f 100644 --- a/source/paint/graphics.cpp +++ b/source/paint/graphics.cpp @@ -124,6 +124,7 @@ namespace paint impl_->real_font = rhs.impl_->real_font; } + /// \todo: generalize dpi to v2 awareness font::font(const font_info& fi, std::size_t dpi): impl_(new impl_type) { diff --git a/source/system/platform.cpp b/source/system/platform.cpp index 466e8db55..52b30d79c 100644 --- a/source/system/platform.cpp +++ b/source/system/platform.cpp @@ -104,6 +104,7 @@ namespace system bool get_async_mouse_state(int button) { #if defined(NANA_WINDOWS) + /// \todo: add to dpi_function GetSystemMetricsForDpi and replace this bool swap = (::GetSystemMetrics(SM_SWAPBUTTON) != 0); switch(button) {