/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
protected boolean isPopDown = false;
super(cBox);
}
protected void configurePopup() {
super.configurePopup();
setBorderPainted(false);
updateContents(false);
// TODO: CPlatformWindow?
}
// for more background on this issue, see AquaMenuBorder.getBorderInsets()
if (isPopDown) {
if (remove) {
}
if (bottomStrut != null) {
this.remove(bottomStrut);
}
} else {
}
} else {
}
this.add(bottomStrut);
}
}
for (int i = 0; i < rowCount; i++) {
}
return popupSize;
}
protected boolean shouldScroll() {
}
protected boolean isPopdown() {
}
public void show() {
// hack for <rdar://problem/4905531> JComboBox does not fire popupWillBecomeVisible if item count is 0
if (afterShowItemCount == 0) {
hide();
return;
}
if (startItemCount != afterShowItemCount) {
pack();
}
// end hack
}
public void processMouseEvent(MouseEvent e) {
if (e.isMetaDown()) {
e = new MouseEvent((Component)e.getSource(), e.getID(), e.getWhen(), e.getModifiers() ^ InputEvent.META_MASK, e.getX(), e.getY(), e.getXOnScreen(), e.getYOnScreen(), e.getClickCount(), e.isPopupTrigger(), MouseEvent.NOBUTTON);
}
super.processMouseEvent(e);
}
};
}
updateContents(true);
}
final Rectangle popupBounds = computePopupBounds(0, comboBox.getBounds().height, popupSize.width, popupSize.height);
list.invalidate();
if (selectedIndex == -1) {
} else {
}
return popupBounds;
}
// Get the bounds of the screen where the menu should appear
// p is the origin of the combo box in screen bounds
//System.err.println("GetBestScreenBounds p: "+ p.x + ", " + p.y);
//System.err.println(" gs.length = " + gs.length);
//System.err.println(" scrSize: "+ scrSize);
// If the combo box is totally off screen, don't show a popup
if ((p.x + comboBoxBounds.width < 0) || (p.y + comboBoxBounds.height < 0) || (p.x > scrSize.width) || (p.y > scrSize.height)) {
return null;
}
}
}
}
// Hmm. Origin's off screen, but is any part on?
}
}
return null;
}
if (isPopdown && !isTableCellEditor) {
// place the popup just below the button, which is
// near the center of a large combo box
py = Math.min((py / 2) + 9, py); // if py is less than new y we have a clipped combo, so leave it alone.
}
// px & py are relative to the combo box
// **** Common calculation - applies to the scrolling and menu-style ****
//System.err.println("First Converting from point to screen: 0,0 is now " + p.x + ", " + p.y);
//System.err.println("BestScreenBounds is " + scrBounds);
// If the combo box is totally off screen, do whatever super does
// and left edge if left-to-right, right edge if right-to-left
if (shouldScroll()) {
pw += 15;
}
if (isPopdown) {
pw += 4;
}
// the popup should be wide enough for the items but not wider than the screen it's on
if (leftToRight) {
} else {
}
// Make sure it's all on the screen - shift it by the amount it's off
p.x += px;
p.y += py; // Screen location of px & py
//System.err.println("Converting from point to screen: 0,0 is now " + top.x + ", " + top.y);
// Since the popup is at zero in this coord space, the maxWidth == the X coord of the screen right edge
// (it might be wider than the screen, if the combo is off the left edge)
final int maxWidth = Math.min(scrBounds.width, top.x + scrBounds.x + scrBounds.width) - 2; // subtract some buffer space
}
// this is a popup window, and will continue calculations below
if (!isPopdown) {
// popup windows are slightly inset from the combo end-cap
pw -= 6;
}
// don't attempt to inset table cell editors
if (!isTableCellEditor) {
if (leftToRight) {
}
}
// Check whether it goes below the bottom of the screen, if so flip it
}
// The one to use when itemCount <= maxRowCount. Size never adjusts for arrows
// We want it positioned so the selected item is right above the combo box
protected Rectangle computePopupBoundsForMenu(final int px, final int py, final int pw, final int ph, final int itemCount, final Rectangle scrBounds) {
//System.err.println("computePopupBoundsForMenu: " + px + "," + py + " " + pw + "," + ph);
//System.err.println("itemCount: " +itemCount +" src: "+ scrBounds);
}
// If the popup fits on the screen and the selection appears under the mouse w/o scrolling, cool!
// If the popup won't fit on the screen, adjust its position but not its size
// and rewrite this to support arrows - JLists always move the contents so they all show
// Test to see if it extends off the screen
if (extendsOffscreenAtTop) {
// Round it so the selection lines up with the combobox
} else if (extendsOffscreenAtBottom) {
// Provide blank space at top for off-screen stuff to scroll into
popupBounds.y = bottom.y - popupBounds.height; // popupBounds.height has already been adjusted to fit
} else { // fits - position it so the selectedLocation is under the mouse
popupBounds.y = -selectedLocation;
}
// Center the selected item on the combobox
return popupBounds;
}
}