Separated main code from UI and PLATform support code, plus other generally small fixes here and there.

This commit is contained in:
waltje
2017-10-10 03:07:29 -04:00
parent e88899bb3c
commit bd89e66b7b
47 changed files with 924 additions and 872 deletions

View File

@@ -1,11 +0,0 @@
extern uint8_t host_cdrom_drive_available[26];
extern uint8_t host_cdrom_drive_available_num;
extern void cdrom_init_host_drives(void);
extern void cdrom_close(uint8_t id);
extern void cdrom_eject(uint8_t id);
extern void cdrom_reload(uint8_t id);
extern void removable_disk_unload(uint8_t id);
extern void removable_disk_eject(uint8_t id);
extern void removable_disk_reload(uint8_t id);

View File

@@ -1,35 +0,0 @@
#ifndef __unix
extern void plat_msgbox_error(int i);
extern wchar_t *plat_get_string(int i);
//#ifndef IDS_2077
//#define IDS_2077 2077
//#endif
//#ifndef IDS_2078
//#define IDS_2078 2078
//#endif
//#ifndef IDS_2079
//#define IDS_2079 2079
//#endif
#ifndef IDS_2139
# define IDS_2139 2139 /* network/network.c */
#endif
#ifndef IDS_2171
#define IDS_2171 2171 /* sound/midi_fluidsynth.c */
#endif
//#ifndef IDS_2219
//#define IDS_2219 2219
//#endif
#endif
extern void plat_msgbox_fatal(char *string);
extern void get_executable_name(wchar_t *s, int size);
extern void set_window_title(wchar_t *s);
extern void startblit(void);
extern void endblit(void);

View File

@@ -8,7 +8,7 @@
*
* The Emulator's Windows core.
*
* Version: @(#)win.c 1.0.18 2017/10/08
* Version: @(#)win.c 1.0.19 2017/10/09
*
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
@@ -52,15 +52,14 @@
#include "../video/vid_ega.h"
#include "../sound/sound.h"
#include "../sound/snd_dbopl.h"
#include "../plat.h"
#include "../ui.h"
#include "plat_keyboard.h"
#include "plat_iodev.h"
#include "plat_mouse.h"
#include "plat_midi.h"
#include "plat_thread.h"
#include "plat_ticks.h"
#include "plat_ui.h"
#include "win.h"
#include "win_cdrom_ioctl.h"
#include "win_cgapal.h"
#include "win_ddraw.h"
#include "win_d3d.h"
@@ -165,16 +164,15 @@ LoadIconEx(PCTSTR pszIconName)
static void
win_menu_update(void)
{
#if 0
menu = LoadMenu(hThisInstance, TEXT("MainMenu"));
menuMain = LoadMenu(hinstance, L"MainMenu"));
smenu = LoadMenu(hThisInstance, TEXT("StatusBarMenu"));
initmenu();
menuSBAR = LoadMenu(hinstance, L"StatusBarMenu");
SetMenu(hwndMain, menu);
initmenu();
win_title_update = 1;
#endif
SetMenu(hwndMain, menu);
win_title_update = 1;
}
#endif
@@ -545,7 +543,7 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
if (video_fullscreen_first) {
video_fullscreen_first = 0;
msgbox_info(hwndMain, IDS_2074);
ui_msgbox(MBX_INFO, (wchar_t *)IDS_2074);
}
startblit();
@@ -693,7 +691,7 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
case IDM_CONFIG_LOAD:
pause = 1;
if (! file_dlg_st(hwnd, IDS_2160, "", 0)) {
if (msgbox_reset_yn(hwndMain) == IDYES) {
if (ui_msgbox(MBX_QUESTION, (wchar_t *)IDS_2051) == IDYES) {
config_write(config_file_default);
for (i = 0; i < FDD_NUM; i++)
{
@@ -747,7 +745,7 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
rom_load_bios(romset);
network_init();
ResetAllMenus();
StatusBarUpdatePanes();
ui_sb_update_panes();
pc_reset_hard_init();
}
}
@@ -1184,8 +1182,8 @@ WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpszArg, int nFunsterStil)
haccel = LoadAccelerators(hInst, ACCEL_NAME);
if (haccel == NULL) {
MessageBox(hwndMain,
win_get_string(IDS_2053),
win_get_string(IDS_2050),
plat_get_string(IDS_2053),
plat_get_string(IDS_2050),
MB_OK | MB_ICONERROR);
return(3);
}
@@ -1198,8 +1196,8 @@ WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpszArg, int nFunsterStil)
device.hwndTarget = hwnd;
if (! RegisterRawInputDevices(&device, 1, sizeof(device))) {
MessageBox(hwndMain,
win_get_string(IDS_2054),
win_get_string(IDS_2050),
plat_get_string(IDS_2054),
plat_get_string(IDS_2050),
MB_OK | MB_ICONERROR);
return(4);
}
@@ -1224,8 +1222,8 @@ WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpszArg, int nFunsterStil)
vid_api ^= 1;
if (! vid_apis[0][vid_api].init(hwndRender)) {
MessageBox(hwnd,
win_get_string(IDS_2095),
win_get_string(IDS_2050),
plat_get_string(IDS_2095),
plat_get_string(IDS_2050),
MB_OK | MB_ICONERROR);
return(5);
}
@@ -1254,8 +1252,8 @@ WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpszArg, int nFunsterStil)
if (! pc_init_modules()) {
/* Dang, no ROMs found at all! */
MessageBox(hwnd,
win_get_string(IDS_2056),
win_get_string(IDS_2050),
plat_get_string(IDS_2056),
plat_get_string(IDS_2050),
MB_OK | MB_ICONERROR);
return(6);
}
@@ -1360,6 +1358,23 @@ set_window_title(wchar_t *s)
}
int
dir_check_exist(wchar_t *path)
{
DWORD dwAttrib = GetFileAttributes(path);
return(((dwAttrib != INVALID_FILE_ATTRIBUTES &&
(dwAttrib & FILE_ATTRIBUTE_DIRECTORY))) ? 1 : 0);
}
int
dir_create(wchar_t *path)
{
return((int)CreateDirectory(path, NULL));
}
uint64_t
timer_read(void)
{
@@ -1418,8 +1433,8 @@ win_language_check(void)
}
LPTSTR
win_get_string(int i)
wchar_t *
plat_get_string(int i)
{
LPTSTR str;
@@ -1443,21 +1458,14 @@ win_get_string(int i)
str = lpRCstr6144[i-6144].str;
}
return(str);
}
LPTSTR
win_get_string_from_string(char *str)
{
return(win_get_string(atoi(str)));
return((wchar_t *)str);
}
wchar_t *
plat_get_string(int i)
plat_get_string_from_string(char *str)
{
return((wchar_t *)win_get_string(i));
return(plat_get_string(atoi(str)));
}

View File

@@ -6,13 +6,11 @@
*
* This file is part of the 86Box distribution.
*
* The Emulator's Windows core.
* This file should contain things only used by the platform
* support modules for Windows. Generic definitions for UI and
* platform go into ../plat*.h.
*
* NOTE This should be named 'plat.h' and then include any
* Windows-specific header files needed, to keep them
* out of the main code.
*
* Version: @(#)win.h 1.0.4 2017/10/07
* Version: @(#)win.h 1.0.4 2017/10/09
*
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
@@ -55,41 +53,29 @@
#define WM_SAVESETTINGS 0x8888
extern HINSTANCE hinstance;
extern HWND hwndMain;
extern HICON hIcon[512];
extern int pause;
extern int status_is_open;
extern int mousecapture;
extern LCID dwLanguage;
extern HINSTANCE hinstance;
extern HWND hwndMain;
extern HICON hIcon[512];
extern char openfilestring[260];
extern WCHAR wopenfilestring[260];
extern int pause;
#ifdef __cplusplus
extern "C" {
#endif
extern HICON LoadIconEx(PCTSTR pszIconName);
extern BOOL DirectoryExists(LPCTSTR szPath);
extern void leave_fullscreen(void);
extern void get_executable_name(wchar_t *s, int size);
extern void set_window_title(wchar_t *s);
extern void win_language_set(void);
extern void win_language_update(void);
extern void win_language_check(void);
extern LPTSTR win_get_string(int i);
extern LPTSTR win_get_string_from_string(char *str);
extern void startblit(void);
extern void endblit(void);
#ifdef EMU_DEVICE_H
extern void deviceconfig_open(HWND hwnd, device_t *device);
#endif
@@ -106,8 +92,7 @@ extern int hard_disk_was_added(void);
extern void get_registry_key_map(void);
extern void process_raw_input(LPARAM lParam, int infocus);
extern void cdrom_init_host_drives(void);
extern void cdrom_close(uint8_t id);
extern int fdd_type_to_icon(int type);
/* Functions in win_about.c: */
@@ -120,39 +105,11 @@ extern void StatusWindowCreate(HWND hwnd);
/* Functions in win_stbar.c: */
#define SB_ICON_WIDTH 24
#define SB_FLOPPY 0x00
#define SB_CDROM 0x10
#define SB_RDISK 0x20
#define SB_HDD 0x40
#define SB_NETWORK 0x50
#define SB_TEXT 0x60
extern HWND hwndSBAR;
extern void StatusBarCreate(HWND hwndParent, int idStatus, HINSTANCE hInst);
extern int fdd_type_to_icon(int type);
extern int StatusBarFindPart(int tag);
extern void StatusBarUpdatePanes(void);
extern void StatusBarUpdateTip(int meaning);
extern void StatusBarUpdateIcon(int tag, int val);
extern void StatusBarUpdateIconState(int tag, int active);
extern void StatusBarCheckMenuItem(int tag, int id, int chk);
extern void StatusBarEnableMenuItem(int tag, int id, int val);
extern void StatusBarSetTextW(wchar_t *wstr);
extern void StatusBarSetText(char *str);
/* Functions in win_dialog.c: */
extern int msgbox_reset(HWND hwndParent);
extern int msgbox_reset_yn(HWND hwndParent);
extern int msgbox_question(HWND hwndParent, int i);
extern void msgbox_info(HWND hwndParent, int i);
extern void msgbox_info_wstr(HWND hwndParent, WCHAR *wstr);
extern void msgbox_error(HWND hwndParent, int i);
extern void msgbox_error_wstr(HWND hwndParent, WCHAR *wstr);
extern void msgbox_fatal(HWND hwndParent, char *string);
extern void msgbox_critical(HWND hwndParent, int i);
extern int file_dlg_w(HWND hwnd, WCHAR *f, WCHAR *fn, int save);
extern int file_dlg(HWND hwnd, WCHAR *f, char *fn, int save);
extern int file_dlg_mb(HWND hwnd, char *f, char *fn, int save);

View File

@@ -8,7 +8,7 @@
*
* Handle the About dialog.
*
* Version: @(#)win_about.c 1.0.1 2017/10/07
* Version: @(#)win_about.c 1.0.2 2017/10/09
*
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
@@ -29,7 +29,6 @@
#include <stdlib.h>
#include <wchar.h>
#include "../86box.h"
#include "../ibm.h"
#include "win.h"

View File

@@ -8,7 +8,7 @@
*
* Handle the platform-side of CDROM drives.
*
* Version: @(#)win_cdrom.c 1.0.2 2017/10/07
* Version: @(#)win_cdrom.c 1.0.3 2017/10/09
*
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
@@ -34,9 +34,9 @@
#include "../disk/hdd.h"
#include "../scsi/scsi.h"
#include "../scsi/scsi_disk.h"
#include "plat_ui.h"
#include "../plat.h"
#include "../ui.h"
#include "win.h"
#include "win_cdrom_ioctl.h"
uint8_t host_cdrom_drive_available[26];
@@ -93,7 +93,7 @@ cdrom_eject(uint8_t id)
if ((cdrom_drives[id].host_drive >= 'A') &&
(cdrom_drives[id].host_drive <= 'Z')) {
StatusBarCheckMenuItem(SB_CDROM|id,
ui_sb_check_menu_item(SB_CDROM|id,
IDM_CDROM_HOST_DRIVE | id | ((cdrom_drives[id].host_drive - 'A') << 3), MF_UNCHECKED);
}
@@ -109,12 +109,12 @@ cdrom_eject(uint8_t id)
cdrom_insert(id);
}
StatusBarCheckMenuItem(SB_CDROM|id, IDM_CDROM_IMAGE | id, MF_UNCHECKED);
ui_sb_check_menu_item(SB_CDROM|id, IDM_CDROM_IMAGE | id, MF_UNCHECKED);
cdrom_drives[id].host_drive=0;
StatusBarCheckMenuItem(SB_CDROM|id, IDM_CDROM_EMPTY | id, MF_CHECKED);
StatusBarUpdateIconState(SB_CDROM|id, 1);
StatusBarEnableMenuItem(SB_CDROM|id, IDM_CDROM_RELOAD | id, MF_BYCOMMAND | MF_ENABLED);
StatusBarUpdateTip(SB_CDROM|id);
ui_sb_check_menu_item(SB_CDROM|id, IDM_CDROM_EMPTY | id, MF_CHECKED);
ui_sb_update_icon_state(SB_CDROM|id, 1);
ui_sb_enable_menu_item(SB_CDROM|id, IDM_CDROM_RELOAD | id, MF_BYCOMMAND | MF_ENABLED);
ui_sb_update_tip(SB_CDROM|id);
config_save();
}
@@ -140,15 +140,15 @@ cdrom_reload(uint8_t id)
cdrom_insert(id);
}
if (wcslen(cdrom_image[id].image_path) == 0) {
StatusBarCheckMenuItem(SB_CDROM|id, IDM_CDROM_EMPTY | id, MF_CHECKED);
ui_sb_check_menu_item(SB_CDROM|id, IDM_CDROM_EMPTY | id, MF_CHECKED);
cdrom_drives[id].host_drive = 0;
StatusBarCheckMenuItem(SB_CDROM|id, IDM_CDROM_IMAGE | id, MF_UNCHECKED);
StatusBarUpdateIconState(SB_CDROM|id, 1);
ui_sb_check_menu_item(SB_CDROM|id, IDM_CDROM_IMAGE | id, MF_UNCHECKED);
ui_sb_update_icon_state(SB_CDROM|id, 1);
} else {
StatusBarCheckMenuItem(SB_CDROM|id, IDM_CDROM_EMPTY | id, MF_UNCHECKED);
ui_sb_check_menu_item(SB_CDROM|id, IDM_CDROM_EMPTY | id, MF_UNCHECKED);
cdrom_drives[id].host_drive = 200;
StatusBarCheckMenuItem(SB_CDROM|id, IDM_CDROM_IMAGE | id, MF_CHECKED);
StatusBarUpdateIconState(SB_CDROM|id, 0);
ui_sb_check_menu_item(SB_CDROM|id, IDM_CDROM_IMAGE | id, MF_CHECKED);
ui_sb_update_icon_state(SB_CDROM|id, 0);
}
} else {
new_cdrom_drive = cdrom_drives[id].prev_host_drive;
@@ -157,14 +157,14 @@ cdrom_reload(uint8_t id)
/* Signal disc change to the emulated machine. */
cdrom_insert(id);
}
StatusBarCheckMenuItem(SB_CDROM|id, IDM_CDROM_EMPTY | id, MF_UNCHECKED);
ui_sb_check_menu_item(SB_CDROM|id, IDM_CDROM_EMPTY | id, MF_UNCHECKED);
cdrom_drives[id].host_drive = new_cdrom_drive;
StatusBarCheckMenuItem(SB_CDROM|id, IDM_CDROM_HOST_DRIVE | id | ((cdrom_drives[id].host_drive - 'A') << 3), MF_CHECKED);
StatusBarUpdateIconState(SB_CDROM|id, 0);
ui_sb_check_menu_item(SB_CDROM|id, IDM_CDROM_HOST_DRIVE | id | ((cdrom_drives[id].host_drive - 'A') << 3), MF_CHECKED);
ui_sb_update_icon_state(SB_CDROM|id, 0);
}
StatusBarEnableMenuItem(SB_CDROM|id, IDM_CDROM_RELOAD | id, MF_BYCOMMAND | MF_GRAYED);
StatusBarUpdateTip(SB_CDROM|id);
ui_sb_enable_menu_item(SB_CDROM|id, IDM_CDROM_RELOAD | id, MF_BYCOMMAND | MF_GRAYED);
ui_sb_update_tip(SB_CDROM|id);
config_save();
}
@@ -187,12 +187,12 @@ void
removable_disk_eject(uint8_t id)
{
removable_disk_unload(id);
StatusBarUpdateIconState(SB_RDISK|id, 1);
StatusBarEnableMenuItem(SB_RDISK|id, IDM_RDISK_EJECT | id, MF_BYCOMMAND | MF_GRAYED);
StatusBarEnableMenuItem(SB_RDISK|id, IDM_RDISK_RELOAD | id, MF_BYCOMMAND | MF_ENABLED);
StatusBarEnableMenuItem(SB_RDISK|id, IDM_RDISK_SEND_CHANGE | id, MF_BYCOMMAND | MF_GRAYED);
ui_sb_update_icon_state(SB_RDISK|id, 1);
ui_sb_enable_menu_item(SB_RDISK|id, IDM_RDISK_EJECT | id, MF_BYCOMMAND | MF_GRAYED);
ui_sb_enable_menu_item(SB_RDISK|id, IDM_RDISK_RELOAD | id, MF_BYCOMMAND | MF_ENABLED);
ui_sb_enable_menu_item(SB_RDISK|id, IDM_RDISK_SEND_CHANGE | id, MF_BYCOMMAND | MF_GRAYED);
StatusBarUpdateTip(SB_RDISK|id);
ui_sb_update_tip(SB_RDISK|id);
config_save();
}
@@ -211,13 +211,13 @@ removable_disk_reload(uint8_t id)
scsi_disk_insert(id);
#endif
StatusBarUpdateIconState(SB_RDISK|id, wcslen(hdd[id].fn) ? 0 : 1);
ui_sb_update_icon_state(SB_RDISK|id, wcslen(hdd[id].fn) ? 0 : 1);
StatusBarEnableMenuItem(SB_RDISK|id, IDM_RDISK_EJECT | id, MF_BYCOMMAND | (wcslen(hdd[id].fn) ? MF_ENABLED : MF_GRAYED));
StatusBarEnableMenuItem(SB_RDISK|id, IDM_RDISK_RELOAD | id, MF_BYCOMMAND | MF_GRAYED);
StatusBarEnableMenuItem(SB_RDISK|id, IDM_RDISK_SEND_CHANGE | id, MF_BYCOMMAND | (wcslen(hdd[id].fn) ? MF_ENABLED : MF_GRAYED));
ui_sb_enable_menu_item(SB_RDISK|id, IDM_RDISK_EJECT | id, MF_BYCOMMAND | (wcslen(hdd[id].fn) ? MF_ENABLED : MF_GRAYED));
ui_sb_enable_menu_item(SB_RDISK|id, IDM_RDISK_RELOAD | id, MF_BYCOMMAND | MF_GRAYED);
ui_sb_enable_menu_item(SB_RDISK|id, IDM_RDISK_SEND_CHANGE | id, MF_BYCOMMAND | (wcslen(hdd[id].fn) ? MF_ENABLED : MF_GRAYED));
StatusBarUpdateTip(SB_RDISK|id);
ui_sb_update_tip(SB_RDISK|id);
config_save();
}

View File

@@ -9,10 +9,11 @@
* Implementation of the CD-ROM host drive IOCTL interface for
* Windows using SCSI Passthrough Direct.
*
* Version: @(#)cdrom_ioctl.c 1.0.5 2017/10/04
* Version: @(#)cdrom_ioctl.c 1.0.6 2017/10/09
*
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
*
* Copyright 2008-2016 Sarah Walker.
* Copyright 2016,2017 Miran Grca.
*/
@@ -29,7 +30,7 @@
#include "../device.h"
#include "../scsi/scsi.h"
#include "../cdrom/cdrom.h"
#include "win_cdrom_ioctl.h"
#include "../plat.h"
#define MSFtoLBA(m,s,f) ((((m*60)+s)*75)+f)

View File

@@ -1,35 +0,0 @@
/*
* 86Box A hypervisor and IBM PC system emulator that specializes in
* running old operating systems and software designed for IBM
* PC systems and compatibles from 1981 through fairly recent
* system designs based on the PCI bus.
*
* This file is part of the 86Box distribution.
*
* Implementation of the CD-ROM host drive IOCTL interface for
* Windows using SCSI Passthrough Direct.
*
* This file lists the functions provided by various platform-
* specific cdrom-ioctl files.
*
* Version: @(#)cdrom_ioctl.h 1.0.3 2017/09/03
*
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
* Copyright 2008-2016 Sarah Walker.
* Copyright 2016,2017 Miran Grca.
*/
#ifndef EMU_CDROM_IOCTL_H
#define EMU_CDROM_IOCTL_H
extern uint32_t cdrom_capacity;
extern int ioctl_open(uint8_t id, char d);
extern void ioctl_reset(uint8_t id);
extern void ioctl_close(uint8_t id);
#endif /*EMU_CDROM_IOCTL_H */

View File

@@ -8,6 +8,8 @@
#include <windows.h>
#undef BITMAP
#include "../video/video.h"
#include "../plat.h"
#include "../ui.h"
#include "win_ddraw.h"
#include "win_cgapal.h"
#include "win.h"
@@ -106,8 +108,8 @@ SaveBitmap(wchar_t *szFilename, HBITMAP hBitmap)
if ((fp = _wfopen(szFilename, L"wb")) == NULL) {
_swprintf(szMessage,
win_get_string(IDS_2088), szFilename);
msgbox_error_wstr(hwndMain, szMessage);
plat_get_string(IDS_2088), szFilename);
ui_msgbox(MBX_ERROR, szMessage);
break;
}

View File

@@ -8,7 +8,7 @@
*
* Windows device configuration dialog implementation.
*
* Version: @(#)win_deviceconfig.c 1.0.4 2017/10/07
* Version: @(#)win_deviceconfig.c 1.0.5 2017/10/09
*
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
@@ -23,6 +23,8 @@
#include "../ibm.h"
#include "../config.h"
#include "../device.h"
#include "../plat.h"
#include "../ui.h"
#include "plat_midi.h"
#define NO_UNICODE /*FIXME: not Unicode? */
#include "win.h"
@@ -271,13 +273,13 @@ deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
return TRUE;
}
ret = msgbox_reset(hwndMain);
ret = ui_msgbox(MBX_QUESTION, (wchar_t *)IDS_2051);
switch(ret)
{
case IDNO:
case 1:
EndDialog(hdlg, 0);
return TRUE;
case IDCANCEL:
case -1:
return FALSE;
default:
break;

View File

@@ -8,7 +8,7 @@
*
* Several dialogs for the application.
*
* Version: @(#)win_dialog.c 1.0.1 2017/10/07
* Version: @(#)win_dialog.c 1.0.2 2017/10/09
*
* Author: Miran Grca, <mgrca8@gmail.com>
* Fred N. van Kempen, <decwiz@yahoo.com>
@@ -29,7 +29,8 @@
#include <wchar.h>
#include "../ibm.h"
#include "../device.h"
#include "plat_ui.h"
#include "../plat.h"
#include "../ui.h"
#include "win.h"
@@ -78,97 +79,80 @@ BrowseFolder(wchar_t *saved_path, wchar_t *title)
int
msgbox_reset(HWND hwnd)
ui_msgbox(int flags, void *arg)
{
return(MessageBox(hwnd, win_get_string(IDS_2051),
win_get_string(IDS_STRINGS),
MB_YESNOCANCEL | MB_ICONQUESTION));
WCHAR temp[512];
DWORD fl = 0;
WCHAR *str = NULL;
WCHAR *cap = NULL;
switch(flags & 0x1f) {
case MBX_INFO: /* just an informational message */
fl = (MB_OK | MB_ICONINFORMATION);
cap = plat_get_string(IDS_STRINGS); /* "86Box" */
break;
case MBX_ERROR: /* error message */
if (flags & MBX_FATAL) {
fl = (MB_OK | MB_ICONERROR);
cap = plat_get_string(IDS_2050); /* "Fatal Error"*/
} else {
fl = (MB_OK | MB_ICONWARNING);
cap = plat_get_string(IDS_2049); /* "Error" */
}
break;
case MBX_QUESTION: /* question */
fl = (MB_YESNOCANCEL | MB_ICONQUESTION);
cap = plat_get_string(IDS_STRINGS); /* "86Box" */
break;
}
/* If ANSI string, convert it. */
str = (WCHAR *)arg;
if (flags & MBX_ANSI) {
mbstowcs(temp, (char *)arg, strlen((char *)arg)+1);
str = temp;
} else {
/*
* It's a Unicode string.
*
* Well, no, maybe not. It could also be one of the
* strings stored in the Resources. Those are wide,
* but referenced by a numeric ID.
*
* The good news is, that strings are usually stored
* in the executable near the end of the code/rodata
* segment. This means, that *real* string pointers
* usually have a pretty high (numeric) value, much
* higher than the numeric ID's. So, we guesswork
* that if the value of 'arg' is low, its an ID..
*/
if (((int64_t)arg) < ((int64_t)65636))
str = plat_get_string((int)arg);
}
/* At any rate, we do have a valid (wide) string now. */
fl = MessageBox(hwndMain, /* our main window */
str, /* error message etc */
cap, /* window caption */
fl);
/* Convert return values to generic ones. */
if (fl == IDNO) fl = 1;
else if (fl == IDCANCEL) fl = -1;
else fl = 0;
return(fl);
}
#if 0
int
msgbox_reset_yn(HWND hwnd)
{
return(MessageBox(hwnd, win_get_string(IDS_2051),
win_get_string(IDS_STRINGS),
MB_YESNO | MB_ICONQUESTION));
}
int
msgbox_question(HWND hwnd, int i)
{
return(MessageBox(hwnd, win_get_string(i),
win_get_string(IDS_STRINGS),
MB_YESNO | MB_ICONQUESTION));
}
void
msgbox_info(HWND hwnd, int i)
{
MessageBox(hwnd, win_get_string(i), win_get_string(IDS_STRINGS),
MB_OK | MB_ICONINFORMATION);
}
void
msgbox_info_wstr(HWND hwnd, WCHAR *wstr)
{
MessageBox(hwnd, wstr, win_get_string(IDS_STRINGS),
MB_OK | MB_ICONINFORMATION);
}
void
msgbox_error(HWND hwnd, int i)
{
MessageBox(hwnd, win_get_string(i), win_get_string(IDS_2049),
MB_OK | MB_ICONWARNING);
}
void
plat_msgbox_error(int i)
{
msgbox_error(hwndMain, i);
}
void
msgbox_error_wstr(HWND hwnd, WCHAR *wstr)
{
MessageBox(hwnd, wstr, win_get_string(IDS_2049), MB_OK | MB_ICONWARNING);
}
void
msgbox_critical(HWND hwnd, int i)
{
MessageBox(hwnd, win_get_string(i), win_get_string(IDS_2050),
MB_OK | MB_ICONERROR);
}
void
msgbox_fatal(HWND hwnd, char *string)
{
LPTSTR temp;
temp = (LPTSTR)malloc(512);
mbstowcs(temp, string, strlen(string)+1);
MessageBox(hwnd, temp, win_get_string(IDS_2050), MB_OK | MB_ICONERROR);
free(temp);
}
void
plat_msgbox_fatal(char *string)
{
msgbox_fatal(hwndMain, string);
}
return(MessageBox(hwnd, plat_get_string(IDS_2051),
#endif
int
@@ -249,12 +233,12 @@ file_dlg_mb(HWND hwnd, char *f, char *fn, int save)
int
file_dlg_w_st(HWND hwnd, int id, WCHAR *fn, int save)
{
return(file_dlg_w(hwnd, win_get_string(id), fn, save));
return(file_dlg_w(hwnd, plat_get_string(id), fn, save));
}
int
file_dlg_st(HWND hwnd, int id, char *fn, int save)
{
return(file_dlg(hwnd, win_get_string(id), fn, save));
return(file_dlg(hwnd, plat_get_string(id), fn, save));
}

View File

@@ -8,7 +8,7 @@
*
* Windows 86Box Settings dialog handler.
*
* Version: @(#)win_settings.c 1.0.18 2017/10/07
* Version: @(#)win_settings.c 1.0.19 2017/10/09
*
* Author: Miran Grca, <mgrca8@gmail.com>
*
@@ -50,6 +50,8 @@
#include "../sound/snd_mpu401.h"
#include "../video/video.h"
#include "../video/vid_voodoo.h"
#include "../plat.h"
#include "../ui.h"
#include "plat_midi.h"
#include "win.h"
@@ -103,6 +105,25 @@ static int settings_scsi_to_list[20], settings_list_to_scsi[20];
static int settings_network_to_list[20], settings_list_to_network[20];
/* Show a MessageBox dialog. This is nasty, I know. --FvK */
static int
settings_msgbox(int type, void *arg)
{
HWND h;
int i;
h = hwndMain;
hwndMain = hwndParentDialog;
i = ui_msgbox(type, arg);
hwndMain = h;
return(i);
}
/* This does the initial read of global variables into the temporary ones. */
static void win_settings_init(void)
{
@@ -252,24 +273,15 @@ static int settings_msgbox_reset(void)
if (changed)
{
i = msgbox_reset(hwndParentDialog);
i = settings_msgbox(MBX_QUESTION, (wchar_t *)IDS_2051);
if (i == IDNO)
{
return 1;
}
else if (i == IDCANCEL)
{
return 0;
}
else
{
return 2;
}
}
else
{
return 1;
if (i == 1) return(1); /* no */
if (i < 0) return(0); /* cancel */
return(2); /* yes */
} else {
return(1);
}
}
@@ -348,7 +360,7 @@ static void win_settings_save(void)
mem_resize();
rom_load_bios(romset);
StatusBarUpdatePanes();
ui_sb_update_panes();
sound_realloc_buffers();
@@ -522,13 +534,13 @@ static void win_settings_machine_recalc_machine(HWND hdlg)
{
SendMessage(h, UDM_SETPOS, 0, temp_mem_size);
h = GetDlgItem(hdlg, IDC_TEXT_MB);
SendMessage(h, WM_SETTEXT, 0, (LPARAM) win_get_string(IDS_2094));
SendMessage(h, WM_SETTEXT, 0, (LPARAM) plat_get_string(IDS_2094));
}
else
{
SendMessage(h, UDM_SETPOS, 0, temp_mem_size / 1024);
h = GetDlgItem(hdlg, IDC_TEXT_MB);
SendMessage(h, WM_SETTEXT, 0, (LPARAM) win_get_string(IDS_2087));
SendMessage(h, WM_SETTEXT, 0, (LPARAM) plat_get_string(IDS_2087));
}
free(lptsTemp);
@@ -572,11 +584,11 @@ static BOOL CALLBACK win_settings_machine_proc(HWND hdlg, UINT message, WPARAM w
SendMessage(h, CB_SETCURSEL, machinetolist[temp_machine], 0);
h = GetDlgItem(hdlg, IDC_COMBO_WS);
SendMessage(h, CB_ADDSTRING, 0, (LPARAM) win_get_string(IDS_2131));
SendMessage(h, CB_ADDSTRING, 0, (LPARAM) plat_get_string(IDS_2131));
for (c = 0; c < 8; c++)
{
wsprintf(lptsTemp, win_get_string(2132), c);
wsprintf(lptsTemp, plat_get_string(2132), c);
SendMessage(h, CB_ADDSTRING, 0, (LPARAM) lptsTemp);
}
@@ -745,12 +757,12 @@ static BOOL CALLBACK win_settings_video_proc(HWND hdlg, UINT message, WPARAM wPa
recalc_vid_list(hdlg);
h = GetDlgItem(hdlg, IDC_COMBO_VIDEO_SPEED);
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)win_get_string(IDS_2133));
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)win_get_string(IDS_2134));
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)win_get_string(IDS_2135));
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)win_get_string(IDS_2136));
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)win_get_string(IDS_2137));
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)win_get_string(IDS_2138));
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)plat_get_string(IDS_2133));
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)plat_get_string(IDS_2134));
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)plat_get_string(IDS_2135));
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)plat_get_string(IDS_2136));
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)plat_get_string(IDS_2137));
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)plat_get_string(IDS_2138));
SendMessage(h, CB_SETCURSEL, temp_video_speed, 0);
h=GetDlgItem(hdlg, IDC_CHECK_VOODOO);
@@ -895,7 +907,7 @@ static BOOL CALLBACK win_settings_input_proc(HWND hdlg, UINT message, WPARAM wPa
{
str_id = IDS_3072 + c;
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)win_get_string(str_id));
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)plat_get_string(str_id));
settings_list_to_mouse[d] = c;
d++;
@@ -908,7 +920,7 @@ static BOOL CALLBACK win_settings_input_proc(HWND hdlg, UINT message, WPARAM wPa
c = 0;
while (joystick_get_name(c))
{
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)win_get_string(2144 + c));
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)plat_get_string(2144 + c));
c++;
}
EnableWindow(h, TRUE);
@@ -1061,7 +1073,7 @@ static BOOL CALLBACK win_settings_sound_proc(HWND hdlg, UINT message, WPARAM wPa
{
if (c == 0)
{
SendMessage(h, CB_ADDSTRING, 0, (LPARAM) win_get_string(IDS_2152));
SendMessage(h, CB_ADDSTRING, 0, (LPARAM) plat_get_string(IDS_2152));
}
else
{
@@ -1110,7 +1122,7 @@ static BOOL CALLBACK win_settings_sound_proc(HWND hdlg, UINT message, WPARAM wPa
{
if (c == 0)
{
SendMessage(h, CB_ADDSTRING, 0, (LPARAM) win_get_string(IDS_2152));
SendMessage(h, CB_ADDSTRING, 0, (LPARAM) plat_get_string(IDS_2152));
}
else
{
@@ -1295,7 +1307,7 @@ static BOOL CALLBACK win_settings_ports_proc(HWND hdlg, UINT message, WPARAM wPa
if (c == 0)
{
SendMessage(h, CB_ADDSTRING, 0, (LPARAM) win_get_string(IDS_2152));
SendMessage(h, CB_ADDSTRING, 0, (LPARAM) plat_get_string(IDS_2152));
}
else
{
@@ -1475,11 +1487,12 @@ static BOOL CALLBACK win_settings_peripherals_proc(HWND hdlg, UINT message, WPAR
{
scsi_dev = scsi_card_getdevice(c);
if (device_is_valid(scsi_dev, machines[temp_machine].flags))
{
if (c == 0)
{
SendMessage(h, CB_ADDSTRING, 0, (LPARAM) win_get_string(IDS_2152));
SendMessage(h, CB_ADDSTRING, 0, (LPARAM) plat_get_string(IDS_2152));
}
else
{
@@ -1510,11 +1523,11 @@ static BOOL CALLBACK win_settings_peripherals_proc(HWND hdlg, UINT message, WPAR
recalc_hdc_list(hdlg, temp_machine, 0);
h=GetDlgItem(hdlg, IDC_COMBO_IDE_TER);
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)win_get_string(IDS_5376));
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)plat_get_string(IDS_5376));
for (c = 0; c < 11; c++)
{
wsprintf(lptsTemp, win_get_string(IDS_2155), valid_ide_irqs[c]);
wsprintf(lptsTemp, plat_get_string(IDS_2155), valid_ide_irqs[c]);
SendMessage(h, CB_ADDSTRING, 0, (LPARAM) lptsTemp);
}
@@ -1528,11 +1541,11 @@ static BOOL CALLBACK win_settings_peripherals_proc(HWND hdlg, UINT message, WPAR
}
h=GetDlgItem(hdlg, IDC_COMBO_IDE_QUA);
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)win_get_string(IDS_5376));
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)plat_get_string(IDS_5376));
for (c = 0; c < 11; c++)
{
wsprintf(lptsTemp, win_get_string(IDS_2155), valid_ide_irqs[c]);
wsprintf(lptsTemp, plat_get_string(IDS_2155), valid_ide_irqs[c]);
SendMessage(h, CB_ADDSTRING, 0, (LPARAM) lptsTemp);
}
@@ -1727,7 +1740,7 @@ static BOOL CALLBACK win_settings_network_proc(HWND hdlg, UINT message, WPARAM w
{
if (c == 0)
{
SendMessage(h, CB_ADDSTRING, 0, (LPARAM) win_get_string(2152));
SendMessage(h, CB_ADDSTRING, 0, (LPARAM) plat_get_string(2152));
}
else
{
@@ -1907,34 +1920,34 @@ static void add_locations(HWND hdlg)
h = GetDlgItem(hdlg, IDC_COMBO_HD_BUS);
for (i = 0; i < 7; i++)
{
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)win_get_string(IDS_4352 + i));
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)plat_get_string(IDS_4352 + i));
}
h = GetDlgItem(hdlg, IDC_COMBO_HD_CHANNEL);
for (i = 0; i < 8; i++)
{
wsprintf(lptsTemp, win_get_string(IDS_4097), i >> 1, i & 1);
wsprintf(lptsTemp, plat_get_string(IDS_4097), i >> 1, i & 1);
SendMessage(h, CB_ADDSTRING, 0, (LPARAM) lptsTemp);
}
h = GetDlgItem(hdlg, IDC_COMBO_HD_ID);
for (i = 0; i < 16; i++)
{
wsprintf(lptsTemp, win_get_string(IDS_4098), i);
wsprintf(lptsTemp, plat_get_string(IDS_4098), i);
SendMessage(h, CB_ADDSTRING, 0, (LPARAM) lptsTemp);
}
h = GetDlgItem(hdlg, IDC_COMBO_HD_LUN);
for (i = 0; i < 8; i++)
{
wsprintf(lptsTemp, win_get_string(IDS_4098), i);
wsprintf(lptsTemp, plat_get_string(IDS_4098), i);
SendMessage(h, CB_ADDSTRING, 0, (LPARAM) lptsTemp);
}
h = GetDlgItem(hdlg, IDC_COMBO_HD_CHANNEL_IDE);
for (i = 0; i < 8; i++)
{
wsprintf(lptsTemp, win_get_string(IDS_4097), i >> 1, i & 1);
wsprintf(lptsTemp, plat_get_string(IDS_4097), i >> 1, i & 1);
SendMessage(h, CB_ADDSTRING, 0, (LPARAM) lptsTemp);
}
@@ -2176,25 +2189,25 @@ static void win_settings_hard_disks_update_item(HWND hwndList, int i, int column
switch(temp_hdd[i].bus)
{
case HDD_BUS_MFM:
wsprintf(szText, win_get_string(IDS_4608), temp_hdd[i].mfm_channel >> 1, temp_hdd[i].mfm_channel & 1);
wsprintf(szText, plat_get_string(IDS_4608), temp_hdd[i].mfm_channel >> 1, temp_hdd[i].mfm_channel & 1);
break;
case HDD_BUS_XTIDE:
wsprintf(szText, win_get_string(IDS_4609), temp_hdd[i].xtide_channel >> 1, temp_hdd[i].xtide_channel & 1);
wsprintf(szText, plat_get_string(IDS_4609), temp_hdd[i].xtide_channel >> 1, temp_hdd[i].xtide_channel & 1);
break;
case HDD_BUS_ESDI:
wsprintf(szText, win_get_string(IDS_4610), temp_hdd[i].esdi_channel >> 1, temp_hdd[i].esdi_channel & 1);
wsprintf(szText, plat_get_string(IDS_4610), temp_hdd[i].esdi_channel >> 1, temp_hdd[i].esdi_channel & 1);
break;
case HDD_BUS_IDE_PIO_ONLY:
wsprintf(szText, win_get_string(IDS_4611), temp_hdd[i].ide_channel >> 1, temp_hdd[i].ide_channel & 1);
wsprintf(szText, plat_get_string(IDS_4611), temp_hdd[i].ide_channel >> 1, temp_hdd[i].ide_channel & 1);
break;
case HDD_BUS_IDE_PIO_AND_DMA:
wsprintf(szText, win_get_string(IDS_4612), temp_hdd[i].ide_channel >> 1, temp_hdd[i].ide_channel & 1);
wsprintf(szText, plat_get_string(IDS_4612), temp_hdd[i].ide_channel >> 1, temp_hdd[i].ide_channel & 1);
break;
case HDD_BUS_SCSI:
wsprintf(szText, win_get_string(IDS_4613), temp_hdd[i].scsi_id, temp_hdd[i].scsi_lun);
wsprintf(szText, plat_get_string(IDS_4613), temp_hdd[i].scsi_id, temp_hdd[i].scsi_lun);
break;
case HDD_BUS_SCSI_REMOVABLE:
wsprintf(szText, win_get_string(IDS_4614), temp_hdd[i].scsi_id, temp_hdd[i].scsi_lun);
wsprintf(szText, plat_get_string(IDS_4614), temp_hdd[i].scsi_id, temp_hdd[i].scsi_lun);
break;
}
lvI.pszText = szText;
@@ -2207,25 +2220,25 @@ static void win_settings_hard_disks_update_item(HWND hwndList, int i, int column
}
else if (column == 2)
{
wsprintf(szText, win_get_string(IDS_4098), temp_hdd[i].tracks);
wsprintf(szText, plat_get_string(IDS_4098), temp_hdd[i].tracks);
lvI.pszText = szText;
lvI.iImage = 0;
}
else if (column == 3)
{
wsprintf(szText, win_get_string(IDS_4098), temp_hdd[i].hpc);
wsprintf(szText, plat_get_string(IDS_4098), temp_hdd[i].hpc);
lvI.pszText = szText;
lvI.iImage = 0;
}
else if (column == 4)
{
wsprintf(szText, win_get_string(IDS_4098), temp_hdd[i].spt);
wsprintf(szText, plat_get_string(IDS_4098), temp_hdd[i].spt);
lvI.pszText = szText;
lvI.iImage = 0;
}
else if (column == 5)
{
wsprintf(szText, win_get_string(IDS_4098), (temp_hdd[i].tracks * temp_hdd[i].hpc * temp_hdd[i].spt) >> 11);
wsprintf(szText, plat_get_string(IDS_4098), (temp_hdd[i].tracks * temp_hdd[i].hpc * temp_hdd[i].spt) >> 11);
lvI.pszText = szText;
lvI.iImage = 0;
}
@@ -2260,25 +2273,25 @@ static BOOL win_settings_hard_disks_recalc_list(HWND hwndList)
switch(temp_hdd[i].bus)
{
case HDD_BUS_MFM:
wsprintf(szText, win_get_string(IDS_4608), temp_hdd[i].mfm_channel >> 1, temp_hdd[i].mfm_channel & 1);
wsprintf(szText, plat_get_string(IDS_4608), temp_hdd[i].mfm_channel >> 1, temp_hdd[i].mfm_channel & 1);
break;
case HDD_BUS_XTIDE:
wsprintf(szText, win_get_string(IDS_4609), temp_hdd[i].xtide_channel >> 1, temp_hdd[i].xtide_channel & 1);
wsprintf(szText, plat_get_string(IDS_4609), temp_hdd[i].xtide_channel >> 1, temp_hdd[i].xtide_channel & 1);
break;
case HDD_BUS_ESDI:
wsprintf(szText, win_get_string(IDS_4610), temp_hdd[i].esdi_channel >> 1, temp_hdd[i].esdi_channel & 1);
wsprintf(szText, plat_get_string(IDS_4610), temp_hdd[i].esdi_channel >> 1, temp_hdd[i].esdi_channel & 1);
break;
case HDD_BUS_IDE_PIO_ONLY:
wsprintf(szText, win_get_string(IDS_4611), temp_hdd[i].ide_channel >> 1, temp_hdd[i].ide_channel & 1);
wsprintf(szText, plat_get_string(IDS_4611), temp_hdd[i].ide_channel >> 1, temp_hdd[i].ide_channel & 1);
break;
case HDD_BUS_IDE_PIO_AND_DMA:
wsprintf(szText, win_get_string(IDS_4612), temp_hdd[i].ide_channel >> 1, temp_hdd[i].ide_channel & 1);
wsprintf(szText, plat_get_string(IDS_4612), temp_hdd[i].ide_channel >> 1, temp_hdd[i].ide_channel & 1);
break;
case HDD_BUS_SCSI:
wsprintf(szText, win_get_string(IDS_4613), temp_hdd[i].scsi_id, temp_hdd[i].scsi_lun);
wsprintf(szText, plat_get_string(IDS_4613), temp_hdd[i].scsi_id, temp_hdd[i].scsi_lun);
break;
case HDD_BUS_SCSI_REMOVABLE:
wsprintf(szText, win_get_string(IDS_4614), temp_hdd[i].scsi_id, temp_hdd[i].scsi_lun);
wsprintf(szText, plat_get_string(IDS_4614), temp_hdd[i].scsi_id, temp_hdd[i].scsi_lun);
break;
}
lvI.pszText = szText;
@@ -2301,7 +2314,7 @@ static BOOL win_settings_hard_disks_recalc_list(HWND hwndList)
}
lvI.iSubItem = 2;
wsprintf(szText, win_get_string(IDS_4098), temp_hdd[i].tracks);
wsprintf(szText, plat_get_string(IDS_4098), temp_hdd[i].tracks);
lvI.pszText = szText;
lvI.iItem = j;
lvI.iImage = 0;
@@ -2312,7 +2325,7 @@ static BOOL win_settings_hard_disks_recalc_list(HWND hwndList)
}
lvI.iSubItem = 3;
wsprintf(szText, win_get_string(IDS_4098), temp_hdd[i].hpc);
wsprintf(szText, plat_get_string(IDS_4098), temp_hdd[i].hpc);
lvI.pszText = szText;
lvI.iItem = j;
lvI.iImage = 0;
@@ -2323,7 +2336,7 @@ static BOOL win_settings_hard_disks_recalc_list(HWND hwndList)
}
lvI.iSubItem = 4;
wsprintf(szText, win_get_string(IDS_4098), temp_hdd[i].spt);
wsprintf(szText, plat_get_string(IDS_4098), temp_hdd[i].spt);
lvI.pszText = szText;
lvI.iItem = j;
lvI.iImage = 0;
@@ -2334,7 +2347,7 @@ static BOOL win_settings_hard_disks_recalc_list(HWND hwndList)
}
lvI.iSubItem = 5;
wsprintf(szText, win_get_string(IDS_4098), (temp_hdd[i].tracks * temp_hdd[i].hpc * temp_hdd[i].spt) >> 11);
wsprintf(szText, plat_get_string(IDS_4098), (temp_hdd[i].tracks * temp_hdd[i].hpc * temp_hdd[i].spt) >> 11);
lvI.pszText = szText;
lvI.iItem = j;
lvI.iImage = 0;
@@ -2370,7 +2383,7 @@ static BOOL win_settings_hard_disks_init_columns(HWND hwndList)
for (iCol = 0; iCol < C_COLUMNS_HARD_DISKS; iCol++)
{
lvc.iSubItem = iCol;
lvc.pszText = win_get_string(2082 + iCol);
lvc.pszText = plat_get_string(2082 + iCol);
switch(iCol)
{
@@ -2433,7 +2446,7 @@ static void set_edit_box_contents(HWND hdlg, int id, uint64_t val)
WCHAR szText[256];
h = GetDlgItem(hdlg, id);
wsprintf(szText, win_get_string(IDS_2156), val);
wsprintf(szText, plat_get_string(IDS_2156), val);
SendMessage(h, WM_SETTEXT, (WPARAM) wcslen(szText), (LPARAM) szText);
}
@@ -2467,15 +2480,15 @@ static int hdconf_initialize_hdt_combo(HWND hdlg)
{
temp_size = hdd_table[i][0] * hdd_table[i][1] * hdd_table[i][2];
size_mb = temp_size >> 11;
wsprintf(szText, win_get_string(IDS_2157), size_mb, hdd_table[i][0], hdd_table[i][1], hdd_table[i][2]);
wsprintf(szText, plat_get_string(IDS_2157), size_mb, hdd_table[i][0], hdd_table[i][1], hdd_table[i][2]);
SendMessage(h, CB_ADDSTRING, 0, (LPARAM) szText);
if ((tracks == hdd_table[i][0]) && (hpc == hdd_table[i][1]) && (spt == hdd_table[i][2]))
{
selection = i;
}
}
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)win_get_string(IDS_4100));
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)win_get_string(IDS_4101));
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)plat_get_string(IDS_4100));
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)plat_get_string(IDS_4101));
SendMessage(h, CB_SETCURSEL, selection, 0);
return selection;
}
@@ -2533,7 +2546,7 @@ static BOOL CALLBACK win_settings_hard_disks_add_proc(HWND hdlg, UINT message, W
hdd_ptr = &(temp_hdd[next_free_id]);
}
SetWindowText(hdlg, win_get_string((existing & 1) ? IDS_4103 : IDS_4102));
SetWindowText(hdlg, plat_get_string((existing & 1) ? IDS_4103 : IDS_4102));
no_update = 1;
spt = (existing & 1) ? 0 : 17;
@@ -2634,7 +2647,7 @@ static BOOL CALLBACK win_settings_hard_disks_add_proc(HWND hdlg, UINT message, W
if ((wcslen(hd_file_name) == 0) && (hdd_ptr->bus != HDD_BUS_SCSI_REMOVABLE))
{
hdd_ptr->bus = HDD_BUS_DISABLED;
msgbox_error(hwndParentDialog, IDS_4112);
settings_msgbox(MBX_ERROR, (wchar_t *)IDS_4112);
return TRUE;
}
else if ((wcslen(hd_file_name) == 0) && (hdd_ptr->bus == HDD_BUS_SCSI_REMOVABLE))
@@ -2706,7 +2719,7 @@ static BOOL CALLBACK win_settings_hard_disks_add_proc(HWND hdlg, UINT message, W
if (size >= 0x100000000ll)
{
fclose(f);
msgbox_error(hwndParentDialog, IDS_4104);
settings_msgbox(MBX_ERROR, (wchar_t *)IDS_4104);
return TRUE;
}
@@ -2729,7 +2742,7 @@ static BOOL CALLBACK win_settings_hard_disks_add_proc(HWND hdlg, UINT message, W
if (size > 0xffffffffffffffffll)
{
fclose(f);
msgbox_error(hwndParentDialog, IDS_4105);
settings_msgbox(MBX_ERROR, (wchar_t *)IDS_4105);
return TRUE;
}
@@ -2769,7 +2782,7 @@ static BOOL CALLBACK win_settings_hard_disks_add_proc(HWND hdlg, UINT message, W
}
fclose(f);
msgbox_info(hwndParentDialog, IDS_4113);
settings_msgbox(MBX_INFO, (wchar_t *)IDS_4113);
}
hd_add_ok_common:
@@ -2787,7 +2800,7 @@ hd_add_ok_common:
return TRUE;
case IDC_CFILE:
if (!file_dlg_w(hdlg, win_get_string(IDS_4106), L"", !(existing & 1)))
if (!file_dlg_w(hdlg, plat_get_string(IDS_4106), L"", !(existing & 1)))
{
if (!(existing & 1))
{
@@ -2795,7 +2808,7 @@ hd_add_ok_common:
if (f != NULL)
{
fclose(f);
if (msgbox_question(hwndMain, IDS_4111) != IDYES)
if (settings_msgbox(MBX_QUESTION, (wchar_t *)IDS_4111) != 0) /* yes */
{
return FALSE;
}
@@ -2806,7 +2819,7 @@ hd_add_ok_common:
if (f == NULL)
{
hdd_add_file_open_error:
msgbox_error(hwndParentDialog, (existing & 1) ? IDS_4107 : IDS_4108);
settings_msgbox(MBX_ERROR, (existing & 1) ? (wchar_t *)IDS_4107 : (wchar_t *)IDS_4108);
return TRUE;
}
if (existing & 1)
@@ -2817,7 +2830,7 @@ hdd_add_file_open_error:
fread(&sector_size, 1, 4, f);
if (sector_size != 512)
{
msgbox_error(hwndParentDialog, IDS_4109);
settings_msgbox(MBX_ERROR, (wchar_t *)IDS_4109);
fclose(f);
return TRUE;
}
@@ -3523,7 +3536,7 @@ static BOOL win_settings_floppy_drives_recalc_list(HWND hwndList)
}
else
{
lvI.pszText = win_get_string(IDS_5376);
lvI.pszText = plat_get_string(IDS_5376);
}
lvI.iItem = i;
lvI.iImage = temp_fdd_types[i];
@@ -3532,7 +3545,7 @@ static BOOL win_settings_floppy_drives_recalc_list(HWND hwndList)
return FALSE;
lvI.iSubItem = 1;
lvI.pszText = win_get_string(temp_fdd_turbo[i] ? IDS_2060 : IDS_2061);
lvI.pszText = plat_get_string(temp_fdd_turbo[i] ? IDS_2060 : IDS_2061);
lvI.iItem = i;
lvI.iImage = 0;
@@ -3542,7 +3555,7 @@ static BOOL win_settings_floppy_drives_recalc_list(HWND hwndList)
}
lvI.iSubItem = 2;
lvI.pszText = win_get_string(temp_fdd_check_bpb[i] ? IDS_2060 : IDS_2061);
lvI.pszText = plat_get_string(temp_fdd_check_bpb[i] ? IDS_2060 : IDS_2061);
lvI.iItem = i;
lvI.iImage = 0;
@@ -3573,21 +3586,21 @@ static BOOL win_settings_cdrom_drives_recalc_list(HWND hwndList)
{
case CDROM_BUS_DISABLED:
default:
lvI.pszText = win_get_string(fsid);
lvI.pszText = plat_get_string(fsid);
lvI.iImage = 0;
break;
case CDROM_BUS_ATAPI_PIO_ONLY:
wsprintf(szText, win_get_string(fsid), temp_cdrom_drives[i].ide_channel >> 1, temp_cdrom_drives[i].ide_channel & 1);
wsprintf(szText, plat_get_string(fsid), temp_cdrom_drives[i].ide_channel >> 1, temp_cdrom_drives[i].ide_channel & 1);
lvI.pszText = szText;
lvI.iImage = 1;
break;
case CDROM_BUS_ATAPI_PIO_AND_DMA:
wsprintf(szText, win_get_string(fsid), temp_cdrom_drives[i].ide_channel >> 1, temp_cdrom_drives[i].ide_channel & 1);
wsprintf(szText, plat_get_string(fsid), temp_cdrom_drives[i].ide_channel >> 1, temp_cdrom_drives[i].ide_channel & 1);
lvI.pszText = szText;
lvI.iImage = 1;
break;
case CDROM_BUS_SCSI:
wsprintf(szText, win_get_string(fsid), temp_cdrom_drives[i].scsi_device_id, temp_cdrom_drives[i].scsi_device_lun);
wsprintf(szText, plat_get_string(fsid), temp_cdrom_drives[i].scsi_device_id, temp_cdrom_drives[i].scsi_device_lun);
lvI.pszText = szText;
lvI.iImage = 1;
break;
@@ -3609,7 +3622,7 @@ static BOOL win_settings_floppy_drives_init_columns(HWND hwndList)
lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
lvc.iSubItem = 0;
lvc.pszText = win_get_string(IDS_2143);
lvc.pszText = plat_get_string(IDS_2143);
lvc.cx = 292;
lvc.fmt = LVCFMT_LEFT;
@@ -3620,7 +3633,7 @@ static BOOL win_settings_floppy_drives_init_columns(HWND hwndList)
}
lvc.iSubItem = 1;
lvc.pszText = win_get_string(IDS_2059);
lvc.pszText = plat_get_string(IDS_2059);
lvc.cx = 50;
lvc.fmt = LVCFMT_LEFT;
@@ -3631,7 +3644,7 @@ static BOOL win_settings_floppy_drives_init_columns(HWND hwndList)
}
lvc.iSubItem = 2;
lvc.pszText = win_get_string(IDS_2170);
lvc.pszText = plat_get_string(IDS_2170);
lvc.cx = 75;
lvc.fmt = LVCFMT_LEFT;
@@ -3650,7 +3663,7 @@ static BOOL win_settings_cdrom_drives_init_columns(HWND hwndList)
lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
lvc.iSubItem = 0;
lvc.pszText = win_get_string(IDS_2082);
lvc.pszText = plat_get_string(IDS_2082);
lvc.cx = 392;
lvc.fmt = LVCFMT_LEFT;
@@ -3721,7 +3734,7 @@ static void win_settings_floppy_drives_update_item(HWND hwndList, int i)
}
else
{
lvI.pszText = win_get_string(IDS_5376);
lvI.pszText = plat_get_string(IDS_5376);
}
lvI.iImage = temp_fdd_types[i];
@@ -3731,7 +3744,7 @@ static void win_settings_floppy_drives_update_item(HWND hwndList, int i)
}
lvI.iSubItem = 1;
lvI.pszText = win_get_string(temp_fdd_turbo[i] ? IDS_2060 : IDS_2061);
lvI.pszText = plat_get_string(temp_fdd_turbo[i] ? IDS_2060 : IDS_2061);
lvI.iItem = i;
lvI.iImage = 0;
@@ -3741,7 +3754,7 @@ static void win_settings_floppy_drives_update_item(HWND hwndList, int i)
}
lvI.iSubItem = 2;
lvI.pszText = win_get_string(temp_fdd_check_bpb[i] ? IDS_2060 : IDS_2061);
lvI.pszText = plat_get_string(temp_fdd_check_bpb[i] ? IDS_2060 : IDS_2061);
lvI.iItem = i;
lvI.iImage = 0;
@@ -3769,21 +3782,21 @@ static void win_settings_cdrom_drives_update_item(HWND hwndList, int i)
{
case CDROM_BUS_DISABLED:
default:
lvI.pszText = win_get_string(fsid);
lvI.pszText = plat_get_string(fsid);
lvI.iImage = 0;
break;
case CDROM_BUS_ATAPI_PIO_ONLY:
wsprintf(szText, win_get_string(fsid), temp_cdrom_drives[i].ide_channel >> 1, temp_cdrom_drives[i].ide_channel & 1);
wsprintf(szText, plat_get_string(fsid), temp_cdrom_drives[i].ide_channel >> 1, temp_cdrom_drives[i].ide_channel & 1);
lvI.pszText = szText;
lvI.iImage = 1;
break;
case CDROM_BUS_ATAPI_PIO_AND_DMA:
wsprintf(szText, win_get_string(fsid), temp_cdrom_drives[i].ide_channel >> 1, temp_cdrom_drives[i].ide_channel & 1);
wsprintf(szText, plat_get_string(fsid), temp_cdrom_drives[i].ide_channel >> 1, temp_cdrom_drives[i].ide_channel & 1);
lvI.pszText = szText;
lvI.iImage = 1;
break;
case CDROM_BUS_SCSI:
wsprintf(szText, win_get_string(fsid), temp_cdrom_drives[i].scsi_device_id, temp_cdrom_drives[i].scsi_device_lun);
wsprintf(szText, plat_get_string(fsid), temp_cdrom_drives[i].scsi_device_id, temp_cdrom_drives[i].scsi_device_lun);
lvI.pszText = szText;
lvI.iImage = 1;
break;
@@ -3808,28 +3821,28 @@ static void cdrom_add_locations(HWND hdlg)
{
if ((i == CDROM_BUS_DISABLED) || (i >= CDROM_BUS_ATAPI_PIO_ONLY))
{
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)win_get_string(combo_id_to_string_id(i)));
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)plat_get_string(combo_id_to_string_id(i)));
}
}
h = GetDlgItem(hdlg, IDC_COMBO_CD_ID);
for (i = 0; i < 16; i++)
{
wsprintf(lptsTemp, win_get_string(IDS_4098), i);
wsprintf(lptsTemp, plat_get_string(IDS_4098), i);
SendMessage(h, CB_ADDSTRING, 0, (LPARAM) lptsTemp);
}
h = GetDlgItem(hdlg, IDC_COMBO_CD_LUN);
for (i = 0; i < 8; i++)
{
wsprintf(lptsTemp, win_get_string(IDS_4098), i);
wsprintf(lptsTemp, plat_get_string(IDS_4098), i);
SendMessage(h, CB_ADDSTRING, 0, (LPARAM) lptsTemp);
}
h = GetDlgItem(hdlg, IDC_COMBO_CD_CHANNEL_IDE);
for (i = 0; i < 8; i++)
{
wsprintf(lptsTemp, win_get_string(IDS_4097), i >> 1, i & 1);
wsprintf(lptsTemp, plat_get_string(IDS_4097), i >> 1, i & 1);
SendMessage(h, CB_ADDSTRING, 0, (LPARAM) lptsTemp);
}
@@ -3923,7 +3936,7 @@ static BOOL CALLBACK win_settings_removable_devices_proc(HWND hdlg, UINT message
{
if (i == 0)
{
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)win_get_string(IDS_5376));
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)plat_get_string(IDS_5376));
}
else
{
@@ -4274,7 +4287,7 @@ static BOOL win_settings_main_insert_categories(HWND hwndList)
for (i = 0; i < 9; i++)
{
lvI.pszText = win_get_string(IDS_2065+i);
lvI.pszText = plat_get_string(IDS_2065+i);
lvI.iItem = i;
lvI.iImage = i;

View File

@@ -8,7 +8,7 @@
*
* Implement the application's Status Bar.
*
* Version: @(#)win_stbar.c 1.0.2 2017/10/07
* Version: @(#)win_stbar.c 1.0.3 2017/10/09
*
* Authors: Miran Grca, <mgrca8@gmail.com>
* Fred N. van Kempen, <decwiz@yahoo.com>
@@ -45,16 +45,15 @@
#include "../network/network.h"
#include "../video/video.h"
#include "../sound/sound.h"
#include "plat_iodev.h"
#include "plat_ui.h"
#include "../plat.h"
#include "../ui.h"
#include "win.h"
#include "win_cdrom_ioctl.h"
HWND hwndSBAR;
static LONG_PTR OriginalStatusBarProcedure;
static LONG_PTR OriginalProcedure;
static HMENU *sb_menu_handles;
static HMENU menuSBAR;
static WCHAR **sbTips;
@@ -132,15 +131,15 @@ static void
StatusBarCreateFloppySubmenu(HMENU m, int id)
{
AppendMenu(m, MF_STRING, IDM_FLOPPY_IMAGE_NEW | id,
win_get_string(IDS_2161));
plat_get_string(IDS_2161));
AppendMenu(m, MF_SEPARATOR, 0, 0);
AppendMenu(m, MF_STRING, IDM_FLOPPY_IMAGE_EXISTING | id,
win_get_string(IDS_2162));
plat_get_string(IDS_2162));
AppendMenu(m, MF_STRING, IDM_FLOPPY_IMAGE_EXISTING_WP | id,
win_get_string(IDS_2163));
plat_get_string(IDS_2163));
AppendMenu(m, MF_SEPARATOR, 0, 0);
AppendMenu(m, MF_STRING, IDM_FLOPPY_EJECT | id,
win_get_string(IDS_2164));
plat_get_string(IDS_2164));
}
@@ -151,15 +150,15 @@ StatusBarCreateCdromSubmenu(HMENU m, int id)
int i;
AppendMenu(m, MF_STRING, IDM_CDROM_MUTE | id,
win_get_string(IDS_2165));
plat_get_string(IDS_2165));
AppendMenu(m, MF_SEPARATOR, 0, 0);
AppendMenu(m, MF_STRING, IDM_CDROM_EMPTY | id,
win_get_string(IDS_2166));
plat_get_string(IDS_2166));
AppendMenu(m, MF_STRING, IDM_CDROM_RELOAD | id,
win_get_string(IDS_2167));
plat_get_string(IDS_2167));
AppendMenu(m, MF_SEPARATOR, 0, 0);
AppendMenu(m, MF_STRING, IDM_CDROM_IMAGE | id,
win_get_string(IDS_2168));
plat_get_string(IDS_2168));
if (host_cdrom_drive_available_num == 0) {
if ((cdrom_drives[id].host_drive >= 'A') &&
@@ -206,23 +205,23 @@ static void
StatusBarCreateRemovableDiskSubmenu(HMENU m, int id)
{
AppendMenu(m, MF_STRING, IDM_RDISK_EJECT | id,
win_get_string(IDS_2166));
plat_get_string(IDS_2166));
AppendMenu(m, MF_STRING, IDM_RDISK_RELOAD | id,
win_get_string(IDS_2167));
plat_get_string(IDS_2167));
AppendMenu(m, MF_SEPARATOR, 0, 0);
AppendMenu(m, MF_STRING, IDM_RDISK_SEND_CHANGE | id,
win_get_string(IDS_2142));
plat_get_string(IDS_2142));
AppendMenu(m, MF_SEPARATOR, 0, 0);
AppendMenu(m, MF_STRING, IDM_RDISK_IMAGE | id,
win_get_string(IDS_2168));
plat_get_string(IDS_2168));
AppendMenu(m, MF_STRING, IDM_RDISK_IMAGE_WP | id,
win_get_string(IDS_2169));
plat_get_string(IDS_2169));
}
/* API */
int
StatusBarFindPart(int tag)
ui_sb_find_part(int tag)
{
int found = -1;
int i;
@@ -244,7 +243,7 @@ StatusBarFindPart(int tag)
/* API: update one of the icons after activity. */
void
StatusBarUpdateIcon(int tag, int active)
ui_sb_update_icon(int tag, int active)
{
int temp_flags = 0;
int found;
@@ -255,7 +254,7 @@ StatusBarUpdateIcon(int tag, int active)
temp_flags |= active;
found = StatusBarFindPart(tag);
found = ui_sb_find_part(tag);
if (found != -1) {
if (temp_flags != (sb_icon_flags[found] & 1)) {
sb_icon_flags[found] &= ~1;
@@ -273,7 +272,7 @@ StatusBarUpdateIcon(int tag, int active)
/* API: This is for the drive state indicator. */
void
StatusBarUpdateIconState(int tag, int state)
ui_sb_update_icon_state(int tag, int state)
{
int found = -1;
@@ -281,7 +280,7 @@ StatusBarUpdateIconState(int tag, int state)
return;
}
found = StatusBarFindPart(tag);
found = ui_sb_find_part(tag);
if (found != -1) {
sb_icon_flags[found] &= ~256;
sb_icon_flags[found] |= state ? 256 : 0;
@@ -306,10 +305,10 @@ StatusBarCreateFloppyTip(int part)
mbstowcs(wtext, fdd_getname(fdd_get_type(drive)),
strlen(fdd_getname(fdd_get_type(drive))) + 1);
if (wcslen(floppyfns[drive]) == 0) {
_swprintf(tempTip, win_get_string(IDS_2158),
drive+1, wtext, win_get_string(IDS_2057));
_swprintf(tempTip, plat_get_string(IDS_2158),
drive+1, wtext, plat_get_string(IDS_2057));
} else {
_swprintf(tempTip, win_get_string(IDS_2158),
_swprintf(tempTip, plat_get_string(IDS_2158),
drive+1, wtext, floppyfns[drive]);
}
@@ -317,7 +316,7 @@ StatusBarCreateFloppyTip(int part)
free(sbTips[part]);
sbTips[part] = NULL;
}
sbTips[part] = (WCHAR *) malloc((wcslen(tempTip) << 1) + 2);
sbTips[part] = (WCHAR *)malloc((wcslen(tempTip) << 1) + 2);
wcscpy(sbTips[part], tempTip);
}
@@ -333,19 +332,19 @@ StatusBarCreateCdromTip(int part)
int bus = cdrom_drives[drive].bus_type;
id = IDS_4352 + (bus - 1);
szText = (WCHAR *)win_get_string(id);
szText = plat_get_string(id);
if (cdrom_drives[drive].host_drive == 200) {
if (wcslen(cdrom_image[drive].image_path) == 0) {
_swprintf(tempTip, win_get_string(IDS_5120), drive + 1, szText, win_get_string(IDS_2057));
_swprintf(tempTip, plat_get_string(IDS_5120), drive+1, szText, plat_get_string(IDS_2057));
} else {
_swprintf(tempTip, win_get_string(IDS_5120), drive + 1, szText, cdrom_image[drive].image_path);
_swprintf(tempTip, plat_get_string(IDS_5120), drive+1, szText, cdrom_image[drive].image_path);
}
} else if ((cdrom_drives[drive].host_drive >= 'A') && (cdrom_drives[drive].host_drive <= 'Z')) {
_swprintf(wtext, win_get_string(IDS_2058), cdrom_drives[drive].host_drive & ~0x20);
_swprintf(tempTip, win_get_string(IDS_5120), drive + 1, szText, wtext);
_swprintf(wtext, plat_get_string(IDS_2058), cdrom_drives[drive].host_drive & ~0x20);
_swprintf(tempTip, plat_get_string(IDS_5120), drive+1, szText, wtext);
} else {
_swprintf(tempTip, win_get_string(IDS_5120), drive + 1, szText, win_get_string(IDS_2057));
_swprintf(tempTip, plat_get_string(IDS_5120), drive+1, szText, plat_get_string(IDS_2057));
}
if (sbTips[part] != NULL) {
@@ -364,9 +363,9 @@ StatusBarCreateRemovableDiskTip(int part)
int drive = sb_part_meanings[part] & 0x1f;
if (wcslen(hdd[drive].fn) == 0) {
_swprintf(tempTip, win_get_string(IDS_4115), drive, win_get_string(IDS_2057));
_swprintf(tempTip, plat_get_string(IDS_4115), drive, plat_get_string(IDS_2057));
} else {
_swprintf(tempTip, win_get_string(IDS_4115), drive, hdd[drive].fn);
_swprintf(tempTip, plat_get_string(IDS_4115), drive, hdd[drive].fn);
}
if (sbTips[part] != NULL) {
@@ -387,9 +386,9 @@ StatusBarCreateDiskTip(int part)
int bus = sb_part_meanings[part] & 0xf;
id = IDS_4352 + (bus - 1);
szText = (WCHAR *)win_get_string(id);
szText = plat_get_string(id);
_swprintf(tempTip, win_get_string(IDS_4096), szText);
_swprintf(tempTip, plat_get_string(IDS_4096), szText);
if (sbTips[part] != NULL)
free(sbTips[part]);
sbTips[part] = (WCHAR *)malloc((wcslen(tempTip) << 1) + 2);
@@ -402,7 +401,7 @@ StatusBarCreateNetworkTip(int part)
{
WCHAR tempTip[512];
_swprintf(tempTip, win_get_string(IDS_2069));
_swprintf(tempTip, plat_get_string(IDS_2069));
if (sbTips[part] != NULL)
free(sbTips[part]);
@@ -413,7 +412,7 @@ StatusBarCreateNetworkTip(int part)
/* API */
void
StatusBarUpdateTip(int meaning)
ui_sb_update_tip(int meaning)
{
int part = -1;
int i;
@@ -513,7 +512,7 @@ StatusBarCreatePopupMenu(int part)
/* API: update the status bar panes. */
void
StatusBarUpdatePanes(void)
ui_sb_update_panes(void)
{
int i, id, hdint;
int edge = 0;
@@ -556,8 +555,8 @@ StatusBarUpdatePanes(void)
StatusBarDestroyMenus();
StatusBarDestroyTips();
}
sb_parts = 0;
sb_parts = 0;
for (i=0; i<FDD_NUM; i++) {
if (fdd_get_type(i) != 0)
sb_parts++;
@@ -802,7 +801,7 @@ StatusBarPopupMenu(HWND hwnd, POINT pt, int id)
static LRESULT CALLBACK
StatusBarProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
WCHAR temp_image_path[1024];
WCHAR temp_path[1024];
RECT rc;
POINT pt;
int new_cdrom_drive;
@@ -822,7 +821,7 @@ StatusBarProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
case IDM_FLOPPY_IMAGE_EXISTING:
case IDM_FLOPPY_IMAGE_EXISTING_WP:
id = item_params & 0x0003;
part = StatusBarFindPart(SB_FLOPPY | id);
part = ui_sb_find_part(SB_FLOPPY | id);
if ((part == -1) || (sb_menu_handles == NULL))
break;
@@ -831,29 +830,29 @@ StatusBarProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
floppy_close(id);
ui_writeprot[id] = (item_id == IDM_FLOPPY_IMAGE_EXISTING_WP) ? 1 : 0;
floppy_load(id, wopenfilestring);
StatusBarUpdateIconState(SB_FLOPPY | id, wcslen(floppyfns[id]) ? 0 : 1);
ui_sb_update_icon_state(SB_FLOPPY | id, wcslen(floppyfns[id]) ? 0 : 1);
EnableMenuItem(sb_menu_handles[part], IDM_FLOPPY_EJECT | id, MF_BYCOMMAND | (wcslen(floppyfns[id]) ? MF_ENABLED : MF_GRAYED));
StatusBarUpdateTip(SB_FLOPPY | id);
ui_sb_update_tip(SB_FLOPPY | id);
config_save();
}
break;
case IDM_FLOPPY_EJECT:
id = item_params & 0x0003;
part = StatusBarFindPart(SB_FLOPPY | id);
part = ui_sb_find_part(SB_FLOPPY | id);
if ((part == -1) || (sb_menu_handles == NULL))
break;
floppy_close(id);
StatusBarUpdateIconState(SB_FLOPPY | id, 1);
ui_sb_update_icon_state(SB_FLOPPY | id, 1);
EnableMenuItem(sb_menu_handles[part], IDM_FLOPPY_EJECT | id, MF_BYCOMMAND | MF_GRAYED);
StatusBarUpdateTip(SB_FLOPPY | id);
ui_sb_update_tip(SB_FLOPPY | id);
config_save();
break;
case IDM_CDROM_MUTE:
id = item_params & 0x0007;
part = StatusBarFindPart(SB_CDROM | id);
part = ui_sb_find_part(SB_CDROM | id);
if ((part == -1) || (sb_menu_handles == NULL))
break;
@@ -875,21 +874,21 @@ StatusBarProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
case IDM_CDROM_IMAGE:
id = item_params & 0x0007;
part = StatusBarFindPart(SB_CDROM | id);
part = ui_sb_find_part(SB_CDROM | id);
if ((part == -1) || (sb_menu_handles == NULL))
break;
if (!file_dlg_w_st(hwnd, IDS_2075, cdrom_image[id].image_path, 0)) {
cdrom_drives[id].prev_host_drive = cdrom_drives[id].host_drive;
wcscpy(temp_image_path, wopenfilestring);
if ((wcscmp(cdrom_image[id].image_path, temp_image_path) == 0) && (cdrom_drives[id].host_drive == 200)) {
wcscpy(temp_path, wopenfilestring);
if ((wcscmp(cdrom_image[id].image_path, temp_path) == 0) && (cdrom_drives[id].host_drive == 200)) {
/* Switching from image to the same image. Do nothing. */
break;
}
wcscpy(cdrom_image[id].prev_image_path, cdrom_image[id].image_path);
cdrom_drives[id].handler->exit(id);
cdrom_close(id);
image_open(id, temp_image_path);
image_open(id, temp_path);
/* Signal media change to the emulated machine. */
cdrom_insert(id);
CheckMenuItem(sb_menu_handles[part], IDM_CDROM_EMPTY | id, MF_UNCHECKED);
@@ -899,14 +898,14 @@ StatusBarProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
cdrom_drives[id].host_drive = (wcslen(cdrom_image[id].image_path) == 0) ? 0 : 200;
if (cdrom_drives[id].host_drive == 200) {
CheckMenuItem(sb_menu_handles[part], IDM_CDROM_IMAGE | id, MF_CHECKED);
StatusBarUpdateIconState(SB_CDROM | id, 0);
ui_sb_update_icon_state(SB_CDROM | id, 0);
} else {
CheckMenuItem(sb_menu_handles[part], IDM_CDROM_IMAGE | id, MF_UNCHECKED);
CheckMenuItem(sb_menu_handles[part], IDM_CDROM_EMPTY | id, MF_UNCHECKED);
StatusBarUpdateIconState(SB_CDROM | id, 1);
ui_sb_update_icon_state(SB_CDROM | id, 1);
}
EnableMenuItem(sb_menu_handles[part], IDM_CDROM_RELOAD | id, MF_BYCOMMAND | MF_GRAYED);
StatusBarUpdateTip(SB_CDROM | id);
ui_sb_update_tip(SB_CDROM | id);
config_save();
}
break;
@@ -914,7 +913,7 @@ StatusBarProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
case IDM_CDROM_HOST_DRIVE:
id = item_params & 0x0007;
letter = ((item_params >> 3) & 0x001f) + 'A';
part = StatusBarFindPart(SB_CDROM | id);
part = ui_sb_find_part(SB_CDROM | id);
if ((part == -1) || (sb_menu_handles == NULL))
{
break;
@@ -941,8 +940,8 @@ StatusBarProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
cdrom_drives[id].host_drive = new_cdrom_drive;
CheckMenuItem(sb_menu_handles[part], IDM_CDROM_HOST_DRIVE | id | ((cdrom_drives[id].host_drive - 'A') << 3), MF_CHECKED);
EnableMenuItem(sb_menu_handles[part], IDM_CDROM_RELOAD | id, MF_BYCOMMAND | MF_GRAYED);
StatusBarUpdateIconState(SB_CDROM | id, 0);
StatusBarUpdateTip(SB_CDROM | id);
ui_sb_update_icon_state(SB_CDROM | id, 0);
ui_sb_update_tip(SB_CDROM | id);
config_save();
break;
@@ -973,18 +972,18 @@ StatusBarProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
scsi_loadhd(hdd[id].scsi_id, hdd[id].scsi_lun, id);
scsi_disk_insert(id);
if (wcslen(hdd[id].fn) > 0) {
StatusBarUpdateIconState(SB_RDISK | id, 0);
ui_sb_update_icon_state(SB_RDISK | id, 0);
EnableMenuItem(sb_menu_handles[part], IDM_RDISK_EJECT | id, MF_BYCOMMAND | MF_ENABLED);
EnableMenuItem(sb_menu_handles[part], IDM_RDISK_RELOAD | id, MF_BYCOMMAND | MF_GRAYED);
EnableMenuItem(sb_menu_handles[part], IDM_RDISK_SEND_CHANGE | id, MF_BYCOMMAND | MF_ENABLED);
}
else {
StatusBarUpdateIconState(SB_RDISK | id, 1);
ui_sb_update_icon_state(SB_RDISK | id, 1);
EnableMenuItem(sb_menu_handles[part], IDM_RDISK_EJECT | id, MF_BYCOMMAND | MF_GRAYED);
EnableMenuItem(sb_menu_handles[part], IDM_RDISK_RELOAD | id, MF_BYCOMMAND | MF_GRAYED);
EnableMenuItem(sb_menu_handles[part], IDM_RDISK_SEND_CHANGE | id, MF_BYCOMMAND | MF_GRAYED);
}
StatusBarUpdateTip(SB_RDISK | id);
ui_sb_update_tip(SB_RDISK | id);
config_save();
}
break;
@@ -1004,7 +1003,7 @@ StatusBarProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
break;
default:
return(CallWindowProc((WNDPROC)OriginalStatusBarProcedure,
return(CallWindowProc((WNDPROC)OriginalProcedure,
hwnd, message, wParam, lParam));
}
@@ -1058,7 +1057,7 @@ StatusBarCreate(HWND hwndParent, int idStatus, HINSTANCE hInst)
(HMENU)idStatus, hInst, NULL);
/* Replace the original procedure with ours. */
OriginalStatusBarProcedure = GetWindowLongPtr(hwndSBAR, GWLP_WNDPROC);
OriginalProcedure = GetWindowLongPtr(hwndSBAR, GWLP_WNDPROC);
SetWindowLongPtr(hwndSBAR, GWL_WNDPROC, (LONG_PTR)&StatusBarProcedure);
SendMessage(hwndSBAR, SB_SETMINHEIGHT, (WPARAM)17, (LPARAM)0);
@@ -1077,17 +1076,17 @@ StatusBarCreate(HWND hwndParent, int idStatus, HINSTANCE hInst)
/* Initialize the status bar and populate the icons and menus. */
sb_parts = 0;
StatusBarUpdatePanes();
ui_sb_update_panes();
}
/* API */
/* API (Settings) */
void
StatusBarCheckMenuItem(int tag, int id, int chk)
ui_sb_check_menu_item(int tag, int id, int chk)
{
int part;
part = StatusBarFindPart(tag);
part = ui_sb_find_part(tag);
if ((part == -1) || (sb_menu_handles == NULL))
return;
@@ -1095,13 +1094,13 @@ StatusBarCheckMenuItem(int tag, int id, int chk)
}
/* API */
/* API (Settings) */
void
StatusBarEnableMenuItem(int tag, int id, int flg)
ui_sb_enable_menu_item(int tag, int id, int flg)
{
int part;
part = StatusBarFindPart(tag);
part = ui_sb_find_part(tag);
if ((part == -1) || (sb_menu_handles == NULL))
return;
@@ -1111,12 +1110,11 @@ StatusBarEnableMenuItem(int tag, int id, int flg)
/* API */
void
StatusBarSetTextW(wchar_t *wstr)
ui_sb_set_text_w(wchar_t *wstr)
{
int part = -1;
int i;
pclog("SB_settext(%ws)", wstr);
if (!sb_ready || (sb_parts == 0) || (sb_part_meanings == NULL)) return;
for (i=0; i<sb_parts; i++) {
@@ -1124,22 +1122,20 @@ pclog("SB_settext(%ws)", wstr);
part = i;
}
}
pclog(" part=%d", part);
if (part != -1)
SendMessage(hwndSBAR, SB_SETTEXT, part | SBT_NOBORDERS, (LPARAM)wstr);
pclog(" done\n");
}
/* API */
void
StatusBarSetText(char *str)
ui_sb_set_text(char *str)
{
static wchar_t cwstr[512];
static wchar_t wstr[512];
memset(cwstr, 0, 1024);
mbstowcs(cwstr, str, strlen(str) + 1);
StatusBarSetTextW(cwstr);
memset(wstr, 0x00, 1024);
mbstowcs(wstr, str, strlen(str) + 1);
ui_sb_set_text_w(wstr);
}