|
|
1.1 root 1: //
2: // nono
3: // Copyright (C) 2020 nono project
4: // Licensed under nono-license.txt
5: //
6:
1.1.1.4 root 7: //
1.1 root 8: // バージョンダイアログ
1.1.1.4 root 9: //
1.1 root 10:
11: #include "wxversion.h"
1.1.1.9 root 12: #include "monitor.h"
1.1.1.2 root 13: #include <sys/utsname.h>
14:
1.1.1.4 root 15: // グローバル参照用
16: HostInfoMonitor *gHostInfo;
1.1 root 17:
18: // コンストラクタ
19: WXVersionDlg::WXVersionDlg(wxWindow *parent)
20: : inherited(parent, wxID_ANY, _("About nono"))
21: {
22: wxBoxSizer *vbox = new wxBoxSizer(wxVERTICAL);
23:
24: wxString title = wxString::Format("nono %d.%d.%d (%s)",
25: NONO_MAJOR_VER, NONO_MINOR_VER, NONO_PATCH_VER, NONO_DATE);
26:
27: // タイトルだけ少し大きく
28: // XXX ..したいのだが wxOSX だと色々おかしいのでただのテキストにする。
29: auto titlectrl = new wxStaticText(this, wxID_ANY, title);
30: #if !defined(__WXOSX__)
31: titlectrl->SetLabelMarkup("<span size=\"x-large\">" + title + "</span>");
32: #endif
33: vbox->Add(titlectrl, 0, wxALIGN_CENTER);
34:
35: // 空行
36: vbox->Add(new wxStaticText(this, wxID_ANY, ""));
37:
38: // Copyright
39: vbox->Add(new wxStaticText(this, wxID_ANY,
1.1.1.10! root 40: "Copyright (C) 2020-2025 nono project"));
1.1 root 41:
42: // 空行
43: vbox->Add(new wxStaticText(this, wxID_ANY, ""));
44:
45: // OK
46: vbox->Add(CreateButtonSizer(wxOK), 0, wxALIGN_CENTER);
47:
48: // 周囲に 12px の余白をつける
49: wxBoxSizer *topsizer = new wxBoxSizer(wxVERTICAL);
50: topsizer->Add(vbox, 0, wxALL, 12);
51: SetSizer(topsizer);
52: topsizer->SetSizeHints(this);
53: }
54:
55: // デストラクタ
56: WXVersionDlg::~WXVersionDlg()
57: {
58: }
1.1.1.2 root 59:
60:
61: //
62: // ホスト情報モニタ
63: //
64:
65: // コンストラクタ
66: HostInfoMonitor::HostInfoMonitor()
1.1.1.5 root 67: : inherited(OBJ_HOSTINFO)
1.1.1.2 root 68: {
1.1.1.4 root 69: // ログは不要
70: ClearAlias();
71:
1.1.1.2 root 72: // この時点で必要な情報は全部集めておく
1.1.1.3 root 73: int width = 0;
1.1.1.8 root 74: int height = 3;
1.1.1.2 root 75:
76: // OS 名
77: const auto info = wxPlatformInfo::Get();
78: #if defined(__WXOSX__)
79: // "Apple Mac OS X 10.14" みたいに表示される
80: osname = info.GetOperatingSystemIdName();
81: osname += wxString::Format(" %d.%d",
82: info.GetOSMajorVersion(),
83: info.GetOSMinorVersion());
84: #else
85: // Linux ならディストリビューション
86: if (info.GetOperatingSystemId() == wxOS_UNIX_LINUX) {
87: auto distro = info.GetLinuxDistributionInfo();
88: osname = distro.Description;
89: }
90: // そうでなければ
91: if (osname.IsEmpty()) {
92: // GetOperatingSystemDescription() はほぼ uname -srm のようなので
93: // 前の2つだけにして uname -sr 相当で表示。
94: osname = info.GetOperatingSystemDescription();
95: auto pos = osname.rfind(' ');
96: if (pos != std::string::npos) {
97: osname = osname.substr(0, pos);
98: }
99: }
100: #endif
101: width = std::max(width, (int)osname.Length());
102:
103: // Machine (アーキテクチャと Endian を表示したい)
104: struct utsname ut;
105: if (uname(&ut) == 0) {
106: machinename = ut.machine;
107: machinename += " ";
108: }
109: // GetEndiannessName() は endian が小文字なので大文字にしたい
110: switch (info.GetEndianness()) {
111: case wxENDIAN_BIG:
112: machinename += "(Big Endian)";
113: break;
114: case wxENDIAN_LITTLE:
115: machinename += "(Little Endian)";
116: break;
117: case wxENDIAN_PDP:
118: machinename += "(PDP Endian)";
119: break;
120: default:
121: break;
122: }
123: width = std::max(width, (int)machinename.Length());
124:
1.1.1.7 root 125: // CPU Features
126: #if defined(__x86_64__)
1.1.1.8 root 127: height++;
1.1.1.7 root 128: # if defined(HAVE_AVX2)
129: if (gMainApp.detect_avx2) {
130: if (gMainApp.enable_avx2) {
131: avx2str = "enabled";
132: } else {
133: avx2str = "disabled";
134: }
135: } else {
136: avx2str = "not detected";
137: }
138: # else
139: avx2str = "not compiled";
140: # endif
141: #endif
1.1.1.8 root 142:
143: #if defined(__aarch64__)
144: height++;
145: # if defined(HAVE_NEON)
146: if (gMainApp.detect_neon) {
147: if (gMainApp.enable_neon) {
148: neonstr = "enabled";
149: } else {
150: neonstr = "disabled";
151: }
152: } else {
153: neonstr = "not detected";
154: }
155: # else
156: neonstr = "not compiled";
157: # endif
158: #endif
1.1.1.7 root 159: width = std::max(width, (int)avx2str.Length());
1.1.1.8 root 160: width = std::max(width, (int)neonstr.Length());
1.1.1.7 root 161:
1.1.1.2 root 162: // wxWidgets バージョン
163: wxname = wxVERSION_NUM_DOT_STRING_T;
164: // wxWidgets ポート名
165: // wxGTK なら wxGTK{2,3} の区別をしておきたい
1.1.1.3 root 166: auto wxport = info.GetPortIdName();
1.1.1.2 root 167: if (info.GetPortId() == wxPORT_GTK) {
168: wxport += wxString::Format("%d", info.GetToolkitMajorVersion());
169: }
170: wxname = wxname + " (" + wxport + ")";
171: width = std::max(width, (int)wxname.Length());
1.1.1.7 root 172:
1.1.1.9 root 173: monitor = gMonitorManager->Regist(ID_MONITOR_WXHOSTINFO, this);
174: monitor->func = ToMonitorCallback(&HostInfoMonitor::MonitorUpdate);
175: monitor->SetSize(11 + width, height);
1.1.1.2 root 176: }
177:
178: // デストラクタ
179: HostInfoMonitor::~HostInfoMonitor()
180: {
1.1.1.4 root 181: gHostInfo = NULL;
1.1.1.2 root 182: }
183:
184: // モニタを更新
185: void
1.1.1.3 root 186: HostInfoMonitor::MonitorUpdate(Monitor *, TextScreen& screen)
1.1.1.2 root 187: {
188: int x = 11;
189: int y;
190:
1.1.1.3 root 191: screen.Clear();
1.1.1.2 root 192: y = 0;
193:
1.1.1.3 root 194: screen.Puts(0, y, "OS:");
195: screen.Puts(x, y, (const char *)osname.mb_str());
1.1.1.2 root 196: y++;
197:
1.1.1.3 root 198: screen.Puts(0, y, "Machine:");
199: screen.Puts(x, y, (const char *)machinename.mb_str());
1.1.1.2 root 200: y++;
201:
1.1.1.7 root 202: #if defined(__x86_64__)
203: screen.Puts(0, y, "AVX2:");
204: screen.Puts(x, y, (const char *)avx2str.mb_str());
205: y++;
206: #endif
1.1.1.8 root 207: #if defined(__aarch64__)
208: screen.Puts(0, y, "NEON:");
209: screen.Puts(x, y, (const char *)neonstr.mb_str());
210: y++;
211: #endif
1.1.1.7 root 212:
1.1.1.3 root 213: screen.Puts(0, y, "wxWidgets:");
214: screen.Puts(x, y, (const char *)wxname.mb_str());
1.1.1.2 root 215: y++;
216: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.