diff --git a/build/wxExtend.props b/build/wxExtend.props index 7987ba5..569a66d 100644 --- a/build/wxExtend.props +++ b/build/wxExtend.props @@ -1,83 +1,85 @@ - - - - - 15 - - - ..\..\..\output\$(Platform).$(Configuration)\ - - - - $(OutDir)..\locale\%(Filename)\$(ProjectName)$(wxExtendVersion).mo - - - - - - - - - - Create - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + 15 + + + ..\..\..\output\$(Platform).$(Configuration)\ + + + + $(OutDir)..\locale\%(Filename)\$(ProjectName)$(wxExtendVersion).mo + + + + + + + + + + + Create + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/build/wxExtendDll.vcxproj.filters b/build/wxExtendDll.vcxproj.filters index eec3039..842f9aa 100644 --- a/build/wxExtendDll.vcxproj.filters +++ b/build/wxExtendDll.vcxproj.filters @@ -61,6 +61,9 @@ Source Files + + Source Files + @@ -111,6 +114,9 @@ Header Files\persist + + Header Files + diff --git a/build/wxExtendLib.vcxproj.filters b/build/wxExtendLib.vcxproj.filters index 6346c6c..f194d7b 100644 --- a/build/wxExtendLib.vcxproj.filters +++ b/build/wxExtendLib.vcxproj.filters @@ -61,6 +61,9 @@ Source Files + + Source Files + @@ -111,6 +114,9 @@ Header Files\persist + + Header Files + diff --git a/include/wxex/icon.h b/include/wxex/icon.h new file mode 100644 index 0000000..1fe669e --- /dev/null +++ b/include/wxex/icon.h @@ -0,0 +1,27 @@ +/* + ​​​SPDX-License-Identifier: GPL-3.0-or-later + Copyright © 2025 Amebis +*/ + +#pragma once + +#include "common.h" + +#include +#pragma warning(push) +#pragma warning(disable: WXWIDGETS_CODE_ANALYSIS_WARNINGS) +#include +#pragma warning(pop) + + +/// +/// Icon for DPI aware applications +/// +class wxIconEx : public wxIcon +{ +public: + wxIconEx(const wxString& name, + wxBitmapType type = wxICON_DEFAULT_TYPE, + int desiredWidth = -1, int desiredHeight = -1, + wxWindowBase *window = nullptr); +}; diff --git a/src/icon.cpp b/src/icon.cpp new file mode 100644 index 0000000..4437813 --- /dev/null +++ b/src/icon.cpp @@ -0,0 +1,39 @@ +/* + ​​​SPDX-License-Identifier: GPL-3.0-or-later + Copyright © 2025 Amebis +*/ + +#include "pch.h" + +static wxSize GetDPIHelper(const wxWindowBase* w) +{ + wxSize dpi; + + if ( w ) + dpi = w->GetDPI(); + if ( !dpi.x || !dpi.y ) + dpi = wxDisplay().GetPPI(); + if ( !dpi.x || !dpi.y ) + dpi = wxDisplay::GetStdPPI(); + + return dpi; +} + + +wxIconEx::wxIconEx(const wxString& name, + wxBitmapType type, + int desiredWidth, int desiredHeight, + wxWindowBase *window) +{ + wxSize dpi = GetDPIHelper(window); + wxSize baseline = wxDisplay::GetStdPPI(); + + if (desiredWidth != wxDefaultCoord) + desiredWidth = wxMulDivInt32(desiredWidth, dpi.x, baseline.x); + + if (desiredHeight != wxDefaultCoord) + desiredHeight = wxMulDivInt32(desiredHeight, dpi.y, baseline.y); + + LoadFile(name, type, desiredWidth, desiredHeight); + SetScaleFactor((double)dpi.y / (double)baseline.y); +} diff --git a/src/pch.h b/src/pch.h index ea13f5b..827eb54 100644 --- a/src/pch.h +++ b/src/pch.h @@ -1,34 +1,35 @@ -/* - ​​​SPDX-License-Identifier: GPL-3.0-or-later - Copyright © 2015-2022 Amebis - Copyright © 2016 GÉANT -*/ - -#pragma once - -// Since including introduces wrong include order in 3.0.2, -// include the grand at a cost of longer pre-compilation phase. -#include -#pragma warning(push) -#pragma warning(disable: ALL_CODE_ANALYSIS_WARNINGS 26812 26814) -#include -#pragma warning(pop) - -#include "../include/wxex/aui/framemanager.h" - -#include "../include/wxex/persist/auimanager.h" -#include "../include/wxex/persist/toplevel.h" - -#include "../include/wxex/appbar.h" -#include "../include/wxex/comutils.h" -#include "../include/wxex/crypto.h" -#include "../include/wxex/hex.h" -#include "../include/wxex/object.h" -#include "../include/wxex/url.h" -#include "../include/wxex/valhex.h" -#include "../include/wxex/valnet.h" -#include "../include/wxex/xml.h" - -#include "../include/wxex/common.h" - -#include "../include/wxex/private/tlwgeom.h" +/* + ​​​SPDX-License-Identifier: GPL-3.0-or-later + Copyright © 2015-2022 Amebis + Copyright © 2016 GÉANT +*/ + +#pragma once + +// Since including introduces wrong include order in 3.0.2, +// include the grand at a cost of longer pre-compilation phase. +#include +#pragma warning(push) +#pragma warning(disable: ALL_CODE_ANALYSIS_WARNINGS 26812 26814) +#include +#pragma warning(pop) + +#include "../include/wxex/aui/framemanager.h" + +#include "../include/wxex/persist/auimanager.h" +#include "../include/wxex/persist/toplevel.h" + +#include "../include/wxex/appbar.h" +#include "../include/wxex/comutils.h" +#include "../include/wxex/crypto.h" +#include "../include/wxex/hex.h" +#include "../include/wxex/icon.h" +#include "../include/wxex/object.h" +#include "../include/wxex/url.h" +#include "../include/wxex/valhex.h" +#include "../include/wxex/valnet.h" +#include "../include/wxex/xml.h" + +#include "../include/wxex/common.h" + +#include "../include/wxex/private/tlwgeom.h"