001: /*
002: * @(#)QtGraphicsDevice.java 1.11 06/10/10
003: *
004: * Copyright 1990-2006 Sun Microsystems, Inc. All Rights Reserved.
005: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
006: *
007: * This program is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU General Public License version
009: * 2 only, as published by the Free Software Foundation.
010: *
011: * This program is distributed in the hope that it will be useful, but
012: * WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * General Public License version 2 for more details (a copy is
015: * included at /legal/license.txt).
016: *
017: * You should have received a copy of the GNU General Public License
018: * version 2 along with this work; if not, write to the Free Software
019: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA
021: *
022: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
023: * Clara, CA 95054 or visit www.sun.com if you need additional
024: * information or have any questions.
025: *
026: */
027:
028: package sun.awt.qt;
029:
030: import java.awt.GraphicsDevice;
031: import java.awt.GraphicsConfiguration;
032: import java.awt.Window;
033: import java.awt.Rectangle;
034: import sun.awt.AppContext;
035:
036: class QtGraphicsDevice extends GraphicsDevice {
037: private Window fullScreenWindow = null;
038: //6208413
039: // tracks which AppContext created the window
040: private AppContext fullScreenAppContext = null;
041:
042: private Rectangle windowedModeBounds = null;
043:
044: public QtGraphicsDevice() {
045: }
046:
047: /**
048: * Returns <code>true</code> if this <code>GraphicsDevice</code>
049: * supports full-screen exclusive mode.
050: * @return whether full-screen exclusive mode is available for
051: * this graphics device
052: * @since 1.4
053: */
054: public boolean isFullScreenSupported() {
055: return false;
056: }
057:
058: public int getAvailableAcceleratedMemory() {
059: return 0;
060: }
061:
062: /**
063: * Enter full-screen mode, or return to windowed mode.
064: * <p>
065: * If <code>isFullScreenSupported</code> returns <code>true</code>, full
066: * screen mode is considered to be <i>exclusive</i>, which implies:
067: * <ul>
068: * <li>Windows cannot overlap the full-screen window. All other application
069: * windows will always appear beneath the full-screen window in the Z-order.
070: * <li>Input method windows are disabled. It is advisable to call
071: * <code>Component.enableInputMethods(false)</code> to make a component
072: * a non-client of the input method framework.
073: * </ul>
074: * <p>
075: * If <code>isFullScreenSupported</code> returns
076: * <code>false</code>, full-screen exclusive mode is simulated by resizing
077: * the window to the size of the screen and positioning it at (0,0).
078: * <p>
079: * When returning to windowed mode from an exclusive full-screen window, any
080: * display changes made by calling <code>setDisplayMode</code> are
081: * automatically restored to their original state.
082: * @param w a window to use as the full-screen window; <code>null</code>
083: * if returning to windowed mode.
084: * @see #isFullScreenSupported
085: * @see #getFullScreenWindow
086: * @see #setDisplayMode
087: * @see Component#enableInputMethods
088: * @since 1.4
089: */
090: public void setFullScreenWindow(Window w) {
091: if (fullScreenWindow != null && windowedModeBounds != null) {
092: fullScreenWindow.setBounds(windowedModeBounds);
093: }
094: // 6208413
095: synchronized (this ) {
096: // Set the full screen window
097: fullScreenWindow = w;
098: if (fullScreenWindow == null)
099: fullScreenAppContext = null;
100: else
101: fullScreenAppContext = AppContext.getAppContext();
102: }
103: // 6208413
104: if (fullScreenWindow != null) {
105: windowedModeBounds = fullScreenWindow.getBounds();
106: fullScreenWindow.setBounds(getDefaultConfiguration()
107: .getBounds());
108: fullScreenWindow.setVisible(true);
109: fullScreenWindow.toFront();
110: }
111: }
112:
113: /**
114: * Returns the <code>Window</code> object representing the
115: * full-screen window if the device is in full-screen mode.
116: * @return the full-screen window, <code>null</code> if the device is
117: * not in full-screen mode.
118: * @see #setFullScreenWindow(Window)
119: * @since 1.4
120: */
121: public Window getFullScreenWindow() {
122: Window returnWindow = null;
123: synchronized (this ) {
124: // Only return a handle to the current fs window if we are in the
125: // same AppContext that set the fs window
126: if (fullScreenAppContext == AppContext.getAppContext()) {
127: returnWindow = fullScreenWindow;
128: }
129: }
130: return returnWindow; //6208413
131: }
132:
133: public int getType() {
134: return TYPE_RASTER_SCREEN;
135: }
136:
137: public String getIDstring() {
138: return "Qt Screen Device";
139: }
140:
141: public GraphicsConfiguration getDefaultConfiguration() {
142: return graphicsConfig;
143: }
144:
145: public GraphicsConfiguration[] getConfigurations() {
146: return new GraphicsConfiguration[] { graphicsConfig };
147: }
148:
149: private QtGraphicsConfiguration graphicsConfig = new QtGraphicsConfiguration(
150: this);
151: }
|