Initial commit for changeable icon set
This commit is contained in:
@@ -107,6 +107,7 @@ extern HWND hwndMain,
|
|||||||
hwndRender;
|
hwndRender;
|
||||||
extern HANDLE ghMutex;
|
extern HANDLE ghMutex;
|
||||||
extern HICON hIcon[256];
|
extern HICON hIcon[256];
|
||||||
|
extern int dpi;
|
||||||
extern RECT oldclip;
|
extern RECT oldclip;
|
||||||
extern int sbar_height, user_resize;
|
extern int sbar_height, user_resize;
|
||||||
extern int acp_utf8;
|
extern int acp_utf8;
|
||||||
@@ -122,8 +123,6 @@ extern uint8_t filterindex;
|
|||||||
extern void ResizeWindowByClientArea(HWND hwnd, int width, int height);
|
extern void ResizeWindowByClientArea(HWND hwnd, int width, int height);
|
||||||
extern void InitCrashDump(void);
|
extern void InitCrashDump(void);
|
||||||
|
|
||||||
extern HICON LoadIconEx(PCTSTR pszIconName);
|
|
||||||
|
|
||||||
/* Emulator start/stop support functions. */
|
/* Emulator start/stop support functions. */
|
||||||
extern void do_start(void);
|
extern void do_start(void);
|
||||||
extern void do_stop(void);
|
extern void do_stop(void);
|
||||||
@@ -150,6 +149,10 @@ extern int win_get_system_metrics(int i, int dpi);
|
|||||||
|
|
||||||
extern LPARAM win_get_string(int id);
|
extern LPARAM win_get_string(int id);
|
||||||
|
|
||||||
|
extern void win_clear_icon_set();
|
||||||
|
extern void win_system_icon_set(HINSTANCE hInst);
|
||||||
|
extern void win_load_icon_set(HINSTANCE hInst);
|
||||||
|
|
||||||
extern intptr_t fdd_type_to_icon(int type);
|
extern intptr_t fdd_type_to_icon(int type);
|
||||||
|
|
||||||
#ifdef EMU_DEVICE_H
|
#ifdef EMU_DEVICE_H
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ enable_language(RC)
|
|||||||
add_library(plat OBJECT win.c win_dynld.c win_cdrom.c win_thread.c
|
add_library(plat OBJECT win.c win_dynld.c win_cdrom.c win_thread.c
|
||||||
win_keyboard.c win_crashdump.c win_midi.c win_mouse.c)
|
win_keyboard.c win_crashdump.c win_midi.c win_mouse.c)
|
||||||
|
|
||||||
add_library(ui OBJECT win_ui.c win_stbar.c win_sdl.c win_dialog.c win_about.c
|
add_library(ui OBJECT win_ui.c win_icon.c win_stbar.c win_sdl.c win_dialog.c win_about.c
|
||||||
win_settings.c win_devconf.c win_snd_gain.c win_specify_dim.c win_new_floppy.c
|
win_settings.c win_devconf.c win_snd_gain.c win_specify_dim.c win_new_floppy.c
|
||||||
win_jsconf.c win_media_menu.c win_lang.c 86Box.rc)
|
win_jsconf.c win_media_menu.c win_lang.c 86Box.rc)
|
||||||
|
|
||||||
|
|||||||
@@ -423,7 +423,7 @@ ifeq ($(WX), y)
|
|||||||
LIBS += $(WX_LIBS)
|
LIBS += $(WX_LIBS)
|
||||||
UIOBJ := wx_main.o wx_ui.o wx_stbar.o wx_render.o
|
UIOBJ := wx_main.o wx_ui.o wx_stbar.o wx_render.o
|
||||||
else
|
else
|
||||||
UIOBJ := win_ui.o win_stbar.o \
|
UIOBJ := win_ui.o win_icon.o win_stbar.o \
|
||||||
win_sdl.o \
|
win_sdl.o \
|
||||||
win_dialog.o win_about.o \
|
win_dialog.o win_about.o \
|
||||||
win_settings.o win_devconf.o win_snd_gain.o win_specify_dim.o win_lang.o \
|
win_settings.o win_devconf.o win_snd_gain.o win_specify_dim.o win_lang.o \
|
||||||
|
|||||||
149
src/win/win_icon.c
Normal file
149
src/win/win_icon.c
Normal file
@@ -0,0 +1,149 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* Implement the application's icon changing system.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* Authors: Laci bá'
|
||||||
|
*
|
||||||
|
* Copyright 2021 Laci bá'.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
#include <windowsx.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <wchar.h>
|
||||||
|
#include <86box/86box.h>
|
||||||
|
#include <86box/config.h>
|
||||||
|
#include <86box/plat.h>
|
||||||
|
#include <86box/ui.h>
|
||||||
|
#include <86box/win.h>
|
||||||
|
|
||||||
|
HICON hIcon[256]; /* icon data loaded from resources */
|
||||||
|
char icon_set[256] = "winbox"; /* name of the iconset to be used */
|
||||||
|
|
||||||
|
void win_clear_icon_set()
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < 256; i++)
|
||||||
|
if (hIcon[i] != 0)
|
||||||
|
{
|
||||||
|
DestroyIcon(hIcon[i]);
|
||||||
|
hIcon[i] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void win_system_icon_set(HINSTANCE hInst)
|
||||||
|
{
|
||||||
|
int i, x = win_get_system_metrics(SM_CXSMICON, dpi), y = win_get_system_metrics(SM_CYSMICON, dpi);
|
||||||
|
|
||||||
|
for (i = 0; i < 256; i++)
|
||||||
|
hIcon[i] = LoadImage(hInst, MAKEINTRESOURCE(i), IMAGE_ICON, x, y, LR_DEFAULTCOLOR);
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
int id;
|
||||||
|
char* filename;
|
||||||
|
} _ICON_DATA;
|
||||||
|
|
||||||
|
const _ICON_DATA icon_files[] =
|
||||||
|
{
|
||||||
|
{16, "floppy_525.ico"},
|
||||||
|
{17, "floppy_525_active.ico"},
|
||||||
|
{24, "floppy_35.ico"},
|
||||||
|
{25, "floppy_35_active.ico"},
|
||||||
|
{32, "cdrom.ico"},
|
||||||
|
{33, "cdrom_active.ico"},
|
||||||
|
{48, "zip.ico"},
|
||||||
|
{49, "zip_active.ico"},
|
||||||
|
{56, "mo.ico"},
|
||||||
|
{57, "mo_active.ico"},
|
||||||
|
{64, "cassette.ico"},
|
||||||
|
{65, "cassette_active.ico"},
|
||||||
|
{80, "hard_disk.ico"},
|
||||||
|
{81, "hard_disk_active.ico"},
|
||||||
|
{96, "network.ico"},
|
||||||
|
{97, "network_active.ico"},
|
||||||
|
{104, "cartridge.ico"},
|
||||||
|
{144, "floppy_525_empty.ico"},
|
||||||
|
{145, "floppy_525_empty_active.ico"},
|
||||||
|
{152, "floppy_35_empty.ico"},
|
||||||
|
{153, "floppy_35_empty_active.ico"},
|
||||||
|
{160, "cdrom_empty.ico"},
|
||||||
|
{161, "cdrom_empty_active.ico"},
|
||||||
|
{176, "zip_empty.ico"},
|
||||||
|
{177, "zip_empty_active.ico"},
|
||||||
|
{184, "mo_empty.ico"},
|
||||||
|
{185, "mo_empty_active.ico"},
|
||||||
|
{192, "cassette_empty.ico"},
|
||||||
|
{193, "cassette_empty_active.ico"},
|
||||||
|
{232, "cartridge_empty.ico"},
|
||||||
|
{240, "machine.ico"},
|
||||||
|
{241, "display.ico"},
|
||||||
|
{242, "input_devices.ico"},
|
||||||
|
{243, "sound.ico"},
|
||||||
|
{244, "ports.ico"},
|
||||||
|
{245, "other_peripherals.ico"},
|
||||||
|
{246, "floppy_and_cdrom_drives.ico"},
|
||||||
|
{247, "other_removable_devices.ico"},
|
||||||
|
{248, "floppy_disabled.ico"},
|
||||||
|
{249, "cdrom_disabled.ico"},
|
||||||
|
{250, "zip_disabled.ico"},
|
||||||
|
{251, "mo_disabled.ico"},
|
||||||
|
{252, "storage_controllers.ico"}
|
||||||
|
};
|
||||||
|
|
||||||
|
void win_load_icon_set(HINSTANCE hInst)
|
||||||
|
{
|
||||||
|
win_clear_icon_set();
|
||||||
|
win_system_icon_set(hInst);
|
||||||
|
|
||||||
|
if (strlen(icon_set) == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
char path_root[2048] = {0}, temp[2048] = {0};
|
||||||
|
wchar_t wtemp[2048] = {0};
|
||||||
|
|
||||||
|
char roms_root[1024] = {0};
|
||||||
|
if (rom_path[0])
|
||||||
|
strcpy(roms_root, rom_path);
|
||||||
|
else
|
||||||
|
plat_append_filename(roms_root, exe_path, "roms");
|
||||||
|
|
||||||
|
plat_append_filename(path_root, roms_root, "icons");
|
||||||
|
plat_path_slash(path_root);
|
||||||
|
strcat(path_root, icon_set);
|
||||||
|
plat_path_slash(path_root);
|
||||||
|
|
||||||
|
int i, count = sizeof(icon_files) / sizeof(_ICON_DATA),
|
||||||
|
x = win_get_system_metrics(SM_CXSMICON, dpi), y = win_get_system_metrics(SM_CYSMICON, dpi);
|
||||||
|
for (i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
plat_append_filename(temp, path_root, icon_files[i].filename);
|
||||||
|
mbstowcs(wtemp, temp, strlen(temp) + 1);
|
||||||
|
|
||||||
|
HICON ictemp;
|
||||||
|
ictemp = LoadImageW(NULL, (LPWSTR)wtemp, IMAGE_ICON, x, y, LR_LOADFROMFILE | LR_DEFAULTCOLOR);
|
||||||
|
if (ictemp)
|
||||||
|
{
|
||||||
|
HICON* helper = &hIcon[icon_files[i].id];
|
||||||
|
if (*helper)
|
||||||
|
DestroyIcon(*helper);
|
||||||
|
*helper = ictemp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t curr_lang = lang_id;
|
||||||
|
lang_id = 0;
|
||||||
|
set_language(curr_lang);
|
||||||
|
}
|
||||||
@@ -76,7 +76,6 @@
|
|||||||
|
|
||||||
|
|
||||||
static int first_cat = 0;
|
static int first_cat = 0;
|
||||||
static int dpi = 96;
|
|
||||||
|
|
||||||
/* Machine category */
|
/* Machine category */
|
||||||
static int temp_machine_type, temp_machine, temp_cpu, temp_wait_states, temp_fpu, temp_sync;
|
static int temp_machine_type, temp_machine, temp_cpu, temp_wait_states, temp_fpu, temp_sync;
|
||||||
@@ -265,13 +264,8 @@ image_list_init(HWND hdlg, int id, const uint8_t *icon_ids)
|
|||||||
if (icon_ids[i] == 0)
|
if (icon_ids[i] == 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#if defined(__amd64__) || defined(__aarch64__)
|
hiconItem = hIcon[icon_ids[i]];
|
||||||
hiconItem = LoadIcon(hinstance, (LPCWSTR) ((uint64_t) icon_ids[i]));
|
|
||||||
#else
|
|
||||||
hiconItem = LoadIcon(hinstance, (LPCWSTR) ((uint32_t) icon_ids[i]));
|
|
||||||
#endif
|
|
||||||
ImageList_AddIcon(hSmall, hiconItem);
|
ImageList_AddIcon(hSmall, hiconItem);
|
||||||
DestroyIcon(hiconItem);
|
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,7 +71,6 @@ static uint8_t *sb_part_icons;
|
|||||||
static int sb_parts = 0;
|
static int sb_parts = 0;
|
||||||
static int sb_ready = 0;
|
static int sb_ready = 0;
|
||||||
static uint8_t sb_map[256];
|
static uint8_t sb_map[256];
|
||||||
static int dpi = 96;
|
|
||||||
static int icon_width = 24;
|
static int icon_width = 24;
|
||||||
static wchar_t sb_text[512] = L"\0";
|
static wchar_t sb_text[512] = L"\0";
|
||||||
static wchar_t sb_bugtext[512] = L"\0";
|
static wchar_t sb_bugtext[512] = L"\0";
|
||||||
@@ -878,46 +877,7 @@ StatusBarPopupMenu(HWND hwnd, POINT pt, int id)
|
|||||||
/* API: Load status bar icons */
|
/* API: Load status bar icons */
|
||||||
void
|
void
|
||||||
StatusBarLoadIcon(HINSTANCE hInst) {
|
StatusBarLoadIcon(HINSTANCE hInst) {
|
||||||
int i;
|
win_load_icon_set(hInst);
|
||||||
int x = win_get_system_metrics(SM_CXSMICON, dpi);
|
|
||||||
|
|
||||||
for (i=0; i<256; i++) {
|
|
||||||
if (hIcon[i] != 0)
|
|
||||||
DestroyIcon(hIcon[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 16; i < 18; i++)
|
|
||||||
hIcon[i] = LoadImage(hInst, MAKEINTRESOURCE(i), IMAGE_ICON, x, x, LR_DEFAULTCOLOR);
|
|
||||||
for (i = 24; i < 26; i++)
|
|
||||||
hIcon[i] = LoadImage(hInst, MAKEINTRESOURCE(i), IMAGE_ICON, x, x, LR_DEFAULTCOLOR);
|
|
||||||
for (i = 32; i < 34; i++)
|
|
||||||
hIcon[i] = LoadImage(hInst, MAKEINTRESOURCE(i), IMAGE_ICON, x, x, LR_DEFAULTCOLOR);
|
|
||||||
for (i = 48; i < 50; i++)
|
|
||||||
hIcon[i] = LoadImage(hInst, MAKEINTRESOURCE(i), IMAGE_ICON, x, x, LR_DEFAULTCOLOR);
|
|
||||||
for (i = 56; i < 58; i++)
|
|
||||||
hIcon[i] = LoadImage(hInst, MAKEINTRESOURCE(i), IMAGE_ICON, x, x, LR_DEFAULTCOLOR);
|
|
||||||
for (i = 64; i < 66; i++)
|
|
||||||
hIcon[i] = LoadImage(hInst, MAKEINTRESOURCE(i), IMAGE_ICON, x, x, LR_DEFAULTCOLOR);
|
|
||||||
for (i = 80; i < 82; i++)
|
|
||||||
hIcon[i] = LoadImage(hInst, MAKEINTRESOURCE(i), IMAGE_ICON, x, x, LR_DEFAULTCOLOR);
|
|
||||||
for (i = 96; i < 98; i++)
|
|
||||||
hIcon[i] = LoadImage(hInst, MAKEINTRESOURCE(i), IMAGE_ICON, x, x, LR_DEFAULTCOLOR);
|
|
||||||
hIcon[104] = LoadImage(hInst, MAKEINTRESOURCE(104), IMAGE_ICON, x, x, LR_DEFAULTCOLOR);
|
|
||||||
for (i = 144; i < 146; i++)
|
|
||||||
hIcon[i] = LoadImage(hInst, MAKEINTRESOURCE(i), IMAGE_ICON, x, x, LR_DEFAULTCOLOR);
|
|
||||||
for (i = 152; i < 154; i++)
|
|
||||||
hIcon[i] = LoadImage(hInst, MAKEINTRESOURCE(i), IMAGE_ICON, x, x, LR_DEFAULTCOLOR);
|
|
||||||
for (i = 160; i < 162; i++)
|
|
||||||
hIcon[i] = LoadImage(hInst, MAKEINTRESOURCE(i), IMAGE_ICON, x, x, LR_DEFAULTCOLOR);
|
|
||||||
for (i = 176; i < 178; i++)
|
|
||||||
hIcon[i] = LoadImage(hInst, MAKEINTRESOURCE(i), IMAGE_ICON, x, x, LR_DEFAULTCOLOR);
|
|
||||||
for (i = 184; i < 186; i++)
|
|
||||||
hIcon[i] = LoadImage(hInst, MAKEINTRESOURCE(i), IMAGE_ICON, x, x, LR_DEFAULTCOLOR);
|
|
||||||
for (i = 192; i < 194; i++)
|
|
||||||
hIcon[i] = LoadImage(hInst, MAKEINTRESOURCE(i), IMAGE_ICON, x, x, LR_DEFAULTCOLOR);
|
|
||||||
hIcon[232] = LoadImage(hInst, MAKEINTRESOURCE(232), IMAGE_ICON, x, x, LR_DEFAULTCOLOR);
|
|
||||||
for (i = 243; i < 244; i++)
|
|
||||||
hIcon[i] = LoadImage(hInst, MAKEINTRESOURCE(i), IMAGE_ICON, x, x, LR_DEFAULTCOLOR);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Handle messages for the Status Bar window. */
|
/* Handle messages for the Status Bar window. */
|
||||||
|
|||||||
@@ -59,7 +59,6 @@
|
|||||||
HWND hwndMain, /* application main window */
|
HWND hwndMain, /* application main window */
|
||||||
hwndRender; /* machine render window */
|
hwndRender; /* machine render window */
|
||||||
HMENU menuMain; /* application main menu */
|
HMENU menuMain; /* application main menu */
|
||||||
HICON hIcon[256]; /* icon data loaded from resources */
|
|
||||||
RECT oldclip; /* mouse rect */
|
RECT oldclip; /* mouse rect */
|
||||||
int sbar_height = 23; /* statusbar height */
|
int sbar_height = 23; /* statusbar height */
|
||||||
int minimized = 0;
|
int minimized = 0;
|
||||||
@@ -78,7 +77,7 @@ extern WCHAR wopenfilestring[512];
|
|||||||
static wchar_t wTitle[512];
|
static wchar_t wTitle[512];
|
||||||
static int manager_wm = 0;
|
static int manager_wm = 0;
|
||||||
static int save_window_pos = 0, pause_state = 0;
|
static int save_window_pos = 0, pause_state = 0;
|
||||||
static int dpi = 96;
|
int dpi = 96;
|
||||||
static int padded_frame = 0;
|
static int padded_frame = 0;
|
||||||
static int vis = -1;
|
static int vis = -1;
|
||||||
|
|
||||||
@@ -153,15 +152,6 @@ show_cursor(int val)
|
|||||||
vis = val;
|
vis = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
HICON
|
|
||||||
LoadIconEx(PCTSTR pszIconName)
|
|
||||||
{
|
|
||||||
return((HICON)LoadImage(hinstance, pszIconName, IMAGE_ICON,
|
|
||||||
16, 16, LR_SHARED));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
video_toggle_option(HMENU h, int *val, int id)
|
video_toggle_option(HMENU h, int *val, int id)
|
||||||
{
|
{
|
||||||
@@ -1074,6 +1064,7 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_DESTROY:
|
case WM_DESTROY:
|
||||||
|
win_clear_icon_set();
|
||||||
KillTimer(hwnd, TIMER_1SEC);
|
KillTimer(hwnd, TIMER_1SEC);
|
||||||
PostQuitMessage(0);
|
PostQuitMessage(0);
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user