本文整理汇总了C++中wxDC::DrawLabel方法的典型用法代码示例。如果您正苦于以下问题:C++ wxDC::DrawLabel方法的具体用法?C++ wxDC::DrawLabel怎么用?C++ wxDC::DrawLabel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wxDC
的用法示例。
在下文中一共展示了wxDC::DrawLabel方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: numRect
void
ClueListBox::OnDrawItem(wxDC & dc, const wxRect & rect, size_t n) const
{
wxRect numRect(rect);
numRect.SetWidth(m_numWidth);
wxRect textRect(rect);
textRect.SetX(numRect.GetRight() + GetMargins().x);
textRect.SetWidth(rect.width - GetMargins().x);
// Get fonts and colors
dc.SetFont(GetFont());
if (IsSelected(n))
dc.SetTextForeground(GetSelectionForeground());
else
dc.SetTextForeground(GetForegroundColour());
XPuzzle::Clue clue = GetItem(n);
dc.DrawLabel(wxString::Format(_T("%d."), clue.Number()), numRect, wxALIGN_RIGHT|wxALIGN_TOP);
wxASSERT(! m_cachedClues.at(n).empty());
dc.DrawLabel(m_cachedClues.at(n), textRect);
//dc.DrawLine(textRect.x, textRect.y, textRect.x + textRect.width, textRect.y + textRect.height);
}
示例2: Draw
void wxJigsawInputParameter::Draw(wxDC & dc, const wxPoint & pos, const wxSize & offset, double scale, wxColour color)
{
wxPoint realPosition(
pos.x + offset.GetWidth(),
pos.y /*+ offset.GetHeight()*/);
/*wxLogTrace(wxTraceMask(), _("ParameterPos = %i,%i; Offset=%i, %i"),
realPosition.x, realPosition.y, offset.x, offset.y);*/
wxSize labelSize;
wxSize size = GetSize(dc, scale);
dc.GetTextExtent(m_Label, &labelSize.x, &labelSize.y, 0, 0, (wxFont *)&dc.GetFont());
//Draw the text with bevel
wxRect rectText(realPosition, size);
rectText.x++;
rectText.y++;
dc.SetTextForeground(*wxBLACK);
dc.DrawLabel(m_Label, rectText, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL);
rectText.x--;
rectText.y--;
dc.SetTextForeground(*wxWHITE);
dc.DrawLabel(m_Label, rectText, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL);
wxPoint shapePos;
wxSize shapeSize;
if(m_Shape)
{
shapeSize = m_Shape->GetSize(dc, scale);
shapePos = wxPoint(
pos.x + labelSize.x + wxJigsawInputParameter::ParameterSpacing*scale,
pos.y + (size.GetHeight()-shapeSize.GetHeight())/2);
m_Shape->SetPosition(shapePos.x,
shapePos.y + (size.GetHeight()-shapeSize.GetHeight())*scale/2 - offset.GetHeight());
m_Shape->Draw(dc, offset, scale);
}
else
{
dc.SetPen(*wxBLACK_PEN);
wxBrush paramBrush(wxColour(color.Red()*.9,color.Green()*.9,color.Blue()*.9));
dc.SetBrush(paramBrush);
//dc.SetBrush(*wxWHITE_BRUSH);
shapeSize = wxJigsawInputParameter::GetDefaultParameterSize();
shapeSize.x *= scale;
shapeSize.y *= scale;
shapePos = wxPoint(
realPosition.x + labelSize.x + wxJigsawInputParameter::ParameterSpacing*scale,
realPosition.y + (size.GetHeight()-shapeSize.GetHeight())/2);
wxJigsawShape::DrawShapeHeader(dc, shapePos,
shapeSize, GetStyle());
}
//dc.SetBrush(*wxTRANSPARENT_BRUSH);
//dc.SetPen(*wxBLACK_PEN);
//dc.DrawRectangle(realPosition, size);
}
示例3: Render
/**
* Render the event in the bitmap
*/
void CppCodeEvent::Render(wxDC & dc, int x, int y, unsigned int width, gd::EventsEditorItemsAreas & areas, gd::EventsEditorSelection & selection, const gd::Platform & platform)
{
#if !defined(GD_NO_WX_GUI)
gd::EventsRenderingHelper * renderingHelper = gd::EventsRenderingHelper::Get();
const int titleTextHeight = 20;
//Draw header rectangle
wxRect headerRect(x, y, width, GetRenderedHeight(width, platform));
renderingHelper->DrawNiceRectangle(dc, headerRect);
//Header
dc.SetFont( renderingHelper->GetNiceFont().Bold() );
dc.SetTextForeground(wxColour(0,0,0));
dc.DrawText( (displayedName.empty() ? _("C++ code") : _("C++ code:")) + displayedName, x + 4, y + 3 );
if ( codeDisplayedInEditor )
{
dc.SetFont( renderingHelper->GetFont() );
dc.SetBrush(renderingHelper->GetActionsRectangleFillBrush());
dc.SetPen(renderingHelper->GetActionsRectangleOutlinePen());
dc.DrawRectangle(wxRect(x + 4, y + 3 + titleTextHeight + 2, width-8, GetRenderedHeight(width, platform)-(3 + titleTextHeight + 5)));
dc.DrawLabel( inlineCode, wxNullBitmap, wxRect(x + 4, y + 3 + titleTextHeight + 4, width-2, GetRenderedHeight(width, platform)));
}
#endif
}
示例4: DrawItem
void wxStdRenderer::DrawItem(wxDC& dc,
const wxString& label,
const wxRect& rect,
int flags)
{
wxDCTextColourChanger colChanger(dc);
if ( flags & wxCONTROL_SELECTED )
{
colChanger.Set(wxSCHEME_COLOUR(m_scheme, HIGHLIGHT_TEXT));
const wxColour colBg = wxSCHEME_COLOUR(m_scheme, HIGHLIGHT);
dc.SetBrush(colBg);
dc.SetPen(colBg);
dc.DrawRectangle(rect);
}
// horizontal adjustment is arbitrary
wxRect rectText = rect;
rectText.Deflate(2, ITEM_MARGIN);
dc.DrawLabel(label, wxNullBitmap, rectText);
if ( flags & wxCONTROL_FOCUSED )
{
DrawFocusRect(NULL, dc, rect, flags);
}
}
示例5: DrawColLabel
void CustomGrid::DrawColLabel( wxDC& dc, int col )
{
//init dc font and colours
dc.SetFont(m_labelFont);
if(col == m_gParent->m_pIndex){
dc.SetBrush(wxBrush(m_greenColour, wxBRUSHSTYLE_SOLID));
dc.SetPen(wxPen(m_greenColour, 1));
}else {
dc.SetBrush(wxBrush(m_labelBackgroundColour, wxBRUSHSTYLE_SOLID));
dc.SetPen(wxPen(m_labelBackgroundColour, 1));
}
//draw retangle
wxRect tRect( GetColLeft(col), 1, GetColWidth(col)-2, m_colLabelHeight -2);
dc.DrawRectangle(tRect);
//draw lines aroud label
dc.SetPen(GetDefaultGridLinePen());
dc.DrawLine( GetColLeft(col) -1, 0, GetColRight(col), 0 );
if( col > -1 && (col == 0 || GetColLabelValue( col ).BeforeFirst('-') != GetColLabelValue( col - 1 ).BeforeFirst('-')) )
dc.SetPen(wxPen(*wxBLACK, 4));
dc.DrawLine( GetColLeft(col) -1, 0, GetColLeft(col) - 1, m_colLabelHeight);
if( col == m_numCols - 1 ){
dc.SetPen(wxPen(*wxBLACK, 4));
dc.DrawLine( GetColRight(col), 0, GetColRight(col), m_colLabelHeight);
}
//then draw label
dc.DrawLabel(GetColLabelValue(col), tRect, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL);
}
示例6: DrawRowLabel
void CustomGrid::DrawRowLabel( wxDC& dc, int row )
{
//init dc font and colours
dc.SetFont( m_labelFont );
dc.SetPen(GetDefaultGridLinePen());
dc.SetBrush( wxBrush( m_labelBackgroundColour, wxBRUSHSTYLE_SOLID ) );
int w = dc.GetTextExtent(_T("Speed")).x;
wxString label1,label2;
label1 = GetRowLabelValue(row).BeforeFirst(',', &label2);
bool pline = true;
//row is the first of 3 for the same parameter (wind ... waves ...)
if(GetNumberRows() > row + 2 && label1 == GetRowLabelValue(row + 2).BeforeFirst(',')){
pline = false;
if(IsRowVisible(row + 2))
label1 = _T(" ");
}
//row is the second of 3 or the first of 2
else if(GetNumberRows() > row + 1 && label1 == GetRowLabelValue(row + 1).BeforeFirst(',')){
pline = false;
if(row > 0 && label1 == GetRowLabelValue(row - 1).BeforeFirst(',')){ //second of 3
if(!IsRowVisible(row + 1))
label1 = _T(" ");
}
}
//row is the last of 3
else if(row > 1 && label1 == GetRowLabelValue(row - 2).BeforeFirst(',')){
if(IsRowVisible(row - 1))
label1 = _T(" ");
}
//row is the last of 2
else if(row > 0 && label1 == GetRowLabelValue(row - 1).BeforeFirst(',')){
if(IsRowVisible(row - 1))
label1 = _T(" ");
}
//draw first part of the label
wxRect aRect(5, GetRowTop(row), m_rowLabelWidth - w, GetRowHeight(row));
dc.DrawLabel(label1, aRect, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL);
//draw second part of the label
wxRect bRect(m_rowLabelWidth - w, GetRowTop(row), w, GetRowHeight(row));
dc.SetFont( wxFont(m_labelFont).Scale(0.85) );
dc.DrawLabel(label2 , bRect, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL);
//draw row lines around labels
if(pline)
dc.DrawLine(0, GetRowBottom(row) - 1, m_rowLabelWidth, GetRowBottom(row) - 1);
dc.DrawLine(0, GetRowTop(row), 0, GetRowBottom(row) );
dc.DrawLine(m_rowLabelWidth - 1, GetRowTop(row), m_rowLabelWidth - 1, GetRowBottom(row) );
}
示例7: DrawButtonLabel
void wxStdRenderer::DrawButtonLabel(wxDC& dc,
const wxString& label,
const wxBitmap& image,
const wxRect& rect,
int flags,
int alignment,
int indexAccel,
wxRect *rectBounds)
{
wxDCTextColourChanger clrChanger(dc);
wxRect rectLabel = rect;
if ( !label.empty() && (flags & wxCONTROL_DISABLED) )
{
if ( flags & wxCONTROL_PRESSED )
{
// shift the label if a button is pressed
rectLabel.Offset(1, 1);
}
// draw shadow of the text
clrChanger.Set(m_penHighlight.GetColour());
wxRect rectShadow = rect;
rectShadow.Offset(1, 1);
dc.DrawLabel(label, rectShadow, alignment, indexAccel);
// make the main label text grey
clrChanger.Set(m_penDarkGrey.GetColour());
if ( flags & wxCONTROL_FOCUSED )
{
// leave enough space for the focus rect
rectLabel.Inflate(-2);
}
}
dc.DrawLabel(label, image, rectLabel, alignment, indexAccel, rectBounds);
if ( !label.empty() && (flags & wxCONTROL_FOCUSED) )
{
rectLabel.Inflate(-1);
DrawFocusRect(NULL, dc, rectLabel);
}
}
示例8: DoDrawLabel
void wxGenericStaticText::DoDrawLabel(wxDC& dc, const wxRect& rect)
{
#if wxUSE_MARKUP
if ( m_markupText )
m_markupText->Render(dc, rect, wxMarkupText::Render_ShowAccels);
else
#endif // wxUSE_MARKUP
dc.DrawLabel(m_label, rect, GetAlignment(), m_mnemonic);
}
示例9: DrawHeaderButton
// draw the header control button (used by wxListCtrl)
virtual void DrawHeaderButton(wxWindow *win,
wxDC& dc,
const wxRect& rect,
int flags = 0)
{
dc.SetBrush(*wxCYAN_BRUSH);
dc.SetTextForeground(*wxRED);
dc.DrawRoundedRectangle(rect, 10);
dc.DrawLabel(_T("MyDllRenderer"), wxNullBitmap, rect, wxALIGN_CENTER);
}
示例10: OnDrawItem
void ColorChoice::OnDrawItem(wxDC& dc, const wxRect& rect,
int item, int flags) const
{
if (item == wxNOT_FOUND)
return;
wxRect smallRect = rect;
smallRect.Deflate(popupPadding);
if (! s_colors[item].color.IsOk())
dc.DrawLabel(other_color, smallRect, wxALIGN_CENTER_VERTICAL);
else
Draw(dc, rect, s_colors[item].color, s_colors[item].label);
}
示例11: DrawHeaderButton
virtual int DrawHeaderButton(wxWindow *WXUNUSED(win),
wxDC& dc,
const wxRect& rect,
int WXUNUSED(flags) = 0,
wxHeaderSortIconType WXUNUSED(sortArrow) = wxHDR_SORT_ICON_NONE,
wxHeaderButtonParams* WXUNUSED(params) = NULL)
{
dc.SetBrush(*wxBLUE_BRUSH);
dc.SetTextForeground(*wxWHITE);
dc.DrawRoundedRectangle(rect, 5);
dc.DrawLabel(_T("MyRenderer"), wxNullBitmap, rect, wxALIGN_CENTER);
return rect.width;
}
示例12: Draw
void ColorChoice::Draw(wxDC& dc, const wxRect& rect,
const wxColour & color, const wxString & label) const
{
wxRect smallRect(rect);
smallRect.Deflate(popupPadding);
// Make a box for the color
int h = smallRect.GetHeight();
wxRect colorRect = wxRect(smallRect.GetTopLeft(), wxSize(h * 1.5, h));
smallRect.Offset(colorRect.width + popupPadding, 0);
dc.SetBrush(wxBrush(color, wxSOLID));
dc.SetPen(*wxBLACK_PEN);
dc.DrawRectangle(colorRect);
dc.DrawLabel(label, smallRect, wxALIGN_CENTER_VERTICAL);
}
示例13: DrawHeaderButton
virtual int DrawHeaderButton(wxWindow *WXUNUSED(win),
wxDC& dc,
const wxRect& rect,
int WXUNUSED(flags) = 0,
wxHeaderSortIconType WXUNUSED(sortArrow)
= wxHDR_SORT_ICON_NONE,
wxHeaderButtonParams* params = NULL)
{
wxDCBrushChanger setBrush(dc, *wxBLUE_BRUSH);
wxDCTextColourChanger setFgCol(dc, *wxWHITE);
dc.DrawRoundedRectangle(rect, 5);
wxString label;
if ( params )
label = params->m_labelText;
dc.DrawLabel(label, wxNullBitmap, rect, wxALIGN_CENTER);
return rect.width;
}
示例14: 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 wxStateButton::render(wxDC& dc) {
int w;
int h;
dc.GetSize(&w,&h);
if (m_bChecked) {
dc.SetBrush(*wxGREY_BRUSH);
dc.SetTextForeground(wxColor(255, 255, 255));
} else {
dc.SetBrush(wxBrush(wxColor(64, 64, 64)));
dc.SetTextForeground(*wxLIGHT_GREY);
}
dc.SetPen(*wxGREY_PEN);
wxRect r = GetClientRect();
dc.DrawRectangle(0, 0, w, h);
dc.SetFont(wxSystemSettings::GetFont(wxSystemFont::wxSYS_DEFAULT_GUI_FONT));
dc.DrawLabel(GetLabel(), r, wxALIGN_CENTER_VERTICAL | wxALIGN_CENTER_HORIZONTAL);
}
示例15: DrawImage
//.........这里部分代码省略.........
wxString replaceWith = Options.AsText(_T("Grid hide overrides char"));
curDiag->ParseASSTags();
size_t n = curDiag->Blocks.size();
for (size_t i=0;i<n;i++) {
AssDialogueBlock *block = curDiag->Blocks.at(i);
AssDialogueBlockPlain *plain = AssDialogueBlock::GetAsPlain(block);
if (plain) {
value += plain->GetText();
}
else {
if (mode == 1) {
value += replaceWith;
}
}
}
curDiag->ClearBlocks();
}
// Show overrides
else value = curDiag->Text;
// Cap length and set text
if (value.Length() > 512) value = value.Left(512) + _T("...");
strings.Add(value);
// Set color
curColor = 0;
bool inSel = IsInSelection(curRow,0);
if (inSel && curDiag->Comment) curColor = 5;
else if (inSel) curColor = 2;
else if (curDiag->Comment) curColor = 3;
else if (Options.AsBool(_T("Highlight subs in frame")) && IsDisplayed(curDiag)) curColor = 4;
}
else {
for (int j=0;j<11;j++) strings.Add(_T("?"));
}
// Draw row background color
if (curColor) {
dc.SetBrush(rowColors[curColor]);
dc.DrawRectangle((curColor == 1) ? 0 : colWidth[0],i*lineHeight+1,w,lineHeight);
}
// Set text color
if (collides) dc.SetTextForeground(Options.AsColour(_T("Grid collision foreground")));
else {
dc.SetTextForeground(foreColors[curColor]);
}
// Draw text
wxRect cur;
bool isCenter;
for (int j=0;j<11;j++) {
// Is center?
isCenter = !(j == 4 || j == 5 || j == 6 || j == 10);
// Calculate clipping
cur = wxRect(dx+4,dy,colWidth[j]-6,lineHeight);
// Set clipping
dc.DestroyClippingRegion();
dc.SetClippingRegion(cur);
// Draw
dc.DrawLabel(strings[j],cur,isCenter ? wxALIGN_CENTER : (wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT));
dx += colWidth[j];
}
//if (collides) dc.SetPen(wxPen(wxColour(255,0,0)));
// Draw grid
dc.DestroyClippingRegion();
if (drawGrid) {
dc.SetPen(wxPen(Options.AsColour(_T("Grid lines"))));
dc.DrawLine(0,dy+lineHeight,w,dy+lineHeight);
dc.SetPen(*wxTRANSPARENT_PEN);
}
}
// Draw grid columns
dx = 0;
if (drawGrid) {
dc.SetPen(wxPen(Options.AsColour(_T("Grid lines"))));
for (int i=0;i<10;i++) {
dx += colWidth[i];
dc.DrawLine(dx,0,dx,maxH);
}
dc.DrawLine(0,0,0,maxH);
dc.DrawLine(w-1,0,w-1,h);
}
// Draw currently active line border
dc.SetPen(wxPen(Options.AsColour(_T("Grid Active border"))));
dc.SetBrush(*wxTRANSPARENT_BRUSH);
dy = (editBox->linen+1-yPos) * lineHeight;
dc.DrawRectangle(0,dy,w,lineHeight+1);
// Done
dc.EndDrawing();
}