public LoginForm( Model model, Controller controller, final String title, boolean firstLogin, final Style style) { super(model, controller, null, style); this.model = model; this.titleitem = new TitleBarItem(title, model); // #if polish.blackberry.isTouchBuild == true this.title = this.titleitem; // #else // add title item this.append(titleitem); // #endif // #if polish.blackberry titleitem.setAppearanceMode(Item.PLAIN); // #endif initForm(firstLogin); // focus on TextField of UserName input if (!usernameReadonly) { UiAccess.focus(this, userName); } }
/** * Arranges the items in this view. * * @param lineWidth the available line width * @param availHeight the available height in pixels * @param myItems all items * @param length the number of items * @param maxWidth the maximum width of one item * @param maxHeight the maximum height of one item */ protected void initItemArrangement( int lineWidth, int availHeight, Item[] myItems, int length, int maxWidth, int maxHeight) { // #debug // # System.out.println("initItemArrangement: lineWidth=" + lineWidth + ", availHeight=" + // availHeight + ", maxWidth=" + maxWidth + ", maxHeight=" + maxHeight + ", length=" + length); if (length == 0) { return; } this.referenceXCenterPositions = new int[length]; this.referenceXCenterPositions[this.focusedIndex] = lineWidth >> 1; this.referenceFocusedIndex = this.focusedIndex; if (maxWidth == 0) { maxWidth = lineWidth; } if (maxHeight == 0) { maxHeight = availHeight; } int completeWidth; // #if polish.midp2 completeWidth = maxWidth + ((maxWidth * this.scaleFactor) / 100) * (length - 1) + (length - 1) * this.paddingHorizontal; // #else // # completeWidth = maxWidth * length + ( length - 1 ) * this.paddingHorizontal; // #endif if (this.focusedStyle != null && this.focusedItem != null) { UiAccess.focus(this.focusedItem, this.focusedDirection, this.focusedStyle); this.focusedWidth = this.focusedItem.getItemWidth(lineWidth, lineWidth, maxHeight); this.focusedItem.relativeX = (lineWidth - this.focusedWidth) >> 1; } else if (this.focusedWidth == 0) { this.focusedWidth = maxWidth; } int availWidth; if ((completeWidth > lineWidth && this.includeAllItems) || (completeWidth < lineWidth && isLayoutExpand())) { availWidth = ((lineWidth - this.focusedWidth) >> 1) - this.paddingHorizontal; } else { availWidth = ((completeWidth - this.focusedWidth) >> 1) - this.paddingHorizontal; } // System.out.println("available=" + availableWidth + ", lineWidth=" + lineWidth + ", // completeWidth=" + completeWidth + ", maxItemWidth=" + maxWidth + ", paddingHorizontal=" + // this.paddingHorizontal); int availableWidthPerItem = (availWidth << 8) / (length - 1); // process items on the left side: int index = this.focusedIndex - 1; int processed = 0; int halfLength = (length - 1) >> 1; int startX = availWidth; // System.out.println("left: startX=" + startX + ", center=" + (lineWidth/2) ); while (processed < halfLength) { if (index < 0) { index = length - 1; } this.referenceXCenterPositions[index] = startX - ((processed * availableWidthPerItem) >>> 8) - (processed * this.paddingHorizontal); // - (maxItemWidth >> 1); // System.out.println( index + "=" + this.referenceXCenterPositions[index]); index--; processed++; } // process items on the right side: index = this.focusedIndex + 1; processed = 0; halfLength = length >> 1; startX = lineWidth - availWidth - (this.paddingHorizontal >> 1); // (lineWidth >> 1) + ((lineWidth >> 1) - startX); // System.out.println("right: startX=" + startX + ", center=" + (lineWidth/2) ); while (processed < halfLength) { if (index >= length) { index = 0; } this.referenceXCenterPositions[index] = startX + ((processed * availableWidthPerItem) >>> 8) + (processed * this.paddingHorizontal); // + (maxWidth >> 1); // System.out.println( index + "=" + this.referenceXCenterPositions[index]); index++; processed++; } }