本文整理汇总了C++中wxGridCellAttr::GetFont方法的典型用法代码示例。如果您正苦于以下问题:C++ wxGridCellAttr::GetFont方法的具体用法?C++ wxGridCellAttr::GetFont怎么用?C++ wxGridCellAttr::GetFont使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wxGridCellAttr
的用法示例。
在下文中一共展示了wxGridCellAttr::GetFont方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tk
wxArrayString
wxGridCellAutoWrapStringRenderer::GetTextLines(wxGrid& grid,
wxDC& dc,
const wxGridCellAttr& attr,
const wxRect& rect,
int row, int col)
{
wxString data = grid.GetCellValue(row, col);
wxArrayString lines;
dc.SetFont(attr.GetFont());
//Taken from wxGrid again!
wxCoord x = 0, y = 0, curr_x = 0;
wxCoord max_x = rect.GetWidth();
dc.SetFont(attr.GetFont());
wxStringTokenizer tk(data , wxT(" \n\t\r"));
wxString thisline = wxEmptyString;
while ( tk.HasMoreTokens() )
{
wxString tok = tk.GetNextToken();
//FIXME: this causes us to print an extra unnecesary
// space at the end of the line. But it
// is invisible , simplifies the size calculation
// and ensures tokens are separated in the display
tok += wxT(" ");
dc.GetTextExtent(tok, &x, &y);
if ( curr_x + x > max_x)
{
if ( curr_x == 0 )
{
// this means that a single token is wider than the maximal
// width -- still use it as is as we need to show at least the
// part of it which fits
lines.Add(tok);
}
else
{
lines.Add(thisline);
thisline = tok;
curr_x = x;
}
}
else
{
thisline+= tok;
curr_x += x;
}
}
//Add last line
lines.Add( wxString(thisline) );
return lines;
}
示例2: DoGetBestSize
wxSize wxGridCellStringRenderer::DoGetBestSize(const wxGridCellAttr& attr,
wxDC& dc,
const wxString& text)
{
wxCoord x = 0, y = 0, max_x = 0;
dc.SetFont(attr.GetFont());
wxStringTokenizer tk(text, wxT('\n'));
while ( tk.HasMoreTokens() )
{
dc.GetTextExtent(tk.GetNextToken(), &x, &y);
max_x = wxMax(max_x, x);
}
y *= 1 + text.Freq(wxT('\n')); // multiply by the number of lines.
return wxSize(max_x, y);
}
示例3: SetTextColoursAndFont
void wxGridCellStringRenderer::SetTextColoursAndFont(const wxGrid& grid,
const wxGridCellAttr& attr,
wxDC& dc,
bool isSelected)
{
dc.SetBackgroundMode( wxBRUSHSTYLE_TRANSPARENT );
// TODO some special colours for attr.IsReadOnly() case?
// different coloured text when the grid is disabled
if ( grid.IsThisEnabled() )
{
if ( isSelected )
{
wxColour clr;
if ( grid.HasFocus() )
clr = grid.GetSelectionBackground();
else
clr = wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW);
dc.SetTextBackground( clr );
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() );
}
示例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 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);
}