--- nono/wx/wxmainview.h 2026/04/29 17:04:28 1.1 +++ nono/wx/wxmainview.h 2026/04/29 17:05:12 1.1.1.12 @@ -1,21 +1,27 @@ // // nono -// Copyright (C) 2018 isaki@NetBSD.org +// Copyright (C) 2020 nono project +// Licensed under nono-license.txt +// + +// +// メイン画面パネル // #pragma once -#include +#include "wxnono.h" -class WXMainView - : public wxPanel +class WXMainView : public wxPanel { - typedef wxPanel inherited; + using inherited = wxPanel; public: WXMainView(wxWindow *); - virtual ~WXMainView(); + virtual ~WXMainView() override; - void DoRefresh(); + bool Init(); + + void Close(); void DoResize(double scale); // 現在のスケールを返す @@ -23,38 +29,57 @@ class WXMainView // 現在のスケール (wxapp が初期値を指定するため static 変数にしてある) static double screen_scale; - private: - void OnPaint(wxPaintEvent& event); - - void DoPaint(wxDC &dc); + // 文字入力モードを取得・設定 + bool GetCharInputMode() const { return is_charinput; } + void SetCharInputMode(bool enable); + + // マウスモードを設定 + void SetMouseMode(bool enable); + // マウスモードを取得 (キャプチャされているなら true) + bool GetMouseMode() const { return mousemode; } + // アクティベートイベント + void OnActivate(wxActivateEvent& event); + // キー入力イベント (WXSoftKeyPanel からも呼ばれる) void OnKeyDown(wxKeyEvent& event); void OnKeyUp(wxKeyEvent& event); + void OnChar(wxKeyEvent& event); - // 裏バッファ。 - // VM がレンダリングするバッファ。 - uint8_t *ImageBuf = NULL; + private: + void OnTimer(wxTimerEvent& event); + void OnPaint(wxPaintEvent& event); + void OnMouse(wxMouseEvent& event); + void OnMouseCaptureLost(wxMouseCaptureLostEvent& event); + void OnRender(wxCommandEvent& event); // 仮想画面サイズ (ピクセル) - int rendwidth = 0; - int rendheight = 0; + int rendwidth {}; + int rendheight {}; // 実画面サイズ (ピクセル) - int viewwidth = 0; - int viewheight = 0; + int viewwidth {}; + int viewheight {}; // 共通キーコードを取得する 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]; - wxTimer paintTimer; - std::atomic paintRequested {}; - void OnTimer(wxTimerEvent& event); + // 文字入力モードなら true + bool is_charinput {}; + + // マウスモード (キャプチャしていれば true) + bool mousemode {}; + // 前回のマウス座標とボタン + wxPoint prevpos {}; + bool prevlb {}; + bool prevmb {}; + bool prevrb {}; + + // WarpPointer() による移動検出用 + bool motion_by_warp_pointer {}; + // マウスカーソルを移動させる + void MyWarpPointer(wxSize pos); wxDECLARE_EVENT_TABLE(); };