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.theme.windows;
021:
022: import java.awt.FileDialog;
023: import java.awt.Graphics;
024: import java.awt.Rectangle;
025:
026: import org.apache.harmony.awt.ContextStorage;
027: import org.apache.harmony.awt.Theme;
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.ScrollbarState;
032: import org.apache.harmony.awt.state.TextComponentState;
033: import org.apache.harmony.awt.wtk.windows.WinEventQueue;
034:
035: /**
036: * WinTheme
037: */
038: public class WinTheme extends Theme {
039:
040: private WinEventQueue.ThemeMap themeMap;
041:
042: private WinEventQueue.ThemeMap getThemeMap() {
043: if (themeMap != null) {
044: return themeMap;
045: }
046: WinEventQueue eq = (WinEventQueue) ContextStorage
047: .getNativeEventQueue();
048: themeMap = eq.getThemeMap();
049: return themeMap;
050: }
051:
052: protected long getXpTheme(String s) {
053: return getThemeMap().get(s);
054: }
055:
056: protected boolean isXpThemeActive() {
057: return getThemeMap().isEnabled();
058: }
059:
060: @Override
061: protected void drawButtonBackground(Graphics g, ButtonState s) {
062:
063: if (!s.isBackgroundSet()) {
064: WinButton.drawBackground(g, s, this );
065: } else {
066: super .drawButtonBackground(g, s);
067: }
068: }
069:
070: @Override
071: protected void drawCheckboxBackground(Graphics g, CheckboxState s,
072: Rectangle focusRect) {
073: if (!s.isBackgroundSet()) {
074: WinCheckbox.drawBackground(g, s, focusRect, this );
075: } else {
076: super .drawCheckboxBackground(g, s, focusRect);
077: }
078: }
079:
080: @Override
081: public void drawScrollbar(Graphics g, ScrollbarState s) {
082: WinScrollbar.draw(g, s, this );
083: }
084:
085: @Override
086: protected void drawChoiceBackground(Graphics g, ChoiceState s) {
087: WinChoice.drawBackground(g, s, this );
088: }
089:
090: @Override
091: public void drawTextComponentBackground(Graphics g,
092: TextComponentState s) {
093: WinTextComponent.drawBackground(g, s, this );
094: }
095:
096: @Override
097: public boolean showFileDialog(FileDialog fd) {
098: WinFileDialog dlg = WinFileDialog.getInstance(fd);
099: if (dlg == null) {
100: dlg = new WinFileDialog(fd);
101: }
102: return dlg.show();
103: }
104:
105: @Override
106: public boolean hideFileDialog(FileDialog fd) {
107: WinFileDialog dlg = WinFileDialog.getInstance(fd);
108: if (dlg != null) {
109: dlg.close();
110: }
111: return false;
112: }
113: }
|