📄 screen.java
字号:
} else { //#ifdef polish.i18n.useDynamicTranslations menuText = Locale.get( "polish.command.options" ); //#elifdef polish.command.options:defined //#= menuText = "${polish.command.options}"; //#else menuText = "Options"; //#endif } } //#ifdef polish.Menu.MarginLeft:defined //#= int menuLeftX += ${polish.Menu.MarginLeft}; //#else menuLeftX += 2; //#endif //#ifdef polish.hasPointerEvents this.menuLeftCommandX = menuLeftX + this.menuFont.stringWidth( menuText ); //#endif g.setColor( this.menuFontColor ); g.setFont( this.menuFont ); //#ifdef polish.Menu.MarginTop:defined //#= g.drawString(menuLeftX, menuX, this.originalScreenHeight + ${polish.Menu.MarginTop}, Graphics.TOP | Graphics.LEFT ); //#else g.drawString(menuText, menuLeftX, this.originalScreenHeight + 2, Graphics.TOP | Graphics.LEFT ); //#endif if ( this.menuOpened ) { // draw cancel string: //#ifdef polish.i18n.useDynamicTranslations menuText = Locale.get( "polish.command.cancel" ); //#elifdef polish.command.cancel:defined //#= menuText = "${polish.command.cancel}"; //#else menuText = "Cancel"; //#endif //#ifdef polish.Menu.MarginRight:defined //#= menuRightX -= ${polish.Menu.MarginRight}; //#elifdef polish.Menu.MarginLeft:defined menuRightX -= 2; //#endif //#ifdef polish.Menu.MarginTop:defined //#= g.drawString(menuText, menuRightX, this.originalScreenHeight + ${polish.Menu.MarginTop}, Graphics.TOP | Graphics.RIGHT ); //#else g.drawString(menuText, menuRightX, this.originalScreenHeight + 2, Graphics.TOP | Graphics.RIGHT ); //#endif //#ifdef polish.hasPointerEvents this.menuRightCommandX = menuRightX - this.menuFont.stringWidth( menuText ); //#endif } } if (this.menuSingleRightCommand != null && !this.menuOpened) { g.setColor( this.menuFontColor ); g.setFont( this.menuFont ); String menuText = this.menuSingleRightCommand.getLabel(); //#ifdef polish.Menu.MarginRight:defined //#= menuRightX -= ${polish.Menu.MarginRight}; //#elifdef polish.Menu.MarginLeft:defined menuRightX -= 2; //#endif //#ifdef polish.Menu.MarginTop:defined //#= g.drawString(menuText, menuRightX, this.originalScreenHeight + ${polish.Menu.MarginTop}, Graphics.TOP | Graphics.RIGHT ); //#else g.drawString(menuText, menuRightX, this.originalScreenHeight + 2, Graphics.TOP | Graphics.RIGHT ); //#endif //#ifdef polish.hasPointerEvents this.menuRightCommandX = menuRightX - this.menuFont.stringWidth( menuText ); //#endif } } // if this.showTitleOrMenu || this.menuOpened //#endif //#endif //#if !tmp.useScrollBar // paint scroll-indicator in the middle of the menu: if (this.paintScrollIndicator) { g.setColor( this.scrollIndicatorColor ); int x = this.scrollIndicatorX; int y = this.scrollIndicatorY; //System.out.println("paint: this.scrollIndicatorY=" + this.scrollIndicatorY); int width = this.scrollIndicatorWidth; int halfWidth = width / 2; if (this.paintScrollIndicatorUp) { //#if polish.css.scrollindicator-up-image if (this.scrollIndicatorUpImage != null) { g.drawImage(this.scrollIndicatorUpImage, x, y, Graphics.LEFT | Graphics.TOP ); } else { //#endif //#ifdef polish.midp2 g.fillTriangle(x, y + halfWidth-1, x + width, y + halfWidth-1, x + halfWidth, y ); //#else g.drawLine( x, y + halfWidth-1, x + width, y + halfWidth-1 ); g.drawLine( x, y + halfWidth-1, x + halfWidth, y ); g.drawLine( x + width, y + halfWidth-1, x + halfWidth, y ); //#endif //#if polish.css.scrollindicator-up-image } //#endif } if (this.paintScrollIndicatorDown) { //#if polish.css.scrollindicator-down-image if (this.scrollIndicatorDownImage != null) { //#if polish.css.scrollindicator-down-image if (this.scrollIndicatorUpImage != null) { y += this.scrollIndicatorUpImage.getHeight() + 1; } else { y += halfWidth; } //#else y += halfWidth; //#endif g.drawImage(this.scrollIndicatorDownImage, x, y, Graphics.LEFT | Graphics.TOP ); } else { //#endif //#ifdef polish.midp2 g.fillTriangle(x, y + halfWidth+1, x + width, y + halfWidth+1, x + halfWidth, y + width ); //#else g.drawLine( x, y + halfWidth+1, x + width, y + halfWidth+1 ); g.drawLine( x, y + halfWidth+1, x + halfWidth, y + width ); g.drawLine(x + width, y + halfWidth+1, x + halfWidth, y + width ); //#endif //#if polish.css.scrollindicator-down-image } //#endif } } //#endif //#ifdef polish.css.foreground-image if (this.foregroundImage != null) { g.drawImage( this.foregroundImage, this.foregroundX, this.foregroundY, Graphics.TOP | Graphics.LEFT ); } //#endif //#if polish.debug.error } catch (RuntimeException e) { //#debug error System.out.println( "unable to paint screen (" + getClass().getName() + "):" + e ); } //#endif } } /** * Paints the screen. * This method also needs to set the protected variables * paintScrollIndicator, paintScrollIndicatorUp and paintScrollIndicatorDown. * * @param g the graphics on which the screen should be painted * @see #contentX * @see #contentY * @see #contentWidth * @see #contentHeight * @see #paintScrollIndicator * @see #paintScrollIndicatorUp * @see #paintScrollIndicatorDown */ protected void paintScreen( Graphics g ) { int y = this.contentY; int x = this.contentX; int height = this.contentHeight; int width = this.contentWidth; int containerHeight = this.container.getItemHeight( width, width); //#if !tmp.useScrollBar this.paintScrollIndicator = false; // defaults to false //#endif if (containerHeight > height ) { //#if !tmp.useScrollBar this.paintScrollIndicator = true; this.paintScrollIndicatorUp = (this.container.yOffset != 0); //&& (this.container.focusedIndex != 0); this.paintScrollIndicatorDown = ( (this.container.focusedIndex != this.container.size() - 1) && (this.container.yOffset + containerHeight > height) ); //#endif } else if (this.isLayoutVCenter) { /* //#debug System.out.println("Screen: adjusting y from [" + y + "] to [" + ( y + (height - containerHeight) / 2) + "] - containerHeight=" + containerHeight); */ if (this.isLayoutVerticalShrink) { y = g.getClipY(); } else { y += ((height - containerHeight) / 2); } } else if (this.isLayoutBottom) { if (this.isLayoutVerticalShrink) { y = g.getClipY(); } else { y += (height - containerHeight); }// System.out.println("content: y=" + y + ", contentY=" + this.contentY + ", contentHeight="+ this.contentHeight + ", containerHeight=" + containerHeight); } int containerWidth = this.container.itemWidth; if (this.isLayoutCenter) { int diff = (width - containerWidth) / 2; x += diff; width -= (width - containerWidth); } else if (this.isLayoutRight) { int diff = width - containerWidth; x += diff; width -= diff; } this.containerX = x; this.containerY = y; //System.out.println("content: x=" + x + ", rightBorder=" + (x + width) ); this.container.paint( x, y, x, x + width, g ); } //#ifdef tmp.usingTitle /** * Gets the title of the Screen. * Returns null if there is no title. * * @return the title of this screen */ public String getTitle() { if (this.title == null) { return null; } else if ( !(this.title instanceof StringItem ) ) { return null; } else { return ((StringItem)this.title).getText(); } } //#endif //#ifdef tmp.usingTitle /** * Sets the title of the Screen. If null is given, removes the title. * * If the Screen is physically visible, the visible effect * should take place no later than immediately * after the callback or * <A HREF="../../../javax/microedition/midlet/MIDlet.html#startApp()"><CODE>startApp</CODE></A> * returns back to the implementation. * * @param s - the new title, or null for no title */ public void setTitle( String s) { setTitle( s, null ); } //#endif //#ifdef tmp.usingTitle /** * Sets the title of the Screen. If null is given, removes the title. * * If the Screen is physically visible, the visible effect * should take place no later than immediately * after the callback or * <A HREF="../../../javax/microedition/midlet/MIDlet.html#startApp()"><CODE>startApp</CODE></A> * returns back to the implementation. * * @param text the new title, or null for no title * @param tStyle the new style for the title, is ignored when null */ public void setTitle( String text, Style tStyle) { //#debug System.out.println("Setting title " + text ); //#ifdef tmp.ignoreMotorolaTitleCall if (text == null) { if (this.ignoreMotorolaTitleCall) { this.ignoreMotorolaTitleCall = false; return; } //return; } //#endif if (text != null) { //#style title, default this.title = new StringItem( null, text ); this.title.screen = this; if ( tStyle != null ) { this.title.setStyle( tStyle ); } //#ifdef polish.css.title-style else if (this.titleStyle != null) { this.title.setStyle( this.titleStyle ); } //#endif // the Nokia 6600 has an amazing bug - when trying to refer the // field screenWidth, it returns 0 in setTitle(). Obviously this works // in other phones and in the simulator, but not on the Nokia 6600. // That's why hardcoded values are used here. // The name of the field does not matter by the way. This is // a very interesting behaviour and should be analysed // at some point... //#ifdef polish.ScreenWidth:defined //#= int width = ${polish.ScreenWidth} - (this.marginLeft + this.marginRight); //#else int width = this.screenWidth - (this.marginLeft + this.marginRight); //#endif this.titleHeight = this.title.getItemHeight( width, width ); } else { this.title = null; this.titleHeight = 0; } if (this.isInitialised && isShown()) { calculateContentArea( 0, 0, this.screenWidth, this.screenHeight ); repaint(); } } //#endif /** * Sets an Item as the title for this screen. * WARNING: You must not call setTitle(String) after calling this method anymore! * * @param item the title Item */ public void setTitle(Item item) { //#ifdef tmp.usingTitle this.title = item; if (item != null){ //#ifdef polish.ScreenWidth:defined //#= int width = ${polish.ScreenWidth} - (this.marginLeft + this.marginRight); //#else int width = this.screenWidth - (this.marginLeft + this.marginRight); //#endif this.titleHeight = this.title.getItemHeight( width, width ); item.screen = this; } else { this.titleHeight = 0; } if (this.isInitialised && isShown()) { calculateContentArea( 0, 0, this.screenWidth, this.screenHeight ); repaint(); } //#endif } /** * Sets the information which should be shown to the user. * The info is shown below the title (if any) and can be designed * using the predefined style "info". * At the moment this feature is only used by the TextField implementation, * when the direct input mode is enabled. * A repaint is not triggered automatically by calling this method. * * @param infoText the text which will be shown to the user */ public void setInfo( String infoText ) { if (this.infoItem == null) { //#style info, default this.infoItem = new StringItem( null, infoText ); this.infoItem.screen = this; } else { this.infoItem.setText( infoText ); } if (infoText == null) { this.infoHeight = 0; this.showI
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -