Allow updating wxBusyInfo text while it's shown
Add UpdateText() and UpdateLabel() updating the text (i.e. possibly containing markup) or the label (just plain text) shown in the window. Closes #14743. Closes https://github.com/Kvaz1r/wxWidgets.git BusyInfoUpdateText14743
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
|
||||
class WXDLLIMPEXP_FWD_CORE wxFrame;
|
||||
class WXDLLIMPEXP_FWD_CORE wxWindow;
|
||||
class WXDLLIMPEXP_FWD_CORE wxControl;
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
// wxBusyInfo
|
||||
@@ -37,12 +38,16 @@ public:
|
||||
Init(wxBusyInfoFlags().Parent(parent).Label(message));
|
||||
}
|
||||
|
||||
void UpdateText(const wxString& str);
|
||||
void UpdateLabel(const wxString& str);
|
||||
|
||||
virtual ~wxBusyInfo();
|
||||
|
||||
private:
|
||||
void Init(const wxBusyInfoFlags& flags);
|
||||
|
||||
wxFrame *m_InfoFrame;
|
||||
wxControl *m_text;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(wxBusyInfo);
|
||||
};
|
||||
|
@@ -111,6 +111,23 @@ public:
|
||||
*/
|
||||
wxBusyInfo(const wxString& msg, wxWindow* parent = NULL);
|
||||
|
||||
/**
|
||||
Update the information text.
|
||||
|
||||
The @a text string may contain markup as described in
|
||||
wxControl::SetLabelMarkup().
|
||||
|
||||
@since 3.1.3
|
||||
*/
|
||||
void UpdateText(const wxString& str);
|
||||
|
||||
/**
|
||||
Same as UpdateText() but doesn't interpret the string as containing markup.
|
||||
|
||||
@since 3.1.3
|
||||
*/
|
||||
void UpdateLabel(const wxString& str);
|
||||
|
||||
/**
|
||||
Hides and closes the window containing the information text.
|
||||
*/
|
||||
|
@@ -79,24 +79,21 @@ void wxBusyInfo::Init(const wxBusyInfoFlags& flags)
|
||||
// Vertically center the text in the window.
|
||||
sizer->AddStretchSpacer();
|
||||
|
||||
wxControl* text;
|
||||
#if wxUSE_MARKUP
|
||||
if ( !flags.m_text.empty() )
|
||||
{
|
||||
text = new wxStaticTextWithMarkupSupport(panel, wxID_ANY, wxString(),
|
||||
m_text = new wxStaticTextWithMarkupSupport(panel, wxID_ANY, wxString(),
|
||||
wxDefaultPosition,
|
||||
wxDefaultSize,
|
||||
wxALIGN_CENTRE);
|
||||
text->SetLabelMarkup(flags.m_text);
|
||||
}
|
||||
if ( !flags.m_text.empty() )
|
||||
m_text->SetLabelMarkup(flags.m_text);
|
||||
else
|
||||
m_text->SetLabelText(flags.m_label);
|
||||
#else
|
||||
m_text = new wxStaticText(panel, wxID_ANY, wxString());
|
||||
m_text->SetLabelText(flags.m_label);
|
||||
#endif // wxUSE_MARKUP
|
||||
{
|
||||
text = new wxStaticText(panel, wxID_ANY, wxString());
|
||||
text->SetLabelText(flags.m_label);
|
||||
}
|
||||
|
||||
sizer->Add(text, wxSizerFlags().DoubleBorder().Centre());
|
||||
sizer->Add(m_text, wxSizerFlags().DoubleBorder().Centre());
|
||||
|
||||
sizer->AddStretchSpacer();
|
||||
|
||||
@@ -106,7 +103,7 @@ void wxBusyInfo::Init(const wxBusyInfoFlags& flags)
|
||||
{
|
||||
if ( title )
|
||||
title->SetForegroundColour(flags.m_foreground);
|
||||
text->SetForegroundColour(flags.m_foreground);
|
||||
m_text->SetForegroundColour(flags.m_foreground);
|
||||
}
|
||||
|
||||
if ( flags.m_background.IsOk() )
|
||||
@@ -131,6 +128,16 @@ void wxBusyInfo::Init(const wxBusyInfoFlags& flags)
|
||||
m_InfoFrame->Update();
|
||||
}
|
||||
|
||||
void wxBusyInfo::UpdateText(const wxString& str)
|
||||
{
|
||||
m_text->SetLabelMarkup(str);
|
||||
}
|
||||
|
||||
void wxBusyInfo::UpdateLabel(const wxString& str)
|
||||
{
|
||||
m_text->SetLabelText(str);
|
||||
}
|
||||
|
||||
wxBusyInfo::~wxBusyInfo()
|
||||
{
|
||||
m_InfoFrame->Show(false);
|
||||
|
Reference in New Issue
Block a user