本文整理汇总了C++中wxDC::GetMultiLineTextExtent方法的典型用法代码示例。如果您正苦于以下问题:C++ wxDC::GetMultiLineTextExtent方法的具体用法?C++ wxDC::GetMultiLineTextExtent怎么用?C++ wxDC::GetMultiLineTextExtent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wxDC
的用法示例。
在下文中一共展示了wxDC::GetMultiLineTextExtent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawCheckOrRadioButton
void wxStdRenderer::DrawCheckOrRadioButton(wxDC& dc,
const wxString& label,
const wxBitmap& bitmap,
const wxRect& rect,
int flags,
wxAlignment align,
int indexAccel)
{
// calculate the position of the bitmap and of the label
wxCoord heightBmp = bitmap.GetHeight();
wxCoord xBmp,
yBmp = rect.y + (rect.height - heightBmp) / 2;
wxRect rectLabel;
dc.GetMultiLineTextExtent(label, NULL, &rectLabel.height);
rectLabel.y = rect.y + (rect.height - rectLabel.height) / 2;
// align label vertically with the bitmap - looks nicer like this
rectLabel.y -= (rectLabel.height - heightBmp) % 2;
// calc horz position
if ( align == wxALIGN_RIGHT )
{
xBmp = rect.GetRight() - bitmap.GetWidth();
rectLabel.x = rect.x + 3;
rectLabel.SetRight(xBmp);
}
else // normal (checkbox to the left of the text) case
{
xBmp = rect.x;
rectLabel.x = xBmp + bitmap.GetWidth() + 5;
rectLabel.SetRight(rect.GetRight());
}
dc.DrawBitmap(bitmap, xBmp, yBmp, true /* use mask */);
DrawLabel(dc, label, rectLabel, flags,
wxALIGN_LEFT | wxALIGN_TOP, indexAccel);
}
示例2: Draw
/// Draw the item
bool InstanceVisual::Draw(wxDC& dc, InstanceCtrl* ctrl, const wxRect& rect, int style)
{
wxColour backgroundColor = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
wxColour textColor = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
wxColour highlightTextColor = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT);
wxColour focus_color = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT);
wxColour focussedSelection = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT);
wxRect imageRect(rect.x + (rect.width - 32) / 2, rect.y, 32, 32);
if (style & wxINST_SELECTED)
{
wxBrush brush(focus_color);
wxPen pen(focus_color);
dc.SetBrush(brush);
dc.SetPen(pen);
}
else
{
wxBrush brush(backgroundColor);
wxPen pen(backgroundColor);
dc.SetBrush(brush);
dc.SetPen(pen);
}
// Draw the label
wxString name = m_inst->GetName();
if (!name.IsEmpty())
{
int margin = ctrl->GetItemMargin();
wxRect textRect;
textRect.x = rect.x + margin;
textRect.y = rect.y + imageRect.height + 2 * margin;
textRect.width = rect.width - 2 * margin;
dc.SetFont(ctrl->GetFont());
if (style & wxINST_SELECTED)
dc.SetTextForeground(highlightTextColor);
else
dc.SetTextForeground(textColor);
dc.SetBackgroundMode(wxTRANSPARENT);
int yoffset = 0;
wxSize textsize = dc.GetMultiLineTextExtent(name_wrapped);
textRect.height = textsize.GetHeight();
if (style & wxINST_SELECTED)
{
wxRect hiRect;
hiRect.x = rect.x + (rect.width - textsize.x) / 2 - margin;
hiRect.y = textRect.y - margin;
hiRect.SetSize(textsize + wxSize(2 * margin, 2 * margin));
dc.DrawRectangle(hiRect);
}
dc.DrawLabel(name_wrapped, textRect, wxALIGN_TOP | wxALIGN_CENTER_HORIZONTAL);
}
// Draw the icon
auto list = InstIconList::Instance();
wxImage icon;
if (style & wxINST_SELECTED)
icon = list->getHLImageForKey(m_inst->GetIconKey());
else
icon = list->getImageForKey(m_inst->GetIconKey());
wxBitmap bmap = wxBitmap(icon);
int x = imageRect.x + (imageRect.width - bmap.GetWidth()) / 2;
int y = imageRect.y + (imageRect.height - bmap.GetHeight()) / 2;
dc.DrawBitmap(bmap , x, y, true);
return true;
}