--- nono/wx/wxversion.cpp 2026/04/29 17:04:37 1.1 +++ nono/wx/wxversion.cpp 2026/04/29 17:05:57 1.1.1.12 @@ -4,9 +4,17 @@ // Licensed under nono-license.txt // +// // バージョンダイアログ +// #include "wxversion.h" +#include "hostnet.h" +#include "monitor.h" +#include + +// グローバル参照用 +HostInfoMonitor *gHostInfo; // コンストラクタ WXVersionDlg::WXVersionDlg(wxWindow *parent) @@ -30,7 +38,7 @@ WXVersionDlg::WXVersionDlg(wxWindow *par // Copyright vbox->Add(new wxStaticText(this, wxID_ANY, - "Copyright (C) 2020 nono project")); + "Copyright (C) 2020-2026 nono project")); // 空行 vbox->Add(new wxStaticText(this, wxID_ANY, "")); @@ -49,3 +57,172 @@ WXVersionDlg::WXVersionDlg(wxWindow *par WXVersionDlg::~WXVersionDlg() { } + + +// +// ホスト情報モニタ +// + +// コンストラクタ +HostInfoMonitor::HostInfoMonitor() + : inherited(OBJ_HOSTINFO) +{ + // ログは不要 + ClearAlias(); + + // この時点で必要な情報は全部集めておく + int width = 0; + int height = 4; + + // OS 名 + const auto info = wxPlatformInfo::Get(); +#if defined(__WXOSX__) + // "Apple Mac OS X 10.14" みたいに表示される + osname = info.GetOperatingSystemIdName(); + osname += wxString::Format(" %d.%d", + info.GetOSMajorVersion(), + info.GetOSMinorVersion()); +#else + // Linux ならディストリビューション + if (info.GetOperatingSystemId() == wxOS_UNIX_LINUX) { + auto distro = info.GetLinuxDistributionInfo(); + osname = distro.Description; + } + // そうでなければ + if (osname.IsEmpty()) { + // GetOperatingSystemDescription() はほぼ uname -srm のようなので + // 前の2つだけにして uname -sr 相当で表示。 + osname = info.GetOperatingSystemDescription(); + auto pos = osname.rfind(' '); + if (pos != std::string::npos) { + osname = osname.substr(0, pos); + } + } +#endif + width = std::max(width, (int)osname.Length()); + + // Machine (アーキテクチャと Endian を表示したい) + struct utsname ut; + if (uname(&ut) == 0) { + machinename = ut.machine; + machinename += " "; + } + // GetEndiannessName() は endian が小文字なので大文字にしたい + switch (info.GetEndianness()) { + case wxENDIAN_BIG: + machinename += "(Big Endian)"; + break; + case wxENDIAN_LITTLE: + machinename += "(Little Endian)"; + break; + case wxENDIAN_PDP: + machinename += "(PDP Endian)"; + break; + default: + break; + } + width = std::max(width, (int)machinename.Length()); + + // CPU Features +#if defined(__x86_64__) + height++; +# if defined(HAVE_AVX2) + if (gMainApp.detect_avx2) { + if (gMainApp.enable_avx2) { + avx2str = "enabled"; + } else { + avx2str = "disabled"; + } + } else { + avx2str = "not detected"; + } +# else + avx2str = "not compiled"; +# endif +#endif + +#if defined(__aarch64__) + height++; +# if defined(HAVE_NEON) + if (gMainApp.detect_neon) { + if (gMainApp.enable_neon) { + neonstr = "enabled"; + } else { + neonstr = "disabled"; + } + } else { + neonstr = "not detected"; + } +# else + neonstr = "not compiled"; +# endif +#endif + width = std::max(width, (int)avx2str.Length()); + width = std::max(width, (int)neonstr.Length()); + + // wxWidgets バージョン + wxname = wxVERSION_NUM_DOT_STRING_T; + // wxWidgets ポート名 + // wxGTK なら wxGTK{2,3} の区別をしておきたい + auto wxport = info.GetPortIdName(); + if (info.GetPortId() == wxPORT_GTK) { + wxport += wxString::Format("%d", info.GetToolkitMajorVersion()); + } + wxname = wxname + " (" + wxport + ")"; + width = std::max(width, (int)wxname.Length()); + + // libslirp バージョン + slirpver = HostNetDevice::GetSlirpVersion(); + if (slirpver == NULL) { + slirpver = "not compiled"; + } + width = std::max(width, (int)strlen(slirpver)); + + monitor = gMonitorManager->Regist(ID_MONITOR_WXHOSTINFO, this); + monitor->SetCallback(&HostInfoMonitor::MonitorScreen); + monitor->SetSize(11 + width, height); +} + +// デストラクタ +HostInfoMonitor::~HostInfoMonitor() +{ + gHostInfo = NULL; +} + +// モニタを更新 +void +HostInfoMonitor::MonitorScreen(Monitor *, TextScreen& screen) +{ + int x = 11; + int y; + + screen.Clear(); + y = 0; + + screen.Puts(0, y, "OS:"); + screen.Puts(x, y, (const char *)osname.mb_str()); + y++; + + screen.Puts(0, y, "Machine:"); + screen.Puts(x, y, (const char *)machinename.mb_str()); + y++; + +#if defined(__x86_64__) + screen.Puts(0, y, "AVX2:"); + screen.Puts(x, y, (const char *)avx2str.mb_str()); + y++; +#endif +#if defined(__aarch64__) + screen.Puts(0, y, "NEON:"); + screen.Puts(x, y, (const char *)neonstr.mb_str()); + y++; +#endif + + screen.Puts(0, y, "wxWidgets:"); + screen.Puts(x, y, (const char *)wxname.mb_str()); + y++; + + screen.Puts(0, y, "libslirp:"); + screen.Puts(x, y, slirpver); + y++; +}