- fixed up ParamDialog to correctly handle "trees" of parameters. A

bx_list_c can now be displayed as either a wxStaticBox with the
  child parameters inside, or as a wxNotebook with each child
  parameter in a separate tab.  (The children can also be lists of
  course.)  The default display is the wxStaticBox type, but if you
  set the option bit bx_list_c::USE_TAB_WINDOW in the list,
  ParamDialog will use the wxNotebook display instead.
- to get the param trees working, I created a new struct
  AddParamContext, which is passed to AddParam().  This struct is
  critical when AddParam calls itself recursively to display lists
  within lists.
- use the wxNotebook display feature for the ATA0,1,2,3 controller
  dialog box.  Now instead of being hundreds of pixels tall, it is
  reasonable height with three different tabs.  This fixed bug
  #619074: "wx: ATA interface editor too tall" and was the whole
  reason I started messing with this at all.

plus some minor cleanups
- when I added the enum constant bx_list_c::USE_TAB_WINDOW, I also
  removed the BX_ prefix from all the other enum constants that are
  used in parameter options in siminterface.cc.  Since these constants
  are enums within a class, there is no possibility of namespace
  conflicts so the prefix is not needed.
- added wxADJUST_MINSIZE to all wxChoice controls, since that tells
  wxWindows to adjust its size to the length of the longest string.
- instead of calling SetSize or SetSizeHints on every textcontrol with
  a hardcoded width, I am using just two wxSize specifications for
  everything: either normalTextSize or longTextSize.
- edit names of a few menus and params.  For example now instead of
  the tab saying "Master ATA device on channel 0" it will say
  "First HD/CD on channel 0".

Modified Files:
  main.cc gui/control.cc gui/gui.cc gui/siminterface.cc gui/siminterface.h
  gui/wxdialog.cc gui/wxdialog.h gui/wxmain.cc
This commit is contained in:
Bryce Denney 2002-10-06 02:37:28 +00:00
parent fdadda0ba8
commit 346e2747d3
8 changed files with 218 additions and 124 deletions

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: control.cc,v 1.63 2002-09-25 22:54:22 bdenney Exp $
// $Id: control.cc,v 1.64 2002-10-06 02:37:27 bdenney Exp $
/////////////////////////////////////////////////////////////////////////
//
// This is code for a text-mode configuration interfac. Note that this file
@ -735,7 +735,7 @@ bx_param_string_c::text_print (FILE *fp)
{
char *value = getptr ();
int opts = options->get ();
if (opts & BX_RAW_BYTES) {
if (opts & RAW_BYTES) {
char buffer[1024];
buffer[0] = 0;
char sep_string[2];
@ -767,15 +767,15 @@ bx_list_c::text_print (FILE *fp)
/*
fprintf (fp, "options=%s%s%s\n",
(options->get () == 0) ? "none" : "",
(options->get () & BX_SHOW_PARENT) ? "SHOW_PARENT " : "",
(options->get () & BX_SERIES_ASK) ? "SERIES_ASK " : "");
(options->get () & SHOW_PARENT) ? "SHOW_PARENT " : "",
(options->get () & SERIES_ASK) ? "SERIES_ASK " : "");
*/
for (int i=0; i<size; i++) {
//fprintf (fp, "param[%d] = %p\n", i, list[i]);
assert (list[i] != NULL);
if (list[i]->get_enabled ()) {
list[i]->text_print (fp);
if (!(options->get () & BX_SERIES_ASK))
if (!(options->get () & SERIES_ASK))
fprintf (fp, "\n");
}
}
@ -883,7 +883,7 @@ bx_param_string_c::text_ask (FILE *fpin, FILE *fpout)
int opts = options->get ();
char buffer2[1024];
strcpy (buffer2, buffer);
if (status == 1 && opts & BX_RAW_BYTES) {
if (status == 1 && opts & RAW_BYTES) {
// copy raw hex into buffer
status = parse_raw_bytes (buffer, buffer2, maxsize, separator);
if (status < 0) {
@ -906,13 +906,13 @@ bx_list_c::text_ask (FILE *fpin, FILE *fpout)
fprintf (fpout, "\n%s\n", my_title);
for (i=0; i<imax; i++) fprintf (fpout, "-");
fprintf (fpout, "\n"); //fprintf (fp, "options=%s\n", options->get ());
if (options->get () & BX_SERIES_ASK) {
if (options->get () & SERIES_ASK) {
for (int i=0; i<size; i++) {
if (list[i]->get_enabled ())
list[i]->text_ask (fpin, fpout);
}
} else {
if (options->get () & BX_SHOW_PARENT)
if (options->get () & SHOW_PARENT)
fprintf (fpout, "0. Return to previous menu\n");
for (int i=0; i<size; i++) {
assert (list[i] != NULL);
@ -925,7 +925,7 @@ bx_list_c::text_ask (FILE *fpin, FILE *fpout)
}
fprintf (fpout, "\n");
Bit32u n = choice->get ();
int min = (options->get () & BX_SHOW_PARENT) ? 0 : 1;
int min = (options->get () & SHOW_PARENT) ? 0 : 1;
int max = size;
int status = ask_uint ("Please choose one: [%d] ", min, max, n, &n, 10);
if (status < 0) return status;

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: gui.cc,v 1.49 2002-09-22 20:56:11 cbothamy Exp $
// $Id: gui.cc,v 1.50 2002-10-06 02:37:27 bdenney Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002 MandrakeSoft S.A.
@ -355,7 +355,7 @@ bx_gui_c::snapshot_handler(void)
#if BX_WITH_WX
int ret = SIM->ask_filename (filename, sizeof(filename),
"Save snapshot as...", "snapshot.txt",
bx_param_string_c::BX_SAVE_FILE_DIALOG);
bx_param_string_c::SAVE_FILE_DIALOG);
if (ret < 0) { // cancelled
free(text_snapshot);
return;

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: siminterface.cc,v 1.70 2002-10-01 13:40:05 bdenney Exp $
// $Id: siminterface.cc,v 1.71 2002-10-06 02:37:27 bdenney Exp $
/////////////////////////////////////////////////////////////////////////
//
// See siminterface.h for description of the siminterface concept.
@ -473,7 +473,7 @@ bx_real_sim_c::ask_filename (char *filename, int maxlen, char *prompt, char *the
// ask_param because I don't intend to register this param.
BxEvent event;
bx_param_string_c param (BXP_NULL, "filename", prompt, the_default, maxlen);
flags |= param.BX_IS_FILENAME;
flags |= param.IS_FILENAME;
param.get_options()->set (flags);
event.type = BX_SYNC_EVT_ASK_PARAM;
event.u.param.param = &param;
@ -982,7 +982,7 @@ bx_param_filename_c::bx_param_filename_c (bx_id id,
int maxsize)
: bx_param_string_c (id, name, description, initial_val, maxsize)
{
get_options()->set (BX_IS_FILENAME);
get_options()->set (IS_FILENAME);
}
bx_param_string_c::~bx_param_string_c ()
@ -1021,7 +1021,7 @@ bx_param_string_c::set_handler (param_string_event_handler handler)
Bit32s
bx_param_string_c::get (char *buf, int len)
{
if (options->get () & BX_RAW_BYTES)
if (options->get () & RAW_BYTES)
memcpy (buf, val, len);
else
strncpy (buf, val, len);
@ -1036,7 +1036,7 @@ bx_param_string_c::get (char *buf, int len)
void
bx_param_string_c::set (char *buf)
{
if (options->get () & BX_RAW_BYTES)
if (options->get () & RAW_BYTES)
memcpy (val, buf, maxsize);
else
strncpy (val, buf, maxsize);

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: siminterface.h,v 1.75 2002-10-05 23:11:59 bdenney Exp $
// $Id: siminterface.h,v 1.76 2002-10-06 02:37:28 bdenney Exp $
/////////////////////////////////////////////////////////////////////////
//
// Before I can describe what this file is for, I have to make the
@ -149,6 +149,10 @@ typedef enum {
BXP_FLOPPYB_TYPE,
BXP_FLOPPYB_STATUS,
BXP_FLOPPYB,
BXP_ATA0_MENU,
BXP_ATA1_MENU,
BXP_ATA2_MENU,
BXP_ATA3_MENU,
BXP_ATA0,
BXP_ATA1,
BXP_ATA2,
@ -928,11 +932,11 @@ class bx_param_string_c : public bx_param_c {
char separator;
public:
enum {
BX_RAW_BYTES = 1, // use binary text editor, like MAC addr
BX_IS_FILENAME = 2, // 1=yes it's a filename, 0=not a filename.
// Some guis have a file browser. This
// bit suggests that they use it.
BX_SAVE_FILE_DIALOG = 4 // Use save dialog opposed to open file dialog
RAW_BYTES = 1, // use binary text editor, like MAC addr
IS_FILENAME = 2, // 1=yes it's a filename, 0=not a filename.
// Some guis have a file browser. This
// bit suggests that they use it.
SAVE_FILE_DIALOG = 4 // Use save dialog opposed to open file dialog
} bx_string_opt_bits;
bx_param_string_c (bx_id id,
char *name,
@ -955,7 +959,7 @@ public:
// Declare a filename class. It is identical to a string, except that
// it initializes the options differently. This is just a shortcut
// for declaring a string param and setting the options with BX_IS_FILENAME.
// for declaring a string param and setting the options with IS_FILENAME.
class bx_param_filename_c : public bx_param_string_c {
public:
bx_param_filename_c (bx_id id,
@ -990,11 +994,16 @@ public:
enum {
// When a bx_list_c is displayed as a menu, SHOW_PARENT controls whether or
// not the menu shows a "Return to parent menu" choice or not.
BX_SHOW_PARENT = (1<<0),
SHOW_PARENT = (1<<0),
// Some lists are best displayed shown as menus, others as a series of
// related questions. This bit suggests to the CI that the
// series of questions format is preferred.
BX_SERIES_ASK = (1<<1)
// related questions. This bit suggests to the CI that the series of
// questions format is preferred.
SERIES_ASK = (1<<1),
// When a bx_list_c is displayed in a dialog, BX_USE_TAB_WINDOW suggests
// to the CI that each item in the list should be shown as a separate
// tab. This would be most appropriate when each item is another list
// of parameters.
USE_TAB_WINDOW = (1<<2)
} bx_listopt_bits;
bx_list_c (bx_id id, int maxsize);
bx_list_c (bx_id id, char *name, char *description, bx_param_c **init_list);

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////
// $Id: wxdialog.cc,v 1.44 2002-09-30 22:15:20 bdenney Exp $
// $Id: wxdialog.cc,v 1.45 2002-10-06 02:37:28 bdenney Exp $
/////////////////////////////////////////////////////////////////
//
// misc/wxdialog.cc
@ -17,6 +17,7 @@
#include <wx/spinctrl.h>
#include <wx/config.h>
#include <wx/confbase.h>
#include <wx/notebook.h>
#include "config.h" // definitions based on configure script
#include "osdep.h" // workarounds for missing stuff
@ -39,6 +40,7 @@ enum {
};
wxSize longTextSize (300, -1); // width=300, height=default
wxSize normalTextSize (180, -1); // width=200, height=default
//////////////////////////////////////////////////////////////////////
// LogMsgAskDialog implementation
@ -208,7 +210,7 @@ FloppyConfigDialog::FloppyConfigDialog(
wxStaticText *captext = new wxStaticText (this, -1, FLOPPY_CONFIG_CAP);
capacity = new wxChoice (this, -1);
capacitySizer->Add (captext, 0, wxALL, 5);
capacitySizer->Add (capacity, 0, wxALL, 5);
capacitySizer->Add (capacity, 0, wxALL|wxADJUST_MINSIZE, 5);
// contents of buttonSizer
btn = new wxButton (this, wxID_HELP, "Help");
buttonSizer->Add (btn, 0, wxALL, 5);
@ -222,8 +224,7 @@ FloppyConfigDialog::FloppyConfigDialog(
// create filename and diskImageRadioBtn so that we can tweak them before
// Init comes. However don't add it to any sizer yet because it needs to go
// in after the last radio button.
filename = new wxTextCtrl (this, ID_FilenameText);
filename->SetSize (300, filename->GetSize ().GetHeight ());
filename = new wxTextCtrl (this, ID_FilenameText, "", wxDefaultPosition, longTextSize);
diskImageRadioBtn = new wxRadioButton (this, ID_Filename, FLOPPY_CONFIG_DISKIMG);
// the radioSizer contents will be added by successive calls to
@ -433,8 +434,7 @@ HDConfigDialog::HDConfigDialog(
wxStaticText *text;
text = new wxStaticText (this, -1, HD_CONFIG_DISKIMG);
hsizer[0]->Add (text);
filename = new wxTextCtrl (this, ID_FilenameText);
filename->SetSize (300, filename->GetSize ().GetHeight ());
filename = new wxTextCtrl (this, ID_FilenameText, "", wxDefaultPosition, longTextSize);
hsizer[0]->Add (filename, 1);
wxButton *btn = new wxButton (this, ID_Browse, BTNLABEL_BROWSE);
hsizer[0]->Add (btn);
@ -650,8 +650,7 @@ CdromConfigDialog::CdromConfigDialog(
fileSizer = new wxBoxSizer (wxHORIZONTAL);
diskImageRadioBtn = new wxRadioButton (this, -1, CDROM_CONFIG_DISKIMG);
fileSizer->Add (diskImageRadioBtn, 0);
filename = new wxTextCtrl (this, ID_FilenameText);
filename->SetSize (300, filename->GetSize ().GetHeight ());
filename = new wxTextCtrl (this, ID_FilenameText, "", wxDefaultPosition, longTextSize);
fileSizer->Add (filename, 1, wxLEFT, 5);
wxButton *btn = new wxButton (this, ID_Browse, BTNLABEL_BROWSE);
fileSizer->Add (btn, 0, wxALL, 5);
@ -832,7 +831,7 @@ NetConfigDialog::NetConfigDialog(
// gridSizer contents
gridSizer->AddGrowableCol (1);
#define add(x) gridSizer->Add (x, 0, wxALL, 5)
#define add(x) gridSizer->Add (x, 0, wxALL|wxADJUST_MINSIZE, 5)
#define add_grow(x) gridSizer->Add (x, 1, wxALL|wxGROW, 5)
#define label(x) (new wxStaticText (this, -1, x))
add (label (NET_CONFIG_EN));
@ -840,24 +839,21 @@ NetConfigDialog::NetConfigDialog(
gridSizer->Add (30, 30);
gridSizer->Add (30, 30);
add (label (NET_CONFIG_IO));
add (io = new wxTextCtrl (this, -1));
add (io = new wxTextCtrl (this, -1, "", wxDefaultPosition, normalTextSize));
add (label (NET_CONFIG_IRQ));
add (irq = new wxSpinCtrl (this, -1));
add (label (NET_CONFIG_MAC));
add (mac = new wxTextCtrl (this, -1));
add (mac = new wxTextCtrl (this, -1, "", wxDefaultPosition, normalTextSize));
add (label (NET_CONFIG_CONN));
add (conn = new wxChoice (this, -1));
add (label (NET_CONFIG_PHYS));
add (phys = new wxTextCtrl (this, -1));
add (phys = new wxTextCtrl (this, -1, "", wxDefaultPosition, normalTextSize));
add (label (NET_CONFIG_SCRIPT));
add_grow (script = new wxTextCtrl (this, -1));
add_grow (script = new wxTextCtrl (this, -1, "", wxDefaultPosition, normalTextSize));
#undef label
#undef add
irq->SetRange (0, 15);
conn->SetSizeHints (200, conn->GetSize ().GetHeight ());
mac->SetSizeHints (200, mac->GetSize ().GetHeight ());
script->SetSizeHints (200, script->GetSize ().GetHeight ());
// buttonSizer contents
wxButton *btn = new wxButton (this, wxID_HELP, BTNLABEL_HELP);
@ -1473,8 +1469,6 @@ ConfigMemoryDialog::ConfigMemoryDialog(
#undef addrt
#undef newlabel
#undef spacer
biosImage->SetSizeHints (300, biosImage->GetSize().GetHeight ());
vgabiosImage->SetSizeHints (300, biosImage->GetSize().GetHeight ());
// box2 contents
box2gridSizer = new wxFlexGridSizer (3);
@ -1486,7 +1480,6 @@ ConfigMemoryDialog::ConfigMemoryDialog(
for (int i=0; i<CONFIG_MEMORY_N_ROMS; i++) {
addrt (newlabel (box2_label[2*i]));
add (rom[i] = newlongtext ());
rom[i]->SetSizeHints (300, rom[i]->GetSize().GetHeight ());
add (newbrowse ());
addrt (newlabel (box2_label[2*i + 1]));
add (romAddr[i] = new wxTextCtrl (this, -1));
@ -1725,7 +1718,6 @@ ParamDialog::ParamDialog(
// top level objects
mainSizer = new wxBoxSizer (wxVERTICAL);
gridSizer = NULL;
// create buttonSizer, which will hold all the buttons.
buttonSizer = new wxBoxSizer (wxHORIZONTAL);
@ -1795,38 +1787,64 @@ void ParamDialog::AddParamList (bx_id *idList, wxFlexGridSizer *sizer, bool plai
bx_id *idptr;
for (idptr = idList; *idptr != BXP_NULL; idptr++) {
bx_param_c *param = SIM->get_param (*idptr);
if (param != NULL)
if (param != NULL) {
AddParam (param, sizer, plain);
}
}
}
void ParamDialog::AddParam (bx_param_c *param_generic, wxFlexGridSizer *sizer, bool plain)
// support "legacy" addparam functions. Easier than changing them.
void ParamDialog::AddParam (bx_param_c *param, wxFlexGridSizer *sizer, bool plain = false)
{
AddParamContext context;
context.depth = 0;
context.parent = this;
context.vertSizer = mainSizer;
context.gridSizer = sizer;
AddParam (param, plain, &context);
}
void ParamDialog::AddParam (
bx_param_c *param_generic,
bool plain,
AddParamContext *context)
{
AddParamContext defaultContext;
if (context == NULL) {
context = &defaultContext;
context->depth = 0;
context->parent = this;
context->vertSizer = mainSizer;
context->gridSizer = NULL;
}
wxASSERT (context->parent != NULL);
wxASSERT (context->vertSizer != NULL);
if (param_generic == NULL)
return; // param not registered, probably this option was not compiled in
if (sizer == NULL) {
// add to default gridSizer. Create a gridSizer if none exists yet.
if (gridSizer == NULL) {
gridSizer = new wxFlexGridSizer (3);
mainSizer->Add (gridSizer);
}
sizer = gridSizer;
wxLogDebug ("AddParam for param '%s'", param_generic->get_name ());
if (context->gridSizer == NULL) {
// create a gridSizer if none exists yet. add it to default vertSizer.
context->gridSizer = new wxFlexGridSizer (3);
context->vertSizer->Add (context->gridSizer);
}
wxFlexGridSizer *sizer = context->gridSizer;
ParamStruct *pstr = new ParamStruct ();
pstr->id = genId ();
pstr->param = param_generic;
pstr->id = genId ();
pstr->label = NULL;
pstr->u.window = NULL;
pstr->browseButton = NULL;
int type = param_generic->get_type ();
char *prompt = pstr->param->get_ask_format ();
if (!prompt) prompt = pstr->param->get_name ();
wxASSERT (prompt != NULL);
#define ADD_LABEL(x) sizer->Add (pstr->label = new wxStaticText (this, -1, wxString (x)), 0, wxALIGN_RIGHT|wxALL, 3)
#define ADD_LABEL(x) sizer->Add (pstr->label = new wxStaticText (context->parent, -1, wxString (x)), 0, wxALIGN_RIGHT|wxALL, 3)
switch (type) {
case BXT_PARAM_BOOL: {
bx_param_bool_c *param = (bx_param_bool_c*) param_generic;
if (!plain) ADD_LABEL (prompt);
wxCheckBox *ckbx = new wxCheckBox (this, pstr->id, "");
wxCheckBox *ckbx = new wxCheckBox (context->parent, pstr->id, "");
ckbx->SetValue (param->get ());
sizer->Add (ckbx);
if (!plain) sizer->Add (1, 1); // spacer
@ -1838,7 +1856,7 @@ void ParamDialog::AddParam (bx_param_c *param_generic, wxFlexGridSizer *sizer, b
case BXT_PARAM_NUM: {
bx_param_num_c *param = (bx_param_num_c*) param_generic;
if (!plain) ADD_LABEL (prompt);
wxTextCtrl *textctrl = new wxTextCtrl (this, pstr->id, "");
wxTextCtrl *textctrl = new wxTextCtrl (context->parent, pstr->id, "", wxDefaultPosition, normalTextSize);
const char *format = param->get_format ();
if (!format)
format = strdup(param->get_base () == 16 ? "0x%X" : "%d");
@ -1853,8 +1871,8 @@ void ParamDialog::AddParam (bx_param_c *param_generic, wxFlexGridSizer *sizer, b
case BXT_PARAM_ENUM: {
bx_param_enum_c *param = (bx_param_enum_c*) param_generic;
if (!plain) ADD_LABEL (prompt);
wxChoice *choice = new wxChoice (this, pstr->id);
sizer->Add (choice);
wxChoice *choice = new wxChoice (context->parent, pstr->id);
sizer->Add (choice, 0, wxADJUST_MINSIZE);
if (!plain) sizer->Add (1, 1); // spacer
// fill in the choices
int i=0;
@ -1870,15 +1888,15 @@ void ParamDialog::AddParam (bx_param_c *param_generic, wxFlexGridSizer *sizer, b
case BXT_PARAM_STRING: {
bx_param_string_c *param = (bx_param_string_c*) param_generic;
if (!plain) ADD_LABEL (prompt);
bool isFilename = param->get_options ()->get () & param->BX_IS_FILENAME;
wxTextCtrl *txtctrl = new wxTextCtrl (this, pstr->id, "", wxDefaultPosition, isFilename? longTextSize : wxDefaultSize);
bool isFilename = param->get_options ()->get () & param->IS_FILENAME;
wxTextCtrl *txtctrl = new wxTextCtrl (context->parent, pstr->id, "", wxDefaultPosition, isFilename? longTextSize : normalTextSize);
txtctrl->SetValue (param->getptr ());
sizer->Add (txtctrl);
if (!plain) {
if (isFilename) {
// create Browse button
pstr->browseButtonId = genId ();
pstr->browseButton = new wxButton (this,
pstr->browseButton = new wxButton (context->parent,
pstr->browseButtonId, BTNLABEL_BROWSE);
sizer->Add (pstr->browseButton, 0, wxALL, 5);
idHash->Put (pstr->browseButtonId, pstr); // register under button id
@ -1892,26 +1910,68 @@ void ParamDialog::AddParam (bx_param_c *param_generic, wxFlexGridSizer *sizer, b
break;
}
case BXT_LIST: {
bx_list_c *list = (bx_list_c*) param_generic;
wxStaticBox *box = new wxStaticBox (this, -1, prompt);
wxStaticBoxSizer *boxsz = new wxStaticBoxSizer (box, wxVERTICAL);
wxFlexGridSizer *gridSz = new wxFlexGridSizer (3);
boxsz->Add (gridSz, 1, wxGROW|wxALL, 10);
// 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, gridSz);
}
// add the boxsz to mainSizer
mainSizer->Add (boxsz, 0, wxALL|wxGROW, 10);
// clear gridSizer variable so that any future parameters force
// creation of a new one.
gridSizer = NULL;
// add to hashes
pstr->u.staticbox = box;
idHash->Put (pstr->id, pstr);
paramHash->Put (pstr->param->get_id (), pstr);
break;
bx_list_c *list = (bx_list_c*) param_generic;
if (list->get_options()->get () & bx_list_c::USE_TAB_WINDOW) {
// put each item in a separate tab of a tabbed window
wxNotebook *notebook = new wxNotebook (context->parent, -1);
wxNotebookSizer *nbsizer = new wxNotebookSizer (notebook);
// put all items in the list into a separate page of the notebook.
for (int i=0; i<list->get_size (); i++) {
bx_param_c *child = list->get (i);
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.
wxPanel *panel = new wxPanel (notebook);
wxBoxSizer *boxsz = new wxBoxSizer (wxVERTICAL);
AddParamContext newcontext;
newcontext.depth = 1 + context->depth;
newcontext.parent = panel;
newcontext.vertSizer = boxsz;
newcontext.gridSizer = NULL; // will be created if needed
// the child itself is a list. Add the child's children in
// 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);
const char *pagename = child->get_ask_format ();
if (!pagename) pagename = child->get_name ();
panel->SetAutoLayout (TRUE);
panel->SetSizer (boxsz);
notebook->AddPage (panel, wxString(pagename));
}
context->vertSizer->Add (nbsizer, 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.notebook = notebook;
idHash->Put (pstr->id, pstr);
paramHash->Put (pstr->param->get_id (), pstr);
} else {
wxStaticBox *box = new wxStaticBox (context->parent, -1, prompt);
wxStaticBoxSizer *boxsz = new wxStaticBoxSizer (box, wxVERTICAL);
AddParamContext newcontext;
newcontext.depth = 1 + context->depth;
newcontext.parent = context->parent;
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);
}
// add the boxsz to vertSizer
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);
}
break;
}
default:
wxLogError ("ParamDialog::AddParam called with unsupported param type id=%d", (int)type);

View File

@ -1,5 +1,5 @@
////////////////////////////////////////////////////////////////////
// $Id: wxdialog.h,v 1.41 2002-09-25 21:28:49 bdenney Exp $
// $Id: wxdialog.h,v 1.42 2002-10-06 02:37:28 bdenney Exp $
////////////////////////////////////////////////////////////////////
//
// wxWindows dialogs for Bochs
@ -729,22 +729,37 @@ struct ParamStruct : public wxObject {
int id;
wxStaticText *label;
union _u_tag {
void *ptr;
wxWindow *window;
wxChoice *choice;
wxTextCtrl *text;
wxCheckBox *checkbox;
wxStaticBox *staticbox;
wxNotebook *notebook;
} u;
int browseButtonId; // only for filename params
wxButton *browseButton; // only for filename params
ParamStruct() { param = NULL; u.window = NULL; browseButton = NULL; }
};
// This context structure is used by AddParam to keep track of where the
// next parameter's controls should be added. When AddParam is called on
// a list of parameters (bx_list_c), it calls itself recursively to add
// the child parameters, which in turn could be lists as well. When it
// calls itself recursively, it will create a new AddParamContext so that
// the various children can be added in the right place.
struct AddParamContext {
int depth;
wxWindow *parent;
wxBoxSizer *vertSizer;
wxFlexGridSizer *gridSizer;
};
class ParamDialog: public wxDialog
{
private:
void ShowHelp ();
wxFlexGridSizer *gridSizer;
wxChoice *type;
wxTextCtrl *serialDelay, *pasteDelay, *mappingFile;
wxCheckBox *enableKeymap;
@ -772,7 +787,6 @@ public:
void OnEvent (wxCommandEvent& event);
wxButton* AddButton(int id, wxString label);
virtual void AddDefaultButtons ();
void BeginParamGrid (wxFlexGridSizer *gs = NULL) { gridSizer = gs; }
virtual void Init (); // called automatically by ShowModal()
int ShowModal() {
Init();
@ -782,7 +796,8 @@ public:
return ret;
}
bool Show (bool val) { isShowing = val; return wxDialog::Show (val); }
void AddParam (bx_param_c *param, wxFlexGridSizer *sizer = NULL, bool plain = false);
void AddParam (bx_param_c *param, wxFlexGridSizer *sizer, bool plain = false);
void AddParam (bx_param_c *param, bool plain = false, AddParamContext *context = NULL);
void AddParamList (bx_id *idList, wxFlexGridSizer *sizer = NULL, bool plain = false);
virtual void CopyParamToGui ();
bool IsShowing () { return isShowing; }

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////
// $Id: wxmain.cc,v 1.61 2002-09-27 19:12:56 bdenney Exp $
// $Id: wxmain.cc,v 1.62 2002-10-06 02:37:28 bdenney Exp $
/////////////////////////////////////////////////////////////////
//
// wxmain.cc implements the wxWindows frame, toolbar, menus, and dialogs.
@ -340,10 +340,10 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size,
menuEdit = new wxMenu;
menuEdit->Append( ID_Edit_FD_0, "Floppy Disk &0..." );
menuEdit->Append( ID_Edit_FD_1, "Floppy Disk &1..." );
menuEdit->Append( ID_Edit_ATA0, "ATA Controller 0..." );
menuEdit->Append( ID_Edit_ATA1, "ATA Controller 1..." );
menuEdit->Append( ID_Edit_ATA2, "ATA Controller 2..." );
menuEdit->Append( ID_Edit_ATA3, "ATA Controller 3..." );
menuEdit->Append( ID_Edit_ATA0, "ATA Channel 0..." );
menuEdit->Append( ID_Edit_ATA1, "ATA Channel 1..." );
menuEdit->Append( ID_Edit_ATA2, "ATA Channel 2..." );
menuEdit->Append( ID_Edit_ATA3, "ATA Channel 3..." );
menuEdit->Append( ID_Edit_Boot, "&Boot..." );
menuEdit->Append( ID_Edit_Memory, "&Memory..." );
menuEdit->Append( ID_Edit_Sound, "&Sound..." );
@ -1014,10 +1014,10 @@ MyFrame::HandleAskParamString (bx_param_string_c *param)
if (!msg) msg = param->get_description ();
char *newval = NULL;
wxDialog *dialog = NULL;
if (n_opt & param->BX_IS_FILENAME) {
if (n_opt & param->IS_FILENAME) {
// use file open dialog
long style =
(n_opt & param->BX_SAVE_FILE_DIALOG) ? wxSAVE|wxOVERWRITE_PROMPT : wxOPEN;
(n_opt & param->SAVE_FILE_DIALOG) ? wxSAVE|wxOVERWRITE_PROMPT : wxOPEN;
wxLogDebug ("HandleAskParamString: create dialog");
wxFileDialog *fdialog = new wxFileDialog (this, msg, "", "", "*.*", style);
wxLogDebug ("HandleAskParamString: before showmodal");
@ -1307,9 +1307,7 @@ void MyFrame::editATAConfig (int channel)
{
ParamDialog dlg (this, -1);
dlg.SetTitle ("Configure ATA0");
dlg.AddParam (SIM->get_param ((bx_id)(BXP_ATA0+channel)));
dlg.AddParam (SIM->get_param ((bx_id)(BXP_ATA0_MASTER+channel*2)));
dlg.AddParam (SIM->get_param ((bx_id)(BXP_ATA0_SLAVE+channel*2)));
dlg.AddParam (SIM->get_param ((bx_id)(BXP_ATA0_MENU+channel)));
dlg.ShowModal ();
}

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: main.cc,v 1.156 2002-10-03 05:28:56 bdenney Exp $
// $Id: main.cc,v 1.157 2002-10-06 02:37:27 bdenney Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002 MandrakeSoft S.A.
@ -376,7 +376,7 @@ void bx_init_options ()
NULL
};
menu = new bx_list_c (BXP_FLOPPYA, "Floppy Disk 0", "All options for first floppy disk", floppya_init_list);
menu->get_options ()->set (menu->BX_SERIES_ASK);
menu->get_options ()->set (menu->SERIES_ASK);
bx_options.floppya.Opath->set_handler (bx_param_string_handler);
bx_options.floppya.Opath->set ("none");
bx_options.floppya.Otype->set_handler (bx_param_handler);
@ -422,7 +422,7 @@ void bx_init_options ()
NULL
};
menu = new bx_list_c (BXP_FLOPPYB, "Floppy Disk 1", "All options for second floppy disk", floppyb_init_list);
menu->get_options ()->set (menu->BX_SERIES_ASK);
menu->get_options ()->set (menu->SERIES_ASK);
bx_options.floppyb.Opath->set_handler (bx_param_string_handler);
bx_options.floppyb.Opath->set ("none");
bx_options.floppyb.Otype->set_handler (bx_param_handler);
@ -438,14 +438,14 @@ void bx_init_options ()
"ATA channel 3",
};
char *s_atadevice[4][2] = {
{ "Master ATA device on channel 0",
"Slave ATA device on channel 0" },
{ "Master ATA device on channel 1",
"Slave ATA device on channel 1" },
{ "Master ATA device on channel 2",
"Slave ATA device on channel 2" },
{ "Master ATA device on channel 3",
"Slave ATA device on channel 3" }
{ "First HD/CD on channel 0",
"Second HD/CD on channel 0" },
{ "First HD/CD on channel 1",
"Second HD/CD on channel 1" },
{ "First HD/CD on channel 2",
"Second HD/CD on channel 2" },
{ "First HD/CD on channel 3",
"Second HD/CD on channel 3" }
};
Bit16u ata_default_ioaddr1[BX_MAX_ATA_CHANNEL] = {
0x1f0, 0x170, 0x1e8, 0x168
@ -455,12 +455,13 @@ void bx_init_options ()
};
bx_list_c *ata[BX_MAX_ATA_CHANNEL];
bx_list_c *ata_menu[BX_MAX_ATA_CHANNEL];
Bit8u channel;
for (channel=0; channel<BX_MAX_ATA_CHANNEL; channel ++) {
ata[channel] = new bx_list_c ((bx_id)(BXP_ATA0+channel), s_atachannel[channel], s_atachannel[channel], 8);
ata[channel]->get_options ()->set (ata[channel]->BX_SERIES_ASK);
ata[channel]->get_options ()->set (bx_list_c::SERIES_ASK);
ata[channel]->add (bx_options.ata[channel].Opresent = new bx_param_bool_c ((bx_id)(BXP_ATA0_PRESENT+channel),
"ata:present",
@ -498,7 +499,7 @@ void bx_init_options ()
s_atadevice[channel][slave],
s_atadevice[channel][slave],
12 /* list max size */);
menu->get_options ()->set (menu->BX_SERIES_ASK);
menu->get_options ()->set (menu->SERIES_ASK);
menu->add (bx_options.atadevice[channel][slave].Opresent = new bx_param_bool_c ((bx_id)(BXP_ATA0_MASTER_PRESENT+channel*2+slave),
"ata-device:present",
@ -567,6 +568,17 @@ void bx_init_options ()
bx_options.ata[channel].Opresent->get_dependent_list()->add (
bx_options.atadevice[channel][slave].Opresent);
}
// set up top level menu for ATA[i] controller configuration. This list
// controls what will appear on the ATA configure dialog. It now
// requests the USE_TAB_WINDOW display, which is implemented in wx.
char buffer[32];
sprintf (buffer, "Configure ATA%d", channel);
ata_menu[channel] = new bx_list_c ((bx_id)(BXP_ATA0_MENU+channel), strdup(buffer), "", 4);
ata_menu[channel]->add (ata[channel]);
ata_menu[channel]->add (bx_options.atadevice[channel][0].Omenu);
ata_menu[channel]->add (bx_options.atadevice[channel][1].Omenu);
ata_menu[channel]->get_options()->set (bx_list_c::USE_TAB_WINDOW);
}
// Enable first ata interface by default, disable the others.
@ -580,7 +592,7 @@ void bx_init_options ()
for (channel=0; channel<BX_MAX_ATA_CHANNEL; channel ++) {
bx_options.ata[channel].Opresent->set_ask_format (
BX_WITH_WX? "Enable?"
BX_WITH_WX? "Enable this channel?"
: "Channel is enabled: [%s] ");
bx_options.ata[channel].Oioaddr1->set_ask_format (
BX_WITH_WX? "I/O Address 1:"
@ -603,7 +615,7 @@ void bx_init_options ()
for (Bit8u slave=0; slave<2; slave++) {
bx_options.atadevice[channel][slave].Opresent->set_ask_format (
BX_WITH_WX? "Enable?"
BX_WITH_WX? "Enable this device?"
: "Device is enabled: [%s] ");
bx_options.atadevice[channel][slave].Otype->set_ask_format (
BX_WITH_WX? "Type of ATA device:"
@ -703,7 +715,7 @@ void bx_init_options ()
NULL
};
menu = new bx_list_c (BXP_MENU_DISK, "Bochs Disk Options", "diskmenu", disk_menu_init_list);
menu->get_options ()->set (menu->BX_SHOW_PARENT);
menu->get_options ()->set (menu->SHOW_PARENT);
// memory options menu
bx_options.memory.Osize = new bx_param_num_c (BXP_MEM_SIZE,
@ -773,7 +785,7 @@ void bx_init_options ()
"Serial and Parallel Port Options",
"serial_parallel_menu",
par_ser_init_list);
menu->get_options ()->set (menu->BX_SHOW_PARENT);
menu->get_options ()->set (menu->SHOW_PARENT);
bx_options.rom.Opath = new bx_param_filename_c (BXP_ROM_PATH,
"romimage",
@ -861,7 +873,7 @@ void bx_init_options ()
NULL
};
menu = new bx_list_c (BXP_MENU_MEMORY, "Bochs Memory Options", "memmenu", memory_init_list);
menu->get_options ()->set (menu->BX_SHOW_PARENT);
menu->get_options ()->set (menu->SHOW_PARENT);
// interface
bx_options.Ovga_update_interval = new bx_param_num_c (BXP_VGA_UPDATE_INTERVAL,
@ -908,7 +920,7 @@ void bx_init_options ()
NULL
};
menu = new bx_list_c (BXP_MENU_INTERFACE, "Bochs Interface Menu", "intfmenu", interface_init_list);
menu->get_options ()->set (menu->BX_SHOW_PARENT);
menu->get_options ()->set (menu->SHOW_PARENT);
// NE2K options
bx_options.ne2k.Ovalid = new bx_param_bool_c (BXP_NE2K_VALID,
@ -930,7 +942,7 @@ void bx_init_options ()
"MAC Address",
"to be written",
"", 6);
bx_options.ne2k.Omacaddr->get_options ()->set (bx_options.ne2k.Omacaddr->BX_RAW_BYTES);
bx_options.ne2k.Omacaddr->get_options ()->set (bx_options.ne2k.Omacaddr->RAW_BYTES);
bx_options.ne2k.Omacaddr->set_separator (':');
bx_options.ne2k.Oethmod = new bx_param_string_c (BXP_NE2K_ETHMOD,
"Ethernet module",
@ -956,7 +968,7 @@ void bx_init_options ()
NULL
};
menu = new bx_list_c (BXP_NE2K, "NE2K Configuration", "", ne2k_init_list);
menu->get_options ()->set (menu->BX_SHOW_PARENT);
menu->get_options ()->set (menu->SHOW_PARENT);
bx_options.ne2k.Ovalid->set_handler (bx_param_handler);
bx_options.ne2k.Ovalid->set (0);
@ -1009,7 +1021,7 @@ void bx_init_options ()
NULL
};
menu = new bx_list_c (BXP_SB16, "SB16 Configuration", "", sb16_init_list);
menu->get_options ()->set (menu->BX_SHOW_PARENT);
menu->get_options ()->set (menu->SHOW_PARENT);
// sb16_dependent_list is a null-terminated list including all the
// sb16 fields except for the "present" field. These will all be enabled/
// disabled according to the value of the present field.
@ -1064,7 +1076,7 @@ void bx_init_options ()
bx_options.load32bitOSImage.Oiolog->set_ask_format ("Enter pathname of I/O log: [%s] ");
bx_options.load32bitOSImage.Oinitrd->set_ask_format ("Enter pathname of initrd: [%s] ");
menu = new bx_list_c (BXP_LOAD32BITOS, "32-bit OS Loader", "", loader_init_list);
menu->get_options ()->set (menu->BX_SERIES_ASK);
menu->get_options ()->set (menu->SERIES_ASK);
bx_options.load32bitOSImage.OwhichOS->set_handler (bx_param_handler);
bx_options.load32bitOSImage.OwhichOS->set (Load32bitOSNone);
@ -1158,7 +1170,7 @@ void bx_init_options ()
NULL
};
menu = new bx_list_c (BXP_MENU_MISC, "Configure Everything Else", "", other_init_list);
menu->get_options ()->set (menu->BX_SHOW_PARENT);
menu->get_options ()->set (menu->SHOW_PARENT);