📄 screen.java
字号:
super();
//#if !(polish.Bugs.fullScreenInShowNotify || polish.Bugs.fullScreenInPaint || tmp.needsNokiaUiForSystemAlerts)
//#if tmp.fullScreen && polish.midp2
//# super.setFullScreenMode( true );
//#endif
//#endif
// get the screen dimensions:
// this is a bit complicated, since Nokia's FullCanvas fucks
// up when calling super.getHeight(), so we need to use hardcoded values...
//#ifdef tmp.menuFullScreen
//#if polish.needsManualMenu && !tmp.fullScreen
//# this.fullScreenHeight = getHeight();
//#else
//#if tmp.needsNokiaUiForSystemAlerts
//#ifdef polish.NokiaFullCanvasHeight:defined
//#= this.fullScreenHeight = ${ polish.NokiaFullCanvasHeight };
//#else
//# this.fullScreenHeight = getHeight();
//#endif
//#else
//#ifdef polish.FullCanvasHeight:defined
//#= this.fullScreenHeight = ${ polish.FullCanvasHeight };
//#else
//# this.fullScreenHeight = getHeight();
//#endif
//#endif
//#endif
//# this.screenHeight = this.fullScreenHeight;
//#else
this.screenHeight = getHeight();
//#endif
this.originalScreenHeight = this.screenHeight;
//#ifdef polish.ScreenWidth:defined
//#= this.screenWidth = ${ polish.ScreenWidth };
//#else
this.screenWidth = getWidth();
//#endif
//#if tmp.useScrollBar
//# this.scrollBar.screen = this;
//#endif
// creating standard container:
if (createDefaultContainer) {
this.container = new Container( true );
this.container.screen = this;
this.container.isFocused = true;
}
this.style = style;
this.forwardCommandListener = new ForwardCommandListener();
//#ifndef tmp.menuFullScreen
super.setCommandListener(this.forwardCommandListener);
//#endif
//#ifdef tmp.useExternalMenuBar
//#style menubar, menu, default
//# this.menuBar = new MenuBar( this );
//#endif
setTitle( title );
}
/**
* Initialises this screen before it is painted for the first time.
*/
private void init() {
//#debug
//# System.out.println("Initialising screen " + this );
boolean startAnimationThread = false;
if (StyleSheet.animationThread == null) {
StyleSheet.animationThread = new AnimationThread();
startAnimationThread = true;
}
//#ifdef polish.Screen.initCode:defined
//#include ${polish.Screen.initCode}
//#endif
if (this.style != null) {
setStyle( this.style );
}
//#ifdef polish.useDynamicStyles
//# // check if this screen has got a style:
//# if (this.style == null) {
//# this.cssSelector = createCssSelector();
//# setStyle( StyleSheet.getStyle( this ) );
//# } else {
//# this.cssSelector = this.style.name;
//# }
//#endif
//#ifdef tmp.menuFullScreen
//#ifdef tmp.useExternalMenuBar
//# int availableScreenWidth = this.screenWidth;
//#if polish.css.separate-menubar
//# if (!this.separateMenubar) {
//# availableScreenWidth -= (this.marginLeft + this.marginRight);
//# }
//#endif
//#
//# this.menuBarHeight = this.menuBar.getItemHeight( availableScreenWidth, availableScreenWidth );
//#if tmp.useScrollIndicator
//# int scrollWidth = this.menuBar.contentHeight + this.menuBar.paddingTop + this.menuBar.paddingBottom;
//# int scrollHeight = scrollWidth;
//#if polish.css.scrollindicator-up-image
//# if (this.scrollIndicatorUpImage != null) {
//# scrollWidth = this.scrollIndicatorUpImage.getWidth();
//# scrollHeight = this.scrollIndicatorUpImage.getHeight();
//# }
//#elif polish.css.scrollindicator-down-image
//# if (this.scrollIndicatorDownImage != null) {
//# scrollWidth = this.scrollIndicatorDownImage.getWidth();
//# scrollHeight = this.scrollIndicatorDownImage.getHeight();
//# }
//#endif
//# this.scrollIndicatorWidth = scrollWidth;
//# this.scrollIndicatorHeight = scrollHeight;
//# this.scrollIndicatorX = (this.screenWidth >> 1) - (scrollWidth >> 1);
//# int space = Math.max( 0, this.menuBarHeight - ((scrollHeight << 1) + 1) );
//# //System.out.println("space=" + space + ", menubarHEIGHT="+ this.menuBarHeight);
//# this.scrollIndicatorY = (this.fullScreenHeight - this.menuBarHeight) + (space >> 1);
//#endif
//# //System.out.println("without ExternalMenu: scrollIndicatorY=" + this.scrollIndicatorY + ", screenHeight=" + this.screenHeight + ", FullScreenHeight=" + this.fullScreenHeight );
//# //System.out.println("Screen.init: menuBarHeight=" + this.menuBarHeight + " scrollIndicatorWidth=" + this.scrollIndicatorWidth );
//#else
//#ifdef polish.css.style.menu
//# Style menustyle = StyleSheet.menuStyle;
//#else
//# Style menustyle = this.style;
//#endif
//# if (menustyle != null) {
//# Integer colorInt = null;
//# if (this.style != null) {
//# colorInt = this.style.getIntProperty(16);
//# }
//# if (colorInt == null) {
//# colorInt = menustyle.getIntProperty(16);
//# }
//# if (colorInt != null) {
//# this.menuBarColor = colorInt.intValue();
//# }
//# this.menuFontColor = menustyle.getFontColor();
//# if (menustyle.font != null) {
//# this.menuFont = menustyle.font;
//# } else {
//# this.menuFont = Font.getFont( Font.FACE_SYSTEM, Font.STYLE_BOLD, Font.SIZE_MEDIUM );
//# }
//# } else {
//# this.menuFont = Font.getFont( Font.FACE_SYSTEM, Font.STYLE_BOLD, Font.SIZE_MEDIUM );
//# }
//# int localMenuBarHeight = this.menuFont.getHeight();
//#ifdef polish.MenuBar.PaddingBottom:defined
//#= localMenuBarHeight += ${polish.MenuBar.PaddingBottom};
//#endif
//#ifdef polish.MenuBar.PaddingTop:defined
//#= localMenuBarHeight += ${polish.MenuBar.PaddingTop};
//#endif
//#if !polish.MenuBar.PaddingBottom:defined && !polish.MenuBar.PaddingTop:defined
//# localMenuBarHeight += 2;
//#endif
//#if tmp.useScrollIndicator
//# int scrollWidth = localMenuBarHeight;
//# int scrollHeight = scrollWidth >> 1;
//#if polish.css.scrollindicator-up-image
//# if (this.scrollIndicatorUpImage != null) {
//# scrollWidth = this.scrollIndicatorUpImage.getWidth();
//# scrollHeight = this.scrollIndicatorUpImage.getHeight();
//# }
//#elif polish.css.scrollindicator-down-image
//# if (this.scrollIndicatorDownImage != null) {
//# scrollWidth = this.scrollIndicatorDownImage.getWidth();
//# scrollHeight = this.scrollIndicatorDownImage.getHeight();
//# }
//#endif
//# this.scrollIndicatorWidth = scrollWidth;
//# this.scrollIndicatorHeight = scrollHeight;
//# this.scrollIndicatorX = this.screenWidth / 2 - scrollWidth / 2;
//# int space = Math.max( 0, localMenuBarHeight - ((scrollHeight << 1) + 1) );
//# this.scrollIndicatorY = (this.fullScreenHeight - localMenuBarHeight) + (space >> 1);
//#endif
//# //System.out.println("without ExternalMenu: scrollIndicatorY=" + this.scrollIndicatorY + ", screenHeight=" + this.screenHeight + ", FullScreenHeight=" + this.fullScreenHeight + ", localMenuBarHeight=" + localMenuBarHeight);
//#ifdef polish.MenuBar.MarginBottom:defined
//#= localMenuBarHeight += ${polish.MenuBar.MarginBottom};
//#= this.scrollIndicatorY -= ${polish.MenuBar.MarginBottom};
//#endif
//#ifdef polish.MenuBar.MarginTop:defined
//#= localMenuBarHeight += ${polish.MenuBar.MarginTop};
//#endif
//#if polish.doja
//# localMenuBarHeight = 0;
//#endif
//# this.menuBarHeight = localMenuBarHeight;
//# updateMenuTexts();
//#endif
//# int diff = this.originalScreenHeight - this.screenHeight;
//# this.originalScreenHeight = this.fullScreenHeight - this.menuBarHeight;
//# this.screenHeight = this.originalScreenHeight - diff;
//# // set position of scroll indicator:
//#elif polish.vendor.Siemens && tmp.useScrollIndicator
//# // set the position of scroll indicator for Siemens devices
//# // on the left side, so that the menu-indicator is visible:
//# int scrollWidth = 12;
//#if polish.css.scrollindicator-up-image
//# if (this.scrollIndicatorUpImage != null) {
//# scrollWidth = this.scrollIndicatorUpImage.getWidth();
//# }
//#elif polish.css.scrollindicator-down-image
//# if (this.scrollIndicatorDownImage != null) {
//# scrollWidth = this.scrollIndicatorDownImage.getWidth();
//# }
//#endif
//# this.scrollIndicatorWidth = scrollWidth;
//# this.scrollIndicatorX = 0;
//# this.scrollIndicatorY = this.screenHeight - (this.scrollIndicatorWidth + 1);
//#elif tmp.useScrollIndicator
// set position of scroll indicator:
int scrollWidth = 12;
//#if polish.css.scrollindicator-up-image
//# if (this.scrollIndicatorUpImage != null) {
//# scrollWidth = this.scrollIndicatorUpImage.getWidth();
//# }
//#elif polish.css.scrollindicator-down-image
//# if (this.scrollIndicatorDownImage != null) {
//# scrollWidth = this.scrollIndicatorDownImage.getWidth();
//# }
//#endif
this.scrollIndicatorWidth = scrollWidth;
this.scrollIndicatorX = this.screenWidth - this.scrollIndicatorWidth;
this.scrollIndicatorY = this.screenHeight - (this.scrollIndicatorWidth + 1);
//#endif
//System.out.println("final: scrollIndicatorY=" + this.scrollIndicatorY + ", screenHeight=" + this.screenHeight + ", FullScreenHeight=" + this.fullScreenHeight );
if (this.container != null) {
this.container.screen = this;
}
//#if !tmp.menuFullScreen
this.screenHeight = getHeight();
//#elif tmp.useExternalMenuBar
//# this.menuBar.relativeY = this.screenHeight;
//#endif
calculateContentArea( 0, 0, this.screenWidth, this.screenHeight );
// start the animmation thread if necessary:
if (startAnimationThread) {
StyleSheet.animationThread.start();
}
this.isInitialized = true;
}
/**
* Calculates and sets the content area for this screen.
* Usually no items are painted outside of the specified area.
* This method knows about the title, subtitle, infoarea and ticker
* and adjusts the content area accordingly
*
* @param x left start of the content area, might later be adjusted by an external scrollindicator
* @param y top start of the content area, is adjusted by the top margin, title height, subtitle height,
* info height and maybe ticker height (when the ticker should be painted at the top).
* @param width width of the content area, might later be adjusted by an external scrollindicator
* @param height height of the content area, is adjusted by the title height, subtitle height,
* info height and ticker height.
*/
protected void calculateContentArea( int x, int y, int width, int height ) {
//#debug
//# System.out.println("calculateContentArea(" + x + ", " + y + ", " + width + ", " + height + ")");
x += this.marginLeft;
width -= this.marginLeft + this.marginRight;
y += this.marginTop;
height -= this.marginTop; // + this.marginBottom;
//#if !polish.css.title-position || !tmp.usingTitle
int topHeight = this.titleHeight + this.subTitleHeight + this.infoHeight;
//#else
//# int topHeight = this.subTitleHeight + this.infoHeight;
//# if (this.paintTitleAtTop) {
//# topHeight += this.titleHeight;
//# } else {
//# height -= this.titleHeight;
//# }
//#endif
y += topHeight;
//#ifndef polish.skipTicker
//# int tickerHeight = 0;
//# if (this.ticker != null) {
//# tickerHeight = this.ticker.getItemHeight( width, width );
//# }
//# height -= topHeight + tickerHeight;
//#else
height -= topHeight;
//#endif
//#if tmp.useScrollBar
//# if ( this.container != null ) {
//# this.scrollBar.scrollBarHeight = height;
//# //System.out.println("calculateContentArea for " + this + ": container.isInitialised=" + this.container.isInitialised );
//# int scrollBarWidth = this.scrollBar.getItemWidth(width, width);
//# int containerHeight = this.container.getItemHeight(width - scrollBarWidth, width - scrollBarWidth);
//# if (containerHeight > height) {
//# //System.out.println("calculateContentArea for" + this + ": scrollBar is required for containerHeight of " + containerHeight + ", availableHeight=" + height );
//# width -= scrollBarWidth;
//# } else {
//# //System.out.println("calculateContentArea for" + this + ": scrollBar is NOT required for containerHeight of " + containerHeight + ", availableHeight=" + height );
//# this.container.requestFullInit();
//# }
//# }
//#endif
// now set the content coordinates:
this.contentX = x;
//#ifndef polish.skipTicker
//#if tmp.paintTickerAtTop
//# y += tickerHeight;
//#elif polish.css.ticker-position && !polish.TickerPosition:defined
//# if (this.paintTickerAtTop) {
//# y += tickerHeight;
//# }
//#endif
//#endif
this.contentY = y;
this.contentWidth = width;
this.contentHeight = height;
//#debug
//# System.out.println("calculateContentArea: x=" + this.contentX + ", y=" + this.contentY + ", width=" + this.contentWidth + ", height=" + this.contentHeight);
if (this.container != null) {
this.container.setScrollHeight( height );
}
}
/**
* Initialises this screen and informs all items about being painted soon.
*/
public void showNotify() {
//#debug
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -