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:
parent
21bb1363ac
commit
7f3552614d
@ -600,12 +600,14 @@ void ParamDialog::Init()
|
|||||||
|
|
||||||
static int _next_id = ID_LAST_USER_DEFINED;
|
static int _next_id = ID_LAST_USER_DEFINED;
|
||||||
|
|
||||||
int ParamDialog::genId () {
|
int ParamDialog::genId()
|
||||||
|
{
|
||||||
return ++_next_id;
|
return ++_next_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ParamDialog::isGeneratedId (int id) {
|
bool ParamDialog::isGeneratedId(int id)
|
||||||
return (id >= ID_LAST_USER_DEFINED && id < _next_id);
|
{
|
||||||
|
return (id >= ID_LAST_USER_DEFINED && id <= _next_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParamDialog::AddParamList(const char *nameList[], bx_param_c *base, wxFlexGridSizer *sizer, bool plain)
|
void ParamDialog::AddParamList(const char *nameList[], bx_param_c *base, wxFlexGridSizer *sizer, bool plain)
|
||||||
@ -738,77 +740,77 @@ void ParamDialog::AddParam (
|
|||||||
char value[1024];
|
char value[1024];
|
||||||
if (!plain) ADD_LABEL(prompt);
|
if (!plain) ADD_LABEL(prompt);
|
||||||
bool isFilename = param->get_options() & param->IS_FILENAME;
|
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));
|
if (description) txtctrl->SetToolTip(wxString(description, wxConvUTF8));
|
||||||
param->sprint(value, 1024, 0);
|
param->sprint(value, 1024, 0);
|
||||||
txtctrl->SetValue(wxString(value, wxConvUTF8));
|
txtctrl->SetValue(wxString(value, wxConvUTF8));
|
||||||
if ((param->get_options() & param->RAW_BYTES) == 0) {
|
if ((param->get_options() & param->RAW_BYTES) == 0) {
|
||||||
txtctrl->SetMaxLength(param->get_maxsize());
|
txtctrl->SetMaxLength(param->get_maxsize());
|
||||||
}
|
}
|
||||||
sizer->Add (txtctrl, 0, wxALL, 2);
|
sizer->Add(txtctrl, 0, wxALL, 2);
|
||||||
if (!plain) {
|
if (!plain) {
|
||||||
if (isFilename) {
|
if (isFilename) {
|
||||||
// create Browse button
|
// create Browse button
|
||||||
pstr->browseButtonId = genId ();
|
pstr->browseButtonId = genId();
|
||||||
pstr->browseButton = new wxButton (context->parent,
|
pstr->browseButton = new wxButton(context->parent,
|
||||||
pstr->browseButtonId, BTNLABEL_BROWSE);
|
pstr->browseButtonId, BTNLABEL_BROWSE);
|
||||||
sizer->Add (pstr->browseButton, 0, wxALL, 2);
|
sizer->Add(pstr->browseButton, 0, wxALL, 2);
|
||||||
idHash->Put (pstr->browseButtonId, pstr); // register under button id
|
idHash->Put(pstr->browseButtonId, pstr); // register under button id
|
||||||
} else {
|
} else {
|
||||||
sizer->Add (1, 1); // spacer
|
sizer->Add(1, 1); // spacer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pstr->u.text = txtctrl;
|
pstr->u.text = txtctrl;
|
||||||
idHash->Put (pstr->id, pstr);
|
idHash->Put(pstr->id, pstr);
|
||||||
paramHash->Put (pstr->param->get_id (), pstr);
|
paramHash->Put(pstr->param->get_id(), pstr);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case BXT_LIST: {
|
case BXT_LIST: {
|
||||||
bx_list_c *list = (bx_list_c*) param_generic;
|
bx_list_c *list = (bx_list_c*) param_generic;
|
||||||
if (list->get_options() & bx_list_c::USE_TAB_WINDOW) {
|
if (list->get_options() & bx_list_c::USE_TAB_WINDOW) {
|
||||||
// put each item in a separate tab of a tabbed window
|
// put each item in a separate tab of a tabbed window
|
||||||
wxNotebook *notebook = new wxNotebook(context->parent, -1);
|
wxNotebook *notebook = new wxNotebook(context->parent, -1);
|
||||||
#if wxMAJOR_VERSION == 2 && wxMINOR_VERSION < 6
|
#if wxMAJOR_VERSION == 2 && wxMINOR_VERSION < 6
|
||||||
wxNotebookSizer *nbsizer = new wxNotebookSizer(notebook);
|
wxNotebookSizer *nbsizer = new wxNotebookSizer(notebook);
|
||||||
#endif
|
#endif
|
||||||
// put all items in the list into a separate page of the notebook.
|
// 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);
|
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
|
// 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
|
// I don't see any reason to. It wouldn't make sense to devote
|
||||||
// a whole tab to a single parameter.
|
// a whole tab to a single parameter.
|
||||||
wxPanel *panel = new wxPanel(notebook);
|
wxPanel *panel = new wxPanel(notebook);
|
||||||
wxBoxSizer *boxsz = new wxBoxSizer(wxVERTICAL);
|
wxBoxSizer *boxsz = new wxBoxSizer(wxVERTICAL);
|
||||||
AddParamContext newcontext;
|
AddParamContext newcontext;
|
||||||
newcontext.depth = 1 + context->depth;
|
newcontext.depth = 1 + context->depth;
|
||||||
newcontext.parent = panel;
|
newcontext.parent = panel;
|
||||||
newcontext.vertSizer = boxsz;
|
newcontext.vertSizer = boxsz;
|
||||||
newcontext.gridSizer = NULL; // will be created if needed
|
newcontext.gridSizer = NULL; // will be created if needed
|
||||||
// the child itself is a list. Add the child's children in
|
// the child itself is a list. Add the child's children in
|
||||||
// this new context.
|
// this new context.
|
||||||
bx_list_c *childl = (bx_list_c *)child;
|
bx_list_c *childl = (bx_list_c *)child;
|
||||||
for (int j=0; j<childl->get_size(); j++)
|
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();
|
const char *pagename = child->get_title();
|
||||||
if (!pagename) pagename = child->get_name();
|
if (!pagename) pagename = child->get_name();
|
||||||
panel->SetAutoLayout(TRUE);
|
panel->SetAutoLayout(TRUE);
|
||||||
panel->SetSizer(boxsz);
|
panel->SetSizer(boxsz);
|
||||||
notebook->AddPage(panel, wxString(pagename, wxConvUTF8));
|
notebook->AddPage(panel, wxString(pagename, wxConvUTF8));
|
||||||
}
|
}
|
||||||
#if wxMAJOR_VERSION == 2 && wxMINOR_VERSION < 6
|
#if wxMAJOR_VERSION == 2 && wxMINOR_VERSION < 6
|
||||||
context->vertSizer->Add(nbsizer, 0, wxALL|wxGROW, 10);
|
context->vertSizer->Add(nbsizer, 0, wxALL|wxGROW, 10);
|
||||||
#else
|
#else
|
||||||
context->vertSizer->Add(notebook, 0, wxALL|wxGROW, 10);
|
context->vertSizer->Add(notebook, 0, wxALL|wxGROW, 10);
|
||||||
#endif
|
#endif
|
||||||
// clear gridSizer variable so that any future parameters force
|
// clear gridSizer variable so that any future parameters force
|
||||||
// creation of a new one.
|
// creation of a new one.
|
||||||
context->gridSizer = NULL;
|
context->gridSizer = NULL;
|
||||||
// add to hashes
|
// add to hashes
|
||||||
pstr->u.notebook = notebook;
|
pstr->u.notebook = notebook;
|
||||||
idHash->Put(pstr->id, pstr);
|
idHash->Put(pstr->id, pstr);
|
||||||
paramHash->Put(pstr->param->get_id(), pstr);
|
paramHash->Put(pstr->param->get_id(), pstr);
|
||||||
} else {
|
} else {
|
||||||
wxString boxTitle;
|
wxString boxTitle;
|
||||||
if (list->get_options() & bx_list_c::USE_BOX_TITLE) {
|
if (list->get_options() & bx_list_c::USE_BOX_TITLE) {
|
||||||
boxTitle = wxString(prompt, wxConvUTF8);
|
boxTitle = wxString(prompt, wxConvUTF8);
|
||||||
@ -816,28 +818,28 @@ void ParamDialog::AddParam (
|
|||||||
boxTitle = wxT("");
|
boxTitle = wxT("");
|
||||||
}
|
}
|
||||||
wxStaticBox *box = new wxStaticBox(context->parent, -1, boxTitle);
|
wxStaticBox *box = new wxStaticBox(context->parent, -1, boxTitle);
|
||||||
wxStaticBoxSizer *boxsz = new wxStaticBoxSizer(box, wxVERTICAL);
|
wxStaticBoxSizer *boxsz = new wxStaticBoxSizer(box, wxVERTICAL);
|
||||||
AddParamContext newcontext;
|
AddParamContext newcontext;
|
||||||
newcontext.depth = 1 + context->depth;
|
newcontext.depth = 1 + context->depth;
|
||||||
newcontext.parent = context->parent;
|
newcontext.parent = context->parent;
|
||||||
newcontext.gridSizer = NULL; // it will be created if necessary
|
newcontext.gridSizer = NULL; // it will be created if necessary
|
||||||
newcontext.vertSizer = boxsz;
|
newcontext.vertSizer = boxsz;
|
||||||
// put all items in the list inside the boxsz sizer.
|
// put all items in the list inside the boxsz sizer.
|
||||||
for (int i=0; i<list->get_size (); i++) {
|
for (int i=0; i<list->get_size(); i++) {
|
||||||
bx_param_c *child = list->get (i);
|
bx_param_c *child = list->get(i);
|
||||||
AddParam (child, plain, &newcontext);
|
AddParam(child, plain, &newcontext);
|
||||||
}
|
}
|
||||||
// add the boxsz to vertSizer
|
// 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
|
// clear gridSizer variable so that any future parameters force
|
||||||
// creation of a new one.
|
// creation of a new one.
|
||||||
context->gridSizer = NULL;
|
context->gridSizer = NULL;
|
||||||
// add to hashes
|
// add to hashes
|
||||||
pstr->u.staticbox = box;
|
pstr->u.staticbox = box;
|
||||||
idHash->Put (pstr->id, pstr);
|
idHash->Put(pstr->id, pstr);
|
||||||
paramHash->Put (pstr->param->get_id (), pstr);
|
paramHash->Put(pstr->param->get_id(), pstr);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
wxLogError(wxT("ParamDialog::AddParam called with unsupported param type id=%d"), (int)type);
|
wxLogError(wxT("ParamDialog::AddParam called with unsupported param type id=%d"), (int)type);
|
||||||
|
@ -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_CPU, canConfigure);
|
||||||
|
menuEdit->Enable(ID_Edit_CPUID, canConfigure);
|
||||||
menuEdit->Enable(ID_Edit_Memory, canConfigure);
|
menuEdit->Enable(ID_Edit_Memory, canConfigure);
|
||||||
menuEdit->Enable(ID_Edit_Clock_Cmos, canConfigure);
|
menuEdit->Enable(ID_Edit_Clock_Cmos, canConfigure);
|
||||||
menuEdit->Enable(ID_Edit_PCI, canConfigure);
|
menuEdit->Enable(ID_Edit_PCI, canConfigure);
|
||||||
menuEdit->Enable(ID_Edit_Boot, canConfigure);
|
menuEdit->Enable(ID_Edit_Boot, canConfigure);
|
||||||
menuEdit->Enable(ID_Edit_Network, canConfigure);
|
menuEdit->Enable(ID_Edit_Network, canConfigure);
|
||||||
|
menuEdit->Enable(ID_Edit_Other, canConfigure);
|
||||||
// during simulation, certain menu options like the floppy disk
|
// during simulation, certain menu options like the floppy disk
|
||||||
// can be modified under some circumstances. A floppy drive can
|
// can be modified under some circumstances. A floppy drive can
|
||||||
// only be edited if it was enabled at boot time.
|
// only be edited if it was enabled at boot time.
|
||||||
|
Loading…
Reference in New Issue
Block a user