display.jpp
来自「This is a resource based on j2me embedde」· JPP 代码 · 共 1,698 行 · 第 1/5 页
JPP
1,698 行
/* * * * Copyright 1990-2008 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License version * 2 only, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License version 2 for more details (a copy is * included at /legal/license.txt). * * You should have received a copy of the GNU General Public License * version 2 along with this work; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA * * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa * Clara, CA 95054 or visit www.sun.com if you need additional * information or have any questions. */package javax.microedition.lcdui;/* This is used to implement the communication between MIDlet and Display */import javax.microedition.midlet.MIDlet;import com.sun.midp.lcdui.DisplayFactory;import com.sun.midp.security.SecurityToken;import com.sun.midp.security.SecurityInitializer;import com.sun.midp.security.ImplicitlyTrustedClass;// #ifndef ENABLE_CDCimport javax.microedition.media.Manager;import javax.microedition.media.MediaException;import javax.microedition.media.control.ToneControl;import com.sun.midp.i18n.ResourceConstants;// #elseimport java.lang.*;import java.lang.reflect.*;// #endif ENABLE_CDCimport com.sun.midp.lcdui.*;import com.sun.midp.log.Logging;import com.sun.midp.log.LogChannels;import com.sun.midp.configurator.Constants;// #ifdef ENABLE_CHAMELEONimport com.sun.midp.chameleon.MIDPWindow;import com.sun.midp.chameleon.CGraphicsQ;import com.sun.midp.chameleon.ChamDisplayTunnel;import com.sun.midp.chameleon.input.TextInputSession;import com.sun.midp.chameleon.input.BasicTextInputSession;import com.sun.midp.chameleon.layers.PopupLayer;import com.sun.midp.chameleon.layers.PTILayer;import com.sun.midp.chameleon.layers.VirtualKeyboardLayer;import com.sun.midp.chameleon.layers.VirtualKeyListener;import com.sun.midp.chameleon.skins.ChoiceGroupSkin;import com.sun.midp.chameleon.skins.ScreenSkin;import com.sun.midp.chameleon.skins.resources.*;import java.io.IOException;// #endif ENABLE_CHAMELEON// #ifdef ENABLE_I3_TESTimport com.sun.midp.util.LiveTracer;// #endif ENABLE_I3_TEST// #ifdef ENABLE_GCIimport com.sun.me.gci.windowsystem.GCIGraphicsEnvironment;import com.sun.me.gci.windowsystem.GCIDisplay;import com.sun.me.gci.windowsystem.GCIScreenWidget;// #endif/** * <code>Display</code> represents the manager of the display and * input devices of the * system. It includes methods for retrieving properties of the device and * for requesting that objects be displayed on the device. Other methods that * deal with device attributes are primarily used with {@link Canvas Canvas} * objects and are thus defined there instead of here. <p> * * There is exactly one instance of Display per {@link * javax.microedition.midlet.MIDlet MIDlet} and the application can get a * reference to that instance by calling the {@link * #getDisplay(javax.microedition.midlet.MIDlet) getDisplay()} method. The * application may call the <code>getDisplay()</code> method at any time * during course of * its execution. The <code>Display</code> object * returned by all calls to <code>getDisplay()</code> will remain the * same during this * time. <p> * * A typical application will perform the following actions in response to * calls to its <code>MIDlet</code> methods: * <UL> * <LI><STRONG>startApp</STRONG> - the application is moving from the * paused state to the active state. * Initialization of objects needed while the application is active should be * done. The application may call * {@link #setCurrent(Displayable) setCurrent()} for the first screen if that * has not already been done. Note that <code>startApp()</code> can be * called several * times if <code>pauseApp()</code> has been called in between. This * means that one-time * initialization * should not take place here but instead should occur within the * <code>MIDlet's</code> * constructor. * </LI> * <LI><STRONG>pauseApp</STRONG> - the application may pause its threads. * Also, if it is * desirable to start with another screen when the application is re-activated, * the new screen should be set with <code>setCurrent()</code>.</LI> * <LI><STRONG>destroyApp</STRONG> - the application should free resources, * terminate threads, etc. * The behavior of method calls on user interface objects after * <code>destroyApp()</code> has returned is undefined. </li> * </UL> * <p> * * <P>The user interface objects that are shown on the display device are * contained within a {@link Displayable Displayable} object. At any time the * application may have at most one <code>Displayable</code> object * that it intends to be * shown on the display device and through which user interaction occurs. This * <code>Displayable</code> is referred to as the <em>current</em> * <code>Displayable</code>. </p> * * <P>The <code>Display</code> class has a {@link * #setCurrent(Displayable) setCurrent()} * method for setting the current <code>Displayable</code> and a * {@link #getCurrent() * getCurrent()} method for retrieving the current * <code>Displayable</code>. The * application has control over its current <code>Displayable</code> * and may call * <code>setCurrent()</code> at any time. Typically, the application * will change the * current <code>Displayable</code> in response to some user action. * This is not always the * case, however. Another thread may change the current * <code>Displayable</code> in * response to some other stimulus. The current * <code>Displayable</code> will also be * changed when the timer for an {@link Alert Alert} elapses. </P> * * <p> The application's current <code>Displayable</code> may not * physically be drawn on the * screen, nor will user events (such as keystrokes) that occur necessarily be * directed to the current <code>Displayable</code>. This may occur * because of the presence * of other <code>MIDlet</code> applications running simultaneously on * the same device. </p> * * <P>An application is said to be in the <em>foreground</em> if its current * <code>Displayable</code> is actually visible on the display device * and if user input * device events will be delivered to it. If the application is not in the * foreground, it lacks access to both the display and input devices, and it is * said to be in the <em>background</em>. The policy for allocation of these * devices to different <code>MIDlet</code> applications is outside * the scope of this * specification and is under the control of an external agent referred to as * the <em>application management software</em>. </p> * * <P>As mentioned above, the application still has a notion of its current * <code>Displayable</code> even if it is in the background. The * current <code>Displayable</code> is * significant, even for background applications, because the current * <code>Displayable</code> is always the one that will be shown the * next time the * application is brought into the foreground. The application can determine * whether a <code>Displayable</code> is actually visible on the * display by calling {@link * Displayable#isShown isShown()}. In the case of <code>Canvas</code>, * the {@link * Canvas#showNotify() showNotify()} and {@link Canvas#hideNotify() * hideNotify()} methods are called when the <code>Canvas</code> is * made visible and is * hidden, respectively.</P> * * <P> Each <code>MIDlet</code> application has its own current * <code>Displayable</code>. This means * that the {@link #getCurrent() getCurrent()} method returns the * <code>MIDlet's</code> * current <code>Displayable</code>, regardless of the * <code>MIDlet's</code> foreground/background * state. For example, suppose a <code>MIDlet</code> running in the * foreground has current * <code>Displayable</code> <em>F</em>, and a <code>MIDlet</code> * running in the background has current * <code>Displayable</code> <em>B</em>. When the foreground * <code>MIDlet</code> calls <code>getCurrent()</code>, it * will return <em>F</em>, and when the background <code>MIDlet</code> * calls <code>getCurrent()</code>, it * will return <em>B</em>. Furthermore, if either <code>MIDlet</code> * changes its current * <code>Displayable</code> by calling <code>setCurrent()</code>, this * will not affect the any other * <code>MIDlet's</code> current <code>Displayable</code>. </p> * * <P>It is possible for <code>getCurrent()</code> to return * <code>null</code>. This may occur at startup * time, before the <code>MIDlet</code> application has called * <code>setCurrent()</code> on its first * screen. The <code>getCurrent(</code>) method will never return a * reference to a * <code>Displayable</code> object that was not passed in a prior call * to <code>setCurrent()</code> call * by this <code>MIDlet</code>. </p> * * <a name="systemscreens"></a> * <h3>System Screens</h3> * * <P> Typically, the * current screen of the foreground <code>MIDlet</code> will be * visible on the display. * However, under certain circumstances, the system may create a screen that * temporarily obscures the application's current screen. These screens are * referred to as <em>system screens.</em> This may occur if the system needs * to show a menu of commands or if the system requires the user to edit text * on a separate screen instead of within a text field inside a * <code>Form</code>. Even * though the system screen obscures the application's screen, the notion of * the current screen does not change. In particular, while a system screen is * visible, a call to <code>getCurrent()</code> will return the * application's current * screen, not the system screen. The value returned by * <code>isShown()</code> is <code>false</code> * while the current <code>Displayable</code> is obscured by a system * screen. </p> * * <p> If system screen obscures a canvas, its * <code>hideNotify()</code> method is called. * When the system screen is removed, restoring the canvas, its * <code>showNotify()</code> * method and then its <code>paint()</code> method are called. If the * system screen was used * by the user to issue a command, the <code>commandAction()</code> * method is called after * <code>showNotify()</code> is called. </p> * * <p>This class contains methods to retrieve the prevailing foreground and * background colors of the high-level user interface. These methods are * useful for creating <CODE>CustomItem</CODE> objects that match the user * interface of other items and for creating user interfaces within * <CODE>Canvas</CODE> that match the user interface of the rest of the * system. Implementations are not restricted to using foreground and * background colors in their user interfaces (for example, they might use * highlight and shadow colors for a beveling effect) but the colors returned * are those that match reasonably well with the implementation's color * scheme. An application implementing a custom item should use the * background color to clear its region and then paint text and geometric * graphics (lines, arcs, rectangles) in the foreground color.</p> * * @since MIDP 1.0 */public class Display {/* * ************* public member variables */ /** * Image type for <code>List</code> element image. * * <P>The value of <code>LIST_ELEMENT</code> is <code>1</code>.</P> * * @see #getBestImageWidth(int imageType) * @see #getBestImageHeight(int imageType) */ public static final int LIST_ELEMENT = 1; /** * Image type for <code>ChoiceGroup</code> element image. * * <P>The value of <code>CHOICE_GROUP_ELEMENT</code> is <code>2</code>.</P> * * @see #getBestImageWidth(int imageType) * @see #getBestImageHeight(int imageType) */ public static final int CHOICE_GROUP_ELEMENT = 2; /** * Image type for <code>Alert</code> image. * * <P>The value of <code>ALERT</code> is <code>3</code>.</P> * * @see #getBestImageWidth(int imageType) * @see #getBestImageHeight(int imageType) */ public static final int ALERT = 3; /** * A color specifier for use with <code>getColor</code>. * <code>COLOR_BACKGROUND</code> specifies the background color of * the screen. * The background color will always contrast with the foreground color. * * <p> * <code>COLOR_BACKGROUND</code> has the value <code>0</code>. * * @see #getColor */ public static final int COLOR_BACKGROUND = 0; /** * A color specifier for use with <code>getColor</code>. * <code>COLOR_FOREGROUND</code> specifies the foreground color, * for text characters * and simple graphics on the screen. Static text or user-editable * text should be drawn with the foreground color. The foreground color * will always constrast with background color. * * <p> <code>COLOR_FOREGROUND</code> has the value <code>1</code>. * * @see #getColor */ public static final int COLOR_FOREGROUND = 1; /** * A color specifier for use with <code>getColor</code>. * <code>COLOR_HIGHLIGHTED_BACKGROUND</code> identifies the color for the * focus, or focus highlight, when it is drawn as a * filled in rectangle. The highlighted * background will always constrast with the highlighted foreground. * * <p> * <code>COLOR_HIGHLIGHTED_BACKGROUND</code> has the value <code>2</code>. * * @see #getColor */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?