void PieChart3D::paintEvent(QPaintEvent *event) { Q_UNUSED(event) QPainter painter( viewport() ); painter.save(); painter.setRenderHint( QPainter::Antialiasing ); updateChart(); if ( myRender != Plain ) { paintExternal( painter, true ); paintSides( painter ); paintExternal( painter, false ); } else { paintExternal( painter, false ); } for ( int i = 0; i < myAngles.count() - 2; i+=2 ) { QModelIndex index = this->model()->index( i/2, 0 ); QColor color( this->model()->data( index, Qt::DecorationRole ).toString() ); if ( !color.isValid() ) { color = Marb::predefinedColor( i/2 ); } bool isSelected = this->selectionModel()->selectedIndexes().contains( index ) || this->currentIndex() == index; if ( mySplitted == false ) { paintPart( painter, myAngles[i], myAngles[i + 1], color, isSelected ); } else { paintPartSplitted( painter, myAngles[i], myAngles[i + 1], color, isSelected ); } } painter.restore(); }
//-------------------------------------------------------------- // paint content of control void mgUglyScrollbar::paint( mgContext* gc) { mgDimension size; getSize(size); mgRectangle inside(0, 0, size.m_width, size.m_height); const mgFrame* cntlFrame = getEnabled() ? m_upFrame : m_disFrame; if (cntlFrame != NULL) { cntlFrame->paintBackground(gc, 0, 0, size.m_width, size.m_height); cntlFrame->getInsideRect(inside); } const mgFrame* frame = NULL; gc->setFont(m_font); int iconHeight = m_font->getHeight(); // constrain view to range int maxRange = m_minRange + m_lenRange; int minView = max(m_minView, m_minRange); int maxView = min(m_minView+m_lenView, maxRange); if (m_horizontal) { // horizontal scrollbar int btnSize = inside.m_height; // draw lineup button mgRectangle btnArea(inside.m_x, inside.m_y, btnSize, btnSize); frame = (m_pressPart == PART_LINEUP) ? m_lineDownFrame : (m_hoverPart == PART_LINEUP) ? m_lineHoverFrame: m_lineUpFrame; paintPart(gc, frame, m_leftIcon, btnArea); m_lineUpCoord = inside.m_x + btnSize; // draw linedown button btnArea.m_x = inside.m_width-btnSize; frame = (m_pressPart == PART_LINEDOWN) ? m_lineDownFrame : (m_hoverPart == PART_LINEDOWN) ? m_lineHoverFrame: m_lineUpFrame; paintPart(gc, frame, m_rightIcon, btnArea); m_pageDownCoord = btnArea.m_x; // draw slider int width = inside.m_width-(2*btnSize); // =-= windows scroll slider does not paint when no room for it int lx = (width * (minView-m_minRange))/m_lenRange; int hx = (width * (maxView-m_minRange))/m_lenRange; hx = max(hx, lx+iconHeight); frame = (m_pressPart == PART_SLIDER) ? m_sliderDownFrame : (m_hoverPart == PART_SLIDER) ? m_sliderHoverFrame: m_sliderUpFrame; btnArea.m_x = inside.m_x + btnSize + lx; btnArea.m_width = hx-lx; paintPart(gc, frame, m_hslideIcon, btnArea); m_pageUpCoord = btnArea.m_x; m_sliderCoord = btnArea.m_x + btnArea.m_width; btnArea.m_x = m_lineUpCoord; btnArea.m_width = m_pageUpCoord-m_lineUpCoord; frame = (m_pressPart == PART_PAGEUP) ? m_pageDownFrame : (m_hoverPart == PART_PAGEUP) ? m_pageHoverFrame: m_pageUpFrame; paintPart(gc, frame, NULL, btnArea); btnArea.m_x = m_sliderCoord; btnArea.m_width = m_pageDownCoord - m_sliderCoord; frame = (m_pressPart == PART_PAGEDOWN) ? m_pageDownFrame : (m_hoverPart == PART_PAGEDOWN) ? m_pageHoverFrame: m_pageUpFrame; paintPart(gc, frame, NULL, btnArea); } else { // vertical scrollbar int btnSize = inside.m_width; // draw lineup button mgRectangle btnArea(inside.m_x, inside.m_y, btnSize, btnSize); frame = (m_pressPart == PART_LINEUP) ? m_lineDownFrame : (m_hoverPart == PART_LINEUP) ? m_lineHoverFrame: m_lineUpFrame; paintPart(gc, frame, m_upIcon, btnArea); m_lineUpCoord = inside.m_y + btnSize; // draw linedown button btnArea.m_y = inside.m_height-btnSize; frame = (m_pressPart == PART_LINEDOWN) ? m_lineDownFrame : (m_hoverPart == PART_LINEDOWN) ? m_lineHoverFrame: m_lineUpFrame; paintPart(gc, frame, m_downIcon, btnArea); m_pageDownCoord = btnArea.m_y; // draw slider int height = inside.m_height-(2*btnSize); // =-= constrain minvisible and maxvisible int ly = (height * (minView-m_minRange))/m_lenRange; int hy = (height * (maxView-m_minRange))/m_lenRange; hy = max(hy, ly+iconHeight); frame = (m_pressPart == PART_SLIDER) ? m_sliderDownFrame : (m_hoverPart == PART_SLIDER) ? m_sliderHoverFrame: m_sliderUpFrame; btnArea.m_y = inside.m_y + btnSize + ly; btnArea.m_height = hy-ly; paintPart(gc, frame, m_vslideIcon, btnArea); m_pageUpCoord = btnArea.m_y; m_sliderCoord = btnArea.m_y + btnArea.m_height; btnArea.m_y = m_lineUpCoord; btnArea.m_height = m_pageUpCoord-m_lineUpCoord; frame = (m_pressPart == PART_PAGEUP) ? m_pageDownFrame : (m_hoverPart == PART_PAGEUP) ? m_pageHoverFrame: m_pageUpFrame; paintPart(gc, frame, NULL, btnArea); btnArea.m_y = m_sliderCoord; btnArea.m_height = m_pageDownCoord - m_sliderCoord; frame = (m_pressPart == PART_PAGEDOWN) ? m_pageDownFrame : (m_hoverPart == PART_PAGEDOWN) ? m_pageHoverFrame: m_pageUpFrame; paintPart(gc, frame, NULL, btnArea); } if (cntlFrame != NULL) cntlFrame->paintForeground(gc, 0, 0, size.m_width, size.m_height); }