--- nono/wx/wxtextscreen.h 2026/04/29 17:04:56 1.1.1.6 +++ nono/wx/wxtextscreen.h 2026/04/29 17:05:08 1.1.1.7 @@ -4,25 +4,34 @@ // Licensed under nono-license.txt // -#pragma once - -#include "wxtextpanel.h" -#include "wxbitmapbuf.h" -#include "monitor.h" - // -// テキストスクリーンを表示するパネル +// テキストスクリーンを描画するパネル // + // wxPanel // ↓ -// WXTextPanel テキストフォントを管理するクラス +// WXTextPanel テキストフォントを描画するクラス // ↓ // WXTextScreen テキストスクリーンを表示するパネル -// + +#pragma once + +#include "wxtextpanel.h" +#include "monitor.h" + class WXTextScreen : public WXTextPanel { using inherited = WXTextPanel; + // テキストスクリーンは本来単純なキャラクタビットマップ構造のため、 + // クライアント領域の端の1ピクセルまでふんだんに使用している。 + // ウィンドウマネージャ側でこのウィンドウに枠などをつけてくれる場合は + // あまり問題にならないが、枠などを一切つけないタイプのウィンドウ + // マネージャでこのウィンドウを表示するとウィンドウの縁に接する文字の + // 視認性が(文字とウィンドウ外の背景の組み合わせによっては)すこぶる + // 悪くなる。そのため、テキストスクリーンの周囲に余白をもたせる。 + static const int DefaultPadding = 3; + public: WXTextScreen(wxWindow *parent, Monitor& monitor); virtual ~WXTextScreen() override; @@ -31,35 +40,59 @@ class WXTextScreen : public WXTextPanel void DoRefresh(); // フォントサイズ変更 - void SetFontSize(FontId fontid) override; + void FontChanged() override; // 更新頻度設定 void SetRate(int hz); + // パディングサイズ変更 + void SetPadding(int l, int t, int r, int b); + // パディングサイズ取得 + int GetPaddingLeft() const { return pad_left; } + int GetPaddingTop() const { return pad_top; } + int GetPaddingRight() const { return pad_right; } + int GetPaddingBottom() const { return pad_bottom; } + // 桁数、行数を取得する int GetCol() const { return ts.GetCol(); } int GetRow() const { return ts.GetRow(); } + // クライアント座標 pos をテキスト座標(桁、行)に変換して返す + // (パディング領域では戻り値が負数になることに注意) + wxPoint GetTextPosition(const wxPoint& pos) const; + // TextScreen のユーザデータ取得、設定 uint64 GetUserData() const { return ts.userdata; } void SetUserData(uint64 value) { ts.userdata = value; } + // コンテキストメニューイベントを解除 + // (ここのコンテキストメニューを使いたくない人が呼ぶ) + void DisconnectContextMenu(); + private: - void OnPaint(wxPaintEvent&); void OnSize(wxSizeEvent&); void OnTimer(wxTimerEvent&); + void OnContextMenu(wxContextMenuEvent&); + void OnCopy(wxCommandEvent&); void Init(int col, int row); - void Draw(wxDC& dc); + void DoSize(); + void InvalidateText(); + void Draw() override; - // コントロール全域のビットマップ - WXBitmapBuf bitmap {}; + // コンテキストメニューを接続 + void ConnectContextMenu(); std::vector prevbuf {}; Monitor& monitor; TextScreen ts {}; + int pad_left {}; + int pad_top {}; + int pad_right {}; + int pad_bottom {}; + wxTimer timer {}; wxDECLARE_EVENT_TABLE();