diff --git a/bochs/gui/wxdialog.cc b/bochs/gui/wxdialog.cc index b57aa55a4..5b5e2a128 100644 --- a/bochs/gui/wxdialog.cc +++ b/bochs/gui/wxdialog.cc @@ -550,6 +550,125 @@ void DebugLogDialog::OnKeyEvent(wxKeyEvent& event) } #endif +////////////////////////////////////////////////////////////////////// +// PluginControlDialog implementation +////////////////////////////////////////////////////////////////////// + +// all events go to OnEvent method +BEGIN_EVENT_TABLE(PluginControlDialog, wxDialog) + EVT_BUTTON(-1, PluginControlDialog::OnEvent) + EVT_CHECKBOX(-1, PluginControlDialog::OnEvent) + EVT_TEXT(-1, PluginControlDialog::OnEvent) + EVT_LISTBOX(-1, PluginControlDialog::OnEvent) +END_EVENT_TABLE() + +PluginControlDialog::PluginControlDialog( + wxWindow* parent, + wxWindowID id) + : wxDialog(parent, id, wxT(""), wxDefaultPosition, wxDefaultSize, + wxDEFAULT_DIALOG_STYLE) +{ + SetTitle(wxT("Optional Plugin Control")); + vertSizer = new wxBoxSizer(wxVERTICAL); + horzSizer = new wxBoxSizer(wxHORIZONTAL); + listSizer = new wxBoxSizer(wxVERTICAL); + editSizer = new wxBoxSizer(wxVERTICAL); + buttonSizer = new wxBoxSizer(wxHORIZONTAL); + horzSizer->Add(listSizer, 0, wxALIGN_LEFT); + horzSizer->Add(editSizer, 0, wxALIGN_RIGHT); + vertSizer->Add(horzSizer, 0, wxALIGN_LEFT); + vertSizer->Add(buttonSizer, 0, wxALIGN_CENTER); + // listSizer contents + pluglist = new wxListBox(this, ID_PluginList); + listSizer->Add(pluglist, 0, wxALL, 10); + // editSizer contents + plugname = new wxTextCtrl(this, ID_PluginName, wxT(""), wxDefaultPosition, wxSize(120, -1)); + editSizer->Add(plugname, 0, wxALL, 10); + btn_load = new wxButton(this, ID_Load, wxT("Load")); + editSizer->Add(btn_load, 0, wxALL | wxALIGN_RIGHT, 5); + btn_unload = new wxButton(this, ID_Unload, wxT("Unload")); + editSizer->Add(btn_unload, 0, wxALL | wxALIGN_RIGHT, 5); + // buttonSizer contents + wxButton *btn = new wxButton(this, wxID_HELP, BTNLABEL_HELP); + buttonSizer->Add(btn, 0, wxALL, 5); + btn = new wxButton(this, wxID_OK, BTNLABEL_OK); + buttonSizer->Add(btn, 0, wxALL, 5); + // add loaded plugins to the listbox + bx_list_c *plugin_ctrl = (bx_list_c*) SIM->get_param(BXPN_PLUGIN_CTRL); + unsigned count = plugin_ctrl->get_size(); + for (unsigned i = 0; i < count; i++) { + pluglist->Insert(wxString(plugin_ctrl->get(i)->get_name(), wxConvUTF8), i); + } + btn_load->Enable(0); + btn_unload->Enable(0); +} + +void PluginControlDialog::Init() +{ + SetSizer(vertSizer); + vertSizer->Fit(this); + wxSize size = vertSizer->GetMinSize(); + int margin = 5; + SetSizeHints(size.GetWidth() + margin, size.GetHeight() + margin); + Center(); +} + +void PluginControlDialog::OnEvent(wxCommandEvent& event) +{ + char buf[1024]; + + int id = event.GetId(); + switch (id) { + case ID_PluginList: + if (event.GetEventType() == wxEVT_COMMAND_LISTBOX_SELECTED) { + btn_unload->Enable(1); + } + break; + case ID_PluginName: + if (event.GetEventType() == wxEVT_COMMAND_TEXT_UPDATED) { + btn_load->Enable(!plugname->IsEmpty()); + } + break; + case ID_Load: + { + wxString tmpname(plugname->GetValue()); + strncpy(buf, tmpname.mb_str(wxConvUTF8), sizeof(buf)); + if (SIM->opt_plugin_ctrl(buf, 1)) { + tmpname.Printf(wxT("Plugin '%s' loaded"), buf); + wxMessageBox(tmpname, wxT("Plugin Control"), wxOK | wxICON_INFORMATION, this); + pluglist->Insert(tmpname, pluglist->GetCount()); + } + } + break; + case ID_Unload: + { + int i = pluglist->GetSelection(); + wxString tmpname = pluglist->GetString(i); + strncpy(buf, tmpname.mb_str(wxConvUTF8), sizeof(buf)); + if (SIM->opt_plugin_ctrl(buf, 0)) { + tmpname.Printf(wxT("Plugin '%s' unloaded"), buf); + wxMessageBox(tmpname, wxT("Plugin Control"), wxOK | wxICON_INFORMATION, this); + pluglist->Delete(i); + btn_unload->Enable(0); + } + } + break; + case wxID_OK: + EndModal(wxID_OK); + break; + case wxID_HELP: + ShowHelp(); + break; + default: + event.Skip(); + } +} + +void PluginControlDialog::ShowHelp() +{ + wxMessageBox(MSG_NO_HELP, MSG_NO_HELP_CAPTION, wxOK | wxICON_ERROR, this); +} + ///////////////////////////////////////////////////////////////// // ParamDialog ///////////////////////////////////////////////////////////////// @@ -1162,9 +1281,9 @@ void ParamDialog::OnEvent(wxCommandEvent& event) break; case wxID_CANCEL: if (IsModal ()) - EndModal (wxID_CANCEL); + EndModal (wxID_CANCEL); else - Show (FALSE); + Show (FALSE); break; case wxID_HELP: ShowHelp(); diff --git a/bochs/gui/wxdialog.h b/bochs/gui/wxdialog.h index c3b83e350..2fcf397dc 100644 --- a/bochs/gui/wxdialog.h +++ b/bochs/gui/wxdialog.h @@ -217,6 +217,26 @@ DECLARE_EVENT_TABLE() }; #endif +//////////////////////////////////////////////////////////////////////////// +// PluginControlDialog +//////////////////////////////////////////////////////////////////////////// +class PluginControlDialog: public wxDialog +{ +private: + void Init(); // called automatically by ShowModal() + void ShowHelp(); + wxBoxSizer *vertSizer, *horzSizer, *listSizer, *editSizer, *buttonSizer; + wxTextCtrl *plugname; + wxListBox *pluglist; + wxButton *btn_load, *btn_unload; +public: + PluginControlDialog(wxWindow* parent, wxWindowID id); + ~PluginControlDialog() {} + void OnEvent(wxCommandEvent& event); + int ShowModal() { Init(); return wxDialog::ShowModal(); } +DECLARE_EVENT_TABLE() +}; + //////////////////////////////////////////////////////////////////////////// // ParamDialog is a general purpose dialog box that displays and edits // any combination of parameters. It's always made up of a @@ -474,20 +494,15 @@ public: /************************************************************************** Everything else in here is a comment! - - - //////////////////////////////////////////////////////////////////////////// // proposed dialogs, not implemented //////////////////////////////////////////////////////////////////////////// Here are some quick sketches of what different parts of the interface could look like. None of these is implemented yet, and everything is -open for debate. Whoever writes the wxwidgets code for any of these +open for debate. Whoever writes the wxWidgets code for any of these screens gets several thousand votes! - - Idea for large configuration dialog, based on Netscape's Edit:Preferences dialog box. Here's a sketch of a dialog with all the components that can be configured in a list on the left, and the details of the selected component @@ -599,7 +614,6 @@ CD-ROM button on the toolbar at runtime. | [Help] [Cancel] [Ok] | +---------------------------------------------+ - //////////////////////////////////////////////////////////////////////////// // ChooseConfigDialog //////////////////////////////////////////////////////////////////////////// @@ -631,7 +645,6 @@ could grow. | | +--------------------------------------------------------+ - //////////////////////////////////////////////////////////////////////////// // ChooseBootDialog //////////////////////////////////////////////////////////////////////////// @@ -682,117 +695,8 @@ you can view/edit/load/save key mappings, produce any combination of keys (esp. ones that your OS or window manager won't allow) //////////////////////////////////////////////////////////////////////////// -// ConfigTimeDialog +// new AdvancedLogOptionsDialog //////////////////////////////////////////////////////////////////////////// - -choose IPS -select starting time for CMOS clock -turn on real time PIT or not (?) -VGA update interval - -This dialog can easily allow people to tune the IPS setting, or -various other speed-related values, at runtime. If you're running -some time-sensitive program you could adjust IPS until it's the right -speed, or if Bochs is wasting all of your CPU's cycles you could turn -a dial to some periodic delays to allow other processes a chance to -complete. - -Suggestions from Greg Alexander: -> I'm using O for radio buttons and [ ] for check boxes. -> -> ---------Basic Configure Timing Dialog-------- -> -> Instructions per second: [_________] (maybe have some default options -> and an "other") -> -> Select timing behavior desired: -> -> O Full Speed, Real Time -> (NOT Reproducible) -> O Minimize CPU Use, Real Time -> O Full speed, NOT Real Time -> -> [Advanced] -> -> ----------------------------------------------- -> The logic for the above would look like this: -> All options get the New PIT. -> Option 1 Gets you the Realtime PIT. -> Option 2 Gets you the Slowdown Timer. -> Option 3 Gets you neither. -> -> -------Advanced Configure Timing Dialog-------- -> -> Instructions per second: [_________] -> -> Select PIT Model: -> O Old Model -> O New Model -> O Realtime PIT (not reproducible) -> -> Select Optional Realtime Hacks: -> [ ] Slowdown Timer Maxmult setting [_________] -> [ ] Idle Hack (X Windows Only) -> -> ---------------------------------------------- - -//////////////////////////////////////////////////////////////////////////// -// OtherOptionsDialog -//////////////////////////////////////////////////////////////////////////// - -everything in the bochsrc that doesn't fit into some other category, -or that is used so rarely (e.g. floppy command delay) that it's not worth -laying out manually in a dialog box. This will probably be done in -sort of a grid with parameter name, and value(editable) in different columns - -//////////////////////////////////////////////////////////////////////////// -// LogOptionsDialog -//////////////////////////////////////////////////////////////////////////// -lets you choose which events you want to write to the log, which you -want to ignore, etc. You can do this at a high level, like - -+---- Configure events -----------------------------------+ -| | -| How should Bochs respond to each type of event? | -| | -| Debug events: [ignore] | -| Info events: [ignore] | -| Error events: [report] | -| Panic events: [ask ] | -| | -| For additional control over how each device responds | -| to events, press the "Advanced" button. | -| | -| [ Advanced ] [ Help ] [ Cancel ] [ Ok ] | -+---------------------------------------------------------+ -This sets up the default actions for all devices. The advanced -dialog lets you set different actions per device. I have two -attempts at the advanced dialog. The first creates a large -grid of wxChoice controls which choose between -ignore/report/ask/die. There will be enough rows in this -table that a scrolling subwindow will be needed to fit -all the devices. - -+---- Advanced event configuration -----------------------+ -| | -| This table determines how Bochs will respond to each | -| kind of event coming from a particular source. For | -| example if you are having problems with the keyboard, | -| you could ask for debug and info events from the | -| keyboard to be reported. | -| | -| [Use defaults for all devices] | -+-------------------------------------------------------+-+ -| Device Debug Info Error Panic |^| -| -------- -------- ------- -------- --------- ||| -| Keyboard [ignore] [ignore] [report] [report] ||| -| VGA [ignore] [ignore] [report] [report] ||| -| NE2000 [ignore] [ignore] [report] [report] ||| -| Sound [ignore] [ignore] [report] [report] |v| -+---------------------------------------------------------+ -| [ Help ] [ Cancel ] [ Ok ] | -+-------------------------------------------------------+-+ - Try #2 for the advanced event configuration dialog. It shows the selection of the default actions again at the top, with some explanation. Then at bottom, you @@ -876,8 +780,6 @@ devices at once. | [ Help ] [ Cancel ] [ Ok ] | +-----------------------------------------------------------+ - - //////////////////////////////////////////////////////////////////////////// // ViewMemoryDialog //////////////////////////////////////////////////////////////////////////// @@ -887,10 +789,4 @@ whenever simulation stops (after single steps for example), or we could update periodically. Modeless dialog, and there could be many of them at once, showing different regions of memory. -//////////////////////////////////////////////////////////////////////////// -// DebugControlDialog -//////////////////////////////////////////////////////////////////////////// -has buttons for most common debugger commands such as step, breakpoint, -display registers, or whatever. - *****************************************************************/ diff --git a/bochs/gui/wxmain.cc b/bochs/gui/wxmain.cc index c23b0b905..7615b2689 100644 --- a/bochs/gui/wxmain.cc +++ b/bochs/gui/wxmain.cc @@ -612,7 +612,8 @@ void MyFrame::OnStateRestore(wxCommandEvent& WXUNUSED(event)) void MyFrame::OnEditPluginCtrl(wxCommandEvent& WXUNUSED(event)) { - wxMessageBox(wxT("Not implemented yet!"), wxT("Error"), wxOK | wxICON_ERROR); + PluginControlDialog dlg(this, -1); + dlg.ShowModal(); } void MyFrame::OnEditCPU(wxCommandEvent& WXUNUSED(event)) diff --git a/bochs/gui/wxmain.h b/bochs/gui/wxmain.h index 1636920e0..e3888639e 100644 --- a/bochs/gui/wxmain.h +++ b/bochs/gui/wxmain.h @@ -95,6 +95,11 @@ enum ID_DebugCommand, // advanced log options ID_ApplyDefault, + // dialog box: PluginControlDialog + ID_PluginList, + ID_PluginName, + ID_Load, + ID_Unload, // that's all ID_LAST_USER_DEFINED };