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

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

unix.superglobalmegacorp.com

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