/* paints the progress bar */ void CBOINCGridCellProgressRenderer::DoProgressDrawing(wxGrid& grid, wxGridCellAttr& attr, wxDC& dc, const wxRect& rectCell, int row, int col, bool isSelected) { wxRect rect = rectCell; rect.Inflate(-1); // erase only this cells background, overflow cells should have been erased this->DrawBackground(grid, dc, rectCell, row, isSelected); // set text attributes int hAlign, vAlign; attr.GetAlignment(&hAlign, &vAlign); SetTextColoursAndFont(grid, attr, dc, isSelected); //calculate the two parts of the progress rect // double dv = 0.0; wxString strValue = grid.GetCellValue(row,col); if(m_bDoPercentAppending) { strValue = strValue + wxT(" %"); } // Project view uses the format: %0.0f (%0.2f%%) // Everyone else uses: %.3f%% if (strValue.Find(wxT("(")) != wxNOT_FOUND) { strValue.SubString(strValue.Find(wxT("(")) + 1, strValue.Find(wxT(")")) - 1).ToDouble( &dv ); } else { strValue.ToDouble ( &dv ); // NOTE: we should do error-checking/reporting here!! } wxRect p1(rect); wxRect p2(rect); int r = (int)((rect.GetRight()-rect.GetLeft())*dv / 100.0); p1.SetRight(rect.GetLeft()+r); p2.SetLeft(rect.GetLeft()+r+1); p2.SetRight(rect.GetRight()-1); //start drawing dc.SetClippingRegion(rect); wxBrush old = dc.GetBrush(); wxColour progressColour = wxTheColourDatabase->Find(wxT("LIGHT BLUE")); wxBrush* progressBrush = wxTheBrushList->FindOrCreateBrush(progressColour); wxPen* progressPen = wxThePenList->FindOrCreatePen(progressColour,1,wxSOLID); //draw the outline rectangle dc.SetBrush(*wxTRANSPARENT_BRUSH); dc.SetPen(*progressPen); dc.DrawRectangle(rect); // Draw the left part dc.SetBrush(*progressBrush); dc.DrawRectangle(p1); //draw the right part dc.SetBrush(old); dc.DrawRectangle(p2); // dc.DestroyClippingRegion(); // draw the text grid.DrawTextRectangle(dc, strValue, rect, hAlign, vAlign); }
void wxSheetCellAutoWrapStringRendererRefData::Draw(wxSheet& sheet, const wxSheetCellAttr& attr, wxDC& dc, const wxRect& rectCell, const wxSheetCoords& coords, bool isSelected) { wxSheetCellRendererRefData::Draw(sheet, attr, dc, rectCell, coords, isSelected); SetTextColoursAndFont(sheet, attr, dc, isSelected); int align = attr.GetAlignment(); int orient = attr.GetOrientation(); wxRect rect = rectCell; rect.Inflate(-1); sheet.DrawTextRectangle(dc, GetTextLines(sheet, dc, attr, rect, coords), rect, align, orient); }
void wxSheetCellEnumRendererRefData::Draw( wxSheet& sheet, const wxSheetCellAttr& attr, wxDC& dc, const wxRect& rectCell, const wxSheetCoords& coords, bool isSelected ) { wxSheetCellRendererRefData::Draw(sheet, attr, dc, rectCell, coords, isSelected); SetTextColoursAndFont(sheet, attr, dc, isSelected); // draw the text right aligned by default FIXME why? int align = attr.GetAlignment(); // | wxRIGHT; int orient = attr.GetOrientation(); wxRect rect = rectCell; rect.Inflate(-1); sheet.DrawTextRectangle(dc, GetString(sheet, coords), rect, align, orient); }
void wxGridCellFloatRenderer::Draw(wxGrid& grid, wxGridCellAttr& attr, wxDC& dc, const wxRect& rectCell, int row, int col, bool isSelected) { wxGridCellRenderer::Draw(grid, attr, dc, rectCell, row, col, isSelected); SetTextColoursAndFont(grid, attr, dc, isSelected); // draw the text right aligned by default int hAlign = wxALIGN_RIGHT, vAlign = wxALIGN_INVALID; attr.GetNonDefaultAlignment(&hAlign, &vAlign); wxRect rect = rectCell; rect.Inflate(-1); grid.DrawTextRectangle(dc, GetString(grid, row, col), rect, hAlign, vAlign); }
void wxGridCellAutoWrapStringRenderer::Draw(wxGrid& grid, wxGridCellAttr& attr, wxDC& dc, const wxRect& rectCell, int row, int col, bool isSelected) { wxGridCellRenderer::Draw(grid, attr, dc, rectCell, row, col, isSelected); // now we only have to draw the text SetTextColoursAndFont(grid, attr, dc, isSelected); int horizAlign, vertAlign; attr.GetAlignment(&horizAlign, &vertAlign); wxRect rect = rectCell; rect.Inflate(-1); grid.DrawTextRectangle(dc, GetTextLines(grid,dc,attr,rect,row,col), rect, horizAlign, vertAlign); }
void wxGridCellStringRenderer::Draw(wxGrid& grid, wxGridCellAttr& attr, wxDC& dc, const wxRect& rectCell, int row, int col, bool isSelected) { wxRect rect = rectCell; rect.Inflate(-1); // erase only this cells background, overflow cells should have been erased wxGridCellRenderer::Draw(grid, attr, dc, rectCell, row, col, isSelected); int hAlign, vAlign; attr.GetAlignment(&hAlign, &vAlign); int overflowCols = 0; if (attr.GetOverflow()) { int cols = grid.GetNumberCols(); int best_width = GetBestSize(grid,attr,dc,row,col).GetWidth(); int cell_rows, cell_cols; attr.GetSize( &cell_rows, &cell_cols ); // shouldn't get here if <= 0 if ((best_width > rectCell.width) && (col < cols) && grid.GetTable()) { int i, c_cols, c_rows; for (i = col+cell_cols; i < cols; i++) { bool is_empty = true; for (int j=row; j < row + cell_rows; j++) { // check w/ anchor cell for multicell block grid.GetCellSize(j, i, &c_rows, &c_cols); if (c_rows > 0) c_rows = 0; if (!grid.GetTable()->IsEmptyCell(j + c_rows, i)) { is_empty = false; break; } } if (is_empty) { rect.width += grid.GetColSize(i); } else { i--; break; } if (rect.width >= best_width) break; } overflowCols = i - col - cell_cols + 1; if (overflowCols >= cols) overflowCols = cols - 1; } if (overflowCols > 0) // redraw overflow cells w/ proper hilight { hAlign = wxALIGN_LEFT; // if oveflowed then it's left aligned wxRect clip = rect; clip.x += rectCell.width; // draw each overflow cell individually int col_end = col + cell_cols + overflowCols; if (col_end >= grid.GetNumberCols()) col_end = grid.GetNumberCols() - 1; for (int i = col + cell_cols; i <= col_end; i++) { clip.width = grid.GetColSize(i) - 1; dc.DestroyClippingRegion(); dc.SetClippingRegion(clip); SetTextColoursAndFont(grid, attr, dc, grid.IsInSelection(row,i)); grid.DrawTextRectangle(dc, grid.GetCellValue(row, col), rect, hAlign, vAlign); clip.x += grid.GetColSize(i) - 1; } rect = rectCell; rect.Inflate(-1); rect.width++; dc.DestroyClippingRegion(); } } // now we only have to draw the text SetTextColoursAndFont(grid, attr, dc, isSelected); grid.DrawTextRectangle(dc, grid.GetCellValue(row, col), rect, hAlign, vAlign); }
void wxGridCellChoiceRenderer::Draw(wxGrid& grid, wxGridCellAttr& attr, wxDC& dc, const wxRect& rectCell, int row, int col, bool isSelected) { wxGridCellRenderer::Draw(grid, attr, dc, rectCell, row, col, isSelected); // first calculate button size // don't draw outside the cell int nButtonWidth = 17; if (rectCell.height < 2) return; wxRect rectButton; rectButton.x = rectCell.x + rectCell.width - nButtonWidth; rectButton.y = rectCell.y + 1; int cell_rows, cell_cols; attr.GetSize(&cell_rows, &cell_cols); rectButton.width = nButtonWidth; if (cell_rows == 1) rectButton.height = rectCell.height-2; else rectButton.height = nButtonWidth; SetTextColoursAndFont(grid, attr, dc, isSelected); int hAlign, vAlign; attr.GetAlignment(&hAlign, &vAlign); // leave room for button wxRect rect = rectCell; rect.SetWidth(rectCell.GetWidth() - rectButton.GetWidth()-2); rect.Inflate(-1); grid.DrawTextRectangle(dc, grid.GetCellValue(row, col), rect, hAlign, vAlign); // don't bother drawing if the cell is too small if (rectButton.height < 4 || rectButton.width < 4) return; // draw 3-d button wxColour colourBackGround = wxColour(COLORBASE); dc.SetBrush(wxBrush(colourBackGround, wxSOLID)); dc.SetPen(wxPen(colourBackGround, 1, wxSOLID)); dc.DrawRectangle(rectButton); dc.SetPen(wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNTEXT), 1, wxSOLID)); dc.DrawLine(rectButton.GetLeft(), rectButton.GetBottom(), rectButton.GetRight(), rectButton.GetBottom()); dc.DrawLine(rectButton.GetRight(), rectButton.GetBottom(), rectButton.GetRight(), rectButton.GetTop()-1); dc.SetPen(wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW), 1, wxSOLID)); dc.DrawLine(rectButton.GetLeft()+1, rectButton.GetBottom()-1, rectButton.GetRight()-1, rectButton.GetBottom()-1); dc.DrawLine(rectButton.GetRight()-1, rectButton.GetBottom()-1, rectButton.GetRight()-1, rectButton.GetTop()); dc.SetPen(wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNHIGHLIGHT), 1, wxSOLID)); dc.DrawLine(rectButton.GetRight()-2, rectButton.GetTop()+1, rectButton.GetLeft()+1, rectButton.GetTop()+1); dc.DrawLine(rectButton.GetLeft()+1, rectButton.GetTop()+1, rectButton.GetLeft()+1, rectButton.GetBottom()-1); // Draw little triangle int nTriWidth = 7; int nTriHeight = 4; wxPoint point[3]; point[0] = wxPoint(rectButton.GetLeft() + (rectButton.GetWidth()-nTriWidth)/2, rectButton.GetTop()+(rectButton.GetHeight()-nTriHeight)/2); point[1] = wxPoint(point[0].x+nTriWidth-1, point[0].y); point[2] = wxPoint(point[0].x+3, point[0].y+nTriHeight-1); dc.SetBrush(wxBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNTEXT), wxSOLID)); dc.SetPen(wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNTEXT), 1, wxSOLID)); dc.DrawPolygon(3, point); if (m_border == wxLAYOUT_TOP) { dc.SetPen(wxPen(*wxBLACK, 1, wxDOT)); dc.DrawLine(rectCell.GetRight(), rectCell.GetTop(), rectCell.GetLeft(), rectCell.GetTop()); } }
void wxSheetCellStringRendererRefData::DoDraw(wxSheet& sheet, const wxSheetCellAttr& attr, wxDC& dc, const wxRect& rectCell, const wxSheetCoords& coords, bool isSelected) { wxRect rect = rectCell; rect.Inflate(-1); int align = attr.GetAlignment(); int orient = attr.GetOrientation(); wxString value( sheet.GetCellValue(coords) ); int best_width = DoGetBestSize(sheet, attr, dc, value).GetWidth(); wxSheetCoords cellSpan(sheet.GetCellSpan(coords)); // shouldn't get here if <=0 int cell_rows = cellSpan.m_row; int cell_cols = cellSpan.m_col; bool is_grid_cell = coords.IsGridCell(); // no overflow for row/col/corner labels bool overflow = is_grid_cell && (orient == wxSHEET_AttrOrientHoriz) ? attr.GetOverflow() : false; int overflowCols = 0; int num_cols = sheet.GetNumberCols(); // this is the right col which includes overflow int rightCol = coords.m_col + cell_cols - 1; // Check if this cell should overflow to right and for how many cells if (overflow) { bool is_editing = sheet.IsCellEditControlShown(); wxSheetCoords editorCell = is_editing ? sheet.GetEditControlCoords() : wxNullSheetCoords; int row = coords.GetRow(), col = coords.GetCol(); wxSheetCoords ownerCell; if ((best_width > rectCell.width) && (col < num_cols-1) && sheet.GetTable()) { wxSheetCoords cell; for (cell.m_col = col+cell_cols; cell.m_col < num_cols; cell.m_col++) { bool is_empty = true; for (cell.m_row = row; cell.m_row < row+cell_rows; cell.m_row++) { // check w/ anchor cell for spanned cell block ownerCell = sheet.GetCellOwner(cell); if ( sheet.GetTable()->HasValue(ownerCell) || (ownerCell == editorCell) ) { is_empty = false; break; } } if (is_empty) rect.width += sheet.GetColWidth(cell.m_col); else { cell.m_col--; break; } if (rect.width >= best_width) break; } // this may extend out of sheet overflowCols = cell.m_col - col - cell_cols + 1; rightCol = wxMin(coords.m_col+cell_cols-1+overflowCols, num_cols - 1); } // redraw overflow cells individually for proper selection hilight if (overflowCols > 0) { // if overflowed then it's left aligned (yes I know ALIGN_LEFT=0) align &= ~wxSHEET_AttrAlignHoriz_Mask; align |= wxSHEET_AttrAlignLeft; wxRect clip(rect); clip.x += rectCell.width; int col_width; wxSheetCoords cell(coords); // draw each cell individually since it may be selected or not for (cell.m_col = col+cell_cols; cell.m_col <= rightCol; cell.m_col++) { col_width = sheet.GetColWidth(cell.m_col); clip.width = col_width - 1; dc.DestroyClippingRegion(); dc.SetClippingRegion(clip); SetTextColoursAndFont(sheet, attr, dc, sheet.IsCellSelected(cell)); sheet.DrawTextRectangle(dc, value, rect, align, orient); clip.x += col_width - 1; } rect = rectCell; rect.Inflate(-1); rect.width++; dc.DestroyClippingRegion(); } } // Draw the text SetTextColoursAndFont(sheet, attr, dc, isSelected); sheet.DrawTextRectangle(dc, value, rect, align, orient); if (attr.GetOverflowMarker()) { // Draw a marker to show that the contents has been clipped off int cellRight = sheet.GetColRight(rightCol); if (cellRight - rect.x < best_width) { int bmpWidth = s_overflowBitmap.GetWidth(); int bmpHeight = s_overflowBitmap.GetHeight(); int cellWidth = sheet.GetColWidth(rightCol); int cellHeight = sheet.GetRowHeight(coords.m_row); if ((bmpWidth < cellWidth-3) && (bmpHeight < cellHeight-3)) { int cellTop = sheet.GetRowTop(coords.m_row); int x = cellRight - bmpWidth - 2; int y = cellTop + (cellHeight - bmpHeight)/2; wxRect r(x-2, cellTop, bmpWidth+4-1, cellHeight-1); wxSheetCellAttr rightAttr(attr); if (overflowCols > 0) { wxSheetCoords clipCell(coords.m_row, rightCol); isSelected = sheet.IsCellSelected(clipCell); rightAttr = sheet.GetAttr(clipCell); } // clear background for bitmap wxSheetCellRendererRefData::Draw(sheet, rightAttr, dc, r, coords, isSelected); dc.DrawBitmap( s_overflowBitmap, x, y, true ); } } } }
void wxSheetCellRolColLabelRendererRefData::Draw(wxSheet& sheet, const wxSheetCellAttr& attr, wxDC& dc, const wxRect& rectCell, const wxSheetCoords& coords, bool isSelected) { // erase this cells background wxRect rect(rectCell); #ifdef FIXME_CANT_SET_COLOURS_FOR_NATIVE_RENDERER // __WXGTK20__ SetTextColoursAndFont(sheet, attr, dc, isSelected); wxWindow *win = sheet.GetWindowForCoords(coords); wxCHECK_RET(win, wxT("Invalid coords in wxSheetCellRolColLabelRendererRefData::Draw")); wxRendererNative::Get().DrawHeaderButton( win, dc, rect, 0 ); #else // !__WXGTK20__ wxSheetCellRendererRefData::Draw(sheet, attr, dc, rect, coords, isSelected); int left = rectCell.x; int top = rectCell.y; int right = rectCell.GetRight(); int bottom = rectCell.GetBottom(); //dc.SetPen( wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DDKSHADOW),1, wxSOLID) ); // right side //dc.DrawLine( right, top, right, bottom ); // left side //if (coords.m_col == -1) // dc.DrawLine( left, top, left, bottom ); // top side //if (coords.m_row == -1) // dc.DrawLine( left, top, right, top ); // bottom //dc.DrawLine( left, bottom, right, bottom ); dc.SetPen( *wxWHITE_PEN ); // left highlight dc.DrawLine( left, top, left, bottom ); // top highlight dc.DrawLine( left, top, right, top ); #endif // __WXGTK__ SetTextColoursAndFont(sheet, attr, dc, isSelected); wxString value( sheet.GetCellValue(coords) ); if (!value.IsEmpty()) { int align = attr.GetAlignment(); int orient = attr.GetOrientation(); rect.Deflate(2); // want margins sheet.DrawTextRectangle(dc, value, rect, align, orient); } #if 0 // test code for sizing, draws corner tick marks if (1) { rect = rectCell; dc.SetPen(*wxGREEN_PEN); dc.DrawLine(left, top, left+25, top); dc.DrawLine(right-25, bottom, right, bottom); dc.DrawLine(left, top, left, top+10); dc.DrawLine(right, bottom-10, right, bottom); wxRect r(rectCell); dc.SetPen(*wxCYAN_PEN); dc.DrawLine(r.x, r.y, r.x+25, r.y); dc.DrawLine(r.GetRight()-25, r.GetBottom(), r.GetRight(), r.GetBottom()); dc.DrawLine(r.x, r.y, r.x, r.y+10); dc.DrawLine(r.GetRight(), r.GetBottom()-10, r.GetRight(), r.GetBottom()); } #endif // 0 }