Fix wxTextCtrl::GetStyle() with GTK+ 3
The text and background colours are now stored in the rgba array instead of fg_color and bg_color as with GTK+ 2 (the latter ones seem to have been repurposed for the underline and strike-through colours!). Also make the unit test for this method more robust.
This commit is contained in:
parent
5fb740fed8
commit
66324470f1
@ -171,6 +171,7 @@ wxGTK:
|
||||
- Make wxUIActionSimulator work with GTK+ 3 (Scott Talbert).
|
||||
- Make wxBORDER_NONE work for wxTextCtrl with GTK+ 3 (Adrien Tétar).
|
||||
- Apply wxTextCtrl::SetDefaultStyle() to user-entered text (Andreas Falkenhahn).
|
||||
- Fix wxTextCtrl::GetStyle() with GTK+ 3.
|
||||
- Support background colour in wxDataViewCtrl attributes.
|
||||
- Improve wxSpinCtrl best size calculation.
|
||||
- Implement support for icon locations in wxMimeTypesManager (Hanmac).
|
||||
|
@ -1777,8 +1777,13 @@ bool wxTextCtrl::GetStyle(long position, wxTextAttr& style)
|
||||
}
|
||||
else // have custom attributes
|
||||
{
|
||||
#ifdef __WXGTK3__
|
||||
style.SetBackgroundColour(*pattr->appearance.rgba[0]);
|
||||
style.SetTextColour(*pattr->appearance.rgba[1]);
|
||||
#else
|
||||
style.SetBackgroundColour(pattr->appearance.bg_color);
|
||||
style.SetTextColour(pattr->appearance.fg_color);
|
||||
#endif
|
||||
|
||||
const wxGtkString
|
||||
pangoFontString(pango_font_description_to_string(pattr->font));
|
||||
|
@ -397,7 +397,7 @@ void TextCtrlTestCase::Style()
|
||||
#ifndef __WXOSX__
|
||||
delete m_text;
|
||||
// We need wxTE_RICH under windows for style support
|
||||
CreateText(wxTE_RICH);
|
||||
CreateText(wxTE_MULTILINE|wxTE_RICH);
|
||||
|
||||
// Red text on a white background
|
||||
m_text->SetDefaultStyle(wxTextAttr(*wxRED, *wxWHITE));
|
||||
@ -431,20 +431,21 @@ void TextCtrlTestCase::Style()
|
||||
wxTextAttr style;
|
||||
|
||||
// We have to check that styles are supported
|
||||
if(m_text->GetStyle(3, style))
|
||||
if ( !m_text->GetStyle(3, style) )
|
||||
{
|
||||
CPPUNIT_ASSERT_EQUAL(style.GetTextColour(), *wxRED);
|
||||
CPPUNIT_ASSERT_EQUAL(style.GetBackgroundColour(), *wxWHITE);
|
||||
WARN("Retrieving text style not supported, skipping test.");
|
||||
return;
|
||||
}
|
||||
|
||||
CHECK( style.GetTextColour() == *wxRED );
|
||||
CHECK( style.GetBackgroundColour() == *wxWHITE );
|
||||
|
||||
// And then setting the style
|
||||
if(m_text->SetStyle(15, 18, style))
|
||||
{
|
||||
m_text->GetStyle(17, style);
|
||||
REQUIRE( m_text->SetStyle(15, 18, style) );
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(style.GetTextColour(), *wxRED);
|
||||
CPPUNIT_ASSERT_EQUAL(style.GetBackgroundColour(), *wxWHITE);
|
||||
}
|
||||
REQUIRE( m_text->GetStyle(17, style) );
|
||||
CHECK( style.GetTextColour() == *wxRED );
|
||||
CHECK( style.GetBackgroundColour() == *wxWHITE );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user