Exemplo n.º 1
0
        protected override void PaintEvent(Qyoto.QPaintEvent arg1)
        {
            using (QPainter p = new QPainter(this)) {
                var rect = ContentsRect();
                //var fm = new QFontMetrics(Font);

                //if (fm.Width(Text) > rect.Width()) {
                var gradient = new QLinearGradient(rect.TopLeft(), rect.TopRight());
                gradient.SetColorAt(0.8, Palette.Color(QPalette.ColorRole.WindowText));
                gradient.SetColorAt(1.0, new QColor(Qt.GlobalColor.transparent));
                var pen = new QPen();
                pen.SetBrush(new QBrush(gradient));
                p.SetPen(pen);
                //}

                p.DrawText(rect, (int)Qt.TextFlag.TextSingleLine, Text);
            }
        }
Exemplo n.º 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));
                }
            }