--- nono/wx/wxdumpmonitor.cpp 2026/04/29 17:05:31 1.1.1.15 +++ nono/wx/wxdumpmonitor.cpp 2026/04/29 17:05:44 1.1.1.16 @@ -142,9 +142,7 @@ WXMemdumpWindow::WXMemdumpWindow(wxWindo SetSizer(topsizer); // ウィンドウサイズを確定させる - fixed_height = ctrlbox->GetSize().y; FontChanged(); - DoSize(); // パネルに来るマウスイベントをこっちに回す screen->Connect(wxEVT_MOUSEWHEEL, @@ -169,30 +167,93 @@ WXMemdumpWindow::~WXMemdumpWindow() { } -bool -WXMemdumpWindow::Layout() +void +WXMemdumpWindow::FontChanged() { - // 縦リサイズ可能レイアウト - return LayoutTextVResize(screen, fixed_height); + for (auto *btn : buttons) { + // ボタンサイズを先に一旦リセット。 + 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(); } void -WXMemdumpWindow::FontChanged() +WXMemdumpWindow::Fit() { - inherited::FontChanged(); + // inherited::Fit() は呼ばずに自力で行う。 - // 最小 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->FontChanged(); + wxSize newsize = DoSizeHints(); + SetClientSize(newsize); +} + +bool +WXMemdumpWindow::Layout() +{ + // wxmonitor.cpp の WXScrollMonitorWindow::Layout() のコメント参照。 + wxSize client = GetClientSize(); + const wxSize win = GetSize(); + const wxSize margin = win - client; + const wxSize ctrlsize = ctrlbox->GetSize(); + const wxSize monsize = screen->GetSize(); + + if (oldmargin != margin) { + layout_pass2 = true; + oldmargin = margin; + CallAfter([this]() { + DoSizeHints(); + }); + return true; + } else if (layout_pass2) { + layout_pass2 = false; + client.y = ctrlsize.y + monsize.y; + SetClientSize(client); + Hide(); + Show(); + return true; } + + // Sizer 使ってるのでその処理は任せる。 + return inherited::Layout(); +} + +// クライアントサイズと最大/最小サイズを計算する。 +// SetSizeHints() を実行し、設定すべきクライアントサイズを返す。 +wxSize +WXMemdumpWindow::DoSizeHints() +{ + // この後の 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 minsize(fitsize.x, min_y); + wxSize maxsize(fitsize.x, GetMaxClientSize().y); + wxSize incsize(0, screen->GetFontHeight()); + SetSizeHints(ClientToWindowSize(minsize), ClientToWindowSize(maxsize), + incsize); + + return wxSize(fitsize.x, new_y); } // テキスト入力イベント