本文整理汇总了C++中wxPaintDC::DrawText方法的典型用法代码示例。如果您正苦于以下问题:C++ wxPaintDC::DrawText方法的具体用法?C++ wxPaintDC::DrawText怎么用?C++ wxPaintDC::DrawText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wxPaintDC
的用法示例。
在下文中一共展示了wxPaintDC::DrawText方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnPaintCustom
//-----------------------------------------------------------------------------
void LineProfileCanvas::OnPaintCustom( wxPaintDC& dc )
//-----------------------------------------------------------------------------
{
wxCoord yOffset( 1 ), w( 0 ), h( 0 );
dc.GetSize( &w, &h );
const double scaleX = static_cast<double>( w - 2 * GetBorderWidth() ) / static_cast<double>( ( GetDataCount() == 0 ) ? 1 : GetDataCount() - 1 );
const double scaleY = GetScaleY( h );
DrawMarkerLines( dc, w, h, scaleX );
unsigned int from, to;
GetDrawRange( &from, &to );
const int borderWidth = GetBorderWidth();
const wxString YMarkerString( wxString::Format( wxT( "Draw Range(absolute): %d / %d, " ), from, to ) );
wxCoord xOffset;
dc.GetTextExtent( YMarkerString, &xOffset, 0 );
xOffset += borderWidth / 2;
dc.DrawText( YMarkerString, borderWidth / 2, yOffset );
if( m_boUnsupportedPixelFormat )
{
dc.SetTextForeground( *wxRED );
dc.DrawText( wxString( wxT( "Unsupported pixel format" ) ), xOffset, yOffset );
dc.SetTextForeground( *wxBLACK );
}
else if( m_ppData )
{
for( int channel = 0; channel < m_ChannelCount; channel++ )
{
DrawProfileLine( dc, h, borderWidth + 1, scaleX, scaleY, from, to, m_ppData[channel], GetDataCount(), *m_Pens[channel].pColour_ );
DrawInfoString( dc, wxString::Format( wxT( "%s%s: " ), ( channel != 0 ) ? wxT( ", " ) : wxT( "" ), m_Pens[channel].description_.c_str() ), xOffset, yOffset, *( m_Pens[channel].pColour_ ) );
}
}
}
示例2: DrawAxis
void TimeLogChart::DrawAxis(wxPaintDC &dc)
{
const int MARKER_OFFSET = 5;
dc.SetPen(*wxTRANSPARENT_PEN);
dc.SetBrush(*wxWHITE_BRUSH);
dc.DrawRectangle(m_axisBounds);
dc.SetPen(wxPen(wxColour(*wxBLACK), 1, wxPENSTYLE_DOT));
int topBound = m_axisBounds.GetTop();
int leftBound = m_axisBounds.GetLeft();
int rightBound = m_axisBounds.GetRight();
int bottomBound = m_axisBounds.GetBottom();
int dx = leftBound;
wxFont savedFont = dc.GetFont();
dc.SetFont(*m_valueFont);
int n = m_logDuration -1;
for (int i = 0; i <= n; i++)
{
dx = leftBound + (int)floor(i*m_axisBounds.GetWidth() / (double)n);
if (i % m_logTickFrequency == 0)
{
dc.DrawLine(dx, topBound, dx, bottomBound);
if (i % (m_logTickFrequency*2) == 0)
{
// draw axis marker
wxString s = wxString::Format(wxT("%d secs"), (m_logDuration-i));
wxSize ext = dc.GetTextExtent(s);
dc.DrawText(s, dx - ext.GetWidth()/2, bottomBound + MARKER_OFFSET);
}
}
}
dc.DrawLine(dx, topBound, dx, bottomBound);
int yValue = m_maxValue;
int yValueSteps = (m_minValue-m_maxValue)/m_valueDivisions;
int ySteps = ValueToPixel((m_maxValue - m_minValue)/m_valueDivisions);
int dy = topBound;
for (int n = 0; n < m_valueDivisions; n++)
{
dc.DrawLine(leftBound, dy, rightBound, dy);
wxString s = wxString::Format(m_valueAxisFormat, (double)yValue/m_valueAxisScale);
wxSize ext = dc.GetTextExtent(s);
dc.DrawText(s, m_axisBounds.GetLeft()-ext.GetWidth() - MARKER_OFFSET, dy - ext.GetHeight()/2);
dy += ySteps;
yValue += yValueSteps;
}
dc.DrawLine(leftBound, bottomBound, rightBound, bottomBound);
dc.SetFont(savedFont);
}
示例3: DrawTicks
void THISCLASS::DrawTicks(wxPaintDC &dc, const SwisTrackCoreEventRecorder::Timeline *timeline) {
wxSize dcsize = dc.GetSize();
int dw = dcsize.GetWidth();
//int dh=dcsize.GetHeight(); // Not needed
dc.SetFont(GetFont());
dc.SetPen(wxPen(wxColour(0xcc, 0xcc, 0xcc)));
dc.SetTextForeground(wxColour(0xcc, 0xcc, 0xcc));
// Calculate how many ticks to display
double mintickdistance = 5;
double mintickdistancetime = mintickdistance / mViewScale;
double tickdistancetime = pow(10, ceil(log(mintickdistancetime) / log((double)10)));
// Draw ticks
double endtime = mSwisTrack->mSwisTrackCore->mEventRecorder->CalculateDuration(&(timeline->mBegin), &(timeline->mEnd));
int ticknumber = (int)ceil(-mViewOffset / mViewScale / tickdistancetime);
while (true) {
double xtime = ticknumber * tickdistancetime;
if (xtime >= endtime) {
break;
}
int x = (int)floor(xtime * mViewScale + mViewOffset);
if (x > dw) {
break;
}
if (ticknumber % 10 == 0) {
dc.DrawLine(x, 0, x, 4);
wxString label = wxString::Format(wxT("%d"), (int)(xtime * 1000));
int textwidth, textheight;
GetTextExtent(label, &textwidth, &textheight) ;
textwidth >>= 1;
dc.DrawText(label, x - textwidth, 2);
} else {
示例4: DrawLegends
void TimeLogChart::DrawLegends(wxPaintDC &dc)
{
const int LEGEND_LENGTH = 10;
if (m_chartCollection == NULL && m_chartCollection->GetCount() == 0)
return;
dc.SetFont(*m_valueFont);
wxSize ext = dc.GetTextExtent("H");
int dy = GetClientRect().GetBottom() - ext.GetHeight();
int dx = m_axisBounds.GetLeft();
for (int i = 0; i < m_chartCollection->GetCount(); i++)
{
ChartValueList *list = m_chartCollection->Item(i)->GetData();
dc.SetPen(wxPen(list->GetColour(), 5));
// draw legend with latest value
wxString label = list->GetTitle();
if (list->GetCount() > 0)
{
// get the latest value
double value = *list->GetLast()->GetData()/m_valueAxisScale;
label += " (" + wxString::Format(m_valueAxisFormat, value) + ")";
}
ext = dc.GetTextExtent(label);
dc.DrawLine(dx, dy, dx + LEGEND_LENGTH, dy);
dx += LEGEND_LENGTH + 5;
dc.DrawText(label, dx, dy - ext.GetHeight()/2);
dx += ext.GetWidth() + 20;
}
}
示例5: DrawTitle
void TimeLogChart::DrawTitle(wxPaintDC &dc)
{
wxRect titleRect = GetClientRect();
titleRect.SetHeight(m_axisBounds.GetTop());
titleRect.Deflate(m_axisBounds.GetLeft(), 5);
dc.SetFont(*m_titleFont);
dc.DrawText(m_title, titleRect.GetTopLeft());
}
示例6: DrawText
static int DrawText(wxPaintDC& arDC, const wxString& arString, int aStartPosition, wxFont& arFont)
{
int Width = 0;
int Height = 0;
if (arString.Length() > 0)
{
arDC.SetFont(arFont);
arDC.GetTextExtent(arString, &Width, &Height);
arDC.DrawText(arString, aStartPosition, 0);
}
return aStartPosition+Width;
}
示例7: DoPaint
void MyVideoCaptureWindow::DoPaint( wxPaintDC& dc )
{
wxVideoCaptureWindowBase::DoPaint(dc);
if (!IsDeviceConnected())
{
// The window is blank when disconnected so we might as well
// give a hint to people that they need to connect first.
wxBitmap bmp = wxArtProvider::GetBitmap(wxART_MISSING_IMAGE, wxART_OTHER, wxSize(32, 32));
wxSize clientSize(GetClientSize());
wxString txt(wxT("Please select a capture device"));
wxSize txtSize = dc.GetTextExtent(txt);
dc.DrawText(txt, clientSize.GetWidth()/2 - txtSize.GetWidth()/2,
clientSize.GetHeight()/2 - txtSize.GetHeight());
dc.DrawBitmap(bmp, clientSize.GetWidth()/2 - bmp.GetWidth()/2,
clientSize.GetHeight()/2 + 4);
}
}
示例8: DrawBoardNumbers
void SudokuSolverFrame::DrawBoardNumbers(wxPaintDC &dc)
{
unsigned int spSq = 0;
unsigned int smallSide;
unsigned int i,j,k, pVal;
wxString debugString;
wxString pString;
wxColour redC, greenC, blackC;
redC.Set(200,0,0);
greenC.Set(0,200,0);
blackC.Set(0,0,0);
wxSize sz = GameBoardPanel->GetClientSize();
if (sz.x < sz.y)
smallSide = sz.x;
else
smallSide = sz.y;
spSq = smallSide / 9;
smallSide -= 10;
// Create a 16 point, serif font, that is not bold,
// not italic, and not underlined.
dc.SetPen(*wxBLACK_PEN );
wxFont BigFont(spSq/2,wxFONTFAMILY_ROMAN,wxNORMAL,wxNORMAL,false);
wxFont SmallFont(spSq/8,wxFONTFAMILY_ROMAN,wxNORMAL,wxNORMAL,false);
// Tell dc to use this font
dc.SetFont(BigFont);
for(i=0;i < 9;i++)
{
for(j=0;j<9;j++)
{
if (mGuessGB->GetVal(i, j) != 0) // Show if there's a value
{
dc.SetFont(BigFont);
debugString.clear();
debugString << _("i = ") << i << _(" j = ") << j;
debugString << _("\nVal = ") << mGuessGB->GetVal(i, j);
//wxMessageBox(debugString);
pVal = 0;
pVal = mGuessGB->GetVal(i, j);
if(mGuessGB->GetShown(i, j))
dc.SetTextForeground(blackC);
else if(mGuessGB->GetVal(i, j) == mMainGB->GetVal(i, j))
dc.SetTextForeground(greenC);
else
dc.SetTextForeground(redC);
pString.clear();
pString << pVal;
dc.DrawText(pString, 6 * spSq / 20 + ((j) * spSq), spSq / 6 + ((i) * spSq));
}
else // Draw all possibles
{
for(k=1;k<=9;k++)
{
dc.SetFont(SmallFont);
pString.clear();
pString << k;
if(mGuessGB->GetPossibles(i, j, k))
switch (k)
{
case 1:
dc.DrawText(pString, spSq*j + spSq/12, spSq*i + spSq/12);
break;
case 2:
dc.DrawText(pString, spSq*j + spSq*5/12, spSq*i + spSq/12);
break;
case 3:
dc.DrawText(pString, spSq*j + spSq*9/12, spSq*i + spSq/12);
break;
case 4:
dc.DrawText(pString, spSq*j + spSq/12, spSq*i + spSq*9/24);
break;
case 5:
dc.DrawText(pString, spSq*j + spSq*5/12, spSq*i + spSq*9/24);
break;
case 6:
dc.DrawText(pString, spSq*j + spSq*9/12, spSq*i + spSq*9/24);
break;
case 7:
dc.DrawText(pString, spSq*j + spSq*1/12, spSq*i + spSq*8/12);
break;
case 8:
dc.DrawText(pString, spSq*j + spSq*5/12, spSq*i + spSq*8/12);
break;
case 9:
dc.DrawText(pString, spSq*j + spSq*9/12, spSq*i + spSq*8/12);
break;
default:
break;
}
}
}
//.........这里部分代码省略.........