From 906ac57dc9954040490bdb57c525acb635ddd225 Mon Sep 17 00:00:00 2001 From: Volker Ruppert Date: Sun, 25 May 2003 13:35:39 +0000 Subject: [PATCH] - the text snapshot function now uses the standard save file dialog box on win32 if the config interface is not wx. --- bochs/gui/gui.cc | 12 ++++++++++- bochs/gui/textconfig.cc | 14 ++++++++++++- bochs/gui/win32dialog.cc | 43 +++++++++++++++++++++++++++++++++++++++- bochs/gui/win32dialog.h | 3 ++- 4 files changed, 68 insertions(+), 4 deletions(-) diff --git a/bochs/gui/gui.cc b/bochs/gui/gui.cc index d10f4ac11..3636ea5f2 100644 --- a/bochs/gui/gui.cc +++ b/bochs/gui/gui.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: gui.cc,v 1.66 2003-05-24 10:51:00 vruppert Exp $ +// $Id: gui.cc,v 1.67 2003-05-25 13:35:39 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2002 MandrakeSoft S.A. @@ -429,7 +429,17 @@ bx_gui_c::snapshot_handler(void) return; } } else { +#ifdef WIN32 + int ret = SIM->ask_filename (filename, sizeof(filename), + "Save snapshot as...", "snapshot.txt", + bx_param_string_c::SAVE_FILE_DIALOG); + if (ret < 0) { // cancelled + free(text_snapshot); + return; + } +#else strcpy (filename, "snapshot.txt"); +#endif } FILE *fp = fopen(filename, "wb"); fwrite(text_snapshot, 1, len, fp); diff --git a/bochs/gui/textconfig.cc b/bochs/gui/textconfig.cc index c9d682d19..b6519a451 100644 --- a/bochs/gui/textconfig.cc +++ b/bochs/gui/textconfig.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: textconfig.cc,v 1.9 2003-05-21 20:33:24 vruppert Exp $ +// $Id: textconfig.cc,v 1.10 2003-05-25 13:35:39 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// // // This is code for a text-mode configuration interfac. Note that this file @@ -665,6 +665,10 @@ int log_action_n_choices = 4 + (BX_DEBUGGER?1:0); BxEvent * config_interface_notify_callback (void *unused, BxEvent *event) { +#ifdef WIN32 + bx_param_filename_c *param; + int opts; +#endif event->retcode = -1; switch (event->type) { @@ -672,6 +676,14 @@ config_interface_notify_callback (void *unused, BxEvent *event) event->retcode = 0; return event; case BX_SYNC_EVT_ASK_PARAM: +#ifdef WIN32 + param = (bx_param_filename_c*)event->u.param.param; + opts = param->get_options()->get(); + if (opts & bx_param_filename_c::IS_FILENAME) { + event->retcode = AskFilename(param); + return event; + } +#endif event->u.param.param->text_ask (stdin, stderr); return event; case BX_SYNC_EVT_LOG_ASK: diff --git a/bochs/gui/win32dialog.cc b/bochs/gui/win32dialog.cc index e9adfd2fe..65845d599 100644 --- a/bochs/gui/win32dialog.cc +++ b/bochs/gui/win32dialog.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: win32dialog.cc,v 1.1 2003-05-21 20:33:24 vruppert Exp $ +// $Id: win32dialog.cc,v 1.2 2003-05-25 13:35:39 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// #ifdef WIN32 @@ -68,4 +68,45 @@ void LogAskDialog(BxEvent *event) (DLGPROC)LogAskProc, (LPARAM)event); } +int AskFilename(bx_param_filename_c *param) +{ + const PCHAR Filter = "Text files (*.txt)\0*.txt\0All files (*.*)\0*.*\0"; + const PCHAR Ext = "txt"; + OPENFILENAME ofn; + int ret; + char filename[MAX_PATH]; + + param->get(filename, MAX_PATH); + ofn.lStructSize = sizeof(OPENFILENAME); + ofn.hwndOwner = GetBochsWindow(); + ofn.hInstance = NULL; + ofn.lpstrFilter = Filter; + ofn.lpstrCustomFilter = NULL; + ofn.nMaxCustFilter = 0; + ofn.nFilterIndex = 0; + ofn.lpstrFile = filename; + ofn.nMaxFile = MAX_PATH; + ofn.lpstrFileTitle = NULL; + ofn.nMaxFileTitle = 0; + ofn.lpstrInitialDir = NULL; + ofn.lpstrTitle = param->get_description(); + ofn.nFileOffset = 0; + ofn.nFileExtension = 0; + ofn.lpstrDefExt = Ext; + ofn.lCustData = 0; + ofn.lpfnHook = NULL; + ofn.lpTemplateName = NULL; + ofn.Flags = OFN_EXPLORER | OFN_HIDEREADONLY; + if (param->get_options()->get() & bx_param_filename_c::SAVE_FILE_DIALOG) { + ofn.Flags |= OFN_OVERWRITEPROMPT; + ret = GetSaveFileName(&ofn); + } else { + ofn.Flags |= OFN_FILEMUSTEXIST; + ret = GetOpenFileName(&ofn); + } + param->set(filename); + if (ret == 0) ret = -1; + return ret; +} + #endif // WIN32 diff --git a/bochs/gui/win32dialog.h b/bochs/gui/win32dialog.h index 15d524b08..7b3d37714 100644 --- a/bochs/gui/win32dialog.h +++ b/bochs/gui/win32dialog.h @@ -1,9 +1,10 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: win32dialog.h,v 1.1 2003-05-21 20:33:24 vruppert Exp $ +// $Id: win32dialog.h,v 1.2 2003-05-25 13:35:39 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// #ifdef WIN32 void LogAskDialog(BxEvent *event); +int AskFilename(bx_param_filename_c *param); #endif