* Show a confirmation window with standard 'yes' and 'no' buttons * The window is aligned to the centre of its parent. * @param caption string shown as window caption * @param message string that will be shown for the window * @param parent pointer to parent window, if this pointer is nullptr the parent becomes * the main window WC_MAIN_WINDOW * @param callback callback function pointer to s
| 1202 | * @param focus whether the window should be focussed (by default false) |
| 1203 | */ |
| 1204 | void ShowQuery(EncodedString &&caption, EncodedString &&message, Window *parent, QueryCallbackProc *callback, bool focus) |
| 1205 | { |
| 1206 | if (parent == nullptr) parent = GetMainWindow(); |
| 1207 | |
| 1208 | for (Window *w : Window::Iterate()) { |
| 1209 | if (w->window_class != WC_CONFIRM_POPUP_QUERY) continue; |
| 1210 | |
| 1211 | QueryWindow *qw = dynamic_cast<QueryWindow *>(w); |
| 1212 | assert(qw != nullptr); |
| 1213 | if (qw->parent != parent || qw->proc != callback) continue; |
| 1214 | |
| 1215 | qw->Close(); |
| 1216 | break; |
| 1217 | } |
| 1218 | |
| 1219 | QueryWindow *q = new QueryWindow(_query_desc, std::move(caption), std::move(message), parent, callback); |
| 1220 | if (focus) SetFocusedWindow(q); |
| 1221 | } |
no test coverage detected