Annotation of nono/wx/wxmpumonitor.cpp, revision 1.1.1.3

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: // コンストラクタ
1.1.1.2   root       22: WXCacheTextScreen::WXCacheTextScreen(wxWindow *parent, IMonitor& monitor_)
                     23:        : inherited(parent, monitor_)
1.1       root       24: {
                     25:        parentwindow = dynamic_cast<WXCacheWindow*>(parent);
                     26: }
                     27: 
                     28: // デストラクタ
                     29: WXCacheTextScreen::~WXCacheTextScreen()
                     30: {
                     31: }
                     32: 
                     33: // マウス左クリックイベント
                     34: void
                     35: WXCacheTextScreen::OnLeftDown(wxMouseEvent& event)
                     36: {
1.1.1.2   root       37:        const wxPoint& pos = event.GetPosition();
1.1       root       38: 
                     39:        // テキストの桁数、行数
                     40:        int tx = pos.x / font_width;
                     41:        int ty = pos.y / font_height;
                     42: 
                     43:        // 親で処理
                     44:        parentwindow->DoLeftDown(tx, ty);
                     45: 
                     46:        event.Skip();
                     47: }
                     48: 
                     49: 
                     50: //
                     51: // CMMU キャッシュウィンドウ
                     52: //
                     53: 
                     54: // コンストラクタ
                     55: WXCacheWindow::WXCacheWindow(wxWindow *parent, wxWindowID id,
                     56:        const wxString& name, m88200 *cmmu_)
                     57:        : inherited(parent, id, name)
                     58: {
                     59:        cmmu = cmmu_;
                     60: 
1.1.1.3 ! root       61:        // top
        !            62:        // | +----------------------------+
        !            63:        // v |           上余白           |
        !            64:        //   |+------+------------+------+|
        !            65:        //   ||左余白| TextScreen |右余白||
        !            66:        //   |+------+------------+------+|
        !            67:        //   |           下余白           |
        !            68:        //   +----------------------------+
1.1       root       69:        wxBoxSizer *topsizer = new wxBoxSizer(wxVERTICAL);
                     70: 
1.1.1.3 ! root       71:        // 上余白
        !            72:        topsizer->Add(new WXPaddingPanel(this), 0, wxEXPAND);
        !            73: 
        !            74:        // 中段(横sizer)
        !            75:        wxBoxSizer *hbox = new wxBoxSizer(wxHORIZONTAL);
        !            76:        topsizer->Add(hbox, 0, wxEXPAND);
        !            77: 
        !            78:        // 左余白
        !            79:        hbox->Add(new WXPaddingPanel(this), 0, wxEXPAND);
        !            80: 
        !            81:        // テキストスクリーン
1.1.1.2   root       82:        screen = new WXCacheTextScreen(this, *this);
1.1.1.3 ! root       83:        hbox->Add(screen, 0, wxEXPAND);
        !            84: 
        !            85:        // 右余白
        !            86:        hbox->Add(new WXPaddingPanel(this), 0, wxEXPAND);
        !            87: 
        !            88:        // 下余白
        !            89:        topsizer->Add(new WXPaddingPanel(this), 0, wxEXPAND);
1.1       root       90: 
                     91:        SetSizer(topsizer);
                     92: 
                     93:        // 大きさを固定
                     94:        Fit();
                     95: }
                     96: 
                     97: // デストラクタ
                     98: WXCacheWindow::~WXCacheWindow()
                     99: {
                    100: }
                    101: 
1.1.1.2   root      102: // モニターサイズ取得
                    103: nnSize
                    104: WXCacheWindow::GetMonitorSize()
                    105: {
                    106:        return nnSize(82, 23);
                    107: }
                    108: 
                    109: // モニターテキストを更新
1.1       root      110: void
1.1.1.2   root      111: WXCacheWindow::MonitorUpdate(TextScreen& monitor)
1.1       root      112: {
                    113:        // 上半分(セット詳細)
                    114:        cmmu->MonitorCacheSet(monitor, 0, setidx);
                    115:        // 下半分(概要)
                    116:        cmmu->MonitorCacheOverview(monitor, 6, setidx, true);
                    117: }
                    118: 
                    119: // 右クリック処理 (WXCacheTextScreen::OnLeftDown から呼ばれる)
                    120: void
                    121: WXCacheWindow::DoLeftDown(int x, int y)
                    122: {
                    123:        // クリックされた場所のセット番号に更新
                    124:        // (再描画は次のタイマーイベントで行われる)
                    125:        x -= 3;
                    126:        y -= 7;
                    127:        if (x >= 0 && y >= 0) {
                    128:                // セットとセットの間の空白には反応しないようにしたい
                    129:                if (x % 5 < 4) {
                    130:                        setidx = y * 16 + (x / 5);
                    131:                }
                    132:        }
                    133: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.