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