001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: /**
018: * @author Pavel Dolgov
019: * @version $Revision$
020: */package org.apache.harmony.awt;
021:
022: import java.awt.Dimension;
023: import java.awt.FileDialog;
024: import java.awt.Graphics;
025: import java.awt.Point;
026: import java.awt.Rectangle;
027:
028: import org.apache.harmony.awt.state.ButtonState;
029: import org.apache.harmony.awt.state.CheckboxState;
030: import org.apache.harmony.awt.state.ChoiceState;
031: import org.apache.harmony.awt.state.LabelState;
032: import org.apache.harmony.awt.state.ListState;
033: import org.apache.harmony.awt.state.MenuBarState;
034: import org.apache.harmony.awt.state.MenuState;
035: import org.apache.harmony.awt.state.ScrollbarState;
036: import org.apache.harmony.awt.state.TextComponentState;
037: import org.apache.harmony.awt.state.TextState;
038: import org.apache.harmony.awt.theme.DefaultButton;
039: import org.apache.harmony.awt.theme.DefaultCheckbox;
040: import org.apache.harmony.awt.theme.DefaultChoice;
041: import org.apache.harmony.awt.theme.DefaultFileDialog;
042: import org.apache.harmony.awt.theme.DefaultLabel;
043: import org.apache.harmony.awt.theme.DefaultList;
044: import org.apache.harmony.awt.theme.DefaultMenu;
045: import org.apache.harmony.awt.theme.DefaultMenuBar;
046: import org.apache.harmony.awt.theme.DefaultScrollbar;
047: import org.apache.harmony.awt.theme.DefaultStyle;
048: import org.apache.harmony.awt.theme.DefaultTextComponent;
049:
050: /**
051: * Standard appearance of standard components
052: */
053: public class Theme {
054:
055: public void drawButton(Graphics g, ButtonState s) {
056: drawButtonBackground(g, s);
057: drawButtonText(g, s);
058: }
059:
060: public void calculateButton(ButtonState s) {
061: DefaultButton.calculate(s);
062: }
063:
064: public void drawLabel(Graphics g, LabelState s) {
065: drawLabelBackground(g, s);
066: drawLabelText(g, s);
067: }
068:
069: public void calculateLabel(LabelState s) {
070: DefaultLabel.calculate(s);
071: }
072:
073: public void drawCheckbox(Graphics g, CheckboxState s) {
074: Rectangle textRect = DefaultCheckbox.getTextRect(s);
075: drawCheckboxBackground(g, s, textRect);
076: drawCheckboxText(g, s, textRect);
077: }
078:
079: public void calculateCheckbox(CheckboxState s) {
080: DefaultCheckbox.calculate(s);
081: }
082:
083: public void drawScrollbar(Graphics g, ScrollbarState s) {
084: DefaultScrollbar.draw(g, s);
085: }
086:
087: public void calculateScrollbar(ScrollbarState s) {
088: DefaultScrollbar.calculate(s);
089: }
090:
091: public void layoutScrollbar(ScrollbarState s) {
092: DefaultScrollbar.layout(s);
093: }
094:
095: public void drawChoice(Graphics g, ChoiceState s) {
096: drawChoiceBackground(g, s);
097: drawChoiceText(g, s);
098:
099: }
100:
101: public void drawTextComponentBackground(Graphics g,
102: TextComponentState s) {
103: DefaultTextComponent.drawBackground(g, s);
104: }
105:
106: public void drawList(Graphics g, ListState s, boolean flat) {
107: drawListBackground(g, s, flat);
108: drawListItems(g, s);
109: }
110:
111: public void drawMenu(MenuState s, Graphics gr) {
112: DefaultMenu.drawMenu(s, gr);
113: }
114:
115: public Dimension calculateMenuSize(MenuState s) {
116: return DefaultMenu.calculateSize(s);
117: }
118:
119: public int getMenuItemIndex(MenuState s, Point p) {
120: return DefaultMenu.getItemIndex(s, p);
121: }
122:
123: public Point getMenuItemLocation(MenuState s, int index) {
124: return DefaultMenu.getItemLocation(s, index);
125: }
126:
127: public void drawMenuBar(MenuBarState s, Graphics gr) {
128: DefaultMenuBar.drawMenuBar(s, gr);
129: }
130:
131: public void layoutMenuBar(MenuBarState s, int width) {
132: DefaultMenuBar.layoutMenuBar(s, width);
133: }
134:
135: public int getMenuBarItemIndex(MenuBarState s, Point p) {
136: return DefaultMenuBar.getItemIndex(s, p);
137: }
138:
139: public Point getMenuBarItemLocation(MenuBarState s, int index) {
140: return DefaultMenuBar.getItemLocation(s, index);
141: }
142:
143: protected void drawListItems(Graphics g, ListState s) {
144: DefaultList.drawItems(g, s);
145:
146: }
147:
148: protected void drawListBackground(Graphics g, ListState s,
149: boolean flat) {
150: DefaultList.drawBackground(g, s, flat);
151: }
152:
153: protected void drawChoiceText(Graphics g, ChoiceState s) {
154: DefaultChoice.drawText(g, s);
155: }
156:
157: protected void drawChoiceBackground(Graphics g, ChoiceState s) {
158: DefaultChoice.drawBackground(g, s);
159: }
160:
161: protected void drawButtonBackground(Graphics g, ButtonState s) {
162: DefaultButton.drawBackground(g, s);
163: }
164:
165: protected void drawButtonText(Graphics g, ButtonState s) {
166: DefaultButton.drawText(g, s);
167: }
168:
169: protected void drawLabelBackground(Graphics g, LabelState s) {
170: DefaultLabel.drawBackground(g, s);
171: }
172:
173: protected void drawLabelText(Graphics g, LabelState s) {
174: DefaultLabel.drawText(g, s);
175: }
176:
177: protected void drawCheckboxBackground(Graphics g, CheckboxState s,
178: Rectangle focusRect) {
179: DefaultCheckbox.drawBackground(g, s, focusRect);
180: }
181:
182: protected void drawCheckboxText(Graphics g, CheckboxState s,
183: Rectangle r) {
184: DefaultCheckbox.drawText(g, s, r);
185: }
186:
187: protected void drawFocusRect(Graphics g, TextState s, Rectangle r) {
188: if (s.isFocused()) {
189: DefaultStyle.drawFocusRect(g, r.x, r.y, r.width, r.height);
190: }
191:
192: }
193:
194: public boolean showFileDialog(FileDialog fd) {
195: DefaultFileDialog dfd = new DefaultFileDialog(fd);
196: return dfd.show();
197: }
198:
199: public boolean hideFileDialog(FileDialog fd) {
200: return true;
201: }
202:
203: }
|