On 24.08.2015 at 15:12 Vadim Zeitlin wrote:
> On Mon, 24 Aug 2015 10:25:03 +0200 Andreas Falkenhahn wrote:
AF>> 1) As you can see in the screenshot, the styled text appears visibly
AF>> larger than the non-styled text although I am not modifying the
AF>> font size. All I am doing is this:
> I think Iwbnwif Yiw has already answered this. In practice, what you
> should do is to add:
AF>> wxTextAttr ta;
tc->GetStyle(0, ta);
So do I need to cache this initial style somewhere in order to be able
to completely reset styles later or is there another way to obtain the
wxTextCtrl's initial style?
Consider the following case:
First, I want the complete text to be bold. Thus, I do:
tc->Clear();
wxTextAttr ta;
tc->GetStyle(0, ta);
ta.SetFontWeight(wxFONTWEIGHT_BOLD);
tc->SetDefaultStyle(ta);
tc->AppendText(wxString("This is bold text"));
Later, I want all the text in the same control to be in italics, but not
in bold. Doing the following here will *not* work now because GetStyle()
obviously returns that bold is active for position 0:
// THIS CODE DOESN'T WORK!
tc->Clear();
wxTextAttr ta;
tc->GetStyle(0, ta);
ta.SetFontStyle(wxFONTSTYLE_ITALIC);
tc->SetDefaultStyle(ta);
tc->AppendText(wxString("This is italic text"));
So do I need to store the initial wxTextAttr returned by GetStyle()
and keep it for the purpose of completely resetting all styles back
to the default ones?
Also, the documentation of GetStyle() could be a little more verbose
as to which platforms actually support it because currently it just
says: "Not all platforms support this function." --- which isn't very
enlightening ;)