--- nono/wx/wxapp.cpp 2026/04/29 17:05:04 1.1.1.10 +++ nono/wx/wxapp.cpp 2026/04/29 17:05:12 1.1.1.12 @@ -4,15 +4,18 @@ // Licensed under nono-license.txt // +// +// wx アプリケーションのエントリポイント +// + +#include "fontmanager.h" #include "wxdumpmonitor.h" +#include "wxlogsetting.h" #include "wxmainframe.h" #include "wxmainview.h" -#include "wxtextpanel.h" +#include "wxuimessage.h" #include "wxversion.h" #include "mainapp.h" -#include "mpu680x0.h" -#include "mpu88xx0.h" -#include "scheduler.h" #include #include @@ -20,6 +23,7 @@ class WXApp : public wxApp { using inherited = wxApp; public: + ~WXApp() override; bool OnInit(); int OnRun() override; private: @@ -28,17 +32,21 @@ class WXApp : public wxApp int SearchMonitorName(const char *name); wxLocale locale; + + std::unique_ptr pFontManager {}; + std::unique_ptr pHostInfo {}; }; // IMPLEMENT_APP() は闇マクロすぎて clang のちからには耐えられない -#if defined(__clang__) -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Weverything" -#endif +PRAGMA_PUSH_WARNINGS IMPLEMENT_APP(WXApp) -#if defined(__clang__) -#pragma clang diagnostic pop -#endif +PRAGMA_POP_WARNINGS + +WXApp::~WXApp() +{ + // 開発用 + WXUIMessage::AssertAllDisconnected(); +} bool WXApp::OnInit() @@ -70,7 +78,7 @@ WXApp::OnRun() // --fontsize テキスト系コントロールのフォントサイズ // 紛らわしいが ::global_fontsize は 12, 16 とかいう値。 - // WXTextPanel::global_fontsize (FontId) は enum 値。 + // FontManager::fontid は enum 値。 FontId fontid; switch (gMainApp.fontsize) { case 12: @@ -83,13 +91,17 @@ WXApp::OnRun() warnx("invalid fontsize: %d", gMainApp.fontsize); return EXIT_FAILURE; } - WXTextPanel::global_fontid = fontid; - - // グローバルオブジェクト (どこでやるのがいいか) - gHostInfo.reset(new HostInfoMonitor()); + pFontManager.reset(new FontManager()); + gFontManager = pFontManager.get(); + gFontManager->SetFont(fontid); + + // ホスト情報用のモニタ (どこでやるのがいいか) + pHostInfo.reset(new HostInfoMonitor()); + gHostInfo = pHostInfo.get(); + // 手順 4. (vm/device.h) // これ以降モニタの登録をしてはいけない。 - gMonitorManager.Fix(); + gMonitorManager->Fix(); // -M 起動時に表示するモニタ if (!gMainApp.monitor_opt.empty()) { @@ -187,14 +199,14 @@ WXApp::ShowMonitorsName() // モニターは登録されていれば列挙 // (登録されているものを全部列挙ではないことに注意) for (int id = ID_MONITOR_START; id <= ID_MONITOR_END; id++) { - if (gMonitorManager.Find(id)) { + if (gMonitorManager->Find(id)) { list.push_back(id); } } // サブウィンドウは機種情報から判断 for (int id = ID_SUBWIN_START; id <= ID_SUBWIN_END; id++) { - vmf_t feature = gMonitorManager.GetFeature(id); - if (gMainApp.HasVMFeature(feature)) { + VMCap vmcap = gMonitorManager->GetVMCap(id); + if (gMainApp.Has(vmcap)) { list.push_back(id); } } @@ -220,18 +232,18 @@ WXApp::SearchMonitorName(const char *nam for (int id = ID_MONITOR_START; id <= ID_SUBWIN_END; id++) { if (id < ID_SUBWIN_START) { // モニターは登録されていなければ除外する - if (gMonitorManager.Find(id) == NULL) { + if (gMonitorManager->Find(id) == NULL) { continue; } } else { // サブウィンドウは該当機種でなければ除外する - vmf_t feature = gMonitorManager.GetFeature(id); - if (gMainApp.HasVMFeature(feature) == false) { + VMCap vmcap = gMonitorManager->GetVMCap(id); + if (gMainApp.Has(vmcap) == false) { continue; } } - const auto& aliases = gMonitorManager.GetAliases(id); + const auto& aliases = gMonitorManager->GetAliases(id); bool matched = false; for (const auto& alias : aliases) {