KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > wings > plaf > css > MenuItemCG


1 /*
2  * $Id: MenuItemCG.java,v 1.12 2005/06/08 10:07:10 neurolabs Exp $
3  * Copyright 2000,2005 wingS development team.
4  *
5  * This file is part of wingS (http://www.j-wings.org).
6  *
7  * wingS is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU Lesser General Public License
9  * as published by the Free Software Foundation; either version 2.1
10  * of the License, or (at your option) any later version.
11  *
12  * Please see COPYING for the complete licence.
13  */

14 package org.wings.plaf.css;
15
16
17 import java.io.IOException JavaDoc;
18
19 import org.wings.SComponent;
20 import org.wings.SIcon;
21 import org.wings.SMenuItem;
22 import org.wings.io.Device;
23
24 public class MenuItemCG extends ButtonCG implements org.wings.plaf.MenuItemCG {
25
26     protected void writeItemContent(final Device device, SMenuItem menuItem)
27             throws IOException JavaDoc {
28         SIcon icon = getIcon(menuItem);
29         if (icon != null) {
30             device.print("<img align=\"middle\"");
31             Utils.optAttribute(device, "src", icon.getURL());
32             Utils.optAttribute(device, "width", icon.getIconWidth());
33             Utils.optAttribute(device, "height", icon.getIconHeight());
34             device.print(" alt=\"");
35             device.print(icon.getIconTitle());
36             device.print("\"/>");
37         }
38         String JavaDoc text = menuItem.getText();
39         if (text != null) {
40             Utils.write(device, text);
41         }
42     }
43
44     protected void writePrefix(Device device, SComponent component) throws IOException JavaDoc {
45     }
46
47     protected void writeSuffix(Device device, SComponent component) throws IOException JavaDoc {
48     }
49
50     public void writeContent(final Device device, final SComponent component)
51             throws IOException JavaDoc {
52         final SMenuItem menuItem = (SMenuItem) component;
53         writeItemContent(device, menuItem);
54     }
55 }
56
Popular Tags