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: import java.io.*;
010:
011: import com.javelin.swinglets.*;
012: import com.javelin.swinglets.plaf.*;
013: import com.javelin.swinglets.border.*;
014: import com.javelin.swinglets.theme.*;
015:
016: /**
017: * HTMLEmptyBorderUI defines a look and feel for default HTML.
018: *
019: * @author Robin Sharp
020: */
021:
022: public class HTMLEmptyBorderUI extends HTMLBorderUI {
023: /**
024: * Paint the border header in the specified manner.
025: */
026: public void updateBorderHeader(PrintWriter out, SComponent component) {
027: if (component.getBorder() == null
028: || !(component.getBorder().getBorder() instanceof SEmptyBorder)) {
029: return;
030: }
031:
032: SEmptyBorder border = (SEmptyBorder) component.getBorder()
033: .getBorder();
034:
035: out.print("<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0");
036:
037: if (border.getBackgroundIcon() != null) {
038: out.print(" BACKGROUND=\""
039: + border.getBackgroundIcon().getUrl() + "\"");
040: } else if (component.getTopLevelAncestor() instanceof SFrame) {
041: //Only set background outside of JSP
042: if (!component.isOpaque()) {
043: } else if (component.getBackground() != null) {
044: out.print(" BGCOLOR=\"#"
045: + SColor.toHexString(component.getBackground())
046: + "\"");
047: } else {
048: out.print(" BGCOLOR=\"#"
049: + SColor.toHexString(getTheme()
050: .getWindowBackground()) + "\"");
051: }
052: }
053:
054: out.print(" >");
055:
056: //1st row
057: out.print("<TR><TD HEIGHT=\"");
058: out.print(border.getInsets().top);
059: out.println("\"></TD><TD></TD><TD></TD></TR>");
060:
061: //2nd row
062: out.print("<TR><TD WIDTH=\"");
063: out.print(border.getInsets().left);
064: out.print("\"></TD><TD>");
065: }
066:
067: /**
068: * Paint the border in the specified manner.
069: */
070: public void updateBorder(PrintWriter out, SComponent component) {
071: if (component.getBorder() == null
072: || !(component.getBorder().getBorder() instanceof SEmptyBorder)) {
073: return;
074: }
075:
076: //Handle compound borders
077: if (component.getBorder().nextBorder()) {
078: component.getBorder().paint(out, component);
079: } else {
080: component.getUI().update(out, component);
081: }
082: }
083:
084: /**
085: * Paint the border header in the specified manner.
086: */
087: public void updateBorderFooter(PrintWriter out, SComponent component) {
088: if (component.getBorder() == null
089: || !(component.getBorder().getBorder() instanceof SEmptyBorder)) {
090: return;
091: }
092:
093: SEmptyBorder border = (SEmptyBorder) component.getBorder()
094: .getBorder();
095:
096: out.print("</TD><TD WIDTH=\"");
097: out.print(border.getInsets().right);
098: out.println("\"></TD></TR>");
099:
100: //3rd row
101: out.print("<TR><TD></TD><TD></TD>");
102: out.print("<TD HEIGHT=\"");
103: out.print(border.getInsets().bottom);
104: out.println("\"></TD></TR>");
105: out.println("</TABLE>");
106:
107: }
108:
109: }
|