--- nono/wx/wxmainview.h 2026/04/29 17:04:42 1.1.1.6 +++ nono/wx/wxmainview.h 2026/04/29 17:05:27 1.1.1.14 @@ -4,20 +4,29 @@ // Licensed under nono-license.txt // +// +// メイン画面パネル +// + #pragma once -#include "wxheader.h" -#include +#include "wxnono.h" + +wxDECLARE_EVENT(NONO_EVT_MOUSEMODE, wxCommandEvent); -class WXMainView - : public wxPanel +class Keyboard; +class Renderer; + +class WXMainView : public wxPanel { using inherited = wxPanel; public: - WXMainView(wxWindow *); - virtual ~WXMainView(); + explicit WXMainView(wxWindow *); + virtual ~WXMainView() override; + + bool Init(); - void DoRefresh(); + void Close(); void DoResize(double scale); // 現在のスケールを返す @@ -25,6 +34,10 @@ class WXMainView // 現在のスケール (wxapp が初期値を指定するため static 変数にしてある) static double screen_scale; + // 文字入力モードを取得・設定 + bool GetCharInputMode() const { return is_charinput; } + void SetCharInputMode(bool enable); + // マウスモードを設定 void SetMouseMode(bool enable); // マウスモードを取得 (キャプチャされているなら true) @@ -32,20 +45,18 @@ class WXMainView // アクティベートイベント void OnActivate(wxActivateEvent& event); + // キー入力イベント (WXSoftKeyPanel からも呼ばれる) + void OnKeyDown(wxKeyEvent& event); + void OnKeyUp(wxKeyEvent& event); + void OnChar(wxKeyEvent& event); + private: void OnTimer(wxTimerEvent& event); void OnPaint(wxPaintEvent& event); - void OnKeyDown(wxKeyEvent& event); - void OnKeyUp(wxKeyEvent& event); void OnMouse(wxMouseEvent& event); - - // 裏バッファ。 - // VM がレンダリングするバッファ。 - std::unique_ptr ImageBuf {}; - - // 仮想画面サイズ (ピクセル) - int rendwidth {}; - int rendheight {}; + void OnMouseCaptureLost(wxMouseCaptureLostEvent& event); + void OnRender(wxCommandEvent& event); + void OnMouseMode(wxCommandEvent& event); // 実画面サイズ (ピクセル) int viewwidth {}; @@ -54,11 +65,10 @@ class WXMainView // 共通キーコードを取得する int GetKeyCode(wxKeyEvent& event); -#if defined(__WXGTK__) - static const int keycode_table[0xd4]; -#elif defined(__WXOSX__) - static const int keycode_table[0x80]; -#endif + static const int keycode_table[0x190]; + + // 文字入力モードなら true + bool is_charinput {}; // マウスモード (キャプチャしていれば true) bool mousemode {}; @@ -73,11 +83,8 @@ class WXMainView // マウスカーソルを移動させる void MyWarpPointer(wxSize pos); - // 再描画を律速する - wxTimer timer {}; - std::atomic paint_request {}; + Keyboard *keyboard {}; + Renderer *renderer {}; wxDECLARE_EVENT_TABLE(); }; - -extern WXMainView *gMainView;