2015-06-12 13:14:38 +00:00
|
|
|
#if defined(Hiro_MessageWindow)
|
2013-03-15 13:11:33 +00:00
|
|
|
|
2015-06-12 13:14:38 +00:00
|
|
|
namespace hiro {
|
|
|
|
|
|
|
|
static auto MessageWindow_response(MessageWindow::Buttons buttons, UINT response) -> MessageWindow::Response {
|
2011-02-24 09:25:20 +00:00
|
|
|
if(response == IDOK) return MessageWindow::Response::Ok;
|
|
|
|
if(response == IDCANCEL) return MessageWindow::Response::Cancel;
|
|
|
|
if(response == IDYES) return MessageWindow::Response::Yes;
|
|
|
|
if(response == IDNO) return MessageWindow::Response::No;
|
2013-03-19 08:48:50 +00:00
|
|
|
|
|
|
|
//default responses if window was closed without a button selected
|
|
|
|
if(buttons == MessageWindow::Buttons::Ok) return MessageWindow::Response::Ok;
|
2011-02-24 09:25:20 +00:00
|
|
|
if(buttons == MessageWindow::Buttons::OkCancel) return MessageWindow::Response::Cancel;
|
|
|
|
if(buttons == MessageWindow::Buttons::YesNo) return MessageWindow::Response::No;
|
2013-03-19 08:48:50 +00:00
|
|
|
if(buttons == MessageWindow::Buttons::YesNoCancel) return MessageWindow::Response::Cancel;
|
|
|
|
|
|
|
|
throw;
|
|
|
|
}
|
|
|
|
|
2015-06-12 13:14:38 +00:00
|
|
|
static auto MessageWindow_buttons(MessageWindow::Buttons buttons) -> UINT {
|
2013-03-19 08:48:50 +00:00
|
|
|
if(buttons == MessageWindow::Buttons::Ok) return MB_OK;
|
|
|
|
if(buttons == MessageWindow::Buttons::OkCancel) return MB_OKCANCEL;
|
|
|
|
if(buttons == MessageWindow::Buttons::YesNo) return MB_YESNO;
|
|
|
|
if(buttons == MessageWindow::Buttons::YesNoCancel) return MB_YESNOCANCEL;
|
|
|
|
throw;
|
2011-02-24 09:25:20 +00:00
|
|
|
}
|
|
|
|
|
2015-06-12 13:14:38 +00:00
|
|
|
auto pMessageWindow::error(MessageWindow::State& state) -> MessageWindow::Response {
|
2013-03-19 08:48:50 +00:00
|
|
|
UINT flags = MB_ICONERROR | MessageWindow_buttons(state.buttons);
|
|
|
|
return MessageWindow_response(state.buttons, MessageBox(
|
2015-06-12 13:14:38 +00:00
|
|
|
state.parent ? state.parent->self()->hwnd : 0, utf16_t(state.text), utf16_t(state.title), flags
|
2013-03-19 08:48:50 +00:00
|
|
|
));
|
2011-02-24 09:25:20 +00:00
|
|
|
}
|
|
|
|
|
2015-06-12 13:14:38 +00:00
|
|
|
auto pMessageWindow::information(MessageWindow::State& state) -> MessageWindow::Response {
|
2013-03-19 08:48:50 +00:00
|
|
|
UINT flags = MB_ICONINFORMATION | MessageWindow_buttons(state.buttons);
|
|
|
|
return MessageWindow_response(state.buttons, MessageBox(
|
2015-06-12 13:14:38 +00:00
|
|
|
state.parent ? state.parent->self()->hwnd : 0, utf16_t(state.text), utf16_t(state.title), flags
|
2013-03-19 08:48:50 +00:00
|
|
|
));
|
2011-02-24 09:25:20 +00:00
|
|
|
}
|
|
|
|
|
2015-06-12 13:14:38 +00:00
|
|
|
auto pMessageWindow::question(MessageWindow::State& state) -> MessageWindow::Response {
|
2013-03-19 08:48:50 +00:00
|
|
|
UINT flags = MB_ICONQUESTION | MessageWindow_buttons(state.buttons);
|
|
|
|
return MessageWindow_response(state.buttons, MessageBox(
|
2015-06-12 13:14:38 +00:00
|
|
|
state.parent ? state.parent->self()->hwnd : 0, utf16_t(state.text), utf16_t(state.title), flags
|
2013-03-19 08:48:50 +00:00
|
|
|
));
|
2011-02-24 09:25:20 +00:00
|
|
|
}
|
|
|
|
|
2015-06-12 13:14:38 +00:00
|
|
|
auto pMessageWindow::warning(MessageWindow::State& state) -> MessageWindow::Response {
|
2013-03-19 08:48:50 +00:00
|
|
|
UINT flags = MB_ICONWARNING | MessageWindow_buttons(state.buttons);
|
|
|
|
return MessageWindow_response(state.buttons, MessageBox(
|
2015-06-12 13:14:38 +00:00
|
|
|
state.parent ? state.parent->self()->hwnd : 0, utf16_t(state.text), utf16_t(state.title), flags
|
2013-03-19 08:48:50 +00:00
|
|
|
));
|
2011-02-24 09:25:20 +00:00
|
|
|
}
|
2013-03-15 13:11:33 +00:00
|
|
|
|
|
|
|
}
|
2015-06-12 13:14:38 +00:00
|
|
|
|
|
|
|
#endif
|