void DataGrid::showMainData() { char buf[MONEY_LEN]; BeginBatch(); int diff = GetNumberRows()-(m_data->getItemsNum()+1+1); // +initial and total if (diff < 0) { if (!AppendRows(-diff)) return; setRows(m_data->getItemsNum()+1+diff, -diff); } else if (diff > 0) { if (!DeleteRows(m_data->getItemsNum()+1, diff)) return; } SetRowLabelValue(0, HaStrings::strInitial); money_to_str_trail(buf, m_data->getInitial()); SetCellValue(0, BalanceIndex, buf); int row = 1; for (DataFileRW::ItemIterator i = m_data->ItemBegin(); i != m_data->ItemEnd(); ++i, row++) { if (ulist_is_first(&i->owner->items, &i->ulist)) { SetRowLabelValue(row, i->owner->title.str); } else { SetRowLabelValue(row, wxT("")); } clearRow(row); if (is_dummy_item(&*i)) continue; if (i->money < 0) { money_to_str_trail(buf, -i->money); SetCellValue(row, IncomeIndex, buf); } else { money_to_str_trail(buf, i->money); SetCellValue(row, OutlayIndex, buf); } SetCellValue(row, DescIndex, i->desc.str); SetCellValue(row, CommentIndex, i->comment.str); } SetRowLabelValue(row, HaStrings::strTotal); for (int i = 0; i < ColumnNum; i++) SetReadOnly(row, i); wxFont font = GetCellFont(row, 0); font.MakeBold(); SetCellFont(row, IncomeIndex, font); SetCellFont(row, OutlayIndex, font); EndBatch(); }
bool wxPropertyList::UpdatePropertyItem(wxPropertyItem *pItem, int row) { wxCHECK(row < GetNumberRows(), false); // reflect the property's state to match the grid row SetReadOnly(row, 0); // TODO: Make this a UpdatePropItem where ADVANCED, and new edit values are reflected SetCellValue(row,0, pItem->GetPropName()); // boolean renderer if(pItem->GetItemType() == wxPropertyList::CHECKBOX) { // translate ON or TRUE (case insensitive to a checkbox) if(pItem->GetCurValue().IsSameAs(wxT("ON"), false) || pItem->GetCurValue().IsSameAs(wxT("TRUE"), false)) SetCellValue(row, 1, wxT("1")); else SetCellValue(row, 1, wxT("0")); } else { // for normal path values, give bold in cell when // the NOTFOUND is present, for emphasis wxString str = pItem->GetPropName() + wxT("-NOTFOUND"); if(pItem->GetCurValue().IsSameAs(str)) { wxFont fnt = GetCellFont(row, 0); fnt.SetWeight(wxFONTWEIGHT_BOLD); SetCellFont(row, 1, fnt); } else SetCellFont(row, 1, GetCellFont(row, 0)); SetCellValue(row,1, pItem->GetCurValue()); } if(pItem->GetCurValue().IsSameAs("IGNORE")) { // ignored cell is completely dimmed wxColour col(192,192,192); SetCellTextColour(row, 1, col); } else { // we colour paths blue, filenames green, all else black wxColour col; if(pItem->IsDirPath()) col.Set(0,0,255); else if(pItem->IsFilePath()) col.Set(0,128,0); else col = GetCellTextColour(row, 0); SetCellTextColour(row, 1, col); } if(pItem->GetNewValue()) { // new cell is red wxColour col(255,100,100); SetCellBackgroundColour(row, 0, col); } else { // old cell is grey wxColour col(192, 192, 192); SetCellBackgroundColour(row, 0, col); } return true; }