01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: /**
18: * @author Dmitry A. Durnev
19: * @version $Revision$
20: */package org.apache.harmony.awt.theme.windows;
21:
22: import java.awt.Color;
23: import java.awt.Dimension;
24: import java.awt.Graphics;
25: import java.awt.Insets;
26: import java.awt.Rectangle;
27: import java.awt.SystemColor;
28:
29: import org.apache.harmony.awt.nativebridge.windows.WindowsConsts;
30: import org.apache.harmony.awt.nativebridge.windows.WindowsDefs;
31: import org.apache.harmony.awt.state.TextComponentState;
32:
33: public class WinTextComponent extends WinStyle {
34:
35: public static void drawBackground(Graphics g, TextComponentState s,
36: WinTheme t) {
37:
38: Color c = (s.isEnabled() ? s.getBackground()
39: : SystemColor.control);
40:
41: WinThemeGraphics wgr = new WinThemeGraphics(g);
42:
43: if (t.isXpThemeActive()) {
44:
45: wgr.setTheme(t.getXpTheme("Edit")); //$NON-NLS-1$
46: int flags = (s.isEnabled() ? WindowsConsts.ETS_NORMAL
47: : WindowsConsts.ETS_DISABLED);
48: wgr.drawXpBackground(s.getSize(),
49: WindowsConsts.EP_EDITTEXT, flags);
50: if (s.isEnabled() && s.isBackgroundSet()) {
51: fill(s, c, wgr);
52: }
53:
54: } else {
55: g.setColor(c);
56: fill(s, c, wgr);
57: wgr.drawEdge(s.getSize(), WindowsDefs.EDGE_SUNKEN);
58: }
59: wgr.dispose();
60: }
61:
62: private static void fill(TextComponentState s, Color c,
63: WinThemeGraphics wgr) {
64: Dimension size = s.getSize();
65: Rectangle client = s.getClient();
66: Insets ins = s.getInsets();
67: int x = client.x + client.width;
68: int y = client.y + client.height;
69: int w = size.width - x;
70: int h = size.height - y;
71: wgr.fillBackground(client, c, true);
72: // fill areas outside of client area &&
73: // scrollbars
74: wgr.fillBackground(x, y, w, h, c, true);
75: wgr.fillBackground(0, size.height - ins.bottom, size.width,
76: ins.bottom, c, true);
77: wgr.fillBackground(size.width - ins.right, 0, ins.right,
78: size.height, c, true);
79: }
80: }
|