--- nono/wx/wxmainview.cpp 2026/04/29 17:05:23 1.1.1.14 +++ nono/wx/wxmainview.cpp 2026/04/29 17:05:53 1.1.1.19 @@ -9,10 +9,10 @@ // #include "wxmainview.h" +#include "wxmainframe.h" #include "wxuimessage.h" -#include "bitmap.h" #include "config.h" -#include "event.h" +#include "device.h" #include "keyboard.h" #include "renderer.h" #include @@ -62,15 +62,20 @@ wxEND_EVENT_TABLE() WXMainView::WXMainView(wxWindow *parent) : inherited(parent) { - // デバイスを取得。Keyboard は NULL の可能性あり。 - keyboard = gMainApp.FindObject(OBJ_KEYBOARD); - renderer = GetRenderer(); - - // 仮想画面(VM が描画する画面) - rendwidth = renderer->GetWidth(); - rendheight = renderer->GetHeight(); + SetName("WXMainView"); - renderer->Enable(); + // デバイスを取得。 + renderer = GetVideoRenderer(); + + // rich dumb + // -------- ------- + // NULL NULL キー入力機能なし + // NULL avail シリアル入力機能のみ + // avail avail キー入力機能あり (2つは同じポインタ) + dumbkbd = gMainApp.FindObject(OBJ_KEYBOARD); + if (dumbkbd) { + richkbd = dynamic_cast(dumbkbd); + } // マウスモード変更イベント Connect(NONO_EVT_MOUSEMODE, @@ -104,7 +109,7 @@ WXMainView::~WXMainView() bool WXMainView::Init() { - if (keyboard) { + if (richkbd) { // キーボードの入力モードの初期値設定 const ConfigItem& item_input = gConfig->Find("hostkbd-input"); const std::string input_mode = item_input.AsString(); @@ -117,6 +122,9 @@ WXMainView::Init() item_input.Err(); return false; } + } else if (dumbkbd) { + // シリアルキーボードのみなら常に文字入力。 + SetCharInputMode(true); } return true; @@ -155,18 +163,12 @@ WXMainView::OnPaint(wxPaintEvent& event) return; } - const BitmapRGB& bitmap0 = renderer->GetBitmap(); - BitmapRGB bitmap1; - uint8 *p = const_cast(bitmap0.GetBuf()); - - if (viewwidth != rendwidth || viewheight != rendheight) { - bitmap1.Create(viewwidth, viewheight); - Rect rect(0, 0, viewwidth, viewheight); - bitmap1.StretchDraw(rect, bitmap0); - p = bitmap1.GetBuf(); + BitmapRGB *bitmap24 = renderer->GetBitmap(); + if (__predict_false(bitmap24 == NULL)) { + return; } - wxImage image(viewwidth, viewheight, p, true); + wxImage image(viewwidth, viewheight, bitmap24->GetBuf(), true); wxBitmap bmp(image); // 実画面 DC にコピー @@ -179,14 +181,18 @@ void WXMainView::DoResize(double scale) { screen_scale = scale; - int width = (double)rendwidth * scale; - int height = (double)rendheight * scale; + int width = (double)renderer->GetWidth() * scale; + int height = (double)renderer->GetHeight() * scale; if (viewwidth != width || viewheight != height) { - // ウィンドウサイズ変更 viewwidth = width; viewheight = height; - SetClientSize(viewwidth, viewheight); - SetMinClientSize(wxSize(viewwidth, viewheight)); + + // レンダラにリサイズ指示。 + renderer->ResizeView(viewwidth, viewheight); + + // ウィンドウサイズ変更 + SetSize(viewwidth, viewheight); + SetMinSize(wxSize(viewwidth, viewheight)); } } @@ -234,7 +240,7 @@ WXMainView::SetMouseMode(bool mode) // このウィンドウから外れないように移動を検出し続けるため、 // マウスカーソルをウィンドウ中央に移す。 // ウィンドウとメニューバーが分離してる wxOSX のために必要。 - MyWarpPointer(GetClientSize() / 2); + MyWarpPointer(GetSize() / 2); } else { // マウスモードを OFF にする DMPRINTF("SetMouseMode OFF\n"); @@ -244,12 +250,16 @@ WXMainView::SetMouseMode(bool mode) } // 分かりやすさのため、マウスカーソルを中央へ戻してから復帰 - wxSize pt = GetClientSize() / 2; + wxSize pt = GetSize() / 2; WarpPointer(pt.x, pt.y); // マウスカーソル ON ::wxSetCursor(wxNullCursor); } + + // マウスモードなら、タイトルにマウスモードの抜け方を表示したい。 + auto frame = dynamic_cast(GetParent()); + frame->SetMyTitle(mousemode); } // マウスカーソルをクライアント座標 (x, y) に移動 @@ -331,7 +341,7 @@ WXMainView::OnMouse(wxMouseEvent& event) // マウスカーソルを中心に戻す if (dx != 0 || dy != 0) { - MyWarpPointer(GetClientSize() / 2); + MyWarpPointer(GetSize() / 2); } } } @@ -349,8 +359,8 @@ WXMainView::OnMouse(wxMouseEvent& event) (mb ? 'M' : '-'), (rb ? 'R' : '-')); - if (keyboard) { - keyboard->MouseInput(dx, dy, rb, lb, mb); + if (richkbd) { + richkbd->MouseInput(dx, dy, rb, lb, mb); } } @@ -463,8 +473,8 @@ WXMainView::OnKeyDown(wxKeyEvent& event) DKPRINTF("KeyDown "); int keycode = GetKeyCode(event); - if (keyboard) { - keyboard->MakeKey(keycode); + if (richkbd) { + richkbd->MakeKey(keycode); } } @@ -478,8 +488,8 @@ WXMainView::OnKeyUp(wxKeyEvent& event) DKPRINTF("KeyUp "); int keycode = GetKeyCode(event); - if (keyboard) { - keyboard->BreakKey(keycode); + if (richkbd) { + richkbd->BreakKey(keycode); } } @@ -553,8 +563,8 @@ WXMainView::OnChar(wxKeyEvent& event) } ukey &= 0xff; - if (keyboard) { - keyboard->CharInput(ukey); + if (dumbkbd) { + dumbkbd->CharInput(ukey); } }