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 }
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()); }