//清除上次选中行 void QuoteTableCtrlGeneralSort::RefreshWnd() { COLORREF color = GetGridBkColor(); CRect rectCell, rectRow; CCellID cell = GetCellFromPt(m_LastDownPoint); CGridCellBase* pCell = GetCell(cell.row, cell.col); BOOL bInTextArea = FALSE; if (pCell) { if (GetCellRect(cell.row, cell.col, rectCell) && pCell->GetTextRect(rectCell)) { bInTextArea = rectCell.PtInRect(m_LastDownPoint); } } if ( bInTextArea ) { for (int i=0; i<GetColumnCount(); i++) { pCell = GetCell(cell.row, i); /* pCell->GetBackClr();*/ if (pCell) { pCell->SetState(/*pCell->GetState() | */m_iColProp->GetColumnMask(GetHeadID(i))); pCell->SetBackClr(color); } } } Invalidate(); }
void GMassMobAppearGrid::SaveParse(GStageLevel* pStage) { CGridCellBase* cell = NULL; GtLongNumberString num; for( gint i = 1 ; i < GetRowCount() ; i++ ) { GStageLevel::MassAppearMob mob; cell = GetCell( i, 0 ); num.SetNumber( (gtchar*)cell->GetText() ); mob.mIndex = (guint32)num.GetNumber( 0 ); cell = GetCell( i, 1 ); num.SetNumber( (gtchar*)cell->GetText() ); mob.mLevel = (guint32)num.GetNumber( 0 ); cell = GetCell( i, 2 ); num.SetNumber( (gtchar*)cell->GetText() ); mob.mNumLine = (guint32)num.GetNumber( 0 ); cell = GetCell( i, 3 ); num.SetNumber( (gtchar*)cell->GetText() ); mob.mNumMobCount = (guint32)num.GetNumber( 0 ); pStage->AddMassAppearMob( mob ); } }
void CResiduePane::OnSelectionChanged(NMHDR* pNMHDR, LRESULT* pResult) {; NM_GRIDVIEW * pnmgv = (NM_GRIDVIEW *)pNMHDR; if (pnmgv!=NULL && m_residueGridCtrl !=NULL && m_residueGridCtrl->GetSelectedCount() > 0 ) { if ( pnmgv->iRow >= 0 && pnmgv->iColumn >= 0 ) { CGridCellBase* grid = m_residueGridCtrl->GetCell(pnmgv->iRow,pnmgv->iColumn); if(grid==NULL) return; m_pProteinVistaRenderer->m_pLastPickObjectInst = (CProteinObjectInst*)grid->GetData(); }else { CCellRange range = m_residueGridCtrl->GetSelectedCellRange(); int row = range.GetMinRow(); int col = range.GetMinCol(); if ( row >= 0 && col >= 0 ) { m_pProteinVistaRenderer->m_pLastPickObjectInst = (CProteinObjectInst*)m_residueGridCtrl->GetCell(row,col)->GetData(); //m_pProteinVistaRenderer->m_pLastPickObjectInst-> } } m_bSelectionChanged = TRUE; } }
/****************************************************************************** @author humkyung @date 2012-07-10 @class CBusToBusView @function OnNotify @return BOOL @param WPARAM wParam @param LPARAM lParam @param LRESULT* pResult @brief ******************************************************************************/ BOOL CBusToBusView::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) { if(wParam == m_wndGridCtrl.GetDlgCtrlID()) { NM_GRIDVIEW* pGridView = (NM_GRIDVIEW*)(lParam); if((GVN_ENDLABELEDIT == pGridView->hdr.code) && (1 == pGridView->iColumn)) { CGridCellBase* pCell = m_wndGridCtrl.GetCell(pGridView->iRow, pGridView->iColumn); CString sFromBus = pCell->GetText(); CGridCellBusCombo* pBusCombo = (CGridCellBusCombo*)m_wndGridCtrl.GetCell(pGridView->iRow, pGridView->iColumn + 1); CString sToBus = pBusCombo->GetText(); if(sFromBus == sToBus) { AfxMessageBox(_T("From and To Bus are same") , MB_OK | MB_ICONWARNING); m_wndGridCtrl.SetSelectedRange(pGridView->iRow , pGridView->iColumn,pGridView->iRow , pGridView->iColumn); m_wndGridCtrl.SetFocusCell(pGridView->iRow , pGridView->iColumn); return TRUE; } pBusCombo->m_sFromBus = sFromBus; GetDocument()->SetModifiedFlag(TRUE); } return TRUE; } return CView::OnNotify(wParam, lParam, pResult); }
void QuoteTableCtrlGeneralSort::DrawTitle() { CGridCellBase* pCell; for (int col =0; col<GetColumnCount(); col++) { pCell = GetCell(0, col); pCell->SetText(""); } }
void CYTGridCtrl::SetSelectClr(COLORREF clr) { for (int row = 0; row < GetRowCount(); row++) { for(int col =0; col < GetColumnCount(); col++) { CGridCellBase* pCell = GetCell(row, col); pCell->SetSelectColor(clr); } } }
void CInstrumentGridCtrl::InsertInstrument(int rowIndex, const Instrument& instrument){ int columnIndex = 0; GV_ITEM item; item.mask = GVIF_TEXT; item.row = rowIndex; item.col = columnIndex; item.strText = DataConverter::ConvertIntToString(rowIndex).c_str(); this->SetItem(&item); columnIndex++; item.col = columnIndex; item.strText = instrument.GetInstrumentType().c_str(); this->SetItem(&item); this->SetItemState(rowIndex, columnIndex, GVIS_READONLY); columnIndex++; item.col = columnIndex; item.strText = instrument.GetInstrumentName().c_str(); this->SetItem(&item); this->SetItemState(rowIndex, columnIndex, GVIS_READONLY); columnIndex++; item.col = columnIndex; item.strText = instrument.GetInstrumentCode().c_str(); this->SetItem(&item); this->SetItemState(rowIndex, columnIndex, GVIS_READONLY); columnIndex++; item.col = columnIndex; item.strText = DataConverter::ConvertIntToString(instrument.GetContract().GetFeedingSourceID()).c_str(); this->SetItem(&item); this->SetItemState(rowIndex, columnIndex, GVIS_READONLY); columnIndex++; item.col = columnIndex; item.strText = DataConverter::ConvertIntToString(instrument.GetLimitOrderBook().GetFeedingSourceID()).c_str(); this->SetItem(&item); this->SetItemState(rowIndex, columnIndex, GVIS_READONLY); columnIndex++; for(int i=0; i<this->columnCount; i++){ CGridCellBase* cellBase = this->GetCell(rowIndex, i); LOGFONT* tempLogFont = cellBase->GetFont(); tempLogFont->lfHeight= this->fontSize; cellBase->SetFont(tempLogFont); } }
/** @brief @author */ int CGridCtrlEx::MultiCompare(const int& lhs, const int& rhs) { int nIndex = 0; for(vector<int>::iterator itr = m_MultiSortCellNoEntry.begin();itr != m_MultiSortCellNoEntry.end();++itr,++nIndex) { if(-1 == (*itr)) continue; CGridCellBase* pLhsCell = GetCell(lhs , *itr); CGridCellBase* pRhsCell = GetCell(rhs , *itr); int res = _tcscmp(pLhsCell->GetText() , pRhsCell->GetText()); if(0 != res) { return (0 == m_MultiSortDirEntry[nIndex]) ? res : -res; } } return 0; }
void CInstrumentGridCtrl::InitHeader(){ const tchar* columnTitles[] = {_T("Type"), _T("Name"), _T("Code"), _T("Contract"), _T("LimitOrderBook")}; const COLORREF GREY = RGB(160, 160, 160); int colCount = this->GetColumnCount(); for (int i = 0; i < colCount; i++){ GV_ITEM item; item.mask = GVIF_TEXT; item.row = 0; item.col = i; item.crBkClr = GREY; item.strText = columnTitles[i]; BOOL temp = this->SetItem(&item); CGridCellBase* cellBase = this->GetCell(0, i); LOGFONT* tempLogFont = cellBase->GetFont(); tempLogFont->lfHeight= this->fontSize;; cellBase->SetFont(tempLogFont); } }
void QuoteTableCtrlGeneralSort::OnLButtonDown(UINT nFlags, CPoint point) { /*CHSGridCtrl::OnLButtonDown(nFlags, point);*/ SetFocus(); RefreshWnd(); RefreashOtherWnd(g_LastSelectWnd); g_LastSelectWnd = m_pTableFlag->nIndex; CRect rectCell, rectRow; CCellID cell = GetCellFromPt(point); if (cell.row == 0) return; CGridCellBase* pCell = GetCell(cell.row, cell.col); BOOL bInTextArea = FALSE; if (pCell) { if (GetCellRect(cell.row, cell.col, rectCell) && pCell->GetTextRect(rectCell)) { bInTextArea = rectCell.PtInRect(point); } } COLORREF selectbk = RGB(100,100,100); if ( bInTextArea ) { for (int i=0; i<GetColumnCount(); i++) { pCell = GetCell(cell.row, i); if (pCell) { pCell->SetState(pCell->GetState() | m_iColProp->GetColumnMask(GetHeadID(i))| GVIS_SELECTED); pCell->SetSelectColor(selectbk); } } } Invalidate(); m_LastDownPoint = point; }
void CDBSchemaTableView::OnBtnMergeClicked() { int iSelectedRowCount = 0; int iSelectedRows[2]; for(int i = GRIDHEADERROWCOUNT; i < GridTab.GetRowCount(); ++i) { CGridCellBase* pCell = GridTab.GetCell(i, 0); if(CEditStyleBool::GetInstance().strTrue == pCell->GetText()) { iSelectedRows[iSelectedRowCount++] = i - GRIDHEADERROWCOUNT; if(iSelectedRowCount >= 2) break; } } if(iSelectedRowCount == 2) { GetDocument()->MergeTable(iSelectedRows[0], iSelectedRows[1]); } iSelectedRowCount = 0; for(int i = GRIDHEADERROWCOUNT; i < GridCol.GetRowCount(); ++i) { CGridCellBase* pCell = GridCol.GetCell(i, 0); TTRACE(pCell->GetText()); if(CEditStyleBool::GetInstance().strTrue == pCell->GetText()) { iSelectedRows[iSelectedRowCount++] = i - GRIDHEADERROWCOUNT; if(iSelectedRowCount >= 2) break; } } if(iSelectedRowCount == 2) { GetDocument()->MergeColumn(GridTabViewer.GetCurRecord(0), iSelectedRows[0], iSelectedRows[1]); } }
void CGridCellBase::operator=(CGridCellBase& cell) { if (this == &cell) return; SetGrid(cell.GetGrid()); // do first in case of dependencies SetText(cell.GetText()); SetImage(cell.GetImage()); SetData(cell.GetData()); SetState(cell.GetState()); SetFormat(cell.GetFormat()); SetTextClr(cell.GetTextClr()); SetBackClr(cell.GetBackClr()); SetFont(cell.IsDefaultFont()? NULL : cell.GetFont()); SetMargin(cell.GetMargin()); //Used for merge cells //by Huang Wei SetMergeCellID(cell.GetMergeCellID()); SetMergeRange(cell.GetMergeRange()); Show(cell.IsShow()); }
void CResiduePane::SetGridCtrlText() { CSTLArrayPDBRenderer & arrayPDBRenderer = m_pProteinVistaRenderer->m_arrayPDBRenderer; if ( arrayPDBRenderer.size() == 0 ) return; long vertIndex = 0; for ( int iPDB = 0; iPDB < arrayPDBRenderer.size() ; iPDB++ ) { CPDBInst * pPDBInst = arrayPDBRenderer[iPDB]->GetPDBInst(); for ( int iModel = 0 ; iModel < pPDBInst->m_arrayModelInst.size() ; iModel ++ ) { CModelInst * pModelInst = pPDBInst->m_arrayModelInst[iModel]; long nChain = pModelInst->m_arrayChainInst.size(); for ( int iChain = 0 ; iChain < nChain ; iChain ++ ) { CChainInst * pChainInst = pPDBInst->GetChainInst(iModel ,iChain); CGridCellBase * pCell = m_residueGridCtrl->GetCell(vertIndex, 0 ); if ( pCell != NULL ) { if ( pPDBInst->m_arrayModelInst.size() == 1 ) { pCell->SetText(pChainInst->GetChain()->m_strPDBID); } else { CString strChain; strChain.Format("[%d]%s", iModel, pChainInst->GetChain()->m_strPDBID); pCell->SetText(strChain); } pCell->SetData((LPARAM)(pChainInst)); } for ( int j = 0 ; j < pChainInst->m_arrayResidueInst.size() ; j++ ) { CGridCellBase * pCell = m_residueGridCtrl->GetCell(vertIndex, j+1); if ( pCell != NULL ) { BOOL selectColor = 30; long ss = pChainInst->m_arrayResidueInst[j]->GetResidue()->GetSS(); if ( ss == SS_NONE ) pCell->SetBackClr(RGB(min(180+selectColor,255), min(180+selectColor,255) , min(180+selectColor,255) )); else if ( ss == SS_HELIX ) pCell->SetBackClr(RGB(min(180+selectColor,255), min(selectColor,255), min(selectColor,255) )); else if ( ss == SS_SHEET ) pCell->SetBackClr(RGB(min(selectColor,255) ,min (180+selectColor, 255) ,min(selectColor,255) )); CString strText; CResidueInst * pResidueInst = pChainInst->m_arrayResidueInst[j]; if ( m_displayStyle == 0 ) strText.Format("%s" , pResidueInst->GetResidue()->m_residueNameOneChar); if ( m_displayStyle == 1 ) strText.Format("%d %s" , pResidueInst->GetResidue()->GetResidueNum(), pResidueInst->GetResidue()->m_residueNameOneChar ); if ( m_displayStyle == 2 ) strText.Format("%d(%d) %s" , pResidueInst->GetResidue()->GetResidueNum(), j, pResidueInst->GetResidue()->m_residueNameOneChar ); if ( m_displayStyle == 3 ) strText.Format("%s" , pResidueInst->GetResidue()->GetResidueName() ); if ( m_displayStyle == 4 ) strText.Format("%d %s" , pResidueInst->GetResidue()->GetResidueNum(), pResidueInst->GetResidue()->GetResidueName() ); if ( m_displayStyle == 5 ) strText.Format("%d(%d) %s" , pResidueInst->GetResidue()->GetResidueNum(), j, pResidueInst->GetResidue()->GetResidueName() ); pCell->SetText(strText); pCell->SetData((LPARAM)(pResidueInst)); } } vertIndex ++; } } } }
void CGridCellBase::operator=(const CGridCellBase& cell) { if (this == &cell) return; SetGrid(cell.GetGrid()); // do first in case of dependencies SetText(cell.GetText()); SetImage(cell.GetImage()); SetData(cell.GetData()); SetState(cell.GetState()); SetFormat(cell.GetFormat()); SetTextClr(cell.GetTextClr()); SetBackClr(cell.GetBackClr()); SetFont(cell.IsDefaultFont()? NULL : cell.GetFont()); SetMargin(cell.GetMargin()); }
/***************************************************************************** This may delete one or more rows depending on the makeup of the tree branch. It's analagous to deleting a file directory with all files and sub-directories deleted, too. *****************************************************************************/ int CTreeColumn::DeleteTreeBranch( int aiRow, // Row that the tree branch begins on BOOL abRedraw) // T=redraw; F=don't // returns: nbr of rows deleted { ASSERT( aiRow >= -1); ASSERT( m_pGrid != NULL); // Must call TreeSetup(), first if( aiRow < m_iFixedRowCount || aiRow >= m_iRowCount) return 0; int iRowDeleteCount = 0; m_bAllowDraw = FALSE; // prevents crash during reset // get level of initial row to delete from tree CGridTreeCell* pGridTreeCell = (CGridTreeCell*)m_pGrid->GetCell( aiRow, m_iColumnWithTree); unsigned char ucLevelCurrent = CHAR_MAX; if( pGridTreeCell != NULL) { // delete just the parent ucLevelCurrent = pGridTreeCell->GetLevel(); if( m_pGrid->DeleteRow( aiRow) ) { iRowDeleteCount++; m_iRowCount--; } } // see if any children need to be deleted, too unsigned char ucLevel; while( aiRow < m_iRowCount) { pGridTreeCell = (CGridTreeCell*)m_pGrid->GetCell( aiRow, m_iColumnWithTree); if( pGridTreeCell == NULL) break; ucLevel = pGridTreeCell->GetLevel(); if( ucLevel <= ucLevelCurrent) break; if( !m_pGrid->DeleteRow( aiRow) ) break; iRowDeleteCount++; m_iRowCount--; } ASSERT( m_iRowCount == m_pGrid->GetRowCount() ); // have to re-number all cells below deletion point if( iRowDeleteCount > 0) { int iRow; int iColumnCount = m_pGrid->GetColumnCount(); for( iRow=aiRow; iRow < m_iRowCount; iRow++) { int iCol; for (iCol = 0; iCol < iColumnCount; iCol++) { CGridCellBase* pGridCellBase = m_pGrid->GetCell( iRow, iCol); if( pGridCellBase != NULL) { pGridCellBase->SetCoords( iRow, iCol); } } } } m_bAllowDraw = TRUE; TreeRefreshRows(); if( abRedraw) m_pGrid->Invalidate(); return iRowDeleteCount; }
/***************************************************************************** 3/2001: Allows one to add to the existing tree structure. Repeatedly calling TreeSetup() with different tree configurations was the only way to change the tree structure with the original implementation, but had the disadvantage of destroying cell contents. The original implementation forced you to NOT store data directly in grid cells if you wished to change the tree. No validation of the tree branch "levels" done. Drawing code assumes a parent / child relationship of tree nodes. Thus, if the lines of the tree don't look right, make sure that the parent / child relationship is not violated. *****************************************************************************/ int CTreeColumn::InsertTreeBranch( const unsigned char* apucTreeLevelAry, // Tree Level data array -- // must have aiNbrElements of entries int aiNbrElements, // NUmber of tree elements to add int aiRow, // insert tree elements beginning at this row // If -1, append to end; If 0, Insert // at top no matter how many fixed rows BOOL abRedraw) // T=redraw; F=don't // returns: row where elements inserted; -1 on error { ASSERT( apucTreeLevelAry != NULL); ASSERT( aiNbrElements >= 0); ASSERT( aiRow >= -1); ASSERT( m_pGrid != NULL); // Must call TreeSetup(), first ASSERT( m_iFixedRowCount >= 0); ASSERT( m_pRuntimeClassTreeCell != NULL); if( aiNbrElements <= 0) return -1; // if user specified 0 or -1, adjust int iRowForAppend = 0; if( m_iRowCount <= m_iFixedRowCount) aiRow = -1; // if no non-fixed rows, then gotta append if( aiRow <= -1) { iRowForAppend = -1; aiRow = m_iRowCount; } else if( aiRow < m_iFixedRowCount) aiRow = m_iFixedRowCount; m_bAllowDraw = FALSE; // prevents crash during reset // retain old cell properties: establishes size for // tree drawing box based on current font CGridTreeCell GridCellCopy; GridCellCopy.SetTreeColumn( this); CGridCellBase* pCurrCell = m_pGrid->GetCell( m_iRowCount-1, m_iColumnWithTree); if (pCurrCell) GridCellCopy = *pCurrCell; // insert rows while replacing tree column cells to tree cell type int iCellRow = aiRow; int i1; for( i1=0; i1 < aiNbrElements; i1++) { // CGridCtrl's InsertRow() requires a -1 to append values to // the end of the grid if( iRowForAppend != -1) iRowForAppend = iCellRow; if( m_pGrid->InsertRow( "", iRowForAppend) < 0) { aiRow = -1; // error break; } if( !m_pGrid->SetCellType( iCellRow, m_iColumnWithTree, m_pRuntimeClassTreeCell ) ) { aiRow = -1; // error break; } CGridTreeCell* pGridTreeCell = (CGridTreeCell*)m_pGrid->GetCell( iCellRow, m_iColumnWithTree); if( pGridTreeCell != NULL) { pGridTreeCell->SetTreeColumn( this); pGridTreeCell->SetLevelAndHide( *apucTreeLevelAry ); pGridTreeCell->SetViewable( TRUE); } iCellRow++; m_iRowCount++; apucTreeLevelAry++; } ASSERT( m_iRowCount == m_pGrid->GetRowCount() ); // have to re-number all cells below insertion point if( aiRow > 0) { int iRow; int iColumnCount = m_pGrid->GetColumnCount(); for( iRow=iCellRow; iRow < m_iRowCount; iRow++) { int iCol; for (iCol = 0; iCol < iColumnCount; iCol++) { CGridCellBase* pGridCellBase = m_pGrid->GetCell( iRow, iCol); if( pGridCellBase != NULL) { pGridCellBase->SetCoords( iRow, iCol); } } } } m_bAllowDraw = TRUE; TreeRefreshRows(); if( abRedraw) m_pGrid->Invalidate(); return aiRow; }