diff --git a/src/include/86box/ui.h b/src/include/86box/ui.h index 6d6cafcd1..ce9635cf1 100644 --- a/src/include/86box/ui.h +++ b/src/include/86box/ui.h @@ -58,16 +58,12 @@ extern int ui_sb_find_part(int tag); extern void ui_sb_set_ready(int ready); extern void ui_sb_update_panes(void); extern void ui_sb_update_tip(int meaning); -extern void ui_sb_check_menu_item(int tag, int id, int chk); -extern void ui_sb_enable_menu_item(int tag, int id, int val); extern void ui_sb_timer_callback(int pane); extern void ui_sb_update_icon(int tag, int val); extern void ui_sb_update_icon_state(int tag, int active); extern void ui_sb_set_text_w(wchar_t *wstr); extern void ui_sb_set_text(char *str); extern void ui_sb_bugui(char *str); -extern void ui_sb_mount_floppy_img(uint8_t id, int part, uint8_t wp, wchar_t *file_name); -extern void ui_sb_mount_zip_img(uint8_t id, int part, uint8_t wp, wchar_t *file_name); #ifdef __cplusplus } diff --git a/src/win/win_stbar.c b/src/win/win_stbar.c index fd67edad2..4dbdb6f9b 100644 --- a/src/win/win_stbar.c +++ b/src/win/win_stbar.c @@ -62,8 +62,6 @@ int update_icons = 1; static LONG_PTR OriginalProcedure; -static HMENU *sb_menu_handles; -static HMENU menuSBAR; static WCHAR **sbTips; static int *iStatusWidths; static int *sb_part_meanings; @@ -72,10 +70,6 @@ static int sb_parts = 0; static int sb_ready = 0; static uint8_t sb_map[256]; -static HMENU hmenuMedia; -static HMENU *media_menu_handles; - - /* Also used by win_settings.c */ intptr_t fdd_type_to_icon(int type) @@ -120,107 +114,6 @@ hdd_count(int bus) } -static void -StatusBarCreateFloppySubmenu(HMENU m, int id) -{ - AppendMenu(m, MF_STRING, IDM_FLOPPY_IMAGE_NEW | id, - plat_get_string(IDS_2096)); - AppendMenu(m, MF_SEPARATOR, 0, 0); - AppendMenu(m, MF_STRING, IDM_FLOPPY_IMAGE_EXISTING | id, - plat_get_string(IDS_2097)); - AppendMenu(m, MF_STRING, IDM_FLOPPY_IMAGE_EXISTING_WP | id, - plat_get_string(IDS_2098)); - AppendMenu(m, MF_SEPARATOR, 0, 0); - AppendMenu(m, MF_STRING, IDM_FLOPPY_EXPORT_TO_86F | id, - plat_get_string(IDS_2080)); - AppendMenu(m, MF_SEPARATOR, 0, 0); - AppendMenu(m, MF_STRING, IDM_FLOPPY_EJECT | id, - plat_get_string(IDS_2093)); - - if (floppyfns[id][0] == 0x0000) { - EnableMenuItem(m, IDM_FLOPPY_EJECT | id, MF_BYCOMMAND | MF_GRAYED); - EnableMenuItem(m, IDM_FLOPPY_EXPORT_TO_86F | id, MF_BYCOMMAND | MF_GRAYED); - } -} - - -static void -StatusBarCreateCdromSubmenu(HMENU m, int id) -{ - AppendMenu(m, MF_STRING, IDM_CDROM_MUTE | id, - plat_get_string(IDS_2092)); - AppendMenu(m, MF_SEPARATOR, 0, 0); - AppendMenu(m, MF_STRING, IDM_CDROM_EMPTY | id, - plat_get_string(IDS_2091)); - AppendMenu(m, MF_STRING, IDM_CDROM_RELOAD | id, - plat_get_string(IDS_2090)); - AppendMenu(m, MF_SEPARATOR, 0, 0); - AppendMenu(m, MF_STRING, IDM_CDROM_IMAGE | id, - plat_get_string(IDS_2089)); - - if (! cdrom[id].sound_on) - CheckMenuItem(m, IDM_CDROM_MUTE | id, MF_CHECKED); - - if (cdrom[id].host_drive == 200) - CheckMenuItem(m, IDM_CDROM_IMAGE | id, MF_CHECKED); - else { - cdrom[id].host_drive = 0; - CheckMenuItem(m, IDM_CDROM_EMPTY | id, MF_CHECKED); - } -} - - -static void -StatusBarCreateZIPSubmenu(HMENU m, int id) -{ - AppendMenu(m, MF_STRING, IDM_ZIP_IMAGE_NEW | id, - plat_get_string(IDS_2096)); - AppendMenu(m, MF_SEPARATOR, 0, 0); - AppendMenu(m, MF_STRING, IDM_ZIP_IMAGE_EXISTING | id, - plat_get_string(IDS_2097)); - AppendMenu(m, MF_STRING, IDM_ZIP_IMAGE_EXISTING_WP | id, - plat_get_string(IDS_2098)); - AppendMenu(m, MF_SEPARATOR, 0, 0); - AppendMenu(m, MF_STRING, IDM_ZIP_EJECT | id, - plat_get_string(IDS_2093)); - AppendMenu(m, MF_STRING, IDM_ZIP_RELOAD | id, - plat_get_string(IDS_2090)); - - if (zip_drives[id].image_path[0] == 0x0000) { - EnableMenuItem(m, IDM_ZIP_EJECT | id, MF_BYCOMMAND | MF_GRAYED); - EnableMenuItem(m, IDM_ZIP_RELOAD | id, MF_BYCOMMAND | MF_ENABLED); - } else { - EnableMenuItem(m, IDM_ZIP_EJECT | id, MF_BYCOMMAND | MF_ENABLED); - EnableMenuItem(m, IDM_ZIP_RELOAD | id, MF_BYCOMMAND | MF_GRAYED); - } -} - -static void -StatusBarCreateMOSubmenu(HMENU m, int id) -{ - AppendMenu(m, MF_STRING, IDM_MO_IMAGE_NEW | id, - plat_get_string(IDS_2096)); - AppendMenu(m, MF_SEPARATOR, 0, 0); - AppendMenu(m, MF_STRING, IDM_MO_IMAGE_EXISTING | id, - plat_get_string(IDS_2097)); - AppendMenu(m, MF_STRING, IDM_MO_IMAGE_EXISTING_WP | id, - plat_get_string(IDS_2098)); - AppendMenu(m, MF_SEPARATOR, 0, 0); - AppendMenu(m, MF_STRING, IDM_MO_EJECT | id, - plat_get_string(IDS_2093)); - AppendMenu(m, MF_STRING, IDM_MO_RELOAD | id, - plat_get_string(IDS_2090)); - - if (mo_drives[id].image_path[0] == 0x0000) { - EnableMenuItem(m, IDM_MO_EJECT | id, MF_BYCOMMAND | MF_GRAYED); - EnableMenuItem(m, IDM_MO_RELOAD | id, MF_BYCOMMAND | MF_ENABLED); - } else { - EnableMenuItem(m, IDM_MO_EJECT | id, MF_BYCOMMAND | MF_ENABLED); - EnableMenuItem(m, IDM_MO_RELOAD | id, MF_BYCOMMAND | MF_GRAYED); - } -} - - void ui_sb_timer_callback(int pane) { @@ -486,54 +379,10 @@ ui_sb_update_tip(int meaning) } SendMessage(hwndSBAR, SB_SETTIPTEXT, part, (LPARAM)sbTips[part]); - ModifyMenu(hmenuMedia, part, MF_BYPOSITION, (UINT_PTR)media_menu_handles[part], sbTips[part]); } } -static void -MediaMenuDestroyMenus(void) -{ - int i; - - if (sb_parts == 0) return; - - if (! media_menu_handles) return; - - for (i=0; iexit) - cdrom[id].ops->exit(&(cdrom[id])); - cdrom[id].ops = NULL; - memset(cdrom[id].image_path, 0, sizeof(cdrom[id].image_path)); - cdrom_image_open(&(cdrom[id]), temp_path); - /* Signal media change to the emulated machine. */ - if (cdrom[id].insert) - cdrom[id].insert(cdrom[id].priv); - cdrom[id].host_drive = (wcslen(cdrom[id].image_path) == 0) ? 0 : 200; - if (cdrom[id].host_drive == 200) { - ui_sb_check_menu_item(SB_CDROM | id, IDM_CDROM_EMPTY | id, MF_UNCHECKED); - ui_sb_check_menu_item(SB_CDROM | id, IDM_CDROM_IMAGE | id, MF_CHECKED); - ui_sb_update_icon_state(SB_CDROM | id, 0); - } else { - ui_sb_check_menu_item(SB_CDROM | id, IDM_CDROM_IMAGE | id, MF_UNCHECKED); - 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_GRAYED); - ui_sb_update_tip(SB_CDROM | id); - config_save(); - } - break; - - case IDM_ZIP_IMAGE_NEW: - id = item_params & 0x0003; - part = sb_map[SB_ZIP | id]; - NewFloppyDialogCreate(hwnd, id | 0x80, part); /* NewZIPDialogCreate */ - break; - - case IDM_ZIP_IMAGE_EXISTING: - case IDM_ZIP_IMAGE_EXISTING_WP: - id = item_params & 0x0003; - part = sb_map[SB_ZIP | id]; - if ((part == 0xff) || (sb_menu_handles == NULL)) - break; - - ret = file_dlg_w_st(hwnd, IDS_2058, zip_drives[id].image_path, 0); - if (! ret) - ui_sb_mount_zip_img(id, part, (item_id == IDM_ZIP_IMAGE_EXISTING_WP) ? 1 : 0, wopenfilestring); - break; - - case IDM_ZIP_EJECT: - id = item_params & 0x0003; - zip_eject(id); - break; - - case IDM_ZIP_RELOAD: - id = item_params & 0x0003; - zip_reload(id); - break; - - case IDM_MO_IMAGE_NEW: - id = item_params & 0x0003; - part = sb_map[SB_MO | id]; - NewFloppyDialogCreate(hwnd, id | 0x80, part); /* NewZIPDialogCreate */ - break; - - case IDM_MO_IMAGE_EXISTING: - case IDM_MO_IMAGE_EXISTING_WP: - id = item_params & 0x0003; - part = sb_map[SB_MO | id]; - if ((part == 0xff) || (sb_menu_handles == NULL)) - break; - - ret = file_dlg_w_st(hwnd, IDS_2125, mo_drives[id].image_path, 0); - if (! ret) - ui_sb_mount_mo_img(id, part, (item_id == IDM_MO_IMAGE_EXISTING_WP) ? 1 : 0, wopenfilestring); - break; - - case IDM_MO_EJECT: - id = item_params & 0x0003; - mo_eject(id); - break; - - case IDM_MO_RELOAD: - id = item_params & 0x0003; - mo_reload(id); - break; - - default: - return(0); - } - - return(1); -} - - /* Handle messages for the Status Bar window. */ #if defined(__amd64__) || defined(__aarch64__) static LRESULT CALLBACK @@ -1237,27 +776,6 @@ StatusBarProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) } -void -MediaMenuCreate(HWND hwndParent, uintptr_t idStatus, HINSTANCE hInst) -{ - HMENU hmenu; - LPWSTR lpMenuName; - - hmenu = GetMenu(hwndParent); - hmenuMedia = CreatePopupMenu(); - - int len = GetMenuString(hmenu, IDM_MEDIA, NULL, 0, MF_BYCOMMAND); - lpMenuName = malloc((len + 1) * sizeof(WCHAR)); - GetMenuString(hmenu, IDM_MEDIA, lpMenuName, len + 1, MF_BYCOMMAND); - - InsertMenu(hmenu, IDM_MEDIA, MF_BYCOMMAND | MF_STRING | MF_POPUP, (UINT_PTR)hmenuMedia, lpMenuName); - RemoveMenu(hmenu, IDM_MEDIA, MF_BYCOMMAND); - DrawMenuBar(hwndParent); - - free(lpMenuName); -} - - /* API: Create and set up the Status Bar window. */ void StatusBarCreate(HWND hwndParent, uintptr_t idStatus, HINSTANCE hInst) @@ -1321,9 +839,6 @@ StatusBarCreate(HWND hwndParent, uintptr_t idStatus, HINSTANCE hInst) rectDialog.bottom-rectDialog.top, SWP_SHOWWINDOW); - /* Load the dummu menu for this window. */ - menuSBAR = LoadMenu(hInst, SB_MENU_NAME); - /* Initialize the status bar. This is clumsy. */ sb_parts = 1; iStatusWidths = (int *)malloc(sb_parts * sizeof(int)); @@ -1332,12 +847,8 @@ StatusBarCreate(HWND hwndParent, uintptr_t idStatus, HINSTANCE hInst) memset(sb_part_meanings, 0, sb_parts * sizeof(int)); sb_part_icons = (uint8_t *)malloc(sb_parts * sizeof(uint8_t)); memset(sb_part_icons, 0, sb_parts * sizeof(uint8_t)); - sb_menu_handles = (HMENU *)malloc(sb_parts * sizeof(HMENU)); - memset(sb_menu_handles, 0, sb_parts * sizeof(HMENU)); sbTips = (WCHAR **)malloc(sb_parts * sizeof(WCHAR *)); memset(sbTips, 0, sb_parts * sizeof(WCHAR *)); - media_menu_handles = (HMENU *)malloc(sb_parts * sizeof(HMENU)); - memset(media_menu_handles, 0, sb_parts * sizeof(HMENU)); sb_parts = 0; iStatusWidths[sb_parts] = -1; sb_part_meanings[sb_parts] = SB_TEXT; @@ -1347,48 +858,10 @@ StatusBarCreate(HWND hwndParent, uintptr_t idStatus, HINSTANCE hInst) SendMessage(hwndSBAR, SB_SETTEXT, 0 | SBT_NOBORDERS, (LPARAM)plat_get_string(IDS_2126)); - //MediaMenuCreate(hwndParent, idStatus, hInst); - sb_ready = 1; } -/* API (Settings) */ -void -ui_sb_check_menu_item(int tag, int id, int chk) -{ - uint8_t part; - - if (!sb_ready) - return; - - part = sb_map[tag]; - if ((part == 0xff) || (sb_menu_handles == NULL)) - return; - - CheckMenuItem(sb_menu_handles[part], id, chk); - CheckMenuItem(media_menu_handles[part], id, chk); -} - - -/* API (Settings) */ -void -ui_sb_enable_menu_item(int tag, int id, int flg) -{ - uint8_t part; - - if (!sb_ready) - return; - - part = sb_map[tag]; - if ((part == 0xff) || (sb_menu_handles == NULL)) - return; - - EnableMenuItem(sb_menu_handles[part], id, flg); - EnableMenuItem(media_menu_handles[part], id, flg); -} - - /* API */ void ui_sb_set_text_w(wchar_t *wstr)