< prev index next >

src/java.desktop/unix/classes/sun/awt/X11/XChoicePeer.java

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 40,50 **** // Note: can't set x,y on layout(), 'cause moving the top-level to the // edge of the screen won't call layout(). Just do it on paint, I guess // TODO: make painting more efficient (i.e. when down arrow is pressed, only two items should need to be repainted. ! public class XChoicePeer extends XComponentPeer implements ChoicePeer, ToplevelStateListener { private static final PlatformLogger log = PlatformLogger.getLogger("sun.awt.X11.XChoicePeer"); private static final int MAX_UNFURLED_ITEMS = 10; // Maximum number of // items to be displayed // at a time in an --- 40,50 ---- // Note: can't set x,y on layout(), 'cause moving the top-level to the // edge of the screen won't call layout(). Just do it on paint, I guess // TODO: make painting more efficient (i.e. when down arrow is pressed, only two items should need to be repainted. ! public final class XChoicePeer extends XComponentPeer implements ChoicePeer, ToplevelStateListener { private static final PlatformLogger log = PlatformLogger.getLogger("sun.awt.X11.XChoicePeer"); private static final int MAX_UNFURLED_ITEMS = 10; // Maximum number of // items to be displayed // at a time in an
*** 739,757 **** if (unfurled && oldState != newState){ hidePopdownMenu(); } } /**************************************************************************/ /* Common functionality between List & Choice /**************************************************************************/ /** * Inner class for the unfurled Choice list * Much, much more docs */ ! class UnfurledChoice extends XWindow /*implements XScrollbarClient*/ { // First try - use Choice as the target public UnfurledChoice(Component target) { super(target); --- 739,767 ---- if (unfurled && oldState != newState){ hidePopdownMenu(); } } + @Override + protected void initGraphicsConfiguration() { + super.initGraphicsConfiguration(); + // The popup have the same graphic config, so update it at the same time + if (unfurledChoice != null) { + unfurledChoice.initGraphicsConfiguration(); + unfurledChoice.doValidateSurface(); + } + } + /**************************************************************************/ /* Common functionality between List & Choice /**************************************************************************/ /** * Inner class for the unfurled Choice list * Much, much more docs */ ! final class UnfurledChoice extends XWindow /*implements XScrollbarClient*/ { // First try - use Choice as the target public UnfurledChoice(Component target) { super(target);
*** 783,793 **** else { int numItems = helper.getItemCount(); numItemsDisplayed = Math.min(MAX_UNFURLED_ITEMS, numItems); } Point global = XChoicePeer.this.toGlobal(0,0); ! Rectangle screen = graphicsConfig.getBounds(); if (alignUnder != null) { Rectangle choiceRec = XChoicePeer.this.getBounds(); choiceRec.setLocation(0, 0); choiceRec = XChoicePeer.this.toGlobal(choiceRec); --- 793,803 ---- else { int numItems = helper.getItemCount(); numItemsDisplayed = Math.min(MAX_UNFURLED_ITEMS, numItems); } Point global = XChoicePeer.this.toGlobal(0,0); ! Rectangle screenBounds = graphicsConfig.getBounds(); if (alignUnder != null) { Rectangle choiceRec = XChoicePeer.this.getBounds(); choiceRec.setLocation(0, 0); choiceRec = XChoicePeer.this.toGlobal(choiceRec);
*** 805,827 **** width = Math.max(XChoicePeer.this.width, helper.getMaxItemWidth() + 2 * (BORDER_WIDTH + ITEM_MARGIN + TEXT_SPACE) + (helper.isVSBVisible() ? SCROLLBAR_WIDTH : 0)); height = 2*BORDER_WIDTH + numItemsDisplayed*(helper.getItemHeight()+2*ITEM_MARGIN); } ! // Don't run off the edge of the screen ! if (x < 0) { ! x = 0; } ! else if (x + width > screen.width) { ! x = screen.width - width; } ! if (y + height > screen.height) { y = global.y - height; } ! if (y < 0) { ! y = 0; } return new Rectangle(x, y, width, height); } public void toFront() { --- 815,837 ---- width = Math.max(XChoicePeer.this.width, helper.getMaxItemWidth() + 2 * (BORDER_WIDTH + ITEM_MARGIN + TEXT_SPACE) + (helper.isVSBVisible() ? SCROLLBAR_WIDTH : 0)); height = 2*BORDER_WIDTH + numItemsDisplayed*(helper.getItemHeight()+2*ITEM_MARGIN); } ! // Don't run off the edge of the screenBounds ! if (x < screenBounds.x) { ! x = screenBounds.x; } ! else if (x + width > screenBounds.x + screenBounds.width) { ! x = screenBounds.x + screenBounds.width - width; } ! if (y + height > screenBounds.y + screenBounds.height) { y = global.y - height; } ! if (y < screenBounds.y) { ! y = screenBounds.y; } return new Rectangle(x, y, width, height); } public void toFront() {
< prev index next >