- simple text input dialog for the userbutton function on win32 added

- snapshot_handler(): simplified the filedialog call
This commit is contained in:
Volker Ruppert 2003-05-25 18:34:03 +00:00
parent 906ac57dc9
commit ecfaa5f1b0
6 changed files with 80 additions and 27 deletions

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: gui.cc,v 1.67 2003-05-25 13:35:39 vruppert Exp $
// $Id: gui.cc,v 1.68 2003-05-25 18:34:03 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002 MandrakeSoft S.A.
@ -419,8 +419,12 @@ bx_gui_c::snapshot_handler(void)
}
//FIXME
char filename[BX_PATHNAME_LEN];
#ifdef WIN32
if (1) {
#else
if (!strcmp(bx_options.Osel_config->get_choice(bx_options.Osel_config->get()),
"wx")) {
#endif
int ret = SIM->ask_filename (filename, sizeof(filename),
"Save snapshot as...", "snapshot.txt",
bx_param_string_c::SAVE_FILE_DIALOG);
@ -429,17 +433,7 @@ 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);
@ -490,8 +484,12 @@ bx_gui_c::userbutton_handler(void)
int i, len, ret = 1;
len = 0;
#ifdef WIN32
if (1) {
#else
if (!strcmp(bx_options.Osel_config->get_choice(bx_options.Osel_config->get()),
"wx")) {
#endif
ret = SIM->ask_param (BXP_USER_SHORTCUT);
}
user_shortcut = bx_options.Ouser_shortcut->getptr();

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: textconfig.cc,v 1.10 2003-05-25 13:35:39 vruppert Exp $
// $Id: textconfig.cc,v 1.11 2003-05-25 18:34:03 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// This is code for a text-mode configuration interfac. Note that this file
@ -666,8 +666,9 @@ BxEvent *
config_interface_notify_callback (void *unused, BxEvent *event)
{
#ifdef WIN32
bx_param_filename_c *param;
int opts;
bx_param_c *param;
bx_param_string_c *sparam;
#endif
event->retcode = -1;
switch (event->type)
@ -677,11 +678,17 @@ config_interface_notify_callback (void *unused, BxEvent *event)
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;
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) {
event->retcode = AskFilename((bx_param_filename_c *)sparam);
return event;
} else {
event->retcode = AskString(sparam);
return event;
}
}
#endif
event->u.param.param->text_ask (stdin, stderr);

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: win32dialog.cc,v 1.2 2003-05-25 13:35:39 vruppert Exp $
// $Id: win32dialog.cc,v 1.3 2003-05-25 18:34:03 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
#ifdef WIN32
@ -62,6 +62,35 @@ static BOOL CALLBACK LogAskProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lPara
return FALSE;
}
static BOOL CALLBACK StringParamProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
static bx_param_string_c *param;
char buffer[20];
switch (msg) {
case WM_INITDIALOG:
param = (bx_param_string_c *)lParam;
SetWindowText(hDlg, param->get_description());
SetWindowText(GetDlgItem(hDlg, IDSTRING), param->getptr());
return FALSE;
case WM_CLOSE:
EndDialog(hDlg, -1);
break;
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDOK:
GetWindowText(GetDlgItem(hDlg, IDSTRING), buffer, 20);
param->set(buffer);
EndDialog(hDlg, 1);
break;
case IDCANCEL:
EndDialog(hDlg, -1);
break;
}
}
return FALSE;
}
void LogAskDialog(BxEvent *event)
{
event->retcode = DialogBoxParam(NULL, MAKEINTRESOURCE(ASK_DLG), GetBochsWindow(),
@ -109,4 +138,10 @@ int AskFilename(bx_param_filename_c *param)
return ret;
}
int AskString(bx_param_string_c *param)
{
return DialogBoxParam(NULL, MAKEINTRESOURCE(STRING_DLG), GetBochsWindow(),
(DLGPROC)StringParamProc, (LPARAM)param);
}
#endif // WIN32

View File

@ -1,10 +1,11 @@
/////////////////////////////////////////////////////////////////////////
// $Id: win32dialog.h,v 1.2 2003-05-25 13:35:39 vruppert Exp $
// $Id: win32dialog.h,v 1.3 2003-05-25 18:34:03 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
#ifdef WIN32
void LogAskDialog(BxEvent *event);
int AskFilename(bx_param_filename_c *param);
int AskString(bx_param_string_c *param);
#endif

View File

@ -1,8 +1,10 @@
#define ICON_BOCHS 1000
#define ICON_BOCHS 1000
#define ASK_DLG 2000
#define IDASKTX1 2010
#define IDASKDEV 2020
#define IDASKTX2 2030
#define IDASKMSG 2040
#define IDASKLIST 2050
#define ASK_DLG 2000
#define IDASKTX1 2010
#define IDASKDEV 2020
#define IDASKTX2 2030
#define IDASKMSG 2040
#define IDASKLIST 2050
#define STRING_DLG 2100
#define IDSTRING 2110

View File

@ -16,3 +16,13 @@ BEGIN
DEFPUSHBUTTON "OK", IDOK, 140, 50, 50, 14
PUSHBUTTON "Cancel", IDCANCEL, 140, 70, 50, 14
END
STRING_DLG DIALOG 30, 30, 130, 65
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "Param"
FONT 8, "Helv"
BEGIN
EDITTEXT IDSTRING, 15, 15, 100, 14
DEFPUSHBUTTON "OK", IDOK, 10, 40, 50, 14
PUSHBUTTON "Cancel", IDCANCEL, 70, 40, 50, 14
END