From 6f9f4c6dbe329b4741bf65b97d253ee3cb45d091 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 3 Oct 2023 16:28:55 +0200 Subject: [PATCH 1/2] Call wxYield() while showing wxBusyInfo in the dialogs sample Otherwise it can't be seen at all with wxGTK. --- samples/dialogs/dialogs.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/samples/dialogs/dialogs.cpp b/samples/dialogs/dialogs.cpp index dfbe38dd9a..fb747dc1fa 100644 --- a/samples/dialogs/dialogs.cpp +++ b/samples/dialogs/dialogs.cpp @@ -3542,7 +3542,11 @@ void MyFrame::ShowRichBusyInfo(wxCommandEvent& WXUNUSED(event)) .Transparency(4*wxALPHA_OPAQUE/5) ); - wxSleep(5); + for ( int i = 0; i < 20; i++ ) + { + wxTheApp->Yield(); + wxMilliSleep(250); + } } #endif // wxUSE_BUSYINFO From 71001385c6d66412f3f07b0fdc5a8d5ab022f296 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 3 Oct 2023 16:31:47 +0200 Subject: [PATCH 2/2] Fix wxBusyInfo layout when using wxGTK Use a dirty hack to ensure the window is created (roughly) as tall as it needs to be instead of being created too small and truncating the text in it. --- src/generic/busyinfo.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/generic/busyinfo.cpp b/src/generic/busyinfo.cpp index 6b00a4f8b9..b27e568ec6 100644 --- a/src/generic/busyinfo.cpp +++ b/src/generic/busyinfo.cpp @@ -59,6 +59,21 @@ void wxBusyInfo::Init(const wxBusyInfoFlags& flags) wxDefaultSize, wxALIGN_CENTRE); title->SetFont(title->GetFont().Scaled(2)); + +#ifdef __WXGTK__ + // This bad hack is needed to fix layout under GTK: the font sent above + // is not taken into account for the size calculation until the window + // is shown but we need the correct size when computing the best size + // below, as otherwise we would make the entire frame too small and + // when the correct size is used for the actual layout later, the title + // control would take too much space pushing the text below it outside + // of the window bounds. + // + // So preemptively make it about as big as it's going to be to prevent + // this from happening. + title->SetMinSize(2*title->GetBestSize()); +#endif // __WXGTK__ + #if wxUSE_MARKUP title->SetLabelMarkup(flags.m_title); #else