void KstViewArrow::paintSelf(KstPainter& p, const QRegion& bounds) { p.save(); if (p.type() != KstPainter::P_PRINT && p.type() != KstPainter::P_EXPORT) { if (p.makingMask()) { p.setCompositionMode(QPainter::CompositionMode_Source); } else { const QRegion clip(clipRegion()); KstViewLine::paintSelf(p, bounds - _myClipMask); p.setClipRegion(bounds & clip); } } else { KstViewLine::paintSelf(p, bounds); } if (hasArrow()) { QPoint to = KstViewLine::to(); QPoint from = KstViewLine::from(); const int w = width() * p.lineWidthAdjustmentFactor(); QPen pen(_foregroundColor, w); pen.setCapStyle(capStyle()); p.setPen(pen); p.setBrush(_foregroundColor); if (_hasToArrow) { paintArrow(p, to, from, w, _toArrowScaling); } if (_hasFromArrow) { paintArrow(p, from, to, w, _fromArrowScaling); } } p.restore(); }
/** * Draws a circle and a solid arrow line and a stick arrow head. */ void MessageWidget::paintFound(QPainter *painter, const QStyleOptionGraphicsItem *option) { int x1 = m_pOw[Uml::RoleType::A]->centerX(); int x2 = m_xclicked; int w = width(); int h = height(); int offsetX = 0; int offsetY = 0; bool messageOverlapsA = m_pOw[Uml::RoleType::A]->messageOverlap(y(), this); //bool messageOverlapsB = m_pOw[Uml::RoleType::B]->messageOverlap(y(), this); if(x1 < x2) { if (messageOverlapsA) { offsetX += 7; w -= 7; } setPenFromSettings(painter); painter->setBrush(WidgetBase::lineColor()); painter->drawEllipse(offsetX + w - h, offsetY, h, h); paintArrow(painter, offsetX, offsetY + h/2, w, Qt::LeftArrow); if (messageOverlapsA) { offsetX -= 7; } } else { if (messageOverlapsA) { w -= 7; } setPenFromSettings(painter); painter->setBrush(WidgetBase::lineColor()); painter->drawEllipse(offsetX, offsetY, h, h); paintArrow(painter, offsetX, offsetY + h/2, w, Qt::RightArrow); } UMLWidget::paint(painter, option); }
/** * Draws a solid arrow line and a stick arrow head to the * edge of the target object widget instead of to the * sequence line. */ void MessageWidget::paintCreation(QPainter *painter, const QStyleOptionGraphicsItem *option) { int x1 = m_pOw[Uml::RoleType::A]->x(); int x2 = m_pOw[Uml::RoleType::B]->x(); int w = width(); //int h = height() - 1; int offsetX = 0; int offsetY = 0; bool messageOverlapsA = m_pOw[Uml::RoleType::A]->messageOverlap(y(), this); //bool messageOverlapsB = m_pOw[Uml::RoleType::B]->messageOverlap(y(), this); const int lineY = offsetY + 4; if (x1 < x2) { if (messageOverlapsA) { offsetX += 7; w -= 7; } paintArrow(painter, offsetX, lineY, w, Qt::RightArrow); if (messageOverlapsA) { offsetX -= 7; } } else { if (messageOverlapsA) { w -= 7; } paintArrow(painter, offsetX, lineY, w, Qt::LeftArrow); } UMLWidget::paint(painter, option); }
/** * Draws the calling arrow with filled in arrowhead, the * timeline box and the returning arrow with a dashed line and * stick arrowhead. */ void MessageWidget::paintSynchronous(QPainter *painter, const QStyleOptionGraphicsItem *option) { int x1 = m_pOw[Uml::RoleType::A]->x(); int x2 = m_pOw[Uml::RoleType::B]->x(); int w = width() - 1; int h = height(); int offsetX = 0; int offsetY = 0; bool messageOverlaps = m_pOw[Uml::RoleType::A]->messageOverlap(y(), this); const int boxWidth = 17; const int wr = w < boxWidth ? w : boxWidth; const int arrowWidth = 4; if(isSelf()) { painter->fillRect(offsetX, offsetY, wr, h, QBrush(Qt::white)); //box painter->drawRect(offsetX, offsetY, wr, h); //box offsetX += wr; w -= wr; offsetY += 3; const int lowerLineY = offsetY + h - 6; // draw upper line segment (leaving the life line) painter->drawLine(offsetX, offsetY, offsetX + w, offsetY); // draw line segment parallel to (and at the right of) the life line painter->drawLine(offsetX + w, offsetY, offsetX + w, lowerLineY); // draw lower line segment (back to the life line) paintArrow(painter, offsetX, lowerLineY, w, Qt::LeftArrow); offsetX -= wr; offsetY -= 3; } else if(x1 < x2) { if (messageOverlaps) { offsetX += 8; w -= 8; } QPen pen = painter->pen(); int startX = offsetX + w - wr + 1; painter->fillRect(startX, offsetY, wr, h, QBrush(Qt::white)); //box painter->drawRect(startX, offsetY, wr, h); //box painter->drawLine(offsetX, offsetY + arrowWidth, startX, offsetY + arrowWidth); //arrow line if (w > boxWidth + arrowWidth) paintSolidArrowhead(painter, startX - 1, offsetY + arrowWidth, Qt::RightArrow); paintArrow(painter, offsetX, offsetY + h - arrowWidth + 1, w - wr + 1, Qt::LeftArrow, true); // return arrow if (messageOverlaps) { offsetX -= 8; //reset for drawSelected() } } else { if (messageOverlaps) { w -=8; } QPen pen = painter->pen(); painter->fillRect(offsetX, offsetY, wr, h, QBrush(Qt::white)); //box painter->drawRect(offsetX, offsetY, wr, h); //box painter->drawLine(offsetX + wr + 1, offsetY + arrowWidth, offsetX + w, offsetY + arrowWidth); //arrow line if (w > boxWidth + arrowWidth) paintSolidArrowhead(painter, offsetX + wr, offsetY + arrowWidth, Qt::LeftArrow); paintArrow(painter, offsetX + wr + 1, offsetY + h - arrowWidth + 1, w - wr - 1, Qt::RightArrow, true); // return arrow } UMLWidget::paint(painter, option); }
/** * Draws a solid arrow line and a stick arrow head. */ void MessageWidget::paintAsynchronous(QPainter *painter, const QStyleOptionGraphicsItem *option) { int x1 = m_pOw[Uml::RoleType::A]->x(); int x2 = m_pOw[Uml::RoleType::B]->x(); int w = width() - 1; int h = height() - 1; int offsetX = 0; int offsetY = 0; bool messageOverlapsA = m_pOw[Uml::RoleType::A]->messageOverlap(y(), this); //bool messageOverlapsB = m_pOw[Uml::RoleType::B]->messageOverlap(y(), this); if(isSelf()) { if (messageOverlapsA) { offsetX += 7; w -= 7; } const int lowerLineY = offsetY + h - 3; // draw upper line segment (leaving the life line) painter->drawLine(offsetX, offsetY, offsetX + w, offsetY); // draw line segment parallel to (and at the right of) the life line painter->drawLine(offsetX + w, offsetY, offsetX + w, lowerLineY); // draw lower line segment (back to the life line) paintArrow(painter, offsetX, lowerLineY, w, Qt::LeftArrow); if (messageOverlapsA) { offsetX -= 7; //reset for drawSelected() } } else if(x1 < x2) { if (messageOverlapsA) { offsetX += 7; w -= 7; } paintArrow(painter, offsetX, offsetY + 4, w, Qt::RightArrow); if (messageOverlapsA) { offsetX -= 7; } } else { if (messageOverlapsA) { w -= 7; } paintArrow(painter, offsetX, offsetY + 4, w, Qt::LeftArrow); } UMLWidget::paint(painter, option); }
void ArrowRightKey::paint(QPainter *painter) { FuncKey::paint(painter); painter->save(); setUpPainter(painter); painter->setRenderHint(QPainter::Antialiasing); painter->setPen(Plasma::Theme::defaultTheme()->color(Plasma::Theme::ButtonTextColor)); painter->rotate(180); paintArrow(painter); painter->restore(); }
void Splitter::drawSplitter() { PAINTSTRUCT ps; RECT rc, rcToDraw1, rcToDraw2, TLrc, BRrc; HDC hdc = ::BeginPaint(_hSelf, &ps); getClientRect(rc); if ((_spiltterSize >= 4) && (_dwFlags & SV_RESIZEWTHPERCNT)) { adjustZoneToDraw(TLrc, ZONE_TYPE::topLeft); adjustZoneToDraw(BRrc, ZONE_TYPE::bottomRight); paintArrow(hdc, TLrc, isVertical() ? Arrow::left : Arrow::up); } if (isVertical()) { rcToDraw2.top = (_dwFlags & SV_RESIZEWTHPERCNT) ? _clickZone2TL.bottom : 0; rcToDraw2.bottom = rcToDraw2.top + 2; rcToDraw1.top = rcToDraw2.top + 1; rcToDraw1.bottom = rcToDraw1.top + 2; } else { rcToDraw2.top = 1; rcToDraw2.bottom = 3; rcToDraw1.top = 2; rcToDraw1.bottom = 4; } int bottom = 0; if (_dwFlags & SV_RESIZEWTHPERCNT) bottom = (isVertical() ? rc.bottom - _clickZone2BR.bottom : rc.bottom); else bottom = rc.bottom; while (rcToDraw1.bottom <= bottom) { if (isVertical()) { rcToDraw2.left = 1; rcToDraw2.right = 3; rcToDraw1.left = 2; rcToDraw1.right = 4; } else { rcToDraw2.left = _clickZone2TL.right; rcToDraw2.right = rcToDraw2.left + 2; rcToDraw1.left = rcToDraw2.left; rcToDraw1.right = rcToDraw1.left + 2; } while (rcToDraw1.right <= (isVertical() ? rc.right : rc.right - _clickZone2BR.right)) { ::FillRect(hdc, &rcToDraw1, (HBRUSH)(RGB(0xFF, 0xFF, 0xFF))); ::FillRect(hdc, &rcToDraw2, (HBRUSH)(COLOR_3DSHADOW+1)); rcToDraw2.left += 4; rcToDraw2.right += 4; rcToDraw1.left += 4; rcToDraw1.right += 4; } rcToDraw2.top += 4; rcToDraw2.bottom += 4; rcToDraw1.top += 4; rcToDraw1.bottom += 4; } if ((_spiltterSize >= 4) && (_dwFlags & SV_RESIZEWTHPERCNT)) paintArrow(hdc, BRrc, isVertical() ? Arrow::right : Arrow::down); ::EndPaint(_hSelf, &ps); }
/***************************************************** ** ** BasicVedicChart --- paintAspectsForFieldPair ** ******************************************************/ void BasicVedicChart::paintAspectsForFieldPair( const int &f1, const int &f2 ) { const double dist = 4; MPoint p1, p2; MRect rect; int acount = 0; list<AspectEvent> &al = aexpert->getAspectList(); list<AspectEvent>::iterator iter; AspectEvent *event = (AspectEvent*)NULL; //printf( "BasicVedicChart::paintAspectsForFieldPair %d %d\n", f1, f2 ); // first step determine field parts and whether apsect relation has to swapped FIELD_PART part1 = FP_ALL; FIELD_PART part2 = FP_ALL; bool swap = false; if ( charttype == CT_TRANSIT ) { part1 = FP_OUTER; part2 = FP_INNER; } else if ( charttype == CT_PARTNER ) { const bool aspecting = markedFieldStatus & CHART_FIELD_STATUS_ASPECTING; const bool aspected = markedFieldStatus & CHART_FIELD_STATUS_ASPECTED; //printf( "aspecting %d aspected %d\n", aspecting, aspected ); //const bool markedFull = markedFieldStatus & CHART_FIELD_STATUS_POS_FULL; const bool markedInner = markedFieldStatus & CHART_FIELD_STATUS_POS_INNER; const bool markedOuter = markedFieldStatus & CHART_FIELD_STATUS_POS_OUTER; //assert( markedFull ^ markedInner ^ markedOuter ); if (( markedInner && aspected ) || ( markedOuter && aspecting )) { part1 = FP_INNER; part2 = FP_OUTER; } else if (( markedInner && aspecting ) || ( markedOuter && aspected )) { part1 = FP_OUTER; part2 = FP_INNER; swap = true; } } // second step: find number of matching aspects for ( iter = al.begin(); iter != al.end(); iter++ ) { if ( (*iter).field1 == f1 && (*iter).field2 == f2 && (*iter).swapCharts == swap ) { event = (AspectEvent*)&(*iter); acount++; } } //printf( "ACOUNT %d H2SET %d\n", acount, h2set ); if ( acount > 0 ) { // correct field index for north indian chart int g1 = f1; int g2 = f2; if ( positionOffset != 0 ) { g1 = a_red( f1 - positionOffset, field_count ); g2 = a_red( f2 - positionOffset, field_count ); } if ( part1 != FP_ALL ) { rect = fields[g1].calculateModifiedRect( part1, MPoint( xr - 0.5 * transitrect.width, yr - 0.5 * transitrect.height )); p1 = rect.getCenter(); rect = fields[g2].calculateModifiedRect( part2, MPoint( xr - 0.5 * transitrect.width, yr - 0.5 * transitrect.height )); p2 = rect.getCenter(); } else { p1 = fields[g1].getCenter(); p2 = fields[g2].getCenter(); } if ( acount == 1 ) { assert( event ); setAspectPainterStyle( event->strength, event->benefic ); paintArrow( p1, p2 ); } else // acount > 1, draw aspects in parallele style { MPoint c = findOrthogonalPoint( p1 - p2, acount * dist ); int i = 0; for ( iter = al.begin(); iter != al.end(); iter++ ) { if ( (*iter).field1 == f1 && (*iter).field2 == f2 && (*iter).swapCharts == swap ) { double lambda = i++; lambda /= (double)( acount - 1 ); MPoint q1 = lambda * ( p1 - c ) + ( 1 - lambda ) * ( p1 + c ); MPoint q2 = lambda * ( p2 - c ) + ( 1 - lambda ) * ( p2 + c ); setAspectPainterStyle( (*iter).strength, (*iter).benefic ); paintArrow( q1, q2 ); } } } } }
static void paintScroller(Scroller * sPtr) { WMView *view = sPtr->view; WMScreen *scr = view->screen; #ifdef DOUBLE_BUFFER Pixmap d; #else Drawable d = view->window; #endif int length, ofs; float knobP, knobL; #ifdef DOUBLE_BUFFER d = XCreatePixmap(scr->display, view->window, view->size.width, view->size.height, scr->depth); XFillRectangle(scr->display, d, WMColorGC(scr->gray), 0, 0, view->size.width, view->size.height); #endif XDrawRectangle(scr->display, d, WMColorGC(scr->black), 0, 0, view->size.width - 1, view->size.height - 1); #ifndef DOUBLE_BUFFER XDrawRectangle(scr->display, d, WMColorGC(scr->gray), 1, 1, view->size.width - 3, view->size.height - 3); #endif if (sPtr->flags.horizontal) length = view->size.width - 4; else length = view->size.height - 4; if (sPtr->flags.documentFullyVisible) { XFillRectangle(scr->display, d, scr->stippleGC, 2, 2, view->size.width - 4, view->size.height - 4); } else { ofs = 2; if (sPtr->flags.arrowsPosition == WSAMaxEnd) { length -= (BUTTON_SIZE + 1) * 2; } else if (sPtr->flags.arrowsPosition == WSAMinEnd) { ofs += (BUTTON_SIZE + 1) * 2; length -= (BUTTON_SIZE + 1) * 2; } knobL = (float)knobLength(sPtr); knobP = sPtr->floatValue * ((float)length - knobL); if (sPtr->flags.horizontal) { /* before */ XFillRectangle(scr->display, d, scr->stippleGC, ofs, 2, (int)knobP, view->size.height - 4); /* knob */ #ifndef DOUBLE_BUFFER XFillRectangle(scr->display, d, scr->lightGC, ofs + (int)knobP + 2, 2 + 2, (int)knobL - 4, view->size.height - 4 - 4); #endif W_DrawRelief(scr, d, ofs + (int)knobP, 2, (int)knobL, view->size.height - 4, WRRaised); XCopyArea(scr->display, scr->scrollerDimple->pixmap, d, scr->copyGC, 0, 0, scr->scrollerDimple->width, scr->scrollerDimple->height, ofs + (int)knobP + ((int)knobL - scr->scrollerDimple->width - 1) / 2, (view->size.height - scr->scrollerDimple->height - 1) / 2); /* after */ if ((int)(knobP + knobL) < length) XFillRectangle(scr->display, d, scr->stippleGC, ofs + (int)(knobP + knobL), 2, length - (int)(knobP + knobL), view->size.height - 4); } else { /* before */ if (knobP > 0.0) XFillRectangle(scr->display, d, scr->stippleGC, 2, ofs, view->size.width - 4, (int)knobP); /* knob */ #ifndef DOUBLE_BUFFER XFillRectangle(scr->display, d, scr->lightGC, 2 + 2, ofs + (int)knobP + 2, view->size.width - 4 - 4, (int)knobL - 4); #endif XCopyArea(scr->display, scr->scrollerDimple->pixmap, d, scr->copyGC, 0, 0, scr->scrollerDimple->width, scr->scrollerDimple->height, (view->size.width - scr->scrollerDimple->width - 1) / 2, ofs + (int)knobP + ((int)knobL - scr->scrollerDimple->height - 1) / 2); W_DrawRelief(scr, d, 2, ofs + (int)knobP, view->size.width - 4, (int)knobL, WRRaised); /* after */ if ((int)(knobP + knobL) < length) XFillRectangle(scr->display, d, scr->stippleGC, 2, ofs + (int)(knobP + knobL), view->size.width - 4, length - (int)(knobP + knobL)); } if (sPtr->flags.arrowsPosition != WSANone) { paintArrow(sPtr, d, 0); paintArrow(sPtr, d, 1); } } #ifdef DOUBLE_BUFFER XCopyArea(scr->display, d, view->window, scr->copyGC, 0, 0, view->size.width, view->size.height, 0, 0); XFreePixmap(scr->display, d); #endif }