--- nono/wx/wxsoftkey.h 2026/04/29 17:04:53 1.1.1.6 +++ nono/wx/wxsoftkey.h 2026/04/29 17:05:07 1.1.1.10 @@ -6,12 +6,13 @@ #pragma once -#include "wxbmp.h" +#include "wxbitmapbuf.h" #include "wxsubwindow.h" #include "wxtextpanel.h" #include "keyboard.h" #include "vm.h" #include +#include #include // キー描画用のデータ構造体 @@ -51,8 +52,9 @@ class WXSoftKeyPanel : public WXTextPane struct ColorPalette { wxColour Background; // 背景というかガワの部分の色 wxColour Text; // 文字色 - wxColour Keytop[2]; // キートップ色。0:通常色、1:(あれば)濃色 - wxColour KeyPressed; // キーが押された時のキートップ色 + wxColour Keytop[2][10]; // キートップ色。 + // [2]=0:通常色、1:(あれば)濃色 + // [10]=押され具合。0は押されていないとき wxColour Border; // LED 点灯時の枠の色 wxColour LED[2]; // LED。色は各機種定義 (今のところ0:赤 1:緑) }; @@ -73,10 +75,10 @@ class WXSoftKeyPanel : public WXTextPane void SetFontSize(FontId fontid) override; protected: - void InitLED(); + void InitColorKeytop(int num); void DoSize(); - void OnSize(wxSizeEvent& event); void OnPaint(wxPaintEvent& event); + void OnKeyChanged(wxCommandEvent& event); void OnTimer(wxTimerEvent& event); void Draw(wxDC& dc); @@ -87,28 +89,26 @@ class WXSoftKeyPanel : public WXTextPane const keydata_t& FindKeydata(uint) const; void OnLeftDown(wxMouseEvent& event); - void DoLeftDown(const keydata_t *key); + void DoLeftDown(uint code); void OnLeftUp(wxMouseEvent& event); - void DoLeftUp(const keydata_t *key); void OnLeftDClick(wxMouseEvent& event); void OnRightDown(wxMouseEvent& event); - bool IsModifier(uint code) const; - void UpdateModifier(); - 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 {}; + + // トグル動作にするキーの集合。 + // first はキーコード、 + // second は押下ならキーコード、開放なら 0。 + std::map toggle {}; // 修飾キーの状態 (刻印を変更するため) Modifier modifier {}; - // 前回の状態 - std::vector last_pressed {}; - Modifier last_modifier {}; - // フォントサイズに相対的な描画単位 int unit {}; @@ -117,7 +117,7 @@ class WXSoftKeyPanel : public WXTextPane int u_height {}; // コントロール全域のビットマップ - WXBitmap bitmap {}; + WXBitmapBuf bitmap {}; // エンター記号の周囲の点集合 std::vector enter_points {}; @@ -126,6 +126,14 @@ class WXSoftKeyPanel : public WXTextPane // 色 ColorPalette color {}; + // 残光処理 + // 10 : 減光しない点灯を示す (ただし色コードは 9) + // 9..1 : 減光中 (9 がもっとも明るい) + // 0 : 消灯中 + std::vector persistence {}; + + wxTimer timer {}; + // UTF-8 -> CP932 変換 // Unicode の "\\" は Shift_JIS に対応する文字がないため、これを // Unicode から Shift_JIS に変換すると "" になり、これではキートップが @@ -138,9 +146,6 @@ class WXSoftKeyPanel : public WXTextPane // キー描画データ (派生クラス側から渡される) const std::vector& keydata; - // タイマー - wxTimer timer {}; - // イベントテーブル wxDECLARE_EVENT_TABLE(); }; @@ -180,7 +185,7 @@ class WXSoftKeyWindow : public WXSubWind { using inherited = WXSubWindow; public: - WXSoftKeyWindow(wxWindow *parent, wxWindowID id, vmtype_t vmtype); + WXSoftKeyWindow(wxWindow *parent, vmtype_t vmtype); virtual ~WXSoftKeyWindow() override; private: