📄 screen.java
字号:
//#endif return animated; } catch (Exception e) { //#debug error System.out.println("animate() threw an exception" + e ); return false; } } } /** * Paints the screen. * When you subclass Screen you should override paintScreen(Graphics g) instead, if possible. * * @param g the graphics context. * @see #paintScreen(Graphics) */ public void paint(Graphics g) { System.out.println("Painting screen "+ this + ", background == null: " + (this.background == null)); synchronized (this.paintLock ) { //#if polish.Bugs.losesFullScreen //# super.setFullScreenMode( true ); //#endif //#if tmp.fullScreenInPaint if (!this.isInFullScreenMode) { //# super.setFullScreenMode( true ); this.isInFullScreenMode = true; //#if tmp.menuFullScreen //#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 - this.menuBarHeight; //#endif } //#endif //#if !tmp.menuFullScreen int translateY = g.getTranslateY(); if (translateY != 0 && this.screenHeight == this.originalScreenHeight) { this.screenHeight -= translateY; //#if !tmp.useScrollBar this.scrollIndicatorY -= translateY; //#endif //#debug System.out.println("Adjusting screenheight from " + this.originalScreenHeight + " to " + this.screenHeight ); if (this.container != null) { int y = translateY; calculateContentArea( 0, y, this.screenWidth, this.screenHeight - y ); } } //#endif //#if tmp.fullScreen && polish.FullCanvasSize:defined && polish.Bugs.setClipForFullScreenNeeded g.translate( -g.getTranslateX(), -g.getTranslateY() ); //#= g.setClip( 0, 0, ${polish.FullCanvasWidth}, ${polish.FullCanvasHeight} ); //#endif //#if polish.debug.error try { //#endif //#if polish.css.repaint-previous-screen //#if polish.Screen.dontBufferPreviousScreen if (this.repaintPreviousScreen && this.previousScreen != null) { this.previousScreen.paint(g); //#if !polish.Bugs.noTranslucencyWithDrawRgb this.previousScreenOverlayBackground.paint(0, 0, this.screenWidth, this.screenHeight, g); //#endif } //#else if (this.repaintPreviousScreen && this.previousScreenImage != null) { g.drawImage(this.previousScreenImage, 0, 0, Graphics.TOP | Graphics.LEFT ); //#if !polish.Bugs.noTranslucencyWithDrawRgb this.previousScreenOverlayBackground.paint(0, 0, this.screenWidth, this.screenHeight, g); //#endif } //#endif //#endif int sWidth = this.screenWidth - this.marginLeft - this.marginRight; int leftBorder = this.marginLeft; int rightBorder = leftBorder + sWidth; if (this.isLayoutHorizontalShrink) { int contWidth = this.contentWidth; if (this.container != null) { contWidth = this.container.getItemWidth(sWidth, sWidth); } sWidth = contWidth; //System.out.println("is horizontal shrink - from sWidth=" + (this.screenWidth - this.marginLeft - this.marginRight) + ", to=" + sWidth ); if (this.isLayoutRight) { leftBorder = rightBorder - sWidth; } else if (this.isLayoutCenter) { leftBorder = (this.screenWidth - sWidth) / 2; rightBorder = this.screenWidth - leftBorder; } else { rightBorder = this.screenWidth - sWidth; } //System.out.println("leftBorder=" + leftBorder + ", rightBorder=" + rightBorder ); } //#ifdef tmp.menuFullScreen int sHeight = this.fullScreenHeight - this.marginTop - this.marginBottom; //#else //# int sHeight = this.screenHeight - this.marginTop - this.marginBottom; //#endif int topBorder = this.marginTop; if (this.isLayoutVerticalShrink) { int contHeight = this.contentHeight; if (this.container != null) { contHeight = this.container.getItemHeight(sWidth, sWidth); }// //#if tmp.menuFullScreen// sHeight = contHeight + this.titleHeight + this.menuBarHeight;// //#else sHeight = contHeight + this.titleHeight;// //#endif //System.out.println("isLayoutVerticalShrink - sHeight: from=" + (this.fullScreenHeight - this.marginTop - this.marginBottom) + ", to=" + sHeight + ", contentHeight=" + this.contentHeight + ", topBorder=" + topBorder ); if (this.isLayoutBottom) {// //#ifdef tmp.menuFullScreen// topBorder = this.fullScreenHeight - (this.marginBottom + sHeight + 1);// //#else topBorder = this.screenHeight - (this.marginBottom + sHeight + 1);// //#endif //System.out.println("bottom -> topBorder=" + topBorder + ", contY=>" + (topBorder + this.titleHeight) ); } else if (this.isLayoutVCenter) {// //#ifdef tmp.menuFullScreen// topBorder = (this.fullScreenHeight - (this.marginBottom + this.marginBottom))/2 - sHeight/2;// //#else topBorder = (this.screenHeight - (this.marginBottom + this.marginTop + sHeight))/2;// //#endif //System.out.println("vcenter -> topBorder=" + topBorder + ", contY=>" + (topBorder + this.titleHeight) ); } } // paint background: if (this.background != null) { int backgroundHeight = sHeight; int backgroundY = topBorder; //#ifdef tmp.menuFullScreen if (this.excludeMenuBarForBackground) { backgroundHeight = this.screenHeight - this.marginTop - this.marginBottom; } //#endif //#ifdef tmp.usingTitle if (this.excludeTitleForBackground) { backgroundHeight -= this.titleHeight; backgroundY += this.titleHeight; } //#endif // System.out.println("Screen (" + this + ": painting background at leftBorder=" + leftBorder + ", backgroundY=" + backgroundY); this.background.paint(leftBorder, backgroundY, sWidth, backgroundHeight, g); } else { //System.out.println("Screen (" + this + ": clearing area..."); int backgroundHeight = sHeight; int backgroundY = topBorder; //#ifdef tmp.menuFullScreen if (this.excludeMenuBarForBackground) { backgroundHeight = this.screenHeight - this.marginTop - this.marginBottom; } //#endif //#ifdef tmp.usingTitle if (this.excludeTitleForBackground) { backgroundHeight -= this.titleHeight; backgroundY += this.titleHeight; } //#endif g.setColor( 0xFFFFFF ); g.fillRect( leftBorder, backgroundY, sWidth, backgroundHeight ); } int topHeight = topBorder; //#ifdef tmp.usingTitle //#if polish.css.title-position if (this.paintTitleAtTop) { //#endif // paint title: if (this.title != null && this.showTitleOrMenu) { this.title.paint( leftBorder, topBorder, leftBorder, rightBorder, g); topHeight += this.titleHeight; } //#if polish.css.title-position } //#endif //#endif if (this.subTitle != null) { this.subTitle.paint( leftBorder, topHeight, leftBorder, rightBorder, g ); this.subTitle.yTopPos = topHeight; topHeight += this.subTitleHeight; this.subTitle.yBottomPos = topHeight; } //#ifndef polish.skipTicker //#if tmp.paintTickerAtTop if (this.ticker != null) { this.ticker.paint( leftBorder, topHeight, leftBorder, rightBorder, g); topHeight += this.ticker.itemHeight; } //#elif polish.css.ticker-position && !polish.TickerPosition:defined if (this.paintTickerAtTop && this.ticker != null) { this.ticker.paint( leftBorder, topHeight, leftBorder, rightBorder, g); topHeight += this.ticker.itemHeight; } //#endif //#endif int infoItemY = topHeight; //#if polish.clip-screen-info if (this.showInfoItem && this.clipScreenInfo) { topHeight += this.infoHeight; } //#endif //System.out.println("topHeight=" + topHeight + ", contentY=" + contentY); // protect the title, ticker and the full-screen-menu area: // int clipHeight = this.screenHeight - topHeight; // //#if tmp.menuFullScreen // int cHeight = this.fullScreenHeight - topHeight - this.marginBottom; // if (cHeight < clipHeight) { // clipHeight = cHeight; // } // //#endif g.setClip(leftBorder, topHeight, sWidth, this.screenHeight - topHeight ); // paint content: //System.out.println("starting to paint content of screen"); paintScreen( g ); //System.out.println("done painting content of screen"); //#if tmp.useScrollBar if (this.container != null && this.container.itemHeight > this.contentHeight) { // paint scroll bar: - this.container.yOffset //#debug System.out.println("Screen/ScrollBar: container.contentY=" + this.container.contentY + ", container.internalY=" + this.container.internalY + ", container.yOffset=" + this.container.yOffset + ", container.yTop=" + this.container.yTop + ", container.yTopPos=" + this.container.yTopPos); int scrollX = sWidth + this.marginLeft - this.scrollBar.initScrollBar(sWidth, this.contentHeight, this.container.itemHeight, this.container.yOffset, this.container.internalY, this.container.internalHeight, this.container.focusedIndex, this.container.size() ); //TODO allow scroll bar on the left side this.scrollBar.paint( scrollX, this.contentY, scrollX, rightBorder, g); } //#endif // allow painting outside of the screen again: //#ifdef tmp.menuFullScreen g.setClip(0, 0, this.screenWidth, this.fullScreenHeight ); //#else g.setClip(0, 0, this.screenWidth, this.originalScreenHeight ); //#endif // paint info element: if (this.showInfoItem) { this.infoItem.paint( this.marginLeft, infoItemY, this.marginLeft, rightBorder, g ); } int bottomY = this.contentY + this.contentHeight; //#ifndef polish.skipTicker //#if tmp.paintTickerAtBottom if (this.ticker != null) { this.ticker.paint( this.marginLeft, bottomY, this.marginLeft, rightBorder, g); bottomY += this.ticker.itemHeight; } //#elif polish.css.ticker-position && !polish.TickerPosition:defined if (!this.paintTickerAtTop && this.ticker != null) { this.ticker.paint( this.marginLeft, bottomY, this.marginLeft, rightBorder, g); bottomY += this.ticker.itemHeight; } //#endif //#endif //#if tmp.usingTitle && polish.css.title-position if (!this.paintTitleAtTop) { // paint title: if (this.title != null && this.showTitleOrMenu) { this.title.paint( leftBorder, bottomY, leftBorder, rightBorder, g); //bottomY += this.titleHeight; } } //#endif // 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 = Locale.get( "polish.command.select" ); //#elifdef polish.command.select:defined //#= menuText = "${polish.command.select}"; //#else menuText = "Select"; //#endif } else { if (this.menuSingleLeftCommand != null) { menuText = this.menuSingleLeftCommand.getLabel();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -