本文整理汇总了C++中wxDC::GetCharHeight方法的典型用法代码示例。如果您正苦于以下问题:C++ wxDC::GetCharHeight方法的具体用法?C++ wxDC::GetCharHeight怎么用?C++ wxDC::GetCharHeight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wxDC
的用法示例。
在下文中一共展示了wxDC::GetCharHeight方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Render
/*
* Here we do the actual rendering. I put it in a separate
* method so that it can work no matter what type of DC
* (e.g. wxPaintDC or wxClientDC) is used.
*/
void BasicDrawPane::Render(wxDC& dc)
{
int width, height;
this->GetSize(&width, &height);
if ( m_bgColor.IsOk() )
{
dc.SetBrush(wxBrush(m_bgColor));
dc.DrawRectangle(0, 0, width, height);
}
if ( m_textForeGround.IsOk() )
{
dc.SetTextForeground( m_textForeGround );
}
if ( !m_text.IsEmpty() )
{
dc.SetBackgroundMode(wxTRANSPARENT);
dc.SetFont( m_font );
/*
* ちょうど中央表示できるよう調整
*/
const int cHeight = dc.GetCharHeight();
const int cWidth = dc.GetCharWidth();
const int textLen = m_text.Len();
const int textHalfSize = textLen * cWidth / 2;
dc.DrawText( m_text, width / 2 - textHalfSize, height / 2 - cHeight / 2 );
}
}
示例2: PaintForeground
void wxStaticBox::PaintForeground(wxDC& dc, const RECT& WXUNUSED(rc))
{
MSWDefWindowProc(WM_PAINT, (WPARAM)GetHdcOf(dc), 0);
// when using XP themes, neither setting the text colour nor transparent
// background mode doesn't change anything: the static box def window proc
// still draws the label in its own colours, so we need to redraw the text
// ourselves if we have a non default fg colour
if ( m_hasFgCol && wxUxThemeEngine::GetIfActive() )
{
// draw over the text in default colour in our colour
dc.SetFont(GetFont());
HDC hdc = GetHdcOf(dc);
::SetTextColor(hdc, GetForegroundColour().GetPixel());
// FIXME: value of x is hardcoded as this is what it is on my system,
// no idea if it's true everywhere
const int y = dc.GetCharHeight();
const int x = 9;
// TODO: RTL?
RECT rc = { x, 0, GetSize().x - x, y };
const wxString label = GetLabel();
::DrawText(hdc, label, label.length(), &rc, DT_SINGLELINE | DT_VCENTER);
}
}
示例3: OnDrawItem
void ODIconCombo::OnDrawItem( wxDC& dc,
const wxRect& rect,
int item,
int flags ) const
{
int offset_x = bmpArray.Item(item).GetWidth();
int bmpHeight = bmpArray.Item(item).GetHeight();
dc.DrawBitmap(bmpArray.Item(item), rect.x, rect.y + (rect.height - bmpHeight)/2, true);
if ( flags & wxODCB_PAINTING_CONTROL )
{
wxString text = GetValue();
int margin_x = 2;
#if wxCHECK_VERSION(2, 9, 0)
if ( ShouldUseHintText() )
{
text = GetHint();
wxColour col = wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT);
dc.SetTextForeground(col);
}
margin_x = GetMargins().x;
#endif
dc.DrawText( text,
rect.x + margin_x + offset_x,
(rect.height-dc.GetCharHeight())/2 + rect.y );
}
else
{
dc.DrawText( GetVListBoxComboPopup()->GetString(item), rect.x + 2 + offset_x, (rect.height-dc.GetCharHeight())/2 + rect.y );
}
}
示例4: while
int
wxGridCellAutoWrapStringRenderer::GetBestWidth(wxGrid& grid,
wxGridCellAttr& attr,
wxDC& dc,
int row, int col,
int height)
{
const int lineHeight = dc.GetCharHeight();
// Maximal number of lines that fully fit but at least 1.
const size_t maxLines = height - AUTOWRAP_Y_MARGIN < lineHeight
? 1
: (height - AUTOWRAP_Y_MARGIN)/lineHeight;
// Increase width until all the text fits.
//
// TODO: this is not the most efficient to do it for the long strings.
const int charWidth = dc.GetCharWidth();
int width = 2*charWidth;
while ( GetTextLines(grid, dc, attr, wxSize(width, height),
row, col).size() > maxLines )
width += charWidth;
return width;
}
示例5: OnDrawItem
void wxOwnerDrawnComboBox::OnDrawItem( wxDC& dc,
const wxRect& rect,
int item,
int flags ) const
{
if ( flags & wxODCB_PAINTING_CONTROL )
{
wxString text;
if ( !ShouldUseHintText() )
{
text = GetValue();
}
else
{
text = GetHint();
wxColour col = wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT);
dc.SetTextForeground(col);
}
dc.DrawText( text,
rect.x + GetMargins().x,
(rect.height-dc.GetCharHeight())/2 + rect.y );
}
else
{
dc.DrawText( GetVListBoxComboPopup()->GetString(item), rect.x + 2, rect.y );
}
}
示例6: OnDrawItem
virtual void OnDrawItem( wxDC& dc,
const wxRect& rect,
int item,
int flags ) const
{
if ( item == wxNOT_FOUND )
return;
wxRect r(rect);
r.Deflate(3);
r.height -= 2;
wxPenStyle penStyle = wxPENSTYLE_SOLID;
if ( item == 1 )
penStyle = wxPENSTYLE_TRANSPARENT;
else if ( item == 2 )
penStyle = wxPENSTYLE_DOT;
else if ( item == 3 )
penStyle = wxPENSTYLE_LONG_DASH;
else if ( item == 4 )
penStyle = wxPENSTYLE_SHORT_DASH;
else if ( item == 5 )
penStyle = wxPENSTYLE_DOT_DASH;
else if ( item == 6 )
penStyle = wxPENSTYLE_BDIAGONAL_HATCH;
else if ( item == 7 )
penStyle = wxPENSTYLE_CROSSDIAG_HATCH;
else if ( item == 8 )
penStyle = wxPENSTYLE_FDIAGONAL_HATCH;
else if ( item == 9 )
penStyle = wxPENSTYLE_CROSS_HATCH;
else if ( item == 10 )
penStyle = wxPENSTYLE_HORIZONTAL_HATCH;
else if ( item == 11 )
penStyle = wxPENSTYLE_VERTICAL_HATCH;
wxPen pen( dc.GetTextForeground(), 3, penStyle );
// Get text colour as pen colour
dc.SetPen( pen );
if ( !(flags & wxODCB_PAINTING_CONTROL) )
{
dc.DrawText(GetString( item ),
r.x + 3,
(r.y + 0) + ( (r.height/2) - dc.GetCharHeight() )/2
);
dc.DrawLine( r.x+5, r.y+((r.height/4)*3), r.x+r.width - 5, r.y+((r.height/4)*3) );
}
else
{
dc.DrawLine( r.x+5, r.y+r.height/2, r.x+r.width - 5, r.y+r.height/2 );
}
}
示例7: OnDrawItem
void PenStyleComboBox::OnDrawItem( wxDC& dc,
const wxRect& rect,
int item,
int flags ) const
{
if ( item == wxNOT_FOUND )
return;
wxRect r(rect);
r.Deflate(3);
r.height -= 2;
int penStyle = wxSOLID;
// if ( item == 1 )
// penStyle = wxTRANSPARENT;
// else if ( item == 2 )
// penStyle = wxDOT;
// else if ( item == 3 )
// penStyle = wxLONG_DASH;
// else if ( item == 4 )
// penStyle = wxSHORT_DASH;
if ( item == 0 )
penStyle = wxDOT_DASH;
else if ( item == 1 )
penStyle = wxBDIAGONAL_HATCH;
else if ( item == 2 )
penStyle = wxCROSSDIAG_HATCH;
// else if ( item == 8 )
// penStyle = wxFDIAGONAL_HATCH;
// else if ( item == 9 )
// penStyle = wxCROSS_HATCH;
// else if ( item == 10 )
// penStyle = wxHORIZONTAL_HATCH;
// else if ( item == 11 )
// penStyle = wxVERTICAL_HATCH;
wxPen pen( dc.GetTextForeground(), 3, penStyle );
// Get text colour as pen colour
dc.SetPen( pen );
if ( !(flags & wxODCB_PAINTING_CONTROL) )
{
dc.DrawText(GetString( item ),
r.x + 3,
(r.y + 0) + ( (r.height/2) - dc.GetCharHeight() )/2
);
dc.DrawLine( r.x+5, r.y+((r.height/4)*3), r.x+r.width - 5, r.y+((r.height/4)*3) );
}
else
{
dc.DrawLine( r.x+5, r.y+r.height/2, r.x+r.width - 5, r.y+r.height/2 );
}
}
示例8: AdjustFontSize
static void AdjustFontSize(wxFont& font, wxDC& dc, const wxSize& pixelSize)
{
int currentSize = 0;
int largestGood = 0;
int smallestBad = 0;
bool initialGoodFound = false;
bool initialBadFound = false;
// NB: this assignment was separated from the variable definition
// in order to fix a gcc v3.3.3 compiler crash
currentSize = font.GetPointSize();
while (currentSize > 0)
{
dc.SetFont(font);
// if currentSize (in points) results in a font that is smaller
// than required by pixelSize it is considered a good size
if (dc.GetCharHeight() <= pixelSize.GetHeight() &&
(!pixelSize.GetWidth() ||
dc.GetCharWidth() <= pixelSize.GetWidth()))
{
largestGood = currentSize;
initialGoodFound = true;
}
else
{
smallestBad = currentSize;
initialBadFound = true;
}
if (!initialGoodFound)
{
currentSize /= 2;
}
else if (!initialBadFound)
{
currentSize *= 2;
}
else
{
int distance = smallestBad - largestGood;
if (distance == 1)
break;
currentSize = largestGood + distance / 2;
}
font.SetPointSize(currentSize);
}
if (currentSize != largestGood)
font.SetPointSize(largestGood);
}
示例9: render
void StateEvaluationTreePanel::render(wxDC &dc)
{
if (Settings.m_ColourScheme == nullptr)
return;
PrepareDC(dc);
auto const &Scheme = *(Settings.m_ColourScheme);
dc.SetBackground(wxBrush{Scheme.getDefault().GetBackground()});
dc.Clear();
if (Statement.empty())
return;
auto const ActiveStmt = ActiveFn->getActiveStmt();
if (!ActiveStmt)
return;
dc.SetFont(CodeFont);
// Draw the sub-Stmts' nodes.
for (auto const &Node : Nodes) {
// Don't draw hovered nodes, they will be drawn later.
if (&*HoverNodeIt == &Node || &*ReplayHoverNodeIt == &Node)
continue;
auto const DoHighlight =
(HighlightedStmt && Node.Statement == HighlightedStmt)
|| (HighlightedValue && Node.Value.get() == HighlightedValue);
if (DoHighlight)
drawNode(dc, Scheme, Node, NodeDecoration::Highlighted);
else if (Node.Statement == ActiveStmt)
drawNode(dc, Scheme, Node, NodeDecoration::Active);
else
drawNode(dc, Scheme, Node, NodeDecoration::None);
}
// Redraw the hovered nodes, so that they outrank active node highlighting.
if (HoverNodeIt != Nodes.end())
drawNode(dc, Scheme, *HoverNodeIt, NodeDecoration::Highlighted);
if (ReplayHoverNodeIt != Nodes.end())
drawNode(dc, Scheme, *ReplayHoverNodeIt, NodeDecoration::Highlighted);
// Draw the pretty-printed Stmt's string.
dc.SetTextForeground(Scheme.getDefault().GetForeground());
wxCoord const PageBorderH = dc.GetCharWidth() * Settings.PageBorderHorizontal;
wxCoord const PageBorderV = dc.GetCharHeight() * Settings.PageBorderVertical;
dc.DrawText(Statement, PageBorderH, PageBorderV);
}
示例10: GetTextLines
int
wxGridCellAutoWrapStringRenderer::GetBestHeight(wxGrid& grid,
wxGridCellAttr& attr,
wxDC& dc,
int row, int col,
int width)
{
const int lineHeight = dc.GetCharHeight();
// Use as many lines as we need for this width and add a small border to
// improve the appearance.
return GetTextLines(grid, dc, attr, wxSize(width, lineHeight),
row, col).size() * lineHeight + AUTOWRAP_Y_MARGIN;
}
示例11: wxSize
wxSize
wxGridCellAutoWrapStringRenderer::GetBestSize(wxGrid& grid,
wxGridCellAttr& attr,
wxDC& dc,
int row, int col)
{
// We have to make a choice here and fix either width or height because we
// don't have any naturally best size. This choice is mostly arbitrary, but
// we need to be consistent about it, otherwise wxGrid auto-sizing code
// would get confused. For now we decide to use a single line of text and
// compute the width needed to fully display everything.
const int height = dc.GetCharHeight();
return wxSize(GetBestWidth(grid, attr, dc, row, col, height), height);
}
示例12: OnDrawItem
void wxOwnerDrawnComboBox::OnDrawItem( wxDC& dc,
const wxRect& rect,
int item,
int flags ) const
{
if ( flags & wxODCB_PAINTING_CONTROL )
{
dc.DrawText( GetValue(),
rect.x + GetTextIndent(),
(rect.height-dc.GetCharHeight())/2 + rect.y );
}
else
{
dc.DrawText( GetVListBoxComboPopup()->GetString(item), rect.x + 2, rect.y );
}
}
示例13: OnDrawItem
void wxBitmapComboBox::OnDrawItem(wxDC& dc,
const wxRect& rect,
int item,
int flags) const
{
wxString text;
int imgAreaWidth = m_imgAreaWidth;
bool drawText;
if ( imgAreaWidth == 0 )
{
wxOwnerDrawnComboBox::OnDrawItem(dc, rect, item, flags);
return;
}
if ( flags & wxODCB_PAINTING_CONTROL )
{
text = GetValue();
if ( HasFlag(wxCB_READONLY) )
drawText = true;
else
drawText = false;
}
else
{
text = GetString(item);
drawText = true;
}
const wxBitmap& bmp = *GetBitmapPtr(item);
if ( bmp.Ok() )
{
wxCoord w = bmp.GetWidth();
wxCoord h = bmp.GetHeight();
// Draw the image centered
dc.DrawBitmap(bmp,
rect.x + (m_usedImgSize.x-w)/2 + IMAGE_SPACING_LEFT,
rect.y + (rect.height-h)/2,
true);
}
if ( drawText )
dc.DrawText(GetString(item),
rect.x + imgAreaWidth + 1,
rect.y + (rect.height-dc.GetCharHeight())/2);
}
示例14: DrawText
wxSize DropDown::DrawText(void * ItemData, wxDC& dc, wxRect& TextRect, INT32 item, INT32 flags, BOOL Draw)
{
if (Draw)
{
if ( (m_pPopup->wxVListBox::GetSelection() == (INT32)item) && !(flags & wxODCB_PAINTING_CONTROL) )
dc.SetTextForeground( wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT) );
else
dc.SetTextForeground( wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT) );
}
wxString Text = GetText(ItemData, item);
wxCoord w, h;
dc.GetTextExtent(Text, &w, &h);
wxSize size(w,dc.GetCharHeight());
if (Draw)
dc.DrawText( Text, TextRect.x, TextRect.y );
return size;
}
示例15: DrawItem
void wxBitmapComboBoxBase::DrawItem(wxDC& dc,
const wxRect& rect,
int item,
const wxString& text,
int WXUNUSED(flags)) const
{
const wxBitmap& bmp = *GetBitmapPtr(item);
if ( bmp.IsOk() )
{
wxCoord w = bmp.GetWidth();
wxCoord h = bmp.GetHeight();
// Draw the image centered
dc.DrawBitmap(bmp,
rect.x + (m_usedImgSize.x-w)/2 + IMAGE_SPACING_LEFT,
rect.y + (rect.height-h)/2,
true);
}
if ( text.length() )
dc.DrawText(text,
rect.x + m_imgAreaWidth + 1,
rect.y + (rect.height-dc.GetCharHeight())/2);
}