if(font != null) gc.setFont(font);
Rectangle drawRect = new Rectangle(1, 1, getSize().x - 2, getSize().y - 2);
//button.getSize().y - 2
if ((getStyle() & SWT.TOGGLE) != 0 && getSelection()) {
if (theme instanceof GeneralThemeRender) {
GeneralThemeRender themeRender = (GeneralThemeRender) theme;
gc.setForeground(themeRender.getTool_item_check_selection_bg_normal1());
gc.setBackground(themeRender.getTool_item_check_selection_bg_normal2());
gc.fillGradientRectangle(drawRect.x, drawRect.y, drawRect.width, drawRect.height, true);
gc.setForeground(themeRender.getTool_item_check_selection_fg_normal());
gc.drawRectangle(drawRect);
} else if (theme instanceof OfficeThemeRender) {
OfficeThemeRender themeRender = (OfficeThemeRender) theme;
Color[] colors = new Color[] {
themeRender.getTool_item_outer_top_checked1(),
themeRender.getTool_item_outer_top_checked2(),
themeRender.getTool_item_outer_bottom_checked1(),
themeRender.getTool_item_outer_bottom_checked2(),
themeRender.getTool_item_inner_top_checked1(),
themeRender.getTool_item_inner_top_checked2(),
themeRender.getTool_item_inner_bottom_checked1(),
themeRender.getTool_item_inner_bottom_checked2(),
themeRender.getTool_item_border_checked(), };
drawGradientBack(gc, drawRect, colors);
drawGradientBorder(gc, drawRect, colors);
} else if (theme instanceof GlossyThemeRender) {
drawGlossyItem(gc, drawRect);
}
}
if (theme instanceof GeneralThemeRender) {
GeneralThemeRender themeRender = (GeneralThemeRender) theme;
if (selected && isEnabled()) {
if (menuTracked || (getMenu() != null && !canSelected())) {
gc.setForeground(themeRender.getTool_item_showmenu_bg1());
gc.setBackground(themeRender.getTool_item_showmenu_bg2());
gc.fillGradientRectangle(drawRect.x, drawRect.y, drawRect.width,
drawRect.height, true);
gc.setForeground(themeRender.getTool_item_showmenu_fg());
gc.drawRectangle(drawRect);
} else {
gc.setForeground(themeRender.getTool_item_bg_selected1());
gc.setBackground(themeRender.getTool_item_bg_selected2());
if (getMenu() != null) {
Rectangle noneMenuRect = getNonMenuRect();
gc.fillGradientRectangle(noneMenuRect.x, noneMenuRect.y,
noneMenuRect.width, noneMenuRect.height, true);
gc.setForeground(themeRender.getTool_item_bg_track1());
gc.setBackground(themeRender.getTool_item_bg_track2());
Rectangle menuRect = getMenuRect();
gc.fillGradientRectangle(menuRect.x, menuRect.y, menuRect.width, menuRect.height, true);
} else {
gc.fillGradientRectangle(drawRect.x, drawRect.y, drawRect.width, drawRect.height, true);
}
gc.setForeground(themeRender.getTool_item_fg_selected());
gc.drawRectangle(drawRect);
}
} else if ((getStyle() & SWT.TOGGLE) != 0 && getSelection() && isEnabled()) {
gc.setForeground(themeRender.getTool_item_check_selection_bg_track1());
gc.setBackground(themeRender.getTool_item_check_selection_bg_track2());
gc.fillGradientRectangle(drawRect.x, drawRect.y, drawRect.width,
drawRect.height, true);
gc.setForeground(themeRender.getTool_item_check_selection_fg_track());
gc.drawRectangle(drawRect);
} else {
gc.setForeground(themeRender.getTool_item_bg_track1());
gc.setBackground(themeRender.getTool_item_bg_track2());
gc.fillGradientRectangle(drawRect.x, drawRect.y, drawRect.width, drawRect.height, true);
gc.setForeground(themeRender.getTool_item_fg_track());
gc.drawRectangle(drawRect);
}
} else if (theme instanceof OfficeThemeRender) {
OfficeThemeRender themeRender = (OfficeThemeRender) theme;
Color[] colors = null;
if (selected && isEnabled()) {
if (menuTracked || (getMenu() != null && !canSelected())) {
colors = new Color[] {
themeRender.getTool_item_outer_top_showmenu_color1(),
themeRender.getTool_item_outer_top_showmenu_color2(),
themeRender.getTool_item_outer_bottom_showmenu_color1(),
themeRender.getTool_item_outer_bottom_showmenu_color2(),
themeRender.getTool_item_inner_top_showmenu_color1(),
themeRender.getTool_item_inner_top_showmenu_color2(),
themeRender.getTool_item_inner_bottom_showmenu_color1(),
themeRender.getTool_item_inner_bottom_showmenu_color2(),
themeRender.getTool_item_border_showmenu_color(), };
drawGradientBack(gc, drawRect, colors);
drawGradientBorder(gc, drawRect, colors);
} else {
colors = new Color[] { themeRender.getTool_item_outer_top_selected1(),
themeRender.getTool_item_outer_top_selected2(),
themeRender.getTool_item_outer_bottom_selected1(),
themeRender.getTool_item_outer_bottom_selected2(),
themeRender.getTool_item_inner_top_selected1(),
themeRender.getTool_item_inner_top_selected2(),
themeRender.getTool_item_inner_bottom_selected1(),
themeRender.getTool_item_inner_bottom_selected2(),
themeRender.getTool_item_border_selected(), };
if (getMenu() != null) {
drawGradientBack(gc, getNonMenuRect(), colors);
colors = new Color[] {
themeRender.getTool_item_outer_top_track1(),
themeRender.getTool_item_outer_top_track2(),
themeRender.getTool_item_outer_bottom_track1(),
themeRender.getTool_item_outer_bottom_track2(),
themeRender.getTool_item_inner_top_track1(),
themeRender.getTool_item_inner_top_track2(),
themeRender.getTool_item_inner_bottom_track1(),
themeRender.getTool_item_inner_bottom_track2(),
themeRender.getTool_item_border_track(), };
drawGradientBack(gc, getMenuRect(), colors);
} else {
drawGradientBack(gc, drawRect, colors);
}
drawGradientBorder(gc, drawRect, colors);
}
} else if ((getStyle() & SWT.TOGGLE) != 0 && getSelection() && isEnabled()) {
colors = new Color[] {
themeRender.getTool_item_outer_top_checked_track1(),
themeRender.getTool_item_outer_top_checked_track2(),
themeRender.getTool_item_outer_bottom_checked_track1(),
themeRender.getTool_item_outer_bottom_checked_track2(),
themeRender.getTool_item_inner_top_checked_track1(),
themeRender.getTool_item_inner_top_checked_track2(),
themeRender.getTool_item_inner_bottom_checked_track1(),
themeRender.getTool_item_inner_bottom_checked_track2(),
themeRender.getTool_item_border_checked_track(), };
drawGradientBack(gc, drawRect, colors);
drawGradientBorder(gc, drawRect, colors);
} else {
colors = new Color[] { themeRender.getTool_item_outer_top_track1(),
themeRender.getTool_item_outer_top_track2(),
themeRender.getTool_item_outer_bottom_track1(),
themeRender.getTool_item_outer_bottom_track2(),
themeRender.getTool_item_inner_top_track1(),
themeRender.getTool_item_inner_top_track2(),
themeRender.getTool_item_inner_bottom_track1(),
themeRender.getTool_item_inner_bottom_track2(),
themeRender.getTool_item_border_track(), };
drawGradientBack(gc, drawRect, colors);
drawGradientBorder(gc, drawRect, colors);
}
} else if (theme instanceof GlossyThemeRender) {
drawGlossyItem(gc, drawRect);