--- nono/wx/wxstatuspanel.h 2026/04/29 17:05:08 1.1.1.4 +++ nono/wx/wxstatuspanel.h 2026/04/29 17:05:16 1.1.1.6 @@ -11,32 +11,67 @@ #pragma once #include "wxtextpanel.h" +#include "fdd.h" #include "scsibus.h" +#include -class Indicator; class HostNetDevice; +class Indicator; +class NewsCtlrDevice; +class PowerDevice; +class Syncer; class WXStatusPanel; -// インジケータ情報 (基本クラス) -// クラス継承の構造をとっているが、基本的には (関数ポインタを持つ) 構造体 -// テイストで扱うほうがここでは都合がよさそう。 +// インジケータ情報 (ほぼ構造体) class Indicator { + public: + // インジケータの識別子 + enum { + NONE = 0, + PERF, + POWER, + SCSI0, + SCSI1, + SCSI2, + SCSI3, + SCSI4, + SCSI5, + SCSI6, + SCSI7, + LAN, + FDD0, + FDD1, + FDD2, + FDD3, + NEWSLED1, + NEWSLED2, + }; protected: using dispfunc_t = void (WXStatusPanel::*)(const Indicator *); using eventfunc_t = void (WXStatusPanel::*)(const Indicator *); public: Indicator() { } - Indicator(const std::string& text_, dispfunc_t draw_) { - text = text_; + Indicator(int id_, int minlen_, dispfunc_t draw_) { + id = id_; + minlen = minlen_; draw = draw_; } + Indicator(int id_, int minlen_, dispfunc_t draw_, const std::string& text_) + : Indicator(id_, minlen_, draw_) + { + text = text_; + } virtual ~Indicator() = default; + // インジケータ識別子 + int id {}; + + // 枠内の最小文字列長。 + // 枠の大きさはこの文字列長と text.length() の長いほうで描画される。 + int minlen {}; + // 表示する文字列。 - // 描画関数はこの文字列を使っても使わなくてもよいが、InitIndicators() が - // この文字数に応じた大きさの枠を用意するため、使わない場合でも文字数 - // だけは揃えておくこと。 std::string text {}; // 描画関数 (必須) @@ -45,33 +80,36 @@ class Indicator // ダブルクリックの処理関数 (必要なら) eventfunc_t dclick {}; - // 枠の位置と大きさは panel.GetRect() で取得できる (実行時に計算する) - Rect rect {}; -}; - -// インジケータ情報 (SCSI) -class SCSIIndicator : public Indicator -{ - using inherited = Indicator; - public: - // SCSI ID - int GetId() const { return id; } - int id {}; + // コンテキストメニューの処理関数 (必要なら) + eventfunc_t contextmenu {}; - // 対応するデバイス - SCSIDevice *dev {}; + // 対応するデバイス (必要なら) + Device *dev {}; // ToolTip を表示するためのダミーパネル wxPanel *panel {}; - // コンテキストメニューの処理関数 (必要なら) - eventfunc_t contextmenu {}; + // 枠の位置と大きさは panel.GetRect() で取得できる (実行時に計算する) + Rect rect {}; + + public: + // SCSI なら SCSI ID を返す。そうでなければ -1 を返す。 + int GetSCSIID() const; + + // FDD ならユニット番号を返す。そうでなければ -1 を返す。 + int GetFDUnit() const; }; // ステータスパネル class WXStatusPanel : public WXTextPanel { using inherited = WXTextPanel; + + struct FDstat { + bool loaded {}; + FDDDevice::LED access_led {}; + bool eject_led {}; + }; public: WXStatusPanel(wxWindow *parent); virtual ~WXStatusPanel() override; @@ -86,6 +124,8 @@ class WXStatusPanel : public WXTextPanel void OnLeftDClick(wxMouseEvent&); void OnContextMenu(wxContextMenuEvent&); void OnSCSIMediaChanged(wxCommandEvent&); + void OnFDDMediaChanged(wxCommandEvent&); + void OnLEDChanged(wxCommandEvent&); bool UpdateStat(); void Draw() override; @@ -94,16 +134,23 @@ class WXStatusPanel : public WXTextPanel void DrawPerf(const Indicator *); void DrawSCSI(const Indicator *); void DrawNet(const Indicator *); + void DrawFD(const Indicator *); + void DrawNewsLED1(const Indicator *); + void DrawNewsLED2(const Indicator *); void DrawPower(const Indicator *); void DrawTextLED(const Indicator *, Color fg, Color bg); void DClickPerf(const Indicator *); void ContextMenuCD(const Indicator *); + void ContextMenuFD(const Indicator *); // インジケータ情報 std::vector indicators {}; // インジケータ表示用 + PowerDevice *power {}; bool ispower {}; + bool powerled {}; + Syncer *syncer {}; int perf_mode {}; int perf_rate {}; std::shared_ptr scsibus {}; @@ -120,12 +167,24 @@ class WXStatusPanel : public WXTextPanel uint64 net_rx_pkts {}; bool net_tx_active {}; bool net_rx_active {}; + std::vector fdd_vector {}; // 存在するドライブのリスト + std::array fdstat {}; // こっちは穴空き配列 + NewsCtlrDevice *newsctlr {}; + int newsled {}; + + // 丸いアクセスマーク (X68k FD 用) + std::unique_ptr accmark /*{}*/; + + // 背景再描画 + bool refresh_background {}; // タイマー wxTimer timer {}; // イベントテーブル wxDECLARE_EVENT_TABLE(); -}; -extern WXStatusPanel *gStatusPanel; + static const uint8 AccessMark12[]; + static const uint8 AccessMark16[]; + static const uint8 AccessMark24[]; +};