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: * HTMLBevelBorderUI defines a look and feel for default HTML.
018: * <P>
019: * Defaults to STheme PrimaryControlShadow and PrimaryControlDarkShadow.
020: *
021: * @author Robin Sharp
022: */
023:
024: public class HTMLBevelBorderUI extends HTMLBorderUI {
025: /**
026: * Paints the border either raised or lowered.
027: */
028: public void updateBorderHeader(PrintWriter out, SComponent component) {
029: if (component.getBorder() == null
030: || !(component.getBorder().getBorder() instanceof SBevelBorder)) {
031: return;
032: }
033:
034: SBevelBorder border = (SBevelBorder) component.getBorder()
035: .getBorder();
036:
037: out.print("<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=");
038: out.print(border.getWidth());
039:
040: //Paint the raised colors
041: if (border.isRaised()) {
042: //Paint dark
043: out.print(" BORDERCOLORDARK=\"#");
044: if (border.getShadowColor() != null) {
045: out.print(SColor.toHexString(border.getShadowColor()));
046: } else if (component.getBackground() != null) {
047: out.print(SColor.toDarkerHexString(component
048: .getBackground()));
049: } else {
050: out.print(SColor.toHexString(getTheme()
051: .getPrimaryControlDarkShadow()));
052: }
053: out.print("\"");
054:
055: //Paint light
056: out.print(" BORDERCOLORLIGHT=\"#");
057: if (border.getHighlightColor() != null) {
058: out.print(SColor
059: .toHexString(border.getHighlightColor()));
060: } else if (component.getBackground() != null) {
061: out.print(SColor.toBrighterHexString(component
062: .getBackground()));
063: } else {
064: out.print(SColor.toHexString(getTheme()
065: .getPrimaryControlShadow()));
066: }
067: out.print("\"");
068:
069: } else // Paint lowered
070: {
071: //Paint light
072: out.print(" BORDERCOLORDARK=\"#");
073: if (border.getHighlightColor() != null) {
074: out.print(SColor
075: .toHexString(border.getHighlightColor()));
076: } else if (component.getBackground() != null) {
077: out.print(SColor.toBrighterHexString(component
078: .getBackground()));
079: } else {
080: out.print(SColor.toHexString(getTheme()
081: .getPrimaryControlShadow()));
082: }
083: out.print("\"");
084:
085: //Paint dark
086: out.print(" BORDERCOLORLIGHT=\"#");
087: if (border.getShadowColor() != null) {
088: out.print(SColor.toHexString(border.getShadowColor()));
089: } else if (component.getBackground() != null) {
090: out.print(SColor.toDarkerHexString(component
091: .getBackground()));
092: } else {
093: out.print(SColor.toHexString(getTheme()
094: .getPrimaryControlDarkShadow()));
095: }
096: out.print("\"");
097: }
098:
099: if (border.getBackgroundIcon() != null) {
100: out.print(" BACKGROUND=\""
101: + border.getBackgroundIcon().getUrl() + "\"");
102: } else if (component.getTopLevelAncestor() instanceof SFrame) {
103: //Only set background outside of JSP
104: if (!component.isOpaque()) {
105: } else if (component.getBackground() != null) {
106: out.print(" BGCOLOR=\"#"
107: + SColor.toHexString(component.getBackground())
108: + "\"");
109: } else {
110: out.print(" BGCOLOR=\"#"
111: + SColor.toHexString(getTheme()
112: .getWindowBackground()) + "\"");
113: }
114: }
115:
116: out.print(" ><TR><TD>");
117: }
118:
119: /**
120: * Paints the border either raised or lowered.
121: */
122: public void updateBorder(PrintWriter out, SComponent component) {
123: if (component.getBorder() == null
124: || !(component.getBorder().getBorder() instanceof SBevelBorder)) {
125: return;
126: }
127:
128: //Handle compound borders
129: if (component.getBorder().nextBorder()) {
130: component.getBorder().paint(out, component);
131: } else {
132: component.getUI().update(out, component);
133: }
134: }
135:
136: /**
137: * Paints the border either raised or lowered.
138: */
139: public void updateBorderFooter(PrintWriter out, SComponent component) {
140: if (component.getBorder() == null
141: || !(component.getBorder().getBorder() instanceof SBevelBorder)) {
142: return;
143: }
144:
145: out.print("</TD></TR>");
146: out.println("</TABLE>");
147:
148: }
149:
150: }
|