Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions include/wx/apptrait.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,10 @@ class WXDLLIMPEXP_BASE wxAppTraitsBase
virtual wxString GetAssertStackTrace();
#endif // wxUSE_STACKWALKER

// Text to be appended to the description returned by wxGetLibraryVersionInfo().
// Currently used for getting compile-time versions of GTK+ and Qt.
virtual wxString GetPlatformDescription() const = 0;

private:
static wxSocketManager *ms_manager;
};
Expand Down Expand Up @@ -238,6 +242,7 @@ class WXDLLIMPEXP_BASE wxConsoleAppTraitsBase : public wxAppTraits

virtual bool IsUsingUniversalWidgets() const override { return false; }
virtual wxString GetDesktopEnvironment() const override { return wxEmptyString; }
virtual wxString GetPlatformDescription() const override { return wxEmptyString; }
};

// ----------------------------------------------------------------------------
Expand Down Expand Up @@ -278,6 +283,7 @@ class WXDLLIMPEXP_CORE wxGUIAppTraitsBase : public wxAppTraits
}

virtual wxString GetDesktopEnvironment() const override { return wxEmptyString; }
virtual wxString GetPlatformDescription() const override { return wxEmptyString; }
};

#endif // wxUSE_GUI
Expand Down
2 changes: 2 additions & 0 deletions include/wx/msw/apptrait.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ class WXDLLIMPEXP_CORE wxGUIAppTraits : public wxGUIAppTraitsBase
virtual bool WriteToStderr(const wxString& WXUNUSED(text)) override
{ return false; }
virtual WXHWND GetMainHWND() const override { return nullptr; }
virtual wxString GetPlatformDescription() const override;
};

#elif defined(__WXQT__)
Expand All @@ -114,6 +115,7 @@ class WXDLLIMPEXP_CORE wxGUIAppTraits : public wxGUIAppTraitsBase
virtual bool CanUseStderr() override { return false; }
virtual bool WriteToStderr(const wxString&) override { return false; }
virtual WXHWND GetMainHWND() const override { return nullptr; }
virtual wxString GetPlatformDescription() const override;
};

#endif
Expand Down
6 changes: 6 additions & 0 deletions include/wx/platinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,9 @@ class WXDLLIMPEXP_BASE wxPlatformInfo
int GetToolkitMicroVersion() const
{ return m_tkVersionMicro; }

wxString GetPlatformDescription() const
{ return m_platformDescription; }

bool CheckToolkitVersion(int major, int minor, int micro = 0) const
{
return DoCheckVersion(GetToolkitMajorVersion(),
Expand Down Expand Up @@ -435,6 +438,9 @@ class WXDLLIMPEXP_BASE wxPlatformInfo

// native CPU architecture family name, possibly empty if unknown
wxString m_nativeCpuArch;

// e.g. compile-time version of toolkit, possibly empty
wxString m_platformDescription;
};

// Return true if running under Wine and fills the provided pointer with
Expand Down
4 changes: 4 additions & 0 deletions include/wx/unix/apptrait.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ class WXDLLIMPEXP_CORE wxGUIAppTraits : public wxGUIAppTraitsBase
virtual wxString GetDesktopEnvironment() const override;
#endif // __WXGTK____

#if defined(__WXGTK__) || defined(__WXQT__)
virtual wxString GetPlatformDescription() const override;
#endif

#if defined(__WXGTK__)
virtual bool ShowAssertDialog(const wxString& msg) override;
#endif
Expand Down
2 changes: 1 addition & 1 deletion include/wx/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ WXDLLIMPEXP_CORE void wxBell();
WXDLLIMPEXP_CORE void wxInfoMessageBox(wxWindow* parent);
#endif // wxUSE_MSGDLG

WXDLLIMPEXP_CORE wxVersionInfo wxGetLibraryVersionInfo();
WXDLLIMPEXP_BASE wxVersionInfo wxGetLibraryVersionInfo();

// Get OS description as a user-readable string
WXDLLIMPEXP_BASE wxString wxGetOsDescription();
Expand Down
2 changes: 1 addition & 1 deletion interface/wx/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ void wxInfoMessageBox(wxWindow* parent);

@header{wx/utils.h}

@library{wxcore}
@library{wxbase}
*/
wxVersionInfo wxGetLibraryVersionInfo();

Expand Down
4 changes: 3 additions & 1 deletion src/common/platinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ bool wxPlatformInfo::operator==(const wxPlatformInfo &t) const
m_port == t.m_port &&
m_usingUniversal == t.m_usingUniversal &&
m_bitness == t.m_bitness &&
m_endian == t.m_endian;
m_endian == t.m_endian &&
m_platformDescription == t.m_platformDescription;
}

void wxPlatformInfo::InitForCurrentPlatform()
Expand All @@ -195,6 +196,7 @@ void wxPlatformInfo::InitForCurrentPlatform()
&m_tkVersionMicro);
m_usingUniversal = traits->IsUsingUniversalWidgets();
m_desktopEnv = traits->GetDesktopEnvironment();
m_platformDescription = traits->GetPlatformDescription();
}

m_os = wxGetOsVersion(&m_osVersionMajor, &m_osVersionMinor, &m_osVersionMicro);
Expand Down
126 changes: 58 additions & 68 deletions src/common/utilscmn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1022,6 +1022,64 @@ unsigned int wxCTZ(wxUint32 x)
#endif
}

wxVersionInfo wxGetLibraryVersionInfo()
{
// Only add the last build component to the version if it's non-zero, it's
// pretty useless otherwise.
wxString ver = wxString::Format
(
wxS("%d.%d.%d"),
wxMAJOR_VERSION,
wxMINOR_VERSION,
wxRELEASE_NUMBER
);
if ( wxSUBRELEASE_NUMBER )
ver += wxString::Format(wxS(".%d"), wxSUBRELEASE_NUMBER);

// don't translate these strings, they're for diagnostics purposes only
wxString msg;
msg.Printf(wxS("wxWidgets Library (%s port)\n")
wxS("Version %s (Unicode: %s, debug level: %d),\n")
#if !wxUSE_REPRODUCIBLE_BUILD
wxS("compiled at %s %s\n\n")
#endif
wxS("Runtime version of toolkit used is %d.%d.%d.\n"),
wxPlatformInfo::Get().GetPortIdName(),
ver,
#if wxUSE_UNICODE_UTF8
"UTF-8",
#else
"wchar_t",
#endif
wxDEBUG_LEVEL,
#if !wxUSE_REPRODUCIBLE_BUILD
// As explained in the comment near these macros definitions,
// ccache has special logic for detecting the use of __DATE__
// and __TIME__ macros, which doesn't apply to our own versions
// of them, hence this comment is needed just to mention the
// standard macro names and to ensure that ccache does _not_
// cache the results of compiling this file.
__TDATE__,
__TTIME__,
#endif
wxPlatformInfo::Get().GetToolkitMajorVersion(),
wxPlatformInfo::Get().GetToolkitMinorVersion(),
wxPlatformInfo::Get().GetToolkitMicroVersion()
);

msg += wxPlatformInfo::Get().GetPlatformDescription();

const wxString copyrightSign = wxString::FromUTF8("\xc2\xa9");

return wxVersionInfo(wxS("wxWidgets"),
wxMAJOR_VERSION,
wxMINOR_VERSION,
wxRELEASE_NUMBER,
msg,
wxString::Format(wxS("Copyright %s 1992-2025 wxWidgets team"),
copyrightSign));
}


#endif // wxUSE_BASE

Expand Down Expand Up @@ -1374,74 +1432,6 @@ int wxMessageBox(const wxString& message, const wxString& caption, long style,
return wxCANCEL;
}

wxVersionInfo wxGetLibraryVersionInfo()
{
// Only add the last build component to the version if it's non-zero, it's
// pretty useless otherwise.
wxString ver = wxString::Format
(
wxS("%d.%d.%d"),
wxMAJOR_VERSION,
wxMINOR_VERSION,
wxRELEASE_NUMBER
);
if ( wxSUBRELEASE_NUMBER )
ver += wxString::Format(wxS(".%d"), wxSUBRELEASE_NUMBER);

// don't translate these strings, they're for diagnostics purposes only
wxString msg;
msg.Printf(wxS("wxWidgets Library (%s port)\n")
wxS("Version %s (Unicode: %s, debug level: %d),\n")
#if !wxUSE_REPRODUCIBLE_BUILD
wxS("compiled at %s %s\n\n")
#endif
wxS("Runtime version of toolkit used is %d.%d.%d.\n"),
wxPlatformInfo::Get().GetPortIdName(),
ver,
#if wxUSE_UNICODE_UTF8
"UTF-8",
#else
"wchar_t",
#endif
wxDEBUG_LEVEL,
#if !wxUSE_REPRODUCIBLE_BUILD
// As explained in the comment near these macros definitions,
// ccache has special logic for detecting the use of __DATE__
// and __TIME__ macros, which doesn't apply to our own versions
// of them, hence this comment is needed just to mention the
// standard macro names and to ensure that ccache does _not_
// cache the results of compiling this file.
__TDATE__,
__TTIME__,
#endif
wxPlatformInfo::Get().GetToolkitMajorVersion(),
wxPlatformInfo::Get().GetToolkitMinorVersion(),
wxPlatformInfo::Get().GetToolkitMicroVersion()
);

#ifdef __WXGTK__
msg += wxString::Format("Compile-time GTK+ version is %d.%d.%d.\n",
GTK_MAJOR_VERSION,
GTK_MINOR_VERSION,
GTK_MICRO_VERSION);
#endif // __WXGTK__

#ifdef __WXQT__
msg += wxString::Format("Compile-time QT version is %s.\n",
QT_VERSION_STR);
#endif // __WXQT__

const wxString copyrightSign = wxString::FromUTF8("\xc2\xa9");

return wxVersionInfo(wxS("wxWidgets"),
wxMAJOR_VERSION,
wxMINOR_VERSION,
wxRELEASE_NUMBER,
msg,
wxString::Format(wxS("Copyright %s 1992-2025 wxWidgets team"),
copyrightSign));
}

void wxInfoMessageBox(wxWindow* parent)
{
wxVersionInfo info = wxGetLibraryVersionInfo();
Expand Down
7 changes: 7 additions & 0 deletions src/gtk/utilsgtk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,13 @@ wxPortId wxGUIAppTraits::GetToolkitVersion(int *verMaj,
return wxPORT_GTK;
}

wxString wxGUIAppTraits::GetPlatformDescription() const {
return wxString::Format("Compile-time GTK+ version is %d.%d.%d.\n",
GTK_MAJOR_VERSION,
GTK_MINOR_VERSION,
GTK_MICRO_VERSION);
}

#if wxUSE_TIMER

wxTimerImpl *wxGUIAppTraits::CreateTimerImpl(wxTimer *timer)
Expand Down
6 changes: 6 additions & 0 deletions src/qt/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "wx/window.h"
#endif // WX_PRECOMP

#include "wx/apptrait.h"
#include "wx/utils.h"
#include "wx/qt/private/utils.h"
#include "wx/qt/private/converter.h"
Expand Down Expand Up @@ -123,3 +124,8 @@ bool wxLaunchDefaultApplication(const wxString& path, int WXUNUSED( flags ) )
{
return QDesktopServices::openUrl( QUrl::fromLocalFile( wxQtConvertString( path ) ) );
}

wxString wxGUIAppTraits::GetPlatformDescription() const {
return wxString::Format("Compile-time QT version is %s.\n",
QT_VERSION_STR);
}
9 changes: 9 additions & 0 deletions tests/misc/misctests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "wx/math.h"
#include "wx/mimetype.h"
#include "wx/versioninfo.h"
#include "wx/utils.h"

#include "wx/private/wordwrap.h"

Expand Down Expand Up @@ -257,6 +258,14 @@ TEST_CASE("wxVersionInfo", "[version]")
CHECK_FALSE( ver120.AtLeast(2, 0) );
}

TEST_CASE("wxGetLibraryVersionInfo", "[libraryversion]")
{
// We especially want to ensure that wxGetLibraryVersionInfo()
// is available in wxBase, and successfully links, too.
wxVersionInfo libver = wxGetLibraryVersionInfo();
CHECK( libver.GetNumericVersionString().starts_with("3.") );
}

TEST_CASE("wxWordWrap", "[wordwrap]")
{
// Use artificially small max width to make the tests shorter and simpler.
Expand Down
Loading