--- nono/wx/wxmpumonitor.cpp 2026/04/29 17:04:39 1.1.1.2 +++ nono/wx/wxmpumonitor.cpp 2026/04/29 17:05:08 1.1.1.5 @@ -4,106 +4,59 @@ // Licensed under nono-license.txt // +// +// MPU 関係のモニターウィンドウ +// + #include "wxmpumonitor.h" +#include "fontmanager.h" #include "wxtextscreen.h" #include "m88200.h" // -// CMMU キャッシュウィンドウ用のパネル -// (マウスイベントを受け取るため) +// CMMU キャッシュウィンドウ // -// イベントテーブル -wxBEGIN_EVENT_TABLE(WXCacheTextScreen, inherited) - EVT_LEFT_DOWN(WXCacheTextScreen::OnLeftDown) -wxEND_EVENT_TABLE() - // コンストラクタ -WXCacheTextScreen::WXCacheTextScreen(wxWindow *parent, IMonitor& monitor_) - : inherited(parent, monitor_) -{ - parentwindow = dynamic_cast(parent); +WXCacheWindow::WXCacheWindow(wxWindow *parent, const wxString& name, + Monitor& monitor_) + : inherited(parent, name, monitor_) +{ + // テキストスクリーンパネルに送られるマウスイベントをこちらで処理する + screen->Connect(wxEVT_LEFT_DOWN, + wxMouseEventHandler(WXCacheWindow::OnLeftDown), NULL, this); } // デストラクタ -WXCacheTextScreen::~WXCacheTextScreen() +WXCacheWindow::~WXCacheWindow() { } // マウス左クリックイベント void -WXCacheTextScreen::OnLeftDown(wxMouseEvent& event) +WXCacheWindow::OnLeftDown(wxMouseEvent& event) { const wxPoint& pos = event.GetPosition(); - // テキストの桁数、行数 - int tx = pos.x / font_width; - int ty = pos.y / font_height; - - // 親で処理 - parentwindow->DoLeftDown(tx, ty); - - event.Skip(); -} - - -// -// CMMU キャッシュウィンドウ -// - -// コンストラクタ -WXCacheWindow::WXCacheWindow(wxWindow *parent, wxWindowID id, - const wxString& name, m88200 *cmmu_) - : inherited(parent, id, name) -{ - cmmu = cmmu_; - - wxBoxSizer *topsizer = new wxBoxSizer(wxVERTICAL); - - screen = new WXCacheTextScreen(this, *this); - topsizer->Add(screen, 0, wxEXPAND | wxALL, DefaultPadding); + // テキストの桁数、行数にする + wxPoint tpos = screen->GetTextPosition(pos); + int x = tpos.x; + int y = tpos.y; - SetSizer(topsizer); - - // 大きさを固定 - Layout(); - Fit(); -} - -// デストラクタ -WXCacheWindow::~WXCacheWindow() -{ -} - -// モニターサイズ取得 -nnSize -WXCacheWindow::GetMonitorSize() -{ - return nnSize(82, 23); -} - -// モニターテキストを更新 -void -WXCacheWindow::MonitorUpdate(TextScreen& monitor) -{ - // 上半分(セット詳細) - cmmu->MonitorCacheSet(monitor, 0, setidx); - // 下半分(概要) - cmmu->MonitorCacheOverview(monitor, 6, setidx, true); -} - -// 右クリック処理 (WXCacheTextScreen::OnLeftDown から呼ばれる) -void -WXCacheWindow::DoLeftDown(int x, int y) -{ // クリックされた場所のセット番号に更新 - // (再描画は次のタイマーイベントで行われる) x -= 3; - y -= 7; - if (x >= 0 && y >= 0) { + y -= 1; + if (x >= 0 && y >= 0 && y < 16) { // セットとセットの間の空白には反応しないようにしたい if (x % 5 < 4) { - setidx = y * 16 + (x / 5); + // このモニタは userdata を現在のセット番号として使っている + int setidx = y * 16 + (x / 5); + screen->SetUserData(setidx); } } + + // 画面更新 + screen->DoRefresh(); + + event.Skip(); }