Fix for #15224: wxRichTextTable: Setting a cell's text colour affects subsequent cells (dghart)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74842 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -10310,6 +10310,9 @@ bool wxRichTextTable::CreateTable(int rows, int cols)
|
|||||||
{
|
{
|
||||||
ClearTable();
|
ClearTable();
|
||||||
|
|
||||||
|
wxRichTextAttr cellattr;
|
||||||
|
cellattr.SetTextColour(GetBasicStyle().GetTextColour());
|
||||||
|
|
||||||
m_rowCount = rows;
|
m_rowCount = rows;
|
||||||
m_colCount = cols;
|
m_colCount = cols;
|
||||||
|
|
||||||
@@ -10322,6 +10325,8 @@ bool wxRichTextTable::CreateTable(int rows, int cols)
|
|||||||
for (j = 0; j < cols; j++)
|
for (j = 0; j < cols; j++)
|
||||||
{
|
{
|
||||||
wxRichTextCell* cell = new wxRichTextCell;
|
wxRichTextCell* cell = new wxRichTextCell;
|
||||||
|
cell->GetAttributes() = cellattr;
|
||||||
|
|
||||||
AppendChild(cell);
|
AppendChild(cell);
|
||||||
cell->AddParagraph(wxEmptyString);
|
cell->AddParagraph(wxEmptyString);
|
||||||
|
|
||||||
|
@@ -3009,6 +3009,12 @@ wxRichTextBox* wxRichTextCtrl::WriteTextBox(const wxRichTextAttr& textAttr)
|
|||||||
textBox->AddParagraph(wxEmptyString);
|
textBox->AddParagraph(wxEmptyString);
|
||||||
textBox->SetParent(NULL);
|
textBox->SetParent(NULL);
|
||||||
|
|
||||||
|
// If the box has an invalid foreground colour, its text will mimic any upstream value (see #15224)
|
||||||
|
if (!textBox->GetAttributes().GetTextColour().IsOk())
|
||||||
|
{
|
||||||
|
textBox->GetAttributes().SetTextColour(GetBasicStyle().GetTextColour());
|
||||||
|
}
|
||||||
|
|
||||||
// The object returned is the one actually inserted into the buffer,
|
// The object returned is the one actually inserted into the buffer,
|
||||||
// while the original one is deleted.
|
// while the original one is deleted.
|
||||||
wxRichTextObject* obj = GetFocusObject()->InsertObjectWithUndo(& GetBuffer(), m_caretPosition+1, textBox, this, wxRICHTEXT_INSERT_WITH_PREVIOUS_PARAGRAPH_STYLE);
|
wxRichTextObject* obj = GetFocusObject()->InsertObjectWithUndo(& GetBuffer(), m_caretPosition+1, textBox, this, wxRICHTEXT_INSERT_WITH_PREVIOUS_PARAGRAPH_STYLE);
|
||||||
@@ -3034,17 +3040,25 @@ wxRichTextTable* wxRichTextCtrl::WriteTable(int rows, int cols, const wxRichText
|
|||||||
wxRichTextTable* table = new wxRichTextTable;
|
wxRichTextTable* table = new wxRichTextTable;
|
||||||
table->SetAttributes(tableAttr);
|
table->SetAttributes(tableAttr);
|
||||||
table->SetParent(& GetBuffer()); // set parent temporarily for AddParagraph to use correct style
|
table->SetParent(& GetBuffer()); // set parent temporarily for AddParagraph to use correct style
|
||||||
|
table->SetBasicStyle(GetBasicStyle());
|
||||||
|
|
||||||
table->CreateTable(rows, cols);
|
table->CreateTable(rows, cols);
|
||||||
|
|
||||||
table->SetParent(NULL);
|
table->SetParent(NULL);
|
||||||
|
|
||||||
|
// If cells have an invalid foreground colour, their text will mimic any upstream value (see #15224)
|
||||||
|
wxRichTextAttr attr = cellAttr;
|
||||||
|
if (!attr.GetTextColour().IsOk())
|
||||||
|
{
|
||||||
|
attr.SetTextColour(GetBasicStyle().GetTextColour());
|
||||||
|
}
|
||||||
|
|
||||||
int i, j;
|
int i, j;
|
||||||
for (j = 0; j < rows; j++)
|
for (j = 0; j < rows; j++)
|
||||||
{
|
{
|
||||||
for (i = 0; i < cols; i++)
|
for (i = 0; i < cols; i++)
|
||||||
{
|
{
|
||||||
table->GetCell(j, i)->GetAttributes() = cellAttr;
|
table->GetCell(j, i)->GetAttributes() = attr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user