SWT Ribbon Control 主頁及下載地址, 精彩截屏

http://hexapixel.com/projects/

http://hexapixel.com/ribbon/

下載地址: download the jar and the source

源碼包裏面的 com.hexapixel.widgets.ribbon.RibbonTester 展示瞭如何使用這個組件.

作者提示道: 可能有很多 bug, 僅供測試.

呵呵, 差不多所有組件都要重新代碼畫了, 這就也跟 Swing 一樣的思路了. 沒辦法, Java 的界面, 一直到現在也沒幾個做的速度快又漂亮的, 包括 SWT 在內.

更多截圖:

SWT Ribbon Control (Work in progress) - Screenshots
 
Features so far (major features):
  • Groups - Named, Hover/Dehover colors, Dividers, Tooltip button corners on/off.
  • Buttons - Normal, Toggle, Split, Toggle & Split, Enabled & disabled images. Vertical image alignments. Arrows.
    • Split - Tooltip / Actions for both top & bottom. Supports toggle or non toggle for half button.
    • Big - Same features as small, just different size.
  • Tabs - Scrollwheel to cycle, Hover, Selected, Double-click to expand/collapse entire folder
  • Checkboxes - The usual features
  • Tooltips - Customizable images, text, sizes, fonts, colors, help icons, help text, rounded shell corners
  • Button Dependency Groups - If button A belongs with buttons B and C and A is selected. User presses C. C is selected. A deselects.
Todo list:
  • Event colors - Currently Normal, Hover, Hover + Selected are done, need to do Hover + Selected + MouseDown.
  • Labels - Simple lables with images.
  • Groups - Fade in/Fade out.
  • Toolbar - All of it, included split-buttons.
  • Layouts - Let user define built-ins to some extent.
    ... questionmarks:
  • Big button - Big button in top left corner? Needed? Too much?
  • What else?
1. Normal button with tooltip, text split on two rows, arrow.
 
2. Split button, showing menu popup when bottom is clicked
 
3. Split button where top is selected, no mouse focus
 
4. Normal button with tooltip
 
5. Same button, pressed and hovered and selected.
 
6. Small split button, right part pressed down.
 
7. Checkboxes, disabled with tooltip.
 
8. Active tab + hover.
 
9. Hover over non-active tab.
 
10. Checkbox, with hover.
 
11. Native control interaction (do note that "Native" group does
not show hover right now, working on that).
 
12. Collapsed entire tabfolder by doubleclicking tab.
 
/*******************************************************************************
 * Copyright (c) Emil Crumhorn - Hexapixel.com - [email protected]
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * 
http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *    [email protected] - initial API and implementation
 ******************************************************************************
*/ 

package com.hexapixel.widgets.ribbon;

import java.util.List;

import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Rectangle;

import com.hexapixel.widgets.generic.ColorCache;

/**
 * Draws a Toolbar button in one of the following states:
 *     
 *  - Hover (light)
 *     - Selected (darker)
 *     - Selected and Hover (darkest)
 * 
 * This is very down to the pixel level and not very simply done, each mode has different highlighted pixels as well so it's
 * not just a matter of darkening or lightening a certain color.
 * 
 * 
@author Emil Crumhorn
 *
 
*/
public abstract class AbstractButtonPainter {

    
private static int TOP_SPACING = 2;

    
// SPLIT BUTTON (Mostly same colors as others, but fills and divider change)
    private Color mInnerTopPartTopTopSplit = ColorCache.getInstance().getColor(255254243);
    
private Color mInnerTopPartTopBottomSplit = ColorCache.getInstance().getColor(255247217);
    
private Color mInnerTopPartTopBottomTopSplit = ColorCache.getInstance().getColor(255241194);
    
private Color mInnerTopPartTopBottomBottomSplit = ColorCache.getInstance().getColor(255240195);
    
    
private Color mInnerTopPartTopTopSplit_Hover = ColorCache.getInstance().getColor(255253219);
    
private Color mInnerTopPartTopBottomSplit_Hover = ColorCache.getInstance().getColor(255231144);
    
private Color mInnerTopPartTopBottomTopSplit_Hover = ColorCache.getInstance().getColor(25521576);
    
private Color mInnerTopPartTopBottomBottomSplit_Hover = ColorCache.getInstance().getColor(25521170);

    
private Color mInnerBottomPartTopSplit = ColorCache.getInstance().getColor(255239199);
    
private Color mInnerBottomPartBottomSplit = ColorCache.getInstance().getColor(255247223);
    
private Color mInnerBottomPartTopSplit_Hover = ColorCache.getInstance().getColor(25521283);
    
private Color mInnerBottomPartBottomSplit_Hover = ColorCache.getInstance().getColor(255234168);
    
private Color mInnerBottomPartTopSplit_Selected = ColorCache.getInstance().getColor(24917078);
    
private Color mInnerBottomPartBottomSplit_Selected = ColorCache.getInstance().getColor(252231160);

    
private Color mInnerSplitDividerLeft = ColorCache.getInstance().getColor(219195116);
    
private Color mInnerSplitDividerMid = ColorCache.getInstance().getColor(206190134);

    
private Color mInnerSplitSmallDividerTop = ColorCache.getInstance().getColor(226214189);
    
private Color mInnerSplitSmallDividerMid = ColorCache.getInstance().getColor(205181131);

    
// SPLIT SMALL
    private Color mInnerTopPartTopTopSplitSmall = ColorCache.getInstance().getColor(255255251);
    
private Color mInnerTopPartTopBottomSplitSmall = ColorCache.getInstance().getColor(255248224);
    
private Color mInnerTopPartTopBottomTopSplitSmall = ColorCache.getInstance().getColor(255252192);
    
private Color mInnerTopPartTopBottomBottomSplitSmall = ColorCache.getInstance().getColor(255251214);

    
/*    private Color mInnerBottomTopSplit = ColorCache.getInstance().getColor(255, 254, 243);
    private Color mInnerBottomBottomSplit = ColorCache.getInstance().getColor(255, 254, 243);
    private Color mInnerBottomTopSplit_Hover = ColorCache.getInstance().getColor(255, 254, 243);
    private Color mInnerBottomBottomSplit_Hover = ColorCache.getInstance().getColor(255, 254, 243);
*/    
    
// HOVER COLORS
    private Color mBorderTop_Hover = ColorCache.getInstance().getColor(221207155); 
    
private Color mBorderSideTopTop_Hover = ColorCache.getInstance().getColor(220206154);
    
private Color mBorderSideTopBottom_Hover = ColorCache.getInstance().getColor(197174125); // 24 px high total
    private Color mBorderSideMidTop_Hover = ColorCache.getInstance().getColor(196173124); 
    
private Color mBorderSideMidBottom_Hover = ColorCache.getInstance().getColor(198178131); // 27 px high total
    private Color mBorderSideBottomTop_Hover = ColorCache.getInstance().getColor(198180135);
    
private Color mBorderSideBottomBottom_Hover = ColorCache.getInstance().getColor(211206185); // 13 px high total
    private Color mBorderBottom_Hover = ColorCache.getInstance().getColor(211207188);
    
    
private Color mCornerFadeTopPixel_Hover = ColorCache.getInstance().getColor(234226168);
    
private Color mCornerFadeBottomPixel_Hover = ColorCache.getInstance().getColor(235225189);
    
    
private Color mBorderInnerTop_Hover = ColorCache.getInstance().getColor(255255247);
    
private Color mBorderInnerSideTopTop_Hover = ColorCache.getInstance().getColor(255255247);
    
private Color mBorderInnerSideTopBottom_Hover = ColorCache.getInstance().getColor(255248223); // 23 px high total
    private Color mBorderInnerSideMidTop_Hover = ColorCache.getInstance().getColor(255243206); 
    
private Color mBorderInnerSideMidBottom_Hover = ColorCache.getInstance().getColor(255243173); // 27 px high total
    private Color mBorderInnerSideBottomTop_Hover = ColorCache.getInstance().getColor(255243170);
    
private Color mBorderInnerSideBottomBottom_Hover = ColorCache.getInstance().getColor(25524393); // 12 px high total    
    private Color mBorderInnerBottomCorner_Hover = ColorCache.getInstance().getColor(255247146);
    
private Color mBorderInnerBottomMidway_Hover = ColorCache.getInstance().getColor(255254247);
    
    
private Color mInnerTop_Hover = ColorCache.getInstance().getColor(255253220);
    
private Color mInnerTopBottom_Hover = ColorCache.getInstance().getColor(255231143);
    
private Color mInnerBottomTop_Hover = ColorCache.getInstance().getColor(25521592);
    
private Color mInnerBottomBottom_Hover = ColorCache.getInstance().getColor(255233164);
    
    
// TEXT COLOR
    private Color mButtonTextColor = ColorCache.getInstance().getColor(2166139);
    
    
// SELECTED COLORS
    private Color mBorderTop_Selected = ColorCache.getInstance().getColor(142129101);
    
    
private Color mBorderSideTopTop_Selected = ColorCache.getInstance().getColor(142129101);
    
private Color mBorderSideTopBottom_Selected = ColorCache.getInstance().getColor(142129101); // 24 px high total
    private Color mBorderSideMidTop_Selected = ColorCache.getInstance().getColor(142129101); 
    
private Color mBorderSideMidBottom_Selected = ColorCache.getInstance().getColor(166155133); // 27 px high total
    private Color mBorderSideBottomTop_Selected = ColorCache.getInstance().getColor(168158136);
    
private Color mBorderSideBottomBottom_Selected = ColorCache.getInstance().getColor(198192178); // 11 px high total
    
    
private Color mCornerFadeTopPixel_Selected = ColorCache.getInstance().getColor(181167145);
    
private Color mCornerFadeBottomPixel_Selected = ColorCache.getInstance().getColor(247229168);
    
private Color mCornerFadeBottomInsidePixel_Selected = ColorCache.getInstance().getColor(25421693);
    
    
private Color mBorderInnerSideTopTop_Selected = ColorCache.getInstance().getColor(24318695);
    
private Color mBorderInnerSideTopBottom_Selected = ColorCache.getInstance().getColor(25019593); // 23 px high total
    private Color mBorderInnerSideMidTop_Selected = ColorCache.getInstance().getColor(24819081); 
    
private Color mBorderInnerSideMidBottom_Selected = ColorCache.getInstance().getColor(25320873); // 27 px high total
    private Color mBorderInnerSideBottomTop_Selected = ColorCache.getInstance().getColor(25320870);
    
private Color mBorderInnerSideBottomBottom_Selected = ColorCache.getInstance().getColor(25520849); // 11 px high total
    
    
private Color mBorderInnerBottomCorner_Selected = ColorCache.getInstance().getColor(25520745);
    
private Color mBorderInnerBottomMidway_Selected = ColorCache.getInstance().getColor(255233160);
    
    
private Color mBorderTopInner_Selected = ColorCache.getInstance().getColor(182154120);
    
private Color mBorderTopInnerTwo_Selected = ColorCache.getInstance().getColor(224182136);
    
private Color mBorderTopInnerThree_Selected = ColorCache.getInstance().getColor(245201154);

    
private Color mInnerTop_Selected = ColorCache.getInstance().getColor(253212168);
    
private Color mInnerTopBottom_Selected = ColorCache.getInstance().getColor(25117395);
    
private Color mInnerMidTop_Selected = ColorCache.getInstance().getColor(24914846);
    
private Color mInnerMidBottom_Selected = ColorCache.getInstance().getColor(252226147);
    
private Color mInnerBottomTop_Selected = ColorCache.getInstance().getColor(252230154);
    
private Color mInnerBottomBottom_Selected = ColorCache.getInstance().getColor(253241176);

    
// SELECTED AND HOVER
    private Color mBorderTop_SelectedHover = ColorCache.getInstance().getColor(142129101);
    
    
private Color mBorderSideTopTop_SelectedHover = ColorCache.getInstance().getColor(142129101);
    
private Color mBorderSideTopBottom_SelectedHover = ColorCache.getInstance().getColor(142129101); // 24 px high total
    private Color mBorderSideMidTop_SelectedHover = ColorCache.getInstance().getColor(142129101); 
    
private Color mBorderSideMidBottom_SelectedHover = ColorCache.getInstance().getColor(166155133); // 27 px high total
    private Color mBorderSideBottomTop_SelectedHover = ColorCache.getInstance().getColor(168158136);
    
private Color mBorderSideBottomBottom_SelectedHover = ColorCache.getInstance().getColor(198192178); // 11 px high total
    
    
private Color mCornerFadeTopPixel_SelectedHover = ColorCache.getInstance().getColor(151137109);
    
private Color mCornerFadeBottomPixel_SelectedHover = ColorCache.getInstance().getColor(204190165);
    
private Color mCornerFadeBottomPixelCenter_SelectedHover = ColorCache.getInstance().getColor(225194113);
    
    
private Color mBorderInnerSideTopTop_SelectedHover = ColorCache.getInstance().getColor(22515347);
    
private Color mBorderInnerSideTopBottom_SelectedHover = ColorCache.getInstance().getColor(253226178); // 23 px high total
    private Color mBorderInnerSideMidTop_SelectedHover = ColorCache.getInstance().getColor(252226181); 
    
private Color mBorderInnerSideMidBottom_SelectedHover = ColorCache.getInstance().getColor(254229160); // 27 px high total
    private Color mBorderInnerSideBottomTop_SelectedHover = ColorCache.getInstance().getColor(254228155);
    
private Color mBorderInnerSideBottomBottom_SelectedHover = ColorCache.getInstance().getColor(255223113); // 11 px high total
    
    
private Color mBorderBottom_SelectedHover = ColorCache.getInstance().getColor(212197173);
    
    
private Color mBorderInnerBottomCorner_SelectedHover = ColorCache.getInstance().getColor(25520744);
    
private Color mBorderInnerBottomMidway_SelectedHover = ColorCache.getInstance().getColor(255233160);
    
    
private Color mBorderTopInner_SelectedHover = ColorCache.getInstance().getColor(16813694);
    
private Color mBorderTopInnerTwo_SelectedHover = ColorCache.getInstance().getColor(209155101);
    
private Color mBorderTopInnerThree_SelectedHover = ColorCache.getInstance().getColor(233169107);

    
private Color mInnerTop_SelectedHover = ColorCache.getInstance().getColor(233169107);
    
private Color mInnerTopBottom_SelectedHover = ColorCache.getInstance().getColor(22713978);
    
private Color mInnerMidTop_SelectedHover = ColorCache.getInstance().getColor(22913050);
    
private Color mInnerMidBottom_SelectedHover = ColorCache.getInstance().getColor(25220396);
    
private Color mInnerBottomTop_SelectedHover = ColorCache.getInstance().getColor(24919794);
    
private Color mInnerBottomBottom_SelectedHover = ColorCache.getInstance().getColor(252207100);
    
    
// SMALL BUTTONS
    
// HOVER
    private Color mSideTopTopSmall_Hover = ColorCache.getInstance().getColor(216202150);
    
private Color mSideTopBottomSmall_Hover = ColorCache.getInstance().getColor(185160116);
    
private Color mSideBottomTopSmall_Hover = ColorCache.getInstance().getColor(183158115);
    
private Color mSideBottomBottomSmall_Hover = ColorCache.getInstance().getColor(184169142);
    
private Color mBottomSmallMid_Hover = ColorCache.getInstance().getColor(203196170);
    
private Color mBorderSmallSideBottomTop_Hover = ColorCache.getInstance().getColor(255242201);
    
private Color mBorderSmallSideBottomBottom_Hover = ColorCache.getInstance().getColor(255246185); 
    
private Color mBorderSmallInsidePixelTop_Hover = ColorCache.getInstance().getColor(233223159);
    
private Color mBorderSmallInsidePixelBottom_Hover = ColorCache.getInstance().getColor(233219177);
    
    
// SELECTED
    private Color mSmallTop_Selected = ColorCache.getInstance().getColor(167142102);
    
private Color mSmallTopInner_Selected = ColorCache.getInstance().getColor(203180153);
    
private Color mSmallTopInnerTwo_Selected = ColorCache.getInstance().getColor(234209178);
    
private Color mSmallLeftSide_Selected = ColorCache.getInstance().getColor(15813085);
    
private Color mSmallRightSide_Selected = mSmallTop_Selected;
    
private Color mBottomSmallMid_Selected = ColorCache.getInstance().getColor(204197172);

    
private Color mSmallFillTopTop_Selected = ColorCache.getInstance().getColor(248218183);
    
private Color mSmallFillTopBottom_Selected = ColorCache.getInstance().getColor(254211139);
    
private Color mSmallFillBottomTop_Selected = ColorCache.getInstance().getColor(25319492);
    
private Color mSmallFillBottomBottom_Selected = ColorCache.getInstance().getColor(253234156);
    
    
private Color mSideBottomBottomSmall_Selected = ColorCache.getInstance().getColor(184169142);
    
private Color mBorderSmallSideTopTop_Selected = ColorCache.getInstance().getColor(239211176);
    
private Color mBorderSmallSideTopBottom_Selected = ColorCache.getInstance().getColor(24117890); 
    
private Color mBorderSmallSideBottomTop_Selected = ColorCache.getInstance().getColor(23917272);
    
private Color mBorderSmallSideBottomBottom_Selected = ColorCache.getInstance().getColor(23017782); 
    
private Color mBorderSmallInsidePixelTop_Selected = ColorCache.getInstance().getColor(178154120);
    
private Color mBorderSmallInsidePixelBottom_Selected = ColorCache.getInstance().getColor(200163104);

    
// SELECTED AND HOVER
    private Color mSmallTop_SelectedHover = ColorCache.getInstance().getColor(15813085);
    
private Color mSmallTopInner_SelectedHover = ColorCache.getInstance().getColor(18914070);
    
private Color mSmallTopInnerTwo_SelectedHover = ColorCache.getInstance().getColor(22216487);
    
private Color mSmallLeftSide_SelectedHover = mSmallTop_SelectedHover;
    
private Color mSmallRightSide_SelectedHover = mSmallTop_SelectedHover;
    
private Color mBottomSmallMid_SelectedHover = ColorCache.getInstance().getColor(204197172);

    
private Color mBottomSmallInnerSide_SelectedHover = ColorCache.getInstance().getColor(25517358);
    
private Color mBottomSmallInnerMid_SelectedHover = ColorCache.getInstance().getColor(255201124);

    
private Color mSmallFillTopTop_SelectedHover = ColorCache.getInstance().getColor(243179101);
    
private Color mSmallFillTopBottom_SelectedHover = ColorCache.getInstance().getColor(25117389);
    
private Color mSmallFillBottomTop_SelectedHover = ColorCache.getInstance().getColor(25015647);
    
private Color mSmallFillBottomBottom_SelectedHover = ColorCache.getInstance().getColor(25218216);
    
    
private Color mSideBottomBottomSmall_SelectedHover = ColorCache.getInstance().getColor(184169142);
    
private Color mBorderSmallSideTopTop_SelectedHover = ColorCache.getInstance().getColor(23117495);
    
private Color mBorderSmallSideTopBottom_SelectedHover = ColorCache.getInstance().getColor(250209135); 
    
private Color mBorderSmallSideBottomTop_SelectedHover = ColorCache.getInstance().getColor(250203123);
    
private Color mBorderSmallSideBottomBottom_SelectedHover = ColorCache.getInstance().getColor(25417456); 
    
private Color mBorderSmallInsidePixelTop_SelectedHover = ColorCache.getInstance().getColor(15813085);
    
private Color mBorderSmallInsidePixelTopTwo_SelectedHover = ColorCache.getInstance().getColor(20815684);
    
private Color mBorderSmallInsidePixelBottom_SelectedHover = ColorCache.getInstance().getColor(21616897);
    
    
// ARROW
    private Color mArrowColor = ColorCache.getInstance().getColor(86125177);
    
private Color mArrowColorShadow = ColorCache.getInstance().getColor(234242249);
    
private Color mArrowColor_Disabled = ColorCache.getInstance().getColor(183183183);
    
private Color mArrowColorShadow_Disabled = ColorCache.getInstance().getColor(237237237);

    
// SEPARATOR 
    private Color mSeparatorColor = ColorCache.getInstance().getColor(251252254);
    
private Color mSeparatorColorShadow = ColorCache.getInstance().getColor(150180218);
    
    
// DISABLED TEXT
    private Color mTextColor_Disabled = ColorCache.getInstance().getColor(165141159);
    
private Color mTextFadedRight_Disabled = ColorCache.getInstance().getColor(178214241);
    
private Color mTextFadedLeft_Disabled = ColorCache.getInstance().getColor(211226210);
    
    
public void drawButton(GC gc, AbstractRibbonGroupItem item) {
        
int x = item.getX();
        
int y = item.getBounds().y;
        
int width = item.getWidth();
        
int yMax = RibbonTabComposite.GROUP_HEIGHT;
        yMax 
-= 3;
        yMax 
-= RibbonGroup.BUTTON_BOT_HEIGHT;
        
int imgTopSpacer = 5;

        
if (item instanceof RibbonGroupSeparator) {
            RibbonGroupSeparator rgs 
= (RibbonGroupSeparator) item;
            Rectangle rgsBounds 
= rgs.getBounds();
            drawSeparator(gc, rgsBounds.x, rgsBounds.y, rgsBounds.height);
        }
        
else if (item instanceof RibbonButton) {
            
if (item.isEnabled() && (item.getStyle() & AbstractRibbonGroupItem.STYLE_ARROW_DOWN_SPLIT) != 0) {
                drawSplitButton(gc, item);
                
return;
            }
                
            
if (item.isEnabled()) {
                
if (item.isHoverButton() && !item.isSelected()) {
                    
// top two lines
                    gc.setForeground(mBorderTop_Hover);
                    gc.drawLine(x
+1, y, x+width-2, y);
                    gc.setForeground(mBorderInnerTop_Hover);
                    gc.drawLine(x
+1, y+1, x+width-2, y+1);            
        
                    
// pixels in corners
                    gc.setForeground(mCornerFadeTopPixel_Hover);
                    gc.drawLine(x
+1, y+1, x+1, y+1);
                    gc.drawLine(x
+width-2, y+1, x+width-2, y+1);
                    
                    
// sides are 3 steps we split them a bit more due to more gradients
                    
// note that outer borders stretch 1px higher and lower in the top and bottom sections, but mid stays the same            
        
                    
// outer sides 
                    gc.setForeground(mBorderSideTopTop_Hover);
                    gc.setBackground(mBorderSideTopBottom_Hover);
                    gc.fillGradientRectangle(x, y
+1124true);
                    gc.fillGradientRectangle(x
+width-1, y+1124true);
                    
// inner sides 
                    gc.setForeground(mBorderInnerSideTopTop_Hover);
                    gc.setBackground(mBorderInnerSideTopBottom_Hover);
                    gc.fillGradientRectangle(x
+1, y+2123true);
                    gc.fillGradientRectangle(x
+width-2, y+2123true);
                    
// outer mid
                    gc.setForeground(mBorderSideMidTop_Hover);
                    gc.setBackground(mBorderSideMidBottom_Hover);
                    gc.fillGradientRectangle(x, y
+2+23127true);
                    gc.fillGradientRectangle(x
+width-1, y+2+23127true);
                    
// inner mid
                    gc.setForeground(mBorderInnerSideMidTop_Hover);
                    gc.setBackground(mBorderInnerSideMidBottom_Hover);
                    gc.fillGradientRectangle(x
+1, y+2+23127true);
                    gc.fillGradientRectangle(x
+width-2, y+2+23127true);
                    
// outer bottom 
                    gc.setForeground(mBorderInnerSideBottomTop_Hover);
                    gc.setBackground(mBorderInnerSideBottomBottom_Hover);
                    gc.fillGradientRectangle(x
+1, y+2+23+27112true);
                    gc.fillGradientRectangle(x
+width-2, y+2+23+27112true);            
                    
// inner bottom 
                    gc.setForeground(mBorderSideBottomTop_Hover);
                    gc.setBackground(mBorderSideBottomBottom_Hover);
                    gc.fillGradientRectangle(x, y
+2+23+27113true);
                    gc.fillGradientRectangle(x
+width-1, y+2+23+27113true);            
                    
// pixel is just below so we do that now too
                    gc.setForeground(mCornerFadeBottomPixel_Hover);
                    gc.drawLine(x
+1, y+2+23+27+12, x+1, y+2+23+27+12);
                    gc.drawLine(x
+width-2, y+2+23+27+12, x+width-2, y+2+23+27+12);
                    
                    
// draw bottom, outer is plain, inner is a radial gradient with highlight at width/2
                    gc.setForeground(mBorderBottom_Hover);
                    gc.drawLine(x
+1, y+2+23+27+12+1, x+width-2, y+2+23+27+12+1);
                    
// inner, left half
                    gc.setForeground(mBorderInnerBottomCorner_Hover);
                    gc.setBackground(mBorderInnerBottomMidway_Hover);
                    gc.fillGradientRectangle(x
+2, y+2+23+27+12, width/21false);
                    
// inner, right half
                    gc.setForeground(mBorderInnerBottomMidway_Hover);
                    gc.setBackground(mBorderInnerBottomCorner_Hover);
                    gc.fillGradientRectangle(x
+2+(width/2), y+2+23+27+12, (width/2)-31false);
                    
                    
// borders are all down, now we fill the center, which is the easy part compared
                    gc.setForeground(mInnerTop_Hover);
                    gc.setBackground(mInnerTopBottom_Hover);
                    gc.fillGradientRectangle(x
+2, y+2, width-423true);
        
                    gc.setForeground(mInnerBottomTop_Hover);
                    gc.setBackground(mInnerBottomBottom_Hover);
                    gc.fillGradientRectangle(x
+2, y+2+23, width-439true);
                                
                }
                
else 
                
if (item.isSelected() && !item.isHoverButton()) {
                    
// let's draw the outer box, start with top, sides, then bottom            
                    
// top
                    gc.setForeground(mBorderTop_Selected);
                    gc.drawLine(x
+1, TOP_SPACING, x+width-2, TOP_SPACING);
                    gc.setForeground(mBorderTopInner_Selected);
                    gc.drawLine(x
+2, TOP_SPACING+1, x+width-3, TOP_SPACING+1);
                    gc.setForeground(mBorderTopInnerTwo_Selected);
                    gc.drawLine(x
+2, TOP_SPACING+2, x+width-3, TOP_SPACING+2);
                    gc.setForeground(mBorderTopInnerThree_Selected);
                    gc.drawLine(x
+2, TOP_SPACING+3, x+width-3, TOP_SPACING+3);
                    
                    
// outer sides 
                    gc.setForeground(mBorderSideTopTop_Selected);
                    gc.setBackground(mBorderSideTopBottom_Selected);
                    gc.fillGradientRectangle(x, y
+1124true);
                    gc.fillGradientRectangle(x
+width-1, y+1124true);
                    
// inner sides 
                    gc.setForeground(mBorderInnerSideTopTop_Selected);
                    gc.setBackground(mBorderInnerSideTopBottom_Selected);
                    gc.fillGradientRectangle(x
+1, y+2123true);
                    gc.fillGradientRectangle(x
+width-2, y+2123true);
                    
// outer mid
                    gc.setForeground(mBorderSideMidTop_Selected);
                    gc.setBackground(mBorderSideMidBottom_Selected);
                    gc.fillGradientRectangle(x, y
+2+23127true);
                    gc.fillGradientRectangle(x
+width-1, y+2+23127true);
                    
// inner mid
                    gc.setForeground(mBorderInnerSideMidTop_Selected);
                    gc.setBackground(mBorderInnerSideMidBottom_Selected);
                    gc.fillGradientRectangle(x
+1, y+2+23127true);
                    gc.fillGradientRectangle(x
+width-2, y+2+23127true);
                    
// outer bottom 
                    gc.setForeground(mBorderInnerSideBottomTop_Selected);
                    gc.setBackground(mBorderInnerSideBottomBottom_Selected);
                    gc.fillGradientRectangle(x
+1, y+2+23+27112true);
                    gc.fillGradientRectangle(x
+width-2, y+2+23+27112true);            
                    
// inner bottom 
                    gc.setForeground(mBorderSideBottomTop_Selected);
                    gc.setBackground(mBorderSideBottomBottom_Selected);
                    gc.fillGradientRectangle(x, y
+2+23+27112true);
                    gc.fillGradientRectangle(x
+width-1, y+2+23+27112true);        
                                
                    
// draw pixel at top
                    gc.setForeground(mCornerFadeTopPixel_Selected);
                    gc.drawLine(x
+1, TOP_SPACING+1, x+1, TOP_SPACING+1);
                    gc.drawLine(x
+width-2, TOP_SPACING+1, x+width-2, TOP_SPACING+1);
                    
// draw bottom pixel
                    gc.setForeground(mCornerFadeBottomPixel_Selected);
                    gc.drawLine(x, y
+2+23+27+12, x, y+2+23+27+12);
                    gc.drawLine(x
+width-1, y+2+23+27+12, x+width-1, y+2+23+27+12);
                    
                    
// fills
                    gc.setForeground(mInnerTop_Selected);
                    gc.setBackground(mInnerTopBottom_Selected);
                    gc.fillGradientRectangle(x
+2, y+4, width-422true);
                    
                    gc.setForeground(mInnerMidTop_Selected);
                    gc.setBackground(mInnerMidBottom_Selected);
                    gc.fillGradientRectangle(x
+2, y+4+22, width-426true);
                    
                    gc.setForeground(mInnerBottomTop_Selected);
                    gc.setBackground(mInnerBottomBottom_Selected);
                    gc.fillGradientRectangle(x
+2, y+4+22+26, width-412true);
                    
                    gc.setForeground(mInnerBottomBottom_Selected);
                    gc.drawLine(x
+3, y+4+22+26+12, x+width-4, y+4+22+26+12);
                    
                    
// bottom border
                    gc.setForeground(mBorderInnerBottomCorner_Selected);
                    gc.setBackground(mBorderInnerBottomMidway_Selected);
                    gc.fillGradientRectangle(x
+1, y+4+22+26+12+1, (width/2)-21false);
                    gc.setForeground(mBorderInnerBottomMidway_Selected);
                    gc.setBackground(mBorderInnerBottomCorner_Selected);
                    gc.fillGradientRectangle(x
+1+(width/2)-2, y+4+22+26+12+1, (width/2)+11false);
                    
                    
// more pixels
                    gc.setForeground(mCornerFadeBottomInsidePixel_Selected);
                    gc.drawLine(x
+2, y+4+22+26+12, x+2, y+4+22+26+12);
                    gc.drawLine(x
+width-3, y+4+22+26+12, x+width-3, y+4+22+26+12);
                    gc.setForeground(mBorderInnerSideBottomBottom_Selected);
                    gc.drawLine(x
+1, y+4+22+26+12, x+1, y+4+22+26+12);
                    gc.drawLine(x
+width-2, y+4+22+26+12, x+width-2, y+4+22+26+12);
                }
                
else if (item.isSelected() && item.isHoverButton()) {
                    
// let's draw the outer box, start with top, sides, then bottom            
                    
// top
                    gc.setForeground(mBorderTop_SelectedHover);
                    gc.drawLine(x
+1, TOP_SPACING, x+width-2, TOP_SPACING);
                    gc.setForeground(mBorderTopInner_SelectedHover);
                    gc.drawLine(x
+2, TOP_SPACING+1, x+width-3, TOP_SPACING+1);
                    gc.setForeground(mBorderTopInnerTwo_SelectedHover);
                    gc.drawLine(x
+2, TOP_SPACING+2, x+width-3, TOP_SPACING+2);
                    gc.setForeground(mBorderTopInnerThree_SelectedHover);
                    gc.drawLine(x
+2, TOP_SPACING+3, x+width-3, TOP_SPACING+3);
                    
                    
// outer sides 
                    gc.setForeground(mBorderSideTopTop_SelectedHover);
                    gc.setBackground(mBorderSideTopBottom_SelectedHover);
                    gc.fillGradientRectangle(x, y
+1124true);
                    gc.fillGradientRectangle(x
+width-1, y+1124true);
                    
// inner sides 
                    gc.setForeground(mBorderInnerSideTopTop_SelectedHover);
                    gc.setBackground(mBorderInnerSideTopBottom_SelectedHover);
                    gc.fillGradientRectangle(x
+1, y+2123true);
                    gc.fillGradientRectangle(x
+width-2, y+2123true);
                    
// outer mid
                    gc.setForeground(mBorderSideMidTop_SelectedHover);
                    gc.setBackground(mBorderSideMidBottom_SelectedHover);
                    gc.fillGradientRectangle(x, y
+2+23127true);
                    gc.fillGradientRectangle(x
+width-1, y+2+23127true);
                    
// inner mid
                    gc.setForeground(mBorderInnerSideMidTop_SelectedHover);
                    gc.setBackground(mBorderInnerSideMidBottom_SelectedHover);
                    gc.fillGradientRectangle(x
+1, y+2+23127true);
                    gc.fillGradientRectangle(x
+width-2, y+2+23127true);
                    
// outer bottom 
                    gc.setForeground(mBorderInnerSideBottomTop_SelectedHover);
                    gc.setBackground(mBorderInnerSideBottomBottom_SelectedHover);
                    gc.fillGradientRectangle(x
+1, y+2+23+27112true);
                    gc.fillGradientRectangle(x
+width-2, y+2+23+27112true);            
                    
// inner bottom 
                    gc.setForeground(mBorderSideBottomTop_SelectedHover);
                    gc.setBackground(mBorderSideBottomBottom_SelectedHover);
                    gc.fillGradientRectangle(x, y
+2+23+27112true);
                    gc.fillGradientRectangle(x
+width-1, y+2+23+27112true);        
                                
                    
// draw pixel at top
                    gc.setForeground(mCornerFadeTopPixel_SelectedHover);
                    gc.drawLine(x
+1, TOP_SPACING+1, x+1, TOP_SPACING+1);
                    gc.drawLine(x
+width-2, TOP_SPACING+1, x+width-2, TOP_SPACING+1);
                    
// draw bottom pixel
                    gc.setForeground(mCornerFadeBottomPixel_SelectedHover);
                    gc.drawLine(x, y
+2+23+27+12, x, y+2+23+27+12);
                    gc.drawLine(x
+width-1, y+2+23+27+12, x+width-1, y+2+23+27+12);
                    
                    
// fills
                    gc.setForeground(mInnerTop_SelectedHover);
                    gc.setBackground(mInnerTopBottom_SelectedHover);
                    gc.fillGradientRectangle(x
+2, y+4, width-422true);
                    
                    gc.setForeground(mInnerMidTop_SelectedHover);
                    gc.setBackground(mInnerMidBottom_SelectedHover);
                    gc.fillGradientRectangle(x
+2, y+4+22, width-426true);
                    
                    gc.setForeground(mInnerBottomTop_SelectedHover);
                    gc.setBackground(mInnerBottomBottom_SelectedHover);
                    gc.fillGradientRectangle(x
+2, y+4+22+26, width-412true);
                    
                    gc.setForeground(mInnerBottomBottom_SelectedHover);
                    gc.drawLine(x
+3, y+4+22+26+12, x+width-4, y+4+22+26+12);
                    
                    
// bottom border
                    gc.setForeground(mBorderInnerBottomCorner_SelectedHover);
                    gc.setBackground(mBorderInnerBottomMidway_SelectedHover);
                    gc.fillGradientRectangle(x
+1, y+4+22+26+12, (width/2)-21false);
                    gc.setForeground(mBorderInnerBottomMidway_SelectedHover);
                    gc.setBackground(mBorderInnerBottomCorner_SelectedHover);
                    gc.fillGradientRectangle(x
+1+(width/2)-2, y+4+22+26+12, (width/2)+11false);
                    
                    
// bottom dark
                    gc.setForeground(mBorderBottom_SelectedHover);
                    gc.drawLine(x
+1, y+4+22+26+12+1, x+width-2, y+4+22+26+12+1);
                    
                    
// more pixels
                    gc.setForeground(mCornerFadeBottomPixelCenter_SelectedHover);
                    gc.drawLine(x
+1, y+4+22+26+12, x+1, y+4+22+26+12);
                    gc.drawLine(x
+width-2, y+4+22+26+12, x+width-2, y+4+22+26+12);
                }                
            }
            
            Image toDraw 
= item.getImage();
            
// fallback is normal image
            if (!item.isEnabled())
                toDraw 
= item.getDisabledImage() == null ? toDraw : item.getDisabledImage();
            
            
// draw image
            if (toDraw != null) {
                Rectangle imBounds 
= toDraw.getBounds();
                
int maxHeight = 32;
                
int horizAlignment = x+(width/2)-(imBounds.width/2);
                
switch (item.getImageVerticalAlignment()) {
                    
default:
                    
case SWT.TOP:
                    {
                        gc.drawImage(toDraw, horizAlignment, imgTopSpacer);
                        
break;
                    }
                    
case SWT.BOTTOM:
                    {
                        
int botSpacer = imBounds.height-maxHeight; 
                        
if (botSpacer < 0)
                            botSpacer 
= 0;
                        
                        botSpacer 
+= imgTopSpacer;
                        botSpacer 
*= 2;
                                            
                        gc.drawImage(toDraw, horizAlignment, botSpacer);
                        
break;
                    }
                    
case SWT.CENTER:
                    {
                        
int botSpacer = Math.abs(imBounds.height-maxHeight); 
                        
if (botSpacer < 0)
                            botSpacer 
= 0;
                        
                        
if (botSpacer != 0)
                            botSpacer 
/= 2;
    
                        botSpacer 
+= imgTopSpacer;
                                            
                        gc.drawImage(toDraw, horizAlignment, botSpacer);
                        
break;
                    }
                }
            }
            
            
// draw text            
            if (item.getName() != null) {
                
if (item.isEnabled()) {
                    gc.setForeground(mButtonTextColor);
                    gc.drawText(item.getName(), x
+340true);
                }
                
else {
                    gc.setForeground(mTextFadedRight_Disabled);
                    gc.drawText(item.getName(), x
+440true);
                    gc.setForeground(mTextFadedLeft_Disabled);
                    gc.drawText(item.getName(), x
+240true);
                    gc.setForeground(mTextColor_Disabled);
                    gc.drawText(item.getName(), x
+340true);
                }
            }            
        }
        
else if (item instanceof RibbonButtonGroup) {
            RibbonButtonGroup rbg 
= (RibbonButtonGroup) item;
            List
<AbstractRibbonGroupItem> buttons = rbg.getButtons();
            
            
int curY = y;
            
int curImgY = curY + imgTopSpacer - 2;
//            int curX = x;
            
            
if (buttons != null) {
                
int maxImgWidth = 0;
                
for (int i = 0; i < buttons.size(); i++) {
                    AbstractRibbonGroupItem button 
= buttons.get(i);
                    Image toUse 
= button.getImage(); 
                    
if (!button.isEnabled())
                        toUse 
= button.getDisabledImage() == null ? toUse : button.getDisabledImage();
                    
                    
if (toUse != null)
                        maxImgWidth 
= Math.max(maxImgWidth, toUse.getBounds().width);
                }
                
                
for (int i = 0; i < buttons.size(); i++) {
                    AbstractRibbonGroupItem button 
= buttons.get(i);

                    
if ((button.getStyle() & RibbonButton.STYLE_ARROW_DOWN_SPLIT) != 0)
                        drawSmallSplitButton(gc, button, maxImgWidth);
                    
else                        
                        drawSmallButton(gc, button, maxImgWidth);
                    
                    curY 
+= 22;
                    curImgY 
+= 22;
                }
            }
        }
    }
    
    
private void drawSmallSplitButton(GC gc, AbstractRibbonGroupItem button, int maxImgWidth) {
        
int x = button.getX();
        
int y = button.getBounds().y;
        
int yMax = RibbonTabComposite.GROUP_HEIGHT;
        yMax 
-= 3;
        yMax 
-= RibbonGroup.BUTTON_BOT_HEIGHT;
        
int imgTopSpacer = 5;

        Rectangle bounds 
= button.getBounds();                    
        
int bx = bounds.x;
        
int by = bounds.y;
        
int bw = bounds.width;
        
int bh = bounds.height;
                                    
        
int curY = y;
        
int curImgY = curY + imgTopSpacer - 2;
        
int curX = x;
        
        
// TODO: Setbounds on buttons seems off, and half is obviously 1 px off too, half is fine, but pick end pixel differently
        if (button.isEnabled()) {
            
if (!button.isSelected() && button.isHoverButton()) {
                gc.setForeground(mBorderTop_Hover);
                gc.drawLine(bx
+1, by, bx+bw-2, by);
                gc.setForeground(mBorderInnerTop_Hover);
                gc.drawLine(bx
+1, by+1, bx+bw-2, by+1);            
                
                gc.setForeground(mSideTopTopSmall_Hover);
                gc.setBackground(mSideTopBottomSmall_Hover);
                gc.fillGradientRectangle(bx, by
+1110true); // left
                gc.fillGradientRectangle(bx+bw-1, by+1110true); // right
                gc.setForeground(mSideBottomTopSmall_Hover);
                gc.setBackground(mSideBottomBottomSmall_Hover);
                gc.fillGradientRectangle(bx, by
+1+10110true); // left
                gc.fillGradientRectangle(bx+bw-1, by+1+10110true); // right
                
                gc.setForeground(mSideBottomBottomSmall_Hover);
                gc.setBackground(mBottomSmallMid_Hover);
                
int half = (bw-2)/2;
                gc.fillGradientRectangle(bx
+1, by+21, half, 1false);
                
// add -1 and start on the right so that if the half value is 1px off, it's ok as middle is highlight anyway
                gc.fillGradientRectangle(bx+bw-1, by+21-half-11false);
                
                
// fill
                if (button.isLeftHovered()) {
                    
int width = button.getLeftBounds().width;
                    
// fill left
                    gc.setForeground(mInnerTopPartTopTopSplitSmall);
                    gc.setBackground(mInnerTopPartTopBottomSplitSmall);
                    gc.fillGradientRectangle(bx
+2, by+2, width-19true);
                    gc.setForeground(mInnerTopPartTopBottomTopSplitSmall);
                    gc.setBackground(mInnerTopPartTopBottomBottomSplitSmall);
                    gc.fillGradientRectangle(bx
+2, by+2+9, width-19true);                
                    
                    
// fill right
                    gc.setForeground(mInnerTop_Hover);
                    gc.setBackground(mInnerTopBottom_Hover);
                    gc.fillGradientRectangle(button.getRightBounds().x, by
+2, button.getRightBounds().width, 9true);
                    gc.setForeground(mInnerBottomTop_Hover);
                    gc.setBackground(mInnerBottomBottom_Hover);
                    gc.fillGradientRectangle(button.getRightBounds().x, by
+2+9, button.getRightBounds().width, 9true);                    
                }
                
else {
                    
// fill left
                    gc.setForeground(mInnerTop_Hover);
                    gc.setBackground(mInnerTopBottom_Hover);
                    gc.fillGradientRectangle(bx
+2, by+2, bw-49true);
                    gc.setForeground(mInnerBottomTop_Hover);
                    gc.setBackground(mInnerBottomBottom_Hover);
                    gc.fillGradientRectangle(bx
+2, by+2+9, bw-49true);
                    
                    
// fill right
                    gc.setForeground(mInnerTopPartTopTopSplitSmall);
                    gc.setBackground(mInnerTopPartTopBottomSplitSmall);
                    gc.fillGradientRectangle(button.getRightBounds().x, by
+2, button.getRightBounds().width, 9true);
                    gc.setForeground(mInnerTopPartTopBottomTopSplitSmall);
                    gc.setBackground(mInnerTopPartTopBottomBottomSplitSmall);
                    gc.fillGradientRectangle(button.getRightBounds().x, by
+2+9, button.getRightBounds().width, 9true);                    
                }                

                
// inner borders
                gc.setForeground(mBorderInnerSideTopTop_Hover);
                gc.setBackground(mBorderInnerSideTopBottom_Hover);
                gc.fillGradientRectangle(bx
+1, by+219true);
                gc.fillGradientRectangle(bx
+bw-2, by+219true);
                gc.setForeground(mBorderSmallSideBottomTop_Hover);
                gc.setBackground(mBorderSmallSideBottomBottom_Hover);
                gc.fillGradientRectangle(bx
+1, by+2+919true);
                gc.fillGradientRectangle(bx
+bw-2, by+2+919true);
                
// bottom border
                gc.setForeground(mBorderSmallSideBottomBottom_Hover);
                gc.drawLine(bx
+1, by+2+9+9, bx+bw-2, by+2+9+9);
                
                gc.setForeground(mBorderSmallInsidePixelTop_Hover);
                gc.drawLine(bx
+1, by+1, bx+1, by+1);
                gc.drawLine(bx
+bw-2, by+1, bx+bw-2, by+1);
                gc.setForeground(mBorderSmallInsidePixelBottom_Hover);
                gc.drawLine(bx
+1, by+1+9+9+1, bx+1, by+1+9+9+1);
                gc.drawLine(bx
+bw-2, by+1+9+9+1, bx+bw-2, by+1+9+9+1);
                
                
// draw divider
                gc.setForeground(mInnerSplitSmallDividerTop);
                gc.setBackground(mInnerSplitSmallDividerMid);                
                gc.fillGradientRectangle(button.getRightBounds().x, y
+11, (bh/2)-1true);
                gc.setForeground(mInnerSplitSmallDividerMid);
                gc.setBackground(mInnerSplitSmallDividerTop);
                gc.fillGradientRectangle(button.getRightBounds().x, y
+(bh/2), 1, (bh/2)-1true);
                
            }
            
else if (button.isSelected()) {                
                
// draw hover border first
                gc.setForeground(mBorderTop_Hover);
                gc.drawLine(bx
+1, by, bx+bw-2, by);
                gc.setForeground(mBorderInnerTop_Hover);
                gc.drawLine(bx
+1, by+1, bx+bw-2, by+1);            
                
                gc.setForeground(mSideTopTopSmall_Hover);
                gc.setBackground(mSideTopBottomSmall_Hover);
                gc.fillGradientRectangle(bx, by
+1110true); // left
                gc.fillGradientRectangle(bx+bw-1, by+1110true); // right
                gc.setForeground(mSideBottomTopSmall_Hover);
                gc.setBackground(mSideBottomBottomSmall_Hover);
                gc.fillGradientRectangle(bx, by
+1+10110true); // left
                gc.fillGradientRectangle(bx+bw-1, by+1+10110true); // right
                
                gc.setForeground(mSideBottomBottomSmall_Hover);
                gc.setBackground(mBottomSmallMid_Hover);
                
int halfx = (bw-2)/2;
                gc.fillGradientRectangle(bx
+1, by+21, halfx, 1false);
                
// add -1 and start on the right so that if the half value is 1px off, it's ok as middle is highlight anyway
                gc.fillGradientRectangle(bx+bw-1, by+21-halfx-11false);
                                
                
int xx = bx+1;         // left x
                int xw = bx+bw-2;    // width                                
                
                
if (button.isLeftSelected()) {
                    xw 
= button.getRightBounds().x;
                }
                
else {
                    xx 
= button.getRightBounds().x;
                }
                
                
// draw outer
                gc.setForeground(mSmallTop_SelectedHover);
                gc.drawLine(xx, by, xw, by);
                gc.setForeground(mSmallTopInner_SelectedHover);
                gc.drawLine(xx, by
+1, xw, by+1);            
                
                gc.setForeground(mSmallLeftSide_SelectedHover);
                gc.drawLine(xx
-1, by+1, xx-1, by+1+19);
                gc.setForeground(mSmallRightSide_SelectedHover);
                gc.drawLine(xw
+1, by+1, xw+1, by+1+19);

                gc.setForeground(mSideBottomBottomSmall_SelectedHover);
                gc.setBackground(mBottomSmallMid_SelectedHover);
                
int halfy = (bw-2)/2;
                gc.fillGradientRectangle(xx, by
+21, halfy, 1false);
                
// add -1 and start on the right so that if the half value is 1px off, it's ok as middle is highlight anyway
                gc.fillGradientRectangle(xw+1, by+21-halfy-11false);

                
                gc.setForeground(mSmallTop_Selected);
                gc.drawLine(xx, by, xw, by);
                gc.setForeground(mSmallTopInner_Selected);
                gc.drawLine(xx, by
+1, xw, by+1);            
                
                gc.setForeground(mSmallLeftSide_Selected);
                gc.drawLine(xx
-1, by+1, xx-1, by+1+19);
                gc.setForeground(mSmallRightSide_Selected);
                gc.drawLine(xw
+1, by+1, xw+1, by+1+19);

                gc.setForeground(mSideBottomBottomSmall_Selected);
                gc.setBackground(mBottomSmallMid_Selected);
                
int half = (bw-2)/2;
                gc.fillGradientRectangle(xx, by
+21, half, 1false);
                
// add -1 and start on the right so that if the half value is 1px off, it's ok as middle is highlight anyway
                gc.fillGradientRectangle(xw+1, by+21-half-11false);
                
                
// fill
                if (button.isLeftSelected()) {
                    
// left
                    gc.setForeground(mSmallFillTopTop_SelectedHover);
                    gc.setBackground(mSmallFillTopBottom_SelectedHover);
                    gc.fillGradientRectangle(bx
+2, by+2, bw-49true);
                    gc.setForeground(mSmallFillBottomTop_SelectedHover);
                    gc.setBackground(mSmallFillBottomBottom_SelectedHover);
                    gc.fillGradientRectangle(bx
+2, by+2+9, bw-49true);

                    
// fill right
                    gc.setForeground(mInnerTopPartTopTopSplitSmall);
                    gc.setBackground(mInnerTopPartTopBottomSplitSmall);
                    gc.fillGradientRectangle(button.getRightBounds().x, by
+2, button.getRightBounds().width, 9true);
                    gc.setForeground(mInnerTopPartTopBottomTopSplitSmall);
                    gc.setBackground(mInnerTopPartTopBottomBottomSplitSmall);
                    gc.fillGradientRectangle(button.getRightBounds().x, by
+2+9, button.getRightBounds().width, 9true);       
                }
                
else if (button.isRightSelected()) {
                    
// fill left
                    gc.setForeground(mInnerTopPartTopTopSplitSmall);
                    gc.setBackground(mInnerTopPartTopBottomSplitSmall);
                    gc.fillGradientRectangle(bx
+2, by+2, bw-49true);
                    gc.setForeground(mInnerTopPartTopBottomTopSplitSmall);
                    gc.setBackground(mInnerTopPartTopBottomBottomSplitSmall);
                    gc.fillGradientRectangle(bx
+2, by+2+9, bw-49true);
                    
                    
// fill right
                    gc.setForeground(mSmallFillTopTop_SelectedHover);
                    gc.setBackground(mSmallFillTopBottom_SelectedHover);
                    gc.fillGradientRectangle(button.getRightBounds().x, by
+2, button.getRightBounds().width, 9true);
                    gc.setForeground(mSmallFillBottomTop_SelectedHover);
                    gc.setBackground(mSmallFillBottomBottom_SelectedHover);
                    gc.fillGradientRectangle(button.getRightBounds().x, by
+2+9, button.getRightBounds().width, 9true);     
                }                
                
                
// draw hover first
                
// inner borders
                gc.setForeground(mBorderInnerSideTopTop_Hover);
                gc.setBackground(mBorderInnerSideTopBottom_Hover);
                gc.fillGradientRectangle(bx
+1, by+219true);
                gc.fillGradientRectangle(bx
+bw-2, by+219true);
                gc.setForeground(mBorderSmallSideBottomTop_Hover);
                gc.setBackground(mBorderSmallSideBottomBottom_Hover);
                gc.fillGradientRectangle(bx
+1, by+2+919true);
                gc.fillGradientRectangle(bx
+bw-2, by+2+919true);
                
// bottom border
                gc.setForeground(mBorderSmallSideBottomBottom_Hover);
                gc.drawLine(bx
+1, by+2+9+9, bx+bw-2, by+2+9+9);
                
                gc.setForeground(mBorderSmallInsidePixelTop_Hover);
                gc.drawLine(bx
+1, by+1, bx+1, by+1);
                gc.drawLine(bx
+bw-2, by+1, bx+bw-2, by+1);
                gc.setForeground(mBorderSmallInsidePixelBottom_Hover);
                gc.drawLine(bx
+1, by+1+9+9+1, bx+1, by+1+9+9+1);
                gc.drawLine(bx
+bw-2, by+1+9+9+1, bx+bw-2, by+1+9+9+1);
                
// --- end
                
                
// draw selected border second
                
// third to top line as below inner borders will overdraw on sides 
                gc.setForeground(mSmallTopInnerTwo_SelectedHover);
                gc.drawLine(xx, by
+2, xw, by+2);            

                
// inner borders
                gc.setForeground(mBorderSmallSideTopTop_SelectedHover);
                gc.setBackground(mBorderSmallSideTopBottom_SelectedHover);
                gc.fillGradientRectangle(xx, by
+219true);
                gc.fillGradientRectangle(xw, by
+219true);
                gc.setForeground(mBorderSmallSideBottomTop_SelectedHover);
                gc.setBackground(mBorderSmallSideBottomBottom_SelectedHover);
                gc.fillGradientRectangle(xx, by
+2+919true);
                gc.fillGradientRectangle(xw, by
+2+919true);
                
// bottom border
                gc.setForeground(mBorderSmallSideBottomBottom_SelectedHover);
                gc.drawLine(xx, by
+2+9+9, xw, by+2+9+9);
                
// inner bottom
                gc.setForeground(mBottomSmallInnerSide_SelectedHover);
                gc.setBackground(mBottomSmallInnerMid_SelectedHover);
                gc.fillGradientRectangle(xx, by
+20, half, 1false);
                
// add -1 and start on the right so that if the half value is 1px off, it's ok as middle is highlight anyway
                gc.fillGradientRectangle(xw+1, by+20-half-11false);
                
                gc.setForeground(mBorderSmallInsidePixelTop_SelectedHover);
                gc.drawLine(xx, by
+1, xx, by+1);
                gc.drawLine(xw, by
+1, xw, by+1);
                gc.setForeground(mBorderSmallInsidePixelTopTwo_SelectedHover);
                gc.drawLine(xx, by
+2, xx, by+2);
                gc.drawLine(xw, by
+2, xw, by+2);
                gc.setForeground(mBorderSmallInsidePixelBottom_SelectedHover);
                gc.drawLine(xx, by
+1+9+9+1, xx, by+1+9+9+1);
                gc.drawLine(xw, by
+1+9+9+1, xw, by+1+9+9+1);
                
// --- end                            
            }
        }
            
        Image toUse 
= button.getImage(); 
        
if (!button.isEnabled())
            toUse 
= button.getDisabledImage() == null ? toUse : button.getDisabledImage();

        
// draw image
        if (toUse != null
            gc.drawImage(toUse, curX 
+ 3, curImgY);
        
        
//if ((button.getStyle() & RibbonButton.STYLE_ARROW_DOWN) != 0)
        drawArrow(gc, curX + bw-9, curImgY+6, button.isEnabled());

        
// draw text
        if (button.getName() != null) {
            
if (!button.isEnabled()) {
                gc.setForeground(mTextFadedRight_Disabled);
                gc.drawText(button.getName(), curX
+5+maxImgWidth+3, curImgY, true);                            
                gc.setForeground(mTextFadedLeft_Disabled);
                gc.drawText(button.getName(), curX
+3+maxImgWidth+3, curImgY, true);                            
                gc.setForeground(mTextColor_Disabled);
                gc.drawText(button.getName(), curX
+4+maxImgWidth+3, curImgY, true);                            
            }
            
else {
                gc.setForeground(mButtonTextColor);
                gc.drawText(button.getName(), curX
+4+maxImgWidth+3, curImgY, true);                            
            }
        }
    }
    
    
private void drawSmallButton(GC gc, AbstractRibbonGroupItem button, int maxImgWidth) {
        
int x = button.getX();
        
int y = button.getBounds().y;
        
int yMax = RibbonTabComposite.GROUP_HEIGHT;
        yMax 
-= 3;
        yMax 
-= RibbonGroup.BUTTON_BOT_HEIGHT;
        
int imgTopSpacer = 5;

        Rectangle bounds 
= button.getBounds();                    
        
int bx = bounds.x;
        
int by = bounds.y;
        
int bw = bounds.width;
                                    
        
int curY = y;
        
int curImgY = curY + imgTopSpacer - 2;
        
int curX = x;
        
        
// TODO: Setbounds on buttons seems off, and half is obviously 1 px off too, half is fine, but pick end pixel differently
        if (button.isEnabled()) {
            
if (!button.isSelected() && button.isHoverButton()) {
                gc.setForeground(mBorderTop_Hover);
                gc.drawLine(bx
+1, by, bx+bw-2, by);
                gc.setForeground(mBorderInnerTop_Hover);
                gc.drawLine(bx
+1, by+1, bx+bw-2, by+1);            
                
                gc.setForeground(mSideTopTopSmall_Hover);
                gc.setBackground(mSideTopBottomSmall_Hover);
                gc.fillGradientRectangle(bx, by
+1110true); // left
                gc.fillGradientRectangle(bx+bw-1, by+1110true); // right
                gc.setForeground(mSideBottomTopSmall_Hover);
                gc.setBackground(mSideBottomBottomSmall_Hover);
                gc.fillGradientRectangle(bx, by
+1+10110true); // left
                gc.fillGradientRectangle(bx+bw-1, by+1+10110true); // right
                
                gc.setForeground(mSideBottomBottomSmall_Hover);
                gc.setBackground(mBottomSmallMid_Hover);
                
int half = (bw-2)/2;
                gc.fillGradientRectangle(bx
+1, by+21, half, 1false);
                
// add -1 and start on the right so that if the half value is 1px off, it's ok as middle is highlight anyway
                gc.fillGradientRectangle(bx+bw-1, by+21-half-11false);
                
                
// fill
                gc.setForeground(mInnerTop_Hover);
                gc.setBackground(mInnerTopBottom_Hover);
                gc.fillGradientRectangle(bx
+2, by+2, bw-49true);
                gc.setForeground(mInnerBottomTop_Hover);
                gc.setBackground(mInnerBottomBottom_Hover);
                gc.fillGradientRectangle(bx
+2, by+2+9, bw-49true);

                
// inner borders
                gc.setForeground(mBorderInnerSideTopTop_Hover);
                gc.setBackground(mBorderInnerSideTopBottom_Hover);
                gc.fillGradientRectangle(bx
+1, by+219true);
                gc.fillGradientRectangle(bx
+bw-2, by+219true);
                gc.setForeground(mBorderSmallSideBottomTop_Hover);
                gc.setBackground(mBorderSmallSideBottomBottom_Hover);
                gc.fillGradientRectangle(bx
+1, by+2+919true);
                gc.fillGradientRectangle(bx
+bw-2, by+2+919true);
                
// bottom border
                gc.setForeground(mBorderSmallSideBottomBottom_Hover);
                gc.drawLine(bx
+1, by+2+9+9, bx+bw-2, by+2+9+9);
                
                gc.setForeground(mBorderSmallInsidePixelTop_Hover);
                gc.drawLine(bx
+1, by+1, bx+1, by+1);
                gc.drawLine(bx
+bw-2, by+1, bx+bw-2, by+1);
                gc.setForeground(mBorderSmallInsidePixelBottom_Hover);
                gc.drawLine(bx
+1, by+1+9+9+1, bx+1, by+1+9+9+1);
                gc.drawLine(bx
+bw-2, by+1+9+9+1, bx+bw-2, by+1+9+9+1);
                
            }
            
else if (!button.isHoverButton() && button.isSelected()) {
                gc.setForeground(mSmallTop_Selected);
                gc.drawLine(bx
+1, by, bx+bw-2, by);
                gc.setForeground(mSmallTopInner_Selected);
                gc.drawLine(bx
+1, by+1, bx+bw-2, by+1);            
                
                gc.setForeground(mSmallLeftSide_Selected);
                gc.drawLine(bx, by
+1, bx, by+1+19);
                gc.setForeground(mSmallRightSide_Selected);
                gc.drawLine(bx
+bw-1, by+1, bx+bw-1, by+1+19);

                gc.setForeground(mSideBottomBottomSmall_Selected);
                gc.setBackground(mBottomSmallMid_Selected);
                
int half = (bw-2)/2;
                gc.fillGradientRectangle(bx
+1, by+21, half, 1false);
                
// add -1 and start on the right so that if the half value is 1px off, it's ok as middle is highlight anyway
                gc.fillGradientRectangle(bx+bw-1, by+21-half-11false);
                
                
// fill
                gc.setForeground(mSmallFillTopTop_Selected);
                gc.setBackground(mSmallFillTopBottom_Selected);
                gc.fillGradientRectangle(bx
+2, by+2, bw-49true);
                gc.setForeground(mSmallFillBottomTop_Selected);
                gc.setBackground(mSmallFillBottomBottom_Selected);
                gc.fillGradientRectangle(bx
+2, by+2+9, bw-49true);

                
// third to top line as below inner borders will overdraw on sides 
                gc.setForeground(mSmallTopInnerTwo_Selected);
                gc.drawLine(bx
+1, by+2, bx+bw-2, by+2);            

                
// inner borders
                gc.setForeground(mBorderSmallSideTopTop_Selected);
                gc.setBackground(mBorderSmallSideTopBottom_Selected);
                gc.fillGradientRectangle(bx
+1, by+219true);
                gc.fillGradientRectangle(bx
+bw-2, by+219true);
                gc.setForeground(mBorderSmallSideBottomTop_Selected);
                gc.setBackground(mBorderSmallSideBottomBottom_Selected);
                gc.fillGradientRectangle(bx
+1, by+2+919true);
                gc.fillGradientRectangle(bx
+bw-2, by+2+919true);
                
// bottom border
                gc.setForeground(mBorderSmallSideBottomBottom_Selected);
                gc.drawLine(bx
+1, by+2+9+9, bx+bw-2, by+2+9+9);
                
                gc.setForeground(mBorderSmallInsidePixelTop_Selected);
                gc.drawLine(bx
+1, by+1, bx+1, by+1);
                gc.drawLine(bx
+bw-2, by+1, bx+bw-2, by+1);
                gc.setForeground(mBorderSmallInsidePixelBottom_Selected);
                gc.drawLine(bx
+1, by+1+9+9+1, bx+1, by+1+9+9+1);
                gc.drawLine(bx
+bw-2, by+1+9+9+1, bx+bw-2, by+1+9+9+1);
                

            }
            
else if (button.isHoverButton() && button.isSelected()) {
                gc.setForeground(mSmallTop_SelectedHover);
                gc.drawLine(bx
+1, by, bx+bw-2, by);
                gc.setForeground(mSmallTopInner_SelectedHover);
                gc.drawLine(bx
+1, by+1, bx+bw-2, by+1);            
                
                gc.setForeground(mSmallLeftSide_SelectedHover);
                gc.drawLine(bx, by
+1, bx, by+1+19);
                gc.setForeground(mSmallRightSide_SelectedHover);
                gc.drawLine(bx
+bw-1, by+1, bx+bw-1, by+1+19);

                gc.setForeground(mSideBottomBottomSmall_SelectedHover);
                gc.setBackground(mBottomSmallMid_SelectedHover);
                
int half = (bw-2)/2;
                gc.fillGradientRectangle(bx
+1, by+21, half, 1false);
                
// add -1 and start on the right so that if the half value is 1px off, it's ok as middle is highlight anyway
                gc.fillGradientRectangle(bx+bw-1, by+21-half-11false);
                
                
// fill
                gc.setForeground(mSmallFillTopTop_SelectedHover);
                gc.setBackground(mSmallFillTopBottom_SelectedHover);
                gc.fillGradientRectangle(bx
+2, by+2, bw-49true);
                gc.setForeground(mSmallFillBottomTop_SelectedHover);
                gc.setBackground(mSmallFillBottomBottom_SelectedHover);
                gc.fillGradientRectangle(bx
+2, by+2+9, bw-49true);

                
// third to top line as below inner borders will overdraw on sides 
                gc.setForeground(mSmallTopInnerTwo_SelectedHover);
                gc.drawLine(bx
+1, by+2, bx+bw-2, by+2);            

                
// inner borders
                gc.setForeground(mBorderSmallSideTopTop_SelectedHover);
                gc.setBackground(mBorderSmallSideTopBottom_SelectedHover);
                gc.fillGradientRectangle(bx
+1, by+219true);
                gc.fillGradientRectangle(bx
+bw-2, by+219true);
                gc.setForeground(mBorderSmallSideBottomTop_SelectedHover);
                gc.setBackground(mBorderSmallSideBottomBottom_SelectedHover);
                gc.fillGradientRectangle(bx
+1, by+2+919true);
                gc.fillGradientRectangle(bx
+bw-2, by+2+919true);
                
// bottom border
                gc.setForeground(mBorderSmallSideBottomBottom_SelectedHover);
                gc.drawLine(bx
+1, by+2+9+9, bx+bw-2, by+2+9+9);
                
// inner bottom
                gc.setForeground(mBottomSmallInnerSide_SelectedHover);
                gc.setBackground(mBottomSmallInnerMid_SelectedHover);
                gc.fillGradientRectangle(bx
+1, by+20, half, 1false);
                
// add -1 and start on the right so that if the half value is 1px off, it's ok as middle is highlight anyway
                gc.fillGradientRectangle(bx+bw-1, by+20-half-11false);
                
                gc.setForeground(mBorderSmallInsidePixelTop_SelectedHover);
                gc.drawLine(bx
+1, by+1, bx+1, by+1);
                gc.drawLine(bx
+bw-2, by+1, bx+bw-2, by+1);
                gc.setForeground(mBorderSmallInsidePixelTopTwo_SelectedHover);
                gc.drawLine(bx
+1, by+2, bx+1, by+2);
                gc.drawLine(bx
+bw-2, by+2, bx+bw-2, by+2);
                gc.setForeground(mBorderSmallInsidePixelBottom_SelectedHover);
                gc.drawLine(bx
+1, by+1+9+9+1, bx+1, by+1+9+9+1);
                gc.drawLine(bx
+bw-2, by+1+9+9+1, bx+bw-2, by+1+9+9+1);
            }
        }
            
        Image toUse 
= button.getImage(); 
        
if (!button.isEnabled())
            toUse 
= button.getDisabledImage() == null ? toUse : button.getDisabledImage();

        
// draw image
        if (toUse != null
            gc.drawImage(toUse, curX 
+ 3, curImgY);
        
        
if ((button.getStyle() & RibbonButton.STYLE_ARROW_DOWN) != 0)
            drawArrow(gc, curX 
+ bw-9, curImgY+5, button.isEnabled());

        
// draw text
        if (button.getName() != null) {
            
if (!button.isEnabled()) {
                gc.setForeground(mTextFadedRight_Disabled);
                gc.drawText(button.getName(), curX
+5+maxImgWidth+3, curImgY, true);                            
                gc.setForeground(mTextFadedLeft_Disabled);
                gc.drawText(button.getName(), curX
+3+maxImgWidth+3, curImgY, true);                            
                gc.setForeground(mTextColor_Disabled);
                gc.drawText(button.getName(), curX
+4+maxImgWidth+3, curImgY, true);                            
            }
            
else {
                gc.setForeground(mButtonTextColor);
                gc.drawText(button.getName(), curX
+4+maxImgWidth+3, curImgY, true);                            
            }
        }
    }
    
    
public void drawSplitButton(GC gc, AbstractRibbonGroupItem item) {
        
int x = item.getX();
        
int y = item.getBounds().y;
        
int width = item.getWidth();
        
int yMax = RibbonTabComposite.GROUP_HEIGHT;
        yMax 
-= 3;
        yMax 
-= RibbonGroup.BUTTON_BOT_HEIGHT;
        
int imgTopSpacer = 5;

        
if (item.isEnabled()) {
            
if (item.isHoverButton() && !item.isSelected()) {
                
// top two lines
                gc.setForeground(mBorderTop_Hover);
                gc.drawLine(x
+1, y, x+width-2, y);
                gc.setForeground(mBorderInnerTop_Hover);
                gc.drawLine(x
+1, y+1, x+width-2, y+1);            
    
                
// pixels in corners
                gc.setForeground(mCornerFadeTopPixel_Hover);
                gc.drawLine(x
+1, y+1, x+1, y+1);
                gc.drawLine(x
+width-2, y+1, x+width-2, y+1);
                
                
// sides are 3 steps we split them a bit more due to more gradients
                
// note that outer borders stretch 1px higher and lower in the top and bottom sections, but mid stays the same            
    
                
// outer sides 
                gc.setForeground(mBorderSideTopTop_Hover);
                gc.setBackground(mBorderSideTopBottom_Hover);
                gc.fillGradientRectangle(x, y
+1124true);
                gc.fillGradientRectangle(x
+width-1, y+1124true);
                
// inner sides 
                gc.setForeground(mBorderInnerSideTopTop_Hover);
                gc.setBackground(mBorderInnerSideTopBottom_Hover);
                gc.fillGradientRectangle(x
+1, y+2123true);
                gc.fillGradientRectangle(x
+width-2, y+2123true);
                
// outer mid
                gc.setForeground(mBorderSideMidTop_Hover);
                gc.setBackground(mBorderSideMidBottom_Hover);
                gc.fillGradientRectangle(x, y
+2+23127true);
                gc.fillGradientRectangle(x
+width-1, y+2+23127true);
                
// inner mid
                gc.setForeground(mBorderInnerSideMidTop_Hover);
                gc.setBackground(mBorderInnerSideMidBottom_Hover);
                gc.fillGradientRectangle(x
+1, y+2+22128true);
                gc.fillGradientRectangle(x
+width-2, y+2+22128true);
                
// outer bottom 
                gc.setForeground(mBorderInnerSideBottomTop_Hover);
                gc.setBackground(mBorderInnerSideBottomBottom_Hover);
                gc.fillGradientRectangle(x
+1, y+2+23+27112true);
                gc.fillGradientRectangle(x
+width-2, y+2+23+27112true);            
                
// inner bottom 
                gc.setForeground(mBorderSideBottomTop_Hover);
                gc.setBackground(mBorderSideBottomBottom_Hover);
                gc.fillGradientRectangle(x, y
+2+23+27113true);
                gc.fillGradientRectangle(x
+width-1, y+2+23+27113true);            
                
// pixel is just below so we do that now too
                gc.setForeground(mCornerFadeBottomPixel_Hover);
                gc.drawLine(x
+1, y+2+23+27+12, x+1, y+2+23+27+12);
                gc.drawLine(x
+width-2, y+2+23+27+12, x+width-2, y+2+23+27+12);
                
                
// draw bottom
                gc.setForeground(mBorderBottom_Hover);
                gc.drawLine(x
+1, y+2+23+27+12+1, x+width-2, y+2+23+27+12+1);
                
// inner, left half
                gc.setForeground(mBorderInnerBottomCorner_Hover);
                gc.setBackground(mBorderInnerBottomMidway_Hover);
                gc.fillGradientRectangle(x
+2, y+2+23+27+12, width/21false);
                
// inner, right half
                gc.setForeground(mBorderInnerBottomMidway_Hover);
                gc.setBackground(mBorderInnerBottomCorner_Hover);
                gc.fillGradientRectangle(x
+2+(width/2), y+2+23+27+12, (width/2)-31false);
                
                
// fills
                if (item.isTopHovered()) {
                    gc.setForeground(mInnerTopPartTopTopSplit_Hover);
                    gc.setBackground(mInnerTopPartTopBottomSplit_Hover);
                }
                
else {
                    gc.setForeground(mInnerTopPartTopTopSplit);
                    gc.setBackground(mInnerTopPartTopBottomSplit);                    
                }
                
                gc.fillGradientRectangle(x
+2, y+2, width-422true);
                    
                
if (item.isTopHovered()) {
                    gc.setForeground(mInnerTopPartTopBottomTopSplit_Hover);
                    gc.setBackground(mInnerTopPartTopBottomBottomSplit_Hover);
                }
                
else {
                    gc.setForeground(mInnerTopPartTopBottomTopSplit);
                    gc.setBackground(mInnerTopPartTopBottomBottomSplit);
                }
                gc.fillGradientRectangle(x
+2, y+2+22, width-412true);                    
                
                gc.setForeground(mInnerSplitDividerLeft);
                gc.setBackground(mInnerSplitDividerMid);
                gc.fillGradientRectangle(x
+1, y+2+22+12, (width/2)-21false);
                gc.setForeground(mInnerSplitDividerMid);
                gc.setBackground(mInnerSplitDividerLeft);
                gc.fillGradientRectangle(x
+1+(width/2)-2, y+2+22+12, (width/2)+11false);
                                           
                
if (item.isBottomHovered()) {
                    gc.setForeground(mInnerBottomPartTopSplit_Hover);
                    gc.setBackground(mInnerBottomPartBottomSplit_Hover);                    
                }
                
else {
                    gc.setForeground(mInnerBottomPartTopSplit);
                    gc.setBackground(mInnerBottomPartBottomSplit);                    
                }
                
                gc.fillGradientRectangle(x
+2, y+2+22+12+1, width-427true);
            }
            
else if (item.isSelected())
            {
                
if (item.isTopSelected()) {
                    
// top two lines
                    gc.setForeground(mBorderTop_SelectedHover);
                    gc.drawLine(x
+1, y, x+width-2, y);
        
                    
// pixels in corners
                    gc.setForeground(mCornerFadeTopPixel_SelectedHover);
                    gc.drawLine(x
+1, y+1, x+1, y+1);
                    gc.drawLine(x
+width-2, y+1, x+width-2, y+1);
                    
                    
// outer sides
                    
// --------------------
                    
// TODO: This is a repeat of code, we draw the unselected button first, then overdraw, needs some cleaner way
                    
// --------------------
                    gc.setForeground(mBorderSideTopTop_Hover);
                    gc.setBackground(mBorderSideTopBottom_Hover);
                    gc.fillGradientRectangle(x, y
+1124true);
                    gc.fillGradientRectangle(x
+width-1, y+1124true);
                    
// inner sides 
                    gc.setForeground(mBorderInnerSideTopTop_Hover);
                    gc.setBackground(mBorderInnerSideTopBottom_Hover);
                    gc.fillGradientRectangle(x
+1, y+2123true);
                    gc.fillGradientRectangle(x
+width-2, y+2123true);
                    
// outer mid
                    gc.setForeground(mBorderSideMidTop_Hover);
                    gc.setBackground(mBorderSideMidBottom_Hover);
                    gc.fillGradientRectangle(x, y
+2+23127true);
                    gc.fillGradientRectangle(x
+width-1, y+2+23127true);
                    
// inner mid
                    gc.setForeground(mBorderInnerSideMidTop_Hover);
                    gc.setBackground(mBorderInnerSideMidBottom_Hover);
                    gc.fillGradientRectangle(x
+1, y+2+22128true);
                    gc.fillGradientRectangle(x
+width-2, y+2+22128true);
                    
// outer bottom 
                    gc.setForeground(mBorderInnerSideBottomTop_Hover);
                    gc.setBackground(mBorderInnerSideBottomBottom_Hover);
                    gc.fillGradientRectangle(x
+1, y+2+23+27112true);
                    gc.fillGradientRectangle(x
+width-2, y+2+23+27112true);            
                    
// inner bottom 
                    gc.setForeground(mBorderSideBottomTop_Hover);
                    gc.setBackground(mBorderSideBottomBottom_Hover);
                    gc.fillGradientRectangle(x, y
+2+23+27113true);
                    gc.fillGradientRectangle(x
+width-1, y+2+23+27113true);            
                    
// pixel is just below so we do that now too
                    gc.setForeground(mCornerFadeBottomPixel_Hover);
                    gc.drawLine(x
+1, y+2+23+27+12, x+1, y+2+23+27+12);
                    gc.drawLine(x
+width-2, y+2+23+27+12, x+width-2, y+2+23+27+12);
                    
                    
// draw bottom
                    gc.setForeground(mBorderBottom_Hover);
                    gc.drawLine(x
+1, y+2+23+27+12+1, x+width-2, y+2+23+27+12+1);
                    
// inner, left half
                    gc.setForeground(mBorderInnerBottomCorner_Hover);
                    gc.setBackground(mBorderInnerBottomMidway_Hover);
                    gc.fillGradientRectangle(x
+2, y+2+23+27+12, width/21false);
                    
// inner, right half
                    gc.setForeground(mBorderInnerBottomMidway_Hover);
                    gc.setBackground(mBorderInnerBottomCorner_Hover);
                    gc.fillGradientRectangle(x
+2+(width/2), y+2+23+27+12, (width/2)-31false);
                    
// -------------------- END ----------------------
                    
                    
// let's draw the outer box, start with top, sides, then bottom            
                    
// top
                    gc.setForeground(mBorderTop_SelectedHover);
                    gc.drawLine(x
+1, TOP_SPACING, x+width-2, TOP_SPACING);
                    gc.setForeground(mBorderTopInner_SelectedHover);
                    gc.drawLine(x
+2, TOP_SPACING+1, x+width-3, TOP_SPACING+1);
                    gc.setForeground(mBorderTopInnerTwo_SelectedHover);
                    gc.drawLine(x
+2, TOP_SPACING+2, x+width-3, TOP_SPACING+2);
                    gc.setForeground(mBorderTopInnerThree_SelectedHover);
                    gc.drawLine(x
+2, TOP_SPACING+3, x+width-3, TOP_SPACING+3);
                    
                    
// outer sides 
                    gc.setForeground(mBorderSideTopTop_SelectedHover);
                    gc.setBackground(mBorderSideTopBottom_SelectedHover);
                    gc.fillGradientRectangle(x, y
+1124true);
                    gc.fillGradientRectangle(x
+width-1, y+1124true);
                    
// inner sides 
                    gc.setForeground(mBorderInnerSideTopTop_SelectedHover);
                    gc.setBackground(mBorderInnerSideTopBottom_SelectedHover);
                    gc.fillGradientRectangle(x
+1, y+2123true);
                    gc.fillGradientRectangle(x
+width-2, y+2123true);
                    
// outer mid
                    gc.setForeground(mBorderSideMidTop_SelectedHover);
                    gc.setBackground(mBorderSideMidBottom_SelectedHover);
                    gc.fillGradientRectangle(x, y
+2+23112true);
                    gc.fillGradientRectangle(x
+width-1, y+2+23112true);
                    
// inner mid
                    gc.setForeground(mBorderInnerSideMidTop_SelectedHover);
                    gc.setBackground(mBorderInnerSideMidBottom_SelectedHover);
                    gc.fillGradientRectangle(x
+1, y+2+23112true);
                    gc.fillGradientRectangle(x
+width-2, y+2+23112true);
                                
                    
// draw pixel at top
                    gc.setForeground(mCornerFadeTopPixel_SelectedHover);
                    gc.drawLine(x
+1, TOP_SPACING+1, x+1, TOP_SPACING+1);
                    gc.drawLine(x
+width-2, TOP_SPACING+1, x+width-2, TOP_SPACING+1);
                    
// draw bottom pixel
                    gc.setForeground(mCornerFadeBottomPixel_SelectedHover);
                    gc.drawLine(x, y
+2+23+27+12, x, y+2+23+27+12);
                    gc.drawLine(x
+width-1, y+2+23+27+12, x+width-1, y+2+23+27+12);
                    
                    
// fill
                    gc.setForeground(mInnerTop_SelectedHover);
                    gc.setBackground(mInnerTopBottom_SelectedHover);
                    gc.fillGradientRectangle(x
+2, y+4, width-422true);
                    
                    gc.setForeground(mInnerMidTop_SelectedHover);
                    gc.setBackground(mInnerMidBottom_SelectedHover);
                    gc.fillGradientRectangle(x
+2, y+4+22, width-412true);
                    
                    
// bottom
                    gc.setForeground(mInnerBottomPartTopSplit);
                    gc.setBackground(mInnerBottomPartBottomSplit);                                
                    gc.fillGradientRectangle(x
+2, y+2+22+12+1, width-427true);
                }
                
else if (item.isBottomSelected()) {
                     gc.setForeground(mBorderTop_Hover);
                    gc.drawLine(x
+1, y, x+width-2, y);
                    gc.setForeground(mBorderInnerTop_Hover);
                    gc.drawLine(x
+1, y+1, x+width-2, y+1);            

                    
// pixels in corners
                    gc.setForeground(mCornerFadeTopPixel_SelectedHover);
                    gc.drawLine(x
+1, y+1, x+1, y+1);
                    gc.drawLine(x
+width-2, y+1, x+width-2, y+1);

                    
// outer sides
                    
// --------------------
                    
// TODO: This is a repeat of code, we draw the unselected button first, then overdraw, needs some cleaner way
                    
// --------------------
                    gc.setForeground(mBorderSideTopTop_Hover);
                    gc.setBackground(mBorderSideTopBottom_Hover);
                    gc.fillGradientRectangle(x, y
+1124true);
                    gc.fillGradientRectangle(x
+width-1, y+1124true);
                    
// inner sides 
                    gc.setForeground(mBorderInnerSideTopTop_Hover);
                    gc.setBackground(mBorderInnerSideTopBottom_Hover);
                    gc.fillGradientRectangle(x
+1, y+2123true);
                    gc.fillGradientRectangle(x
+width-2, y+2123true);
                    
// outer mid
                    gc.setForeground(mBorderSideMidTop_Hover);
                    gc.setBackground(mBorderSideMidBottom_Hover);
                    gc.fillGradientRectangle(x, y
+2+23127true);
                    gc.fillGradientRectangle(x
+width-1, y+2+23127true);
                    
// inner mid
                    gc.setForeground(mBorderInnerSideMidTop_Hover);
                    gc.setBackground(mBorderInnerSideMidBottom_Hover);
                    gc.fillGradientRectangle(x
+1, y+2+22128true);
                    gc.fillGradientRectangle(x
+width-2, y+2+22128true);
                    
// outer bottom 
                    gc.setForeground(mBorderInnerSideBottomTop_Hover);
                    gc.setBackground(mBorderInnerSideBottomBottom_Hover);
                    gc.fillGradientRectangle(x
+1, y+2+23+27112true);
                    gc.fillGradientRectangle(x
+width-2, y+2+23+27112true);            
                    
// inner bottom 
                    gc.setForeground(mBorderSideBottomTop_Hover);
                    gc.setBackground(mBorderSideBottomBottom_Hover);
                    gc.fillGradientRectangle(x, y
+2+23+27113true);
                    gc.fillGradientRectangle(x
+width-1, y+2+23+27113true);            
                    
// pixel is just below so we do that now too
                    gc.setForeground(mCornerFadeBottomPixel_Hover);
                    gc.drawLine(x
+1, y+2+23+27+12, x+1, y+2+23+27+12);
                    gc.drawLine(x
+width-2, y+2+23+27+12, x+width-2, y+2+23+27+12);
                    
                    
// draw bottom
                    gc.setForeground(mBorderBottom_Hover);
                    gc.drawLine(x
+1, y+2+23+27+12+1, x+width-2, y+2+23+27+12+1);
                    
// inner, left half
                    gc.setForeground(mBorderInnerBottomCorner_Hover);
                    gc.setBackground(mBorderInnerBottomMidway_Hover);
                    gc.fillGradientRectangle(x
+2, y+2+23+27+12, width/21false);
                    
// inner, right half
                    gc.setForeground(mBorderInnerBottomMidway_Hover);
                    gc.setBackground(mBorderInnerBottomCorner_Hover);
                    gc.fillGradientRectangle(x
+2+(width/2), y+2+23+27+12, (width/2)-31false);
                    
// -------------------- END ----------------------
                    
                    
// fills
                    gc.setForeground(mInnerTopPartTopTopSplit);
                    gc.setBackground(mInnerTopPartTopBottomSplit);                    
                    gc.fillGradientRectangle(x
+2, y+2, width-422true);
                    gc.setForeground(mInnerTopPartTopBottomTopSplit);
                    gc.setBackground(mInnerTopPartTopBottomBottomSplit);
                    gc.fillGradientRectangle(x
+2, y+2+22, width-412true);                    
                                                                   
                    gc.setForeground(mInnerBottomPartTopSplit_Selected);
                    gc.setBackground(mInnerBottomPartBottomSplit_Selected);                                        
                    gc.fillGradientRectangle(x
+2, y+2+22+12+1, width-427true);
                }
                                
                gc.setForeground(mInnerSplitDividerLeft);
                gc.setBackground(mInnerSplitDividerMid);
                gc.fillGradientRectangle(x
+1, y+2+22+12, (width/2)-21false);
                gc.setForeground(mInnerSplitDividerMid);
                gc.setBackground(mInnerSplitDividerLeft);
                gc.fillGradientRectangle(x
+1+(width/2)-2, y+2+22+12, (width/2)+11false);                                
            }
        }
        
        
// TODO: Account for multi-row text
        if ((item.getStyle() & RibbonButton.STYLE_ARROW_DOWN) != 0)
            drawArrow(gc, item.getBounds().width
/256, item.isEnabled());
        
        Image toDraw 
= item.getImage();
        
// fallback is normal image
        if (!item.isEnabled())
            toDraw 
= item.getDisabledImage() == null ? toDraw : item.getDisabledImage();
        
        
// draw image
        if (toDraw != null) {
            Rectangle imBounds 
= toDraw.getBounds();
            
int maxHeight = 32;
            
int horizAlignment = x+(width/2)-(imBounds.width/2);
            
switch (item.getImageVerticalAlignment()) {
                
default:
                
case SWT.TOP:
                {
                    gc.drawImage(toDraw, horizAlignment, imgTopSpacer);
                    
break;
                }
                
case SWT.BOTTOM:
                {
                    
int botSpacer = imBounds.height-maxHeight; 
                    
if (botSpacer < 0)
                        botSpacer 
= 0;
                    
                    botSpacer 
+= imgTopSpacer;
                    botSpacer 
*= 2;
                                        
                    gc.drawImage(toDraw, horizAlignment, botSpacer);
                    
break;
                }
                
case SWT.CENTER:
                {
                    
int botSpacer = Math.abs(imBounds.height-maxHeight); 
                    
if (botSpacer < 0)
                        botSpacer 
= 0;
                    
                    
if (botSpacer != 0)
                        botSpacer 
/= 2;

                    botSpacer 
+= imgTopSpacer;
                                        
                    gc.drawImage(toDraw, horizAlignment, botSpacer);
                    
break;
                }
            }
        }
        
        
// draw text            
        if (item.getName() != null) {
            
if (item.isEnabled()) {
                gc.setForeground(mButtonTextColor);
                gc.drawText(item.getName(), x
+340true);
            }
            
else {
                gc.setForeground(mTextFadedRight_Disabled);
                gc.drawText(item.getName(), x
+440true);
                gc.setForeground(mTextFadedLeft_Disabled);
                gc.drawText(item.getName(), x
+240true);
                gc.setForeground(mTextColor_Disabled);
                gc.drawText(item.getName(), x
+340true);
            }
        }        
    }

    
public void drawSeparator(GC gc, int x, int y, int height) {
        gc.setForeground(mSeparatorColor);
        gc.drawLine(x, y, x, y
+height);
        gc.setForeground(mSeparatorColorShadow);
        gc.drawLine(x
+1, y, x+1, y+height);
    }
    
    
public void drawArrow(GC gc, int x, int y, boolean enabled) {
        
if (enabled)
            gc.setForeground(mArrowColor);
        
else
            gc.setForeground(mArrowColor_Disabled);
        
        gc.drawLine(x, y, x
+4, y);
        gc.drawLine(x
+1, y+1, x+3, y+1);
        gc.drawLine(x
+2, y+2, x+1, y+2);

        
if (enabled)
            gc.setForeground(mArrowColorShadow);
        
else
            gc.setForeground(mArrowColorShadow_Disabled);
        
        gc.drawLine(x, y
+1, x, y+1);
        gc.drawLine(x
+1, y+2, x+1, y+2);
        gc.drawLine(x
+2, y+3, x+2, y+3);
        gc.drawLine(x
+3, y+2, x+3, y+2);
        gc.drawLine(x
+4, y+1, x+4, y+1);
        
    }
    
}
 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章