📄 uiaccess.java
字号:
//#condition polish.midp || polish.usePolishGui
/*
* Created on 31-Jan-2006 at 00:04:45.
*
* Copyright (c) 2005 Robert Virkus / Enough Software
*
* This file is part of J2ME Polish.
*
* J2ME Polish is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* J2ME Polish 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 for more details.
*
* You should have received a copy of the GNU General Public License
* along with J2ME Polish; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Commercial licenses are also available, please
* refer to the accompanying LICENSE.txt or visit
* http://www.j2mepolish.org for details.
*/
package de.enough.polish.ui;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Image;
import de.enough.polish.util.HashMap;
/**
* <p>Allows to access J2ME Polish specific features in a standard compliant way.</p>
* <p>When a ScreenStateListener is registered with a screen, it will get notified when
* the screen changes its focus or another internal state (like changing a tab in the TabbedForm).
* </p>
*
* <p>Copyright (c) 2005, 2006 Enough Software</p>
* <pre>
* history
* 31-Jan-2006 - rob creation
* </pre>
* @author Robert Virkus, j2mepolish@enough.de
*/
public final class UiAccess {
/**
* A constant for setting the input mode of an TextField to lowercase.
* @see #setInputMode(javax.microedition.lcdui.TextField, int)
*/
public static final int MODE_LOWERCASE = 0;
/**
* A constant for setting the input mode of an TextField to uppercase for the first character, followed by lowercase characters.
* @see #setInputMode(javax.microedition.lcdui.TextField, int)
*/
public static final int MODE_FIRST_UPPERCASE = 1; // only the first character should be written in uppercase
/**
* A constant for setting the input mode of an TextField to uppercase.
* @see #setInputMode(javax.microedition.lcdui.TextField, int)
*/
public static final int MODE_UPPERCASE = 2;
/**
* A constant for setting the input mode of an TextField to numbers.
* @see #setInputMode(javax.microedition.lcdui.TextField, int)
*/
public static final int MODE_NUMBERS = 3;
/**
* A constant for setting the input mode of an TextField to it't native input - that's useful for using T9 and similar input helpers.
* @see #setInputMode(javax.microedition.lcdui.TextField, int)
*/
public static final int MODE_NATIVE = 4;
private static HashMap attributes;
/**
* No instantiation is allowd.
*/
private UiAccess() {
super();
}
//#if polish.usePolishGui && polish.midp
/**
* Registers a ScreenStateListener to any J2ME Polish screen.
*
* @param screen the screen
* @param listener the listener
*/
public static void setScreenStateListener( javax.microedition.lcdui.Screen screen, ScreenStateListener listener ) {
// ignore, just for being able to use the ScreenStateListener along with a normal screen.
}
//#endif
//#if polish.usePolishGui
/**
* Registers a ScreenStateListener to any J2ME Polish screen.
*
* @param screen the screen
* @param listener the listener
*/
public static void setScreenStateListener( Screen screen, ScreenStateListener listener ) {
screen.setScreenStateListener( listener );
}
//#endif
//#if polish.midp
/**
* Retrieves the focused index of the specified screen
*
* @param screen the screen
* @return the focused index, -1 when it is not known
*/
public static int getFocusedIndex( javax.microedition.lcdui.Screen screen ) {
return -1;
}
//#endif
//#if polish.usePolishGui
/**
* Retrieves the focused index of the specified screen
*
* @param screen the screen
* @return the focused index, -1 when it is not known
*/
public static int getFocusedIndex( Screen screen ) {
if (screen.container != null) {
return screen.container.getFocusedIndex();
}
return -1;
}
//#endif
//#if polish.midp
/**
* Retrieves the focused index of the specified screen
*
* @param screen the screen
* @return the focused item, null when it is not known
*/
public static javax.microedition.lcdui.Item getFocusedItem( javax.microedition.lcdui.Screen screen ) {
return null;
}
//#endif
//#if polish.usePolishGui
/**
* Retrieves the focused index of the specified screen
*
* @param screen the screen
* @return the focused item, null when it is not known
*/
public static Item getFocusedItem( Screen screen ) {
return screen.getCurrentItem();
}
//#endif
//#if polish.midp
/**
* Sets the focused index of the specified screen
*
* @param screen the screen
* @param index the focused index, -1 when none should be focused
*/
public static void setFocusedIndex( javax.microedition.lcdui.Screen screen, int index ) {
// ignore
}
//#endif
//#if polish.usePolishGui
/**
* Sets the focused index of the specified screen
*
* @param screen the screen
* @param index the focused index, -1 when none should be focused
*/
public static void setFocusedIndex( Screen screen, int index ) {
screen.focus( index );
}
//#endif
//#if polish.midp
/**
* Sets the focused item of the specified screen
*
* @param screen the screen
* @param item the focused item, null when none should be focused
*/
public static void setFocusedItem( javax.microedition.lcdui.Screen screen, javax.microedition.lcdui.Item item ) {
// ignore
}
//#endif
//#if polish.usePolishGui
/**
* Sets the focused item of the specified screen
*
* @param screen the screen
* @param item the focused item, null when none should be focused
*/
public static void setFocusedItem( Screen screen, Item item ) {
screen.focus(item);
}
//#endif
//#if polish.midp
/**
* Sets the title of the screen using an Item.
* <b>important</b>: you cannot call screen.setTitle(String) afterwards anymore!
*
* @param screen the screen for which the title should be replaced
* @param title the element responsible for painting the title.
*/
public static void setTitle( javax.microedition.lcdui.Screen screen, javax.microedition.lcdui.Item title ) {
// this is ignored.
}
//#endif
//#if polish.usePolishGui
/**
* Sets the title of the screen using an Item.
* <b>important</b>: you cannot call screen.setTitle(String) afterwards anymore!
*
* @param screen the screen for which the title should be replaced
* @param title the element responsible for painting the title.
*/
public static void setTitle( Screen screen, Item title ) {
screen.setTitle( title );
}
//#endif
//#if polish.usePolishGui
/**
* Sets the title of the screen using an Item.
* <b>important</b>: you cannot call screen.setTitle(String) afterwards anymore!
* This method is meant to be used in conjunction with the //#style preprocessing directive.
*
* @param screen the screen for which the title should be replaced
* @param title the element responsible for painting the title.
* @param style the style for the title
*/
public static void setTitle( Screen screen, Item title, Style style ) {
if (style != null) {
title.setStyle(style);
}
screen.setTitle( title );
}
//#endif
//#if polish.usePolishGui && polish.midp
/**
* Sets the title of the screen using an Item.
* <b>important</b>: you cannot call screen.setTitle(String) afterwards anymore!
*
* @param screen the screen for which the title should be replaced
* @param title the element responsible for painting the title.
*/
public static void setTitle( javax.microedition.lcdui.Screen screen, Item title ) {
// ignore
}
//#endif
//#if polish.usePolishGui && polish.midp
/**
* Sets the title of the screen using an Item.
* <b>important</b>: you cannot call screen.setTitle(String) afterwards anymore!
* This method is meant to be used in conjunction with the //#style preprocessing directive.
*
* @param screen the screen for which the title should be replaced
* @param title the element responsible for painting the title.
* @param style the style for the title
*/
public static void setTitle( javax.microedition.lcdui.Screen screen, Item title, Style style ) {
// ignore
}
//#endif
//#if polish.midp
/**
* Sets the fullscreen mode of the screen.
* The title and the menubar will be hidden by this call.
*
* @param screen the screen
* @param fullScreen true when the fullscreen mode should be entered
*/
public static void setFullScreenMode( javax.microedition.lcdui.Screen screen, boolean fullScreen ) {
// this is ignored.
}
//#endif
//#if polish.usePolishGui
/**
* Sets the fullscreen mode of the screen.
* The title and the menubar will be hidden by this call.
*
* @param screen the screen
* @param fullScreen true when the fullscreen mode should be entered
*/
public static void setFullScreenMode( Screen screen, boolean fullScreen ) {
screen.setFullScreenMode(fullScreen);
}
//#endif
//#if polish.midp
/**
* Adds a command to a list item.
* Warning: this method won't add any commands when the J2ME Polish GUI is not activated.
*
* @param list the list
* @param index the index of the item
* @param command the item command
*/
public static void addItemCommand( javax.microedition.lcdui.List list, int index, Command command ) {
// ignore on real lists
}
//#endif
//#if polish.usePolishGui
/**
* Adds a command to a list item.
* Warning: this method won't add any commands when the J2ME Polish GUI is not activated.
*
* @param list the list
* @param index the index of the item
* @param command the item command
*/
public static void addItemCommand( List list, int index, Command command ) {
Item item = list.getItem(index);
item.addCommand(command);
}
//#endif
//#if polish.usePolishGui
/**
* Sets the parent for the given child item.
*
* @param child the child
* @param parent the parent
*/
public static void setParent( Item child, Item parent ) {
child.parent = parent;
}
//#endif
//#if polish.usePolishGui && polish.midp
/**
* Sets the parent for the given child item.
*
* @param child the child
* @param parent the parent
*/
public static void setParent( Item child, javax.microedition.lcdui.Item parent ) {
// ignore
}
//#endif
//#if polish.midp
/**
* Sets the parent for the given child item.
*
* @param child the child
* @param parent the parent
*/
public static void setParent( javax.microedition.lcdui.Item child, javax.microedition.lcdui.Item parent ) {
// ignore
}
//#endif
//#if polish.midp
/**
* Retrieves the internal x position of the given item.
* When it is equal -9999 this item's internal position is not known.
* The internal position is useful for items that have a large content which
* needs to be scrolled, e.g. containers.
*
* @param item the item
* @return the internal x position of this item's currently selected content, -9999 when it is unknown.
*/
public static int getInternalX( javax.microedition.lcdui.Item item ) {
return -9999;
}
//#endif
//#if polish.midp
/**
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -