示例#1
0
  void onSetDecorativeWidgetBounds() override {
    SkinTheme* theme = static_cast<SkinTheme*>(this->theme());
    Widget* window = parent();
    gfx::Rect rect(0, 0, 0, 0);
    gfx::Size centerSize = this->sizeHint();
    gfx::Size playSize = theme->calcSizeHint(this, theme->styles.windowPlayButton());
    gfx::Size closeSize = theme->calcSizeHint(this, theme->styles.windowCloseButton());

    rect.w = centerSize.w;
    rect.h = centerSize.h;
    rect.offset(window->bounds().x2()
                - theme->styles.windowCloseButton()->margin().width() - closeSize.w
                - theme->styles.windowPlayButton()->margin().width() - playSize.w
                - style()->margin().right() - centerSize.w,
                window->bounds().y + style()->margin().top());

    setBounds(rect);
  }
示例#2
0
  void onSizeHint(SizeHintEvent& ev) override {
    SkinTheme* theme = static_cast<SkinTheme*>(this->theme());
    ui::Style* style = theme->styles.newsItem();

    setText(m_title);
    gfx::Size sz = theme->calcSizeHint(this, style);

    if (!m_desc.empty())
      sz.h *= 5;

    ev.setSizeHint(gfx::Size(0, sz.h));
  }
示例#3
0
  void onPaint(PaintEvent& ev) override {
    SkinTheme* theme = static_cast<SkinTheme*>(this->theme());
    Graphics* g = ev.graphics();
    gfx::Rect bounds = clientBounds();
    ui::Style* style = theme->styles.newsItem();
    ui::Style* styleDetail = theme->styles.newsItemDetail();

    setText(m_title);
    gfx::Size textSize = theme->calcSizeHint(this, style);
    gfx::Rect textBounds(bounds.x, bounds.y, bounds.w, textSize.h);
    gfx::Rect detailsBounds(
      bounds.x, bounds.y+textSize.h,
      bounds.w, bounds.h-textSize.h);

    theme->paintWidget(g, this, style, textBounds);

    setText(m_desc);
    theme->paintWidget(g, this, styleDetail, detailsBounds);
  }