--- nono/wx/wxapp.cpp 2026/04/29 17:04:56 1.1.1.8 +++ nono/wx/wxapp.cpp 2026/04/29 17:05:08 1.1.1.11 @@ -4,25 +4,26 @@ // 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 -// イベントタイプの定義 -wxDEFINE_EVENT(WXW_EVT_HALT_NOTIFY, wxCommandEvent); - class WXApp : public wxApp { using inherited = wxApp; public: + ~WXApp() override; bool OnInit(); int OnRun() override; private: @@ -31,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() @@ -73,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: @@ -86,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()) { @@ -109,17 +118,16 @@ WXApp::OnRun() return EXIT_FAILURE; } - // VM にコールバックを登録 - gScheduler->SetPowerOffCallback(wxmainframe_poweroff_callback); - if (gMPU680x0) { - gMPU680x0->SetHaltCallback(wxmainframe_halt_callback, this); - } - // メインウィンドウ gMainFrame = new WXMainFrame(NULL); gMainFrame->Show(true); SetTopWindow(gMainFrame); + // 設定反映などの初期化 + if (!gMainFrame->Init()) { + return EXIT_FAILURE; + } + return inherited::OnRun(); } @@ -191,13 +199,13 @@ 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); + vmf_t feature = gMonitorManager->GetFeature(id); if (gMainApp.HasVMFeature(feature)) { list.push_back(id); } @@ -224,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); + vmf_t feature = gMonitorManager->GetFeature(id); if (gMainApp.HasVMFeature(feature) == false) { continue; } } - const auto& aliases = gMonitorManager.GetAliases(id); + const auto& aliases = gMonitorManager->GetAliases(id); bool matched = false; for (const auto& alias : aliases) {