- fix bug 619320 "wx: clicking mouse enable btn different". Now both

the toolbar button and the mouse capture shortcuts (F12 and middle button)
  call ToggleMouse().  The only difference is that the first time you
  press the toolbar button it gives a little message about mouse capture
  and how to turn it off.
- modified: gui/wx.cc gui/wxmain.cc gui/wxmain.h
This commit is contained in:
Bryce Denney 2002-10-07 04:49:50 +00:00
parent 84c33ec824
commit 77a2d3fc89
3 changed files with 24 additions and 9 deletions

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////
// $Id: wx.cc,v 1.41 2002-10-05 18:27:24 bdenney Exp $
// $Id: wx.cc,v 1.42 2002-10-07 04:49:50 bdenney Exp $
/////////////////////////////////////////////////////////////////
//
// wxWindows VGA display for Bochs. wx.cc implements a custom
@ -142,10 +142,24 @@ void MyPanel::OnPaint(wxPaintEvent& WXUNUSED(event))
needRefresh = false;
}
void MyPanel::ToggleMouse ()
void MyPanel::ToggleMouse (bool fromToolbar)
{
static bool first_enable = true;
bx_param_bool_c *enable = SIM->get_param_bool (BXP_MOUSE_ENABLED);
bool en = ! enable->get ();
bool needmutex = isSimThread();
if (needmutex) wxMutexGuiEnter();
if (fromToolbar && first_enable && en) {
// only show this help if you click on the toolbar. If they already
// know the shortcut, don't annoy them with the message.
wxString msg =
"You have enabled the mouse in Bochs, so now your mouse actions will\n"
"be sent into the simulator. The usual mouse cursor will be trapped\n"
"inside the Bochs window until you press F12 or press the middle button\n"
"to turn mouse capture off.";
wxMessageBox(msg, "Mouse Capture Enabled", wxOK | wxICON_INFORMATION);
first_enable = false;
}
enable->set (en);
IFDBG_MOUSE (wxLogDebug ("now mouse is %sabled", en ? "en" : "dis"));
if (en) {
@ -156,6 +170,7 @@ void MyPanel::ToggleMouse ()
} else {
SetCursor (wxNullCursor);
}
if (needmutex) wxMutexGuiLeave();
}
void MyPanel::OnMouse(wxMouseEvent& event)
@ -177,7 +192,7 @@ void MyPanel::OnMouse(wxMouseEvent& event)
)
if (event.MiddleDown ()) {
ToggleMouse ();
ToggleMouse (false);
return;
}
@ -228,7 +243,7 @@ MyPanel::MyRefresh ()
void MyPanel::OnKeyDown(wxKeyEvent& event)
{
if(event.GetKeyCode() == WXK_F12) {
ToggleMouse ();
ToggleMouse (false);
return;
}
wxCriticalSectionLocker lock(event_thread_lock);
@ -769,7 +784,7 @@ void bx_gui_c::handle_events(void)
case BX_TOOLBAR_PASTE: paste_handler (); break;
case BX_TOOLBAR_SNAPSHOT: snapshot_handler (); break;
case BX_TOOLBAR_CONFIG: config_handler (); break;
case BX_TOOLBAR_MOUSE_EN: toggle_mouse_enable (); break;
case BX_TOOLBAR_MOUSE_EN: thePanel->ToggleMouse (true); break;
case BX_TOOLBAR_USER: userbutton_handler (); break;
default:
wxLogDebug ("unknown toolbar id %d", event_queue[i].u.toolbar.button);

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////
// $Id: wxmain.cc,v 1.64 2002-10-07 04:00:59 bdenney Exp $
// $Id: wxmain.cc,v 1.65 2002-10-07 04:49:50 bdenney Exp $
/////////////////////////////////////////////////////////////////
//
// wxmain.cc implements the wxWindows frame, toolbar, menus, and dialogs.
@ -425,7 +425,7 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size,
// Omit config button because the whole wxWindows interface is like
// one really big config button.
//BX_ADD_TOOL(ID_Toolbar_Config, configbutton_xpm, "Runtime Configuration");
BX_ADD_TOOL(ID_Toolbar_Mouse_en, mouse_xpm, "Enable/disable mouse\nAlso, middle mouse button does the same thing.");
BX_ADD_TOOL(ID_Toolbar_Mouse_en, mouse_xpm, "Enable/disable mouse capture\nThere are also two shortcuts for this: F12 and the middle mouse button.");
BX_ADD_TOOL(ID_Toolbar_User, userbutton_xpm, "Keyboard shortcut");
tb->Realize();

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////
// $Id: wxmain.h,v 1.32 2002-10-07 04:01:00 bdenney Exp $
// $Id: wxmain.h,v 1.33 2002-10-07 04:49:50 bdenney Exp $
/////////////////////////////////////////////////////////////////
// This file defines variables and classes that the wxWindows .cc files
// share. It should be included only by wx.cc and wxmain.cc.
@ -145,7 +145,7 @@ public:
void OnPaint(wxPaintEvent& event);
void OnMouse(wxMouseEvent& event);
void MyRefresh ();
void ToggleMouse ();
void ToggleMouse (bool fromToolbar);
private:
wxCursor *blankCursor;
bool needRefresh;