21#include "../../SDL_internal.h"
23#if SDL_VIDEO_DRIVER_WINRT
27#include "../../core/windows/SDL_windows.h"
32#include <windows.ui.popups.h>
33using namespace Platform;
34using namespace Windows::Foundation;
35using namespace Windows::UI::Popups;
38WINRT_UTF8ToPlatformString(
const char * str)
41 String ^ rtstr =
ref new String(wstr);
49#if (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP) && (NTDDI_VERSION == NTDDI_WIN8)
57 return SDL_SetError(
"SDL_messagebox support is not available for Windows Phone 8.0");
61#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
62 const int maxbuttons = 2;
63 const char * platform =
"Windows Phone 8.1+";
65 const int maxbuttons = 3;
66 const char * platform =
"Windows 8.x";
70 return SDL_SetError(
"WinRT's MessageDialog only supports %d buttons, at most, on %s. %d were requested.",
71 maxbuttons, platform, messageboxdata->
numbuttons);
75 MessageDialog ^ dialog =
ref new MessageDialog(WINRT_UTF8ToPlatformString(messageboxdata->
message));
76 dialog->Title = WINRT_UTF8ToPlatformString(messageboxdata->
title);
79 button->Id = safe_cast<IntPtr>(
i);
80 dialog->Commands->Append(
button);
82 dialog->CancelCommandIndex =
i;
85 dialog->DefaultCommandIndex =
i;
91 auto operation = dialog->ShowAsync();
92 while (operation->Status == Windows::Foundation::AsyncStatus::Started) {
97 if (operation->Status != Windows::Foundation::AsyncStatus::Completed) {
98 return SDL_SetError(
"An unknown error occurred in displaying the WinRT MessageDialog");
101 IntPtr results = safe_cast<IntPtr>(operation->GetResults()->Id);
102 int clicked_index = results.ToInt32();
@ SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT
@ SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT
SDL_VideoDevice * SDL_GetVideoDevice(void)
static SDL_VideoDevice * _this
#define WIN_UTF8ToString(S)
void WINRT_PumpEvents(_THIS)
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
MessageBox structure containing title, text, window, etc.
const SDL_MessageBoxButtonData * buttons