--- nono/wx/wxstatuspanel.h 2026/04/29 17:04:53 1.1.1.1 +++ nono/wx/wxstatuspanel.h 2026/04/29 17:05:00 1.1.1.3 @@ -6,29 +6,29 @@ #pragma once -#include "wxheader.h" -#include "wxbmp.h" +#include "wxnono.h" +#include "wxbitmapbuf.h" #include "wxtextpanel.h" #include "scsibus.h" class Indicator; class WXStatusPanel; -// インジケータ情報 +// インジケータ情報 (基本クラス) +// クラス継承の構造をとっているが、基本的には (関数ポインタを持つ) 構造体 +// テイストで扱うほうがここでは都合がよさそう。 class Indicator { - using dispfunc_t = void (WXStatusPanel::*)(wxDC&, const Indicator&); - using dclickfunc_t = void (WXStatusPanel::*)(const Indicator&); + protected: + using dispfunc_t = void (WXStatusPanel::*)(wxDC&, const Indicator *); + using eventfunc_t = void (WXStatusPanel::*)(const Indicator *); public: - Indicator(const std::string& text_, dispfunc_t draw_, int data_) - : Indicator(text_, draw_) - { - userdata = data_; - } + Indicator() { } Indicator(const std::string& text_, dispfunc_t draw_) { text = text_; draw = draw_; } + virtual ~Indicator() = default; // 表示する文字列。 // 描画関数はこの文字列を使っても使わなくてもよいが、InitIndicators() が @@ -36,19 +36,35 @@ class Indicator // だけは揃えておくこと。 std::string text {}; - // 描画関数 + // 描画関数 (必須) dispfunc_t draw {}; - // ダブルクリックの処理関数 - dclickfunc_t dclick {}; - - // ユーザデータ (ご自由にお使いください、SCSI ID とか) - int userdata {}; + // ダブルクリックの処理関数 (必要なら) + eventfunc_t dclick {}; - // 枠の位置と大きさ (実行時に計算する) + // 枠の位置と大きさは panel.GetRect() で取得できる (実行時に計算する) wxRect rect {}; }; +// インジケータ情報 (SCSI) +class SCSIIndicator : public Indicator +{ + using inherited = Indicator; + public: + // SCSI ID + int GetId() const { return id; } + int id {}; + + // 対応するデバイス + SCSIDevice *dev {}; + + // ToolTip を表示するためのダミーパネル + wxPanel *panel {}; + + // コンテキストメニューの処理関数 (必要なら) + eventfunc_t contextmenu {}; +}; + // ステータスパネル class WXStatusPanel : public WXTextPanel { @@ -60,48 +76,52 @@ class WXStatusPanel : public WXTextPanel void SetFontSize(FontId) override; private: - void OnCreate(wxCommandEvent&); void OnClose(wxCloseEvent&); void OnShow(wxShowEvent&); void OnSize(wxSizeEvent&); void OnTimer(wxTimerEvent&); void OnPaint(wxPaintEvent&); void OnLeftDClick(wxMouseEvent&); + void OnContextMenu(wxContextMenuEvent&); + void OnSCSIMediaChanged(wxCommandEvent&); void DoSize(); bool UpdateStat(); void Draw(wxDC&); void InitIndicators(); void LayoutIndicators(); - void DrawPerf(wxDC&, const Indicator&); - void DrawSCSI(wxDC&, const Indicator&); - void DrawNet(wxDC&, const Indicator&); - void DrawPower(wxDC&, const Indicator&); - void DrawTextLED(wxDC&, const Indicator&, + void DrawPerf(wxDC&, const Indicator *); + void DrawSCSI(wxDC&, const Indicator *); + void DrawNet(wxDC&, const Indicator *); + void DrawPower(wxDC&, const Indicator *); + void DrawTextLED(wxDC&, const Indicator *, const wxColour& fg, const wxColour& bg); - void DClickPerf(const Indicator&); - void UpdateFFMark(); + void DClickPerf(const Indicator *); + void ContextMenuCD(const Indicator *); // コントロール全域のビットマップ - WXBitmap bitmap {}; - - // 高速モードアイコン - std::unique_ptr ffmark {}; + WXBitmapBuf bitmap {}; // インジケータ情報 - std::vector indicators {}; + std::vector indicators {}; // インジケータ表示用 bool ispower {}; - bool last_ispower {}; int perf_mode {}; - int last_perf_mode {}; int perf_rate {}; - int last_perf_rate {}; std::shared_ptr scsibus {}; uint8 scsi_bsy {}; - uint8 last_scsi_bsy {}; - bool net_ok {}; + bool scsi_out {}; + uint8 scsi_loaded {}; + enum { + NOT_AVAILABLE = -1, // 存在しない (Nereid なし X68k とか) + DISABLE = 0, // 存在してホスト側が無効 (driver = none) + ENABLE = 1, // 存在してホスト側が有効 + } net_ok {}; + uint64 net_tx_pkts {}; + uint64 net_rx_pkts {}; + bool net_tx_active {}; + bool net_rx_active {}; // タイマー wxTimer timer {};