Merge branch 'safe-show-message'

Show message box from wxSafeShowMessage() in the other ports too, if
possible.

Currently this is done using wxMessageBox() if it can be sure that it's
safe to call and only MSW uses native function which is always safe to
call. Ideal would be to also use a native function under Mac, where it
should also be the case, but this doesn't seem to work for whichever
reason.

See https://github.com/wxWidgets/wxWidgets/pull/2270
This commit is contained in:
Vadim Zeitlin
2021-03-23 18:59:51 +01:00
34 changed files with 194 additions and 47 deletions

View File

@@ -859,6 +859,18 @@ public:
*/
bool GetUseBestVisual() const;
/**
Returns a pointer to the top application window if any.
This function is safe to call even before creating, or after
destroying, the application object, as it simply returns @NULL if it
doesn't exist. Otherwise it's equivalent to calling
@c wxTheApp->GetTopWindow().
@since 3.1.5
*/
static wxWindow* GetMainTopWindow();
/**
Returns a pointer to the top window.

View File

@@ -133,5 +133,28 @@ public:
Returns @true to suppress subsequent asserts, @false to continue as before.
*/
virtual bool ShowAssertDialog(const wxString& msg) = 0;
/**
Shows a message box with the given text and title if possible.
In some ports, e.g. wxMSW, a message box will always be shown, while in
the other ones it will be only done if the GUI is available (e.g. X11
display was successfully opened for X11-based ports) and the function
simply returns @false without doing anything otherwise.
This function is safe in the sense that it can always be called, even
before creating wxApp, similarly to wxSafeShowMessage() which is
implemented by calling this function and then logging the message to
standard error stream if it returned @false.
@since 3.1.5
@param text
The text to show to the user.
@param title
The title of the message box shown to the user.
@return @true if the message box was shown or @false otherwise.
*/
virtual bool SafeMessageBox(const wxString& text, const wxString& title) = 0;
};

View File

@@ -1268,12 +1268,17 @@ public:
message string.
@param text
The text to show to the user.
@return
@true If a message box was actually shown or @false if the message was
logged to the console because there is no safe to show it currently
(the return value is only available since wxWidgets 3.1.5, the function
doesn't return anything in the previous versions).
@see wxLogFatalError()
@header{wx/log.h}
*/
void wxSafeShowMessage(const wxString& title, const wxString& text);
bool wxSafeShowMessage(const wxString& title, const wxString& text);
/**
Returns the error code from the last system call. This function uses