void EdgeItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { QPen selectedPen(Qt::black, 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); QPen unselectedPen(Qt::black, 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); if( isSelected() ) painter->setPen(selectedPen); else painter->setPen(unselectedPen); painter->drawPath( path() ); painter->drawPath( m_arrowPath ); }
void CBTGView::btgvPDraw(CDC *pDC) { CBTGDoc *pDocument; BTGVertex *pVertex; CPoint p; pDocument = GetDocument(); pVertex = pDocument->GetFirstBTGVertex(); while(pVertex) { if(pVertex->bVisible == FALSE) { pVertex = pVertex->GetNext(); continue; } // Get this vertex's colors. CPen standardPen(PS_SOLID, 1, RGB(0xFF, 0xFF, 0xFF)); CPen selectedPen(PS_SOLID, 2, RGB(0, 0xFF, 0xFF)); CBrush interiorBrush(RGB(pVertex->red, pVertex->green, pVertex->blue)); pDC->SelectObject(&interiorBrush); // Get this vertex's screen coords. p.x = (long)pVertex->x; p.y = (long)pVertex->y; pDocument->CalculateScreenCoordinates(&p); // Is this vertex selected? if(bitTest(pVertex->flags, BTGVertex::btgvFlags_Selected)) { pDC->SelectObject(&selectedPen); } else { pDC->SelectObject(&standardPen); } // Draw a rectangle around the vertex. pDC->Rectangle(p.x - BTGV_SIZE2, p.y - BTGV_SIZE2, p.x + BTGV_SIZE2, p.y + BTGV_SIZE2); pVertex = pVertex->GetNext(); } }
void CFlowTreeView::DrawScreenIcons(CDC *pDC) { CPoint *pWorkPoint; CRect *pWorkRect; CSize *pWorkSize; char *pWorkName; Screen *pWorkScreen; CFEManDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); // Create the pens we need to draw the screen icons in both thier selected and // non-selected forms. CPen normalPen(PS_SOLID, 1, RGB(0, 0, 0)); CPen selectedPen(PS_SOLID, 3, RGB(255, 0, 0)); pWorkScreen = pDoc->GetFirstScreen(); while(pWorkScreen) { pWorkPoint = pWorkScreen->GetIconPos(); pWorkRect = pWorkScreen->GetIconBounds(); pWorkSize = pWorkScreen->GetNameSize(); pWorkName = pWorkScreen->GetName(); // Check to see if the screen icon is selected. If it is, draw it with // a thicker border. if(pWorkScreen->GetScreenStatus() == Screen::SS_SELECTED) { pDC->SelectObject(selectedPen); } else { pDC->SelectObject(normalPen); } // Draw the bounds of the icon. pDC->Rectangle(pWorkRect->left, pWorkRect->top, pWorkRect->right, pWorkRect->bottom); // Draw the text in the icon. pDC->SetTextAlign(TA_CENTER | TA_TOP); pDC->TextOut(pWorkPoint->x + (pWorkSize->cx / 2), pWorkPoint->y, pWorkName, strlen(pWorkName)); pWorkScreen = (Screen *)pWorkScreen->GetNext(); } }
void PaletteColorPicker::OnPaint(wxPaintEvent& evt) { wxPaintDC dc(this); wxPen defaultPen(wxColor(64, 64, 64)), selectedPen(wxColor(255, 255, 0), 2); int symbol_width = GetSize().GetWidth() / 16; int symbol_height = GetSize().GetHeight() - 16; wxColor colors[16]; for (int i = 0; i < 256; i += 16) { colors[i / 16] = wxColor(255 - i, 255 - i, 255 - i); } for (int i = 0; i < 256; i += 80) { colors[i / 80] = wxColor(255 - i, 255 - i, 255 - i); } for (int i = 0; i < 16; ++i) { wxPoint position; position.x = symbol_width * i; position.y = 0; wxBrush tempBrush = wxBrush(colors[i]); dc.SetBrush(tempBrush); if (m_selectedColor == i) { dc.SetPen(selectedPen); } else { dc.SetPen(defaultPen); } dc.DrawRectangle(position, wxSize(symbol_width, symbol_height)); dc.DrawText(wxString::Format("%d", i), wxPoint(position.x, symbol_height + 2)); } }
void CBTGView::btgpPDraw(CDC *pDC) { CBTGDoc *pDocument; BTGPolygon *pPolygon; CPoint p0, p1, p2; CPen *regEdgePen; CPen standardPen(PS_SOLID, 1, RGB(181, 182, 181)); CPen selectedPen(PS_SOLID, 2, RGB(181, 182, 181)); CPen selEdgePen(PS_SOLID, 2, RGB(0, 255, 0)); pDocument = GetDocument(); pPolygon = pDocument->GetFirstBTGPolygon(); while(pPolygon) { if(pPolygon->bVisible == FALSE) { pPolygon = pPolygon->GetNext(); continue; } // Calculate the proper coordinates. p0.x = (int)pPolygon->v0->x; p0.y = (int)pPolygon->v0->y; p1.x = (int)pPolygon->v1->x; p1.y = (int)pPolygon->v1->y; p2.x = (int)pPolygon->v2->x; p2.y = (int)pPolygon->v2->y; pDocument->CalculateScreenCoordinates(&p0); pDocument->CalculateScreenCoordinates(&p1); pDocument->CalculateScreenCoordinates(&p2); // Is this polygon selected? if(bitTest(pPolygon->flags, BTGPolygon::btgpFlags_Selected)) { regEdgePen = &selectedPen; } else { regEdgePen = &standardPen; } if((pDocument->btgpSelectedEdge == 1) && (bitTest(pPolygon->flags, BTGPolygon::btgpFlags_Selected))) { pDC->SelectObject(&selEdgePen); } else { pDC->SelectObject(regEdgePen); } // First Edge pDC->MoveTo(p0.x, p0.y); pDC->LineTo(p1.x, p1.y); if((pDocument->btgpSelectedEdge == 2) && (bitTest(pPolygon->flags, BTGPolygon::btgpFlags_Selected))) { pDC->SelectObject(&selEdgePen); } else { pDC->SelectObject(regEdgePen); } // Second Edge pDC->LineTo(p2.x, p2.y); if((pDocument->btgpSelectedEdge == 3) && (bitTest(pPolygon->flags, BTGPolygon::btgpFlags_Selected))) { pDC->SelectObject(&selEdgePen); } else { pDC->SelectObject(regEdgePen); } // Third Edge pDC->LineTo(p0.x, p0.y); pPolygon = pPolygon->GetNext(); } }
void CBTGView::btgsPDraw(CDC *pDC) { CBTGDoc *pDocument; BTGStar *pStar; CPoint p; CDC dcCompatible; dcCompatible.CreateCompatibleDC(pDC); pDocument = GetDocument(); pStar = pDocument->GetFirstBTGStar(); pDC->SelectStockObject(HOLLOW_BRUSH); while(pStar) { if(pStar->bVisible == FALSE) { pStar = pStar->GetNext(); continue; } p.x = (long)pStar->x; p.y = (long)pStar->y; pDocument->CalculateScreenCoordinates(&p); if(pStar->pMyStar) { // Get this star's colors. CPen standardPen(PS_SOLID, 1, RGB(pStar->red, pStar->green, pStar->blue)); CPen selectedPen(PS_SOLID, 2, RGB(pStar->red, pStar->green, pStar->blue)); // Get this star's screen coords. p.x = (long)pStar->x; p.y = (long)pStar->y; pDocument->CalculateScreenCoordinates(&p); // Is this star selected? if(bitTest(pStar->flags, BTGStar::btgsFlags_Selected)) { pDC->SelectObject(&selectedPen); } else { pDC->SelectObject(&standardPen); } // Draw a Ellipse around the Star. pDC->Ellipse(p.x - pStar->pMyStar->myFile.header.imageWidth / 2, p.y - pStar->pMyStar->myFile.header.imageHeight / 2, p.x + pStar->pMyStar->myFile.header.imageWidth / 2, p.y + pStar->pMyStar->myFile.header.imageHeight / 2); } else { // Get this star's colors. CPen standardPen(PS_SOLID, 1, RGB(pStar->red, pStar->green, pStar->blue)); CPen selectedPen(PS_SOLID, 2, RGB(pStar->red, pStar->green, pStar->blue)); // Get this star's screen coords. p.x = (long)pStar->x; p.y = (long)pStar->y; pDocument->CalculateScreenCoordinates(&p); // Is this star selected? if(bitTest(pStar->flags, BTGStar::btgsFlags_Selected)) { pDC->SelectObject(&selectedPen); } else { pDC->SelectObject(&standardPen); } // Draw a ellipse around the Star. pDC->Ellipse(p.x - BTGS_SIZE2, p.y - BTGS_SIZE2, p.x + BTGS_SIZE2, p.y + BTGS_SIZE2); pDC->MoveTo(p.x - BTGS_SIZE2, p.y - BTGS_SIZE2); pDC->LineTo(p.x + BTGS_SIZE2, p.y + BTGS_SIZE2); pDC->MoveTo(p.x + BTGS_SIZE2, p.y - BTGS_SIZE2); pDC->LineTo(p.x - BTGS_SIZE2, p.y + BTGS_SIZE2); } pStar = pStar->GetNext(); } }
void PipelineFlowChart::paintEvent(QPaintEvent *e) { if(m_StageNames.empty()) return; QPainter p(this); p.fillRect(rect(), Qt::transparent); p.setRenderHint(QPainter::Antialiasing, true); const QRectF totalRect = totalAreaRect(); const QRectF box0Rect = boxRect(0); const qreal radius = qMin(MaxBoxCornerRadius, box0Rect.height() * BoxCornerRadiusFraction); const qreal arrowY = totalRect.y() + totalRect.height() / 2; QColor base = palette().color(QPalette::Base); QColor baseText = palette().color(QPalette::Text); QColor inactiveWin = palette().color(QPalette::Inactive, QPalette::Dark); QColor inactiveWinText = palette().color(QPalette::Inactive, QPalette::WindowText); QColor tooltip = palette().color(QPalette::ToolTipBase); QColor tooltipText = palette().color(QPalette::ToolTipText); QPen pen(baseText); QPen selectedPen(Qt::red); int num = numGaps(); for(int i = 0; i < num; i++) { if(!m_StageFlows[i] || !m_StageFlows[i + 1]) continue; float right = totalRect.x() + (i + 1) * (box0Rect.width() + boxMargin()); float left = right - boxMargin(); p.setBrush(baseText); drawArrow(p, pen, ArrowHeadSize, arrowY, left, right); } num = numItems(); for(int i = 0; i < num; i++) { QRectF boxrect = boxRect(i); QBrush backBrush(base); QPen textPen(baseText); QPen outlinePen = pen; if(!stageEnabled(i)) { backBrush.setColor(inactiveWin); textPen.setColor(inactiveWinText); } if(i == m_HoverStage) { backBrush.setColor(tooltip); textPen.setColor(tooltipText); } if(i == m_SelectedStage) { outlinePen = selectedPen; } outlinePen.setWidthF(BoxBorderWidth); p.setPen(outlinePen); p.setBrush(backBrush); p.drawRoundedRect(boxrect, radius, radius); QTextOption opts(Qt::AlignCenter); opts.setWrapMode(QTextOption::NoWrap); QString s = m_StageNames[i]; QRectF reqBox = p.boundingRect(QRectF(0, 0, 1, 1), m_StageNames[i], opts); if(reqBox.width() + BoxLabelMargin > (float)boxrect.width()) s = m_StageAbbrevs[i]; p.setPen(textPen); p.drawText(boxrect, s, opts); } }