diff --git a/bochs/gui/sdl.cc b/bochs/gui/sdl.cc index 0a7ff5a70..5fde5e6ad 100644 --- a/bochs/gui/sdl.cc +++ b/bochs/gui/sdl.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: sdl.cc,v 1.60 2005-10-21 18:00:17 vruppert Exp $ +// $Id: sdl.cc,v 1.61 2005-10-22 11:00:00 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2002 MandrakeSoft S.A. @@ -42,6 +42,9 @@ #include "icon_bochs.h" #include "sdl.h" +#ifdef WIN32 +#include "win32dialog.h" +#endif class bx_sdl_gui_c : public bx_gui_c { public: @@ -298,6 +301,7 @@ void bx_sdl_gui_c::specific_init( new_gfx_api = 1; #ifdef WIN32 + win32_init_notify_callback(); user_dialog = 1; #endif } diff --git a/bochs/gui/textconfig.cc b/bochs/gui/textconfig.cc index 4587cf9ef..f9ab1e138 100644 --- a/bochs/gui/textconfig.cc +++ b/bochs/gui/textconfig.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: textconfig.cc,v 1.30 2005-06-06 20:14:50 vruppert Exp $ +// $Id: textconfig.cc,v 1.31 2005-10-22 11:00:00 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// // // This is code for a text-mode configuration interface. Note that this file @@ -644,11 +644,6 @@ int log_action_n_choices = 4 + (BX_DEBUGGER||BX_GDBSTUB?1:0); BxEvent * config_interface_notify_callback (void *unused, BxEvent *event) { -#ifdef WIN32 - int opts; - bx_param_c *param; - bx_param_string_c *sparam; -#endif event->retcode = -1; switch (event->type) { @@ -656,34 +651,10 @@ config_interface_notify_callback (void *unused, BxEvent *event) event->retcode = 0; return event; case BX_SYNC_EVT_ASK_PARAM: -#ifdef WIN32 - param = event->u.param.param; - if (param->get_type() == BXT_PARAM_STRING) { - sparam = (bx_param_string_c *)param; - opts = sparam->get_options()->get(); - if (opts & sparam->IS_FILENAME) { - if (param->get_id() == BXP_NULL) { - event->retcode = AskFilename(GetBochsWindow(), (bx_param_filename_c *)sparam, "txt"); - } else { - event->retcode = FloppyDialog((bx_param_filename_c *)sparam); - } - return event; - } else { - event->retcode = AskString(sparam); - return event; - } - } else if (param->get_type() == BXT_LIST) { - event->retcode = Cdrom1Dialog(); - return event; - } -#endif event->u.param.param->text_ask (stdin, stderr); return event; case BX_SYNC_EVT_LOG_ASK: { -#ifdef WIN32 - LogAskDialog(event); -#else int level = event->u.logmsg.level; fprintf (stderr, "========================================================================\n"); fprintf (stderr, "Event type: %s\n", SIM->get_log_level_name (level)); @@ -713,7 +684,6 @@ ask: fflush(stdout); fflush(stderr); event->retcode = choice; -#endif } return event; case BX_ASYNC_EVT_REFRESH: diff --git a/bochs/gui/win32.cc b/bochs/gui/win32.cc index 5af073cf7..a6228d674 100644 --- a/bochs/gui/win32.cc +++ b/bochs/gui/win32.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: win32.cc,v 1.97 2005-10-21 18:00:17 vruppert Exp $ +// $Id: win32.cc,v 1.98 2005-10-22 11:00:00 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2002 MandrakeSoft S.A. @@ -38,6 +38,7 @@ #if BX_WITH_WIN32 #include "zmouse.h" +#include "win32dialog.h" #include "win32res.h" #include "font/vga.bitmap.h" // windows.h is included by bochs.h @@ -680,6 +681,7 @@ void bx_win32_gui_c::specific_init(int argc, char **argv, unsigned bx_keymap.loadKeymap(NULL); // I have no function to convert X windows symbols } + win32_init_notify_callback(); user_dialog = 1; } diff --git a/bochs/gui/win32dialog.cc b/bochs/gui/win32dialog.cc index 9880faf58..cddbfac16 100644 --- a/bochs/gui/win32dialog.cc +++ b/bochs/gui/win32dialog.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: win32dialog.cc,v 1.25 2005-10-07 23:28:43 vruppert Exp $ +// $Id: win32dialog.cc,v 1.26 2005-10-22 11:00:00 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// #include "config.h" @@ -7,6 +7,7 @@ #if BX_USE_TEXTCONFIG && defined(WIN32) extern "C" { +#include #include #include #include @@ -18,6 +19,10 @@ extern "C" { const char log_choices[5][16] = {"ignore", "log", "ask user", "end simulation", "no change"}; static int retcode = 0; +static bxevent_handler old_callback = NULL; +static void *old_callback_arg = NULL; + +int AskFilename(HWND hwnd, bx_param_filename_c *param, const char *ext); HWND GetBochsWindow() { @@ -97,21 +102,23 @@ static BOOL CALLBACK LogAskProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lPara static BOOL CALLBACK StringParamProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) { static bx_param_string_c *param; - char buffer[20]; + char buffer[512]; switch (msg) { case WM_INITDIALOG: param = (bx_param_string_c *)lParam; SetWindowText(hDlg, param->get_name()); SetWindowText(GetDlgItem(hDlg, IDSTRING), param->getptr()); - return FALSE; + SendMessage(GetDlgItem(hDlg, IDSTRING), EM_SETLIMITTEXT, param->get_maxsize(), 0); + return TRUE; + break; case WM_CLOSE: EndDialog(hDlg, -1); break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDOK: - GetDlgItemText(hDlg, IDSTRING, buffer, 20); + GetDlgItemText(hDlg, IDSTRING, buffer, param->get_maxsize() + 1); param->set(buffer); EndDialog(hDlg, 1); break; @@ -233,6 +240,7 @@ static BOOL CALLBACK Cdrom1DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lP if (cdromop.Ostatus->get() == BX_INSERTED) { SendMessage(GetDlgItem(hDlg, IDSTATUS1), BM_SETCHECK, BST_CHECKED, 0); } + return TRUE; break; case WM_CLOSE: if (lstrcmp(cdromop.Opath->getptr(), origpath)) { @@ -742,4 +750,51 @@ int RuntimeOptionsDialog() return retcode; } +BxEvent* win32_notify_callback(void *unused, BxEvent *event) +{ + int opts; + bx_param_c *param; + bx_param_string_c *sparam; + + event->retcode = -1; + switch (event->type) + { + case BX_SYNC_EVT_LOG_ASK: + LogAskDialog(event); + return event; + case BX_SYNC_EVT_ASK_PARAM: + param = event->u.param.param; + if (param->get_type() == BXT_PARAM_STRING) { + sparam = (bx_param_string_c *)param; + opts = sparam->get_options()->get(); + if (opts & sparam->IS_FILENAME) { + if (param->get_id() == BXP_NULL) { + event->retcode = AskFilename(GetBochsWindow(), (bx_param_filename_c *)sparam, "txt"); + } else { + event->retcode = FloppyDialog((bx_param_filename_c *)sparam); + } + return event; + } else { + event->retcode = AskString(sparam); + return event; + } + } else if (param->get_type() == BXT_LIST) { + event->retcode = Cdrom1Dialog(); + 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. + // fall into default case + default: + return (*old_callback)(old_callback_arg, event); + } +} + +void win32_init_notify_callback() +{ + SIM->get_notify_callback(&old_callback, &old_callback_arg); + assert (old_callback != NULL); + SIM->set_notify_callback(win32_notify_callback, NULL); +} + #endif // BX_USE_TEXTCONFIG && defined(WIN32) diff --git a/bochs/gui/win32dialog.h b/bochs/gui/win32dialog.h index b18ecf893..58ad0dc61 100644 --- a/bochs/gui/win32dialog.h +++ b/bochs/gui/win32dialog.h @@ -1,21 +1,12 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: win32dialog.h,v 1.7 2004-02-01 01:40:14 vruppert Exp $ +// $Id: win32dialog.h,v 1.8 2005-10-22 11:00:00 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// #include "config.h" #if BX_USE_TEXTCONFIG && defined(WIN32) -extern "C" { -#include -} - -HWND GetBochsWindow(); -void LogAskDialog(BxEvent *event); -int AskFilename(HWND hwnd, bx_param_filename_c *param, const char *ext); -int AskString(bx_param_string_c *param); -int FloppyDialog(bx_param_filename_c *param); -int Cdrom1Dialog(); int RuntimeOptionsDialog(); +void win32_init_notify_callback(); #endif