< prev index next >

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

Print this page


   1 /*
   2  * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 768             params.remove(BOUNDS);
 769             params.add(OVERRIDE_REDIRECT, Boolean.TRUE);
 770         }
 771 
 772         // Generally, bounds should be:
 773         //  x = target.x
 774         //  y = target.y + target.height
 775         //  w = Max(target.width, getLongestItemWidth) + possible vertScrollbar
 776         //  h = Min(MAX_UNFURLED_ITEMS, target.getItemCount()) * itemHeight
 777         Rectangle placeOnScreen() {
 778             int numItemsDisplayed;
 779             // Motif paints an empty Choice the same size as a single item
 780             if (helper.isEmpty()) {
 781                 numItemsDisplayed = 1;
 782             }
 783             else {
 784                 int numItems = helper.getItemCount();
 785                 numItemsDisplayed = Math.min(MAX_UNFURLED_ITEMS, numItems);
 786             }
 787             Point global = XChoicePeer.this.toGlobal(0,0);
 788             Rectangle screen = graphicsConfig.getBounds();
 789 
 790             if (alignUnder != null) {
 791                 Rectangle choiceRec = XChoicePeer.this.getBounds();
 792                 choiceRec.setLocation(0, 0);
 793                 choiceRec = XChoicePeer.this.toGlobal(choiceRec);
 794                 Rectangle alignUnderRec = new Rectangle(alignUnder.getLocationOnScreen(), alignUnder.getSize()); // TODO: Security?
 795                 Rectangle result = choiceRec.union(alignUnderRec);
 796                 // we've got the left and width, calculate top and height
 797                 width = result.width;
 798                 x = result.x;
 799                 y = result.y + result.height;
 800                 height = 2*BORDER_WIDTH +
 801                     numItemsDisplayed*(helper.getItemHeight()+2*ITEM_MARGIN);
 802             } else {
 803                 x = global.x;
 804                 y = global.y + XChoicePeer.this.height;
 805                 width = Math.max(XChoicePeer.this.width,
 806                                  helper.getMaxItemWidth() + 2 * (BORDER_WIDTH + ITEM_MARGIN + TEXT_SPACE) + (helper.isVSBVisible() ? SCROLLBAR_WIDTH : 0));
 807                 height = 2*BORDER_WIDTH +
 808                     numItemsDisplayed*(helper.getItemHeight()+2*ITEM_MARGIN);


   1 /*
   2  * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 768             params.remove(BOUNDS);
 769             params.add(OVERRIDE_REDIRECT, Boolean.TRUE);
 770         }
 771 
 772         // Generally, bounds should be:
 773         //  x = target.x
 774         //  y = target.y + target.height
 775         //  w = Max(target.width, getLongestItemWidth) + possible vertScrollbar
 776         //  h = Min(MAX_UNFURLED_ITEMS, target.getItemCount()) * itemHeight
 777         Rectangle placeOnScreen() {
 778             int numItemsDisplayed;
 779             // Motif paints an empty Choice the same size as a single item
 780             if (helper.isEmpty()) {
 781                 numItemsDisplayed = 1;
 782             }
 783             else {
 784                 int numItems = helper.getItemCount();
 785                 numItemsDisplayed = Math.min(MAX_UNFURLED_ITEMS, numItems);
 786             }
 787             Point global = XChoicePeer.this.toGlobal(0,0);
 788             Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
 789 
 790             if (alignUnder != null) {
 791                 Rectangle choiceRec = XChoicePeer.this.getBounds();
 792                 choiceRec.setLocation(0, 0);
 793                 choiceRec = XChoicePeer.this.toGlobal(choiceRec);
 794                 Rectangle alignUnderRec = new Rectangle(alignUnder.getLocationOnScreen(), alignUnder.getSize()); // TODO: Security?
 795                 Rectangle result = choiceRec.union(alignUnderRec);
 796                 // we've got the left and width, calculate top and height
 797                 width = result.width;
 798                 x = result.x;
 799                 y = result.y + result.height;
 800                 height = 2*BORDER_WIDTH +
 801                     numItemsDisplayed*(helper.getItemHeight()+2*ITEM_MARGIN);
 802             } else {
 803                 x = global.x;
 804                 y = global.y + XChoicePeer.this.height;
 805                 width = Math.max(XChoicePeer.this.width,
 806                                  helper.getMaxItemWidth() + 2 * (BORDER_WIDTH + ITEM_MARGIN + TEXT_SPACE) + (helper.isVSBVisible() ? SCROLLBAR_WIDTH : 0));
 807                 height = 2*BORDER_WIDTH +
 808                     numItemsDisplayed*(helper.getItemHeight()+2*ITEM_MARGIN);


< prev index next >