--- nono/wx/wxstatuspanel.h 2026/04/29 17:04:53 1.1.1.1 +++ nono/wx/wxstatuspanel.h 2026/04/29 17:05:19 1.1.1.7 @@ -4,110 +4,176 @@ // Licensed under nono-license.txt // +// +// ステータスパネル +// + #pragma once -#include "wxheader.h" -#include "wxbmp.h" #include "wxtextpanel.h" -#include "scsibus.h" +#include "fdd.h" +#include class Indicator; +class PowerDevice; +class Syncer; +class Status; class WXStatusPanel; -// インジケータ情報 +// インジケータ情報 (ほぼ構造体) class Indicator { - using dispfunc_t = void (WXStatusPanel::*)(wxDC&, const Indicator&); - using dclickfunc_t = void (WXStatusPanel::*)(const Indicator&); public: - Indicator(const std::string& text_, dispfunc_t draw_, int data_) - : Indicator(text_, draw_) - { - userdata = data_; + // インジケータの識別子 + enum { + NONE = 0, + PERF, + POWER, + SCSI0, + SCSI1, + SCSI2, + SCSI3, + SCSI4, + SCSI5, + SCSI6, + SCSI7, + LAN0, + LAN1, + FDD0, + FDD1, + FDD2, + FDD3, + NEWSLED1, + NEWSLED2, + }; + protected: + using dispfunc_t = void (WXStatusPanel::*)(const Indicator *); + using eventfunc_t = void (WXStatusPanel::*)(const Indicator *); + public: + Indicator() { } + // 文字列の長さだけ指定する場合 + Indicator(int id_, dispfunc_t draw_, int minlen_, Status *stat_) { + id = id_; + draw = draw_; + stat = stat_; + minlen = minlen_; } - Indicator(const std::string& text_, dispfunc_t draw_) { + // 文字列で指定する場合 + Indicator(int id_, dispfunc_t draw_, const std::string& text_, + Status *stat_) + : Indicator(id_, draw_, text_.length(), stat_) + { text = text_; - draw = draw_; } + virtual ~Indicator() = default; + + // インジケータ識別子 + int id {}; + + // 対応する状態 + Status *stat {}; + + // 枠内の最小文字列長。 + // 枠の大きさはこの文字列長と text.length() の長いほうで描画される。 + int minlen {}; // 表示する文字列。 - // 描画関数はこの文字列を使っても使わなくてもよいが、InitIndicators() が - // この文字数に応じた大きさの枠を用意するため、使わない場合でも文字数 - // だけは揃えておくこと。 std::string text {}; - // 描画関数 + // 描画関数 (必須) dispfunc_t draw {}; - // ダブルクリックの処理関数 - dclickfunc_t dclick {}; + // ダブルクリックの処理関数 (必要なら) + eventfunc_t dclick {}; - // ユーザデータ (ご自由にお使いください、SCSI ID とか) - int userdata {}; + // コンテキストメニューの処理関数 (必要なら) + eventfunc_t contextmenu {}; - // 枠の位置と大きさ (実行時に計算する) - wxRect rect {}; + // 対応するデバイス (必要なら) + Device *dev {}; + + // ToolTip を表示するためのダミーパネル + wxPanel *panel {}; + + // 枠の位置と大きさは panel.GetRect() で取得できる (実行時に計算する) + Rect rect {}; + + public: + // SCSI なら SCSI ID を返す。そうでなければ -1 を返す。 + int GetSCSIID() const; + + // FDD ならユニット番号を返す。そうでなければ -1 を返す。 + int GetFDUnit() const; }; // ステータスパネル class WXStatusPanel : public WXTextPanel { using inherited = WXTextPanel; + public: WXStatusPanel(wxWindow *parent); virtual ~WXStatusPanel() override; - void SetFontSize(FontId) override; + void FontChanged() 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 OnFDDMediaChanged(wxCommandEvent&); + void OnLEDChanged(wxCommandEvent&); - void DoSize(); bool UpdateStat(); - void Draw(wxDC&); + void Draw() override; 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&, - const wxColour& fg, const wxColour& bg); - void DClickPerf(const Indicator&); - void UpdateFFMark(); + 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 *); - // コントロール全域のビットマップ - WXBitmap bitmap {}; - - // 高速モードアイコン - std::unique_ptr ffmark {}; + // 状態 + std::vector stats {}; // インジケータ情報 - std::vector indicators {}; + std::vector indicators {}; // インジケータ表示用 bool ispower {}; - bool last_ispower {}; + bool powerled {}; 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 {}; + std::array scsi_loaded {}; + std::array fd_loaded {}; + + // 丸いアクセスマーク (X68k FD 用) + std::unique_ptr accmark /*{}*/; + + // 背景再描画 + bool refresh_background {}; + + PowerDevice *power {}; + Syncer *syncer {}; // タイマー wxTimer timer {}; // イベントテーブル wxDECLARE_EVENT_TABLE(); -}; -extern WXStatusPanel *gStatusPanel; + static const uint8 AccessMark12[]; + static const uint8 AccessMark16[]; + static const uint8 AccessMark24[]; +};