|
|
1.1 root 1: //
2: // nono
3: // Copyright (C) 2021 nono project
4: // Licensed under nono-license.txt
5: //
6:
7: #pragma once
8:
9: #include "wxheader.h"
10: #include "wxbmp.h"
11: #include "wxtextpanel.h"
12: #include "scsibus.h"
13:
14: class Indicator;
15: class WXStatusPanel;
16:
17: // インジケータ情報
18: class Indicator
19: {
20: using dispfunc_t = void (WXStatusPanel::*)(wxDC&, const Indicator&);
21: using dclickfunc_t = void (WXStatusPanel::*)(const Indicator&);
22: public:
23: Indicator(const std::string& text_, dispfunc_t draw_, int data_)
24: : Indicator(text_, draw_)
25: {
26: userdata = data_;
27: }
28: Indicator(const std::string& text_, dispfunc_t draw_) {
29: text = text_;
30: draw = draw_;
31: }
32:
33: // 表示する文字列。
34: // 描画関数はこの文字列を使っても使わなくてもよいが、InitIndicators() が
35: // この文字数に応じた大きさの枠を用意するため、使わない場合でも文字数
36: // だけは揃えておくこと。
37: std::string text {};
38:
39: // 描画関数
40: dispfunc_t draw {};
41:
42: // ダブルクリックの処理関数
43: dclickfunc_t dclick {};
44:
45: // ユーザデータ (ご自由にお使いください、SCSI ID とか)
46: int userdata {};
47:
48: // 枠の位置と大きさ (実行時に計算する)
49: wxRect rect {};
50: };
51:
52: // ステータスパネル
53: class WXStatusPanel : public WXTextPanel
54: {
55: using inherited = WXTextPanel;
56: public:
57: WXStatusPanel(wxWindow *parent);
58: virtual ~WXStatusPanel() override;
59:
60: void SetFontSize(FontId) override;
61:
62: private:
63: void OnCreate(wxCommandEvent&);
64: void OnClose(wxCloseEvent&);
65: void OnShow(wxShowEvent&);
66: void OnSize(wxSizeEvent&);
67: void OnTimer(wxTimerEvent&);
68: void OnPaint(wxPaintEvent&);
69: void OnLeftDClick(wxMouseEvent&);
70:
71: void DoSize();
72: bool UpdateStat();
73: void Draw(wxDC&);
74: void InitIndicators();
75: void LayoutIndicators();
76: void DrawPerf(wxDC&, const Indicator&);
77: void DrawSCSI(wxDC&, const Indicator&);
78: void DrawNet(wxDC&, const Indicator&);
79: void DrawPower(wxDC&, const Indicator&);
80: void DrawTextLED(wxDC&, const Indicator&,
81: const wxColour& fg, const wxColour& bg);
82: void DClickPerf(const Indicator&);
83: void UpdateFFMark();
84:
85: // コントロール全域のビットマップ
86: WXBitmap bitmap {};
87:
88: // 高速モードアイコン
89: std::unique_ptr<wxBitmap> ffmark {};
90:
91: // インジケータ情報
92: std::vector<Indicator> indicators {};
93:
94: // インジケータ表示用
95: bool ispower {};
96: bool last_ispower {};
97: int perf_mode {};
98: int last_perf_mode {};
99: int perf_rate {};
100: int last_perf_rate {};
101: std::shared_ptr<SCSIBus> scsibus {};
102: uint8 scsi_bsy {};
103: uint8 last_scsi_bsy {};
104: bool net_ok {};
105:
106: // タイマー
107: wxTimer timer {};
108:
109: // イベントテーブル
110: wxDECLARE_EVENT_TABLE();
111: };
112:
113: extern WXStatusPanel *gStatusPanel;
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.