itemlfimpl.java
来自「This is a resource based on j2me embedde」· Java 代码 · 共 1,226 行 · 第 1/3 页
JAVA
1,226 行
*/ boolean equateNLA() { return ((item.layout & Item.LAYOUT_NEWLINE_AFTER) == Item.LAYOUT_NEWLINE_AFTER); } /** * Determine if this <code>Item</code> should have a newline before it. * * @return <code>true</code> if it should have a newline before */ boolean equateNLB() { return ((item.layout & Item.LAYOUT_NEWLINE_BEFORE) == Item.LAYOUT_NEWLINE_BEFORE); } /** * Get the effective layout type of this <code>Item</code>. * * @return layout The translated layout type. */ int getLayout() { int l = item.layout; if (l == Item.LAYOUT_DEFAULT) { // the spec requires the default vertical layout to be bottom return Item.LAYOUT_BOTTOM; } else { return l; } } /** * Called by the system to notify internal traverse into the item. * By default, it always returns false and should be overriden for * items with enabled internal traversal * * @param dir the direction of traversal * @param viewportWidth the width of the container's viewport * @param viewportHeight the height of the container's viewport * @param visRect_inout passes the visible rectangle into the method, and * returns the updated traversal rectangle from the * method * * @return <code>true</code> if focus ius accepted by the item * <code>false</code> if traversal should proceed out * * @see #getInteractionModes * @see #traverseOut * @see #TRAVERSE_HORIZONTAL * @see #TRAVERSE_VERTICAL */ boolean uCallTraverse(int dir, int viewportWidth, int viewportHeight, int[] visRect_inout) { boolean ret = false; synchronized (Display.LCDUILock) { if (!hasFocus || dir == CustomItem.NONE) { if (ret = item.acceptFocus()) { hasFocus = true; } } } return ret; } /** * Called by the system to indicate traversal has left this * <code>Item</code>. * This function simply calls lCallTraverseOut after obtaining LCDUILock. * * @see #getInteractionModes * @see #traverse * @see #TRAVERSE_HORIZONTAL * @see #TRAVERSE_VERTICAL */ void uCallTraverseOut() { synchronized (Display.LCDUILock) { lCallTraverseOut(); } } /** * Called by the system to indicate traversal has left this * <code>Item</code>. * * @see #getInteractionModes * @see #traverse * @see #TRAVERSE_HORIZONTAL * @see #TRAVERSE_VERTICAL */ void lCallTraverseOut() { hasFocus = false; } /** * Initialize native resource - size and location. */ void initNativeResource() { if (nativeId != DisplayableLFImpl.INVALID_NATIVE_ID) { if (!actualBoundsInvalid[WIDTH] && !actualBoundsInvalid[HEIGHT]) { setSize0(nativeId, bounds[WIDTH], bounds[HEIGHT]); } if (!actualBoundsInvalid[X] && !actualBoundsInvalid[Y]) { setLocation0(nativeId, bounds[X], bounds[Y]); } } } /** * Called by the system to show this <code>Item</code>'s * native resource. * * <p>The default implementation of this method shows * the native resource corresponding to this <code>Item</code> * * <p>SYNC NOTE: */ void lShowNativeResource() { if (nativeId != DisplayableLFImpl.INVALID_NATIVE_ID) { show0(nativeId); } } /** * Called by the system to hide this <code>Item</code>'s * native resource. * * <p>The default implementation of this method * hides native resources corresponding to this <code>Item</code> */ void lHideNativeResource() { if (nativeId != DisplayableLFImpl.INVALID_NATIVE_ID) { hide0(nativeId); } } /** * Sets the visibleInViewport flag of this Item to be true. * Note that this method has no effect on the native resource. * This function simply calls lCallShowNotify() after obtaining LCDUILock. */ void uCallShowNotify() { synchronized (Display.LCDUILock) { lCallShowNotify(); } } /** * Sets the visibleInViewport flag of this Item to be true. * Note that this method has no effect on the native resource. */ void lCallShowNotify() { this.visibleInViewport = true; } /** * Sets the visibleInViewport flag to be false. * Note the native resource is not hidden, nor deleted. * This function simply calls lCallShowNotify() after obtaining LCDUILock. */ void uCallHideNotify() { synchronized (Display.LCDUILock) { lCallHideNotify(); } } /** * Sets the visibleInViewport flag to be false. * Note the native resource is not hidden, nor deleted. */ void lCallHideNotify() { this.visibleInViewport = false; } /** * Called by event delivery to notify an <code>ItemLF</code> in current * <code>FormLF</code> of a change in its peer state. * Subclass should implement this function to sync its state with * the peer and choose to return proper value to let <code>Form</code> know * whether the itemStateListener should be notified. * * @param hint some value that is interpreted only between the peers * * @return <code>true</code> if internal state has changed and * <code>ItemStateListener</code> should be notified after * this function returns. */ abstract boolean uCallPeerStateChanged(int hint); /** * Called by the system to signal a key press. * * @param keyCode the key code of the key that has been pressed * * @see #getInteractionModes */ void uCallKeyPressed(int keyCode) { } /** * Called by the system to signal a key release. * * @param keyCode the key code of the key that has been released * * @see #getInteractionModes */ void uCallKeyReleased(int keyCode) { } /** * Called by the system to signal a key repeat. * * @param keyCode the key code of the key that has been repeated * * @see #getInteractionModes */ void uCallKeyRepeated(int keyCode) { } /** * Called by the system to signal a pointer press. * * @param x the x coordinate of the pointer down * @param y the y coordinate of the pointer down * * @see #getInteractionModes */ void uCallPointerPressed(int x, int y) { } /** * Called by the system to signal a pointer release. * * @param x the x coordinate of the pointer up * @param y the x coordinate of the pointer up * * @see #getInteractionModes */ void uCallPointerReleased(int x, int y) {} /** * Called by the system to signal a pointer drag. * * @param x the x coordinate of the pointer drag * @param y the x coordinate of the pointer drag * * @see #getInteractionModes */ void uCallPointerDragged(int x, int y) { } /** * Called by the system to indicate the size available to this * <code>Item</code> has changed. * * @param w the new width of the item's content area * @param h the new height of the item's content area */ void uCallSizeChanged(int w, int h) { synchronized (Display.LCDUILock) { item.lUpdateLockedSize(); } } /** * Called to commit any pending user interaction for the item. */ public void lCommitPendingInteraction() { } /** * Sets item's location. * * @param x the new x location in form's content coordinate system * @param y the new y location in form's content coordinate system */ void lSetLocation(int x, int y) { bounds[X] = x; bounds[Y] = y; if (nativeId != DisplayableLFImpl.INVALID_NATIVE_ID) { setLocation0(nativeId, x, y); } } /** * Sets item's size. * * @param w the new width of the item * @param h the new height of the item */ void lSetSize(int w, int h) { if (Logging.REPORT_LEVEL <= Logging.INFORMATION) { Logging.report(Logging.INFORMATION, LogChannels.LC_HIGHUI_ITEM_LAYOUT, " ItemLFImpl - lSetSize: " + w + "x" + h); } if (Logging.REPORT_LEVEL <= Logging.INFORMATION) { if (w < minimumWidth) { Logging.report(Logging.INFORMATION, LogChannels.LC_HIGHUI_ITEM_LAYOUT, " ******* ItemLFImpl - lSetSize: " + w + " < " + minimumWidth); } } bounds[WIDTH] = w; bounds[HEIGHT] = h; if (nativeId != DisplayableLFImpl.INVALID_NATIVE_ID) { setSize0(nativeId, w, h); } } /** * Sets the content size in the passed in array. * Content is calculated based on the availableWidth. * size[WIDTH] and size[HEIGHT] should be set by this method. * Subclasses need to override this method for correct layout. * @param size The array that holds Item content size and location * in Item internal bounds coordinate system. * @param availableWidth The width available for this Item */ void lGetContentSize(int size[], int availableWidth) { } /** * Return the content size * @return array of content size */ int[] lGetContentBounds() { return null; } /** * Moves item's location by delta. Both deltaX and deltaY can be * positive and negative. * * @param deltaX the amount of pixels by which x item's location * has to be moved * @param deltaY the amount of pixels by which y item's location * has to be moved */ void lMove(int deltaX, int deltaY) { bounds[X] += deltaX; bounds[Y] += deltaY; if (nativeId != DisplayableLFImpl.INVALID_NATIVE_ID) { setLocation0(nativeId, bounds[X], bounds[Y]); } } /** * Request the event scheduler to schedule an invalidate event, that * eventually will call uCallInvalidate(this item) of this item's * <code>DisplayableLFImpl</code>. * If caller also needs to call lSetRequestedSizes, then it must be * called AFTER this function, to have effect. * * @param width <code>true</code> if it was changed * @param height <code>true</code> if it was changed */ void lRequestInvalidate(boolean width, boolean height) { actualBoundsInvalid[WIDTH] = actualBoundsInvalid[WIDTH] || width; actualBoundsInvalid[HEIGHT] = actualBoundsInvalid[HEIGHT] || height; if (width || height) { cachedWidth = INVALID_SIZE; } // if native resource is not visible we still need // process invalidate to proper set the sizes of this ItemLF // and of form container as well if (item.owner != null) { ((DisplayableLFImpl)item.owner.getLF()).lRequestInvalidate(); } } /** * Set minimum and preferred width and height of this item. * This function should only be called on a <code>CustomItemLFImpl</code> * or <code>SpacerLFImpl</code>. * They will collect its own sizing, then call this function to cache them. * * @param mw minimum width * @param mh minimum height * @param pw preferred width * @param ph preferred height */ final void lSetRequestedSizes(int mw, int mh, int pw, int ph) { // ASSERT (this instanceof CustomItemLFImpl or SpacerLFImpl) minimumWidth = mw; minimumHeight = mh; preferredWidth = pw; preferredHeight = ph; cachedWidth= pw; if (Logging.REPORT_LEVEL <= Logging.INFORMATION) { Logging.report(Logging.INFORMATION, LogChannels.LC_HIGHUI_ITEM_LAYOUT, " lSetRequestedSizes: " + " mw=" + minimumWidth + " mh=" + minimumHeight + " pw=" + preferredWidth + " ph=" + preferredHeight); } } /** * Calculate minimum and preferred width and height of this item and * store the result in instance variables: * minimumWidth, minimumHeight, preferredWidth and preferredHeight. * This function will query native resources for the sizes. For
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?