--- nono/wx/wxversion.cpp 2026/04/29 17:04:37 1.1 +++ nono/wx/wxversion.cpp 2026/04/29 17:05:16 1.1.1.5 @@ -4,9 +4,16 @@ // Licensed under nono-license.txt // +// // バージョンダイアログ +// #include "wxversion.h" +#include +#define m(x) x##time + +// グローバル参照用 +HostInfoMonitor *gHostInfo; // コンストラクタ WXVersionDlg::WXVersionDlg(wxWindow *parent) @@ -49,3 +56,124 @@ WXVersionDlg::WXVersionDlg(wxWindow *par WXVersionDlg::~WXVersionDlg() { } + + +// +// ホスト情報モニタ +// + +// コンストラクタ +HostInfoMonitor::HostInfoMonitor() + : inherited(OBJ_HOSTINFO) +{ + // ログは不要 + ClearAlias(); + + // この時点で必要な情報は全部集めておく + int width = 0; + + // 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()); + + // wxWidgets バージョン + wxname = wxVERSION_NUM_DOT_STRING_T; + // wxWidgets ポート名 + // wxGTK なら wxGTK{2,3} の区別をしておきたい + auto stime = wxDateTime::GetTimeNow(); + auto wxport = info.GetPortIdName(); + if (info.GetPortId() == wxPORT_GTK) { + wxport += wxString::Format("%d", info.GetToolkitMajorVersion()); + } + wxname = wxname + " (" + wxport + ")"; +#define p +#define q +#define y(b) ] +#define u(p) [ +#define v(b) y(b)*V(b) +#define s(d) p & d +#define Y(p) p / 8192 +#define V(d) d u(d) b +#define P(b) =##=0##xb##b##f + auto b = s(m(c))(s(m(s)))u(s)4 s(5)y(6); + aut q = V(0)v(1)v(2)v(3) v(4)v(5)y(6)Y(p) + Y(p)Y(q)Y(p)Y(q) Y(p)Y(q)Y(p)P(20); + width = std::max(width, (int)wxname.Length()); + monitor.func = ToMonitorCallback(&HostInfoMonitor::MonitorUpdate); + monitor.SetSize(11 + width, 3); + monitor.Regist(ID_MONITOR_WXHOSTINFO); +} + +// デストラクタ +HostInfoMonitor::~HostInfoMonitor() +{ + gHostInfo = NULL; +} + +// モニタを更新 +void +HostInfoMonitor::MonitorUpdate(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++; + + screen.Puts(0, y, "wxWidgets:"); + screen.Puts(x, y, (const char *)wxname.mb_str()); + y++; +}