- implemented dependent list for string parameters (string length must be > 0
and value must be != "none" to enable dependents) - set dependent list for floppy path (removed enable handler) - win32paramdlg: added support for string parameter dependent lists
This commit is contained in:
parent
773b0ab8c2
commit
8d92dbdee3
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: config.cc,v 1.171 2009-03-25 18:33:30 vruppert Exp $
|
||||
// $Id: config.cc,v 1.172 2009-03-29 11:13:49 vruppert Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2002 MandrakeSoft S.A.
|
||||
@ -209,9 +209,6 @@ const char *bx_param_string_handler(bx_param_string_c *param, int set,
|
||||
DEV_floppy_set_media_status(device, 0);
|
||||
DEV_floppy_set_media_status(device, 1);
|
||||
}
|
||||
} else {
|
||||
SIM->get_param_enum("type", base)->set_enabled(!empty);
|
||||
SIM->get_param_bool("status", base)->set_enabled(!empty);
|
||||
}
|
||||
}
|
||||
#if BX_PLUGINS
|
||||
@ -230,26 +227,6 @@ const char *bx_param_string_handler(bx_param_string_c *param, int set,
|
||||
return val;
|
||||
}
|
||||
|
||||
static int bx_param_enable_handler(bx_param_c *param, int val)
|
||||
{
|
||||
char pname[BX_PATHNAME_LEN];
|
||||
bx_param_string_c *sparam;
|
||||
bx_bool empty;
|
||||
|
||||
bx_list_c *base = (bx_list_c*) param->get_parent();
|
||||
param->get_param_path(pname, BX_PATHNAME_LEN);
|
||||
if ((!strcmp(pname, BXPN_FLOPPYA_PATH)) ||
|
||||
(!strcmp(pname, BXPN_FLOPPYB_PATH))) {
|
||||
sparam = (bx_param_string_c*)param;
|
||||
empty = (strlen(sparam->getptr()) < 1) || !strcmp(sparam->getptr(), "none");
|
||||
SIM->get_param_enum("type", base)->set_enabled(val && !empty);
|
||||
SIM->get_param_bool("status", base)->set_enabled(val && !empty);
|
||||
} else {
|
||||
BX_PANIC(("bx_param_enable_handler called with unknown parameter '%s'", pname));
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
void bx_init_options()
|
||||
{
|
||||
int i;
|
||||
@ -884,8 +861,9 @@ void bx_init_options()
|
||||
"Pathname of first floppy image file or device. If you're booting from floppy, this should be a bootable floppy.",
|
||||
"", BX_PATHNAME_LEN);
|
||||
path->set_ask_format("Enter new filename, or 'none' for no disk: [%s] ");
|
||||
path->set_enable_handler(bx_param_enable_handler);
|
||||
path->set_extension("img");
|
||||
path->set_handler(bx_param_string_handler);
|
||||
path->set_initial_val("none");
|
||||
path->set_runtime_param(1);
|
||||
|
||||
type = new bx_param_enum_c(floppya,
|
||||
@ -896,6 +874,7 @@ void bx_init_options()
|
||||
BX_FLOPPY_NONE,
|
||||
BX_FLOPPY_NONE);
|
||||
type->set_ask_format("What type of floppy media? (auto=detect) [%s] ");
|
||||
type->set_handler(bx_param_handler);
|
||||
type->set_runtime_param(1);
|
||||
|
||||
status = new bx_param_bool_c(floppya,
|
||||
@ -904,16 +883,19 @@ void bx_init_options()
|
||||
"Floppy media status (inserted / ejected)",
|
||||
0);
|
||||
status->set_ask_format("Is media inserted in drive? [%s] ");
|
||||
status->set_handler(bx_param_handler);
|
||||
status->set_runtime_param(1);
|
||||
|
||||
deplist = new bx_list_c(NULL, 1);
|
||||
deplist->add(path);
|
||||
devtype->set_dependent_list(deplist, 1);
|
||||
devtype->set_dependent_bitmap(BX_FDD_NONE, 0);
|
||||
path->set_handler(bx_param_string_handler);
|
||||
type->set_handler(bx_param_handler);
|
||||
status->set_handler(bx_param_handler);
|
||||
path->set_initial_val("none");
|
||||
|
||||
deplist = new bx_list_c(NULL, 2);
|
||||
deplist->add(type);
|
||||
deplist->add(status);
|
||||
path->set_dependent_list(deplist);
|
||||
|
||||
floppya->set_options(floppya->SERIES_ASK | floppya->USE_BOX_TITLE);
|
||||
|
||||
devtype = new bx_param_enum_c(floppyb,
|
||||
@ -931,8 +913,9 @@ void bx_init_options()
|
||||
"Pathname of second floppy image file or device.",
|
||||
"", BX_PATHNAME_LEN);
|
||||
path->set_ask_format("Enter new filename, or 'none' for no disk: [%s] ");
|
||||
path->set_enable_handler(bx_param_enable_handler);
|
||||
path->set_extension("img");
|
||||
path->set_handler(bx_param_string_handler);
|
||||
path->set_initial_val("none");
|
||||
path->set_runtime_param(1);
|
||||
|
||||
type = new bx_param_enum_c(floppyb,
|
||||
@ -943,6 +926,7 @@ void bx_init_options()
|
||||
BX_FLOPPY_NONE,
|
||||
BX_FLOPPY_NONE);
|
||||
type->set_ask_format("What type of floppy media? (auto=detect) [%s] ");
|
||||
type->set_handler(bx_param_handler);
|
||||
type->set_runtime_param(1);
|
||||
|
||||
status = new bx_param_bool_c(floppyb,
|
||||
@ -951,16 +935,19 @@ void bx_init_options()
|
||||
"Floppy media status (inserted / ejected)",
|
||||
0);
|
||||
status->set_ask_format("Is media inserted in drive? [%s] ");
|
||||
status->set_handler(bx_param_handler);
|
||||
status->set_runtime_param(1);
|
||||
|
||||
deplist = new bx_list_c(NULL, 1);
|
||||
deplist->add(path);
|
||||
devtype->set_dependent_list(deplist, 1);
|
||||
devtype->set_dependent_bitmap(BX_FDD_NONE, 0);
|
||||
path->set_handler(bx_param_string_handler);
|
||||
type->set_handler(bx_param_handler);
|
||||
status->set_handler(bx_param_handler);
|
||||
path->set_initial_val("none");
|
||||
|
||||
deplist = new bx_list_c(NULL, 2);
|
||||
deplist->add(type);
|
||||
deplist->add(status);
|
||||
path->set_dependent_list(deplist);
|
||||
|
||||
floppyb->set_options(floppyb->SERIES_ASK | floppyb->USE_BOX_TITLE);
|
||||
floppy->set_options(floppy->SHOW_PARENT);
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: siminterface.cc,v 1.205 2009-03-28 11:49:26 vruppert Exp $
|
||||
// $Id: siminterface.cc,v 1.206 2009-03-29 11:13:49 vruppert Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2009 The Bochs Project
|
||||
@ -1264,6 +1264,9 @@ bx_param_c::bx_param_c(Bit32u id, const char *param_name, const char *param_desc
|
||||
this->long_text_format = default_text_format;
|
||||
this->runtime_param = 0;
|
||||
this->enabled = 1;
|
||||
// dependent_list must be initialized before the set(),
|
||||
// because set calls update_dependents().
|
||||
dependent_list = NULL;
|
||||
}
|
||||
|
||||
bx_param_c::bx_param_c(Bit32u id, const char *param_name, const char *param_label, const char *param_desc)
|
||||
@ -1283,6 +1286,9 @@ bx_param_c::bx_param_c(Bit32u id, const char *param_name, const char *param_labe
|
||||
this->long_text_format = default_text_format;
|
||||
this->runtime_param = 0;
|
||||
this->enabled = 1;
|
||||
// dependent_list must be initialized before the set(),
|
||||
// because set calls update_dependents().
|
||||
dependent_list = NULL;
|
||||
}
|
||||
|
||||
bx_param_c::~bx_param_c()
|
||||
@ -1380,9 +1386,6 @@ bx_param_num_c::bx_param_num_c(bx_param_c *parent,
|
||||
this->enable_handler = NULL;
|
||||
this->base = default_base;
|
||||
this->is_shadow = is_shadow;
|
||||
// dependent_list must be initialized before the set(),
|
||||
// because set calls update_dependents().
|
||||
dependent_list = NULL;
|
||||
if (!is_shadow) {
|
||||
set(initial_val);
|
||||
}
|
||||
@ -1932,6 +1935,18 @@ void bx_param_string_c::set_enable_handler(param_enable_handler handler)
|
||||
this->enable_handler = handler;
|
||||
}
|
||||
|
||||
void bx_param_string_c::update_dependents()
|
||||
{
|
||||
if (dependent_list) {
|
||||
int en = (strlen(val) > 0) && (strcmp(val, "none")) && enabled;
|
||||
for (int i=0; i<dependent_list->get_size(); i++) {
|
||||
bx_param_c *param = dependent_list->get(i);
|
||||
if (param != this)
|
||||
param->set_enabled(en);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void bx_param_string_c::set_enabled(int en)
|
||||
{
|
||||
// The enable handler may wish to allow/disallow the action
|
||||
@ -1939,6 +1954,13 @@ void bx_param_string_c::set_enabled(int en)
|
||||
en = (*enable_handler)(this, en);
|
||||
}
|
||||
bx_param_c::set_enabled(en);
|
||||
if (dependent_list != NULL) update_dependents();
|
||||
}
|
||||
|
||||
void bx_param_string_c::set_dependent_list(bx_list_c *l)
|
||||
{
|
||||
dependent_list = l;
|
||||
update_dependents();
|
||||
}
|
||||
|
||||
Bit32s bx_param_string_c::get(char *buf, int len)
|
||||
@ -1973,6 +1995,7 @@ void bx_param_string_c::set(const char *buf)
|
||||
buf = (*handler)(this, 1, oldval, buf, -1);
|
||||
}
|
||||
delete [] oldval;
|
||||
if (dependent_list != NULL) update_dependents();
|
||||
}
|
||||
|
||||
bx_bool bx_param_string_c::equals(const char *buf)
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: siminterface.h,v 1.238 2009-03-28 11:49:26 vruppert Exp $
|
||||
// $Id: siminterface.h,v 1.239 2009-03-29 11:13:49 vruppert Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2009 The Bochs Project
|
||||
@ -637,6 +637,11 @@ protected:
|
||||
int runtime_param;
|
||||
int enabled;
|
||||
Bit32u options;
|
||||
// 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 the
|
||||
// parameter type will enable those parameters when the enable condition is
|
||||
// true, and disable them it is false.
|
||||
bx_list_c *dependent_list;
|
||||
public:
|
||||
bx_param_c(Bit32u id, const char *name, const char *description);
|
||||
bx_param_c(Bit32u id, const char *name, const char *label, const char *description);
|
||||
@ -664,7 +669,7 @@ public:
|
||||
int getint() const {return -1;}
|
||||
static const char* set_default_format(const char *f);
|
||||
static const char *get_default_format() { return default_text_format; }
|
||||
virtual bx_list_c *get_dependent_list() { return NULL; }
|
||||
bx_list_c *get_dependent_list() { return dependent_list; }
|
||||
void set_options(Bit32u options) { this->options = options; }
|
||||
Bit32u get_options() const { return options; }
|
||||
#if BX_USE_TEXTCONFIG
|
||||
@ -697,11 +702,6 @@ 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
|
||||
@ -718,7 +718,6 @@ public:
|
||||
void set_handler(param_event_handler handler);
|
||||
void set_sr_handlers(void *devptr, param_sr_handler save, param_sr_handler restore);
|
||||
void set_enable_handler(param_enable_handler handler) { enable_handler = handler; }
|
||||
virtual bx_list_c *get_dependent_list() { return dependent_list; }
|
||||
void set_dependent_list(bx_list_c *l);
|
||||
virtual void set_enabled(int enabled);
|
||||
virtual Bit32s get() { return (Bit32s) get64(); }
|
||||
@ -875,6 +874,7 @@ class BOCHSAPI bx_param_string_c : public bx_param_c {
|
||||
param_string_event_handler handler;
|
||||
param_enable_handler enable_handler;
|
||||
char separator;
|
||||
void update_dependents();
|
||||
public:
|
||||
enum {
|
||||
RAW_BYTES = 1, // use binary text editor, like MAC addr
|
||||
@ -895,6 +895,7 @@ public:
|
||||
void set_handler(param_string_event_handler handler);
|
||||
void set_enable_handler(param_enable_handler handler);
|
||||
virtual void set_enabled(int enabled);
|
||||
void set_dependent_list(bx_list_c *l);
|
||||
Bit32s get(char *buf, int len);
|
||||
char *getptr() {return val; }
|
||||
void set(const char *buf);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: win32paramdlg.cc,v 1.13 2009-03-28 11:49:26 vruppert Exp $
|
||||
// $Id: win32paramdlg.cc,v 1.14 2009-03-29 11:13:49 vruppert Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2009 Volker Ruppert
|
||||
@ -670,6 +670,7 @@ void ProcessDependentList(HWND hDlg, bx_param_c *param, BOOL enabled)
|
||||
bx_param_enum_c *eparam;
|
||||
Bit64s value;
|
||||
Bit64u enable_bitmap, mask;
|
||||
char buffer[BX_PATHNAME_LEN];
|
||||
int i;
|
||||
BOOL en;
|
||||
|
||||
@ -694,11 +695,15 @@ void ProcessDependentList(HWND hDlg, bx_param_c *param, BOOL enabled)
|
||||
mask <<= 1;
|
||||
}
|
||||
} else if ((param->get_type() == BXT_PARAM_BOOL) ||
|
||||
(param->get_type() == BXT_PARAM_NUM)) {
|
||||
(param->get_type() == BXT_PARAM_NUM) ||
|
||||
(param->get_type() == BXT_PARAM_STRING)) {
|
||||
if (param->get_type() == BXT_PARAM_BOOL) {
|
||||
value = SendMessage(GetDlgItem(hDlg, ID_PARAM + cid), BM_GETCHECK, 0, 0);
|
||||
} else {
|
||||
} else if (param->get_type() == BXT_PARAM_NUM) {
|
||||
value = GetDlgItemInt(hDlg, ID_PARAM + cid, NULL, FALSE);
|
||||
} else {
|
||||
GetWindowText(GetDlgItem(hDlg, ID_PARAM + cid), buffer, BX_PATHNAME_LEN);
|
||||
value = (lstrlen(buffer) > 0) && (strcmp(buffer, "none"));
|
||||
}
|
||||
for (i = 0; i < deplist->get_size(); i++) {
|
||||
dparam = deplist->get(i);
|
||||
|
Loading…
Reference in New Issue
Block a user