📄 screen.java
字号:
//# System.out.println("showNotify " + this + " isInitialised=" + this.isInitialized);
try {
//#ifdef polish.Screen.showNotifyCode:defined
//#include ${polish.Screen.showNotifyCode}
//#endif
//#if tmp.fullScreen && polish.midp2 && polish.Bugs.fullScreenInShowNotify
//# super.setFullScreenMode( true );
//#ifdef polish.FullCanvasHeight:defined
//#= this.fullScreenHeight = ${polish.FullCanvasHeight};
//#else
//# this.fullScreenHeight = getHeight();
//#endif
//# this.screenHeight = this.fullScreenHeight - this.menuBarHeight;
//# this.originalScreenHeight = this.screenHeight;
//# this.scrollIndicatorY = this.screenHeight + 1; //- this.scrollIndicatorWidth - 1;
//#endif
if (!this.isInitialized) {
init();
}
//#if polish.css.repaint-previous-screen
if (this.repaintPreviousScreen) {
Displayable currentDisplayable = StyleSheet.display.getCurrent();
if (currentDisplayable == this) {
currentDisplayable = StyleSheet.currentScreen;
}
//#if polish.Screen.dontBufferPreviousScreen
//# if ( currentDisplayable != this && currentDisplayable instanceof AccessibleCanvas) {
//# this.previousScreen = (AccessibleCanvas) currentDisplayable;
//#if !polish.Bugs.noTranslucencyWithDrawRgb
//#if polish.color.overlay:defined
//#= this.previousScreenOverlayBackground = new TranslucentSimpleBackground( ${polish.color.overlay} );
//#else
//# this.previousScreenOverlayBackground = new TranslucentSimpleBackground( 0xAA000000 );
//#endif
//#endif
//# }
//#else
if ( currentDisplayable != this && currentDisplayable instanceof AccessibleCanvas ) {
if (this.previousScreenImage == null) {
//#if tmp.menuFullScreen
//# this.previousScreenImage = Image.createImage( this.screenWidth, this.fullScreenHeight);
//#else
this.previousScreenImage = Image.createImage( this.screenWidth, this.screenHeight);
//#endif
}
//#debug
//# System.out.println("storing previous screen " + currentDisplayable + " to image buffer...");
Graphics g = this.previousScreenImage.getGraphics();
((AccessibleCanvas)currentDisplayable).paint(g);
//#if !polish.Bugs.noTranslucencyWithDrawRgb
//#if polish.color.overlay:defined
//#= this.previousScreenOverlayBackground = new TranslucentSimpleBackground( ${polish.color.overlay} );
//#else
this.previousScreenOverlayBackground = new TranslucentSimpleBackground( 0xAA000000 );
//#endif
//#endif
}
//#endif
}
//#endif
// inform all root items that they belong to this screen
// and that they will be shown soon:
Item[] items = getRootItems();
for (int i = 0; i < items.length; i++) {
Item item = items[i];
item.screen = this;
item.showNotify();
}
if (this.container != null) {
this.container.showNotify();
}
//#if tmp.ignoreMotorolaTitleCall
//# this.ignoreMotorolaTitleCall = true;
//#endif
//#if tmp.fullScreen && polish.midp2 && !polish.blackberry
//# // this is needed on Sony Ericsson for example,
//# // since the fullscreen mode is not resumed automatically
//# // when the previous screen was in the "normal" mode:
//#if ! tmp.fullScreenInPaint
//# super.setFullScreenMode( true );
//#endif
//#endif
// init components:
int width = this.screenWidth - (this.marginLeft + this.marginRight);
//#ifdef tmp.menuFullScreen
//#ifdef tmp.useExternalMenuBar
//# if (!this.menuBar.isInitialized) {
//# this.menuBar.init( width, width );
//# }
//#else
//# if (this.menuOpened) {
//# if (!this.menuContainer.isInitialized) {
//# this.menuContainer.init( width, width );
//# }
//# } else
//#endif
//#endif
if (this.container != null && !this.container.isInitialized) {
this.container.init( width, width );
}
//#ifdef tmp.usingTitle
if (this.title != null && !this.title.isInitialized) {
this.title.init( width, width );
}
//#endif
//#ifndef polish.skipTicker
//# if (this.ticker != null && !this.ticker.isInitialized) {
//# this.ticker.init( width, width );
//# }
//#endif
calculateContentArea(0, 0, this.screenWidth, this.screenHeight);
} catch (Exception e) {
//#debug error
//# System.out.println("error while calling showNotify" + e );
}
// register this screen:
StyleSheet.currentScreen = this;
//#ifdef polish.Vendor.Siemens
//# this.showNotifyTime = System.currentTimeMillis();
//#endif
//#if polish.ScreenInfo.enable
//# ScreenInfo.setScreen( this );
//#endif
}
/**
* Unregisters this screen and notifies all items that they will not be shown anymore.
*/
public void hideNotify() {
//#if polish.css.repaint-previous-screen
//#if polish.Screen.dontBufferPreviousScreen
//# this.previousScreen = null;
//#else
this.previousScreenImage = null;
//#endif
//#if !polish.Bugs.noTranslucencyWithDrawRgb
this.previousScreenOverlayBackground = null;
//#endif
//#endif
//#ifdef polish.Vendor.Siemens
//# // Siemens sometimes calls hideNotify directly
//# // after showNotify for some reason.
//# // So hideNotify checks how long the screen
//# // has been shown - if not long enough,
//# // the call will be ignored:
//# if (System.currentTimeMillis() - this.showNotifyTime < 500) {
//#debug
//# System.out.println("Ignoring hideNotify on Siemens");
//# return;
//# }
//#endif
//#debug
//# System.out.println("hideNotify " + this);
//#if !polish.css.repaint-previous-screen
//# // un-register this screen:
//# if (StyleSheet.currentScreen == this) {
//# StyleSheet.currentScreen = null;
//# }
//#endif
Item[] items = getRootItems();
for (int i = 0; i < items.length; i++) {
Item item = items[i];
item.hideNotify();
}
if (this.container != null) {
this.container.hideNotify();
}
//#ifdef tmp.ignoreMotorolaTitleCall
//# this.ignoreMotorolaTitleCall = true;
//#endif
//#if polish.ScreenInfo.enable
//# // de-register screen from ScreenInfo element:
//# if (ScreenInfo.item.screen == this ) {
//# ScreenInfo.setScreen( null );
//# }
//#endif
}
/**
* Sets the style of this screen.
*
* @param style the style
*/
public void setStyle(Style style) {
if (style != this.style && this.style != null ) {
this.style.releaseResources();
}
//#debug
//# System.out.println("Setting screen-style for " + getClass().getName() );
this.style = style;
this.background = style.background;
this.border = style.border;
this.marginTop = style.marginTop;
this.marginBottom = style.marginBottom;
this.marginLeft = style.marginRight;
this.marginRight = style.marginRight;
if (this.container != null) {
// use the same style for the container - but ignore the background and border settings:
this.container.setStyle(style, true);
}
this.isLayoutVCenter = (( style.layout & Item.LAYOUT_VCENTER ) == Item.LAYOUT_VCENTER);
this.isLayoutBottom = !this.isLayoutVCenter
&& (( style.layout & Item.LAYOUT_BOTTOM ) == Item.LAYOUT_BOTTOM);
this.isLayoutCenter = (( style.layout & Item.LAYOUT_CENTER ) == Item.LAYOUT_CENTER);
this.isLayoutRight = !this.isLayoutCenter
&& (( style.layout & Item.LAYOUT_RIGHT ) == Item.LAYOUT_RIGHT);
this.isLayoutHorizontalShrink = (style.layout & Item.LAYOUT_SHRINK) == Item.LAYOUT_SHRINK;
this.isLayoutVerticalShrink = (style.layout & Item.LAYOUT_VSHRINK) == Item.LAYOUT_VSHRINK;
//#if polish.css.scrollindicator-up-image && tmp.useScrollIndicator
//# String scrollUpUrl = style.getProperty(102);
//# if (scrollUpUrl != null) {
//# try {
//# this.scrollIndicatorUpImage = StyleSheet.getImage(scrollUpUrl, null, true);
//# } catch (IOException e) {
//#debug error
//# System.out.println("Unable to load scroll up image" + e );
//# }
//# } else {
//# this.scrollIndicatorUpImage = null;
//# }
//#endif
//#if polish.css.scrollindicator-down-image && tmp.useScrollIndicator
//# String scrollDownUrl = style.getProperty(103);
//# if (scrollDownUrl != null) {
//# try {
//# this.scrollIndicatorDownImage = StyleSheet.getImage(scrollDownUrl, null, true);
//# } catch (IOException e) {
//#debug error
//# System.out.println("Unable to load scroll down image" + e );
//# }
//# } else {
//# this.scrollIndicatorDownImage = null;
//# }
//#endif
//#if polish.css.scrollindicator-up-image && polish.css.scrollindicator-down-image && tmp.useScrollIndicator
//# if (this.scrollIndicatorUpImage != null && this.scrollIndicatorDownImage != null) {
//# int height = this.scrollIndicatorUpImage.getHeight() + this.scrollIndicatorDownImage.getHeight();
//# int width = Math.max( this.scrollIndicatorUpImage.getWidth(), this.scrollIndicatorDownImage.getWidth() );
//# this.scrollIndicatorWidth = width;
//# this.scrollIndicatorX = this.screenWidth / 2 - width / 2;
//#ifdef tmp.menuFullScreen
//#ifdef tmp.useExternalMenuBar
//# this.scrollIndicatorY = this.fullScreenHeight - (this.menuBar.marginBottom + 1 + height);
//#else
//# this.scrollIndicatorY = this.fullScreenHeight - (height + 1);
//#endif
//#elif polish.vendor.Siemens
//# // set the position of scroll indicator for Siemens devices
//# // on the left side, so that the menu-indicator is visible:
//# this.scrollIndicatorWidth = width;
//# this.scrollIndicatorX = 0;
//# this.scrollIndicatorY = this.screenHeight - height - 1;
//#else
//# // set position of scroll indicator:
//# this.scrollIndicatorWidth = width;
//# this.scrollIndicatorX = this.screenWidth - width - 1;
//# this.scrollIndicatorY = this.screenHeight - height - 1;
//#endif
//# }
//#endif
//#if polish.css.scrollindicator-color && tmp.useScrollIndicator
//# Integer scrollIndicatorColorInt = style.getIntProperty( 36 );
//# if (scrollIndicatorColorInt != null) {
//# this.scrollIndicatorColor = scrollIndicatorColorInt.intValue();
//# }
//#endif
//#if tmp.usingTitle && polish.css.title-style
//# this.titleStyle = (Style) style.getObjectProperty(2);
//# if (this.titleStyle != null && this.title != null) {
//# this.title.setStyle(this.titleStyle);
//# int width = this.screenWidth - (this.marginLeft + this.marginRight);
//# this.titleHeight = this.title.getItemHeight( width, width );
//# } else {
//#endif
//#if tmp.usingTitle
if (this.title != null && this.title.isInitialized) {
this.title.isInitialized = false;
int width = this.screenWidth - (this.marginLeft + this.marginRight);
this.titleHeight = this.title.getItemHeight( width, width );
}
//#endif
//#if tmp.usingTitle && polish.css.title-style
//# }
//#endif
//#if tmp.usingTitle && polish.css.title-position
//# Integer titlePositionInt = style.getIntProperty(115);
//# if (titlePositionInt == null && this.title != null && this.title.style != null) {
//# titlePositionInt = this.title.style.getIntProperty(115);
//# }
//# if (titlePositionInt != null) {
//# this.paintTitleAtTop = (titlePositionInt.intValue() == POSITION_TOP);
//# }
//#
//#endif
//#if tmp.useScrollBar && polish.css.scrollbar-style
//# Style scrollbarStyle = (Style) style.getObjectProperty(126);
//# if (scrollbarStyle != null) {
//# this.scrollBar.setStyle( scrollbarStyle );
//# }
//#endif
//#if tmp.useScrollBar && polish.css.scrollbar-position
//# Integer scrollBarPositionInt = style.getIntProperty( 118 );
//# if (scrollBarPositionInt == null && this.scrollBar.style != null) {
//# scrollBarPositionInt = this.scrollBar.style.getIntProperty( 118 );
//# }
//# if (scrollBarPositionInt != null) {
//# this.paintScrollBarOnRightSide = (scrollBarPositionInt.intValue() != POSITION_LEFT);
//# }
//#endif
//#ifdef polish.css.foreground-image
//# String foregroundImageUrl = this.style.getProperty(52);
//# if (foregroundImageUrl == null) {
//# this.foregroundImage = null;
//# } else {
//# try {
//# this.foregroundImage = StyleSheet.getImage(foregroundImageUrl, null,true);
//#ifdef polish.css.foreground-x
//# Integer xInteger = this.style.getIntProperty(53);
//# if (xInteger != null) {
//# this.foregroundX = xInteger.intValue();
//# }
//#endif
//#ifdef polish.css.foreground-y
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -