2003-05-22 00:33:24 +04:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
2009-02-23 00:48:21 +03:00
|
|
|
// $Id: win32dialog.cc,v 1.72 2009-02-22 21:48:21 sshwarts Exp $
|
2003-05-22 00:33:24 +04:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
2009-02-08 12:05:52 +03:00
|
|
|
//
|
|
|
|
// Copyright (C) 2009 The Bochs Project
|
|
|
|
//
|
|
|
|
// This library is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Lesser General Public
|
|
|
|
// License as published by the Free Software Foundation; either
|
|
|
|
// version 2 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public
|
|
|
|
// License along with this library; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
2003-05-22 00:33:24 +04:00
|
|
|
|
2008-10-21 17:45:03 +04:00
|
|
|
#include "win32dialog.h"
|
2003-05-22 00:33:24 +04:00
|
|
|
|
2008-12-18 18:37:25 +03:00
|
|
|
#if BX_USE_TEXTCONFIG && defined(WIN32) && (BX_WITH_WIN32 || BX_WITH_SDL)
|
2004-01-29 21:50:33 +03:00
|
|
|
|
2008-10-21 17:45:03 +04:00
|
|
|
#include "bochs.h"
|
2003-05-22 00:33:24 +04:00
|
|
|
#include "win32res.h"
|
|
|
|
|
2004-02-05 23:02:53 +03:00
|
|
|
const char log_choices[5][16] = {"ignore", "log", "ask user", "end simulation", "no change"};
|
2005-10-08 03:28:43 +04:00
|
|
|
static int retcode = 0;
|
2005-10-22 15:00:00 +04:00
|
|
|
static bxevent_handler old_callback = NULL;
|
|
|
|
static void *old_callback_arg = NULL;
|
2006-11-12 13:07:18 +03:00
|
|
|
#if BX_DEBUGGER
|
2008-12-27 15:06:39 +03:00
|
|
|
extern char *debug_cmd;
|
|
|
|
extern bx_bool debug_cmd_ready;
|
2009-01-09 17:53:38 +03:00
|
|
|
extern bx_bool vgaw_refresh;
|
2006-11-12 13:07:18 +03:00
|
|
|
#endif
|
2005-10-22 15:00:00 +04:00
|
|
|
|
|
|
|
int AskFilename(HWND hwnd, bx_param_filename_c *param, const char *ext);
|
2004-02-05 23:02:53 +03:00
|
|
|
|
2007-12-03 23:50:24 +03:00
|
|
|
char *backslashes(char *s)
|
|
|
|
{
|
|
|
|
if (s != NULL) {
|
|
|
|
while (*s != 0) {
|
|
|
|
if (*s == '/') *s = '\\';
|
|
|
|
s++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
2003-05-22 00:33:24 +04:00
|
|
|
HWND GetBochsWindow()
|
|
|
|
{
|
|
|
|
HWND hwnd;
|
|
|
|
|
2006-11-12 13:07:18 +03:00
|
|
|
hwnd = FindWindow("Bochs for Windows", NULL);
|
2003-05-22 00:33:24 +04:00
|
|
|
if (hwnd == NULL) {
|
|
|
|
hwnd = GetForegroundWindow();
|
|
|
|
}
|
|
|
|
return hwnd;
|
|
|
|
}
|
|
|
|
|
2003-09-01 21:47:57 +04:00
|
|
|
BOOL CreateImage(HWND hDlg, int sectors, const char *filename)
|
|
|
|
{
|
|
|
|
if (sectors < 1) {
|
|
|
|
MessageBox(hDlg, "The disk size is invalid.", "Invalid size", MB_ICONERROR);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (lstrlen(filename) < 1) {
|
|
|
|
MessageBox(hDlg, "You must type a file name for the new disk image.", "Bad filename", MB_ICONERROR);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
int ret = SIM->create_disk_image (filename, sectors, 0);
|
|
|
|
if (ret == -1) { // already exists
|
|
|
|
int answer = MessageBox(hDlg, "File exists. Do you want to overwrite it?",
|
|
|
|
"File exists", MB_YESNO);
|
|
|
|
if (answer == IDYES)
|
|
|
|
ret = SIM->create_disk_image (filename, sectors, 1);
|
2008-02-06 01:57:43 +03:00
|
|
|
else
|
2003-09-01 21:47:57 +04:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (ret == -2) {
|
|
|
|
MessageBox(hDlg, "I could not create the disk image. Check for permission problems or available disk space.", "Failed", MB_ICONERROR);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2006-05-29 22:52:46 +04:00
|
|
|
int CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData)
|
|
|
|
{
|
|
|
|
char path[MAX_PATH];
|
|
|
|
|
|
|
|
if (uMsg == BFFM_INITIALIZED) {
|
|
|
|
GetCurrentDirectory(MAX_PATH, path);
|
|
|
|
SendMessage(hwnd, BFFM_SETSELECTION, TRUE, (LPARAM)path);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-12-06 18:05:08 +03:00
|
|
|
#ifndef BIF_NEWDIALOGSTYLE
|
|
|
|
#define BIF_NEWDIALOGSTYLE 0
|
|
|
|
#endif
|
|
|
|
|
2006-04-09 17:55:55 +04:00
|
|
|
int BrowseDir(const char *Title, char *result)
|
|
|
|
{
|
|
|
|
BROWSEINFO browseInfo;
|
|
|
|
LPITEMIDLIST ItemIDList;
|
2006-08-30 00:10:27 +04:00
|
|
|
int r = -1;
|
2006-04-09 17:55:55 +04:00
|
|
|
|
|
|
|
memset(&browseInfo,0,sizeof(BROWSEINFO));
|
|
|
|
browseInfo.hwndOwner = GetActiveWindow();
|
|
|
|
browseInfo.pszDisplayName = result;
|
|
|
|
browseInfo.lpszTitle = (LPCSTR)Title;
|
|
|
|
browseInfo.ulFlags = BIF_NEWDIALOGSTYLE | BIF_RETURNONLYFSDIRS;
|
2006-05-29 22:52:46 +04:00
|
|
|
browseInfo.lpfn = BrowseCallbackProc;
|
2006-04-09 17:55:55 +04:00
|
|
|
ItemIDList = SHBrowseForFolder(&browseInfo);
|
|
|
|
if (ItemIDList != NULL) {
|
|
|
|
*result = 0;
|
|
|
|
if (SHGetPathFromIDList(ItemIDList, result)) {
|
2006-08-30 00:10:27 +04:00
|
|
|
if (result[0]) r = 0;
|
2006-04-09 17:55:55 +04:00
|
|
|
}
|
|
|
|
// free memory used
|
|
|
|
IMalloc * imalloc = 0;
|
|
|
|
if (SUCCEEDED(SHGetMalloc(&imalloc))) {
|
|
|
|
imalloc->Free(ItemIDList);
|
|
|
|
imalloc->Release();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2003-05-22 00:33:24 +04:00
|
|
|
static BOOL CALLBACK LogAskProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
BxEvent *event;
|
|
|
|
int level;
|
|
|
|
|
|
|
|
switch (msg) {
|
|
|
|
case WM_INITDIALOG:
|
|
|
|
event = (BxEvent*)lParam;
|
|
|
|
level = event->u.logmsg.level;
|
|
|
|
SetWindowText(hDlg, SIM->get_log_level_name(level));
|
|
|
|
SetWindowText(GetDlgItem(hDlg, IDASKDEV), event->u.logmsg.prefix);
|
|
|
|
SetWindowText(GetDlgItem(hDlg, IDASKMSG), event->u.logmsg.msg);
|
|
|
|
SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Continue");
|
|
|
|
SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Continue and don't ask again");
|
|
|
|
SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Kill simulation");
|
|
|
|
SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Abort (dump core)");
|
|
|
|
#if BX_DEBUGGER
|
|
|
|
SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Continue and return to debugger");
|
|
|
|
#endif
|
|
|
|
SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_SETCURSEL, 2, 0);
|
|
|
|
SetFocus(GetDlgItem(hDlg, IDASKLIST));
|
|
|
|
return FALSE;
|
|
|
|
case WM_CLOSE:
|
2003-10-24 19:39:57 +04:00
|
|
|
EndDialog(hDlg, BX_LOG_ASK_CHOICE_DIE);
|
2003-05-22 00:33:24 +04:00
|
|
|
break;
|
|
|
|
case WM_COMMAND:
|
|
|
|
switch (LOWORD(wParam)) {
|
|
|
|
case IDOK:
|
|
|
|
EndDialog(hDlg, SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_GETCURSEL, 0, 0));
|
|
|
|
break;
|
|
|
|
case IDCANCEL:
|
2003-10-24 19:39:57 +04:00
|
|
|
EndDialog(hDlg, BX_LOG_ASK_CHOICE_DIE);
|
2003-05-22 00:33:24 +04:00
|
|
|
break;
|
2004-02-01 04:40:14 +03:00
|
|
|
}
|
2003-05-22 00:33:24 +04:00
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2003-05-25 22:34:03 +04:00
|
|
|
static BOOL CALLBACK StringParamProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
static bx_param_string_c *param;
|
2006-05-30 02:33:38 +04:00
|
|
|
char buffer[512];
|
|
|
|
const char *title;
|
2003-05-25 22:34:03 +04:00
|
|
|
|
|
|
|
switch (msg) {
|
|
|
|
case WM_INITDIALOG:
|
|
|
|
param = (bx_param_string_c *)lParam;
|
2006-02-28 18:48:59 +03:00
|
|
|
title = param->get_label();
|
|
|
|
if ((title == NULL) || (strlen(title) == 0)) {
|
|
|
|
title = param->get_name();
|
|
|
|
}
|
|
|
|
SetWindowText(hDlg, title);
|
2003-05-25 22:34:03 +04:00
|
|
|
SetWindowText(GetDlgItem(hDlg, IDSTRING), param->getptr());
|
2005-10-22 15:00:00 +04:00
|
|
|
SendMessage(GetDlgItem(hDlg, IDSTRING), EM_SETLIMITTEXT, param->get_maxsize(), 0);
|
|
|
|
return TRUE;
|
|
|
|
break;
|
2003-05-25 22:34:03 +04:00
|
|
|
case WM_CLOSE:
|
|
|
|
EndDialog(hDlg, -1);
|
|
|
|
break;
|
|
|
|
case WM_COMMAND:
|
|
|
|
switch (LOWORD(wParam)) {
|
|
|
|
case IDOK:
|
2005-10-22 15:00:00 +04:00
|
|
|
GetDlgItemText(hDlg, IDSTRING, buffer, param->get_maxsize() + 1);
|
2003-05-25 22:34:03 +04:00
|
|
|
param->set(buffer);
|
|
|
|
EndDialog(hDlg, 1);
|
|
|
|
break;
|
|
|
|
case IDCANCEL:
|
|
|
|
EndDialog(hDlg, -1);
|
|
|
|
break;
|
2004-02-01 04:40:14 +03:00
|
|
|
}
|
2003-05-25 22:34:03 +04:00
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2003-07-16 01:02:05 +04:00
|
|
|
static BOOL CALLBACK FloppyDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
static bx_param_filename_c *param;
|
|
|
|
static bx_param_enum_c *status;
|
2005-11-20 20:22:44 +03:00
|
|
|
static bx_param_enum_c *devtype;
|
|
|
|
static bx_param_enum_c *mediatype;
|
2003-07-16 01:02:05 +04:00
|
|
|
static char origpath[MAX_PATH];
|
2003-09-01 21:47:57 +04:00
|
|
|
char mesg[MAX_PATH];
|
2003-07-16 01:02:05 +04:00
|
|
|
char path[MAX_PATH];
|
2006-02-27 01:36:01 +03:00
|
|
|
char pname[80];
|
2006-05-30 02:33:38 +04:00
|
|
|
const char *title;
|
2005-11-20 20:22:44 +03:00
|
|
|
int i, cap;
|
2003-07-16 01:02:05 +04:00
|
|
|
|
|
|
|
switch (msg) {
|
|
|
|
case WM_INITDIALOG:
|
|
|
|
param = (bx_param_filename_c *)lParam;
|
2006-02-27 01:36:01 +03:00
|
|
|
param->get_param_path(pname, 80);
|
|
|
|
if (!strcmp(pname, BXPN_FLOPPYA_PATH)) {
|
2006-02-25 01:35:46 +03:00
|
|
|
status = SIM->get_param_enum(BXPN_FLOPPYA_STATUS);
|
|
|
|
devtype = SIM->get_param_enum(BXPN_FLOPPYA_DEVTYPE);
|
|
|
|
mediatype = SIM->get_param_enum(BXPN_FLOPPYA_TYPE);
|
2003-07-16 01:02:05 +04:00
|
|
|
} else {
|
2006-02-25 01:35:46 +03:00
|
|
|
status = SIM->get_param_enum(BXPN_FLOPPYB_STATUS);
|
|
|
|
devtype = SIM->get_param_enum(BXPN_FLOPPYB_DEVTYPE);
|
|
|
|
mediatype = SIM->get_param_enum(BXPN_FLOPPYB_TYPE);
|
2003-07-16 01:02:05 +04:00
|
|
|
}
|
2005-11-20 20:22:44 +03:00
|
|
|
cap = devtype->get() - (int)devtype->get_min();
|
2003-09-18 21:37:46 +04:00
|
|
|
SetWindowText(GetDlgItem(hDlg, IDDEVTYPE), floppy_type_names[cap]);
|
2006-12-17 11:17:28 +03:00
|
|
|
i = 0;
|
|
|
|
while (floppy_type_names[i] != NULL) {
|
2005-11-20 20:22:44 +03:00
|
|
|
SendMessage(GetDlgItem(hDlg, IDMEDIATYPE), CB_ADDSTRING, 0, (LPARAM)floppy_type_names[i]);
|
|
|
|
SendMessage(GetDlgItem(hDlg, IDMEDIATYPE), CB_SETITEMDATA, i, (LPARAM)(mediatype->get_min() + i));
|
2006-12-17 21:14:59 +03:00
|
|
|
i++;
|
2005-11-20 20:22:44 +03:00
|
|
|
}
|
|
|
|
cap = mediatype->get() - (int)mediatype->get_min();
|
|
|
|
SendMessage(GetDlgItem(hDlg, IDMEDIATYPE), CB_SETCURSEL, cap, 0);
|
2003-07-16 01:02:05 +04:00
|
|
|
if (status->get() == BX_INSERTED) {
|
|
|
|
SendMessage(GetDlgItem(hDlg, IDSTATUS), BM_SETCHECK, BST_CHECKED, 0);
|
|
|
|
}
|
|
|
|
lstrcpy(origpath, param->getptr());
|
2003-08-30 21:13:06 +04:00
|
|
|
title = param->get_label();
|
|
|
|
if (!title) title = param->get_name();
|
|
|
|
SetWindowText(hDlg, title);
|
2003-07-16 01:02:05 +04:00
|
|
|
if (lstrlen(origpath) && lstrcmp(origpath, "none")) {
|
|
|
|
SetWindowText(GetDlgItem(hDlg, IDPATH), origpath);
|
|
|
|
}
|
2004-02-26 22:25:00 +03:00
|
|
|
return TRUE;
|
|
|
|
break;
|
2003-07-16 01:02:05 +04:00
|
|
|
case WM_CLOSE:
|
2004-02-26 22:25:00 +03:00
|
|
|
GetDlgItemText(hDlg, IDPATH, path, MAX_PATH);
|
|
|
|
if (lstrcmp(path, origpath)) {
|
|
|
|
param->set(origpath);
|
|
|
|
}
|
2003-07-16 01:02:05 +04:00
|
|
|
EndDialog(hDlg, -1);
|
2004-02-26 22:25:00 +03:00
|
|
|
return TRUE;
|
2003-07-16 01:02:05 +04:00
|
|
|
break;
|
|
|
|
case WM_COMMAND:
|
|
|
|
switch (LOWORD(wParam)) {
|
|
|
|
case IDBROWSE:
|
2004-02-01 04:40:14 +03:00
|
|
|
GetDlgItemText(hDlg, IDPATH, path, MAX_PATH);
|
2007-12-03 23:50:24 +03:00
|
|
|
param->set(backslashes(path));
|
2004-02-01 04:40:14 +03:00
|
|
|
if (AskFilename(hDlg, param, "img") > 0) {
|
2003-07-16 01:02:05 +04:00
|
|
|
SetWindowText(GetDlgItem(hDlg, IDPATH), param->getptr());
|
|
|
|
SendMessage(GetDlgItem(hDlg, IDSTATUS), BM_SETCHECK, BST_CHECKED, 0);
|
2005-11-27 17:15:11 +03:00
|
|
|
SendMessage(GetDlgItem(hDlg, IDMEDIATYPE), CB_SELECTSTRING, (WPARAM)-1, (LPARAM)"auto");
|
2005-11-26 01:44:18 +03:00
|
|
|
EnableWindow(GetDlgItem(hDlg, IDCREATE), FALSE);
|
2003-07-16 01:02:05 +04:00
|
|
|
}
|
2004-02-26 22:25:00 +03:00
|
|
|
return TRUE;
|
2003-07-16 01:02:05 +04:00
|
|
|
break;
|
|
|
|
case IDOK:
|
2005-11-20 20:22:44 +03:00
|
|
|
status->set(BX_EJECTED);
|
2003-07-16 01:02:05 +04:00
|
|
|
if (SendMessage(GetDlgItem(hDlg, IDSTATUS), BM_GETCHECK, 0, 0) == BST_CHECKED) {
|
2004-02-01 04:40:14 +03:00
|
|
|
GetDlgItemText(hDlg, IDPATH, path, MAX_PATH);
|
2005-11-20 20:22:44 +03:00
|
|
|
if (lstrlen(path) == 0) {
|
2003-07-16 01:02:05 +04:00
|
|
|
lstrcpy(path, "none");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
lstrcpy(path, "none");
|
|
|
|
}
|
|
|
|
param->set(path);
|
2005-11-20 20:22:44 +03:00
|
|
|
i = SendMessage(GetDlgItem(hDlg, IDMEDIATYPE), CB_GETCURSEL, 0, 0);
|
|
|
|
cap = SendMessage(GetDlgItem(hDlg, IDMEDIATYPE), CB_GETITEMDATA, i, 0);
|
|
|
|
mediatype->set(cap);
|
|
|
|
if (lstrcmp(path, "none")) {
|
|
|
|
status->set(BX_INSERTED);
|
|
|
|
}
|
2003-07-16 01:02:05 +04:00
|
|
|
EndDialog(hDlg, 1);
|
2004-02-26 22:25:00 +03:00
|
|
|
return TRUE;
|
2003-07-16 01:02:05 +04:00
|
|
|
break;
|
|
|
|
case IDCANCEL:
|
2004-02-26 22:25:00 +03:00
|
|
|
GetDlgItemText(hDlg, IDPATH, path, MAX_PATH);
|
|
|
|
if (lstrcmp(path, origpath)) {
|
|
|
|
param->set(origpath);
|
|
|
|
}
|
2003-07-16 01:02:05 +04:00
|
|
|
EndDialog(hDlg, -1);
|
2004-02-26 22:25:00 +03:00
|
|
|
return TRUE;
|
2003-07-16 01:02:05 +04:00
|
|
|
break;
|
2005-11-20 20:22:44 +03:00
|
|
|
case IDMEDIATYPE:
|
|
|
|
if (HIWORD(wParam) == CBN_SELCHANGE) {
|
|
|
|
i = SendMessage(GetDlgItem(hDlg, IDMEDIATYPE), CB_GETCURSEL, 0, 0);
|
|
|
|
EnableWindow(GetDlgItem(hDlg, IDCREATE), (floppy_type_n_sectors[i] > 0));
|
|
|
|
}
|
|
|
|
break;
|
2003-09-01 21:47:57 +04:00
|
|
|
case IDCREATE:
|
2004-02-01 04:40:14 +03:00
|
|
|
GetDlgItemText(hDlg, IDPATH, path, MAX_PATH);
|
2007-12-03 23:50:24 +03:00
|
|
|
backslashes(path);
|
2005-11-20 20:22:44 +03:00
|
|
|
i = SendMessage(GetDlgItem(hDlg, IDMEDIATYPE), CB_GETCURSEL, 0, 0);
|
|
|
|
if (CreateImage(hDlg, floppy_type_n_sectors[i], path)) {
|
|
|
|
wsprintf(mesg, "Created a %s disk image called %s", floppy_type_names[i], path);
|
2003-09-01 21:47:57 +04:00
|
|
|
MessageBox(hDlg, mesg, "Image created", MB_OK);
|
|
|
|
}
|
2004-02-26 22:25:00 +03:00
|
|
|
return TRUE;
|
2003-09-01 21:47:57 +04:00
|
|
|
break;
|
2004-02-01 04:40:14 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL CALLBACK Cdrom1DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
2006-02-26 22:11:20 +03:00
|
|
|
static bx_list_c *cdromop;
|
2004-02-01 04:40:14 +03:00
|
|
|
int device;
|
|
|
|
static char origpath[MAX_PATH];
|
|
|
|
char path[MAX_PATH];
|
|
|
|
|
|
|
|
switch (msg) {
|
|
|
|
case WM_INITDIALOG:
|
|
|
|
SIM->get_cdrom_options(0, &cdromop, &device);
|
2006-02-26 22:11:20 +03:00
|
|
|
lstrcpy(origpath, SIM->get_param_string("path", cdromop)->getptr());
|
2004-02-01 04:40:14 +03:00
|
|
|
if (lstrlen(origpath) && lstrcmp(origpath, "none")) {
|
|
|
|
SetWindowText(GetDlgItem(hDlg, IDCDROM1), origpath);
|
|
|
|
}
|
2006-02-26 22:11:20 +03:00
|
|
|
if (SIM->get_param_enum("status", cdromop)->get() == BX_INSERTED) {
|
2004-02-01 04:40:14 +03:00
|
|
|
SendMessage(GetDlgItem(hDlg, IDSTATUS1), BM_SETCHECK, BST_CHECKED, 0);
|
|
|
|
}
|
2005-10-22 15:00:00 +04:00
|
|
|
return TRUE;
|
2004-02-01 04:40:14 +03:00
|
|
|
break;
|
|
|
|
case WM_CLOSE:
|
2006-02-26 22:11:20 +03:00
|
|
|
if (lstrcmp(SIM->get_param_string("path", cdromop)->getptr(), origpath)) {
|
|
|
|
SIM->get_param_string("path", cdromop)->set(origpath);
|
2004-08-30 14:47:09 +04:00
|
|
|
}
|
2004-02-01 04:40:14 +03:00
|
|
|
EndDialog(hDlg, -1);
|
|
|
|
break;
|
|
|
|
case WM_COMMAND:
|
|
|
|
switch (LOWORD(wParam)) {
|
|
|
|
case IDBROWSE1:
|
|
|
|
GetDlgItemText(hDlg, IDCDROM1, path, MAX_PATH);
|
2007-12-03 23:50:24 +03:00
|
|
|
SIM->get_param_string("path", cdromop)->set(backslashes(path));
|
2006-02-26 22:11:20 +03:00
|
|
|
if (AskFilename(hDlg, (bx_param_filename_c *)SIM->get_param_string("path", cdromop), "iso") > 0) {
|
|
|
|
SetWindowText(GetDlgItem(hDlg, IDCDROM1), SIM->get_param_string("path", cdromop)->getptr());
|
2004-02-01 04:40:14 +03:00
|
|
|
SendMessage(GetDlgItem(hDlg, IDSTATUS1), BM_SETCHECK, BST_CHECKED, 0);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case IDOK:
|
|
|
|
if (SendMessage(GetDlgItem(hDlg, IDSTATUS1), BM_GETCHECK, 0, 0) == BST_CHECKED) {
|
|
|
|
GetDlgItemText(hDlg, IDCDROM1, path, MAX_PATH);
|
|
|
|
if (lstrlen(path)) {
|
2006-02-26 22:11:20 +03:00
|
|
|
SIM->get_param_enum("status", cdromop)->set(BX_INSERTED);
|
|
|
|
if (lstrcmp(path, SIM->get_param_string("path", cdromop)->getptr())) {
|
|
|
|
SIM->get_param_string("path", cdromop)->set(path);
|
2004-08-30 14:47:09 +04:00
|
|
|
}
|
2004-02-01 04:40:14 +03:00
|
|
|
} else {
|
2006-02-26 22:11:20 +03:00
|
|
|
SIM->get_param_enum("status", cdromop)->set(BX_EJECTED);
|
2004-02-01 04:40:14 +03:00
|
|
|
}
|
|
|
|
} else {
|
2006-02-26 22:11:20 +03:00
|
|
|
SIM->get_param_enum("status", cdromop)->set(BX_EJECTED);
|
2004-02-01 04:40:14 +03:00
|
|
|
}
|
|
|
|
EndDialog(hDlg, 1);
|
|
|
|
break;
|
|
|
|
case IDCANCEL:
|
2006-02-26 22:11:20 +03:00
|
|
|
if (lstrcmp(SIM->get_param_string("path", cdromop)->getptr(), origpath)) {
|
|
|
|
SIM->get_param_string("path", cdromop)->set(origpath);
|
2004-08-30 14:47:09 +04:00
|
|
|
}
|
2004-02-01 04:40:14 +03:00
|
|
|
EndDialog(hDlg, -1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2004-02-05 23:02:53 +03:00
|
|
|
void RuntimeDlgSetStdLogOpt(HWND hDlg)
|
2004-02-01 22:22:41 +03:00
|
|
|
{
|
2004-02-05 23:02:53 +03:00
|
|
|
int level, idx;
|
2004-02-01 22:22:41 +03:00
|
|
|
int defchoice[5];
|
|
|
|
|
|
|
|
for (level=0; level<5; level++) {
|
2004-02-05 23:02:53 +03:00
|
|
|
int mod = 0;
|
2004-02-01 22:22:41 +03:00
|
|
|
int first = SIM->get_log_action (mod, level);
|
|
|
|
BOOL consensus = true;
|
|
|
|
// now compare all others to first. If all match, then use "first" as
|
|
|
|
// the initial value.
|
2004-02-05 23:02:53 +03:00
|
|
|
for (mod=1; mod<SIM->get_n_log_modules(); mod++) {
|
2004-02-01 22:22:41 +03:00
|
|
|
if (first != SIM->get_log_action (mod, level)) {
|
|
|
|
consensus = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (consensus)
|
|
|
|
defchoice[level] = first;
|
|
|
|
else
|
|
|
|
defchoice[level] = 4;
|
|
|
|
}
|
|
|
|
for (level=0; level<5; level++) {
|
|
|
|
idx = 0;
|
2004-02-05 23:02:53 +03:00
|
|
|
SendMessage(GetDlgItem(hDlg, IDLOGEVT1+level), CB_RESETCONTENT, 0, 0);
|
2004-02-01 22:22:41 +03:00
|
|
|
for (int action=0; action<5; action++) {
|
|
|
|
if (((level > 1) && (action > 0)) || ((level < 2) && ((action < 2) || (action > 3)))) {
|
2004-02-05 23:02:53 +03:00
|
|
|
SendMessage(GetDlgItem(hDlg, IDLOGEVT1+level), CB_ADDSTRING, 0, (LPARAM)log_choices[action]);
|
2004-02-01 22:22:41 +03:00
|
|
|
SendMessage(GetDlgItem(hDlg, IDLOGEVT1+level), CB_SETITEMDATA, idx, action);
|
|
|
|
if (action == defchoice[level]) {
|
|
|
|
SendMessage(GetDlgItem(hDlg, IDLOGEVT1+level), CB_SETCURSEL, idx, 0);
|
|
|
|
}
|
|
|
|
idx++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-02-05 23:02:53 +03:00
|
|
|
EnableWindow(GetDlgItem(hDlg, IDDEVLIST), FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
void RuntimeDlgSetAdvLogOpt(HWND hDlg)
|
|
|
|
{
|
|
|
|
int idx, level, mod;
|
|
|
|
|
|
|
|
idx = SendMessage(GetDlgItem(hDlg, IDDEVLIST), LB_GETCURSEL, 0, 0);
|
|
|
|
mod = SendMessage(GetDlgItem(hDlg, IDDEVLIST), LB_GETITEMDATA, idx, 0);
|
|
|
|
for (level=0; level<5; level++) {
|
|
|
|
idx = 0;
|
|
|
|
SendMessage(GetDlgItem(hDlg, IDLOGEVT1+level), CB_RESETCONTENT, 0, 0);
|
|
|
|
for (int action=0; action<4; action++) {
|
|
|
|
if (((level > 1) && (action > 0)) || ((level < 2) && (action < 2))) {
|
|
|
|
SendMessage(GetDlgItem(hDlg, IDLOGEVT1+level), CB_ADDSTRING, 0, (LPARAM)log_choices[action]);
|
|
|
|
SendMessage(GetDlgItem(hDlg, IDLOGEVT1+level), CB_SETITEMDATA, idx, action);
|
|
|
|
if (action == SIM->get_log_action (mod, level)) {
|
|
|
|
SendMessage(GetDlgItem(hDlg, IDLOGEVT1+level), CB_SETCURSEL, idx, 0);
|
|
|
|
}
|
|
|
|
idx++;
|
|
|
|
}
|
2004-02-04 01:40:33 +03:00
|
|
|
}
|
|
|
|
}
|
2004-02-01 22:22:41 +03:00
|
|
|
}
|
|
|
|
|
2005-10-08 03:28:43 +04:00
|
|
|
static BOOL CALLBACK RTCdromDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
|
2004-02-01 04:40:14 +03:00
|
|
|
{
|
|
|
|
static int devcount;
|
2006-02-26 22:11:20 +03:00
|
|
|
static bx_list_c *cdromop[4];
|
2004-02-01 04:40:14 +03:00
|
|
|
static char origpath[4][MAX_PATH];
|
2005-10-08 03:28:43 +04:00
|
|
|
static BOOL changed;
|
|
|
|
int device;
|
|
|
|
long noticode;
|
2005-01-19 21:21:40 +03:00
|
|
|
Bit8u cdrom;
|
2005-10-08 03:28:43 +04:00
|
|
|
char path[MAX_PATH];
|
|
|
|
PSHNOTIFY *psn;
|
2004-02-01 04:40:14 +03:00
|
|
|
|
|
|
|
switch (msg) {
|
|
|
|
case WM_INITDIALOG:
|
2005-10-08 03:28:43 +04:00
|
|
|
SetForegroundWindow(GetParent(hDlg));
|
|
|
|
SetDlgItemText(GetParent(hDlg), IDOK, "Continue");
|
|
|
|
SetDlgItemText(GetParent(hDlg), IDCANCEL, "Quit");
|
2004-02-01 04:40:14 +03:00
|
|
|
// 4 cdroms supported at run time
|
|
|
|
devcount = 1;
|
2005-01-19 21:21:40 +03:00
|
|
|
for (cdrom=1; cdrom<4; cdrom++) {
|
2006-02-26 22:11:20 +03:00
|
|
|
if (!SIM->get_cdrom_options(cdrom, &cdromop[cdrom], &device) ||
|
|
|
|
!SIM->get_param_bool("present", cdromop[cdrom])->get()) {
|
2004-02-01 04:40:14 +03:00
|
|
|
EnableWindow(GetDlgItem(hDlg, IDLABEL1+cdrom), FALSE);
|
|
|
|
EnableWindow(GetDlgItem(hDlg, IDCDROM1+cdrom), FALSE);
|
|
|
|
EnableWindow(GetDlgItem(hDlg, IDBROWSE1+cdrom), FALSE);
|
|
|
|
EnableWindow(GetDlgItem(hDlg, IDSTATUS1+cdrom), FALSE);
|
|
|
|
} else {
|
2006-02-26 22:11:20 +03:00
|
|
|
lstrcpy(origpath[cdrom], SIM->get_param_string("path", cdromop[cdrom])->getptr());
|
2004-02-01 04:40:14 +03:00
|
|
|
if (lstrlen(origpath[cdrom]) && lstrcmp(origpath[cdrom], "none")) {
|
|
|
|
SetWindowText(GetDlgItem(hDlg, IDCDROM1+cdrom), origpath[cdrom]);
|
|
|
|
}
|
2006-02-26 22:11:20 +03:00
|
|
|
if (SIM->get_param_enum("status", cdromop[cdrom])->get() == BX_INSERTED) {
|
2004-02-01 04:40:14 +03:00
|
|
|
SendMessage(GetDlgItem(hDlg, IDSTATUS1+cdrom), BM_SETCHECK, BST_CHECKED, 0);
|
|
|
|
}
|
|
|
|
devcount++;
|
|
|
|
}
|
|
|
|
}
|
2005-10-08 03:28:43 +04:00
|
|
|
changed = FALSE;
|
|
|
|
return TRUE;
|
|
|
|
case WM_NOTIFY:
|
|
|
|
psn = (PSHNOTIFY *)lParam;
|
|
|
|
switch(psn->hdr.code) {
|
|
|
|
case PSN_APPLY:
|
|
|
|
if ((psn->lParam == FALSE) && changed) { // Apply pressed & change in this dialog
|
|
|
|
for (device=1; device<devcount; device++) {
|
|
|
|
if (SendMessage(GetDlgItem(hDlg, IDSTATUS1+device), BM_GETCHECK, 0, 0) == BST_CHECKED) {
|
|
|
|
GetDlgItemText(hDlg, IDCDROM1+device, path, MAX_PATH);
|
|
|
|
if (lstrlen(path)) {
|
2006-02-26 22:11:20 +03:00
|
|
|
SIM->get_param_enum("status", cdromop[device])->set(BX_INSERTED);
|
|
|
|
if (lstrcmp(path, SIM->get_param_string("path", cdromop[device])->getptr())) {
|
|
|
|
SIM->get_param_string("path", cdromop[device])->set(path);
|
2005-10-08 03:28:43 +04:00
|
|
|
}
|
|
|
|
} else {
|
2006-02-26 22:11:20 +03:00
|
|
|
SIM->get_param_enum("status", cdromop[device])->set(BX_EJECTED);
|
2005-10-08 03:28:43 +04:00
|
|
|
}
|
|
|
|
} else {
|
2006-02-26 22:11:20 +03:00
|
|
|
SIM->get_param_enum("status", cdromop[device])->set(BX_EJECTED);
|
2005-10-08 03:28:43 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
changed = FALSE;
|
|
|
|
} else {
|
|
|
|
if (changed) {
|
|
|
|
for (device=1; device<devcount; device++) {
|
2006-02-26 22:11:20 +03:00
|
|
|
if (lstrcmp(SIM->get_param_string("path", cdromop[device])->getptr(), origpath[device])) {
|
|
|
|
SIM->get_param_string("path", cdromop[device])->set(origpath[device]);
|
2005-10-08 03:28:43 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
retcode = BX_CI_RT_CONT;
|
|
|
|
}
|
|
|
|
return PSNRET_NOERROR;
|
|
|
|
case PSN_QUERYCANCEL:
|
|
|
|
retcode = BX_CI_RT_QUIT;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case WM_COMMAND:
|
|
|
|
noticode = HIWORD(wParam);
|
|
|
|
switch(noticode) {
|
|
|
|
case EN_CHANGE:
|
|
|
|
switch (LOWORD(wParam)) {
|
|
|
|
case IDCDROM2:
|
|
|
|
case IDCDROM3:
|
|
|
|
case IDCDROM4:
|
|
|
|
changed = TRUE;
|
|
|
|
SendMessage(GetParent(hDlg), PSM_CHANGED, (WPARAM)hDlg, 0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
switch (LOWORD(wParam)) {
|
|
|
|
case IDBROWSE2:
|
|
|
|
case IDBROWSE3:
|
|
|
|
case IDBROWSE4:
|
|
|
|
device = LOWORD(wParam) - IDBROWSE1;
|
|
|
|
GetDlgItemText(hDlg, IDCDROM1+device, path, MAX_PATH);
|
2007-12-03 23:50:24 +03:00
|
|
|
SIM->get_param_string("path", cdromop[device])->set(backslashes(path));
|
2006-02-26 22:11:20 +03:00
|
|
|
if (AskFilename(hDlg, (bx_param_filename_c *)SIM->get_param_string("path", cdromop[device]), "iso") > 0) {
|
|
|
|
SetWindowText(GetDlgItem(hDlg, IDCDROM1+device), SIM->get_param_string("path", cdromop[device])->getptr());
|
2005-10-08 03:28:43 +04:00
|
|
|
SendMessage(GetDlgItem(hDlg, IDSTATUS1+device), BM_SETCHECK, BST_CHECKED, 0);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case IDSTATUS2:
|
|
|
|
case IDSTATUS3:
|
|
|
|
case IDSTATUS4:
|
|
|
|
changed = TRUE;
|
|
|
|
SendMessage(GetParent(hDlg), PSM_CHANGED, (WPARAM)hDlg, 0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2005-11-30 21:06:24 +03:00
|
|
|
static BOOL CALLBACK RTUSBdevDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
static BOOL changed;
|
|
|
|
long noticode;
|
|
|
|
char buffer[MAX_PATH];
|
|
|
|
PSHNOTIFY *psn;
|
|
|
|
|
|
|
|
switch (msg) {
|
|
|
|
case WM_INITDIALOG:
|
2009-01-19 16:13:32 +03:00
|
|
|
if (SIM->get_param_string(BXPN_UHCI_PORT1)->get_enabled()) {
|
|
|
|
SetDlgItemText(hDlg, IDUSBDEV1, SIM->get_param_string(BXPN_UHCI_PORT1)->getptr());
|
|
|
|
SetDlgItemText(hDlg, IDUSBDEV2, SIM->get_param_string(BXPN_UHCI_PORT2)->getptr());
|
2005-12-26 21:10:21 +03:00
|
|
|
} else {
|
|
|
|
EnableWindow(GetDlgItem(hDlg, IDUSBLBL1), FALSE);
|
|
|
|
EnableWindow(GetDlgItem(hDlg, IDUSBLBL2), FALSE);
|
|
|
|
EnableWindow(GetDlgItem(hDlg, IDUSBDEV1), FALSE);
|
|
|
|
EnableWindow(GetDlgItem(hDlg, IDUSBDEV2), FALSE);
|
|
|
|
}
|
2005-11-30 21:06:24 +03:00
|
|
|
changed = FALSE;
|
|
|
|
return TRUE;
|
|
|
|
case WM_NOTIFY:
|
|
|
|
psn = (PSHNOTIFY *)lParam;
|
|
|
|
switch(psn->hdr.code) {
|
|
|
|
case PSN_APPLY:
|
|
|
|
if ((psn->lParam == FALSE) && changed) { // Apply pressed & change in this dialog
|
|
|
|
GetDlgItemText(hDlg, IDUSBDEV1, buffer, sizeof(buffer));
|
2009-01-19 16:13:32 +03:00
|
|
|
SIM->get_param_string(BXPN_UHCI_PORT1)->set(buffer);
|
2005-11-30 21:06:24 +03:00
|
|
|
GetDlgItemText(hDlg, IDUSBDEV2, buffer, sizeof(buffer));
|
2009-01-19 16:13:32 +03:00
|
|
|
SIM->get_param_string(BXPN_UHCI_PORT2)->set(buffer);
|
2005-11-30 21:06:24 +03:00
|
|
|
}
|
|
|
|
return PSNRET_NOERROR;
|
|
|
|
case PSN_QUERYCANCEL:
|
|
|
|
retcode = BX_CI_RT_QUIT;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case WM_COMMAND:
|
|
|
|
noticode = HIWORD(wParam);
|
|
|
|
switch(noticode) {
|
|
|
|
case EN_CHANGE:
|
|
|
|
switch (LOWORD(wParam)) {
|
|
|
|
case IDUSBDEV1:
|
|
|
|
case IDUSBDEV2:
|
|
|
|
changed = TRUE;
|
|
|
|
SendMessage(GetParent(hDlg), PSM_CHANGED, (WPARAM)hDlg, 0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2005-10-08 03:28:43 +04:00
|
|
|
static BOOL CALLBACK RTLogOptDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
static BOOL advanced;
|
|
|
|
static BOOL changed;
|
|
|
|
int idx, level, mod, value;
|
|
|
|
long noticode;
|
|
|
|
char prefix[8];
|
|
|
|
PSHNOTIFY *psn;
|
|
|
|
|
|
|
|
switch (msg) {
|
|
|
|
case WM_INITDIALOG:
|
2004-02-05 23:02:53 +03:00
|
|
|
idx = 0;
|
|
|
|
for (mod=0; mod<SIM->get_n_log_modules(); mod++) {
|
|
|
|
if (strcmp(SIM->get_prefix(mod), "[ ]")) {
|
|
|
|
lstrcpyn(prefix, SIM->get_prefix(mod), sizeof(prefix));
|
|
|
|
lstrcpy(prefix, prefix+1);
|
|
|
|
prefix[5] = 0;
|
|
|
|
SendMessage(GetDlgItem(hDlg, IDDEVLIST), LB_ADDSTRING, 0, (LPARAM)prefix);
|
|
|
|
SendMessage(GetDlgItem(hDlg, IDDEVLIST), LB_SETITEMDATA, idx, mod);
|
|
|
|
idx++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
RuntimeDlgSetStdLogOpt(hDlg);
|
|
|
|
advanced = FALSE;
|
2005-10-08 03:28:43 +04:00
|
|
|
changed = FALSE;
|
|
|
|
return TRUE;
|
|
|
|
case WM_NOTIFY:
|
|
|
|
psn = (PSHNOTIFY *)lParam;
|
|
|
|
switch(psn->hdr.code) {
|
|
|
|
case PSN_APPLY:
|
|
|
|
if ((psn->lParam == FALSE) && changed) { // Apply pressed & change in this dialog
|
|
|
|
if (advanced) {
|
|
|
|
idx = SendMessage(GetDlgItem(hDlg, IDDEVLIST), LB_GETCURSEL, 0, 0);
|
|
|
|
mod = SendMessage(GetDlgItem(hDlg, IDDEVLIST), LB_GETITEMDATA, idx, 0);
|
|
|
|
for (level=0; level<5; level++) {
|
|
|
|
idx = SendMessage(GetDlgItem(hDlg, IDLOGEVT1+level), CB_GETCURSEL, 0, 0);
|
|
|
|
value = SendMessage(GetDlgItem(hDlg, IDLOGEVT1+level), CB_GETITEMDATA, idx, 0);
|
|
|
|
SIM->set_log_action (mod, level, value);
|
|
|
|
}
|
|
|
|
EnableWindow(GetDlgItem(hDlg, IDDEVLIST), TRUE);
|
|
|
|
} else {
|
|
|
|
for (level=0; level<5; level++) {
|
|
|
|
idx = SendMessage(GetDlgItem(hDlg, IDLOGEVT1+level), CB_GETCURSEL, 0, 0);
|
|
|
|
value = SendMessage(GetDlgItem(hDlg, IDLOGEVT1+level), CB_GETITEMDATA, idx, 0);
|
|
|
|
if (value < 4) {
|
|
|
|
// set new default
|
|
|
|
SIM->set_default_log_action (level, value);
|
|
|
|
// apply that action to all modules (devices)
|
|
|
|
SIM->set_log_action (-1, level, value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
EnableWindow(GetDlgItem(hDlg, IDADVLOGOPT), TRUE);
|
|
|
|
changed = FALSE;
|
|
|
|
}
|
|
|
|
return PSNRET_NOERROR;
|
|
|
|
case PSN_QUERYCANCEL:
|
|
|
|
retcode = BX_CI_RT_QUIT;
|
|
|
|
return TRUE;
|
2004-02-01 04:40:14 +03:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case WM_COMMAND:
|
|
|
|
noticode = HIWORD(wParam);
|
|
|
|
switch(noticode) {
|
2004-02-05 23:02:53 +03:00
|
|
|
case CBN_SELCHANGE: /* LBN_SELCHANGE is the same value */
|
|
|
|
switch (LOWORD(wParam)) {
|
|
|
|
case IDDEVLIST:
|
|
|
|
RuntimeDlgSetAdvLogOpt(hDlg);
|
|
|
|
break;
|
|
|
|
case IDLOGEVT1:
|
|
|
|
case IDLOGEVT2:
|
|
|
|
case IDLOGEVT3:
|
|
|
|
case IDLOGEVT4:
|
|
|
|
case IDLOGEVT5:
|
2005-10-08 03:28:43 +04:00
|
|
|
if (!changed) {
|
2004-02-05 23:02:53 +03:00
|
|
|
EnableWindow(GetDlgItem(hDlg, IDADVLOGOPT), FALSE);
|
|
|
|
if (advanced) {
|
|
|
|
EnableWindow(GetDlgItem(hDlg, IDDEVLIST), FALSE);
|
|
|
|
}
|
2005-10-08 03:28:43 +04:00
|
|
|
changed = TRUE;
|
|
|
|
SendMessage(GetParent(hDlg), PSM_CHANGED, (WPARAM)hDlg, 0);
|
2004-02-05 23:02:53 +03:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2004-02-01 04:40:14 +03:00
|
|
|
default:
|
|
|
|
switch (LOWORD(wParam)) {
|
2004-02-01 22:22:41 +03:00
|
|
|
case IDADVLOGOPT:
|
2004-02-05 23:02:53 +03:00
|
|
|
if (SendMessage(GetDlgItem(hDlg, IDADVLOGOPT), BM_GETCHECK, 0, 0) == BST_CHECKED) {
|
|
|
|
EnableWindow(GetDlgItem(hDlg, IDDEVLIST), TRUE);
|
|
|
|
SendMessage(GetDlgItem(hDlg, IDDEVLIST), LB_SETCURSEL, 0, 0);
|
|
|
|
RuntimeDlgSetAdvLogOpt(hDlg);
|
|
|
|
advanced = TRUE;
|
|
|
|
} else {
|
|
|
|
SendMessage(GetDlgItem(hDlg, IDDEVLIST), LB_SETCURSEL, (WPARAM)-1, 0);
|
|
|
|
RuntimeDlgSetStdLogOpt(hDlg);
|
|
|
|
advanced = FALSE;
|
|
|
|
}
|
2004-02-01 04:40:14 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2005-10-08 03:28:43 +04:00
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL CALLBACK RTMiscDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
static BOOL changed;
|
|
|
|
int value;
|
|
|
|
long noticode;
|
|
|
|
char buffer[32];
|
|
|
|
PSHNOTIFY *psn;
|
|
|
|
|
|
|
|
switch (msg) {
|
|
|
|
case WM_INITDIALOG:
|
2006-02-22 22:43:55 +03:00
|
|
|
SetDlgItemInt(hDlg, IDVGAUPDATE, SIM->get_param_num(BXPN_VGA_UPDATE_INTERVAL)->get(), FALSE);
|
|
|
|
SetDlgItemInt(hDlg, IDKBDPASTE, SIM->get_param_num(BXPN_KBD_PASTE_DELAY)->get(), FALSE);
|
|
|
|
if (SIM->get_param_num(BXPN_MOUSE_ENABLED)->get()) {
|
2005-10-08 03:28:43 +04:00
|
|
|
SendMessage(GetDlgItem(hDlg, IDMOUSE), BM_SETCHECK, BST_CHECKED, 0);
|
|
|
|
}
|
2006-02-22 22:43:55 +03:00
|
|
|
SetDlgItemText(hDlg, IDUSERBTN, SIM->get_param_string(BXPN_USER_SHORTCUT)->getptr());
|
2006-03-03 23:29:50 +03:00
|
|
|
SetDlgItemInt(hDlg, IDSB16TIMER, SIM->get_param_num(BXPN_SB16_DMATIMER)->get(), FALSE);
|
|
|
|
SetDlgItemInt(hDlg, IDSBLOGLEV, SIM->get_param_num(BXPN_SB16_LOGLEVEL)->get(), FALSE);
|
2005-10-08 03:28:43 +04:00
|
|
|
changed = FALSE;
|
|
|
|
return TRUE;
|
2004-02-01 04:40:14 +03:00
|
|
|
case WM_NOTIFY:
|
2005-10-08 03:28:43 +04:00
|
|
|
psn = (PSHNOTIFY *)lParam;
|
|
|
|
switch(psn->hdr.code) {
|
|
|
|
case PSN_APPLY:
|
|
|
|
if ((psn->lParam == FALSE) && changed) { // Apply pressed & change in this dialog
|
|
|
|
value = GetDlgItemInt(hDlg, IDVGAUPDATE, NULL, FALSE);
|
2006-02-22 22:43:55 +03:00
|
|
|
SIM->get_param_num(BXPN_VGA_UPDATE_INTERVAL)->set(value);
|
2005-10-08 03:28:43 +04:00
|
|
|
value = GetDlgItemInt(hDlg, IDKBDPASTE, NULL, FALSE);
|
2006-02-22 22:43:55 +03:00
|
|
|
SIM->get_param_num(BXPN_KBD_PASTE_DELAY)->set(value);
|
2005-10-08 03:28:43 +04:00
|
|
|
value = SendMessage(GetDlgItem(hDlg, IDMOUSE), BM_GETCHECK, 0, 0);
|
2006-02-22 22:43:55 +03:00
|
|
|
SIM->get_param_num(BXPN_MOUSE_ENABLED)->set(value==BST_CHECKED);
|
2005-10-08 03:28:43 +04:00
|
|
|
GetDlgItemText(hDlg, IDUSERBTN, buffer, sizeof(buffer));
|
2006-02-22 22:43:55 +03:00
|
|
|
SIM->get_param_string(BXPN_USER_SHORTCUT)->set(buffer);
|
2005-10-08 03:28:43 +04:00
|
|
|
value = GetDlgItemInt(hDlg, IDSB16TIMER, NULL, FALSE);
|
2006-03-03 23:29:50 +03:00
|
|
|
SIM->get_param_num(BXPN_SB16_DMATIMER)->set(value);
|
2005-10-08 03:28:43 +04:00
|
|
|
value = GetDlgItemInt(hDlg, IDSBLOGLEV, NULL, FALSE);
|
2006-03-03 23:29:50 +03:00
|
|
|
SIM->get_param_num(BXPN_SB16_LOGLEVEL)->set(value);
|
2005-10-08 03:28:43 +04:00
|
|
|
changed = FALSE;
|
|
|
|
}
|
|
|
|
return PSNRET_NOERROR;
|
|
|
|
case PSN_QUERYCANCEL:
|
|
|
|
retcode = BX_CI_RT_QUIT;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case WM_COMMAND:
|
|
|
|
noticode = HIWORD(wParam);
|
|
|
|
switch(noticode) {
|
|
|
|
case EN_CHANGE:
|
|
|
|
switch (LOWORD(wParam)) {
|
|
|
|
case IDVGAUPDATE:
|
|
|
|
case IDKBDPASTE:
|
|
|
|
case IDUSERBTN:
|
|
|
|
case IDSB16TIMER:
|
|
|
|
case IDSBLOGLEV:
|
|
|
|
changed = TRUE;
|
|
|
|
SendMessage(GetParent(hDlg), PSM_CHANGED, (WPARAM)hDlg, 0);
|
|
|
|
break;
|
2004-02-01 04:40:14 +03:00
|
|
|
}
|
|
|
|
break;
|
2005-10-08 03:28:43 +04:00
|
|
|
default:
|
|
|
|
switch (LOWORD(wParam)) {
|
|
|
|
case IDMOUSE:
|
|
|
|
changed = TRUE;
|
|
|
|
SendMessage(GetParent(hDlg), PSM_CHANGED, (WPARAM)hDlg, 0);
|
|
|
|
break;
|
|
|
|
}
|
2004-02-01 04:40:14 +03:00
|
|
|
}
|
|
|
|
break;
|
2003-07-16 01:02:05 +04:00
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2003-05-22 00:33:24 +04:00
|
|
|
void LogAskDialog(BxEvent *event)
|
|
|
|
{
|
|
|
|
event->retcode = DialogBoxParam(NULL, MAKEINTRESOURCE(ASK_DLG), GetBochsWindow(),
|
|
|
|
(DLGPROC)LogAskProc, (LPARAM)event);
|
|
|
|
}
|
|
|
|
|
2004-02-01 04:40:14 +03:00
|
|
|
int AskFilename(HWND hwnd, bx_param_filename_c *param, const char *ext)
|
2003-05-25 17:35:39 +04:00
|
|
|
{
|
|
|
|
OPENFILENAME ofn;
|
|
|
|
int ret;
|
2004-01-26 07:29:47 +03:00
|
|
|
DWORD errcode;
|
2003-05-25 17:35:39 +04:00
|
|
|
char filename[MAX_PATH];
|
2006-05-30 02:33:38 +04:00
|
|
|
const char *title;
|
2004-01-26 07:29:47 +03:00
|
|
|
char errtext[80];
|
2003-05-25 17:35:39 +04:00
|
|
|
|
|
|
|
param->get(filename, MAX_PATH);
|
2005-10-26 13:14:24 +04:00
|
|
|
// common file dialogs don't accept raw device names
|
|
|
|
if ((isalpha(filename[0])) && (filename[1] == ':') && (strlen(filename) == 2)) {
|
|
|
|
filename[0] = 0;
|
|
|
|
}
|
2003-08-31 21:12:20 +04:00
|
|
|
title = param->get_label();
|
|
|
|
if (!title) title = param->get_name();
|
2004-01-26 07:29:47 +03:00
|
|
|
memset(&ofn, 0, sizeof(OPENFILENAME));
|
2003-05-25 17:35:39 +04:00
|
|
|
ofn.lStructSize = sizeof(OPENFILENAME);
|
2003-09-01 21:47:57 +04:00
|
|
|
ofn.hwndOwner = hwnd;
|
2003-05-25 17:35:39 +04:00
|
|
|
ofn.lpstrFile = filename;
|
|
|
|
ofn.nMaxFile = MAX_PATH;
|
2004-02-04 22:54:58 +03:00
|
|
|
ofn.lpstrInitialDir = bx_startup_flags.initial_dir;
|
2003-07-16 01:02:05 +04:00
|
|
|
ofn.lpstrTitle = title;
|
2003-05-25 17:35:39 +04:00
|
|
|
ofn.Flags = OFN_EXPLORER | OFN_HIDEREADONLY;
|
2004-02-01 04:40:14 +03:00
|
|
|
ofn.lpstrDefExt = ext;
|
|
|
|
if (!lstrcmp(ext, "img")) {
|
|
|
|
ofn.lpstrFilter = "Floppy image files (*.img)\0*.img\0All files (*.*)\0*.*\0";
|
|
|
|
} else if (!lstrcmp(ext, "iso")) {
|
|
|
|
ofn.lpstrFilter = "CD-ROM image files (*.iso)\0*.iso\0All files (*.*)\0*.*\0";
|
|
|
|
} else if (!lstrcmp(ext, "txt")) {
|
2003-07-16 01:02:05 +04:00
|
|
|
ofn.lpstrFilter = "Text files (*.txt)\0*.txt\0All files (*.*)\0*.*\0";
|
2004-02-01 04:40:14 +03:00
|
|
|
} else {
|
|
|
|
ofn.lpstrFilter = "All files (*.*)\0*.*\0";
|
|
|
|
}
|
|
|
|
if (param->get_options()->get() & bx_param_filename_c::SAVE_FILE_DIALOG) {
|
2003-05-25 17:35:39 +04:00
|
|
|
ofn.Flags |= OFN_OVERWRITEPROMPT;
|
|
|
|
ret = GetSaveFileName(&ofn);
|
|
|
|
} else {
|
|
|
|
ofn.Flags |= OFN_FILEMUSTEXIST;
|
|
|
|
ret = GetOpenFileName(&ofn);
|
|
|
|
}
|
|
|
|
param->set(filename);
|
2004-01-26 07:29:47 +03:00
|
|
|
if (ret == 0) {
|
|
|
|
errcode = CommDlgExtendedError();
|
|
|
|
if (errcode == 0) {
|
|
|
|
ret = -1;
|
|
|
|
} else {
|
2004-02-02 21:34:24 +03:00
|
|
|
if (errcode == 0x3002) {
|
2004-02-04 01:40:33 +03:00
|
|
|
wsprintf(errtext, "CommDlgExtendedError: invalid filename");
|
2004-02-02 21:34:24 +03:00
|
|
|
} else {
|
|
|
|
wsprintf(errtext, "CommDlgExtendedError returns 0x%04x", errcode);
|
|
|
|
}
|
2004-01-26 07:29:47 +03:00
|
|
|
MessageBox(hwnd, errtext, "Error", MB_ICONERROR);
|
|
|
|
}
|
|
|
|
}
|
2003-05-25 17:35:39 +04:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2003-05-25 22:34:03 +04:00
|
|
|
int AskString(bx_param_string_c *param)
|
|
|
|
{
|
|
|
|
return DialogBoxParam(NULL, MAKEINTRESOURCE(STRING_DLG), GetBochsWindow(),
|
|
|
|
(DLGPROC)StringParamProc, (LPARAM)param);
|
|
|
|
}
|
|
|
|
|
2003-07-16 01:02:05 +04:00
|
|
|
int FloppyDialog(bx_param_filename_c *param)
|
|
|
|
{
|
|
|
|
return DialogBoxParam(NULL, MAKEINTRESOURCE(FLOPPY_DLG), GetBochsWindow(),
|
|
|
|
(DLGPROC)FloppyDlgProc, (LPARAM)param);
|
|
|
|
}
|
|
|
|
|
2004-02-01 04:40:14 +03:00
|
|
|
int Cdrom1Dialog()
|
|
|
|
{
|
|
|
|
return DialogBox(NULL, MAKEINTRESOURCE(CDROM1_DLG), GetBochsWindow(),
|
|
|
|
(DLGPROC)Cdrom1DlgProc);
|
|
|
|
}
|
|
|
|
|
|
|
|
int RuntimeOptionsDialog()
|
|
|
|
{
|
2005-11-30 21:06:24 +03:00
|
|
|
PROPSHEETPAGE psp[4];
|
2005-10-08 03:28:43 +04:00
|
|
|
PROPSHEETHEADER psh;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
memset(psp,0,sizeof(psp));
|
2005-11-30 21:06:24 +03:00
|
|
|
for (i = 0; i < 4; i++) {
|
2005-10-08 03:28:43 +04:00
|
|
|
psp[i].dwSize = sizeof(PROPSHEETPAGE);
|
|
|
|
psp[i].dwFlags = PSP_DEFAULT;
|
|
|
|
psp[i].hInstance = NULL;
|
|
|
|
}
|
|
|
|
psp[0].pszTemplate = MAKEINTRESOURCE(RT_CDROM_DLG);
|
2009-02-23 00:48:21 +03:00
|
|
|
psp[0].pfnDlgProc = (DLGPROC) RTCdromDlgProc;
|
2005-11-30 21:06:24 +03:00
|
|
|
psp[1].pszTemplate = MAKEINTRESOURCE(RT_USBDEV_DLG);
|
2009-02-23 00:48:21 +03:00
|
|
|
psp[1].pfnDlgProc = (DLGPROC) RTUSBdevDlgProc;
|
2005-11-30 21:06:24 +03:00
|
|
|
psp[2].pszTemplate = MAKEINTRESOURCE(RT_LOGOPT_DLG);
|
2009-02-23 00:48:21 +03:00
|
|
|
psp[2].pfnDlgProc = (DLGPROC) RTLogOptDlgProc;
|
2005-11-30 21:06:24 +03:00
|
|
|
psp[3].pszTemplate = MAKEINTRESOURCE(RT_MISC_DLG);
|
2009-02-23 00:48:21 +03:00
|
|
|
psp[3].pfnDlgProc = (DLGPROC) RTMiscDlgProc;
|
2005-10-08 03:28:43 +04:00
|
|
|
|
|
|
|
memset(&psh,0,sizeof(PROPSHEETHEADER));
|
|
|
|
psh.dwSize = sizeof(PROPSHEETHEADER);
|
|
|
|
psh.dwFlags = PSH_PROPSHEETPAGE;
|
|
|
|
psh.hwndParent = GetBochsWindow();
|
|
|
|
psh.hInstance = NULL;
|
|
|
|
psh.pszCaption = "Runtime Options";
|
2005-11-30 21:06:24 +03:00
|
|
|
psh.nPages = 4;
|
2005-10-08 03:28:43 +04:00
|
|
|
psh.ppsp = (LPCPROPSHEETPAGE)&psp;
|
|
|
|
|
|
|
|
PropertySheet(&psh);
|
|
|
|
PostMessage(GetBochsWindow(), WM_SETFOCUS, 0, 0);
|
|
|
|
return retcode;
|
2004-02-01 04:40:14 +03:00
|
|
|
}
|
|
|
|
|
2005-10-22 15:00:00 +04:00
|
|
|
BxEvent* win32_notify_callback(void *unused, BxEvent *event)
|
|
|
|
{
|
2006-12-17 21:14:59 +03:00
|
|
|
int opts;
|
2005-10-22 15:00:00 +04:00
|
|
|
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;
|
2009-01-12 22:15:35 +03:00
|
|
|
#if BX_DEBUGGER && BX_DEBUGGER_GUI
|
2006-11-12 13:07:18 +03:00
|
|
|
case BX_SYNC_EVT_GET_DBG_COMMAND:
|
|
|
|
{
|
2009-01-09 17:53:38 +03:00
|
|
|
// sim is at a "break" -- internal debugger is ready for a command
|
2006-11-17 19:50:39 +03:00
|
|
|
debug_cmd = new char[512];
|
|
|
|
debug_cmd_ready = FALSE;
|
2009-01-09 17:53:38 +03:00
|
|
|
HitBreak();
|
|
|
|
while (debug_cmd_ready == FALSE && bx_user_quit == 0)
|
|
|
|
{
|
|
|
|
if (vgaw_refresh != FALSE) // is the GUI frontend requesting a VGAW refresh?
|
2009-01-19 23:37:40 +03:00
|
|
|
SIM->refresh_vga();
|
2009-01-09 17:53:38 +03:00
|
|
|
vgaw_refresh = FALSE;
|
2006-11-17 19:50:39 +03:00
|
|
|
Sleep(10);
|
|
|
|
}
|
2009-01-09 17:53:38 +03:00
|
|
|
if (bx_user_quit != 0)
|
|
|
|
BX_EXIT(0);
|
2006-11-17 19:50:39 +03:00
|
|
|
event->u.debugcmd.command = debug_cmd;
|
2006-11-12 13:07:18 +03:00
|
|
|
event->retcode = 1;
|
|
|
|
return event;
|
|
|
|
}
|
|
|
|
case BX_ASYNC_EVT_DBG_MSG:
|
2009-02-08 21:52:06 +03:00
|
|
|
ParseIDText (event->u.logmsg.msg);
|
2006-11-12 13:07:18 +03:00
|
|
|
return event;
|
|
|
|
#endif
|
2005-10-22 15:00:00 +04:00
|
|
|
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) {
|
2006-08-30 00:10:27 +04:00
|
|
|
if (opts & sparam->SELECT_FOLDER_DLG) {
|
|
|
|
event->retcode = BrowseDir(sparam->get_label(), sparam->getptr());
|
|
|
|
} else if (param->get_parent() == NULL) {
|
2005-10-22 15:00:00 +04:00
|
|
|
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;
|
2006-06-01 00:12:43 +04:00
|
|
|
} 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;
|
2005-10-22 15:00:00 +04:00
|
|
|
}
|
|
|
|
case BX_SYNC_EVT_TICK: // called periodically by siminterface.
|
|
|
|
// 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);
|
|
|
|
}
|
|
|
|
|
2004-01-29 21:50:33 +03:00
|
|
|
#endif // BX_USE_TEXTCONFIG && defined(WIN32)
|