--- nono/wx/wxsoftkey.h 2026/04/29 17:05:04 1.1.1.9 +++ nono/wx/wxsoftkey.h 2026/04/29 17:05:16 1.1.1.13 @@ -4,16 +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 { @@ -49,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:緑) }; // 修飾キーの状態 @@ -71,39 +77,40 @@ class WXSoftKeyPanel : public WXTextPane virtual ~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; - static bool IsShiftKey(uint keycode); void OnLeftDown(wxMouseEvent& event); - void DoLeftDown(const keydata_t *key); + void DoLeftDown(uint code); void OnLeftUp(wxMouseEvent& event); void OnLeftDClick(wxMouseEvent& event); void OnRightDown(wxMouseEvent& event); - void KeyDown(const keydata_t& key); - void KeyUp(const keydata_t& key); + void KeyDown(uint code); + void KeyUp(uint code); const keydata_t *GetKeydataFromPoint(const wxPoint& pt) const; // 左クリック押下時のキー - const keydata_t *leftdown_key {}; + uint leftdown_key {}; - // SHIFT キー長押し中なら true。 - // SHIFT 状態でのみ意味を持つので事前に gKeyboard->IsShift() 確認すること。 - bool shift_hold {}; + // トグル動作にするキーの集合。 + // first はキーコード、 + // second は押下ならキーコード、開放なら 0。 + std::map toggle {}; // 修飾キーの状態 (刻印を変更するため) Modifier modifier {}; @@ -115,12 +122,18 @@ class WXSoftKeyPanel : public WXTextPane int u_width {}; int u_height {}; - // コントロール全域のビットマップ - WXBitmapBuf bitmap {}; + // 初期タイトル + wxString title {}; + + // キーボードの接続状態 + bool connected {}; - // エンター記号の周囲の点集合 - std::vector enter_points {}; - wxRegion enter_region {}; + // エンターキーの矩形 + Rect enter_top {}; + Rect enter_btm {}; + + // アイコン + std::unique_ptr enter_icon /*{}*/; // 色 ColorPalette color {}; @@ -145,6 +158,8 @@ class WXSoftKeyPanel : public WXTextPane // キー描画データ (派生クラス側から渡される) const std::vector& keydata; + Keyboard *keyboard {}; + // イベントテーブル wxDECLARE_EVENT_TABLE(); }; @@ -158,7 +173,7 @@ class WXLunaSoftKeyPanel : public WXSoft virtual ~WXLunaSoftKeyPanel() override; private: - int DrawLED(wxDC& dc, const keydata_t& key) override; + int DrawLED(const keydata_t& key) override; // キー描画データ static std::vector keydata; @@ -173,7 +188,7 @@ class WXX68kSoftKeyPanel : public WXSoft virtual ~WXX68kSoftKeyPanel() override; private: - int DrawLED(wxDC& dc, const keydata_t& key) override; + int DrawLED(const keydata_t& key) override; // キー描画データ static std::vector keydata; @@ -184,7 +199,7 @@ class WXSoftKeyWindow : public WXSubWind { using inherited = WXSubWindow; public: - WXSoftKeyWindow(wxWindow *parent, vmtype_t vmtype); + WXSoftKeyWindow(wxWindow *parent, VMType vmtype); virtual ~WXSoftKeyWindow() override; private: