|
|
1.1 ! root 1: // ! 2: // nono ! 3: // Copyright (C) 2020 nono project ! 4: // Licensed under nono-license.txt ! 5: // ! 6: ! 7: #include "wxmpumonitor.h" ! 8: #include "wxtextscreen.h" ! 9: #include "m88200.h" ! 10: ! 11: // ! 12: // CMMU キャッシュウィンドウ用のパネル ! 13: // (マウスイベントを受け取るため) ! 14: // ! 15: ! 16: // イベントテーブル ! 17: wxBEGIN_EVENT_TABLE(WXCacheTextScreen, inherited) ! 18: EVT_LEFT_DOWN(WXCacheTextScreen::OnLeftDown) ! 19: wxEND_EVENT_TABLE() ! 20: ! 21: // コンストラクタ ! 22: WXCacheTextScreen::WXCacheTextScreen(wxWindow *parent, int col_, int row_, ! 23: const uint16 *textbuf_) ! 24: : inherited(parent, col_, row_, textbuf_) ! 25: { ! 26: parentwindow = dynamic_cast<WXCacheWindow*>(parent); ! 27: } ! 28: ! 29: // デストラクタ ! 30: WXCacheTextScreen::~WXCacheTextScreen() ! 31: { ! 32: } ! 33: ! 34: // マウス左クリックイベント ! 35: void ! 36: WXCacheTextScreen::OnLeftDown(wxMouseEvent& event) ! 37: { ! 38: wxPoint pos = event.GetPosition(); ! 39: ! 40: // テキストの桁数、行数 ! 41: int tx = pos.x / font_width; ! 42: int ty = pos.y / font_height; ! 43: ! 44: // 親で処理 ! 45: parentwindow->DoLeftDown(tx, ty); ! 46: ! 47: event.Skip(); ! 48: } ! 49: ! 50: ! 51: // ! 52: // CMMU キャッシュウィンドウ ! 53: // ! 54: ! 55: // イベントテーブル ! 56: wxBEGIN_EVENT_TABLE(WXCacheWindow, inherited) ! 57: EVT_TIMER(wxID_ANY, WXCacheWindow::OnTimer) ! 58: wxEND_EVENT_TABLE() ! 59: ! 60: // コンストラクタ ! 61: WXCacheWindow::WXCacheWindow(wxWindow *parent, wxWindowID id, ! 62: const wxString& name, m88200 *cmmu_) ! 63: : inherited(parent, id, name) ! 64: { ! 65: cmmu = cmmu_; ! 66: ! 67: wxBoxSizer *topsizer = new wxBoxSizer(wxVERTICAL); ! 68: ! 69: col = 82; ! 70: row = 23; ! 71: monitor.Init(col, row); ! 72: screen = new WXCacheTextScreen(this, col, row, monitor.GetBuf()); ! 73: topsizer->Add(screen, BorderFlags); ! 74: ! 75: SetSizer(topsizer); ! 76: ! 77: // 大きさを固定 ! 78: Layout(); ! 79: Fit(); ! 80: ! 81: // 更新タイマーは適当 ! 82: timer.SetOwner(this); ! 83: timer.Start(33); ! 84: } ! 85: ! 86: // デストラクタ ! 87: WXCacheWindow::~WXCacheWindow() ! 88: { ! 89: } ! 90: ! 91: // タイマーイベント ! 92: void ! 93: WXCacheWindow::OnTimer(wxTimerEvent& event) ! 94: { ! 95: // 上半分(セット詳細) ! 96: cmmu->MonitorCacheSet(monitor, 0, setidx); ! 97: // 下半分(概要) ! 98: cmmu->MonitorCacheOverview(monitor, 6, setidx, true); ! 99: ! 100: // 再描画 ! 101: screen->Refresh(); ! 102: } ! 103: ! 104: // フォントサイズ変更 ! 105: void ! 106: WXCacheWindow::SetFontSize(fontsize_t fontsize) ! 107: { ! 108: screen->SetFontSize(fontsize); ! 109: // 大きさを変更 ! 110: Layout(); ! 111: Fit(); ! 112: } ! 113: ! 114: // 右クリック処理 (WXCacheTextScreen::OnLeftDown から呼ばれる) ! 115: void ! 116: WXCacheWindow::DoLeftDown(int x, int y) ! 117: { ! 118: // クリックされた場所のセット番号に更新 ! 119: // (再描画は次のタイマーイベントで行われる) ! 120: x -= 3; ! 121: y -= 7; ! 122: if (x >= 0 && y >= 0) { ! 123: // セットとセットの間の空白には反応しないようにしたい ! 124: if (x % 5 < 4) { ! 125: setidx = y * 16 + (x / 5); ! 126: } ! 127: } ! 128: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.