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