📄 item.java
字号:
* rows. (However, a <code>StringItem</code> with an appearance mode of
* <code>HYPERLINK</code> should be wrapped the same way as if its appearance
* mode is <code>PLAIN</code>.)</p>
*
* <p>A <code>StringItem</code> or <code>ImageItem</code>
* in <code>BUTTON</code> mode can be used to create a
* button-based user interface. This can easily lead to applications that are
* inconvenient to use. For example, in a traversal-based system, users must
* navigate to a button before they can invoke any commands on it. If buttons
* are spread across a long <code>Form</code>, users may be required
* to perform a
* considerable amount of navigation in order to discover all the available
* commands. Furthermore, invoking a command from a button at the
* other end of the <code>Form</code> can be quite cumbersome.
* Traversal-based systems
* often provide a means of invoking commands from anywhere (such as from a
* menu), without the need to traverse to a particular item. Instead of
* adding a command to a button and placing that button into a
* <code>Form</code>, it would
* often be more appropriate and convenient for users if that command were
* added directly to the <code>Form</code>. Buttons should be used
* only in cases where
* direct user interaction with the item's string or image contents is
* essential to the user's understanding of the commands that can be invoked
* from that item.</p>
*
* <h3>Default State</h3>
*
* <p>Unless otherwise specified by a subclass, the default state of newly
* created <code>Items</code> is as follows:</p>
*
* <ul>
* <li>the <code>Item</code> is not contained within
* ("owned by") any container;</li>
* <li>there are no <code>Commands</code> present;</li>
* <li>the default <code>Command</code> is <code>null</code>;</li>
* <li>the <code>ItemCommandListener</code> is <code>null</code>;</li>
* <li>the layout directive value is <code>LAYOUT_DEFAULT</code>; and</li>
* <li>both the preferred width and preferred height are unlocked.</li>
* </ul>
*
* @since MIDP 1.0
*/
public abstract class Item extends Object
{
/**
* A J2ME Polish constant defining a transparent/invisible color.
* TRANSPARENT has the value -1.
*/
public static final int TRANSPARENT = -1;
/**
* A J2ME Polish constant defining a vertical orientation.
* VERTICAL has the value 0.
*/
public static final int VERTICAL = 0;
/**
* A J2ME Polish constant defining a horizontal orientation.
* HORIZONTAL has the value 1.
*/
public static final int HORIZONTAL = 1;
/**
* A layout directive indicating that this <code>Item</code>
* should follow the default layout policy of its container.
*
* <P>Value <code>0</code> is assigned to <code>LAYOUT_DEFAULT</code>.</P>
*
*
* @since MIDP 2.0
*/
public static final int LAYOUT_DEFAULT = 0;
/**
* A layout directive indicating that this <code>Item</code> should have a
* left-aligned layout.
*
* <P>Value <code>1</code> is assigned to <code>LAYOUT_LEFT</code>.</P>
*
*
* @since MIDP 2.0
*/
public static final int LAYOUT_LEFT = 1;
/**
* A layout directive indicating that this <code>Item</code> should have a
* right-aligned layout.
*
* <P>Value <code>2</code> is assigned to <code>LAYOUT_RIGHT</code>.</P>
*
*
* @since MIDP 2.0
*/
public static final int LAYOUT_RIGHT = 2;
/**
* A layout directive indicating that this <code>Item</code> should have a
* horizontally centered layout.
*
* <P>Value <code>3</code> is assigned to <code>LAYOUT_CENTER</code>.</P>
*
*
* @since MIDP 2.0
*/
public static final int LAYOUT_CENTER = 3;
/**
* A layout directive indicating that this <code>Item</code> should have a
* top-aligned layout.
*
* <P>Value <code>0x10</code> is assigned to <code>LAYOUT_TOP</code>.</P>
*
*
* @since MIDP 2.0
*/
public static final int LAYOUT_TOP = 0x10;
/**
* A layout directive indicating that this <code>Item</code> should have a
* bottom-aligned layout.
*
* <P>Value <code>0x20</code> is assigned to <code>LAYOUT_BOTTOM</code>.</P>
*
*
* @since MIDP 2.0
*/
public static final int LAYOUT_BOTTOM = 0x20;
/**
* A layout directive indicating that this <code>Item</code> should have a
* vertically centered layout.
*
* <P>Value <code>0x30</code> is assigned to
* <code>LAYOUT_VCENTER</code>.</P>
*
*
* @since MIDP 2.0
*/
public static final int LAYOUT_VCENTER = 0x30;
/**
* A layout directive indicating that this <code>Item</code>
* should be placed at the beginning of a new line or row.
*
* <P>Value <code>0x100</code> is assigned to
* <code>LAYOUT_NEWLINE_BEFORE</code>.</P>
*
*
* @since MIDP 2.0
*/
public static final int LAYOUT_NEWLINE_BEFORE = 0x100;
/**
* A layout directive indicating that this <code>Item</code>
* should the last on its line or row, and that the next
* <code>Item</code> (if any) in the container
* should be placed on a new line or row.
*
* <P>Value <code>0x200</code> is assigned to
* <code>LAYOUT_NEWLINE_AFTER</code>.</P>
*
*
* @since MIDP 2.0
*/
public static final int LAYOUT_NEWLINE_AFTER = 0x200;
/**
* A layout directive indicating that this <code>Item's</code>
* width may be reduced to its minimum width.
*
* <P>Value <code>0x400</code> is assigned to <code>LAYOUT_SHRINK</code></P>
*
*
* @since MIDP 2.0
*/
public static final int LAYOUT_SHRINK = 0x400;
/**
* A layout directive indicating that this <code>Item's</code>
* width may be increased to fill available space.
*
* <P>Value <code>0x800</code> is assigned to <code>LAYOUT_EXPAND</code>.</P>
*
*
* @since MIDP 2.0
*/
public static final int LAYOUT_EXPAND = 0x800;
/**
* A layout directive indicating that this <code>Item's</code>
* height may be reduced to its minimum height.
*
* <P>Value <code>0x1000</code> is assigned to
* <code>LAYOUT_VSHRINK</code>.</P>
*
*
* @since MIDP 2.0
*/
public static final int LAYOUT_VSHRINK = 0x1000;
/**
* A layout directive indicating that this <code>Item's</code>
* height may be increased to fill available space.
*
* <P>Value <code>0x2000</code> is assigned to
* <code>LAYOUT_VEXPAND</code>.</P>
*
*
* @since MIDP 2.0
*/
public static final int LAYOUT_VEXPAND = 0x2000;
/**
* A layout directive indicating that new MIDP 2.0 layout
* rules are in effect for this <code>Item</code>. If this
* bit is clear, indicates that MIDP 1.0 layout behavior
* applies to this <code>Item</code>.
*
* <P>Value <code>0x4000</code> is assigned to
* <code>LAYOUT_2</code>.</P>
*
*
* @since MIDP 2.0
*/
public static final int LAYOUT_2 = 0x4000;
/**
* An appearance mode value indicating that the <code>Item</code> is to have
* a normal appearance.
*
* <P>Value <code>0</code> is assigned to <code>PLAIN</code>.</P>
*
*
* @since MIDP 2.0
*/
public static final int PLAIN = 0;
/**
* An appearance mode value indicating that the <code>Item</code>
* is to appear as a hyperlink.
* <P>Value <code>1</code> is assigned to <code>HYPERLINK</code>.</P>
*
*
* @since MIDP 2.0
*/
public static final int HYPERLINK = 1;
/**
* An appearance mode value indicating that the <code>Item</code>
* is to appear as a button.
* <P>Value <code>2</code> is assigned to <code>BUTTON</code>.</P>
*
* @since MIDP 2.0
*/
public static final int BUTTON = 2;
/**
* A J2ME Polish appearance mode value indicating that the <code>Item</code>
* accepts input from the user.
* <P>Value <code>3</code> is assigned to <code>INTERACTIVE</code>.</P>
*/
public static final int INTERACTIVE = 3;
protected int layout;
protected ItemCommandListener itemCommandListener;
protected Command defaultCommand;
protected int preferredWidth;
protected int preferredHeight;
protected int minimumWidth;
protected int minimumHeight;
//#ifdef polish.css.max-width
protected int maximumWidth;
//#endif
//#ifdef polish.css.max-height
//# protected int maximumHeight;
//#endif
protected boolean isInitialized;
public Background background;
protected Border border;
protected Style style;
public int itemWidth;
public int itemHeight;
protected int paddingLeft;
protected int paddingTop;
protected int paddingRight;
protected int paddingBottom;
protected int paddingVertical;
protected int paddingHorizontal;
protected int marginLeft;
protected int marginTop;
protected int marginRight;
protected int marginBottom;
/** The width of this item's content **/
protected int contentWidth;
/** The height of this item's content **/
protected int contentHeight;
protected int borderWidth;
protected int backgroundWidth;
protected int backgroundHeight;
/** The appearance mode of this item, either PLAIN or one of the interactive modes BUTTON, HYPERLINK or INTERACTIVE. */
public int appearanceMode;
/**
* The screen to which this item belongs to.
*/
protected Screen screen;
//#ifdef polish.useDynamicStyles
//# /**
//# * The appropriate CSS selector of this item.
//# * This is either the style's name or a selector
//# * depending on the state of this item. A StringItem
//# * can have the selector "p", "a" or "button", for example.
//# * This variable can only be used, when the proprocessing variable
//# * "polish.useDynamicStyles" is defined.
//# */
//# protected String cssSelector;
//#endif
/**
* Determines whether the style has be dynamically assigned already.
*/
protected boolean isStyleInitialised;
/**
* The parent of this item.
*/
protected Item parent;
protected ArrayList commands;
protected boolean isLayoutCenter;
protected boolean isLayoutExpand;
protected boolean isLayoutRight;
// the current positions of this item:
/** the horizontal start position relative to it's parent's item left content edge */
public int relativeX;
/** the vertical start position of this item relative to it's parent item top content edge */
public int relativeY;
/** the horizontal position of this item's content relative to it's left edge */
protected int contentX;
/** the vertical position of this item's content relative to it's top edge */
protected int contentY; // absolute top vertical position of the content
// the current positions of an internal element relative to the content origin
// which should be visible:
/**
* The internal horizontal position of this item's content relative to it's left edge.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -