--- nono/wx/wxtextscreen.cpp 2026/04/29 17:05:08 1.1.1.8 +++ nono/wx/wxtextscreen.cpp 2026/04/29 17:05:12 1.1.1.9 @@ -20,38 +20,25 @@ PRAGMA_POP_WARNINGS // イベントテーブル wxBEGIN_EVENT_TABLE(WXTextScreen, inherited) EVT_SIZE(WXTextScreen::OnSize) - EVT_TIMER(wxID_ANY, WXTextScreen::OnTimer) EVT_MENU(wxID_COPY, WXTextScreen::OnCopy) wxEND_EVENT_TABLE() // コンストラクタ -WXTextScreen::WXTextScreen(wxWindow *parent, Monitor& monitor_) +WXTextScreen::WXTextScreen(wxWindow *parent, const nnSize& screensize) : inherited(parent) - , monitor(monitor_) { pad_left = DefaultPadding; pad_top = DefaultPadding; pad_right = DefaultPadding; pad_bottom = DefaultPadding; - // モニタサイズから初期サイズを決定 - nnSize ms = monitor.GetSize(); - Init(ms.width, ms.height); + Init(screensize.width, screensize.height); FontChanged(); // コンテキストメニューイベントを動的に追加 // (コンテキストメニューを表示したくない人があとから外せるようにするため) ConnectContextMenu(); - - timer.SetOwner(this); - - // 現在の設定値を適用 - SetRate(gMainFrame->GetMonitorRate()); - - // 最初に一回描画を起こす - wxTimerEvent dummy(timer); - AddPendingEvent(dummy); } // デストラクタ @@ -63,7 +50,7 @@ WXTextScreen::~WXTextScreen() void WXTextScreen::Init(int col, int row) { - ts.Init(col, row); + screen.Init(col, row); prevbuf.resize(col * row); InvalidateText(); } @@ -75,13 +62,6 @@ WXTextScreen::InvalidateText() std::fill(prevbuf.begin(), prevbuf.end(), 0xffff); } -// 画面更新頻度を Hz で設定する。 -void -WXTextScreen::SetRate(int hz) -{ - timer.Start(1000 / hz); -} - // フォントサイズ変更 (外部インタフェース) void WXTextScreen::FontChanged() @@ -97,14 +77,14 @@ WXTextScreen::FontChanged() } // (自発的な)サイズ変更。 -// ts の行数桁数、font_{width,height}、四方のパディングのいずれかが +// screen の行数桁数、font_{width,height}、四方のパディングのいずれかが // 変わった場合に呼ぶこと。 void WXTextScreen::DoSize() { wxSize size = wxSize( - ts.GetCol() * font_width + pad_left + pad_right, - ts.GetRow() * font_height + pad_top + pad_bottom); + screen.GetCol() * font_width + pad_left + pad_right, + screen.GetRow() * font_height + pad_top + pad_bottom); SetClientSize(size); SetMinClientSize(size); } @@ -113,8 +93,8 @@ WXTextScreen::DoSize() void WXTextScreen::OnSize(wxSizeEvent& event) { - // Mac ではウィンドウ作成時に 0 以下の値が来ることがある - // GTK では 1 で来ることがある + // Mac ではウィンドウ作成時に 0 以下の値が来ることがある。 + // GTK では 1 で来ることがある。 const wxSize& size = event.GetSize(); if (size.x <= 1 || size.y <= 1) { return; @@ -136,7 +116,7 @@ WXTextScreen::OnSize(wxSizeEvent& event) } int col = sw / font_width; int row = sh / font_height; - if (col != ts.GetCol() || row != ts.GetRow()) { + if (col != screen.GetCol() || row != screen.GetRow()) { Init(col, row); } else { // テキストバッファを再構成しなくても全域を再描画する必要がある @@ -144,37 +124,15 @@ WXTextScreen::OnSize(wxSizeEvent& event) } } -// タイマーイベント -void -WXTextScreen::OnTimer(wxTimerEvent& event) -{ - DoRefresh(); -} - -// 画面を更新して再描画する。 -// -// 通常はタイマーイベントにより更新間隔ごとに呼ばれるが、 -// ユーザ操作により画面の更新が必要ならその都度直接これを呼ぶ。 -void -WXTextScreen::DoRefresh() -{ - // モニタースクリーンを更新して - MONITOR_UPDATE(monitor, ts); - // 必要なら再描画 - if (ts.GetBuf() != prevbuf) { - Refresh(); - } -} - // テキストバッファの内容をパネルのバックグラウンドバッファに描画する。 void WXTextScreen::Draw() { - auto text = ts.GetBuf().begin(); + auto text = screen.GetBuf().begin(); auto prev = prevbuf.begin(); - int col = ts.GetCol(); - int row = ts.GetRow(); + int col = screen.GetCol(); + int row = screen.GetRow(); uint prevattr = (uint)-1; int py = pad_top; @@ -308,10 +266,10 @@ WXTextScreen::OnContextMenu(wxContextMen void WXTextScreen::OnCopy(wxCommandEvent& ev) { - int col = ts.GetCol(); - int row = ts.GetRow(); + int col = screen.GetCol(); + int row = screen.GetRow(); - const std::vector& src = ts.GetBuf(); + const std::vector& src = screen.GetBuf(); auto s = src.begin(); std::vector buf;