- prepared yes/no dialog in the siminterface and added message box for win32

- test case for ask_yes_no(): confirm power off
- textconfig: set the event return code when asking for a parameter
This commit is contained in:
Volker Ruppert 2006-05-31 20:12:43 +00:00
parent 594b8cce47
commit 005ca56f04
5 changed files with 37 additions and 8 deletions

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: gui.cc,v 1.94 2006-04-10 19:02:30 sshwarts Exp $
// $Id: gui.cc,v 1.95 2006-05-31 20:12:43 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002 MandrakeSoft S.A.
@ -336,6 +336,9 @@ void bx_gui_c::reset_handler(void)
void bx_gui_c::power_handler(void)
{
// test case for yes/no dialog: confirm power off
//if (!SIM->ask_yes_no("Quit Bochs", "Are you sure ?", 0))
// return;
// the user pressed power button, so there's no doubt they want bochs
// to quit. Change panics to fatal for the GUI and then do a panic.
bx_user_quit = 1;

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: siminterface.cc,v 1.156 2006-05-30 17:01:27 sshwarts Exp $
// $Id: siminterface.cc,v 1.157 2006-05-31 20:12:43 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// See siminterface.h for description of the siminterface concept.
@ -92,6 +92,8 @@ public:
virtual int ask_param(const char *pname);
// ask the user for a pathname
virtual int ask_filename(char *filename, int maxlen, char *prompt, char *the_default, int flags);
// yes/no dialog
virtual int ask_yes_no(char *title, char *prompt, bx_bool the_default);
// called at a regular interval, currently by the keyboard handler.
virtual void periodic ();
virtual int create_disk_image (const char *filename, int sectors, bx_bool overwrite);
@ -558,15 +560,29 @@ int bx_real_sim_c::ask_filename(char *filename, int maxlen, char *prompt, char *
BxEvent event;
bx_param_string_c param(NULL, "filename", prompt, "", the_default, maxlen);
flags |= param.IS_FILENAME;
param.get_options()->set (flags);
param.get_options()->set(flags);
event.type = BX_SYNC_EVT_ASK_PARAM;
event.u.param.param = &param;
sim_to_ci_event (&event);
sim_to_ci_event(&event);
if (event.retcode >= 0)
memcpy(filename, param.getptr(), maxlen);
return event.retcode;
}
int bx_real_sim_c::ask_yes_no(char *title, char *prompt, bx_bool the_default)
{
BxEvent event;
bx_param_bool_c param(NULL, "yes_no", title, prompt, the_default);
event.type = BX_SYNC_EVT_ASK_PARAM;
event.u.param.param = &param;
sim_to_ci_event(&event);
if (event.retcode >= 0) {
return param.get();
} else {
return event.retcode;
}
}
void bx_real_sim_c::periodic()
{
// give the GUI a chance to do periodic things on the bochs thread. in

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: siminterface.h,v 1.194 2006-05-30 17:01:27 sshwarts Exp $
// $Id: siminterface.h,v 1.195 2006-05-31 20:12:43 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Intro to siminterface by Bryce Denney:
@ -1174,6 +1174,8 @@ public:
// ask the user for a pathname
virtual int ask_filename(char *filename, int maxlen, char *prompt, char *the_default, int flags) {return -1;}
// yes/no dialog
virtual int ask_yes_no(char *title, char *prompt, bx_bool the_default) {return -1;}
// called at a regular interval, currently by the keyboard handler.
virtual void periodic() {}
virtual int create_disk_image(const char *filename, int sectors, bx_bool overwrite) {return -3;}

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: textconfig.cc,v 1.55 2006-05-30 18:01:51 vruppert Exp $
// $Id: textconfig.cc,v 1.56 2006-05-31 20:12:43 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// This is code for a text-mode configuration interface. Note that this file
@ -669,7 +669,7 @@ config_interface_notify_callback (void *unused, BxEvent *event)
event->retcode = 0;
return event;
case BX_SYNC_EVT_ASK_PARAM:
event->u.param.param->text_ask (stdin, stderr);
event->retcode = event->u.param.param->text_ask(stdin, stderr);
return event;
case BX_SYNC_EVT_LOG_ASK:
{

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: win32dialog.cc,v 1.46 2006-05-29 22:33:38 sshwarts Exp $
// $Id: win32dialog.cc,v 1.47 2006-05-31 20:12:43 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
#include "config.h"
@ -940,6 +940,14 @@ BxEvent* win32_notify_callback(void *unused, BxEvent *event)
} else if (param->get_type() == BXT_LIST) {
event->retcode = Cdrom1Dialog();
return event;
} else if (param->get_type() == BXT_PARAM_BOOL) {
UINT flag = MB_YESNO | MB_SETFOREGROUND;
if (((bx_param_bool_c *)param)->get() == 0) {
flag |= MB_DEFBUTTON2;
}
((bx_param_bool_c *)param)->set(MessageBox(GetActiveWindow(), param->get_description(), param->get_label(), flag) == IDYES);
event->retcode = 0;
return event;
}
case BX_SYNC_EVT_TICK: // called periodically by siminterface.
case BX_ASYNC_EVT_REFRESH: // called when some bx_param_c parameters have changed.