001: /*
002: * Copyright (c) 2005-2008 Flamingo / Substance Kirill Grouchnikov. All Rights Reserved.
003: *
004: * Redistribution and use in source and binary forms, with or without
005: * modification, are permitted provided that the following conditions are met:
006: *
007: * o Redistributions of source code must retain the above copyright notice,
008: * this list of conditions and the following disclaimer.
009: *
010: * o Redistributions in binary form must reproduce the above copyright notice,
011: * this list of conditions and the following disclaimer in the documentation
012: * and/or other materials provided with the distribution.
013: *
014: * o Neither the name of Flamingo Kirill Grouchnikov nor the names of
015: * its contributors may be used to endorse or promote products derived
016: * from this software without specific prior written permission.
017: *
018: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
019: * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
020: * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
021: * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
022: * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
023: * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
024: * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
025: * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
026: * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
027: * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
028: * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
029: */
030: package org.jvnet.substance.flamingo.ribbon.ui;
031:
032: import java.awt.*;
033:
034: import javax.swing.JComponent;
035: import javax.swing.plaf.ComponentUI;
036:
037: import org.jvnet.flamingo.ribbon.JRibbonBand;
038: import org.jvnet.flamingo.ribbon.ui.BasicBandControlPanelUI;
039: import org.jvnet.flamingo.ribbon.ui.BasicRibbonBandUI;
040: import org.jvnet.substance.SubstanceFillBackgroundDelegate;
041: import org.jvnet.substance.theme.SubstanceTheme;
042: import org.jvnet.substance.utils.SubstanceThemeUtilities;
043:
044: /**
045: * UI for control panel of ribbon gallery in <b>Substance</b> look and feel.
046: *
047: * @author Kirill Grouchnikov
048: */
049: public class SubstanceBandControlPanelUI extends
050: BasicBandControlPanelUI {
051: /**
052: * Background delegate.
053: */
054: private SubstanceFillBackgroundDelegate bgDelegate;
055:
056: /*
057: * (non-Javadoc)
058: *
059: * @see javax.swing.plaf.ComponentUI#createUI(javax.swing.JComponent)
060: */
061: public static ComponentUI createUI(JComponent c) {
062: return new SubstanceBandControlPanelUI();
063: }
064:
065: /**
066: * Creates new UI delegate.
067: */
068: private SubstanceBandControlPanelUI() {
069: this .bgDelegate = new SubstanceFillBackgroundDelegate();// 0.6f);
070: }
071:
072: /*
073: * (non-Javadoc)
074: *
075: * @see org.jvnet.flamingo.ribbon.ui.BasicBandControlPanelUI#paintBandBackground(java.awt.Graphics,
076: * java.awt.Rectangle)
077: */
078: @Override
079: protected void paintBandBackground(Graphics graphics,
080: Rectangle toFill) {
081: SubstanceTheme theme = SubstanceThemeUtilities
082: .getTheme(this .controlPanel);
083: Color fillColor = theme.getBackgroundColor();
084:
085: Component parent = this .controlPanel.getParent();
086: if (parent instanceof JRibbonBand) {
087: // not in popup
088: JRibbonBand band = (JRibbonBand) this .controlPanel
089: .getParent();
090: BasicRibbonBandUI ui = (BasicRibbonBandUI) band.getUI();
091: boolean isUnderMouse = ui.isUnderMouse();
092: if (isUnderMouse) {
093: fillColor = theme.getLightBackgroundColor();
094: }
095: }
096:
097: this.bgDelegate.fillAndWatermark(graphics, this.controlPanel,
098: fillColor, toFill);
099: }
100: }
|