TabbedFolder.java revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* ident "%Z%%M% %I% %E% SMI"
*
* Copyright (c) 2000 by Sun Microsystems, Inc.
* All rights reserved.
*/
/*
* Copyright (C) 1996 Active Software, Inc.
* All rights reserved.
*
* @(#) TabbedFolder.java 1.20 - last change made 08/04/97
*/
public class TabbedFolder extends CardPanel {
public static final int CONFIRM_SWITCH = 4862;
//
// Constants used for drawing the tabs
//
private static final int bd = 2;
private static final double BFACTOR = 0.8;
private static final double DFACTOR = 0.7;
private static final int tabipadx = 14;
private static final int tabipady = 14;
private static final int comppadx = 20;
private static final int comppady = 14;
//
// Cached tab information
//
private int tabx[];
private boolean cancelSwitch = false;
public TabbedFolder() {
}
}
}
protected Label newCardLabel() {
"sunsoft.jws.visual.rt.awt.TabbedFolder.NewCardLabel"));
}
//
// Methods that comprise the public interface for TabbedFolder
//
flushCache();
repaint();
}
flushCache();
repaint();
}
flushCache();
repaint();
}
flushCache();
repaint();
}
public void removeAllTabs() {
super.removeAllTabs();
flushCache();
repaint();
}
public String getCurrentFolder() {
return getCurrentCard();
}
repaint();
}
//
// Overridden methods from Component
//
public void addNotify() {
super.addNotify();
flushCache();
}
public void removeNotify() {
super.removeNotify();
flushCache();
}
flushCache();
}
public Dimension minimumSize() {
cacheTabInfo();
Dimension d = super.minimumSize();
if (w > d.width)
return d;
}
public Dimension preferredSize() {
cacheTabInfo();
Dimension d = super.preferredSize();
if (w > d.width)
return d;
}
cacheTabInfo();
return insets;
}
//
// Event Handling
//
int index = calcTabIndex(x, y);
cancelSwitch = false;
if (!cancelSwitch) {
} else {
cancelSwitch = false;
}
}
return false;
}
public void cancelSwitch() {
cancelSwitch = true;
}
private synchronized int calcTabIndex(int x, int y) {
cacheTabInfo();
return -1;
}
return -1;
}
return i;
}
}
return -1;
}
//
// Cache all the information and the image needed for the tabs.
//
private synchronized void cacheTabInfo() {
return;
if (len == 0) {
tabx = new int[2];
"sunsoft.jws.visual.rt.awt.TabbedFolder.Empty");
} else {
int i = 0;
int x = bd;
while (e.hasMoreElements()) {
tabx[i] = x;
i++;
}
tabx[i] = x;
}
// Need 4 extra pixels: 2 on each end
// Need 6 extra pixels: 4 on top, and 2 on the bottom
// Create the image buffer
}
}
private synchronized void flushCache() {
tabW = 0;
tabH = 0;
if (isValid())
invalidate();
}
//
// Drawing methods
//
g = getGraphics();
cacheTabInfo();
int x, y;
// Clear the background
g.setColor(getBackground());
draw(g);
}
g = getGraphics();
draw(g);
}
cacheTabInfo();
}
}
int selIndex = -1;
g.setColor(getBackground());
if (i != selIndex) {
drawTab(g, i, false);
}
}
if (i == selIndex) {
drawTab(g, i, true);
break;
}
}
// Draw the left extra bit
// Draw the right extra bit
folderInsets.right)) {
// The corner does not lie within the image.
// This can happen
// when the tabs do not completely fill
// the top of the folder.
} else {
}
}
private void drawUpperRightCorner(Graphics g, int x, int y) {
int selIndex = -1;
}
}
int y = bd;
if (selected) {
x -= bd;
y -= bd;
w += 2*bd;
h += 2*bd;
}
g.setColor(getBackground());
draw3DOuterTab(g, x, y, w, h, selected);
if (selected)
y -= bd;
g.setColor(getForeground());
}
int x = folderInsets.left;
return;
g.setColor(getBackground());
draw3DU(g, x, y, w, h, true);
// Draw the extra line on the top-right side if the tab image
// does not cover the area. The tab image is only as wide as
// the tabs, so we need to account for any possible extra space
// here.
folderInsets.right)) {
tabW),
bd);
}
}
y + height - 1);
g.setColor(c);
}
private void draw3DInnerTab(Graphics g,
boolean selected) {
if (!selected)
g.setColor(c);
}
private void draw3DOuterTab(Graphics g,
boolean selected) {
// Left, Top, Bottom, Right
if (!selected)
g.setColor(c);
}
/**
* Returns a brighter version of this color.
*/
// fix for bug where the brighter color doesn't show up
// against a white background The Util.brighter will return
// new Color(<some light grey>) for whites.
}
/**
* Returns a darker version of this color.
*/
}
// Workaround for Windows fillRect bug.
// The Windows fillRect sometimes
// fills the lower-right edges when it shouldn't.
// The bug appears to
// only happen is certain situations. It does
// not seem to happen when
// drawing inside an off-screen buffer.
w -= 1;
h -= 1;
g.drawRect(x, y, w, h);
}
g.fillRect(x, y, w, h);
}
}