long CTWenUGCtrlEx::RowIndexOfMinValue(bool emptyFirst, int col, long rowFrom, long rowTo) { long index = rowFrom; CString minValue; QuickGetText(col, index, &minValue); if(minValue.IsEmpty() && emptyFirst) return index; CString si; for(long i=rowFrom+1; i<=rowTo; i++) { QuickGetText(col, i, &si); if(si.IsEmpty()) { if(emptyFirst) return i; else continue; } if(minValue.IsEmpty() || (_tstof(minValue) > _tstof(si))) { minValue = si; index = i; } } return index; }
void CLayerTypeGrid::OnDClicked(int col,long row, RECT *rect,POINT *point,BOOL processed) { int lastColIndx = GetNumberCols() - 1; CString cellText(QuickGetText(lastColIndx, row)); int layerType = atoi(cellText); // Edit color if a layerType row (not a group name row) // and double click was not in the layer type column. if (layerType > -1 && col > 0) { CUGCell cell; GetCell(col, row, &cell); COLORREF color = cell.GetBackColor(); // current color CPersistantColorDialog dialog(color); if (dialog.DoModal() == IDOK) { color = dialog.GetColor(); cell.SetBackColor(color); SetCell(col, row, &cell); RedrawAll(); } } }
void CLayerTypeGrid::ExpandLayerGroup(int groupNameRowIndx) { int rowCnt = GetNumberRows(); int lastColIndx = GetNumberCols() - 1; bool keepGoing = true; for (int rowIndx = groupNameRowIndx+1; rowIndx < rowCnt && keepGoing; rowIndx++) { CString cellText( QuickGetText(lastColIndx, rowIndx) ); int layerType = atoi(cellText); if (layerType < 0) { keepGoing = false; } else { SetRowHeight(rowIndx, m_expandedRowHeight); } } CString groupNameText( QuickGetText(0, groupNameRowIndx) ); groupNameText.SetAt(0, '-'); // Is now expanded, show operator to collapse. QuickSetText(0, groupNameRowIndx, groupNameText); }
void CLayerTypeGrid::OnLClicked(int col,long row, int updn, RECT *rect, POINT *point, int processed) { // A click will get two event calls here, one for button down (updn = true) and one // for button up. We don't want to do this twice for a single click. // So react only to the button up, that is the end of the click event. if (updn) return; // Ignore the button down. int lastColIndx = GetNumberCols() - 1; CString cellText(QuickGetText(lastColIndx, row)); int layerType = atoi(cellText); // Toggle expand/collapse if layer type indicates this is a layer group row. // React only if cell was first column cell. if (layerType < 0 && col == 0) { int rowCnt = GetNumberRows(); CUGCell cell; GetCell(col, row, &cell); // We use the "+" and "-" in name to track expanded/collapsed state. // The char shows the current state. CString groupNameText( cell.GetText() ); bool isExpanded = (groupNameText.Left(1).Compare("-") == 0); if (isExpanded) { // Is expanded, perform collapse. CollapseLayerGroup(row); RedrawAll(); } else { // Is collapsed, perform expand. ExpandLayerGroup(row); RedrawAll(); } } }