2362N/A * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 0N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 0N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 2362N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 0N/A * or visit www.oracle.com if you need additional information or have any 0N/A * Provides the Synth L&F UI delegate for 0N/A * {@link javax.swing.JTabbedPane}. 0N/A * <p>Looks up the {@code selectedTabPadInsets} property from the Style, 0N/A * which represents additional insets for the selected tab. 0N/A * @author Scott Violet 0N/A * <p>If non-zero, tabOverlap indicates the amount that the tab bounds 0N/A * should be altered such that they would overlap with a tab on either the 0N/A * leading or trailing end of a run (ie: in TOP, this would be on the left 0N/A * <p>A positive overlap indicates that tabs should overlap right/down, 0N/A * while a negative overlap indicates tha tabs should overlap left/up.</p> 0N/A * <p>When tabOverlap is specified, it both changes the x position and width 0N/A * of the tab if in TOP or BOTTOM placement, and changes the y position and 0N/A * height if in LEFT or RIGHT placement.</p> 0N/A * <p>This is done for the following reason. Consider a run of 10 tabs. 0N/A * There are 9 gaps between these tabs. If you specified a tabOverlap of 0N/A * "-1", then each of the tabs "x" values will be shifted left. This leaves 0N/A * 9 pixels of space to the right of the right-most tab unpainted. So, each 0N/A * tab's width is also extended by 1 pixel to make up the difference.</p> 0N/A * <p>This property respects the RTL component orientation.</p> 0N/A * When a tabbed pane has multiple rows of tabs, this indicates whether 0N/A * the tabs in the upper row(s) should extend to the base of the tab area, 0N/A * or whether they should remain at their normal tab height. This does not 0N/A * affect the bounds of the tabs, only the bounds of area painted by the 0N/A * tabs. The text position does not change. The result is that the bottom 0N/A * border of the upper row of tabs becomes fully obscured by the lower tabs, 0N/A * resulting in a cleaner look. 0N/A //added for the Nimbus look and feel, where the tab area is painted differently depending on the 0N/A //state for the selected tab 0N/A //added for the Nimbus LAF to ensure that the labels don't move whether the tab is selected or not 0N/A * Creates a new UI object for the given component. 0N/A * @param c component to create UI object for 0N/A * @return the UI object 0N/A // Add properties other than JComponent colors, Borders and 0N/A // opacity settings here: 0N/A "TabbedPane.extendTabsToBase",
false);
0N/A "TabbedPane.selectedTabPadInsets");
0N/A "TabbedPane.tabAreaStatesMatchSelectedTab",
false);
0N/A "TabbedPane.nudgeSelectedLabel",
true);
// added for Nimbus LAF so that it can use the basic arrow buttons // UIManager is queried directly here because this is called before // updateStyle is called so the style can not be queried directly * Overridden to keep track of whether the selected tab is also pressed. // Clicking on selected tab //TODO need to just repaint the tab area! //forward the event (this will set the selected index, or none at all //TODO need to just repaint the tab area! //hack: The super method *should* be setting the mouse-over property correctly //here, but it doesn't. That is, when the mouse is released, whatever tab is below the //released mouse should be in rollover state. But, if you select a tab and don't //move the mouse, this doesn't happen. Hence, forwarding the event. * Notifies this UI delegate to repaint the specified component. * This method paints the component background, then calls * the {@link #paint(SynthContext,Graphics)} method. * <p>In general, this method does not need to be overridden by subclasses. * All Look and Feel rendering code should reside in the {@code paint} method. * @param g the {@code Graphics} object used for painting * @param c the component being painted * @see #paint(SynthContext,Graphics) * Paints the specified component according to the Look and Feel. * <p>This method is not used by Synth Look and Feel. * Painting is handled by the {@link #paint(SynthContext,Graphics)} method. * @param g the {@code Graphics} object used for painting * @param c the component being painted * @see #paint(SynthContext,Graphics) * Paints the specified component. * @param context context for the component being painted * @param g the {@code Graphics} object used for painting * @see #update(Graphics,JComponent) // If scrollable tabs are enabled, the tab area will be // painted by the scrollable tab panel instead. // This can be invoked from ScrollabeTabPanel //if the tab area's states should match that of the selected tab, then //first update the selected tab's states, then set the state //for the tab area to match //otherwise, restore the tab area's state to ENABLED (which is the //only supported state otherwise). // Paint tabRuns of tabs from back to front for (
int i =
runCount -
1; i >=
0; i--) {
//TODO need to just repaint the tab area! //paint this tab such that its edge closest to the base is equal to //edge of the selected tab closest to the base. In terms of the TOP //tab placement, this will cause the bottom of each tab to be //painted even with the bottom of the selected tab. This is because //in each tab placement (TOP, LEFT, BOTTOM, RIGHT) the selected tab //is closest to the base. /* If tabPane doesn't have a peer yet, the validate() call will * silently fail. We handle that by forcing a layout if tabPane * is still invalid. See bug 4237677. * Overridden to create a TabbedPaneLayout subclass which takes into }
else {
/* WRAP_TAB_LAYOUT */ //shift all the tabs, if necessary //when placement is TOP or BOTTOM for (
int i =
runCount -
1; i >=
0; i--) {
// xshift and yshift represent the amount & // direction to shift the tab in their // configure xshift and y shift based on tab