01: /*
02: * Copyright Javelin Software, All rights reserved.
03: */
04:
05: package com.javelin.swinglets.plaf.wml;
06:
07: import java.awt.*;
08: import java.util.*;
09: import java.io.*;
10:
11: import com.javelin.swinglets.*;
12: import com.javelin.swinglets.plaf.*;
13:
14: /**
15: * WMLIconUI defines a look and feel for default WML.
16: *
17: * @author Robin Sharp
18: */
19:
20: public class WMLIconUI extends WMLComponentUI implements SIconUI {
21: /**
22: * Render the script on the output, in the body part of the web page
23: */
24: public void updateLinkScript(Object out, SComponent c) {
25: updateLinkScript((PrintWriter) out, c);
26: }
27:
28: /**
29: * Render the script on the PrintWriter, in the body part of the web page
30: */
31: public void updateLinkScript(PrintWriter out, SComponent c) {
32: }
33:
34: /**
35: * Render the UI on the PrintWriter
36: */
37: public void update(PrintWriter out, SComponent c) {
38: if (!c.isVisible())
39: return;
40:
41: SIcon icon = (SIcon) c;
42:
43: // MS 23 Sept 1999 - added everything below this line:
44:
45: // WML does not support image maps.
46:
47: if (icon.getLink() != null) {
48: out.println("<do type=\"accept\">");
49: out.print(" <go href=\"");
50: out.print(icon.getLink().getUrl());
51: out.println("\"/>");
52: out.println("</do>");
53:
54: updateLinkScript(out, c);
55: }
56:
57: if (icon.getUrl() != null) {
58: out.print("<img");
59:
60: out.print(" id=\"");
61: out.print(icon.getName());
62: out.print("\"");
63:
64: WMLUtility.setSrc(out, icon);
65:
66: if (icon.getToolTipText() != null) {
67: // Uses ToolTipText for "alt=" text.
68: out.print(" alt=\"");
69: out.print(icon.getToolTipText());
70: out.print("\"");
71: } else if (icon.getUrl() != null) {
72: out.print(" alt=\"");
73:
74: out.print(icon.getFileName());
75:
76: out.print("\"");
77: } else {
78: out.print(" alt=\"");
79: out.print(icon.getName());
80: out.print("\"");
81: }
82:
83: if (icon.getSize().height > 0 && icon.getSize().width > 0) {
84: out.print(" height=\"");
85: out.print(icon.getSize().height);
86: out.print("\"");
87:
88: out.print(" width=\"");
89: out.print(icon.getSize().width);
90: out.print("\"");
91: }
92:
93: updateEvent(out, c);
94:
95: out.print("/>");
96: }
97:
98: }
99: }
|