Example #1
0
void ImageView::onPreferredSize(PreferredSizeEvent& ev)
{
  struct jrect box, text, icon;
  jwidget_get_texticon_info(this, &box, &text, &icon,
                            getAlign(), m_bmp->w, m_bmp->h);

  ev.setPreferredSize(gfx::Size(border_width.l + jrect_w(&box) + border_width.r,
                                border_width.t + jrect_h(&box) + border_width.b));
}
Example #2
0
void ColorButton::onPaint(PaintEvent& ev) // TODO use "ev.getGraphics()"
{
  struct jrect box, text, icon;
  jwidget_get_texticon_info(this, &box, &text, &icon, 0, 0, 0);

  int bg = getBgColor();
  if (bg < 0) bg = ji_color_face();
  jdraw_rectfill(this->rc, bg);

  Color color;

  // When the button is pushed, show the negative
  if (isSelected()) {
    color = Color::fromRgb(255-m_color.getRed(),
			   255-m_color.getGreen(),
			   255-m_color.getBlue());
  }
  // When the button is not pressed, show the real color
  else
    color = this->m_color;

  draw_color_button
    (ji_screen,
     this->getBounds(),
     true, true, true, true,
     true, true, true, true,
     this->m_imgtype,
     color,
     this->hasMouseOver(), false);

  // Draw text
  std::string str = m_color.toFormalString(this->m_imgtype, false);

  setTextQuiet(str.c_str());
  jwidget_get_texticon_info(this, &box, &text, &icon, 0, 0, 0);
  
  int textcolor = makecol(255, 255, 255);
  if (color.isValid())
    textcolor = color_utils::blackandwhite_neg(color.getRed(), color.getGreen(), color.getBlue());

  jdraw_text(ji_screen, getFont(), getText(), text.x1, text.y1,
	     textcolor, -1, false, jguiscale());
}
Example #3
0
void ColorButton::onPreferredSize(PreferredSizeEvent& ev)
{
  struct jrect box;

  jwidget_get_texticon_info(this, &box, NULL, NULL, 0, 0, 0);

  box.x2 = box.x1+64;

  ev.setPreferredSize(jrect_w(&box) + border_width.l + border_width.r,
		      jrect_h(&box) + border_width.t + border_width.b);
}
Example #4
0
void ImageView::onPaint(PaintEvent& ev)
{
  struct jrect box, text, icon;

  jwidget_get_texticon_info(this, &box, &text, &icon,
                            getAlign(), m_bmp->w, m_bmp->h);

  jdraw_rectexclude(rc, &icon, getBgColor());

  blit(m_bmp, ji_screen, 0, 0,
       icon.x1, icon.y1, jrect_w(&icon), jrect_h(&icon));
}