1 /*
2 * Copyright (c) 2003, 2013, 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
482 firstPress = false;
483 dragStartIdx = -1;
484 }
485
486 public void mouseDragged(MouseEvent e) {
487 /*
488 * fix for 5003166. On Motif user are unable to drag
489 * mouse inside opened Choice if he drags the mouse with
490 * different from LEFT mouse button ( e.g. RIGHT or MIDDLE).
491 * This fix make impossible to drag mouse inside opened choice
492 * with other mouse buttons rather then LEFT one.
493 */
494 if ( e.getModifiers() == MouseEvent.BUTTON1_MASK ){
495 dragging = true;
496 wasDragged = true;
497 unfurledChoice.trackMouse(e);
498 }
499 }
500
501 // Stolen from TinyChoicePeer
502 public Dimension getMinimumSize() {
503 // TODO: move this impl into ListHelper?
504 FontMetrics fm = getFontMetrics(target.getFont());
505 Choice c = (Choice)target;
506 int w = 0;
507 for (int i = c.countItems() ; i-- > 0 ;) {
508 w = Math.max(fm.stringWidth(c.getItem(i)), w);
509 }
510 return new Dimension(w + TEXT_XPAD + WIDGET_OFFSET,
511 fm.getMaxAscent() + fm.getMaxDescent() + TEXT_YPAD);
512 }
513
514 /*
515 * Layout the...
516 */
517 public void layout() {
518 /*
519 Dimension size = target.getSize();
520 Font f = target.getFont();
521 FontMetrics fm = target.getFontMetrics(f);
|
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
482 firstPress = false;
483 dragStartIdx = -1;
484 }
485
486 public void mouseDragged(MouseEvent e) {
487 /*
488 * fix for 5003166. On Motif user are unable to drag
489 * mouse inside opened Choice if he drags the mouse with
490 * different from LEFT mouse button ( e.g. RIGHT or MIDDLE).
491 * This fix make impossible to drag mouse inside opened choice
492 * with other mouse buttons rather then LEFT one.
493 */
494 if ( e.getModifiers() == MouseEvent.BUTTON1_MASK ){
495 dragging = true;
496 wasDragged = true;
497 unfurledChoice.trackMouse(e);
498 }
499 }
500
501 // Stolen from TinyChoicePeer
502 @SuppressWarnings("deprecation")
503 public Dimension getMinimumSize() {
504 // TODO: move this impl into ListHelper?
505 FontMetrics fm = getFontMetrics(target.getFont());
506 Choice c = (Choice)target;
507 int w = 0;
508 for (int i = c.countItems() ; i-- > 0 ;) {
509 w = Math.max(fm.stringWidth(c.getItem(i)), w);
510 }
511 return new Dimension(w + TEXT_XPAD + WIDGET_OFFSET,
512 fm.getMaxAscent() + fm.getMaxDescent() + TEXT_YPAD);
513 }
514
515 /*
516 * Layout the...
517 */
518 public void layout() {
519 /*
520 Dimension size = target.getSize();
521 Font f = target.getFont();
522 FontMetrics fm = target.getFontMetrics(f);
|