--- nono/wx/wxtextscreen.h 2026/04/29 17:04:28 1.1.1.1 +++ nono/wx/wxtextscreen.h 2026/04/29 17:04:43 1.1.1.4 @@ -1,6 +1,7 @@ // // nono -// Copyright (C) 2018 isaki@NetBSD.org +// Copyright (C) 2020 nono project +// Licensed under nono-license.txt // #pragma once @@ -8,44 +9,57 @@ #include "wxtextpanel.h" // -// テキストスクリーン風コントロール +// テキストスクリーンを表示するパネル // // wxPanel // ↓ // WXTextPanel テキストフォントを管理するクラス // ↓ -// WXTextScreen テキストフォントを使ったテキストスクリーン +// WXTextScreen テキストスクリーンを表示するパネル // class WXTextScreen : public WXTextPanel { - typedef WXTextPanel inherited; + using inherited = WXTextPanel; public: - WXTextScreen(wxWindow *parent, int col, int row, const uint16 *textbuf); - virtual ~WXTextScreen(); + WXTextScreen(wxWindow *parent, IMonitor& monitor); + virtual ~WXTextScreen() override; - // XXX - void SetTextSize(int col, int row); - - void OnPaint(wxPaintEvent&); - void OnSize(wxSizeEvent&); + // 必要なら画面を更新して再描画する。 + // TextScreen が前回描画時から更新されていたら、このパネルを再描画する。 + void RefreshIfUpdated(); // フォントサイズ変更 - void SetFontSize(fontsize_t fontsize); + void SetFontSize(FontId fontid) override; + + // 更新頻度設定 + void SetRate(int hz); + + // サイズ (桁数×行数) を取得する + const wxSize GetSize() const { return wxSize(ts.GetCol(), ts.GetRow()); } + + // TextScreen のユーザデータ取得、設定 + uint64 GetUserData() const { return ts.userdata; } + void SetUserData(uint64 value) { ts.userdata = value; } private: + void OnPaint(wxPaintEvent&); + void OnSize(wxSizeEvent&); + void OnTimer(wxTimerEvent&); + void Draw(wxDC& dc); - const uint16 *textbuf = NULL; - uint16 *prevbuf = NULL; - uint8 *bmpbuf = NULL; - wxImage *image = NULL; - wxBitmap *bitmap = NULL; - - int col = 0; - int row = 0; - int view_width = 0; - int view_height = 0; + std::unique_ptr prevbuf {}; + std::unique_ptr bmpbuf {}; + std::unique_ptr image {}; + std::unique_ptr bitmap {}; + + IMonitor& monitor; + TextScreen ts {}; + int view_width {}; + int view_height {}; + + wxTimer timer {}; wxDECLARE_EVENT_TABLE(); };