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