Some wxWidgets fixes

- Fixed ParamDialog::isGeneratediD() (browse button of last item could fail)
- Disable menu items without runtime options
- Partial whitespace cleanup
This commit is contained in:
Volker Ruppert 2013-11-29 16:37:50 +00:00
parent 21bb1363ac
commit 7f3552614d
2 changed files with 78 additions and 73 deletions

View File

@ -600,12 +600,14 @@ void ParamDialog::Init()
static int _next_id = ID_LAST_USER_DEFINED;
int ParamDialog::genId () {
int ParamDialog::genId()
{
return ++_next_id;
}
bool ParamDialog::isGeneratedId (int id) {
return (id >= ID_LAST_USER_DEFINED && id < _next_id);
bool ParamDialog::isGeneratedId(int id)
{
return (id >= ID_LAST_USER_DEFINED && id <= _next_id);
}
void ParamDialog::AddParamList(const char *nameList[], bx_param_c *base, wxFlexGridSizer *sizer, bool plain)
@ -738,29 +740,29 @@ void ParamDialog::AddParam (
char value[1024];
if (!plain) ADD_LABEL(prompt);
bool isFilename = param->get_options() & param->IS_FILENAME;
wxTextCtrl *txtctrl = new wxTextCtrl (context->parent, pstr->id, wxT(""), wxDefaultPosition, isFilename? longTextSize : normalTextSize);
wxTextCtrl *txtctrl = new wxTextCtrl(context->parent, pstr->id, wxT(""), wxDefaultPosition, isFilename? longTextSize : normalTextSize);
if (description) txtctrl->SetToolTip(wxString(description, wxConvUTF8));
param->sprint(value, 1024, 0);
txtctrl->SetValue(wxString(value, wxConvUTF8));
if ((param->get_options() & param->RAW_BYTES) == 0) {
txtctrl->SetMaxLength(param->get_maxsize());
}
sizer->Add (txtctrl, 0, wxALL, 2);
sizer->Add(txtctrl, 0, wxALL, 2);
if (!plain) {
if (isFilename) {
// create Browse button
pstr->browseButtonId = genId ();
pstr->browseButton = new wxButton (context->parent,
pstr->browseButtonId = genId();
pstr->browseButton = new wxButton(context->parent,
pstr->browseButtonId, BTNLABEL_BROWSE);
sizer->Add (pstr->browseButton, 0, wxALL, 2);
idHash->Put (pstr->browseButtonId, pstr); // register under button id
sizer->Add(pstr->browseButton, 0, wxALL, 2);
idHash->Put(pstr->browseButtonId, pstr); // register under button id
} else {
sizer->Add (1, 1); // spacer
sizer->Add(1, 1); // spacer
}
}
pstr->u.text = txtctrl;
idHash->Put (pstr->id, pstr);
paramHash->Put (pstr->param->get_id (), pstr);
idHash->Put(pstr->id, pstr);
paramHash->Put(pstr->param->get_id(), pstr);
break;
}
case BXT_LIST: {
@ -772,9 +774,9 @@ void ParamDialog::AddParam (
wxNotebookSizer *nbsizer = new wxNotebookSizer(notebook);
#endif
// put all items in the list into a separate page of the notebook.
for (int i=0; i<list->get_size (); i++) {
for (int i=0; i<list->get_size(); i++) {
bx_list_c *child = (bx_list_c*)list->get(i);
wxASSERT (child->get_type() == BXT_LIST);
wxASSERT(child->get_type() == BXT_LIST);
// the child must be a list! I could support other things but
// I don't see any reason to. It wouldn't make sense to devote
// a whole tab to a single parameter.
@ -789,7 +791,7 @@ void ParamDialog::AddParam (
// this new context.
bx_list_c *childl = (bx_list_c *)child;
for (int j=0; j<childl->get_size(); j++)
AddParam (childl->get(j), plain, &newcontext);
AddParam(childl->get(j), plain, &newcontext);
const char *pagename = child->get_title();
if (!pagename) pagename = child->get_name();
panel->SetAutoLayout(TRUE);
@ -823,19 +825,19 @@ void ParamDialog::AddParam (
newcontext.gridSizer = NULL; // it will be created if necessary
newcontext.vertSizer = boxsz;
// put all items in the list inside the boxsz sizer.
for (int i=0; i<list->get_size (); i++) {
bx_param_c *child = list->get (i);
AddParam (child, plain, &newcontext);
for (int i=0; i<list->get_size(); i++) {
bx_param_c *child = list->get(i);
AddParam(child, plain, &newcontext);
}
// add the boxsz to vertSizer
context->vertSizer->Add (boxsz, 0, wxALL|wxGROW, 10);
context->vertSizer->Add(boxsz, 0, wxALL|wxGROW, 10);
// clear gridSizer variable so that any future parameters force
// creation of a new one.
context->gridSizer = NULL;
// add to hashes
pstr->u.staticbox = box;
idHash->Put (pstr->id, pstr);
paramHash->Put (pstr->param->get_id (), pstr);
idHash->Put(pstr->id, pstr);
paramHash->Put(pstr->param->get_id(), pstr);
}
break;
}

View File

@ -846,12 +846,15 @@ void MyFrame::simStatusChanged(StatusChange change, bx_bool popupNotify) {
}
}
}
menuEdit->Enable(ID_Edit_Plugins, canConfigure);
menuEdit->Enable(ID_Edit_CPU, canConfigure);
menuEdit->Enable(ID_Edit_CPUID, canConfigure);
menuEdit->Enable(ID_Edit_Memory, canConfigure);
menuEdit->Enable(ID_Edit_Clock_Cmos, canConfigure);
menuEdit->Enable(ID_Edit_PCI, canConfigure);
menuEdit->Enable(ID_Edit_Boot, canConfigure);
menuEdit->Enable(ID_Edit_Network, canConfigure);
menuEdit->Enable(ID_Edit_Other, canConfigure);
// during simulation, certain menu options like the floppy disk
// can be modified under some circumstances. A floppy drive can
// only be edited if it was enabled at boot time.