void CGridAttrGrid::SetupGridColoursAttr(CParmOsiris *pParm) { wxFont fn = GetDefaultCellFont(); wxFontWeight fw = wxFONTWEIGHT_NORMAL; int fs = wxFONTSTYLE_NORMAL; const size_t N = sizeof(aROWS_ATTR) / sizeof(aROWS_ATTR[0]); const ROW_INFO *pRow = aROWS_ATTR; size_t i; int nRow; int nFlag; wxColour cFG; wxColour cBG; wxColour c; for(i = 0; i < N; i++) { nRow = (int) pRow->nRow; nFlag = pRow->nFlag; cFG = pParm->GetForeground(nFlag); cBG = pParm->GetBackground(nFlag); if( pParm->IsGridReverse(nFlag) ) { c = cFG; cFG = cBG; cBG = c; } fw = pParm->IsGridBold(nFlag) ? wxFONTWEIGHT_BOLD : wxFONTWEIGHT_NORMAL; fs = pParm->IsGridItalic(nFlag) ? wxFONTSTYLE_ITALIC : wxFONTSTYLE_NORMAL; fn.SetWeight(fw); fn.SetStyle(fs); SetCellFont(nRow,0,fn); SetCellTextColour(nRow,0,cFG); SetCellBackgroundColour(nRow,0,cBG); pRow++; } }
void CGridColorGrid::SetupGridColoursAttr(CParmOsiris *pParm) { wxFont fn = GetDefaultCellFont(); wxFontWeight fw = wxFONTWEIGHT_NORMAL; int fs = wxFONTSTYLE_NORMAL; const size_t N = sizeof(aROWS) / sizeof(aROWS[0]); const ROW_INFO *pRow = aROWS; size_t i; int nRow; int nFlag; wxColour cFG; wxColour cBG; for(i = 0; i < N; i++) { nRow = (int) pRow->nRow; nFlag = pRow->nFlag; cFG = pParm->GetForeground(nFlag); cBG = pParm->GetBackground(nFlag); fw = pParm->IsGridBold(nFlag) ? wxFONTWEIGHT_BOLD : wxFONTWEIGHT_NORMAL; fs = pParm->IsGridItalic(nFlag) ? wxFONTSTYLE_ITALIC : wxFONTSTYLE_NORMAL; fn.SetWeight(fw); fn.SetStyle(fs); SetCellFont(nRow,0,fn); SetCellTextColour(nRow,0,cFG); SetCellBackgroundColour(nRow,0,cBG); pRow++; } SetCellTextColour( (int)ROW_ATTN,0,pParm->GetStatusForeground(true)); SetCellBackgroundColour( (int)ROW_ATTN,0,pParm->GetStatusBackground(true)); SetCellTextColour( (int)ROW_OK,0,pParm->GetStatusForeground(false)); SetCellBackgroundColour( (int)ROW_OK,0,pParm->GetStatusBackground(false)); }
/* void CGridAnalysis::SetCellStyle( int nRow, int nCol, bool bBold, bool bItal,bool bHasAlert) { wxFont *pFont(NULL); if(bBold) { pFont = bItal ? &m_fontBoldItalic : &m_fontBold; SetCellFont(nRow,nCol,*pFont); SetCellBackgroundColour(nRow,nCol,m_bgBold); SetCellTextColour(nRow,nCol,m_fgBold); } else { wxColour *pcolor = bHasAlert ? &m_bgRowHasAlert : &m_bgNormal; pFont = bItal ? &m_fontItalic : &m_fontNormal; SetCellFont(nRow,nCol,*pFont); SetCellBackgroundColour(nRow,nCol,*pcolor); SetCellTextColour(nRow,nCol,m_fgNormal); } } */ void CGridAnalysis::SetCellStyle( int nRow, int nCol, GRID_FLAG nFlag) { const int BOLD = 1; const int ITALIC = 2; const int BOLD_ITALIC = 3; int n = 0; wxFont *pFont = NULL; CParmOsiris *pParm(CParmOsiris::GetGlobal()); const wxColour &cFG(pParm->GetForeground(nFlag)); const wxColour &cBG(pParm->GetBackground(nFlag)); const wxColour *pcFG(&cFG); const wxColour *pcBG(&cBG); if(pParm->IsGridBold(nFlag)) { n |= BOLD; } if(pParm->IsGridItalic(nFlag)) { n |= ITALIC; } switch(n) { case BOLD: pFont = &m_fontBold; break; case ITALIC: pFont = &m_fontItalic; break; case BOLD_ITALIC: pFont = &m_fontBoldItalic; break; default: pFont = &m_fontNormal; break; } SetCellFont(nRow,nCol,*pFont); if(pParm->IsGridReverse(nFlag)) { pcFG = &cBG; pcBG = &cFG; } SetCellBackgroundColour(nRow,nCol,*pcBG); SetCellTextColour(nRow,nCol,*pcFG); }
void DataGrid::setRow(int row) { SetCellAlignment(wxALIGN_RIGHT, row, IncomeIndex); SetCellAlignment(wxALIGN_RIGHT, row, OutlayIndex); SetCellAlignment(wxALIGN_RIGHT, row, BalanceIndex); SetReadOnly(row, IncomeIndex, false); SetReadOnly(row, OutlayIndex, false); SetReadOnly(row, DescIndex, false); SetReadOnly(row, CommentIndex, false); SetReadOnly(row, BalanceIndex); SetCellEditor(row, IncomeIndex, new wxGridCellFloatEditor(MONEY_LEN, 2)); SetCellEditor(row, OutlayIndex, new wxGridCellFloatEditor(MONEY_LEN, 2)); clearRow(row); for (int i = 0; i < ColumnNum; i++) { SetCellFont(row, i, GetDefaultCellFont()); SetCellTextColour(row, i, GetDefaultCellTextColour()); } }
void ctlVarWindow::addVar( wxString name, wxString value, wxString type, bool readOnly ) { // If this is a 'hidden' variable, just ignore it if( m_hiddenNames.find( name ) != m_hiddenNames.end()) return; if( m_hiddenTypes.find( type ) != m_hiddenTypes.end()) return; if( m_cells == NULL ) { // This is the first variable we're adding to this grid, // layout the grid and set the column headers. m_cells = new wsCellHash; } // Try to find an existing grid cell for this variable... wxString key( name ); wsCellHash::iterator cell = m_cells->find( key ); if( cell == m_cells->end()) { // Can't find this variable in the grid, go ahead and add it gridCell newCell; newCell.m_row = m_cells->size(); newCell.m_type = type; newCell.m_value = value; AppendRows( 1 ); SetRowLabelValue( newCell.m_row, key ); SetCellValue( newCell.m_row, COL_NAME, key ); SetCellValue( newCell.m_row, COL_TYPE, type ); SetCellValue( newCell.m_row, COL_VALUE, value ); SetCellFont( newCell.m_row, COL_NAME, m_nameFont ); SetReadOnly( newCell.m_row, COL_NAME, true ); SetReadOnly( newCell.m_row, COL_TYPE, true ); SetReadOnly( newCell.m_row, COL_VALUE, readOnly ); (*m_cells)[key] = newCell; } else { // This variable is already in the grid, update the value // and hilite it so the user knows that it has changed. cell->second.m_value = value; if( GetCellValue( cell->second.m_row, COL_VALUE ).IsSameAs( value )) SetCellTextColour( cell->second.m_row, COL_VALUE, *wxBLACK ); else SetCellTextColour( cell->second.m_row, COL_VALUE, *wxRED ); SetCellValue( cell->second.m_row, COL_VALUE, value ); // FIXME: why is this part conditional? // FIXME: why do we need this code? can the type ever change? if( GetCellValue( cell->second.m_row, COL_TYPE) == wxT( "" )) { SetCellValue( cell->second.m_row, COL_TYPE, type ); } } // AutoSizeColumns( false ); }
void CGridAnalysis::UpdateGrid( COARfile *pFile, COARsampleSort *pSort, int nLabelType, int nLabelTypeName, const wxDateTime *pHistory, wxDC *pDC) { nwxGridBatch xBatch(this); wxDC *pDCuse = (pDC != NULL) ? pDC : GetDC(); DCholder xx(this,pDCuse); wxString sChannel; wxString sCell; int iRow; int nCol; int nReviewCount; int nAcceptCount; int nReviewNeeded; int nAcceptNeeded; size_t nRowCount = pSort->GetCount(); size_t nAlleleColCount = pFile->GetLocusCount(); size_t i; COARlocus *pLocus; COARsample *pSample; const COARmessages *pMsgs = pFile->GetMessages(); GRID_FLAG flagBase; GRID_FLAG flag; bool bAlert; bool bEdited; bool bSampleHasAlert; bool bSampleEdited; bool bNeedsAttention; bool bSampleDisabled; m_nLabelSize = 0; m_nLabelType = nLabelTypeName; #if 0 // moved to next loop // Set up row labels for(iRow = 0; iRow < (int)nRowCount; ++iRow) { pSample = pSort->GetSample((size_t)iRow); sName = pSample->GetName(); if(pSample->IsSampleLevelEdited(pFile->GetMessages(),pHistory)) { sName.Append(COARsample::g_sCellChannelEdited); } SetRowLabel(iRow,sName); } #endif // set up cells pFile->GetReviewerCounts(&nReviewNeeded,&nAcceptNeeded,CLabReview::REVIEW_SAMPLE); for(iRow = 0; iRow < (int)nRowCount; ++iRow) { // setup sample info flagBase = GRID_NORMAL; bNeedsAttention = false; pSample = pSort->GetSample((size_t)iRow); bSampleHasAlert = pSample->HasAnyAlerts(pMsgs,pHistory); bSampleEdited = pSample->IsEdited(pMsgs,pHistory); bSampleDisabled = pSample->IsDisabled(pHistory); const COARsampleReviewAccept &accept(pSample->GetAcceptance()); const COARsampleReviewAccept &review(pSample->GetReviews()); if(bSampleDisabled) { flagBase |= GRID_DISABLED; } else { if(bSampleHasAlert) { flagBase |= GRID_ALERT_SAMPLE; } if(bSampleEdited) { flagBase |= GRID_EDITED_SAMPLE; } } // Setup Row Label for sample bEdited = pSample->IsSampleLevelEdited(pMsgs,pHistory); bAlert = pSample->HasSampleAlert(pMsgs,pHistory); nAcceptCount = accept.GetSampleCount(pHistory); nReviewCount = review.GetSampleCount(pHistory); _SetupCellFlag( flagBase, bSampleDisabled,bEdited,bAlert, nAcceptCount, nAcceptNeeded, nReviewCount, nReviewNeeded, &flag,&bNeedsAttention); SetupRowLabel(pSample,iRow,nLabelTypeName,bEdited,bNeedsAttention); // ILS alert column bAlert = bSampleHasAlert && pSample->HasILSAlert(pMsgs,pHistory); bEdited = pSample->IsCellILSEdited(pMsgs,pHistory); nAcceptCount = accept.GetILSCount(pHistory); nReviewCount = review.GetILSCount(pHistory); pFile->GetReviewerCounts(&nReviewNeeded,&nAcceptNeeded,CLabReview::REVIEW_ILS); _SetupCellFlag( flagBase, bSampleDisabled,bEdited,bAlert, nAcceptCount, nAcceptNeeded, nReviewCount, nReviewNeeded, &flag,&bNeedsAttention); SetCellValue(iRow,CFrameAnalysis::ILS_COLUMN,pSample->GetCellILS(pMsgs,pHistory)); SetCellStyle( iRow,CFrameAnalysis::ILS_COLUMN,flag); // channel alert column sChannel = pSample->GetCellChannel(pMsgs,pHistory); bAlert = bSampleHasAlert && COARsample::HasChannelAlert(sChannel); bEdited = bSampleEdited && pSample->IsCellChannelEdited(pMsgs,pHistory); nAcceptCount = accept.GetChannelCount(pHistory); nReviewCount = review.GetChannelCount(pHistory); pFile->GetReviewerCounts(&nReviewNeeded,&nAcceptNeeded,CLabReview::REVIEW_CHANNEL); _SetupCellFlag( flagBase, bSampleDisabled,bEdited,bAlert, nAcceptCount, nAcceptNeeded, nReviewCount, nReviewNeeded, &flag,&bNeedsAttention); SetCellValue(iRow,CFrameAnalysis::CHANNEL_ALERT_COLUMN,sChannel); SetCellStyle(iRow,CFrameAnalysis::CHANNEL_ALERT_COLUMN,flag); SetReadOnly(iRow,CFrameAnalysis::ILS_COLUMN,true); SetReadOnly(iRow,CFrameAnalysis::CHANNEL_ALERT_COLUMN,true); SetReadOnly(iRow,CFrameAnalysis::STATUS_COLUMN,true); pFile->GetReviewerCounts(&nReviewNeeded,&nAcceptNeeded,CLabReview::REVIEW_LOCUS); for(i = 0, nCol = CFrameAnalysis::FIRST_LOCUS_COLUMN; i < nAlleleColCount; ++i, ++nCol) { SetReadOnly(iRow,nCol,true); pLocus = pSample->FindLocus(pFile->GetLocusName(i)); if(pLocus != NULL) { sCell = pLocus->GetCell(nLabelType,pHistory); bAlert = bSampleHasAlert && pLocus->HasAlerts(pMsgs,pHistory); const COARchannel *pChannel = pFile->GetChannelFromLocus(pLocus->GetName()); int nChannel = pChannel->GetChannelNr(); nAcceptCount = pLocus->GetAcceptanceCount(pHistory); nReviewCount = pLocus->GetReviewCount(pHistory); bEdited = pLocus->HasBeenEdited( pMsgs,pSample,nChannel,pHistory); _SetupCellFlag(flagBase, bSampleDisabled,bEdited,bAlert, nAcceptCount,nAcceptNeeded, nReviewCount,nReviewNeeded, &flag,&bNeedsAttention); if(sCell.IsEmpty()) { if(bAlert) { sCell = _T("?"); } else if(bEdited) { sCell = COARsample::g_sCellChannelEdited; } } SetCellValue(iRow,nCol,sCell); SetCellStyle(iRow,nCol,flag); } else { SetCellValue(iRow,nCol,wxEmptyString); SetCellStyle(iRow,nCol,flagBase); } } // setup control cell SetReadOnly(iRow,nCol,true); SetCellValue(iRow,nCol,pSample->GetPositiveControl()); SetCellStyle(iRow,nCol,flagBase); // setup status cell SetReadOnly(iRow,CFrameAnalysis::STATUS_COLUMN,true); if(bSampleDisabled) { SetCellValue(iRow,CFrameAnalysis::STATUS_COLUMN,_T("")); SetCellStyle(iRow,CFrameAnalysis::STATUS_COLUMN,flagBase); } else { CParmOsirisGlobal parm; const wxColour &clFg(parm->GetStatusForeground(bNeedsAttention)); const wxColour &clBg(parm->GetStatusBackground(bNeedsAttention)); const wxString &s( bNeedsAttention ? g_sStatusNeedsAttention : g_sStatusOK); SetCellValue(iRow,CFrameAnalysis::STATUS_COLUMN,s); SetCellFont(iRow,CFrameAnalysis::STATUS_COLUMN,g_fontStatus); SetCellBackgroundColour(iRow,CFrameAnalysis::STATUS_COLUMN,clBg); SetCellTextColour(iRow,CFrameAnalysis::STATUS_COLUMN,clFg); SetCellAlignment( iRow,CFrameAnalysis::STATUS_COLUMN, wxALIGN_CENTRE,wxALIGN_CENTRE); SetCellAlignment( iRow,CFrameAnalysis::ILS_COLUMN, wxALIGN_CENTRE,wxALIGN_CENTRE); } } AutoSize(); UpdateLabelSize(); }
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; }