Wrap label if necessary in wxInfoBar in wxGTK
Also update the sample to test showing an overlong message in wxInfoBar. Closes https://github.com/wxWidgets/wxWidgets/pull/1443 See #14121.
This commit is contained in:
committed by
Vadim Zeitlin
parent
43c519e04f
commit
32d8b5954a
@@ -159,6 +159,7 @@ wxBEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
|||||||
#endif // wxUSE_LOG_DIALOG
|
#endif // wxUSE_LOG_DIALOG
|
||||||
#if wxUSE_INFOBAR
|
#if wxUSE_INFOBAR
|
||||||
EVT_MENU(DIALOGS_INFOBAR_SIMPLE, MyFrame::InfoBarSimple)
|
EVT_MENU(DIALOGS_INFOBAR_SIMPLE, MyFrame::InfoBarSimple)
|
||||||
|
EVT_MENU(DIALOGS_INFOBAR_SIMPLE_WRAPPED, MyFrame::InfoBarSimpleWrapped)
|
||||||
EVT_MENU(DIALOGS_INFOBAR_ADVANCED, MyFrame::InfoBarAdvanced)
|
EVT_MENU(DIALOGS_INFOBAR_ADVANCED, MyFrame::InfoBarAdvanced)
|
||||||
#endif // wxUSE_INFOBAR
|
#endif // wxUSE_INFOBAR
|
||||||
|
|
||||||
@@ -530,6 +531,7 @@ bool MyApp::OnInit()
|
|||||||
|
|
||||||
#if wxUSE_INFOBAR
|
#if wxUSE_INFOBAR
|
||||||
info_menu->Append(DIALOGS_INFOBAR_SIMPLE, "Simple &info bar\tCtrl-I");
|
info_menu->Append(DIALOGS_INFOBAR_SIMPLE, "Simple &info bar\tCtrl-I");
|
||||||
|
info_menu->Append(DIALOGS_INFOBAR_SIMPLE_WRAPPED, "Simple info bar with wrapped text");
|
||||||
info_menu->Append(DIALOGS_INFOBAR_ADVANCED, "&Advanced info bar\tShift-Ctrl-I");
|
info_menu->Append(DIALOGS_INFOBAR_ADVANCED, "&Advanced info bar\tShift-Ctrl-I");
|
||||||
#endif // wxUSE_INFOBAR
|
#endif // wxUSE_INFOBAR
|
||||||
|
|
||||||
@@ -890,6 +892,11 @@ void MyFrame::InfoBarSimple(wxCommandEvent& WXUNUSED(event))
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MyFrame::InfoBarSimpleWrapped(wxCommandEvent &WXUNUSED(event))
|
||||||
|
{
|
||||||
|
m_infoBarSimple->ShowMessage( "This is very very long message to try the label wrapping on the info bar" );
|
||||||
|
}
|
||||||
|
|
||||||
void MyFrame::InfoBarAdvanced(wxCommandEvent& WXUNUSED(event))
|
void MyFrame::InfoBarAdvanced(wxCommandEvent& WXUNUSED(event))
|
||||||
{
|
{
|
||||||
m_infoBarAdvanced->ShowMessage("Sorry, it didn't work out.", wxICON_WARNING);
|
m_infoBarAdvanced->ShowMessage("Sorry, it didn't work out.", wxICON_WARNING);
|
||||||
|
@@ -391,6 +391,7 @@ public:
|
|||||||
|
|
||||||
#if wxUSE_INFOBAR
|
#if wxUSE_INFOBAR
|
||||||
void InfoBarSimple(wxCommandEvent& event);
|
void InfoBarSimple(wxCommandEvent& event);
|
||||||
|
void InfoBarSimpleWrapped(wxCommandEvent &event);
|
||||||
void InfoBarAdvanced(wxCommandEvent& event);
|
void InfoBarAdvanced(wxCommandEvent& event);
|
||||||
#endif // wxUSE_INFOBAR
|
#endif // wxUSE_INFOBAR
|
||||||
|
|
||||||
@@ -598,6 +599,7 @@ enum
|
|||||||
DIALOGS_NUM_ENTRY,
|
DIALOGS_NUM_ENTRY,
|
||||||
DIALOGS_LOG_DIALOG,
|
DIALOGS_LOG_DIALOG,
|
||||||
DIALOGS_INFOBAR_SIMPLE,
|
DIALOGS_INFOBAR_SIMPLE,
|
||||||
|
DIALOGS_INFOBAR_SIMPLE_WRAPPED,
|
||||||
DIALOGS_INFOBAR_ADVANCED,
|
DIALOGS_INFOBAR_ADVANCED,
|
||||||
DIALOGS_MODAL,
|
DIALOGS_MODAL,
|
||||||
DIALOGS_MODELESS,
|
DIALOGS_MODELESS,
|
||||||
|
@@ -236,7 +236,7 @@ void wxInfoBarGeneric::ShowMessage(const wxString& msg, int flags)
|
|||||||
// notice the use of EscapeMnemonics() to ensure that "&" come through
|
// notice the use of EscapeMnemonics() to ensure that "&" come through
|
||||||
// correctly
|
// correctly
|
||||||
m_text->SetLabel(wxControl::EscapeMnemonics(msg));
|
m_text->SetLabel(wxControl::EscapeMnemonics(msg));
|
||||||
|
m_text->Wrap( GetClientSize().GetWidth() );
|
||||||
|
|
||||||
// then show this entire window if not done yet
|
// then show this entire window if not done yet
|
||||||
if ( !IsShown() )
|
if ( !IsShown() )
|
||||||
|
@@ -196,7 +196,11 @@ void wxInfoBar::ShowMessage(const wxString& msg, int flags)
|
|||||||
if ( wxGTKImpl::ConvertMessageTypeFromWX(flags, &type) )
|
if ( wxGTKImpl::ConvertMessageTypeFromWX(flags, &type) )
|
||||||
gtk_info_bar_set_message_type(GTK_INFO_BAR(m_widget), type);
|
gtk_info_bar_set_message_type(GTK_INFO_BAR(m_widget), type);
|
||||||
gtk_label_set_text(GTK_LABEL(m_impl->m_label), wxGTK_CONV(msg));
|
gtk_label_set_text(GTK_LABEL(m_impl->m_label), wxGTK_CONV(msg));
|
||||||
|
gtk_label_set_line_wrap(GTK_LABEL(m_impl->m_label), TRUE );
|
||||||
|
#if GTK_CHECK_VERSION(2,10,0)
|
||||||
|
if( wx_is_at_least_gtk2( 10 ) )
|
||||||
|
gtk_label_set_line_wrap_mode(GTK_LABEL(m_impl->m_label), PANGO_WRAP_WORD);
|
||||||
|
#endif
|
||||||
if ( !IsShown() )
|
if ( !IsShown() )
|
||||||
Show();
|
Show();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user