001: /*
002: * Copyright Javelin Software, All rights reserved.
003: */
004:
005: package com.javelin.swinglets.plaf.html;
006:
007: import java.awt.*;
008: import java.util.*;
009:
010: import com.javelin.swinglets.*;
011: import com.javelin.swinglets.tabbed.*;
012: import com.javelin.swinglets.theme.*;
013:
014: /**
015: * This interface defines the methods any object that would like to be
016: * a renderer for cell in a STabbbedPane for HTML.
017: * <P>
018: * This uses 5 images for a selected and unselected tab.
019: *
020: * @author Robin Sharp
021: */
022:
023: public class HTMLImageTabbedCellRenderer extends STable implements
024: STabbedCellRenderer {
025:
026: /**
027: * Create a HTMLImageTabbedCellRenderer.
028: */
029: public HTMLImageTabbedCellRenderer() {
030: super (2, 3);
031:
032: //setSize( -100, 0 );
033: setGridWidth(0);
034: setNoWrap(true);
035: setIntercellPadding(new Dimension(0, 0));
036: setIntercellSpacing(new Dimension(0, 0));
037: }
038:
039: /**
040: * If the component is a SComponent it is returned. Otherwise the
041: * value is converted toString() on a SPanel.
042: */
043: public SComponent getTabbedCellRendererComponent(
044: STabbedPane tabbedPane, int index, SLink link) {
045: if (theme == null || theme != getSwingletManager().getTheme()) {
046: theme = getSwingletManager().getTheme();
047:
048: tl = getSwingletManager().getTheme().getIcon(
049: STheme.TAB_TL_ICON);
050: bl = getSwingletManager().getTheme().getIcon(
051: STheme.TAB_BL_ICON);
052: tm = getSwingletManager().getTheme().getIcon(
053: STheme.TAB_TM_ICON);
054: tr = getSwingletManager().getTheme().getIcon(
055: STheme.TAB_TR_ICON);
056: br = getSwingletManager().getTheme().getIcon(
057: STheme.TAB_BR_ICON);
058:
059: tl.setLookAndFeel(getLookAndFeel());
060: bl.setLookAndFeel(getLookAndFeel());
061: tm.setLookAndFeel(getLookAndFeel());
062: tr.setLookAndFeel(getLookAndFeel());
063: br.setLookAndFeel(getLookAndFeel());
064:
065: label = new SLabel();
066: label.setSize(-100, 0);
067:
068: if (this .getSwingletManager().getBrowserProfile().isNS) {
069: //Set the background
070: setBackgroundIconAt(bl, 1, 0);
071: setBackgroundIconAt(br, 1, 2);
072:
073: this .setVerticalAlignmentAt(SConstants.BOTTOM, 0, 0);
074: this .setVerticalAlignmentAt(SConstants.BOTTOM, 0, 1);
075: this .setVerticalAlignmentAt(SConstants.BOTTOM, 0, 2);
076: }
077:
078: tl.setSize(5, 5);
079: tm.setSize(-100, 5);
080: tr.setSize(5, 5);
081: //label.setSize( -100, -100 );
082: bl.setSize(5, -100);
083: br.setSize(5, -100);
084:
085: setValueAt(tl, 0, 0);
086: setValueAt(tm, 0, 1);
087: setValueAt(tr, 0, 2);
088: setValueAt(label, 1, 1);
089: setValueAt(bl, 1, 0);
090: setValueAt(br, 1, 2);
091:
092: }
093:
094: //Set other properties on the tab
095: label.setFont(tabbedPane.getFont());
096: label.setIcon(tabbedPane.getIconAt(index));
097: label.setText(tabbedPane.getTitleAt(index));
098: label.setEnabled(tabbedPane.isEnabledAt(index));
099: label.setLink(link);
100:
101: return this ;
102: }
103:
104: //Selected Panel
105: protected SIcon tl;
106: protected SIcon bl;
107: protected SIcon tm;
108: protected SLabel label;
109: protected SIcon tr;
110: protected SIcon br;
111:
112: protected STheme theme;
113: }
|