SetRenderHint() public method

public SetRenderHint ( QPainter hint ) : void
hint QPainter
return void
Beispiel #1
0
    protected override void PaintEvent(QPaintEvent e)
    {
        QColor hourColor = new QColor(127, 0, 127);
        QColor minuteColor = new QColor(0, 127, 127, 191);

        int side = QMin(Width(), Height());
        QTime time = QTime.CurrentTime();

        QPainter painter = new QPainter(this);
        painter.SetRenderHint(QPainter.RenderHint.Antialiasing);
        painter.Translate(Width() / 2, Height() / 2);
        painter.Scale(side / 200.0, side / 200.0);

        painter.SetPen(Qt.PenStyle.NoPen);
        painter.SetBrush(hourColor);

        painter.Save();
        painter.Rotate(30.0 * ((time.Hour() + time.Minute() / 60.0)));
        painter.DrawConvexPolygon(new QPolygon(hourHand));
        painter.Restore();

        painter.SetPen(hourColor);

        for (int i = 0; i < 12; ++i) {
            painter.DrawLine(88, 0, 96, 0);
            painter.Rotate(30.0);
        }

        painter.SetPen(Qt.PenStyle.NoPen);
        painter.SetBrush(minuteColor);

        painter.Save();
        painter.Rotate(6.0 * (time.Minute() + time.Second() / 60.0));
        painter.DrawConvexPolygon(new QPolygon(minuteHand));
        painter.Restore();

        painter.SetPen(minuteColor);

        for (int j = 0; j < 60; ++j) {
            if ((j % 5) != 0)
                painter.DrawLine(92, 0, 96, 0);
            painter.Rotate(6.0);
        }

        painter.End();
    }
Beispiel #2
0
            public override void Paint(Qyoto.QPainter painter, Qyoto.QStyleOptionGraphicsItem option, Qyoto.QWidget widget)
            {
                painter.SetRenderHint(QPainter.RenderHint.Antialiasing, true);
                int iconSize = m_Grid.IconSize;

                // Parent opacity overrides item opacity.
                var parentGroup = (RosterItemGroup)base.Group();

                if (parentGroup == null)                 // This happens while the item is being removed.
                {
                    return;
                }
                if (parentGroup.Opacity != 1)
                {
                    painter.SetOpacity(parentGroup.Opacity);
                }
                else
                {
                    painter.SetOpacity(m_Opacity);
                }

                QPixmap pixmap = (QPixmap)m_Grid.Model.GetImage(m_Item);

                Gui.DrawAvatar(painter, iconSize, iconSize, pixmap);

                if (IsHover)
                {
                    // FIXME: Do something?
                }

                if (m_Grid.ListMode)
                {
                    var rect = BoundingRect();
                    var pen  = new QPen();
                    pen.SetBrush(m_Grid.Palette.Text());
                    painter.SetPen(pen);

                    int x = iconSize + m_Grid.IconPadding;
                    painter.DrawText(x, 0, (int)rect.Width() - x, (int)rect.Height(), (int)Qt.TextFlag.TextSingleLine, m_Grid.Model.GetName(m_Item));
                }
            }