--- nono/wx/wxmpumonitor.cpp 2026/04/29 17:04:39 1.1.1.2 +++ nono/wx/wxmpumonitor.cpp 2026/04/29 17:05:31 1.1.1.8 @@ -4,70 +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, IMonitor& monitor_) - : inherited(parent, monitor_) -{ - parentwindow = dynamic_cast(parent); -} - -// デストラクタ -WXCacheTextScreen::~WXCacheTextScreen() -{ -} - -// マウス左クリックイベント -void -WXCacheTextScreen::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(); -} - +#include "wxmpumonitor.h" // // 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); - - SetSizer(topsizer); - - // 大きさを固定 - Layout(); - Fit(); +WXCacheWindow::WXCacheWindow(wxWindow *parent, const wxString& name, + Monitor *monitor_) + : inherited(parent, name, monitor_) +{ + // モニタパネルに送られるマウスイベントをこちらで処理する + monpanel->Connect(wxEVT_LEFT_DOWN, + wxMouseEventHandler(WXCacheWindow::OnLeftDown), NULL, this); } // デストラクタ @@ -75,35 +29,31 @@ WXCacheWindow::~WXCacheWindow() { } -// モニターサイズ取得 -nnSize -WXCacheWindow::GetMonitorSize() -{ - return nnSize(82, 23); -} - -// モニターテキストを更新 +// マウス左クリックイベント void -WXCacheWindow::MonitorUpdate(TextScreen& monitor) +WXCacheWindow::OnLeftDown(wxMouseEvent& event) { - // 上半分(セット詳細) - cmmu->MonitorCacheSet(monitor, 0, setidx); - // 下半分(概要) - cmmu->MonitorCacheOverview(monitor, 6, setidx, true); -} + const wxPoint& pos = event.GetPosition(); + + // テキストの桁数、行数にする + wxPoint tpos = monpanel->GetTextPosition(pos); + int x = tpos.x; + int y = tpos.y; -// 右クリック処理 (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(); }