01: /*
02: * Copyright Javelin Software, All rights reserved.
03: */
04:
05: package com.javelin.swinglets.plaf.javascript;
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: import com.javelin.swinglets.plaf.html.*;
14:
15: /**
16: * JSIconUI defines a look and feel for default Java Script.
17: *
18: * @author Robin Sharp
19: */
20:
21: public class JSIconUI extends HTMLIconUI implements JSComponentUI {
22: public void setIconSrc(PrintWriter out, SIcon icon1, SIcon source) {
23: if (source == null) {
24: return;
25: }
26: out.print(" document.");
27: out.print(icon1.getName());
28: out.print(".src='");
29: out.print(source.getUrl());
30: out.print("';");
31: }
32:
33: /**
34: * Render the script code for a text the PrintWriter.
35: */
36: public void updateScript(PrintWriter out, SComponent c) {
37: JSUtility.updateScript(out, c);
38: }
39:
40: /**
41: * Render the Script UI on the PrintWriter
42: */
43: public void updateEvent(PrintWriter out, SComponent c) {
44: JSUtility.updateEvents(out, c, swingletListeners);
45: }
46:
47: /**
48: * Render the Script UI on the PrintWriter
49: */
50: public void updateLinkScript(PrintWriter out, SComponent c) {
51: if (c.isVisible() == false)
52: return;
53:
54: SIcon icon = (SIcon) c;
55: Vector v = icon.getRolloverTargetPairs();
56:
57: if (icon.getRolloverIcon() != null || v != null) {
58: out.print(" onMouseOver=\"if(document.images){");
59: setIconSrc(out, icon, icon.getRolloverIcon());
60: if (v != null) {
61: for (Enumeration e = v.elements(); e.hasMoreElements();) {
62: Object p[] = (Object[]) e.nextElement();
63: SIcon targeticon = (SIcon) p[0];
64: SIcon rollovericon = (SIcon) p[1];
65: setIconSrc(out, targeticon, rollovericon);
66: }
67: }
68:
69: out.print("}\"");
70:
71: out.print(" onMouseOut=\"if(document.images){");
72: setIconSrc(out, icon, icon);
73: if (v != null) {
74: for (Enumeration e = v.elements(); e.hasMoreElements();) {
75: Object p[] = (Object[]) e.nextElement();
76: SIcon targeticon = (SIcon) p[0];
77:
78: setIconSrc(out, targeticon, targeticon);
79: }
80: }
81: out.print("}\"");
82: }
83:
84: }
85:
86: }
|