Esempio n. 1
0
void Tabs::drawTab(BITMAP* bmp, JRect box, Tab* tab, int y_delta, bool selected)
{
  // Is the tab outside the bounds of the widget?
  if (box->x1 >= this->rc->x2 || box->x2 <= this->rc->x1)
    return;

  SkinTheme* theme = static_cast<SkinTheme*>(this->getTheme());
  int text_color;
  int face_color;

  // Selected
  if (selected) {
    text_color = theme->get_tab_selected_text_color();
    face_color = theme->get_tab_selected_face_color();
  }
  // Non-selected
  else {
    text_color = theme->get_tab_normal_text_color();
    face_color = theme->get_tab_normal_face_color();
  }

  if (jrect_w(box) > 2) {
    theme->draw_bounds_nw(bmp,
                          box->x1, box->y1+y_delta, box->x2-1, box->y2-1,
                          (selected) ? PART_TAB_SELECTED_NW:
                                       PART_TAB_NORMAL_NW, face_color);
    jdraw_text(bmp, this->getFont(), tab->text.c_str(),
               box->x1+4*jguiscale(),
               (box->y1+box->y2)/2-text_height(this->getFont())/2+1 + y_delta,
               text_color, face_color, false, jguiscale());
  }

  if (selected) {
    theme->draw_bounds_nw(bmp,
                          box->x1, box->y2, box->x2-1, this->rc->y2-1,
                          PART_TAB_BOTTOM_SELECTED_NW,
                          theme->get_tab_selected_face_color());
  }
  else {
    theme->draw_part_as_hline(bmp,
                              box->x1, box->y2, box->x2-1, this->rc->y2-1,
                              PART_TAB_BOTTOM_NORMAL);
  }

#ifdef CLOSE_BUTTON_IN_EACH_TAB
  BITMAP* close_icon = theme->get_part(PART_WINDOW_CLOSE_BUTTON_NORMAL);
  set_alpha_blender();
  draw_trans_sprite(doublebuffer, close_icon,
                    box->x2-4*jguiscale()-close_icon->w,
                    (box->y1+box->y2)/2-close_icon->h/2+1*jguiscale());
#endif
}