Annotation of nono/wx/wxstatuspanel.h, revision 1.1.1.5

1.1       root        1: //
                      2: // nono
                      3: // Copyright (C) 2021 nono project
                      4: // Licensed under nono-license.txt
                      5: //
                      6: 
1.1.1.4   root        7: //
                      8: // ステータスパネル
                      9: //
                     10: 
1.1       root       11: #pragma once
                     12: 
                     13: #include "wxtextpanel.h"
1.1.1.5 ! root       14: #include "fdd.h"
1.1       root       15: #include "scsibus.h"
1.1.1.5 ! root       16: #include <array>
1.1       root       17: 
                     18: class Indicator;
1.1.1.4   root       19: class HostNetDevice;
1.1       root       20: class WXStatusPanel;
                     21: 
1.1.1.5 ! root       22: // インジケータ情報 (ほぼ構造体)
1.1       root       23: class Indicator
                     24: {
1.1.1.5 ! root       25:  public:
        !            26:        // インジケータの識別子
        !            27:        enum {
        !            28:                NONE = 0,
        !            29:                PERF,
        !            30:                POWER,
        !            31:                SCSI0,
        !            32:                SCSI1,
        !            33:                SCSI2,
        !            34:                SCSI3,
        !            35:                SCSI4,
        !            36:                SCSI5,
        !            37:                SCSI6,
        !            38:                SCSI7,
        !            39:                LAN,
        !            40:                FDD0,
        !            41:                FDD1,
        !            42:                FDD2,
        !            43:                FDD3,
        !            44:        };
1.1.1.3   root       45:  protected:
1.1.1.4   root       46:        using dispfunc_t = void (WXStatusPanel::*)(const Indicator *);
1.1.1.3   root       47:        using eventfunc_t = void (WXStatusPanel::*)(const Indicator *);
1.1       root       48:  public:
1.1.1.3   root       49:        Indicator() { }
1.1.1.5 ! root       50:        Indicator(int id_, int minlen_, dispfunc_t draw_) {
        !            51:                id = id_;
        !            52:                minlen = minlen_;
1.1       root       53:                draw = draw_;
                     54:        }
1.1.1.3   root       55:        virtual ~Indicator() = default;
1.1       root       56: 
1.1.1.5 ! root       57:        // インジケータ識別子
        !            58:        int id {};
        !            59: 
        !            60:        // 枠内の最小文字列長。
        !            61:        // 枠の大きさはこの文字列長と text.length() の長いほうで描画される。
        !            62:        int minlen {};
        !            63: 
1.1       root       64:        // 表示する文字列。
                     65:        std::string text {};
                     66: 
1.1.1.3   root       67:        // 描画関数 (必須)
1.1       root       68:        dispfunc_t draw {};
                     69: 
1.1.1.3   root       70:        // ダブルクリックの処理関数 (必要なら)
                     71:        eventfunc_t dclick {};
1.1       root       72: 
1.1.1.5 ! root       73:        // コンテキストメニューの処理関数 (必要なら)
        !            74:        eventfunc_t contextmenu {};
1.1.1.3   root       75: 
1.1.1.5 ! root       76:        // 対応するデバイス (必要なら)
        !            77:        Device *dev {};
1.1.1.3   root       78: 
                     79:        // ToolTip を表示するためのダミーパネル
                     80:        wxPanel *panel {};
                     81: 
1.1.1.5 ! root       82:        // 枠の位置と大きさは panel.GetRect() で取得できる (実行時に計算する)
        !            83:        Rect rect {};
        !            84: 
        !            85:  public:
        !            86:        // SCSI なら SCSI ID を返す。そうでなければ -1 を返す。
        !            87:        int GetSCSIID() const;
        !            88: 
        !            89:        // FDD ならユニット番号を返す。そうでなければ -1 を返す。
        !            90:        int GetFDUnit() const;
1.1.1.3   root       91: };
                     92: 
1.1       root       93: // ステータスパネル
                     94: class WXStatusPanel : public WXTextPanel
                     95: {
                     96:        using inherited = WXTextPanel;
                     97:  public:
                     98:        WXStatusPanel(wxWindow *parent);
                     99:        virtual ~WXStatusPanel() override;
                    100: 
1.1.1.4   root      101:        void FontChanged() override;
1.1       root      102: 
                    103:  private:
                    104:        void OnClose(wxCloseEvent&);
                    105:        void OnShow(wxShowEvent&);
                    106:        void OnSize(wxSizeEvent&);
                    107:        void OnTimer(wxTimerEvent&);
                    108:        void OnLeftDClick(wxMouseEvent&);
1.1.1.3   root      109:        void OnContextMenu(wxContextMenuEvent&);
                    110:        void OnSCSIMediaChanged(wxCommandEvent&);
1.1.1.5 ! root      111:        void OnFDDMediaChanged(wxCommandEvent&);
        !           112:        void OnLEDChanged(wxCommandEvent&);
1.1       root      113: 
                    114:        bool UpdateStat();
1.1.1.4   root      115:        void Draw() override;
1.1       root      116:        void InitIndicators();
                    117:        void LayoutIndicators();
1.1.1.4   root      118:        void DrawPerf(const Indicator *);
                    119:        void DrawSCSI(const Indicator *);
                    120:        void DrawNet(const Indicator *);
1.1.1.5 ! root      121:        void DrawFD(const Indicator *);
1.1.1.4   root      122:        void DrawPower(const Indicator *);
                    123:        void DrawTextLED(const Indicator *, Color fg, Color bg);
1.1.1.3   root      124:        void DClickPerf(const Indicator *);
                    125:        void ContextMenuCD(const Indicator *);
1.1.1.5 ! root      126:        void ContextMenuFD(const Indicator *);
1.1       root      127: 
                    128:        // インジケータ情報
1.1.1.3   root      129:        std::vector<Indicator*> indicators {};
1.1       root      130: 
                    131:        // インジケータ表示用
                    132:        bool ispower {};
1.1.1.5 ! root      133:        bool powerled {};
1.1       root      134:        int perf_mode {};
                    135:        int perf_rate {};
                    136:        std::shared_ptr<SCSIBus> scsibus {};
                    137:        uint8 scsi_bsy {};
1.1.1.2   root      138:        bool scsi_out {};
1.1.1.3   root      139:        uint8 scsi_loaded {};
1.1.1.2   root      140:        enum {
                    141:                NOT_AVAILABLE = -1,     // 存在しない (Nereid なし X68k とか)
                    142:                DISABLE = 0,            // 存在してホスト側が無効 (driver = none)
                    143:                ENABLE = 1,                     // 存在してホスト側が有効
                    144:        } net_ok {};
1.1.1.4   root      145:        HostNetDevice *hostnet {};
1.1.1.2   root      146:        uint64 net_tx_pkts {};
                    147:        uint64 net_rx_pkts {};
                    148:        bool net_tx_active {};
                    149:        bool net_rx_active {};
1.1.1.5 ! root      150:        std::array<bool, 4> fd_loaded {};
        !           151:        std::array<FDDDevice::LED, 4> fd_access_led {};
        !           152:        std::array<bool, 4> fd_eject_led {};
        !           153: 
        !           154:        // 背景再描画
        !           155:        bool refresh_background {};
1.1       root      156: 
                    157:        // タイマー
                    158:        wxTimer timer {};
                    159: 
                    160:        // イベントテーブル
                    161:        wxDECLARE_EVENT_TABLE();
1.1.1.5 ! root      162: 
        !           163:        static const uint8 AccessMark12[];
        !           164:        static const uint8 AccessMark16[];
1.1       root      165: };
                    166: 
                    167: extern WXStatusPanel *gStatusPanel;

unix.superglobalmegacorp.com

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