|
|
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"
14: #include "scsibus.h"
15:
16: class Indicator;
1.1.1.4 ! root 17: class HostNetDevice;
1.1 root 18: class WXStatusPanel;
19:
1.1.1.3 root 20: // インジケータ情報 (基本クラス)
21: // クラス継承の構造をとっているが、基本的には (関数ポインタを持つ) 構造体
22: // テイストで扱うほうがここでは都合がよさそう。
1.1 root 23: class Indicator
24: {
1.1.1.3 root 25: protected:
1.1.1.4 ! root 26: using dispfunc_t = void (WXStatusPanel::*)(const Indicator *);
1.1.1.3 root 27: using eventfunc_t = void (WXStatusPanel::*)(const Indicator *);
1.1 root 28: public:
1.1.1.3 root 29: Indicator() { }
1.1 root 30: Indicator(const std::string& text_, dispfunc_t draw_) {
31: text = text_;
32: draw = draw_;
33: }
1.1.1.3 root 34: virtual ~Indicator() = default;
1.1 root 35:
36: // 表示する文字列。
37: // 描画関数はこの文字列を使っても使わなくてもよいが、InitIndicators() が
38: // この文字数に応じた大きさの枠を用意するため、使わない場合でも文字数
39: // だけは揃えておくこと。
40: std::string text {};
41:
1.1.1.3 root 42: // 描画関数 (必須)
1.1 root 43: dispfunc_t draw {};
44:
1.1.1.3 root 45: // ダブルクリックの処理関数 (必要なら)
46: eventfunc_t dclick {};
1.1 root 47:
1.1.1.3 root 48: // 枠の位置と大きさは panel.GetRect() で取得できる (実行時に計算する)
1.1.1.4 ! root 49: Rect rect {};
1.1 root 50: };
51:
1.1.1.3 root 52: // インジケータ情報 (SCSI)
53: class SCSIIndicator : public Indicator
54: {
55: using inherited = Indicator;
56: public:
57: // SCSI ID
58: int GetId() const { return id; }
59: int id {};
60:
61: // 対応するデバイス
62: SCSIDevice *dev {};
63:
64: // ToolTip を表示するためのダミーパネル
65: wxPanel *panel {};
66:
67: // コンテキストメニューの処理関数 (必要なら)
68: eventfunc_t contextmenu {};
69: };
70:
1.1 root 71: // ステータスパネル
72: class WXStatusPanel : public WXTextPanel
73: {
74: using inherited = WXTextPanel;
75: public:
76: WXStatusPanel(wxWindow *parent);
77: virtual ~WXStatusPanel() override;
78:
1.1.1.4 ! root 79: void FontChanged() override;
1.1 root 80:
81: private:
82: void OnClose(wxCloseEvent&);
83: void OnShow(wxShowEvent&);
84: void OnSize(wxSizeEvent&);
85: void OnTimer(wxTimerEvent&);
86: void OnLeftDClick(wxMouseEvent&);
1.1.1.3 root 87: void OnContextMenu(wxContextMenuEvent&);
88: void OnSCSIMediaChanged(wxCommandEvent&);
1.1 root 89:
90: bool UpdateStat();
1.1.1.4 ! root 91: void Draw() override;
1.1 root 92: void InitIndicators();
93: void LayoutIndicators();
1.1.1.4 ! root 94: void DrawPerf(const Indicator *);
! 95: void DrawSCSI(const Indicator *);
! 96: void DrawNet(const Indicator *);
! 97: void DrawPower(const Indicator *);
! 98: void DrawTextLED(const Indicator *, Color fg, Color bg);
1.1.1.3 root 99: void DClickPerf(const Indicator *);
100: void ContextMenuCD(const Indicator *);
1.1 root 101:
102: // インジケータ情報
1.1.1.3 root 103: std::vector<Indicator*> indicators {};
1.1 root 104:
105: // インジケータ表示用
106: bool ispower {};
107: int perf_mode {};
108: int perf_rate {};
109: std::shared_ptr<SCSIBus> scsibus {};
110: uint8 scsi_bsy {};
1.1.1.2 root 111: bool scsi_out {};
1.1.1.3 root 112: uint8 scsi_loaded {};
1.1.1.2 root 113: enum {
114: NOT_AVAILABLE = -1, // 存在しない (Nereid なし X68k とか)
115: DISABLE = 0, // 存在してホスト側が無効 (driver = none)
116: ENABLE = 1, // 存在してホスト側が有効
117: } net_ok {};
1.1.1.4 ! root 118: HostNetDevice *hostnet {};
1.1.1.2 root 119: uint64 net_tx_pkts {};
120: uint64 net_rx_pkts {};
121: bool net_tx_active {};
122: bool net_rx_active {};
1.1 root 123:
124: // タイマー
125: wxTimer timer {};
126:
127: // イベントテーブル
128: wxDECLARE_EVENT_TABLE();
129: };
130:
131: extern WXStatusPanel *gStatusPanel;
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.