📄 screen.java
字号:
// paint border:
if (this.border != null) {
// //#ifdef tmp.menuFullScreen
// this.border.paint(this.marginLeft, this.marginTop, sWidth, this.screenHeight - this.marginBottom - this.marginTop, g);
// //#else
this.border.paint(leftBorder, this.marginTop, sWidth, sHeight, g);
// //#endif
}
//#if polish.ScreenInfo.enable == true
//# ScreenInfo.paint( g, topHeight, this.screenWidth );
//#endif
// paint menu in full-screen mode:
int menuLeftX = 0;
int menuRightX = this.screenWidth;
int menuY = this.screenHeight; // + this.marginBottom;
//#if polish.css.separate-menubar
//# if (!this.separateMenubar) {
//# menuLeftX = leftBorder;
//# menuRightX = rightBorder;
//# menuY = this.screenHeight - this.marginBottom;
//# }
//#endif
//#ifdef tmp.menuFullScreen
//#ifdef tmp.useExternalMenuBar
//# this.menuBar.paint(menuLeftX, menuY, menuLeftX, menuRightX, g);
//#if !tmp.useScrollBar
//# if (this.menuBar.isOpened) {
//# this.paintScrollIndicator = this.menuBar.paintScrollIndicator;
//# this.paintScrollIndicatorUp = this.menuBar.canScrollUpwards;
//# this.paintScrollIndicatorDown = this.menuBar.canScrollDownwards;
//# }
//#endif
//#else
if (this.menuOpened) {
topHeight -= this.infoHeight;
int menuHeight = this.menuContainer.getItemHeight(this.screenWidth, this.screenWidth);
int y = this.originalScreenHeight - (menuHeight + 1);
if (y < topHeight) {
//#if !tmp.useScrollBar
this.paintScrollIndicator = true;
this.paintScrollIndicatorUp = (this.menuContainer.yOffset != 0);
this.paintScrollIndicatorDown = ( (this.menuContainer.focusedIndex != this.menuContainer.size() - 1)
&& (this.menuContainer.yOffset + menuHeight > this.originalScreenHeight - topHeight)) ;
//#endif
y = topHeight;
//#if !tmp.useScrollBar
} else {
this.paintScrollIndicator = false;
//#endif
}
this.menuContainer.setVerticalDimensions(topHeight, this.originalScreenHeight);
g.setClip(0, topHeight, this.screenWidth, this.originalScreenHeight - topHeight );
this.menuContainer.paint(menuLeftX, y, menuLeftX, menuLeftX + this.screenWidth, g);
g.setClip(0, 0, this.screenWidth, this.fullScreenHeight );
}
if (this.showTitleOrMenu || this.menuOpened) {
// clear menu-bar:
if (this.menuBarColor != Item.TRANSPARENT) {
g.setColor( this.menuBarColor );
//TODO check use menuY instead of this.originalScreenHeight?
g.fillRect(menuLeftX, this.originalScreenHeight, menuRightX, this.menuBarHeight );
}
if (this.menuContainer != null && this.menuContainer.size() > 0) {
String menuText = null;
if (this.menuOpened) {
//#ifdef polish.i18n.useDynamicTranslations
//# menuText = "Select";
//#elifdef polish.command.select:defined
menuText = "Select";
//#else
//# menuText = "Select";
//#endif
} else {
if (this.menuSingleLeftCommand != null) {
menuText = this.menuSingleLeftCommand.getLabel();
} else {
//#ifdef polish.i18n.useDynamicTranslations
//# menuText = "Options";
//#elifdef polish.command.options:defined
menuText = "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 = "Cancel";
//#elifdef polish.command.cancel:defined
menuText = "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
de.enough.polish.util.Debug.debug("error", "de.enough.polish.ui.Screen", 1540, "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
de.enough.polish.util.Debug.debug("debug", "de.enough.polish.ui.Screen", 1580, "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 f
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -