--- nono/wx/wxmpumonitor.cpp 2026/04/29 17:04:37 1.1.1.1 +++ nono/wx/wxmpumonitor.cpp 2026/04/29 17:05:31 1.1.1.8 @@ -4,83 +4,24 @@ // Licensed under nono-license.txt // -#include "wxmpumonitor.h" -#include "wxtextscreen.h" -#include "m88200.h" - // -// CMMU キャッシュウィンドウ用のパネル -// (マウスイベントを受け取るため) +// MPU 関係のモニターウィンドウ // -// イベントテーブル -wxBEGIN_EVENT_TABLE(WXCacheTextScreen, inherited) - EVT_LEFT_DOWN(WXCacheTextScreen::OnLeftDown) -wxEND_EVENT_TABLE() - -// コンストラクタ -WXCacheTextScreen::WXCacheTextScreen(wxWindow *parent, int col_, int row_, - const uint16 *textbuf_) - : inherited(parent, col_, row_, textbuf_) -{ - parentwindow = dynamic_cast(parent); -} - -// デストラクタ -WXCacheTextScreen::~WXCacheTextScreen() -{ -} - -// マウス左クリックイベント -void -WXCacheTextScreen::OnLeftDown(wxMouseEvent& event) -{ - wxPoint pos = event.GetPosition(); - - // テキストの桁数、行数 - int tx = pos.x / font_width; - int ty = pos.y / font_height; - - // 親で処理 - parentwindow->DoLeftDown(tx, ty); - - event.Skip(); -} - +#include "wxmpumonitor.h" // // CMMU キャッシュウィンドウ // -// イベントテーブル -wxBEGIN_EVENT_TABLE(WXCacheWindow, inherited) - EVT_TIMER(wxID_ANY, WXCacheWindow::OnTimer) -wxEND_EVENT_TABLE() - // コンストラクタ -WXCacheWindow::WXCacheWindow(wxWindow *parent, wxWindowID id, - const wxString& name, m88200 *cmmu_) - : inherited(parent, id, name) -{ - cmmu = cmmu_; - - wxBoxSizer *topsizer = new wxBoxSizer(wxVERTICAL); - - col = 82; - row = 23; - monitor.Init(col, row); - screen = new WXCacheTextScreen(this, col, row, monitor.GetBuf()); - topsizer->Add(screen, BorderFlags); - - SetSizer(topsizer); - - // 大きさを固定 - Layout(); - Fit(); - - // 更新タイマーは適当 - timer.SetOwner(this); - timer.Start(33); +WXCacheWindow::WXCacheWindow(wxWindow *parent, const wxString& name, + Monitor *monitor_) + : inherited(parent, name, monitor_) +{ + // モニタパネルに送られるマウスイベントをこちらで処理する + monpanel->Connect(wxEVT_LEFT_DOWN, + wxMouseEventHandler(WXCacheWindow::OnLeftDown), NULL, this); } // デストラクタ @@ -88,41 +29,31 @@ WXCacheWindow::~WXCacheWindow() { } -// タイマーイベント +// マウス左クリックイベント void -WXCacheWindow::OnTimer(wxTimerEvent& event) +WXCacheWindow::OnLeftDown(wxMouseEvent& event) { - // 上半分(セット詳細) - cmmu->MonitorCacheSet(monitor, 0, setidx); - // 下半分(概要) - cmmu->MonitorCacheOverview(monitor, 6, setidx, true); + const wxPoint& pos = event.GetPosition(); - // 再描画 - screen->Refresh(); -} + // テキストの桁数、行数にする + wxPoint tpos = monpanel->GetTextPosition(pos); + int x = tpos.x; + int y = tpos.y; -// フォントサイズ変更 -void -WXCacheWindow::SetFontSize(fontsize_t fontsize) -{ - screen->SetFontSize(fontsize); - // 大きさを変更 - Layout(); - Fit(); -} - -// 右クリック処理 (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); + monpanel->SetUserData(setidx); } } + + // 画面更新 + monpanel->DoRefresh(); + + event.Skip(); }