--- nono/wx/wxdumpmonitor.cpp 2026/04/29 17:05:23 1.1.1.14 +++ nono/wx/wxdumpmonitor.cpp 2026/04/29 17:05:58 1.1.1.18 @@ -11,6 +11,8 @@ #include "wxdumpmonitor.h" #include "mainapp.h" #include "mainbus.h" +#include "monitor.h" +#include "mpu680x0.h" enum { ID_TEXT = IDGROUP_MEMDUMP, @@ -63,6 +65,7 @@ WXMemdumpWindow::WXMemdumpWindow(wxWindo // 上枠用の下敷きパネル auto *ctrlpanel = new wxPanel(this); + ctrlpanel->SetName("WXMemdumpWindow.CtrlPanel"); topsizer->Add(ctrlpanel, 0, wxEXPAND); // 上枠用の横 sizer @@ -89,12 +92,25 @@ WXMemdumpWindow::WXMemdumpWindow(wxWindo // 表示形式 (機種によって選択肢と名前が異なる) if (gMainApp.Has(VMCap::M68K)) { + auto mpu680x0 = GetMPU680x0Device(GetMPUDevice()); fmts.emplace_back(Memdump::Byte, _("Byte")); fmts.emplace_back(Memdump::Word, _("Word")); fmts.emplace_back(Memdump::Long, _("Long Word")); - fmts.emplace_back(Memdump::M68030PageShort, - _("MMU Descriptor (Short Format)")); - fmts.emplace_back(Memdump::M68030Disasm, _("68030 Disassemble")); + switch (mpu680x0->GetMPUType()) { + case m680x0MPUType::M68030: + fmts.emplace_back(Memdump::M68030PageShort, + _("MMU Descriptor (Short Format)")); + break; + case m680x0MPUType::M68040: + fmts.emplace_back(Memdump::M68040TableDesc, + _("MMU Table Descriptor")); + fmts.emplace_back(Memdump::M68040PageDesc, + _("MMU Page Descriptor")); + break; + default: + break; + } + fmts.emplace_back(Memdump::M680x0Disasm, _("680x0 Disassemble")); } else { fmts.emplace_back(Memdump::Byte, _("Byte")); fmts.emplace_back(Memdump::Word, _("Half Word")); @@ -125,20 +141,19 @@ WXMemdumpWindow::WXMemdumpWindow(wxWindo SetSizer(topsizer); + // 自前レイアウト。 + SetMyLayout(); + // ウィンドウサイズを確定させる - fixed_height = ctrlbox->GetSize().y; FontChanged(); - DoSize(); // パネルに来るマウスイベントをこっちに回す - screen->Connect(wxEVT_MOUSEWHEEL, - wxMouseEventHandler(WXMemdumpWindow::OnMouseWheel), NULL, this); - screen->Connect(wxEVT_LEFT_DCLICK, - wxMouseEventHandler(WXMemdumpWindow::OnDClick), NULL, this); + screen->Bind(wxEVT_MOUSEWHEEL, &WXMemdumpWindow::OnMouseWheel, this); + screen->Bind(wxEVT_LEFT_DCLICK, &WXMemdumpWindow::OnDClick, this); // メモリダンプオブジェクトを取得 auto mon = screen->GetMonitor(); - memdump = dynamic_cast(mon.obj); + memdump = dynamic_cast(mon->obj); assert(memdump); // 初期値をコントロールに設定 @@ -153,30 +168,66 @@ WXMemdumpWindow::~WXMemdumpWindow() { } -bool -WXMemdumpWindow::Layout() -{ - // 縦リサイズ可能レイアウト - return LayoutTextVResize(screen, fixed_height); -} - void WXMemdumpWindow::FontChanged() { - inherited::FontChanged(); - - // 最小 24x24 にしてみる - wxSize sz(screen->GetFontWidth() * 2 + 4, - screen->GetFontHeight() + 4); - if (sz.x < 24) - sz.x = 24; - if (sz.y < 24) - sz.y = 24; for (auto *btn : buttons) { - btn->SetClientSize(sz); - btn->SetMinClientSize(sz); + // ボタンサイズを先に一旦リセット。 + btn->SetMinSize(wxSize(1, 1)); + btn->SetSize(wxSize(1, 1)); + + // 各ボタンコントロールに伝搬。 btn->FontChanged(); + + // ボタンを正方形に固定する (テキストは1文字か2文字と知っている)。 + // 押しやすくするため、最小 24x24 にしてみる。 + wxSize size = btn->GetSize(); + if (size.y < 24) { + size.y = 24; + } + size.x = size.y; + + // 勝手にベストサイズに戻らないように最小サイズごと固定する。 + btn->SetSize(size); + btn->SetMinSize(size); + } + + screen->FontChanged(); + + Fit(); +} + +bool +WXMemdumpWindow::GetMySizeHints(wxSize *newp, wxSize *minp, wxSize *maxp, + wxSize *incp) +{ + // この後の Fit() でリサイズに使われる大きさを取得。 + wxSize fitsize = GetSizer()->ComputeFittingClientSize(this); + wxSize ctrlsize = ctrlbox->ComputeFittingClientSize(this); + + // 高さの最小は (コントロールパネル分と) TextScreen 1行分にしておく。 + int min_y = ctrlsize.y + screen->GetScreenHeight(1); + int new_y = ctrlsize.y + screen->GetSize().y; + wxSize newsize(fitsize.x, new_y); + wxSize minsize(fitsize.x, min_y); + wxSize maxsize(fitsize.x, GetMaxClientSize().y); + wxSize incsize(0, screen->GetFontHeight()); + + if (newp) *newp = newsize; + if (minp) *minp = minsize; + if (maxp) *maxp = maxsize; + if (incp) *incp = incsize; + return true; +} + +bool +WXMemdumpWindow::Layout() +{ + if (MyLayout() == false) { + // Sizer 使ってるのでその処理は(さらに親に)任せる。 + BaseLayout(); } + return true; } // テキスト入力イベント @@ -348,7 +399,7 @@ WXMemdumpWindow::OnDClick(wxMouseEvent& PANIC("not supported"); break; - case Memdump::M68030Disasm: + case Memdump::M680x0Disasm: len = 2; addr = GetAddrAtDisasm(x, y, len); break;