From 7400272cd2a8e52af17356e5e8148ef1a5b7cfd3 Mon Sep 17 00:00:00 2001 From: pelya Date: Fri, 7 Apr 2017 21:52:47 +0300 Subject: [PATCH] Added 'OK' button to error message dialog --- src/error_gui.cpp | 24 +++++++++++++++++++++--- src/widgets/error_widget.h | 1 + 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/error_gui.cpp b/src/error_gui.cpp index c8c603afb3..e3aec20080 100644 --- a/src/error_gui.cpp +++ b/src/error_gui.cpp @@ -37,7 +37,10 @@ static const NWidgetPart _nested_errmsg_widgets[] = { NWidget(WWT_CAPTION, COLOUR_RED, WID_EM_CAPTION), SetDataTip(STR_ERROR_MESSAGE_CAPTION, STR_NULL), EndContainer(), NWidget(WWT_PANEL, COLOUR_RED), - NWidget(WWT_EMPTY, COLOUR_RED, WID_EM_MESSAGE), SetPadding(0, 2, 0, 2), SetMinimalSize(236, 32), + NWidget(WWT_TEXT, COLOUR_RED), SetDataTip(STR_EMPTY, STR_NULL), // Add some borders + NWidget(WWT_EMPTY, COLOUR_RED, WID_EM_MESSAGE), SetPadding(4, 4, 4, 4), SetMinimalSize(236, 32), + NWidget(WWT_TEXT, COLOUR_RED), SetDataTip(STR_EMPTY, STR_NULL), + NWidget(WWT_PUSHTXTBTN, COLOUR_RED, WID_EM_CLOSE), SetPadding(4, 4, 4, 4), SetDataTip(STR_BUTTON_OK, STR_NULL), EndContainer(), }; @@ -54,10 +57,13 @@ static const NWidgetPart _nested_errmsg_face_widgets[] = { NWidget(WWT_CAPTION, COLOUR_RED, WID_EM_CAPTION), SetDataTip(STR_ERROR_MESSAGE_CAPTION_OTHER_COMPANY, STR_NULL), EndContainer(), NWidget(WWT_PANEL, COLOUR_RED), + NWidget(WWT_TEXT, COLOUR_RED), SetDataTip(STR_EMPTY, STR_NULL), // Add some borders NWidget(NWID_HORIZONTAL), SetPIP(2, 1, 2), - NWidget(WWT_EMPTY, COLOUR_RED, WID_EM_FACE), SetMinimalSize(92, 119), SetFill(0, 1), SetPadding(2, 0, 1, 0), - NWidget(WWT_EMPTY, COLOUR_RED, WID_EM_MESSAGE), SetFill(0, 1), SetMinimalSize(238, 123), + NWidget(WWT_EMPTY, COLOUR_RED, WID_EM_FACE), SetMinimalSize(92, 119), SetFill(0, 1), SetPadding(4, 4, 4, 4), + NWidget(WWT_EMPTY, COLOUR_RED, WID_EM_MESSAGE), SetFill(0, 1), SetMinimalSize(238, 123), SetPadding(4, 4, 4, 4), EndContainer(), + NWidget(WWT_TEXT, COLOUR_RED), SetDataTip(STR_EMPTY, STR_NULL), + NWidget(WWT_PUSHTXTBTN, COLOUR_RED, WID_EM_CLOSE), SetPadding(4, 4, 4, 4), SetDataTip(STR_BUTTON_OK, STR_NULL), EndContainer(), }; @@ -320,6 +326,18 @@ public: return ES_HANDLED; } + virtual void OnClick(Point pt, int widget, int click_count) + { + switch (widget) { + case WID_EM_CLOSE: + delete this; + break; + + default: + break; + } + } + /** * Check whether the currently shown error message was critical or not. * @return True iff the message was critical. diff --git a/src/widgets/error_widget.h b/src/widgets/error_widget.h index 8693575a75..b1fcb1b01c 100644 --- a/src/widgets/error_widget.h +++ b/src/widgets/error_widget.h @@ -17,6 +17,7 @@ enum ErrorMessageWidgets { WID_EM_CAPTION, ///< Caption of the window. WID_EM_FACE, ///< Error title. WID_EM_MESSAGE, ///< Error message. + WID_EM_CLOSE, ///< Close button. }; #endif /* WIDGETS_ERROR_WIDGET_H */