//==============================================================================
void BubbleComponent::paint (Graphics& g)
{
    getLookAndFeel().drawBubble (g, *this, arrowTip.toFloat(), content.toFloat());

    g.reduceClipRegion (content);
    g.setOrigin (content.getPosition());

    paintContent (g, content.getWidth(), content.getHeight());
}
Beispiel #2
0
void UIBar::paintEvent(QPaintEvent *pEvent)
{
    QPainter painter(this);
    painter.setClipRect(pEvent->rect());

#ifdef Q_WS_MAC
    paintContentDarwin(&painter);
#else /* Q_WS_MAC */
    paintContent(&painter);
#endif /* !Q_WS_MAC */
}
//==============================================================================
void BubbleComponent::paint (Graphics& g)
{
    int x = content.getX();
    int y = content.getY();
    int w = content.getWidth();
    int h = content.getHeight();

    int cw, ch;
    getContentSize (cw, ch);

    if (side == 3)
        x += w - cw;
    else if (side != 1)
        x += (w - cw) / 2;

    w = cw;

    if (side == 2)
        y += h - ch;
    else if (side != 0)
        y += (h - ch) / 2;

    h = ch;

    getLookAndFeel().drawBubble (g, arrowTipX, arrowTipY,
                                 (float) x, (float) y,
                                 (float) w, (float) h);

    const int cx = x + (w - cw) / 2;
    const int cy = y + (h - ch) / 2;

    const int indent = 3;

    g.setOrigin (cx + indent, cy + indent);
    g.reduceClipRegion (0, 0, cw - indent * 2, ch - indent * 2);

    paintContent (g, cw - indent * 2, ch - indent * 2);
}
Beispiel #4
0
/**
 * @brief       This method has been reimplemented. It paints the whole table.
 *
 * @param[in]   event       Paint event
 *
 * @return      Nothing.
 */
void AbstractTableView::paintEvent(QPaintEvent* event)
{
    if(!mAllowPainting)
        return;
    if(getColumnCount()) //make sure the last column is never smaller than the window
    {
        int totalWidth = 0;
        for(int i = 0; i < getColumnCount(); i++)
            totalWidth += getColumnWidth(i);
        int lastWidth = 0;
        for(int i = 0; i < getColumnCount() - 1; i++)
            lastWidth += getColumnWidth(i);
        int width = this->viewport()->width();
        lastWidth = width > lastWidth ? width - lastWidth : 0;
        int last = getColumnCount() - 1;
        if(totalWidth < width)
            setColumnWidth(last, lastWidth);
        else
            setColumnWidth(last, getColumnWidth(last));
    }

    Q_UNUSED(event);
    QPainter wPainter(this->viewport());
    int wViewableRowsCount = getViewableRowsCount();

    int scrollValue = -horizontalScrollBar()->value();

    int x = scrollValue;
    int y = 0;

    // Reload data if needed
    if(mPrevTableOffset != mTableOffset || mShouldReload == true)
    {
        prepareData();
        mPrevTableOffset = mTableOffset;
        mShouldReload = false;
    }

    // Paints background
    wPainter.fillRect(wPainter.viewport(), QBrush(backgroundColor));

    // Paints header
    if(mHeader.isVisible == true)
    {
        for(int i = 0; i < getColumnCount(); i++)
        {
            QStyleOptionButton wOpt;
            if((mColumnList[i].header.isPressed == true) && (mColumnList[i].header.isMouseOver == true))
                wOpt.state = QStyle::State_Sunken;
            else
                wOpt.state = QStyle::State_Enabled;

            wOpt.rect = QRect(x, y, getColumnWidth(i), getHeaderHeight());

            mHeaderButtonSytle.style()->drawControl(QStyle::CE_PushButton, &wOpt, &wPainter, &mHeaderButtonSytle);

            wPainter.setPen(headerTextColor);
            wPainter.drawText(QRect(x + 4, y, getColumnWidth(i) - 8, getHeaderHeight()), Qt::AlignVCenter | Qt::AlignLeft, mColumnList[i].title);

            x += getColumnWidth(i);
        }
    }

    x = scrollValue;
    y = getHeaderHeight();

    // Iterate over all columns and cells
    for(int j = 0; j < getColumnCount(); j++)
    {
        for(int i = 0; i < wViewableRowsCount; i++)
        {
            //  Paints cell contents
            if(i < mNbrOfLineToPrint)
            {
                // Don't draw cells if the flag is set, and no process is running
                //if(!mDrawDebugOnly || DbgIsDebugging())
                if(true)
                {
                    QString wStr = paintContent(&wPainter, mTableOffset, i, j, x, y, getColumnWidth(j), getRowHeight());

                    if(wStr.length())
                    {
                        wPainter.setPen(textColor);
                        wPainter.drawText(QRect(x + 4, y, getColumnWidth(j) - 4, getRowHeight()), Qt::AlignVCenter | Qt::AlignLeft, wStr);
                    }
                }
            }

            // Paints cell right borders
            wPainter.setPen(separatorColor);
            wPainter.drawLine(x + getColumnWidth(j) - 1, y, x + getColumnWidth(j) - 1, y + getRowHeight() - 1);

            // Update y for the next iteration
            y += getRowHeight();
        }

        y = getHeaderHeight();
        x += getColumnWidth(j);
    }
    //emit repainted();
}