本文整理汇总了C++中wxGrid::DrawTextRectangle方法的典型用法代码示例。如果您正苦于以下问题:C++ wxGrid::DrawTextRectangle方法的具体用法?C++ wxGrid::DrawTextRectangle怎么用?C++ wxGrid::DrawTextRectangle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wxGrid
的用法示例。
在下文中一共展示了wxGrid::DrawTextRectangle方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DoProgressDrawing
/* 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);
}
示例2: Draw
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);
}
示例3: SetTextColoursAndFont
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);
}
示例4: Draw
void TimeRenderer::Draw(wxGrid &grid,
wxGridCellAttr &attr,
wxDC &dc,
const wxRect &rect,
int row,
int col,
bool isSelected)
{
wxGridCellRenderer::Draw(grid, attr, dc, rect, row, col, isSelected);
wxGridTableBase *table = grid.GetTable();
TimeEditor *te = (TimeEditor *) grid.GetCellEditor(row, col);
wxString tstr;
if (te) {
double value;
table->GetValue(row, col).ToDouble(&value);
NumericTextCtrl tt(NumericConverter::TIME, &grid,
wxID_ANY,
te->GetFormat(),
value,
te->GetRate(),
wxPoint(10000, 10000), // create offscreen
wxDefaultSize,
true);
tstr = tt.GetString();
te->DecRef();
}
dc.SetBackgroundMode(wxTRANSPARENT);
if (grid.IsEnabled())
{
if (isSelected)
{
dc.SetTextBackground(grid.GetSelectionBackground());
dc.SetTextForeground(grid.GetSelectionForeground());
}
else
{
dc.SetTextBackground(attr.GetBackgroundColour());
dc.SetTextForeground(attr.GetTextColour());
}
}
else
{
dc.SetTextBackground(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));
dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT));
}
dc.SetFont(attr.GetFont());
int hAlign, vAlign;
attr.GetAlignment(&hAlign, &vAlign);
grid.DrawTextRectangle(dc, tstr, rect, hAlign, vAlign);
}
示例5: Draw
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());
}
}
示例6: Draw
void NumericRenderer::Draw(wxGrid &grid,
wxGridCellAttr &attr,
wxDC &dc,
const wxRect &rect,
int row,
int col,
bool isSelected)
{
wxGridCellRenderer::Draw(grid, attr, dc, rect, row, col, isSelected);
wxGridTableBase *table = grid.GetTable();
NumericEditor *ne =
static_cast<NumericEditor *>(grid.GetCellEditor(row, col));
wxString tstr;
if (ne) {
double value;
table->GetValue(row, col).ToDouble(&value);
NumericTextCtrl tt(&grid, wxID_ANY,
mType,
ne->GetFormat(),
value,
ne->GetRate(),
NumericTextCtrl::Options{}.AutoPos(true),
wxPoint(10000, 10000)); // create offscreen
tstr = tt.GetString();
ne->DecRef();
}
dc.SetBackgroundMode(wxTRANSPARENT);
if (grid.IsEnabled())
{
if (isSelected)
{
dc.SetTextBackground(grid.GetSelectionBackground());
dc.SetTextForeground(grid.GetSelectionForeground());
}
else
{
dc.SetTextBackground(attr.GetBackgroundColour());
dc.SetTextForeground(attr.GetTextColour());
}
}
else
{
dc.SetTextBackground(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));
dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT));
}
dc.SetFont(attr.GetFont());
int hAlign, vAlign;
attr.GetAlignment(&hAlign, &vAlign);
grid.DrawTextRectangle(dc, tstr, rect, hAlign, vAlign);
}