RetroArch/ui/drivers/ui_win32.c

135 lines
3.9 KiB
C
Raw Normal View History

2015-11-19 07:23:41 +01:00
/* RetroArch - A frontend for libretro.
2017-01-22 13:40:32 +01:00
* Copyright (C) 2015-2017 - Ali Bouhlel
* Copyright (C) 2011-2017 - Daniel De Matteis
* Copyright (C) 2016-2019 - Brad Parker
2015-11-19 07:23:41 +01:00
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdint.h>
#include <boolean.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#ifdef _MSC_VER
#pragma comment( lib, "comctl32" )
#endif
#define IDI_ICON 1
2015-11-19 07:37:22 +01:00
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0500 //_WIN32_WINNT_WIN2K
#endif
2016-11-29 14:26:33 -05:00
#include "../../gfx/common/win32_common.h"
2015-11-19 07:37:22 +01:00
#include <windows.h>
#include <commdlg.h>
#include <commctrl.h>
2015-11-19 07:37:22 +01:00
#include <retro_inline.h>
#include <retro_miscellaneous.h>
2015-11-19 07:23:41 +01:00
#include <file/file_path.h>
2019-08-20 23:01:01 +02:00
#include <encodings/utf.h>
2017-01-16 23:32:28 +01:00
#include <string/stdstring.h>
2016-12-16 22:30:39 -05:00
#include <compat/strl.h>
2015-11-19 07:23:41 +01:00
#include "../ui_companion_driver.h"
2016-06-20 02:46:25 +02:00
#include "../../msg_hash.h"
#include "../../driver.h"
2016-09-30 21:20:50 +02:00
#include "../../paths.h"
2017-05-11 09:11:46 +02:00
#include "../../retroarch.h"
2016-05-16 20:21:53 +02:00
#include "../../tasks/tasks_internal.h"
#include "../../frontend/drivers/platform_win32.h"
2016-06-07 16:33:55 +02:00
#include "ui_win32.h"
2015-11-19 07:23:41 +01:00
typedef struct ui_companion_win32
{
void *empty;
} ui_companion_win32_t;
2018-08-17 14:50:56 +02:00
#ifndef __WINRT__
2017-09-07 16:42:34 +02:00
bool win32_window_init(WNDCLASSEX *wndclass,
bool fullscreen, const char *class_name)
{
#if _WIN32_WINNT >= 0x0501
/* Use the language set in the config for the menubar... also changes the console language. */
2020-01-18 05:48:19 +01:00
SetThreadUILanguage(win32_get_langid_from_retro_lang((enum retro_language)*msg_hash_get_uint(MSG_HASH_USER_LANGUAGE)));
#endif
2017-09-07 16:42:34 +02:00
wndclass->cbSize = sizeof(WNDCLASSEX);
wndclass->style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
wndclass->hInstance = GetModuleHandle(NULL);
wndclass->hCursor = LoadCursor(NULL, IDC_ARROW);
2019-07-19 20:08:45 +02:00
wndclass->lpszClassName = (class_name != NULL) ? class_name : msg_hash_to_str(MSG_PROGRAM);
2017-09-07 16:42:34 +02:00
wndclass->hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_ICON));
wndclass->hIconSm = (HICON)LoadImage(GetModuleHandle(NULL),
MAKEINTRESOURCE(IDI_ICON), IMAGE_ICON, 16, 16, 0);
if (!fullscreen)
wndclass->hbrBackground = (HBRUSH)COLOR_WINDOW;
if (class_name != NULL)
wndclass->style |= CS_CLASSDC;
if (!RegisterClassEx(wndclass))
return false;
return true;
}
2018-08-17 14:50:56 +02:00
#endif
2017-09-07 16:42:34 +02:00
2015-11-19 07:23:41 +01:00
static void ui_companion_win32_deinit(void *data)
{
ui_companion_win32_t *handle = (ui_companion_win32_t*)data;
if (handle)
free(handle);
}
static void *ui_companion_win32_init(void)
{
2016-02-26 13:31:34 +01:00
ui_companion_win32_t *handle = (ui_companion_win32_t*)
calloc(1, sizeof(*handle));
2015-11-19 07:23:41 +01:00
if (!handle)
return NULL;
return handle;
}
2020-02-13 22:39:29 +01:00
static void ui_companion_win32_notify_content_loaded(void *data) { }
static void ui_companion_win32_toggle(void *data, bool force) { }
2016-02-26 13:31:34 +01:00
static void ui_companion_win32_event_command(
2020-02-13 22:39:29 +01:00
void *data, enum event_command cmd) { }
2015-11-19 07:23:41 +01:00
static void ui_companion_win32_notify_list_pushed(void *data,
2020-02-13 22:39:29 +01:00
file_list_t *list, file_list_t *menu_list) { }
2015-11-19 07:23:41 +01:00
2018-04-30 14:33:05 -04:00
ui_companion_driver_t ui_companion_win32 = {
2015-11-19 07:23:41 +01:00
ui_companion_win32_init,
ui_companion_win32_deinit,
ui_companion_win32_toggle,
ui_companion_win32_event_command,
ui_companion_win32_notify_content_loaded,
ui_companion_win32_notify_list_pushed,
NULL,
NULL,
NULL,
NULL,
NULL, /* log_msg */
NULL, /* is_active */
&ui_browser_window_win32,
&ui_msg_window_win32,
2016-06-04 04:24:54 +02:00
&ui_window_win32,
2016-06-07 17:03:34 +02:00
&ui_application_win32,
2015-11-19 07:23:41 +01:00
"win32",
};