--- nono/wx/wxsoftkey.h 2026/04/29 17:05:07 1.1.1.10 +++ nono/wx/wxsoftkey.h 2026/04/29 17:05:44 1.1.1.15 @@ -4,17 +4,22 @@ // Licensed under nono-license.txt // +// +// ソフトウェアキーボード +// + #pragma once -#include "wxbitmapbuf.h" #include "wxsubwindow.h" #include "wxtextpanel.h" #include "keyboard.h" -#include "vm.h" +#include "mainapp.h" #include #include #include +class Keyboard; + // キー描画用のデータ構造体 struct keydata_t { @@ -50,13 +55,13 @@ class WXSoftKeyPanel : public WXTextPane protected: // 色の集合(パレット) struct ColorPalette { - wxColour Background; // 背景というかガワの部分の色 - wxColour Text; // 文字色 - wxColour Keytop[2][10]; // キートップ色。 - // [2]=0:通常色、1:(あれば)濃色 - // [10]=押され具合。0は押されていないとき - wxColour Border; // LED 点灯時の枠の色 - wxColour LED[2]; // LED。色は各機種定義 (今のところ0:赤 1:緑) + Color Background; // 背景というかガワの部分の色 + Color Text; // 文字色 + Color Keytop[2][10]; // キートップ色。 + // [2]=0:通常色、1:(あれば)濃色 + // [10]=押され具合。0は押されていないとき + Color Border; // LED 点灯時の枠の色 + Color LED[2]; // LED。色は各機種定義 (今のところ0:赤 1:緑) }; // 修飾キーの状態 @@ -69,23 +74,24 @@ class WXSoftKeyPanel : public WXTextPane WXSoftKeyPanel(wxWindow *parent, const std::vector& keydata_, int u_width_, int u_height_); public: - virtual ~WXSoftKeyPanel() override; + ~WXSoftKeyPanel() override; // フォントサイズ変更 - void SetFontSize(FontId fontid) override; + void FontChanged() override; protected: + void UpdateTitle(); + void InitColorKeytop(int num); - void DoSize(); - void OnPaint(wxPaintEvent& event); + void InitIcon(); void OnKeyChanged(wxCommandEvent& event); void OnTimer(wxTimerEvent& event); - void Draw(wxDC& dc); - void DrawKey(wxDC& dc, const keydata_t& key); - void DrawEnterKey(wxDC& dc); - void DrawEnterMark(wxDC& dc, const wxPoint& basep); - virtual int DrawLED(wxDC& dc, const keydata_t& key) = 0; + void Draw() override; + void DrawKey(const keydata_t& key); + void DrawEnterKey(); + void DrawBuzzer(const keydata_t& key); + virtual int DrawLED(const keydata_t& key) = 0; const keydata_t& FindKeydata(uint) const; void OnLeftDown(wxMouseEvent& event); @@ -116,12 +122,18 @@ class WXSoftKeyPanel : public WXTextPane int u_width {}; int u_height {}; - // コントロール全域のビットマップ - WXBitmapBuf bitmap {}; + // 初期タイトル + wxString title {}; - // エンター記号の周囲の点集合 - std::vector enter_points {}; - wxRegion enter_region {}; + // キーボードの接続状態 + bool connected {}; + + // エンターキーの矩形 + Rect enter_top {}; + Rect enter_btm {}; + + // アイコン + std::unique_ptr enter_icon /*{}*/; // 色 ColorPalette color {}; @@ -146,6 +158,8 @@ class WXSoftKeyPanel : public WXTextPane // キー描画データ (派生クラス側から渡される) const std::vector& keydata; + Keyboard *keyboard {}; + // イベントテーブル wxDECLARE_EVENT_TABLE(); }; @@ -155,11 +169,11 @@ class WXLunaSoftKeyPanel : public WXSoft { using inherited = WXSoftKeyPanel; public: - WXLunaSoftKeyPanel(wxWindow *parent); - virtual ~WXLunaSoftKeyPanel() override; + explicit WXLunaSoftKeyPanel(wxWindow *parent); + ~WXLunaSoftKeyPanel() override; private: - int DrawLED(wxDC& dc, const keydata_t& key) override; + int DrawLED(const keydata_t& key) override; // キー描画データ static std::vector keydata; @@ -170,11 +184,11 @@ class WXX68kSoftKeyPanel : public WXSoft { using inherited = WXSoftKeyPanel; public: - WXX68kSoftKeyPanel(wxWindow *parent); - virtual ~WXX68kSoftKeyPanel() override; + explicit WXX68kSoftKeyPanel(wxWindow *parent); + ~WXX68kSoftKeyPanel() override; private: - int DrawLED(wxDC& dc, const keydata_t& key) override; + int DrawLED(const keydata_t& key) override; // キー描画データ static std::vector keydata; @@ -185,10 +199,6 @@ class WXSoftKeyWindow : public WXSubWind { using inherited = WXSubWindow; public: - WXSoftKeyWindow(wxWindow *parent, vmtype_t vmtype); - virtual ~WXSoftKeyWindow() override; - - private: - // キーボードパネル - WXSoftKeyPanel *panel {}; + WXSoftKeyWindow(wxWindow *parent, VMType vmtype); + ~WXSoftKeyWindow() override; };