Esempio n. 1
0
void
DirectionalButton::updateTextBaseGeometry()
{
    ILOG_TRACE_W(ILX_DIRBUTTON);
    int textHeight = textExtents().height();
    int iconW = 0;
    int iconH = 0;
    int wUsed = stylist()->defaultParameter(StyleHint::ToolButtonLR);
    int x = stylist()->defaultParameter(StyleHint::ToolButtonLeft);

    if (_icon)
    {
        if (!_icon->size().isValid())
            _icon->setSize(_icon->preferredSize());
        iconW = _icon->width();
        iconH = _icon->height();

        _icon->moveTo(x, (height() - iconH) / 2);
        x += iconW + stylist()->defaultParameter(StyleHint::ButtonOffset);
        wUsed += iconW + stylist()->defaultParameter(StyleHint::ButtonOffset);
    }

    _layout.setBounds(x, (height() - textHeight) / 2, width() - wUsed, textHeight);
    _layout.doLayout(font());
}
Esempio n. 2
0
Size
DirectionalButton::preferredSize() const
{
    ILOG_TRACE_W(ILX_DIRBUTTON);

    int imgW = 0;
    int imgH = 0;
    if (_icon)
    {
        Size s;
        if (_icon->size().isValid())
            s = _icon->size();
        else
            s = _icon->preferredSize();
        imgW = s.width();
        imgH = s.height();
    }

    Size s = textExtents();
    int w = 0;
    if (!text().empty())
    {
        if (_icon)
            w = stylist()->defaultParameter(StyleHint::ButtonOffset);
        w += s.width();
    }

    return Size(w + imgW + stylist()->defaultParameter(StyleHint::ToolButtonLR), std::max(s.height(), imgH) + stylist()->defaultParameter(StyleHint::ToolButtonTB));
}
Esempio n. 3
0
int
CheckBox::heightForWidth(int width) const
{
    ILOG_TRACE_W(ILX_CHECKBOX);
    int w = stylist()->defaultParameter(StyleHint::CheckBoxWidth);
    int h = stylist()->defaultParameter(StyleHint::CheckBoxHeight);

    return std::max(textLayoutHeightForWidth(width - w), h);
}
Esempio n. 4
0
void
CheckBox::updateTextBaseGeometry()
{
    ILOG_TRACE_W(ILX_CHECKBOX);
    int x = stylist()->defaultParameter(StyleHint::ButtonOffset)
            + stylist()->defaultParameter(StyleHint::CheckBoxWidth);

    int th = textLayoutHeightForWidth(width() - x);
    int y = (height() - th) / 2;

    _layout.setBounds(x, y, width() - x, height());
    _layout.doLayout(font());
}
Esempio n. 5
0
Size
CheckBox::preferredSize() const
{
    ILOG_TRACE_W(ILX_CHECKBOX);
    int w = stylist()->defaultParameter(StyleHint::CheckBoxWidth);
    int h = stylist()->defaultParameter(StyleHint::CheckBoxHeight);

    if (!text().empty())
    {
        Size s = textExtents();
        w += stylist()->defaultParameter(StyleHint::ButtonOffset) + s.width();
        h = std::max(s.height(), h);
    }
    return Size(w, h);
}
Esempio n. 6
0
int
Frame::heightForWidth(int width) const
{
    if (_drawFrame)
        return _layout->heightForWidth(width - _margin.hSum() - stylist()->defaultParameter(StyleHint::FrameOffsetLR)) + _margin.vSum() + stylist()->defaultParameter(StyleHint::FrameOffsetLR);
    return _layout->heightForWidth(width - _margin.hSum()) + _margin.vSum();
}
Esempio n. 7
0
int
Frame::canvasWidth() const
{
    if (_drawFrame)
        return width() - _margin.hSum() - stylist()->defaultParameter(StyleHint::FrameOffsetLR);
    return width() - _margin.hSum();
}
Esempio n. 8
0
int
Frame::canvasY() const
{
    if (_drawFrame)
        return _margin.top() + stylist()->defaultParameter(StyleHint::FrameOffsetTop);
    return _margin.top();
}
Esempio n. 9
0
int
Frame::canvasHeight() const
{
    if (_drawFrame)
        return height() - _margin.vSum() - stylist()->defaultParameter(StyleHint::FrameOffsetTB);
    return height() - _margin.vSum();
}
Esempio n. 10
0
int
Frame::canvasX() const
{
    if (_drawFrame)
        return _margin.left() + stylist()->defaultParameter(StyleHint::FrameOffsetLeft);
    return _margin.left();
}
Esempio n. 11
0
Size
Frame::preferredSize() const
{
    Size s = _layout->preferredSize();
    if (_drawFrame)
        return Size(s.width() + _margin.hSum() + stylist()->defaultParameter(StyleHint::FrameOffsetLR), s.height() + _margin.vSum() + stylist()->defaultParameter(StyleHint::FrameOffsetTB));
    return Size(s.width() + _margin.hSum(), s.height() + _margin.vSum());
}
Esempio n. 12
0
void
DirectionalButton::compose(const ilixi::PaintEvent& event)
{
    ILOG_TRACE_W(ILX_DIRBUTTON);
    Painter p(this);
    p.begin(event);
    stylist()->drawDirectionalButton(&p, this);
}
Esempio n. 13
0
void
CheckBox::compose(const PaintEvent& event)
{
    ILOG_TRACE_W(ILX_CHECKBOX);
    Painter p(this);
    p.begin(event);
    stylist()->drawCheckBox(&p, this);
    p.end();
}
Esempio n. 14
0
void
Notification::compose(const PaintEvent& event)
{
    ILOG_TRACE_W(ILX_NOTIFICATION);
    Painter p(this);
    p.begin(event);
    p.stretchImage(_bg, width() * _tweenX->value(), 0, width(), height());

    if (_tweenZ->enabled())
        p.stretchImage(_icon, Rectangle(20 + 32 * (1 - _tweenZ->value()), 5 + 32 * (1 - _tweenZ->value()), 64 * _tweenZ->value(), 64 * _tweenZ->value()));
    else
        p.drawImage(_icon, 20 + width() * _tweenX->value(), 5);

    p.setBrush(Color(255, 255, 255));
    p.setFont(*stylist()->defaultFont(StyleHint::TitleFont));
    p.drawText(_title, 90 + width() * _tweenX->value(), 15);
    p.setFont(*stylist()->defaultFont(StyleHint::DefaultFont));
    p.drawText(_text, 90 + width() * _tweenX->value(), 35);
    p.end();
}
Esempio n. 15
0
void
Frame::compose(const PaintEvent& event)
{
    ILOG_TRACE_W(ILX_FRAME);
    if (_drawFrame)
    {
        Painter painter(this);
        painter.begin(event);
        stylist()->drawFrame(&painter, this);
        painter.end();
    }
}
Esempio n. 16
0
Notification::Notification(const Compositor::NotificationData& data, ILXCompositor* parent)
        : Widget(parent->appWindow()),
          _compositor(parent),
          _notState(Init),
          _clicked(false)
{
    ILOG_TRACE_W(ILX_NOTIFICATION);
    setInputMethod(PointerInput);

    if (!_bg)
        _bg = new Image(ILIXI_DATADIR"images/notify.png");

    _client = data.client;
    _tag = data.tag;
    _text = data.body;
    _title = data.title;
    snprintf(_uuid, 37, "%s", data.uuid);
    if (strcmp(data.icon, "") != 0)
        _icon = new Image(data.icon, 64, 64);
    else
    {
        AppInfo* info = _compositor->appMan()->infoByPID(_client);
        if (info)
            _icon = new Image(info->icon(), 64, 64);
        else
            _icon = stylist()->defaultIcon(StyleHint::Cross);
    }
    _timer.sigExec.connect(sigc::mem_fun(this, &Notification::hide));

    _animZ = new TweenAnimation();
    _tweenZ = new Tween(Tween::SINE, Tween::EASE_OUT, 0, 1);
    _animZ->addTween(_tweenZ);
    _animZ->setDuration(400);
    _animZ->sigExec.connect(sigc::mem_fun(this, &Notification::tweenSlot));
    _seq.addAnimation(_animZ);

    _animX = new TweenAnimation();
    _tweenX = new Tween(Tween::SINE, Tween::EASE_OUT, 1, 0);
    _animX->addTween(_tweenX);
    _animX->setDuration(400);
    _animX->sigExec.connect(sigc::mem_fun(this, &Notification::tweenSlot));
    _animX->sigFinished.connect(sigc::mem_fun(this, &Notification::tweenEndSlot));
    _seq.addAnimation(_animX);

    setVisible(false);
    ILOG_DEBUG(ILX_NOTIFICATION, " -> body: %s\n", data.body);
    ILOG_DEBUG(ILX_NOTIFICATION, " -> client: %d\n", _client);
    ILOG_DEBUG(ILX_NOTIFICATION, " -> iconURL: %s\n", data.icon);
    ILOG_DEBUG(ILX_NOTIFICATION, " -> title: %s\n", data.title);
    ILOG_DEBUG(ILX_NOTIFICATION, " -> uuid: %s\n", data.uuid);
}
Esempio n. 17
0
void
ToolButton::compose(const PaintEvent& event)
{
    ILOG_TRACE_W(ILX_TOOLBUTTON);

    if (_icon)
    {
        if (_toolButtonStyle == TextOnly)
            _icon->setVisible(false);
        else
            _icon->setVisible(true);
    }

    Painter p(this);
    p.begin(event);
    stylist()->drawToolButton(&p, this);
    p.end();
}
Esempio n. 18
0
Size
ToolButton::preferredSize() const
{
    ILOG_TRACE_W(ILX_TOOLBUTTON);
    if (text().empty() && !icon())
        return stylist()->defaultSize(StyleHint::PushButton);

    int w = (_tbOptions & DrawFrame) ? stylist()->defaultParameter(StyleHint::ToolButtonLR) : 0;
    int h = (_tbOptions & DrawFrame) ? stylist()->defaultParameter(StyleHint::ToolButtonTB) : 0;

    if (checkable())
    {
        if ((_toolButtonStyle == IconBelowText) || (_toolButtonStyle == IconAboveText))
            h += stylist()->defaultParameter(StyleHint::ToolButtonIndicator) + stylist()->defaultParameter(StyleHint::ButtonOffset);
        else
            w += stylist()->defaultParameter(StyleHint::ToolButtonIndicator) + stylist()->defaultParameter(StyleHint::ButtonOffset);
    }

    if (_toolButtonStyle == TextOnly)
    {
        Size s = textExtents();
        if (s.isValid())
            return Size(w + s.width(), h + s.height());
        return stylist()->defaultSize(StyleHint::PushButton);
    }

    // calculate image size
    int imgW = 0;
    int imgH = 0;
    if (_icon)
    {
        Size s;
        if (_icon->size().isValid())
            s = _icon->size();
        else
            s = _icon->preferredSize();
        imgW = s.width();
        imgH = s.height() + 2; // 1px for button down movement
    }

    if (_toolButtonStyle == IconOnly)
    {
        ILOG_DEBUG(ILX_TOOLBUTTON, " -> icon only: %d, %d\n", w + imgW, h + imgH);
        if (imgW)
            return Size(w + imgW, h + imgH);
        return stylist()->defaultSize(StyleHint::PushButton);
    } else
    {
        Size s = textExtents();
        if (s.isValid() && imgW)
        {
            if (_toolButtonStyle == IconBeforeText)
            {
                w += imgW + stylist()->defaultParameter(StyleHint::ButtonOffset) + s.width();
                h += std::max(s.height(), imgH);
                return Size(w, h);
            } else
            {
                // IconBelowText or IconAboveText
                w += std::max(imgW, s.width());
                h += imgH + s.height() + stylist()->defaultParameter(StyleHint::ButtonOffset);
                return Size(w, h);
            }
        } else if (imgW)
            return Size(w + imgW, h + imgH);
        else
            return Size(w + s.width(), h + s.height());
    }
}
Esempio n. 19
0
Font*
CheckBox::defaultFont() const
{
    return stylist()->defaultFont(StyleHint::DefaultFont);
}
Esempio n. 20
0
QStringList Image::stylishedTags(Profile *profile) const
{
	TagStylist stylist(profile);
	return stylist.stylished(m_tags);
}
Esempio n. 21
0
void
ToolButton::updateTextBaseGeometry()
{
    ILOG_TRACE_W(ILX_TOOLBUTTON);
    int textHeight = textExtents().height();
    int iconW = 0;
    int iconH = 0;
    int wUsed = drawFrame() ? stylist()->defaultParameter(StyleHint::ToolButtonLR) : 0;
    int x = drawFrame() ? stylist()->defaultParameter(StyleHint::ToolButtonLeft) : 0;
    int yTop = drawFrame() ? stylist()->defaultParameter(StyleHint::ToolButtonTop) : 0;

    if (checkable())
    {
        if ((_toolButtonStyle == TextOnly) || (_toolButtonStyle == IconOnly) || (_toolButtonStyle == IconBeforeText))
        {
            x += stylist()->defaultParameter(StyleHint::ToolButtonIndicator) + stylist()->defaultParameter(StyleHint::ButtonOffset);
            wUsed += stylist()->defaultParameter(StyleHint::ToolButtonIndicator) + stylist()->defaultParameter(StyleHint::ButtonOffset);
        }
    }

    if (_icon)
    {
        if (!_icon->size().isValid())
            _icon->setSize(_icon->preferredSize());
        iconW = _icon->width();
        iconH = _icon->height() + 1;
    }

    if (_toolButtonStyle == TextOnly)
    {
        int y = (height() - textHeight) / 2;
        _layout.setBounds(x, y, width() - wUsed, textHeight);
    }

    else if (_toolButtonStyle == IconOnly)
    {
        _icon->moveTo(x, (height() - iconH) / 2);
        _layout.setBounds(0, 0, 0, 0);
        return;
    }

    else if (_toolButtonStyle == IconBeforeText)
    {
        if (iconW)
        {
            _icon->moveTo(x, (height() - iconH) / 2);
            x += iconW + stylist()->defaultParameter(StyleHint::ButtonOffset);
            wUsed += iconW + stylist()->defaultParameter(StyleHint::ButtonOffset);
        }

        _layout.setBounds(x, (height() - textHeight) / 2, width() - wUsed, textHeight);

    } else if (_toolButtonStyle == IconBelowText)
    {
        _layout.setBounds(x, yTop, width() - wUsed, textHeight);
        if (iconW)
            _icon->moveTo((width() - iconW) / 2, yTop + textHeight + 1 + stylist()->defaultParameter(StyleHint::ButtonOffset));
    } else //  IconAboveText
    {
        if (iconW)
        {
            _icon->moveTo((width() - iconW) / 2, yTop + 1);
            yTop += iconH + stylist()->defaultParameter(StyleHint::ButtonOffset) + 1;
        }

        _layout.setBounds(x, yTop, width() - wUsed, textHeight);
    }
    _layout.doLayout(font());
}