< prev index next >

src/java.desktop/unix/classes/sun/awt/X11/ListHelper.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


 559         //g.drawString(string, x + TEXT_SPACE, y + TEXT_SPACE + ITEM_MARGIN);
 560 
 561         int fontAscent = fm.getAscent();
 562         int fontDescent = fm.getDescent();
 563 
 564         g.drawString(string, x + TEXT_SPACE, y + (height + fm.getMaxAscent() - fm.getMaxDescent())/2);
 565         //g.clipRect(clip.x, clip.y, clip.width, clip.height);
 566     }
 567 
 568     private boolean isItemSelected(int index) {
 569         Iterator<Integer> itr = selected.iterator();
 570         while (itr.hasNext()) {
 571             Integer val = itr.next();
 572             if (val.intValue() == index) {
 573                 return true;
 574             }
 575         }
 576         return false;
 577     }
 578 
 579     private void paintVSB(Graphics g, Color colors[], Rectangle bounds) {
 580         int height = bounds.height - 2*BORDER_WIDTH - (hsbVis ? (SCROLLBAR_WIDTH-2) : 0);
 581         Graphics ng = g.create();
 582 
 583         g.setColor(colors[XComponentPeer.BACKGROUND_COLOR]);
 584         try {
 585             ng.translate(bounds.width - BORDER_WIDTH - SCROLLBAR_WIDTH,
 586                          BORDER_WIDTH);
 587             // Update scrollbar's size
 588             vsb.setSize(SCROLLBAR_WIDTH, bounds.height);
 589             vsb.paint(ng, colors, true);
 590         } finally {
 591             ng.dispose();
 592         }
 593     }
 594 
 595     private void paintHSB(Graphics g, Color colors[], Rectangle bounds) {
 596 
 597     }
 598 
 599     /*
 600      * Helper method for Components with integrated scrollbars.
 601      * Pass in the vertical and horizontal scroll bar (or null for none/hidden)
 602      * and the MouseWheelEvent, and the appropriate scrollbar will be scrolled
 603      * correctly.
 604      * Returns whether or not scrolling actually took place.  This will indicate
 605      * whether or not repainting is required.
 606      */
 607     static boolean doWheelScroll(XVerticalScrollbar vsb,
 608                                      XHorizontalScrollbar hsb,
 609                                      MouseWheelEvent e) {
 610         XScrollbar scroll = null;
 611         int wheelRotation;
 612 
 613         // Determine which, if any, sb to scroll
 614         if (vsb != null) {
 615             scroll = vsb;


   1 /*
   2  * Copyright (c) 2003, 2018, 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


 559         //g.drawString(string, x + TEXT_SPACE, y + TEXT_SPACE + ITEM_MARGIN);
 560 
 561         int fontAscent = fm.getAscent();
 562         int fontDescent = fm.getDescent();
 563 
 564         g.drawString(string, x + TEXT_SPACE, y + (height + fm.getMaxAscent() - fm.getMaxDescent())/2);
 565         //g.clipRect(clip.x, clip.y, clip.width, clip.height);
 566     }
 567 
 568     private boolean isItemSelected(int index) {
 569         Iterator<Integer> itr = selected.iterator();
 570         while (itr.hasNext()) {
 571             Integer val = itr.next();
 572             if (val.intValue() == index) {
 573                 return true;
 574             }
 575         }
 576         return false;
 577     }
 578 
 579     private void paintVSB(Graphics g, Color[] colors, Rectangle bounds) {
 580         int height = bounds.height - 2*BORDER_WIDTH - (hsbVis ? (SCROLLBAR_WIDTH-2) : 0);
 581         Graphics ng = g.create();
 582 
 583         g.setColor(colors[XComponentPeer.BACKGROUND_COLOR]);
 584         try {
 585             ng.translate(bounds.width - BORDER_WIDTH - SCROLLBAR_WIDTH,
 586                          BORDER_WIDTH);
 587             // Update scrollbar's size
 588             vsb.setSize(SCROLLBAR_WIDTH, bounds.height);
 589             vsb.paint(ng, colors, true);
 590         } finally {
 591             ng.dispose();
 592         }
 593     }
 594 
 595     private void paintHSB(Graphics g, Color[] colors, Rectangle bounds) {
 596 
 597     }
 598 
 599     /*
 600      * Helper method for Components with integrated scrollbars.
 601      * Pass in the vertical and horizontal scroll bar (or null for none/hidden)
 602      * and the MouseWheelEvent, and the appropriate scrollbar will be scrolled
 603      * correctly.
 604      * Returns whether or not scrolling actually took place.  This will indicate
 605      * whether or not repainting is required.
 606      */
 607     static boolean doWheelScroll(XVerticalScrollbar vsb,
 608                                      XHorizontalScrollbar hsb,
 609                                      MouseWheelEvent e) {
 610         XScrollbar scroll = null;
 611         int wheelRotation;
 612 
 613         // Determine which, if any, sb to scroll
 614         if (vsb != null) {
 615             scroll = vsb;


< prev index next >