Kvaz1r wrote: ↑Sun Jul 14, 2019 8:06 am
doublemax wrote: ↑Sun Jul 14, 2019 7:45 am
You need a matching EndAlignment() call.
It didn't work with this changes either. But if called
Newline/0 style works as expected.
Adding a new line after the text worked for me. Thank you Kvaz1r.
Code: Select all
te->WriteText("Hello rich text!\n");
or
Code: Select all
te->WriteText("Hello rich text!");
te->Newline();
--- Edit ---
This is what my actual code looked like:
Code: Select all
textarea->BeginAlignment(wxTEXT_ALIGNMENT_CENTER);
textarea->BeginFontSize(14);
textarea->BeginBold();
textarea->WriteText("HOW TO PLAY");
textarea->EndAllStyles();
textarea->BeginBold();
textarea->BeginUnderline();
textarea->WriteText("\n\nSelecting a category:\n");
So I changed it to this:
Code: Select all
textarea->BeginAlignment(wxTEXT_ALIGNMENT_CENTER);
textarea->BeginFontSize(14);
textarea->BeginBold();
textarea->WriteText("HOW TO PLAY\n");
textarea->EndAllStyles();
textarea->BeginBold();
textarea->BeginUnderline();
textarea->WriteText("\nSelecting a category:\n");
It seems that calling
EndAllStyles or
EndAlignment before a newline removes the alignment for the current line. Which actually makes sense. But it makes it look like a bug when there is only a single line without calling one of those.
--- Edit ---
Alignment is not applied to final line if not followed by a newline character:
Code: Select all
Window::Window() :
wxFrame(NULL, -1, "Rich Text") {
te = new wxRichTextCtrl(this, -1, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxRE_READONLY);
te->BeginAlignment(wxTEXT_ALIGNMENT_CENTER); // centering text not working
te->WriteText("Hello rich text!\n");
te->WriteText("Goodbye rich text");
}
Result:
- rich_text_center_justify2.png (2.78 KiB) Viewed 1876 times