| 1 |
namespace phoenix { |
| 2 |
|
| 3 |
static MessageWindow::Response MessageWindow_response(MessageWindow::Buttons buttons, UINT response) { |
| 4 |
if(response == IDOK) return MessageWindow::Response::Ok; |
| 5 |
if(response == IDCANCEL) return MessageWindow::Response::Cancel; |
| 6 |
if(response == IDYES) return MessageWindow::Response::Yes; |
| 7 |
if(response == IDNO) return MessageWindow::Response::No; |
| 8 |
|
| 9 |
//default responses if window was closed without a button selected |
| 10 |
if(buttons == MessageWindow::Buttons::Ok) return MessageWindow::Response::Ok; |
| 11 |
if(buttons == MessageWindow::Buttons::OkCancel) return MessageWindow::Response::Cancel; |
| 12 |
if(buttons == MessageWindow::Buttons::YesNo) return MessageWindow::Response::No; |
| 13 |
if(buttons == MessageWindow::Buttons::YesNoCancel) return MessageWindow::Response::Cancel; |
| 14 |
|
| 15 |
throw; |
| 16 |
} |
| 17 |
|
| 18 |
static UINT MessageWindow_buttons(MessageWindow::Buttons buttons) { |
| 19 |
if(buttons == MessageWindow::Buttons::Ok) return MB_OK; |
| 20 |
if(buttons == MessageWindow::Buttons::OkCancel) return MB_OKCANCEL; |
| 21 |
if(buttons == MessageWindow::Buttons::YesNo) return MB_YESNO; |
| 22 |
if(buttons == MessageWindow::Buttons::YesNoCancel) return MB_YESNOCANCEL; |
| 23 |
throw; |
| 24 |
} |
| 25 |
|
| 26 |
MessageWindow::Response pMessageWindow::error(MessageWindow::State& state) { |
| 27 |
UINT flags = MB_ICONERROR | MessageWindow_buttons(state.buttons); |
| 28 |
return MessageWindow_response(state.buttons, MessageBox( |
| 29 |
state.parent ? state.parent->p.hwnd : 0, utf16_t(state.text), utf16_t(state.title), flags |
| 30 |
)); |
| 31 |
} |
| 32 |
|
| 33 |
MessageWindow::Response pMessageWindow::information(MessageWindow::State& state) { |
| 34 |
UINT flags = MB_ICONINFORMATION | MessageWindow_buttons(state.buttons); |
| 35 |
return MessageWindow_response(state.buttons, MessageBox( |
| 36 |
state.parent ? state.parent->p.hwnd : 0, utf16_t(state.text), utf16_t(state.title), flags |
| 37 |
)); |
| 38 |
} |
| 39 |
|
| 40 |
MessageWindow::Response pMessageWindow::question(MessageWindow::State& state) { |
| 41 |
UINT flags = MB_ICONQUESTION | MessageWindow_buttons(state.buttons); |
| 42 |
return MessageWindow_response(state.buttons, MessageBox( |
| 43 |
state.parent ? state.parent->p.hwnd : 0, utf16_t(state.text), utf16_t(state.title), flags |
| 44 |
)); |
| 45 |
} |
| 46 |
|
| 47 |
MessageWindow::Response pMessageWindow::warning(MessageWindow::State& state) { |
| 48 |
UINT flags = MB_ICONWARNING | MessageWindow_buttons(state.buttons); |
| 49 |
return MessageWindow_response(state.buttons, MessageBox( |
| 50 |
state.parent ? state.parent->p.hwnd : 0, utf16_t(state.text), utf16_t(state.title), flags |
| 51 |
)); |
| 52 |
} |
| 53 |
|
| 54 |
} |