void QtBrushManager::removeBrush(const QString &name) { if (!d_ptr->theBrushMap.contains(name)) return; if (currentBrush() == name) setCurrentBrush(QString()); emit brushRemoved(name); d_ptr->theBrushMap.remove(name); }
/** * @brief Implements the drop of a pattern on the timeline. * The drag-and-dropped pattern is inserted in the pointed rectangle of the timeline. * @param[in] drop event. */ void BARSongAreaScene::dropEvent(QGraphicsSceneDragDropEvent *event) { QColor currentColor; /**< creation of the two variables that will receive the information sent by through the drag-and-drop. */ int patternLength; QByteArray itemData= event->mimeData()->data("application/x-dnditemdata"); /**< unpack the information stored in the MIME file. */ QDataStream droppedData(&itemData, QIODevice::ReadOnly); droppedData>>currentColor; /**< store the unpacked information in each relevant variable. */ droppedData>>patternLength; QGraphicsRectItem *testdrop=new QGraphicsRectItem(event->scenePos().toPoint().x() - (event->scenePos().toPoint().x() % timeLineSize),0,timeLineSize*patternLength,60); /**< creates a rectangle in the rectangle of the timeline where the drop occured. */ QBrush currentBrush(currentColor); /**< sets the color of the rectangle. This color corresponds to the color of the pattern that was dragged-and-dropped. */ testdrop->setBrush(currentBrush); addItem(testdrop); }
void CCodeView::OnPaint(wxPaintEvent& event) { // ------------------------- // General settings // ------------------------- std::unique_ptr<wxGraphicsContext> ctx(wxGraphicsContext::Create(wxPaintDC(this))); wxRect rc = GetClientRect(); ctx->SetFont(DebuggerFont, *wxBLACK); wxDouble w, h; ctx->GetTextExtent("0WJyq", &w, &h); if (h > m_rowHeight) m_rowHeight = h; ctx->GetTextExtent("W", &w, &h); int charWidth = w; struct branch { int src, dst, srcAddr; }; branch branches[256]; int numBranches = 0; // TODO: Add any drawing code here... int width = rc.width; int numRows = ((rc.height / m_rowHeight) / 2) + 2; // ------------ // ------------------------- // Colors and brushes // ------------------------- const wxColour bgColor = *wxWHITE; wxPen nullPen(bgColor); wxPen currentPen(*wxBLACK_PEN); wxPen selPen(*wxGREY_PEN); nullPen.SetStyle(wxPENSTYLE_TRANSPARENT); currentPen.SetStyle(wxPENSTYLE_SOLID); wxBrush currentBrush(*wxLIGHT_GREY_BRUSH); wxBrush pcBrush(*wxGREEN_BRUSH); wxBrush bpBrush(*wxRED_BRUSH); wxBrush bgBrush(bgColor); wxBrush nullBrush(bgColor); nullBrush.SetStyle(wxBRUSHSTYLE_TRANSPARENT); ctx->SetPen(nullPen); ctx->SetBrush(bgBrush); ctx->DrawRectangle(0, 0, 16, rc.height); ctx->DrawRectangle(0, 0, rc.width, 5); // ------------ // ----------------------------- // Walk through all visible rows // ----------------------------- for (int i = -numRows; i <= numRows; i++) { unsigned int address = m_curAddress + (i * m_align); int rowY1 = (rc.height / 2) + (m_rowHeight * i) - (m_rowHeight / 2); int rowY2 = (rc.height / 2) + (m_rowHeight * i) + (m_rowHeight / 2); wxString temp = wxString::Format("%08x", address); u32 color = m_debugger->GetColor(address); wxBrush rowBrush(wxColour(color >> 16, color >> 8, color)); ctx->SetBrush(nullBrush); ctx->SetPen(nullPen); ctx->DrawRectangle(0, rowY1, 16, rowY2 - rowY1 + 2); if (m_selecting && (address == m_selection)) ctx->SetPen(selPen); else ctx->SetPen(i == 0 ? currentPen : nullPen); if (address == m_debugger->GetPC()) ctx->SetBrush(pcBrush); else ctx->SetBrush(rowBrush); ctx->DrawRectangle(16, rowY1, width, rowY2 - rowY1 + 1); ctx->SetBrush(currentBrush); if (!m_plain) { // the address text is dark red ctx->SetFont(DebuggerFont, wxColour("#600000")); ctx->DrawText(temp, 17, rowY1); ctx->SetFont(DebuggerFont, *wxBLACK); } // If running if (m_debugger->IsAlive()) { std::vector<std::string> dis; SplitString(m_debugger->Disassemble(address), '\t', dis); dis.resize(2); static const size_t VALID_BRANCH_LENGTH = 10; const std::string& opcode = dis[0]; const std::string& operands = dis[1]; std::string desc; // look for hex strings to decode branches std::string hex_str; size_t pos = operands.find("0x8"); if (pos != std::string::npos) { hex_str = operands.substr(pos); } if (hex_str.length() == VALID_BRANCH_LENGTH) { u32 offs = std::stoul(hex_str, nullptr, 16); branches[numBranches].src = rowY1 + (m_rowHeight / 2); branches[numBranches].srcAddr = (address / m_align); branches[numBranches++].dst = (int)(rowY1 + ((s64)(u32)offs - (s64)(u32)address) * m_rowHeight / m_align + m_rowHeight / 2); desc = StringFromFormat("-->%s", m_debugger->GetDescription(offs).c_str()); // the -> arrow illustrations are purple ctx->SetFont(DebuggerFont, wxTheColourDatabase->Find("PURPLE")); } else { ctx->SetFont(DebuggerFont, *wxBLACK); } ctx->DrawText(StrToWxStr(operands), 17 + 17 * charWidth, rowY1); // ------------ // Show blr as its' own color if (opcode == "blr") ctx->SetFont(DebuggerFont, wxTheColourDatabase->Find("DARK GREEN")); else ctx->SetFont(DebuggerFont, wxTheColourDatabase->Find("VIOLET")); ctx->DrawText(StrToWxStr(opcode), 17 + (m_plain ? 1 * charWidth : 9 * charWidth), rowY1); if (desc.empty()) { desc = m_debugger->GetDescription(address); } if (!m_plain) { ctx->SetFont(DebuggerFont, *wxBLUE); // char temp[256]; // UnDecorateSymbolName(desc,temp,255,UNDNAME_COMPLETE); if (!desc.empty()) { ctx->DrawText(StrToWxStr(desc), 17 + 35 * charWidth, rowY1); } } // Show red breakpoint dot if (m_debugger->IsBreakpoint(address)) { ctx->SetBrush(bpBrush); ctx->DrawRectangle(2, rowY1 + 1, 11, 11); } } } // end of for // ------------ // ------------------------- // Colors and brushes // ------------------------- ctx->SetPen(currentPen); for (int i = 0; i < numBranches; i++) { int x = 17 + 49 * charWidth + (branches[i].srcAddr % 9) * 8; MoveTo(x - 2, branches[i].src); if (branches[i].dst < rc.height + 400 && branches[i].dst > -400) { LineTo(ctx, x + 2, branches[i].src); LineTo(ctx, x + 2, branches[i].dst); LineTo(ctx, x - 4, branches[i].dst); MoveTo(x, branches[i].dst - 4); LineTo(ctx, x - 4, branches[i].dst); LineTo(ctx, x + 1, branches[i].dst + 5); } // else //{ // This can be re-enabled when there is a scrollbar or // something on the codeview (the lines are too long) // LineTo(ctx, x+4, branches[i].src); // MoveTo(x+2, branches[i].dst-4); // LineTo(ctx, x+6, branches[i].dst); // LineTo(ctx, x+1, branches[i].dst+5); //} // LineTo(ctx, x, branches[i].dst+4); // LineTo(ctx, x-2, branches[i].dst); } // ------------ }
void KDChartLinesPainter::specificPaintData( QPainter* painter, const QRect& /*ourClipRect*/, KDChartTableDataBase* data, KDChartDataRegionList* regions, const KDChartAxisParams* ordinatePara, bool /*bNormalMode*/, uint chart, double logWidth, double /*areaWidthP1000*/, double logHeight, double axisYOffset, double minColumnValue, double maxColumnValue, double columnValueDistance, uint /*chartDatasetStart*/, uint /*chartDatasetEnd*/, uint datasetStart, uint datasetEnd ) { if( !data ) return; abscissaInfos ai; ai.bCenterThePoints = mCenterThePoints; calculateAbscissaInfos( *params(), *data, datasetStart, datasetEnd, logWidth, _dataRect, ai ); mCenterThePoints = ai.bCenterThePoints; bool bOrdinateDecreasing = ordinatePara ? ordinatePara->axisValuesDecreasing() : false; bool bOrdinateIsLogarithmic = ordinatePara ? (KDChartAxisParams::AxisCalcLogarithmic == ordinatePara->axisCalcMode()) : false; //const double ordinatePixelsPerUnit = logHeight / columnValueDistance; const double ordinatePixelsPerUnit = ( ordinatePara && (0.0 != ordinatePara->trueAxisDeltaPixels()) && (0.0 != ordinatePara->trueAxisDelta())) ? ordinatePara->trueAxisDeltaPixels() / ordinatePara->trueAxisDelta() : logHeight / columnValueDistance;; //qDebug("ordinatePixelsPerUnit: %f",ordinatePixelsPerUnit); const bool showThreeDLines = !mIsArea && params()->threeDLines(); enum { Normal, Stacked, Percent } mode = Normal; if ( ( ( mChartType == KDChartParams::Line ) && ( params()->lineChartSubType() == KDChartParams::LineNormal ) ) || ( ( mChartType == KDChartParams::Area ) && ( params()->areaChartSubType() == KDChartParams::AreaNormal ) ) ) mode = Normal; else if ( ( ( mChartType == KDChartParams::Line ) && ( params()->lineChartSubType() == KDChartParams::LineStacked ) ) || ( ( mChartType == KDChartParams::Area ) && ( params()->areaChartSubType() == KDChartParams::AreaStacked ) ) ) mode = Stacked; else if ( ( ( mChartType == KDChartParams::Line ) && ( params()->lineChartSubType() == KDChartParams::LinePercent ) ) || ( ( mChartType == KDChartParams::Area ) && ( params()->areaChartSubType() == KDChartParams::AreaPercent ) ) ) mode = Percent; else qDebug( "Internal error in KDChartLinesPainter::paintDataInternal(): Unknown subtype" ); QMap < int, double > currentValueSums; if ( mode == Stacked || mode == Percent ) { // this array is only used for stacked and percent lines, no need // to waste time initializing it for normal types for ( int value = 0; value < ai.numValues; ++value ) currentValueSums[ value ] = 0.0; } QMap < int, double > totalValueSums; // compute the position of the 0 axis double zeroXAxisI; if ( mode == Percent ) { if ( minColumnValue == 0.0 ) zeroXAxisI = logHeight + axisYOffset; else if( maxColumnValue == 0.0 ) zeroXAxisI = _dataRect.y() + axisYOffset; else zeroXAxisI = logHeight / 2.0 + _dataRect.y(); } else zeroXAxisI = ordinatePara->axisZeroLineStartY() - _dataRect.y(); // compute how to shift of the points in case we want them in the // middle of their respective columns int xShift = mCenterThePoints ? static_cast < int > ( ai.pointDist * 0.5 ) : 0; // calculate all points' positions // =============================== int arrayNumDatasets = 0; int arrayNumValues = ai.bAbscissaHasTrueAxisDtValues ? data->cols() : ai.numValues; int dataset; for( dataset = datasetEnd; ( dataset >= static_cast < int > ( datasetStart ) && dataset >= 0 ); --dataset ) ++arrayNumDatasets; #if COMPAT_QT_VERSION >= 0x030000 QValueVector<MyPoint> allPoints( #else QArray<MyPoint> allPoints( #endif arrayNumDatasets * arrayNumValues ); KDChartPropertySet curPropSet; int curPropSetId = KDChartPropertySet::UndefinedID; for( dataset = datasetEnd; ( dataset >= (int)datasetStart && dataset >= 0 ); --dataset ) { int prevPointX = -1; int prevPointY = -1; const KDChartParams::LineMarkerStyle defaultMarkerStyle = params()->lineMarkerStyle( dataset ); const QPen default2DPen( params()->lineColor().isValid() ? params()->lineColor() : params()->dataColor( dataset ), params()->lineWidth(), params()->lineStyle( dataset ) ); if( ai.bAbscissaHasTrueAxisDtValues ) ai.numValues = data->cols(); QVariant vValY; QVariant vValX; int cellPropID; for( int value = 0; value < ai.numValues; ++value ) { //if ( mode == Percent ) // valueTotal = data->colAbsSum( value ); double valueTotal = 0.0; // Will only be used for Percent if( mode == Percent ) { valueTotal = 0.0; // iterate over datasets of this axis only: for ( uint dataset2 = datasetStart; dataset2 <= datasetEnd; ++dataset2 ) { if( data->cellCoord( dataset2, value, vValY, 1 ) && QVariant::Double == vValY.type() ) valueTotal += vValY.toDouble(); } } if( data->cellContent( dataset, value, vValY, vValX, cellPropID ) && QVariant::Double == vValY.type() && ( !ai.bCellsHaveSeveralCoordinates || QVariant::Invalid != vValX.type() ) ){ //qDebug("a. cellPropID: %i",cellPropID); // calculate Ordinate axis value // ----------------------------- double cellValue = vValY.toDouble(); double drawValue = 0.0; // PENDING(kalle) This does not work for AreaPercent yet if ( mode == Stacked ) drawValue = ( cellValue + currentValueSums[ value ] ) * ordinatePixelsPerUnit; else if ( mode == Percent ) drawValue = ( ( cellValue + currentValueSums[ value ] ) / valueTotal ) * 100.0 * ordinatePixelsPerUnit; else { // LineNormal or AreaNormal if( bOrdinateIsLogarithmic ){ if( 0.0 < cellValue ) drawValue = log10( cellValue ) * ordinatePixelsPerUnit; else drawValue = -10250.0; //qDebug("\nlogarithmic calc - cellValue: %f drawValue: %f", // cellValue, drawValue ); }else{ drawValue = cellValue * ordinatePixelsPerUnit * (bOrdinateDecreasing ? -1.0 : 1.0); //qDebug("\nlinear calc - cellValue: %f\n - drawValue: %f", // cellValue, drawValue ); } } // calculate Abscissa axis value // ----------------------------- double xValue; bool skipMe = !calculateAbscissaAxisValue( vValX, ai, value, xValue ); // calculate and store the point and region / draw the marker // ---------------------------------------------------------- if( !skipMe ){ // prevent the point from being toooo far // below the bottom (or above the top, resp.) // of the cliprect double pY = QMIN( zeroXAxisI - drawValue, (logHeight + axisYOffset) * 3 ); pY = QMAX( pY, -(logHeight + axisYOffset) * 3 ); // specify the Point int myPointX = static_cast < int > ( xValue ) + xShift; int myPointY = static_cast < int > ( pY ); if( cellPropID == curPropSetId && myPointX == prevPointX && myPointY == prevPointY ){ allPoints[ static_cast < int > ( datasetEnd-dataset ) * arrayNumValues + value ].setSkipThis( true ); skipMe = true; //qDebug("skipped"); }else{ // use typecast to make it compile on windows using qt232 allPoints[ static_cast < int > ( datasetEnd-dataset ) * arrayNumValues + value ].set( myPointX, myPointY, cellValue ); //qDebug("ok"); } if( !skipMe ){ // -------------------------------------------------------- // determine any 'extra' properties assigned to this cell // by traversing the property set chain (if necessary) // -------------------------------------------------------- if( cellPropID != curPropSetId ){ //qDebug("b. ( curPropSetId: %i )",curPropSetId); //qDebug("b. cellPropID: %i",cellPropID); //qDebug(curPropSet.name().latin1()); if( cellPropID != KDChartPropertySet::UndefinedID && params()->calculateProperties( cellPropID, curPropSet ) ){ curPropSetId = cellPropID; //qDebug("c. curPropSetId: %i",curPropSetId); //qDebug(curPropSet.name().latin1()); }else{ curPropSetId = KDChartPropertySet::UndefinedID; } } // make sure any extra horiz. and/or vert. lines and/or markers // are drawn *before* the data lines and/or markers are painted if( mChartType == KDChartParams::Line ){ if( curPropSetId != KDChartPropertySet::UndefinedID ){ drawExtraLinesAndMarkers( curPropSet, default2DPen, defaultMarkerStyle, myPointX, myPointY, painter, ai.abscissaPara, ordinatePara, logWidth/1000.0, logHeight/1000.0, false ); } } prevPointX = myPointX; prevPointY = myPointY; } } // calculate running sum for stacked and percent if ( mode == Stacked || mode == Percent ) { if( cellValue == KDCHART_POS_INFINITE ) currentValueSums[ value ] = KDCHART_POS_INFINITE; else if( currentValueSums[ value ] != KDCHART_POS_INFINITE ) currentValueSums[ value ] += cellValue; } } } } QPointArray previousPoints; // no vector since only areas need it, // and these do not support 3d yet // Store some (dataset-independend) default values // to be used unless other properties // have been specified for the respective data cell: // const bool defaultDrawMarkers = mDrawMarkers; for ( dataset = datasetEnd; ( dataset >= (int)datasetStart && dataset >= 0 ); --dataset ) { // Store some (dataset-dependend) default values // to be used unless other properties // have been specified for the respective data cell: // const QPen default2DPen( params()->lineColor().isValid() ? params()->lineColor() : params()->dataColor( dataset ), params()->lineWidth(), params()->lineStyle( dataset ) ); bool currentDrawMarkers = defaultDrawMarkers; const KDChartParams::LineMarkerStyle markerStyle = params()->lineMarkerStyle( dataset ); // the +2 is for the areas (if any) QPtrVector< QPointArray > points( 2 ); points.setAutoDelete( true ); /* Pending Michel - we need to keep track of the * non rotated points for 3D lines */ QPtrVector< QPointArray > oripoints( 2 ); oripoints.setAutoDelete( true ); int i = 0; for( i = 0; i < 2; ++i ) { points.insert( i, new QPointArray( ai.numValues + 2 ) ); oripoints.insert( i, new QPointArray( ai.numValues + 2 ) ); } if( ai.bAbscissaHasTrueAxisDtValues ) ai.numValues = data->cols(); int point = 0; for ( int value = 0; value < ai.numValues; ++value ) { // determine and store marker properties assigned to this cell // ----------------------------------------------------------- currentDrawMarkers = defaultDrawMarkers; int cellPropID; if( data->cellProp( dataset, value, cellPropID ) && cellPropID != curPropSetId ){ if( cellPropID != KDChartPropertySet::UndefinedID && params()->calculateProperties( cellPropID, curPropSet ) ) curPropSetId = cellPropID; else curPropSetId = KDChartPropertySet::UndefinedID; } if( curPropSetId != KDChartPropertySet::UndefinedID ){ // we can safely call the following functions and ignore their // return values since they will touch the parameters' values // if the propSet *contains* corresponding own values only. int iDummy; curPropSet.hasOwnShowMarker( iDummy, currentDrawMarkers ); } int iVec = static_cast < int > ( datasetEnd-dataset ) * arrayNumValues + value; if( allPoints[ iVec ].bValid && !allPoints[ iVec ].bSkipThis ){ const MyPoint& mp = allPoints[iVec]; //qDebug("\np.x() %i p.y() %i", p.x(), p.y() ); // For 3D lines, we need two points (that lie // behind each other on the Z axis). For 2D lines and // areas, we need only one point. if( showThreeDLines ) { points[0]->setPoint( point, project( mp.p.x(), mp.p.y(), (datasetStart+dataset)*params()->threeDLineDepth() ) ); points[1]->setPoint( point, project( mp.p.x(), mp.p.y(), (datasetStart+dataset + 1)*params()->threeDLineDepth() ) ); oripoints[0]->setPoint( point, mp.p.x(), mp.p.y() ); oripoints[1]->setPoint( point, mp.p.x() - (datasetStart+dataset + 1)*params()->threeDLineDepth(), mp.p.y() - (datasetStart+dataset + 1)*params()->threeDLineDepth() ); } else // 2D lines or areas points[0]->setPoint( point, mp.p ); ++point; int x = mp.p.x(); int y = QMAX(QMIN(mp.p.y(), static_cast < int > (logHeight +axisYOffset)), 0); bool markerIsOutside = y != mp.p.y(); // draw the marker and store the region if ( currentDrawMarkers ){ uint theAlignment = Qt::AlignCenter; bool hasOwnSize = false; int theWidth = 0; int theHeight = 0; QColor theColor(params()->dataColor( dataset )); int theStyle = markerStyle; if( curPropSetId != KDChartPropertySet::UndefinedID ){ // we can safely call the following functions and ignore their // return values since they will touch the parameters' values // if the propSet *contains* corresponding own values only. int iDummy; curPropSet.hasOwnMarkerAlign( iDummy, theAlignment ); curPropSet.hasOwnMarkerColor( iDummy, theColor ); curPropSet.hasOwnMarkerStyle( iDummy, theStyle ); QSize size(theWidth, theHeight); hasOwnSize = curPropSet.hasOwnMarkerSize(iDummy, size); if( hasOwnSize ){ theWidth = size.width(); theHeight = size.height(); } } drawMarker( painter, params(), _areaWidthP1000, _areaHeightP1000, _dataRect.x(), _dataRect.y(), markerIsOutside ? KDChartParams::LineMarker1Pixel : theStyle, theColor, QPoint(x,y), dataset, value, chart, regions, hasOwnSize ? &theWidth : 0, hasOwnSize ? &theHeight : 0, theAlignment ); } // store the region else if( regions ) { QRect rect( QPoint( x-params()->lineWidth()-1, y-params()->lineWidth()-1 ), QPoint( x+params()->lineWidth()+1, y+params()->lineWidth()+1 ) ); rect.moveBy( _dataRect.x(), _dataRect.y() ); regions->append( new KDChartDataRegion(dataset, value, chart, rect) ); } } } if ( point ) { bool bDrawLines = (0 != params()->lineWidth()); if ( mIsArea ) { // first draw with the fill brush, no pen, with the // zero axis points or upper border points added for the first // dataset or with the previous points reversed for all other // datasets. painter->setPen( QPen( Qt::NoPen ) ); const QBrush datasetBrush( params()->dataColor( dataset ), Qt::SolidPattern ); painter->setBrush( datasetBrush ); QBrush currentBrush( datasetBrush ); if ( mode == Normal || dataset == (int)datasetEnd ) { /// first dataset (or any dataset in normal mode, where /// the datasets overwrite each other) // no 3d handling for areas yet QPoint lastPoint = points[0]->point( point - 1 ); // zeroXAxisI can be too far below the abscissa, but it's // the only thing we have. Likewise can 0 be too far above // the upper boundary, but again it's the only thing we // have, at the rest is clipped anyway. int yCoord; if ( params()->areaLocation() == KDChartParams::AreaBelow || mode == Percent ) yCoord = static_cast<int>(zeroXAxisI); else yCoord = static_cast<int>(axisYOffset); // old: draw the complete area in on go: /* // no 3d handling for areas yet points[0]->setPoint( point, lastPoint.x(), yCoord ); point++; QPoint firstPoint = points[0]->point( 0 ); points[0]->setPoint( point, firstPoint.x(), yCoord ); point++; painter->drawPolygon( *points[0], false, 0, point ); */ // new: draw individual area segments: curPropSetId = KDChartPropertySet::UndefinedID; for( int value = 0; value < point-1; ++value ) { int cellPropID; if( data->cellProp( dataset, value, cellPropID ) && cellPropID != curPropSetId ){ if( cellPropID != KDChartPropertySet::UndefinedID && params()->calculateProperties( cellPropID, curPropSet ) ){ curPropSetId = cellPropID; }else{ curPropSetId = KDChartPropertySet::UndefinedID; } // preset with default value QBrush theAreaBrush = datasetBrush; if( curPropSetId != KDChartPropertySet::UndefinedID ){ // we can safely call the following functions and ignore their // return values since they will touch the parameters' values // if the propSet *contains* corresponding own values only. int iDummy; curPropSet.hasOwnAreaBrush( iDummy, theAreaBrush ); } painter->setBrush( theAreaBrush ); } QPointArray segment( 4 ); segment.setPoint( 0, points[0]->point( value ) ); segment.setPoint( 1, points[0]->point( value+1 ) ); segment.setPoint( 2, points[0]->point( value+1 ).x(), yCoord ); segment.setPoint( 3, points[0]->point( value ).x(), yCoord ); painter->drawPolygon( segment ); } // old: draw the complete area in on go: /* // remove the last two points added point -= 2; */ //qDebug("\n111"); } // if ( mode == Normal || dataset == (int)datasetEnd ) else { // don't mess around with the original array; we'll need // that for the next time through. //qDebug("222"); // no 3d handling for areas yet QPointArray thisSection = points[0]->copy(); thisSection.resize( point + previousPoints.size() ); // append the previous array (there is guaranteed to be // one because we are at least the second time through // here) in reverse order for ( unsigned int i = 0; i < previousPoints.size(); ++i ) { thisSection.setPoint( point + i, previousPoints.point( previousPoints.size() - i - 1 ) ); //qDebug("\nx: %i",previousPoints.point( previousPoints.size() - i - 1 ).x()); //qDebug("y: %i",previousPoints.point( previousPoints.size() - i - 1 ).y()); } painter->drawPolygon( thisSection ); } // draw the line with no brush and outline color painter->setBrush( Qt::NoBrush ); painter->setPen( QPen( params()->outlineDataColor(), params()->outlineDataLineWidth() ) ); } else { // line if( showThreeDLines ) { // This is a 3D line: // We draw the line with the data color brush // and the outline data pen. painter->setBrush( params()->dataColor( dataset ) ); painter->setPen( QPen( params()->outlineDataColor(), params()->outlineDataLineWidth() ) ); } else { // This is a 2D line: // We draw the line with the no brush // and the data color if no special line color was specified. painter->setBrush( Qt::NoBrush ); painter->setPen( default2DPen ); } } // Neither draw the contour line if this is a pure Point chart // nor draw it for the last row of a percent area chart. if( bDrawLines && ( (mode != Percent) || !mIsArea || (dataset != (int)datasetEnd) ) ){ if( showThreeDLines ) { // A 3D line needs to be drawn piece-wise for ( int value = 0; value < point-1; ++value ) { // if( data->cell( dataset, value ).hasValue() && // data->cell( dataset, value+1 ).hasValue() ) { // qDebug( "Draw a segment in dataset %d from %d to %d", dataset, value, value+1 ); //store the rotated points ( see project() ) QPointArray rotatedSegment( 4 ); rotatedSegment.setPoint( 0, points[0]->point( value )); rotatedSegment.setPoint( 1, points[0]->point( value+1 ) ); rotatedSegment.setPoint( 2, points[1]->point( value+1 ) ); rotatedSegment.setPoint( 3, points[1]->point( value ) ); //store the true points without rotation QPointArray trueSegment( 4 ); trueSegment.setPoint( 0, oripoints[0]->point( value )); trueSegment.setPoint( 1, oripoints[0]->point( value+1 ) ); trueSegment.setPoint( 2, oripoints[1]->point( value+1 ) ); trueSegment.setPoint( 3, oripoints[1]->point( value ) ); // calculate the rotated points position relative to each other // we will then be able to keep the rotation ( see: project () ) // by reporting this position relative to the true segment line //left side pt3 and pt0 int dx30 = rotatedSegment.point(3).x() - rotatedSegment.point(0).x(); int dy30 = rotatedSegment.point(3).y() - rotatedSegment.point(0).y(); //right side pt1 and pt2 int dx12 = rotatedSegment.point(2).x() - rotatedSegment.point(1).x(); int dy12 = rotatedSegment.point(2).y() - rotatedSegment.point(1).y(); // store and paint the "3D" segment QPointArray segment( 4 ); segment.setPoint( 0, trueSegment.point(0) ); segment.setPoint( 1, trueSegment.point(1) ); segment.setPoint( 2, trueSegment.point(1).x() + dx12, trueSegment.point(1).y() + dy12 ); segment.setPoint( 3, trueSegment.point(0).x() + dx30, trueSegment.point(0).y() + dy30); //PENDING Michel 3dlines drawing a segment with showThreeDLines painter->drawPolygon( segment ); // } else // qDebug( "Can't draw a segment in dataset %d from %d to %d", dataset, value, value+1 ); } } else { QPoint p1, p2; // Note: If markers are drawn very near to each other // and tiny markers are used // we don't draw the connecting lines. bool b4PMarkers = KDChartParams::LineMarker4Pixels == markerStyle; bool bTinyMarkers = KDChartParams::LineMarker1Pixel == markerStyle || b4PMarkers; curPropSetId = KDChartPropertySet::UndefinedID; painter->setPen( default2DPen ); for ( int value = 0; value < point-1; ++value ) { p1 = points[0]->point( value ); p2 = points[0]->point( value+1 ); // Determine properties assigned to this cell // and change the painter if necessarry: currentDrawMarkers = defaultDrawMarkers; int cellPropID; if( data->cellProp( dataset, value, cellPropID ) && cellPropID != curPropSetId ){ if( cellPropID != KDChartPropertySet::UndefinedID && params()->calculateProperties( cellPropID, curPropSet ) ){ curPropSetId = cellPropID; }else{ curPropSetId = KDChartPropertySet::UndefinedID; } // preset with default values int theLineWidth = default2DPen.width(); QColor theLineColor = default2DPen.color(); Qt::PenStyle theLineStyle = default2DPen.style(); if( curPropSetId != KDChartPropertySet::UndefinedID ){ // we can safely call the following functions and ignore their // return values since they will touch the parameters' values // if the propSet *contains* corresponding own values only. int iDummy; curPropSet.hasOwnLineWidth ( iDummy, theLineWidth ); curPropSet.hasOwnLineColor ( iDummy, theLineColor ); curPropSet.hasOwnLineStyle ( iDummy, theLineStyle ); curPropSet.hasOwnShowMarker( iDummy, currentDrawMarkers ); } painter->setPen( QPen( theLineColor, theLineWidth, theLineStyle ) ); } if( !currentDrawMarkers ){ //PENDING Michel: drawing a line - not currentMarkers painter->drawLine( p1, p2 ); }else{ int dx = p2.x() - p1.x(); int dy = p2.y() - p1.y(); if( !bTinyMarkers || (abs(dx) > 4) || (abs(dy) > 4) ){ if( bTinyMarkers ) { double m = !dx ? 100.0 : !dy ? 0.01 : ((double)dy / (double)dx); double am = fabs(m); int dxx; int dyy; if( 0.25 > am ){ dxx = 3; dyy = 0; }else if( 0.67 > am ){ dxx = 3; dyy = 1; }else if( 1.33 > am ){ dxx = 2; dyy = 2; }else if( 4.0 > am ){ dxx = 1; dyy = 3; }else{ dxx = 0; dyy = 3; } if( 0 > dx ) dxx *= -1; if( 0 > dy ) dyy *= -1; if( b4PMarkers ){ if( 0 < dx ) ++p1.rx(); else if( 0 > dx ) ++p2.rx(); if( 0 < dy ) ++p1.ry(); else if( 0 > dy ) ++p2.ry(); } p1.rx() += dxx; p1.ry() += dyy; p2.rx() -= dxx; p2.ry() -= dyy; } //PENDING Michel: drawing a line - currentMarkers painter->drawLine( p1, p2 ); } } } } } } // Save point array for next way through (needed for e.g. stacked // areas), not for 3D currently points[0]->resize( point ); previousPoints = points[0]->copy(); } // Now draw any extra lines (and/or their markers, resp.) that // are to be printed IN FRONT of the normal lines: if( mChartType == KDChartParams::Line ){ for( dataset = datasetEnd; ( dataset >= (int)datasetStart && dataset >= 0 ); --dataset ) { const KDChartParams::LineMarkerStyle defaultMarkerStyle = params()->lineMarkerStyle( dataset ); const QPen default2DPen( params()->lineColor().isValid() ? params()->lineColor() : params()->dataColor( dataset ), params()->lineWidth(), params()->lineStyle( dataset ) ); if( ai.bAbscissaHasTrueAxisDtValues ) ai.numValues = data->cols(); for ( int value = 0; value < ai.numValues; ++value ) { int iVec = static_cast < int > ( datasetEnd-dataset ) * arrayNumValues + value; if( allPoints[ iVec ].bValid ){ const MyPoint& mp = allPoints[iVec]; //qDebug("\np.x() %i p.y() %i", p.x(), p.y() ); // -------------------------------------------------------- // determine any 'extra' properties assigned to this cell // by traversing the property set chain (if necessary) // -------------------------------------------------------- int cellPropID; if( data->cellProp( dataset, value, cellPropID ) && cellPropID != curPropSetId ){ if( cellPropID != KDChartPropertySet::UndefinedID && params()->calculateProperties( cellPropID, curPropSet ) ) curPropSetId = cellPropID; else curPropSetId = KDChartPropertySet::UndefinedID; } if( curPropSetId != KDChartPropertySet::UndefinedID ){ drawExtraLinesAndMarkers( curPropSet, default2DPen, defaultMarkerStyle, mp.p.x(), mp.p.y(), painter, ai.abscissaPara, ordinatePara, logWidth/1000.0, logHeight/1000.0, true ); } } } } } //qDebug(const_cast < KDChartParams* > ( params() )->properties( KDCHART_PROPSET_NORMAL_DATA )->name().latin1()); //qDebug(const_cast < KDChartParams* > ( params() )->properties( KDCHART_PROPSET_TRANSPARENT_DATA )->name().latin1()); //qDebug(const_cast < KDChartParams* > ( params() )->properties( KDCHART_PROPSET_HORI_LINE )->name().latin1()); //qDebug(const_cast < KDChartParams* > ( params() )->properties( KDCHART_PROPSET_VERT_LINE )->name().latin1()); //qDebug("--"); }
void CMemoryView::OnPaint(wxPaintEvent& event) { wxPaintDC dc(this); wxRect rc = GetClientRect(); wxFont hFont("Courier"); hFont.SetFamily(wxFONTFAMILY_TELETYPE); wxCoord w,h; dc.GetTextExtent("0WJyq", &w, &h, nullptr, nullptr, &hFont); if (h > rowHeight) rowHeight = h; dc.GetTextExtent("0WJyq", &w, &h, nullptr, nullptr, &DebuggerFont); if (h > rowHeight) rowHeight = h; if (viewAsType==VIEWAS_HEX) dc.SetFont(hFont); else dc.SetFont(DebuggerFont); dc.GetTextExtent("W", &w, &h); int fontSize = w; int textPlacement = 17 + 9 * fontSize; // TODO: Add any drawing code here... int width = rc.width; int numRows = (rc.height / rowHeight) / 2 + 2; dc.SetBackgroundMode(wxTRANSPARENT); const wxColour bgColor = *wxWHITE; wxPen nullPen(bgColor); wxPen currentPen(*wxBLACK_PEN); wxPen selPen(*wxGREY_PEN); nullPen.SetStyle(wxTRANSPARENT); wxBrush currentBrush(*wxLIGHT_GREY_BRUSH); wxBrush pcBrush(*wxGREEN_BRUSH); wxBrush mcBrush(*wxBLUE_BRUSH); wxBrush bgBrush(bgColor); wxBrush nullBrush(bgColor); nullBrush.SetStyle(wxTRANSPARENT); dc.SetPen(nullPen); dc.SetBrush(bgBrush); dc.DrawRectangle(0, 0, 16, rc.height); dc.DrawRectangle(0, 0, rc.width, 5+8); // TODO - clean up this freaking mess!!!!! for (int row = -numRows; row <= numRows; row++) { unsigned int address = curAddress + row * align; int rowY1 = rc.height / 2 + rowHeight * row - rowHeight / 2; int rowY2 = rc.height / 2 + rowHeight * row + rowHeight / 2; wxString temp = wxString::Format("%08x", address); u32 col = debugger->GetColor(address); wxBrush rowBrush(wxColour(col >> 16, col >> 8, col)); dc.SetBrush(nullBrush); dc.SetPen(nullPen); dc.DrawRectangle(0, rowY1, 16, rowY2); if (selecting && (address == selection)) dc.SetPen(selPen); else dc.SetPen(row == 0 ? currentPen : nullPen); if (address == debugger->GetPC()) dc.SetBrush(pcBrush); else dc.SetBrush(rowBrush); dc.DrawRectangle(16, rowY1, width, rowY2 - 1); dc.SetBrush(currentBrush); dc.SetTextForeground("#600000"); // Dark red dc.DrawText(temp, 17, rowY1); if (viewAsType != VIEWAS_HEX) { char mem[256]; debugger->GetRawMemoryString(memory, address, mem, 256); dc.SetTextForeground(wxTheColourDatabase->Find("NAVY")); dc.DrawText(StrToWxStr(mem), 17+fontSize*(8), rowY1); dc.SetTextForeground(*wxBLACK); } if (!PowerPC::HostIsRAMAddress(address)) continue; if (debugger->IsAlive()) { std::string dis; u32 mem_data = debugger->ReadExtraMemory(memory, address); if (viewAsType == VIEWAS_FP) { float flt = *(float *)(&mem_data); dis = StringFromFormat("f: %f", flt); } else if (viewAsType == VIEWAS_ASCII) { u32 a[4] = { (mem_data & 0xff000000) >> 24, (mem_data & 0xff0000) >> 16, (mem_data & 0xff00) >> 8, (mem_data & 0xff) }; for (auto& word : a) { if (word == '\0') word = ' '; } dis = StringFromFormat("%c%c%c%c", a[0], a[1], a[2], a[3]); } else if (viewAsType == VIEWAS_HEX)
void CCodeView::OnPaint(wxPaintEvent& event) { // -------------------------------------------------------------------- // General settings // ------------------------- wxPaintDC dc(this); wxRect rc = GetClientRect(); dc.SetFont(DebuggerFont); wxCoord w,h; dc.GetTextExtent(_T("0WJyq"),&w,&h); if (h > rowHeight) rowHeight = h; dc.GetTextExtent(_T("W"),&w,&h); int charWidth = w; struct branch { int src, dst, srcAddr; }; branch branches[256]; int numBranches = 0; // TODO: Add any drawing code here... int width = rc.width; int numRows = (rc.height / rowHeight) / 2 + 2; // ------------ // -------------------------------------------------------------------- // Colors and brushes // ------------------------- dc.SetBackgroundMode(wxTRANSPARENT); // the text background const wxChar* bgColor = _T("#ffffff"); wxPen nullPen(bgColor); wxPen currentPen(_T("#000000")); wxPen selPen(_T("#808080")); // gray nullPen.SetStyle(wxTRANSPARENT); currentPen.SetStyle(wxSOLID); wxBrush currentBrush(_T("#FFEfE8")); // light gray wxBrush pcBrush(_T("#70FF70")); // green wxBrush bpBrush(_T("#FF3311")); // red wxBrush bgBrush(bgColor); wxBrush nullBrush(bgColor); nullBrush.SetStyle(wxTRANSPARENT); dc.SetPen(nullPen); dc.SetBrush(bgBrush); dc.DrawRectangle(0, 0, 16, rc.height); dc.DrawRectangle(0, 0, rc.width, 5); // ------------ // -------------------------------------------------------------------- // Walk through all visible rows // ------------------------- for (int i = -numRows; i <= numRows; i++) { unsigned int address = curAddress + i * align; int rowY1 = rc.height / 2 + rowHeight * i - rowHeight / 2; int rowY2 = rc.height / 2 + rowHeight * i + rowHeight / 2; wxString temp = wxString::Format(_T("%08x"), address); u32 col = debugger->GetColor(address); wxBrush rowBrush(wxColor(col >> 16, col >> 8, col)); dc.SetBrush(nullBrush); dc.SetPen(nullPen); dc.DrawRectangle(0, rowY1, 16, rowY2 - rowY1 + 2); if (selecting && (address == selection)) dc.SetPen(selPen); else dc.SetPen(i == 0 ? currentPen : nullPen); if (address == debugger->GetPC()) dc.SetBrush(pcBrush); else dc.SetBrush(rowBrush); dc.DrawRectangle(16, rowY1, width, rowY2 - rowY1 + 1); dc.SetBrush(currentBrush); if (!plain) { dc.SetTextForeground(_T("#600000")); // the address text is dark red dc.DrawText(temp, 17, rowY1); dc.SetTextForeground(_T("#000000")); } // If running if (debugger->IsAlive()) { char dis[256]; debugger->Disassemble(address, dis, 256); char* dis2 = strchr(dis, '\t'); char desc[256] = ""; // If we have a code if (dis2) { *dis2 = 0; dis2++; // look for hex strings to decode branches const char* mojs = strstr(dis2, "0x8"); if (mojs) { for (int k = 0; k < 8; k++) { bool found = false; for (int j = 0; j < 22; j++) { if (mojs[k + 2] == "0123456789ABCDEFabcdef"[j]) found = true; } if (!found) { mojs = nullptr; break; } } } if (mojs) { int offs; sscanf(mojs + 2, "%08x", &offs); branches[numBranches].src = rowY1 + rowHeight / 2; branches[numBranches].srcAddr = address / align; branches[numBranches++].dst = (int)(rowY1 + ((s64)(u32)offs - (s64)(u32)address) * rowHeight / align + rowHeight / 2); sprintf(desc, "-->%s", debugger->GetDescription(offs).c_str()); dc.SetTextForeground(_T("#600060")); // the -> arrow illustrations are purple } else { dc.SetTextForeground(_T("#000000")); } dc.DrawText(StrToWxStr(dis2), 17 + 17*charWidth, rowY1); // ------------ } // Show blr as its' own color if (strcmp(dis, "blr")) dc.SetTextForeground(_T("#007000")); // dark green else dc.SetTextForeground(_T("#8000FF")); // purple dc.DrawText(StrToWxStr(dis), 17 + (plain ? 1*charWidth : 9*charWidth), rowY1); if (desc[0] == 0) { strcpy(desc, debugger->GetDescription(address).c_str()); } if (!plain) { dc.SetTextForeground(_T("#0000FF")); // blue //char temp[256]; //UnDecorateSymbolName(desc,temp,255,UNDNAME_COMPLETE); if (strlen(desc)) { dc.DrawText(StrToWxStr(desc), 17 + 35 * charWidth, rowY1); } } // Show red breakpoint dot if (debugger->IsBreakpoint(address)) { dc.SetBrush(bpBrush); dc.DrawRectangle(2, rowY1 + 1, 11, 11); } } } // end of for // ------------ // -------------------------------------------------------------------- // Colors and brushes // ------------------------- dc.SetPen(currentPen); for (int i = 0; i < numBranches; i++) { int x = 17 + 49 * charWidth + (branches[i].srcAddr % 9) * 8; _MoveTo(x-2, branches[i].src); if (branches[i].dst < rc.height + 400 && branches[i].dst > -400) { _LineTo(dc, x+2, branches[i].src); _LineTo(dc, x+2, branches[i].dst); _LineTo(dc, x-4, branches[i].dst); _MoveTo(x, branches[i].dst - 4); _LineTo(dc, x-4, branches[i].dst); _LineTo(dc, x+1, branches[i].dst+5); } //else //{ // This can be re-enabled when there is a scrollbar or // something on the codeview (the lines are too long) //_LineTo(dc, x+4, branches[i].src); //_MoveTo(x+2, branches[i].dst-4); //_LineTo(dc, x+6, branches[i].dst); //_LineTo(dc, x+1, branches[i].dst+5); //} //_LineTo(dc, x, branches[i].dst+4); //_LineTo(dc, x-2, branches[i].dst); } // ------------ }
void CtrlDisAsmView::paintEvent(QPaintEvent *) { QPainter painter(this); painter.setBrush(Qt::white); painter.setPen(Qt::white); painter.drawRect(rect()); struct branch { int src,dst,srcAddr; bool conditional; }; branch branches[256]; int numBranches=0; int width = rect().width(); int numRows=(rect().height()/rowHeight); QColor bgColor(0xFFFFFFFF); QPen nullPen(bgColor); QPen currentPen(QColor(0,0,0)); QPen selPen(QColor(0xFF808080)); QPen condPen(QColor(0xFFFF3020)); QBrush lbr; lbr.setColor(bgColor); QBrush currentBrush(QColor(0xFFFFEfE8)); QBrush pcBrush(QColor(0xFF70FF70)); QFont normalFont("Arial", 10); QFont boldFont("Arial", 10); QFont alignedFont("Monospace", 10); alignedFont.setStyleHint(QFont::Monospace); boldFont.setBold(true); painter.setFont(normalFont); QImage breakPoint(":/resources/breakpoint.ico"); int i; curAddress&=~(align-1); align=(debugger->getInstructionSize(0)); for (i=0; i<=numRows; i++) { unsigned int address=curAddress + (i-(numRows/2))*align; int rowY1 = rect().top() + rowHeight*i; int rowY2 = rect().top() + rowHeight*i + rowHeight - 1; lbr.setColor((unsigned int)marker == address ? QColor(0xFFFFEEE0) : QColor(debugger->getColor(address))); QColor bg = lbr.color(); painter.setBrush(currentBrush); painter.setPen(nullPen); painter.drawRect(0,rowY1,16-1,rowY2-rowY1); if (selecting && address == (unsigned int)selection) painter.setPen(selPen); else { if(i==numRows/2) painter.setPen(currentPen); else painter.setPen(bg); } painter.setBrush(QBrush(bg)); if (address == debugger->getPC()) { painter.setBrush(pcBrush); } painter.drawRect(16,rowY1,width-16-1,rowY2-rowY1); painter.setBrush(currentBrush); QPen textPen(QColor(halfAndHalf(bg.rgba(),0))); painter.setPen(textPen); painter.setFont(alignedFont); painter.drawText(17,rowY1-3+rowHeight,QString("%1").arg(address,8,16,QChar('0'))); painter.setFont(normalFont); textPen.setColor(QColor(0xFF000000)); painter.setPen(textPen); if (debugger->isAlive()) { const char *dizz = debugger->disasm(address, align); char dis[512]; strcpy(dis, dizz); char *dis2 = strchr(dis,'\t'); char desc[256]=""; if (dis2) { *dis2=0; dis2++; const char *mojs=strstr(dis2,"->$"); if (mojs) { for (int i=0; i<8; i++) { bool found=false; for (int j=0; j<22; j++) { if (mojs[i+3]=="0123456789ABCDEFabcdef"[j]) found=true; } if (!found) { mojs=0; break; } } } if (mojs) { int offs; sscanf(mojs+3,"%08x",&offs); branches[numBranches].src=rowY1 + rowHeight/2; branches[numBranches].srcAddr=address/align; branches[numBranches].dst=(int)(rowY1+((s64)offs-(s64)address)*rowHeight/align + rowHeight/2); branches[numBranches].conditional = (dis[1]!=0); //unconditional 'b' branch numBranches++; const char *t = debugger->getDescription(offs).c_str(); if (memcmp(t,"z_",2)==0) t+=2; if (memcmp(t,"zz_",3)==0) t+=3; sprintf(desc,"-->%s", t); textPen.setColor(QColor(0xFF600060)); painter.setPen(textPen); } else { textPen.setColor(QColor(0xFF000000)); painter.setPen(textPen); } painter.drawText(149,rowY1-3+rowHeight,QString(dis2)); } textPen.setColor(QColor(0xFF007000)); painter.setPen(textPen); painter.setFont(boldFont); painter.drawText(84,rowY1-3+rowHeight,QString(dis)); painter.setFont(normalFont); if (desc[0]==0) { const char *t = debugger->getDescription(address).c_str(); if (memcmp(t,"z_",2)==0) t+=2; if (memcmp(t,"zz_",3)==0) t+=3; strcpy(desc,t); } if (memcmp(desc,"-->",3) == 0) { textPen.setColor(QColor(0xFF0000FF)); painter.setPen(textPen); } else { textPen.setColor(halfAndHalf(halfAndHalf(bg.rgba(),0),bg.rgba())); painter.setPen(textPen); } if (strlen(desc)) painter.drawText(std::max(280,width/3+190),rowY1-3+rowHeight,QString(desc)); if (debugger->isBreakpoint(address)) { painter.drawImage(2,rowY1+2,breakPoint); } } } for (i=0; i<numBranches; i++) { painter.setPen(branches[i].conditional ? condPen : currentPen); int x=280+(branches[i].srcAddr%9)*8; QPoint curPos(x-2,branches[i].src); if (branches[i].dst<rect().bottom()+200 && branches[i].dst>-200) { painter.drawLine(curPos, QPoint(x+2,branches[i].src)); curPos = QPoint(x+2,branches[i].src); painter.drawLine(curPos, QPoint(x+2,branches[i].dst)); curPos = QPoint(x+2,branches[i].dst); painter.drawLine(curPos, QPoint(x-4,branches[i].dst)); curPos = QPoint(x,branches[i].dst-4); painter.drawLine(curPos, QPoint(x-4,branches[i].dst)); curPos = QPoint(x-4,branches[i].dst); painter.drawLine(curPos, QPoint(x+1,branches[i].dst+5)); } else { painter.drawLine(curPos, QPoint(x+4,branches[i].src)); } } }
void CMemoryView::OnPaint(wxPaintEvent& event) { wxPaintDC dc(this); wxRect rc = GetClientRect(); wxFont hFont(_T("Courier")); hFont.SetFamily(wxFONTFAMILY_TELETYPE); wxCoord w,h; dc.GetTextExtent(_T("0WJyq"),&w,&h,nullptr,nullptr,&hFont); if (h > rowHeight) rowHeight = h; dc.GetTextExtent(_T("0WJyq"),&w,&h,nullptr,nullptr,&DebuggerFont); if (h > rowHeight) rowHeight = h; if (viewAsType==VIEWAS_HEX) dc.SetFont(hFont); else dc.SetFont(DebuggerFont); dc.GetTextExtent(_T("W"),&w,&h); int fontSize = w; int textPlacement = 17 + 9 * fontSize; // TODO: Add any drawing code here... int width = rc.width; int numRows = (rc.height / rowHeight) / 2 + 2; dc.SetBackgroundMode(wxTRANSPARENT); const wxChar* bgColor = _T("#ffffff"); wxPen nullPen(bgColor); wxPen currentPen(_T("#000000")); wxPen selPen(_T("#808080")); // gray nullPen.SetStyle(wxTRANSPARENT); wxBrush currentBrush(_T("#FFEfE8")); // light gray wxBrush pcBrush(_T("#70FF70")); // green wxBrush mcBrush(_T("#1133FF")); // blue wxBrush bgBrush(bgColor); wxBrush nullBrush(bgColor); nullBrush.SetStyle(wxTRANSPARENT); dc.SetPen(nullPen); dc.SetBrush(bgBrush); dc.DrawRectangle(0, 0, 16, rc.height); dc.DrawRectangle(0, 0, rc.width, 5+8); // TODO - clean up this freaking mess!!!!! for (int row = -numRows; row <= numRows; row++) { unsigned int address = curAddress + row * align; int rowY1 = rc.height / 2 + rowHeight * row - rowHeight / 2; int rowY2 = rc.height / 2 + rowHeight * row + rowHeight / 2; wxString temp = wxString::Format(_T("%08x"), address); u32 col = debugger->GetColor(address); wxBrush rowBrush(wxColor(col >> 16, col >> 8, col)); dc.SetBrush(nullBrush); dc.SetPen(nullPen); dc.DrawRectangle(0, rowY1, 16, rowY2); if (selecting && (address == selection)) dc.SetPen(selPen); else dc.SetPen(row == 0 ? currentPen : nullPen); if (address == debugger->GetPC()) dc.SetBrush(pcBrush); else dc.SetBrush(rowBrush); dc.DrawRectangle(16, rowY1, width, rowY2 - 1); dc.SetBrush(currentBrush); dc.SetTextForeground(_T("#600000")); dc.DrawText(temp, 17, rowY1); if (viewAsType != VIEWAS_HEX) { char mem[256]; debugger->GetRawMemoryString(memory, address, mem, 256); dc.SetTextForeground(_T("#000080")); dc.DrawText(StrToWxStr(mem), 17+fontSize*(8), rowY1); dc.SetTextForeground(_T("#000000")); } if (debugger->IsAlive()) { char dis[256] = {0}; u32 mem_data = debugger->ReadExtraMemory(memory, address); if (viewAsType == VIEWAS_FP) { float flt = *(float *)(&mem_data); sprintf(dis, "f: %f", flt); } else if (viewAsType == VIEWAS_ASCII) { u32 a[4] = {(mem_data&0xff000000)>>24, (mem_data&0xff0000)>>16, (mem_data&0xff00)>>8, mem_data&0xff}; for (auto& word : a) if (word == '\0') word = ' '; sprintf(dis, "%c%c%c%c", a[0], a[1], a[2], a[3]); } else if (viewAsType == VIEWAS_HEX)
void CtrlMemView::paintEvent(QPaintEvent *) { QPainter painter(this); painter.setBrush(Qt::white); painter.setPen(Qt::white); painter.drawRect(rect()); if (!debugger) return; int width = rect().width(); int numRows=(rect().bottom()/rowHeight)/2+1; QPen nullPen(0xFFFFFF); QPen currentPen(0xFF000000); QPen selPen(0x808080); QBrush lbr(0xFFFFFF); QBrush nullBrush(0xFFFFFF); QBrush currentBrush(0xFFEFE8); QBrush pcBrush(0x70FF70); QPen textPen; QFont normalFont("Arial", 10); QFont alignedFont("Monospace", 10); alignedFont.setStyleHint(QFont::Monospace); painter.setFont(normalFont); int i; curAddress&=~(align-1); for (i=-numRows; i<=numRows; i++) { unsigned int address=curAddress + i*align*alignMul; int rowY1 = rect().bottom()/2 + rowHeight*i - rowHeight/2; int rowY2 = rect().bottom()/2 + rowHeight*i + rowHeight/2; char temp[256]; painter.setBrush(currentBrush); if (selecting && address == (unsigned int)selection) painter.setPen(selPen); else painter.setPen(i==0 ? currentPen : nullPen); painter.drawRect(0, rowY1, 16-1, rowY2 - rowY1 - 1); painter.drawRect(16, rowY1, width - 16 -1, rowY2 - rowY1 - 1); painter.setBrush(nullBrush); textPen.setColor(0x600000); painter.setPen(textPen); painter.setFont(alignedFont); painter.drawText(17,rowY1-2+rowHeight, QString("%1").arg(address,8,16,QChar('0'))); textPen.setColor(0xFF000000); painter.setPen(textPen); if (debugger->isAlive()) { switch(mode) { case MV_NORMAL: { const char *m = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; if (Memory::IsValidAddress(address)) { u32 memory[4] = { debugger->readMemory(address), debugger->readMemory(address+4), debugger->readMemory(address+8), debugger->readMemory(address+12) }; m = (const char*)memory; sprintf(temp, "%08x %08x %08x %08x ................", memory[0],memory[1],memory[2],memory[3]); } for (int i=0; i<16; i++) { int c = (unsigned char)m[i]; if (c>=32 && c<255) temp[i+37]=c; } } painter.setFont(alignedFont); painter.drawText(85,rowY1 - 2 + rowHeight, temp); break; case MV_SYMBOLS: { /* textPen.setColor(0x0000FF); painter.setPen(textPen); int fn = g_symbolMap->GetSymbolNum(address); if (fn==-1) { sprintf(temp, "%s (ns)", Memory::GetAddressName(address)); } else sprintf(temp, "%s (0x%x b)", g_symbolMap->GetSymbolName(fn),g_symbolMap->GetSymbolSize(fn)); painter.drawText(205,rowY1 - 2 + rowHeight, temp); textPen.setColor(0xFF000000); painter.setPen(textPen); if (align==4) { u32 value = Memory::ReadUnchecked_U32(address); int symbolnum = g_symbolMap->GetSymbolNum(value); if(symbolnum>=0) sprintf(temp, "%08x [%s]", value, g_symbolMap->GetSymbolName(symbolnum)); } else if (align==2) { u16 value = Memory::ReadUnchecked_U16(address); int symbolnum = g_symbolMap->GetSymbolNum(value); if(symbolnum>=0) sprintf(temp, "%04x [%s]", value, g_symbolMap->GetSymbolName(symbolnum)); } painter.drawText(85,rowY1 - 2 + rowHeight, temp);*/ break; } case MV_MAX: break; } } } }
void CtrlRegisterList::paintEvent(QPaintEvent *) { int numRowsTotal = cpu->GetNumRegsInCategory(category); int maxRowsDisplay =rect().bottom()/rowHeight - 1; selection = std::min(std::max(selection,0),numRowsTotal); curVertOffset = std::max(std::min(curVertOffset,numRowsTotal - maxRowsDisplay),0); QScrollBar *bar = findChild<QScrollBar*>("RegListScroll"); if(bar) { bar->setMinimum(0); bar->setMaximum(numRowsTotal - maxRowsDisplay); bar->setPageStep(1); bar->setValue(curVertOffset); } QPainter painter(this); painter.setBrush(Qt::white); painter.setPen(Qt::white); painter.drawRect(rect()); if (!cpu) return; QFont normalFont = QFont("Arial", 10); painter.setFont(normalFont); int width = rect().width(); QColor bgColor(0xffffff); QPen nullPen(bgColor); QPen currentPen(QColor(0xFF000000)); QPen selPen(0x808080); QPen textPen; QBrush lbr; lbr.setColor(bgColor); QBrush nullBrush(bgColor); QBrush currentBrush(0xFFEfE8); QBrush pcBrush(0x70FF70); int nc = cpu->GetNumCategories(); for (int i=0; i<nc; i++) { painter.setPen(i==category?currentPen:nullPen); painter.setBrush(i==category?pcBrush:nullBrush); painter.drawRect(width*i/nc,0,width*(i+1)/nc - width*i/nc -1,rowHeight-1); QString name = cpu->GetCategoryName(i); painter.setPen(currentPen); painter.drawText(width*i/nc+1,-3+rowHeight,name); } int numRows=rect().bottom()/rowHeight; for (int i=curVertOffset; i<curVertOffset+numRows; i++) { int rowY1 = rowHeight*(i-curVertOffset+1); int rowY2 = rowHeight*(i-curVertOffset+2)-1; lbr.setColor(i==selection?0xffeee0:0xffffff); painter.setBrush(currentBrush); painter.setPen(nullPen); painter.drawRect(0,rowY1,16-1,rowY2-rowY1); if (selecting && i == selection) painter.setPen(selPen); else painter.setPen(nullPen); QBrush mojsBrush(lbr.color()); painter.setBrush(mojsBrush); painter.drawRect(16,rowY1,width-16-1,rowY2-rowY1); // Check for any changes in the registers. if (lastPC != cpu->GetPC()) { for (int i = 0, n = cpu->GetNumRegsInCategory(0); i < n; ++i) { u32 v = cpu->GetRegValue(0, i); changedCat0Regs[i] = v != lastCat0Values[i]; lastCat0Values[i] = v; } lastPC = cpu->GetPC(); } painter.setBrush(currentBrush); if (i<cpu->GetNumRegsInCategory(category)) { QString regName = cpu->GetRegName(category,i); textPen.setColor(0x600000); painter.setPen(textPen); painter.drawText(17,rowY1-3+rowHeight,regName); textPen.setColor(0xFF000000); painter.setPen(textPen); char temp[256]; cpu->PrintRegValue(category,i,temp); if (category == 0 && changedCat0Regs[i]) { textPen.setColor(0x0000FF); painter.setPen(textPen); } else { textPen.setColor(0x004000); painter.setPen(textPen); } painter.drawText(77,rowY1-3+rowHeight,temp); } } }