- simple floppy image dialogbox for win32 added

- references to wx removed from the floppy button handlers (wx doesn't use them)
This commit is contained in:
Volker Ruppert 2003-07-15 21:02:05 +00:00
parent 4e63eca16c
commit 0d60d343b3
7 changed files with 122 additions and 35 deletions

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: gui.cc,v 1.69 2003-05-27 18:19:12 vruppert Exp $
// $Id: gui.cc,v 1.70 2003-07-15 21:02:05 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002 MandrakeSoft S.A.
@ -212,48 +212,42 @@ bx_gui_c::update_drive_status_buttons (void) {
void
bx_gui_c::floppyA_handler(void)
{
if (!strcmp(bx_options.Osel_config->get_choice(bx_options.Osel_config->get()),
"wx")) {
// instead of just toggling the status, call wxWindows to bring up
// a dialog asking what disk image you want to switch to.
int ret = SIM->ask_param (BXP_FLOPPYA_PATH);
if (ret < 0) return; // cancelled
#ifdef WIN32
// instead of just toggling the status, call win32dialog to bring up
// a dialog asking what disk image you want to switch to.
int ret = SIM->ask_param (BXP_FLOPPYA_PATH);
if (ret > 0) {
// eject and then insert the disk. If the new path is invalid,
// the status will return 0.
unsigned new_status = DEV_floppy_set_media_status(0, 0);
printf ("eject disk, new_status is %d\n", new_status);
new_status = DEV_floppy_set_media_status(0, 1);
printf ("insert disk, new_status is %d\n", new_status);
fflush (stdout);
BX_GUI_THIS floppyA_status = new_status;
} else {
}
#else
BX_GUI_THIS floppyA_status = !BX_GUI_THIS floppyA_status;
DEV_floppy_set_media_status(0, BX_GUI_THIS floppyA_status);
}
#endif
BX_GUI_THIS update_drive_status_buttons ();
}
void
bx_gui_c::floppyB_handler(void)
{
if (!strcmp(bx_options.Osel_config->get_choice(bx_options.Osel_config->get()),
"wx")) {
// instead of just toggling the status, call wxWindows to bring up
// a dialog asking what disk image you want to switch to.
int ret = SIM->ask_param (BXP_FLOPPYB_PATH);
if (ret < 0) return; // cancelled
#ifdef WIN32
// instead of just toggling the status, call win32dialog to bring up
// a dialog asking what disk image you want to switch to.
int ret = SIM->ask_param (BXP_FLOPPYB_PATH);
if (ret > 0) {
// eject and then insert the disk. If the new path is invalid,
// the status will return 0.
unsigned new_status = DEV_floppy_set_media_status(1, 0);
printf ("eject disk, new_status is %d\n", new_status);
new_status = DEV_floppy_set_media_status(1, 1);
printf ("insert disk, new_status is %d\n", new_status);
fflush (stdout);
BX_GUI_THIS floppyB_status = new_status;
} else {
}
#else
BX_GUI_THIS floppyB_status = !BX_GUI_THIS floppyB_status;
DEV_floppy_set_media_status(1, BX_GUI_THIS floppyB_status);
}
#endif
BX_GUI_THIS update_drive_status_buttons ();
}

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: textconfig.cc,v 1.12 2003-06-07 19:16:53 vruppert Exp $
// $Id: textconfig.cc,v 1.13 2003-07-15 21:02:05 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// This is code for a text-mode configuration interfac. Note that this file
@ -683,7 +683,11 @@ config_interface_notify_callback (void *unused, BxEvent *event)
sparam = (bx_param_string_c *)param;
opts = sparam->get_options()->get();
if (opts & sparam->IS_FILENAME) {
event->retcode = AskFilename((bx_param_filename_c *)sparam);
if (param->get_id() == BXP_NULL) {
event->retcode = AskFilename((bx_param_filename_c *)sparam);
} else {
event->retcode = FloppyDialog((bx_param_filename_c *)sparam);
}
return event;
} else {
event->retcode = AskString(sparam);

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: win32dialog.cc,v 1.3 2003-05-25 18:34:03 vruppert Exp $
// $Id: win32dialog.cc,v 1.4 2003-07-15 21:02:05 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
#ifdef WIN32
@ -12,6 +12,7 @@ extern "C" {
}
#include "win32res.h"
#include "siminterface.h"
#include "win32dialog.h"
HWND GetBochsWindow()
{
@ -91,6 +92,66 @@ static BOOL CALLBACK StringParamProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM
return FALSE;
}
static BOOL CALLBACK FloppyDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
static bx_param_filename_c *param;
static bx_param_enum_c *status;
static char origpath[MAX_PATH];
char path[MAX_PATH];
switch (msg) {
case WM_INITDIALOG:
param = (bx_param_filename_c *)lParam;
if (param->get_id() == BXP_FLOPPYA_PATH) {
status = SIM->get_param_enum(BXP_FLOPPYA_STATUS);
} else {
status = SIM->get_param_enum(BXP_FLOPPYB_STATUS);
}
if (status->get() == BX_INSERTED) {
SendMessage(GetDlgItem(hDlg, IDSTATUS), BM_SETCHECK, BST_CHECKED, 0);
}
lstrcpy(origpath, param->getptr());
SetWindowText(hDlg, param->get_ask_format());
if (lstrlen(origpath) && lstrcmp(origpath, "none")) {
SetWindowText(GetDlgItem(hDlg, IDPATH), origpath);
}
return FALSE;
case WM_CLOSE:
EndDialog(hDlg, -1);
break;
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDBROWSE:
if (AskFilename(param) > 0) {
SetWindowText(GetDlgItem(hDlg, IDPATH), param->getptr());
SendMessage(GetDlgItem(hDlg, IDSTATUS), BM_SETCHECK, BST_CHECKED, 0);
}
break;
case IDOK:
if (SendMessage(GetDlgItem(hDlg, IDSTATUS), BM_GETCHECK, 0, 0) == BST_CHECKED) {
GetWindowText(GetDlgItem(hDlg, IDPATH), path, MAX_PATH);
if (lstrlen(path)) {
status->set(BX_INSERTED);
} else {
status->set(BX_EJECTED);
lstrcpy(path, "none");
}
} else {
status->set(BX_EJECTED);
lstrcpy(path, "none");
}
param->set(path);
EndDialog(hDlg, 1);
break;
case IDCANCEL:
param->set(origpath);
EndDialog(hDlg, -1);
break;
}
}
return FALSE;
}
void LogAskDialog(BxEvent *event)
{
event->retcode = DialogBoxParam(NULL, MAKEINTRESOURCE(ASK_DLG), GetBochsWindow(),
@ -99,17 +160,19 @@ void LogAskDialog(BxEvent *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];
char *title;
param->get(filename, MAX_PATH);
title = param->get_ask_format();
if (!title) {
title = param->get_description();
}
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = GetBochsWindow();
ofn.hInstance = NULL;
ofn.lpstrFilter = Filter;
ofn.lpstrCustomFilter = NULL;
ofn.nMaxCustFilter = 0;
ofn.nFilterIndex = 0;
@ -118,18 +181,21 @@ int AskFilename(bx_param_filename_c *param)
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = NULL;
ofn.lpstrTitle = param->get_description();
ofn.lpstrTitle = title;
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.lpstrFilter = "Text files (*.txt)\0*.txt\0All files (*.*)\0*.*\0";
ofn.lpstrDefExt = "prg";
ofn.Flags |= OFN_OVERWRITEPROMPT;
ret = GetSaveFileName(&ofn);
} else {
ofn.lpstrFilter = "Floppy image files (*.img)\0*.img\0All files (*.*)\0*.*\0";
ofn.lpstrDefExt = "img";
ofn.Flags |= OFN_FILEMUSTEXIST;
ret = GetOpenFileName(&ofn);
}
@ -144,4 +210,10 @@ int AskString(bx_param_string_c *param)
(DLGPROC)StringParamProc, (LPARAM)param);
}
int FloppyDialog(bx_param_filename_c *param)
{
return DialogBoxParam(NULL, MAKEINTRESOURCE(FLOPPY_DLG), GetBochsWindow(),
(DLGPROC)FloppyDlgProc, (LPARAM)param);
}
#endif // WIN32

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: win32dialog.h,v 1.3 2003-05-25 18:34:03 vruppert Exp $
// $Id: win32dialog.h,v 1.4 2003-07-15 21:02:05 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
#ifdef WIN32
@ -7,5 +7,6 @@
void LogAskDialog(BxEvent *event);
int AskFilename(bx_param_filename_c *param);
int AskString(bx_param_string_c *param);
int FloppyDialog(bx_param_filename_c *param);
#endif

View File

@ -8,3 +8,7 @@
#define IDASKLIST 2050
#define STRING_DLG 2100
#define IDSTRING 2110
#define FLOPPY_DLG 2200
#define IDPATH 2210
#define IDBROWSE 2220
#define IDSTATUS 2230

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: main.cc,v 1.229 2003-07-10 20:26:05 vruppert Exp $
// $Id: main.cc,v 1.230 2003-07-15 21:02:05 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002 MandrakeSoft S.A.
@ -360,7 +360,7 @@ void bx_init_options ()
"Floppy A image",
"Pathname of first floppy image file or device. If you're booting from floppy, this should be a bootable floppy.",
"", BX_PATHNAME_LEN);
#if BX_WITH_WX
#if BX_WITH_WX || defined(WIN32)
bx_options.floppya.Opath->set_ask_format ("Filename of first floppy image");
#else
bx_options.floppya.Opath->set_ask_format ("Enter new filename, or 'none' for no disk: [%s] ");
@ -407,7 +407,7 @@ void bx_init_options ()
"floppyb:path",
"Pathname of second floppy image file or device.",
"", BX_PATHNAME_LEN);
#if BX_WITH_WX
#if BX_WITH_WX || defined(WIN32)
bx_options.floppyb.Opath->set_ask_format ("Filename of second floppy image");
#else
bx_options.floppyb.Opath->set_ask_format ("Enter new filename, or 'none' for no disk: [%s] ");

View File

@ -26,3 +26,15 @@ BEGIN
DEFPUSHBUTTON "OK", IDOK, 10, 40, 50, 14
PUSHBUTTON "Cancel", IDCANCEL, 70, 40, 50, 14
END
FLOPPY_DLG DIALOG 30, 30, 190, 80
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "Param"
FONT 8, "Helv"
BEGIN
EDITTEXT IDPATH, 15, 15, 100, 14, ES_AUTOHSCROLL
PUSHBUTTON "Browse...", IDBROWSE, 130, 15, 50, 14
AUTOCHECKBOX "Inserted", IDSTATUS, 15, 35, 50, 14
DEFPUSHBUTTON "OK", IDOK, 40, 55, 50, 14
PUSHBUTTON "Cancel", IDCANCEL, 100, 55, 50, 14
END