- win32 ParamDialog: full parameter dependency handling implemented (recursive

dependency list processing, enum parameter support)
- bx_param_enum_c: added argument for the default value of the dependent bitmaps
  to set_dependent_list()
- bx_param_num_c: dependent_list is now a protected member of the object to make
  it accessible for the enum specific dependency code
- config.cc: ata parameter dependency rewrite to avoid multiple dependencies
- config.cc: added missing dependency for SB16 parameter list
This commit is contained in:
Volker Ruppert 2009-03-17 19:37:20 +00:00
parent d987b68127
commit 5913073a20
4 changed files with 98 additions and 54 deletions

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: config.cc,v 1.163 2009-03-16 21:07:44 vruppert Exp $
// $Id: config.cc,v 1.164 2009-03-17 19:37:20 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002 MandrakeSoft S.A.
@ -75,19 +75,6 @@ static Bit64s bx_param_handler(bx_param_c *param, int set, Bit64s val)
DEV_hd_set_cd_media_status(handle, val == BX_INSERTED);
bx_gui->update_drive_status_buttons();
}
} else if (!strcmp(param->get_name(), "mode")) {
if (set) {
switch (val) {
case BX_ATA_MODE_UNDOABLE:
case BX_ATA_MODE_VOLATILE:
// case BX_ATA_MODE_Z_UNDOABLE:
// case BX_ATA_MODE_Z_VOLATILE:
SIM->get_param("journal", base)->set_enabled(1);
break;
default:
SIM->get_param("journal", base)->set_enabled(0);
}
}
} else if (!strcmp(param->get_name(), "type")) {
if (set) {
switch (val) {
@ -98,7 +85,6 @@ static Bit64s bx_param_handler(bx_param_c *param, int set, Bit64s val)
break;
case BX_ATA_DEVICE_CDROM:
((bx_param_filename_c*)SIM->get_param("path", base))->set_extension("iso");
SIM->get_param("journal", base)->set_enabled(0);
SIM->get_param("path", base)->set_runtime_param(1);
SIM->get_param("status", base)->set_runtime_param(1);
break;
@ -937,7 +923,7 @@ void bx_init_options()
iolog->set_ask_format("Enter pathname of I/O log: [%s] ");
initrd->set_ask_format("Enter pathname of initrd: [%s] ");
load32bitos->set_options(menu->SERIES_ASK);
whichOS->set_dependent_list(load32bitos->clone());
whichOS->set_dependent_list(load32bitos->clone(), TRUE);
whichOS->set_dependent_bitmap(Load32bitOSNone, 0);
whichOS->set(Load32bitOSNone);
boot_params->set_options(menu->SHOW_PARENT);
@ -1180,6 +1166,11 @@ void bx_init_options()
"Pathname of the journal file",
"", BX_PATHNAME_LEN);
journal->set_ask_format("Enter path of journal file: [%s]");
deplist = new bx_list_c(NULL, 1);
deplist->add(journal);
mode->set_dependent_list(deplist, 0);
mode->set_dependent_bitmap(BX_ATA_MODE_UNDOABLE, 1);
mode->set_dependent_bitmap(BX_ATA_MODE_VOLATILE, 1);
bx_param_num_c *cylinders = new bx_param_num_c(menu,
"cylinders",
@ -1229,11 +1220,16 @@ void bx_init_options()
translation->set_ask_format("Enter translation type: [%s]");
// the menu and all items on it depend on the present flag
present->set_dependent_list(menu->clone());
// the present flag depends on the ATA channel's enabled flag
enabled->get_dependent_list()->add(present);
deplist = new bx_list_c(NULL, 4);
deplist->add(type);
deplist->add(path);
deplist->add(model);
deplist->add(biosdetect);
present->set_dependent_list(deplist);
// the master/slave menu depends on the ATA channel's enabled flag
enabled->get_dependent_list()->add(menu);
// the present flag depends on the ATA channel's enabled flag
enabled->get_dependent_list()->add(present);
// some items depend on the drive type
bx_param_c *type_deplist[] = {
@ -1246,7 +1242,7 @@ void bx_init_options()
NULL
};
deplist = new bx_list_c(NULL, "deplist", "", type_deplist);
type->set_dependent_list(deplist);
type->set_dependent_list(deplist, 0);
type->set_dependent_bitmap(BX_ATA_DEVICE_DISK, 0x3d);
type->set_dependent_bitmap(BX_ATA_DEVICE_CDROM, 0x02);
@ -1513,7 +1509,7 @@ void bx_init_options()
"Device configuration script",
"Name of the script that is executed after Bochs initializes the network interface (optional).",
"none", BX_PATHNAME_LEN);
path->set_ask_format("Enter new script name, or 'none': [%s] ");
path->set_ask_format("Enter new script name, or 'none': [%s] ");
enabled->set_dependent_list(menu->clone());
// pnic options
menu = new bx_list_c(network, "pnic", "PCI Pseudo NIC");
@ -1615,10 +1611,11 @@ void bx_init_options()
loglevel->set_options(loglevel->USE_SPIN_CONTROL);
loglevel->set_group("SB16");
dmatimer->set_group("SB16");
deplist = new bx_list_c(NULL, 3);
deplist = new bx_list_c(NULL, 4);
deplist->add(midimode);
deplist->add(wavemode);
deplist->add(loglevel);
deplist->add(dmatimer);
enabled->set_dependent_list(deplist);
deplist = new bx_list_c(NULL, 1);
deplist->add(midifile);

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: siminterface.cc,v 1.199 2009-03-16 21:07:44 vruppert Exp $
// $Id: siminterface.cc,v 1.200 2009-03-17 19:37:20 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2009 The Bochs Project
@ -1812,12 +1812,16 @@ bx_bool bx_param_enum_c::set_by_name(const char *string)
return 1;
}
void bx_param_enum_c::set_dependent_list(bx_list_c *l)
void bx_param_enum_c::set_dependent_list(bx_list_c *l, bx_bool enable_all)
{
dependent_list = l;
deps_bitmap = (Bit64u*)malloc(sizeof(Bit64u) * (max - min + 1));
for (int i=0; i<(max-min+1); i++) {
deps_bitmap[i] = (1 << (l->get_size())) - 1;
if (enable_all) {
deps_bitmap[i] = (1 << (l->get_size())) - 1;
} else {
deps_bitmap[i] = 0;
}
}
update_dependents();
}

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: siminterface.h,v 1.233 2009-03-16 21:07:44 vruppert Exp $
// $Id: siminterface.h,v 1.234 2009-03-17 19:37:20 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2009 The Bochs Project
@ -683,11 +683,6 @@ typedef int (*param_enable_handler)(class bx_param_c *, int en);
class BOCHSAPI bx_param_num_c : public bx_param_c {
BOCHSAPI_CYGONLY static Bit32u default_base;
// The dependent_list is initialized to NULL. If dependent_list is modified
// to point to a bx_list_c of other parameters, the set() method of
// bx_param_bool_c will enable those parameters when this bool is true, and
// disable them when this bool is false.
bx_list_c *dependent_list;
void update_dependents();
protected:
Bit64s min, max, initial_val;
@ -706,6 +701,11 @@ protected:
param_enable_handler enable_handler;
int base;
bx_bool is_shadow;
// The dependent_list is initialized to NULL. If dependent_list is modified
// to point to a bx_list_c of other parameters, the set() method of
// bx_param_bool_c will enable those parameters when this bool is true, and
// disable them when this bool is false.
bx_list_c *dependent_list;
public:
enum {
// When a bx_param_num_c is displayed in dialog, USE_SPIN_CONTROL controls
@ -844,7 +844,6 @@ public:
class BOCHSAPI bx_param_enum_c : public bx_param_num_c {
const char **choices;
bx_list_c *dependent_list;
Bit64u *deps_bitmap;
void update_dependents();
public:
@ -861,7 +860,7 @@ public:
int find_by_name(const char *string);
virtual void set(Bit64s val);
bx_bool set_by_name(const char *string);
void set_dependent_list(bx_list_c *l);
void set_dependent_list(bx_list_c *l, bx_bool enable_all);
void set_dependent_bitmap(Bit64s value, Bit64u bitmap);
Bit64u get_dependent_bitmap(Bit64s value);
#if BX_USE_TEXTCONFIG

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: win32paramdlg.cc,v 1.5 2009-03-15 21:16:16 vruppert Exp $
// $Id: win32paramdlg.cc,v 1.6 2009-03-17 19:37:20 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2009 Volker Ruppert
@ -612,11 +612,9 @@ void EnableParam(HWND hDlg, bx_param_c *param, BOOL val)
{
UINT cid;
int i;
bx_list_c *plist, *clist;
bx_list_c *clist;
HWND Button, Updown;
Bit64u *n_disable = NULL;
plist = (bx_list_c*)param->get_parent();
cid = findDlgIDFromParam(param);
if (param->get_type() == BXT_LIST) {
clist = (bx_list_c*)param;
@ -637,14 +635,70 @@ void EnableParam(HWND hDlg, bx_param_c *param, BOOL val)
}
}
void ProcessDependentList(HWND hDlg, bx_param_num_c *nparam, BOOL enabled)
{
UINT cid;
bx_list_c *deplist;
bx_param_c *dparam;
bx_param_enum_c *eparam;
Bit64s value;
Bit64u enable_bitmap, mask;
int i;
BOOL en;
cid = findDlgIDFromParam(nparam);
deplist = nparam->get_dependent_list();
if (nparam->get_type() == BXT_PARAM_ENUM) {
eparam = (bx_param_enum_c*)nparam;
value = SendMessage(GetDlgItem(hDlg, ID_PARAM + cid), CB_GETCURSEL, 0, 0);
enable_bitmap = eparam->get_dependent_bitmap(value + eparam->get_min());
mask = 0x1;
for (i = 0; i < deplist->get_size(); i++) {
dparam = deplist->get(i);
if (dparam != nparam) {
en = (enable_bitmap & mask) && enabled;
if ((dparam->get_type() == BXT_PARAM_BOOL) ||
(dparam->get_type() == BXT_PARAM_NUM) ||
(dparam->get_type() == BXT_PARAM_ENUM)) {
if (((bx_param_num_c*)dparam)->get_dependent_list() != NULL) {
ProcessDependentList(hDlg, (bx_param_num_c*)dparam, en);
}
}
EnableParam(hDlg, dparam, en);
}
mask <<= 1;
}
} else {
if (nparam->get_type() == BXT_PARAM_BOOL) {
value = SendMessage(GetDlgItem(hDlg, ID_PARAM + cid), BM_GETCHECK, 0, 0);
} else if (nparam->get_type() == BXT_PARAM_NUM) {
value = GetDlgItemInt(hDlg, ID_PARAM + cid, NULL, FALSE);
}
for (i = 0; i < deplist->get_size(); i++) {
dparam = deplist->get(i);
if (dparam != nparam) {
en = (value && enabled);
if ((dparam->get_type() == BXT_PARAM_BOOL) ||
(dparam->get_type() == BXT_PARAM_NUM) ||
(dparam->get_type() == BXT_PARAM_ENUM)) {
if (((bx_param_num_c*)dparam)->get_dependent_list() != NULL) {
ProcessDependentList(hDlg, (bx_param_num_c*)dparam, en);
}
}
EnableParam(hDlg, dparam, en);
}
}
}
}
static BOOL CALLBACK ParamDlgProc(HWND Window, UINT AMessage, WPARAM wParam, LPARAM lParam)
{
static bx_list_c *list = NULL;
static int items = 0;
bx_param_c *param, *dparam;
bx_param_c *param;
bx_param_string_c *sparam;
bx_list_c *deplist, *tmplist;
int cid, code, i, j, k, val;
bx_list_c *tmplist;
int cid, code, i, j, k;
RECT r, r2;
SIZE size;
NMHDR tcinfo;
@ -707,20 +761,10 @@ static BOOL CALLBACK ParamDlgProc(HWND Window, UINT AMessage, WPARAM wParam, LPA
param = findParamFromDlgID(i);
if (param != NULL) {
if ((param->get_type() == BXT_PARAM_BOOL) ||
(param->get_type() == BXT_PARAM_NUM)) {
deplist = ((bx_param_bool_c *)param)->get_dependent_list();
if (deplist != NULL) {
if (param->get_type() == BXT_PARAM_BOOL) {
val = SendMessage(GetDlgItem(Window, code), BM_GETCHECK, 0, 0);
} else {
val = GetDlgItemInt(Window, code, NULL, FALSE);
}
for (j = 0; j < deplist->get_size(); j++) {
dparam = deplist->get(j);
if (dparam != param) {
EnableParam(Window, dparam, val);
}
}
(param->get_type() == BXT_PARAM_NUM) ||
(param->get_type() == BXT_PARAM_ENUM)) {
if (((bx_param_num_c*)param)->get_dependent_list() != NULL) {
ProcessDependentList(Window, (bx_param_num_c*)param, TRUE);
}
}
}