void CLayerTypeDlg::fillLayerColorsInGrid() { int lastColIndx = m_layerTypeGrid.GetNumberCols() - 1; int rowCnt = m_layerTypeGrid.GetNumberRows(); for (int layerSet=0; layerSet<MAX_LAYERSETS; layerSet++) { for (int row=0; row < rowCnt; row++) { // get the layer type in the last column (hidden) CString layerTypeStrVal( m_layerTypeGrid.QuickGetText(lastColIndx, row) ); int layerTypeIntVal = atoi(layerTypeStrVal); if (layerTypeIntVal < 0) continue; LayerTypeStruct *lt = &pDoc->LayerTypeArray[layerSet][layerTypeIntVal]; int col = layerSet+1; m_layerTypeGrid.QuickSetBackColor(col, row, lt->color); CUGCell cell; m_layerTypeGrid.GetCell(col, row, &cell); cell.SetBool(lt->show); m_layerTypeGrid.SetCell(col, row, &cell); } } }
int CDDBaseGrid::QuickSetBool(int col, long row, bool val) { CUGCell cell; GetCell(col, row, &cell); cell.SetBool(val); SetCell(col, row, &cell); return UG_SUCCESS; }
/*************************************************** OnSetup This function is called just after the grid window is created or attached to a dialog item. It can be used to initially setup the grid ****************************************************/ void CRealTimeGrid::OnSetup(){ int y; int ROWS = 25; int COLS = 6; int iHeight; CUGCell cell; CString strTemp; CDC* pDC; m_pro1Index = AddCellType( &m_pro1 ); m_pro1.SetCanAdjust( FALSE ); m_buttonIndex = AddCellType( &m_button ); pDC = GetDC(); iHeight = -MulDiv( 10, GetDeviceCaps( pDC->m_hDC, LOGPIXELSY), 72 ); m_font1.CreateFont( iHeight,0,0,0,800,0,0,0,0,0,0,0,0, _T( "Arial" ) ); m_font2.CreateFont( iHeight,0,0,0,500,0,0,0,0,0,0,0,0, _T( "Arial" ) ); ReleaseDC( pDC ); SetDefFont(&m_font2); SetUniformRowHeight(TRUE); SetDefRowHeight(25); SetNumberCols(COLS); SetNumberRows(ROWS); SetDoubleBufferMode(1); Set3DHeight( 2 ); SetTH_Height( 0 ); SetSH_Width( 100 ); for( y = 0 ; y < ROWS ; y++ ) { QuickSetCellType(0,y,m_pro1Index); QuickSetAlignment(0,y,UG_ALIGNCENTER|UG_ALIGNVCENTER); QuickSetText( 0, y, _T( "20" ) ); QuickSetTextColor(0,y,RGB(0,0,0)); QuickSetHTextColor(0,y,RGB(0,0,0)); JoinCells(0,y,2,y); QuickSetAlignment(3,y,UG_ALIGNCENTER|UG_ALIGNVCENTER); QuickSetText(3,y,_T( "Normal" ) ); //QuickSetFont(3,y,&m_font2); strTemp.Format( _T( "Sensor %d" ), y ); QuickSetText( -1, y, strTemp ); } GetColDefault( 4, &cell ); cell.SetCellType( m_buttonIndex ); cell.SetText( _T( "Reset" ) ); cell.SetAlignment( UG_ALIGNCENTER | UG_ALIGNVCENTER ); cell.SetBackColor( GetSysColor( COLOR_BTNFACE ) ); SetColDefault( 4, &cell ); GetColDefault( 5, &cell ); cell.SetCellType( UGCT_CHECKBOX ); cell.SetLabelText( _T( "Enabled" ) ); cell.SetBool( TRUE ); cell.SetAlignment( UG_ALIGNVCENTER ); SetColDefault( 5, &cell ); SetColWidth( 5, GetColWidth( 5 ) + 20 ); SetTimer( TIMERID, 100, NULL); }