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

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

unix.superglobalmegacorp.com

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