//----------------------------------------------------------------------------- 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_ ) ); } } }
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 {
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; } } } } } }