RetroArch/ui/drivers/win32/ui_win32_window.c

107 lines
2.8 KiB
C
Raw Normal View History

2016-06-04 04:24:54 +02: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
2016-06-04 04:24:54 +02: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>
#include <windows.h>
2016-06-04 04:24:54 +02:00
#ifdef _MSC_VER
#pragma comment( lib, "comctl32" )
#endif
#define IDI_ICON 1
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0500 //_WIN32_WINNT_WIN2K
#endif
#ifndef _WIN32_IE
#define _WIN32_IE 0x0300
#endif
#include <windows.h>
#include <commdlg.h>
#include <commctrl.h>
#include <retro_inline.h>
#include <file/file_path.h>
2016-06-07 16:33:55 +02:00
#include "../ui_win32.h"
2016-06-04 04:39:41 +02:00
2016-06-04 04:24:54 +02:00
#include "../../ui_companion_driver.h"
#include "../../../driver.h"
2017-05-11 09:11:46 +02:00
#include "../../../retroarch.h"
2016-06-04 04:24:54 +02:00
#include "../../../tasks/tasks_internal.h"
2018-04-30 14:33:05 -04:00
static void* ui_window_win32_init(void)
{
return NULL;
}
2016-06-06 08:01:26 +02:00
static void ui_window_win32_destroy(void *data)
2016-06-04 04:36:07 +02:00
{
ui_window_win32_t *window = (ui_window_win32_t*)data;
2016-06-04 04:39:41 +02:00
DestroyWindow(window->hwnd);
2016-06-04 04:36:07 +02:00
}
2016-06-06 08:01:26 +02:00
static void ui_window_win32_set_focused(void *data)
{
ui_window_win32_t *window = (ui_window_win32_t*)data;
SetFocus(window->hwnd);
}
static void ui_window_win32_set_visible(void *data,
2016-06-04 04:24:54 +02:00
bool set_visible)
{
ui_window_win32_t *window = (ui_window_win32_t*)data;
2016-06-04 05:05:41 +02:00
ShowWindow(window->hwnd, set_visible ? SW_SHOWNORMAL : SW_HIDE);
2016-06-04 04:24:54 +02:00
}
2016-06-06 08:01:26 +02:00
static void ui_window_win32_set_title(void *data, char *buf)
{
ui_window_win32_t *window = (ui_window_win32_t*)data;
2016-12-02 23:36:23 -05:00
SetWindowText(window->hwnd, buf);
}
void ui_window_win32_set_droppable(void *data, bool droppable)
2016-06-04 08:38:38 +02:00
{
/* Minimum supported client: Windows XP, minimum supported server: Windows 2000 Server */
ui_window_win32_t *window = (ui_window_win32_t*)data;
if (DragAcceptFiles_func != NULL)
DragAcceptFiles_func(window->hwnd, droppable);
2016-06-04 08:38:38 +02:00
}
2016-06-06 08:01:26 +02:00
static bool ui_window_win32_focused(void *data)
2016-06-04 17:24:46 +02:00
{
ui_window_win32_t *window = (ui_window_win32_t*)data;
2016-06-04 17:26:14 +02:00
return (GetForegroundWindow() == window->hwnd);
2016-06-04 17:24:46 +02:00
}
2018-04-30 14:33:05 -04:00
ui_window_t ui_window_win32 = {
ui_window_win32_init,
ui_window_win32_destroy,
ui_window_win32_set_focused,
2016-06-04 04:24:54 +02:00
ui_window_win32_set_visible,
ui_window_win32_set_title,
2016-06-04 08:38:38 +02:00
ui_window_win32_set_droppable,
2016-06-04 17:24:46 +02:00
ui_window_win32_focused,
"win32"
2016-06-04 04:24:54 +02:00
};