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);
|
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);
|