Skip to content

Commit

Permalink
Some more wx toolbar changes.
Browse files Browse the repository at this point in the history
- Added XPM file for disabled mouse capture.
- Added method for toggling toolbar bitmaps and use it for the mouse button.
- Some small tooltip changes.
  • Loading branch information
vruppert committed Jun 23, 2024
1 parent b8d2f15 commit cefedbd
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 4 deletions.
40 changes: 40 additions & 0 deletions bochs/gui/bitmaps/mouse_dis.xpm
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/* XPM */
static const char *mouse_dis_xpm[] = {
/* columns rows colors chars-per-pixel */
"32 32 2 1 ",
" c None",
". c black",
/* pixels */
". .",
" . ...... . ",
" . .......... . ",
" . .. .. . ",
" . .. .. . ",
" . .. . . ",
" ............. .. . ",
" .. . .. ... ",
" . . .. . . .. ",
" . ... ... ... . .. ",
" . ... ... ... . . .. ",
" . ... ....... . . .. ",
" . ... ... ... . . . ",
" . ... ... ... . . .. ",
" . ... ... ... .. .. ",
" . . . . .. .. ",
" .. .. ... ",
" . . .. ",
" .. . .. . ",
" . . . . ",
" .. . .. . ",
" . . . . ",
" .. . .. . ",
" . . . . ",
" .. . .. . ",
" . . . . . . ",
" .. . . .. . ",
" . . . . . . . . . ",
" .. . . . . . .. . ",
" .............. . ",
" . . ",
". ."
};
1 change: 1 addition & 0 deletions bochs/gui/wx.cc
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ void MyPanel::ToggleMouse(bool fromToolbar)
wxMessageBox(msg, wxT("Mouse Capture Enabled"), wxOK | wxICON_INFORMATION);
first_enable = false;
}
theFrame->SetToolBarBitmap(ID_Toolbar_Mouse_en, en);
enable->set(en);
IFDBG_MOUSE(wxLogDebug (wxT ("now mouse is %sabled", en ? "en" : "dis")));
if (en) {
Expand Down
23 changes: 20 additions & 3 deletions bochs/gui/wxmain.cc
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
#include "bitmaps/reset.xpm"
#include "bitmaps/snapshot.xpm"
#include "bitmaps/mouse.xpm"
#include "bitmaps/mouse_dis.xpm"
//#include "bitmaps/configbutton.xpm"
#include "bitmaps/userbutton.xpm"
#include "bitmaps/saverestore.xpm"
Expand Down Expand Up @@ -444,7 +445,7 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size,
BX_ADD_TOOL(ID_Edit_FD_0, floppya_xpm, wxT("Change floppy A: media"));
BX_ADD_TOOL(ID_Edit_FD_1, floppyb_xpm, wxT("Change floppy B: media"));
BX_ADD_TOOL(ID_Edit_Cdrom1, cdromd_xpm, wxT("Change first CDROM media"));
BX_ADD_TOOL(ID_Toolbar_Mouse_en, mouse_xpm, wxT("Enable mouse capture"));
BX_ADD_TOOL(ID_Toolbar_Mouse_en, mouse_dis_xpm, wxT("Enable mouse capture"));
#if BX_USE_WIN32USBDEBUG
BX_ADD_TOOL(ID_Toolbar_USB_Debug, usb_xpm, wxT("Trigger the USB Debugger"));
#endif
Expand All @@ -454,8 +455,8 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size,
BX_ADD_TOOL(ID_Toolbar_Paste, paste_xpm, wxT("Paste clipboard text as emulated keystrokes"));
BX_ADD_TOOL(ID_Toolbar_Snapshot, snapshot_xpm, wxT("Save snapshot of the Bochs screen"));
BX_ADD_TOOL(ID_Toolbar_Reset, reset_xpm, wxT("Reset the system"));
BX_ADD_TOOL(ID_Toolbar_SaveRestore, saverestore_xpm, wxT("Save/restore simulation state"));
BX_ADD_TOOL(ID_Toolbar_Power, power_xpm, wxT("Turn power on/off"));
BX_ADD_TOOL(ID_Toolbar_SaveRestore, saverestore_xpm, wxT("Restore simulation state"));
BX_ADD_TOOL(ID_Toolbar_Power, power_xpm, wxT("Turn power on"));

bxToolBar->Realize();
UpdateToolBar(false);
Expand Down Expand Up @@ -868,8 +869,10 @@ void MyFrame::UpdateToolBar(bool simPresent)
bxToolBar->EnableTool(ID_Toolbar_User, simPresent);
if (simPresent) {
bxToolBar->SetToolShortHelp(ID_Toolbar_SaveRestore, wxT("Save simulation state"));
bxToolBar->SetToolShortHelp(ID_Toolbar_Power, wxT("Turn power off"));
} else {
bxToolBar->SetToolShortHelp(ID_Toolbar_SaveRestore, wxT("Restore simulation state"));
bxToolBar->SetToolShortHelp(ID_Toolbar_Power, wxT("Turn power on"));
}
#if BX_USE_WIN32USBDEBUG
bxToolBar->EnableTool(ID_Toolbar_USB_Debug, simPresent);
Expand Down Expand Up @@ -1299,6 +1302,20 @@ void MyFrame::SetToolBarHelp(int id, wxString& text)
bxToolBar->SetToolShortHelp(id, text);
}

void MyFrame::SetToolBarBitmap(int id, bool onoff)
{
wxBitmap bitmap;

switch (id) {
case ID_Toolbar_Mouse_en:
bitmap = onoff ? mouse_xpm : mouse_dis_xpm;
break;
default:
return;
}
bxToolBar->SetToolNormalBitmap(id, bitmap);
}

//////////////////////////////////////////////////////////////////////
// Simulation Thread
//////////////////////////////////////////////////////////////////////
Expand Down
3 changes: 2 additions & 1 deletion bochs/gui/wxmain.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// $Id$
/////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002-2021 The Bochs Project
// Copyright (C) 2002-2024 The Bochs Project
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
Expand Down Expand Up @@ -216,6 +216,7 @@ class MyFrame: public wxFrame

void UpdateToolBar(bool simPresent);
void SetToolBarHelp(int id, wxString& text);
void SetToolBarBitmap(int id, bool onoff);

private:
wxCriticalSection sim_thread_lock;
Expand Down

0 comments on commit cefedbd

Please sign in to comment.