src/share/classes/com/sun/java/swing/plaf/windows/WindowsSliderUI.java

Print this page


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


 198             xp.getSkin(slider, part).paintSkin(g, thumbRect.x, thumbRect.y, state);
 199         } else {
 200             super.paintThumb(g);
 201         }
 202     }
 203 
 204     protected Dimension getThumbSize() {
 205         XPStyle xp = XPStyle.getXP();
 206         if (xp != null) {
 207             Dimension size = new Dimension();
 208             Skin s = xp.getSkin(slider, getXPThumbPart());
 209             size.width = s.getWidth();
 210             size.height = s.getHeight();
 211             return size;
 212         } else {
 213             return super.getThumbSize();
 214         }
 215     }
 216 
 217     private Part getXPThumbPart() {
 218         XPStyle xp = XPStyle.getXP();
 219         Part part;
 220         boolean vertical = (slider.getOrientation() == JSlider.VERTICAL);
 221         boolean leftToRight = slider.getComponentOrientation().isLeftToRight();
 222         Boolean paintThumbArrowShape =
 223                 (Boolean)slider.getClientProperty("Slider.paintThumbArrowShape");
 224         if ((!slider.getPaintTicks() && paintThumbArrowShape == null) ||
 225             paintThumbArrowShape == Boolean.FALSE) {
 226                 part = vertical ? Part.TKP_THUMBVERT
 227                                 : Part.TKP_THUMB;
 228         } else {
 229                 part = vertical ? (leftToRight ? Part.TKP_THUMBRIGHT : Part.TKP_THUMBLEFT)
 230                                 : Part.TKP_THUMBBOTTOM;
 231         }
 232         return part;
 233     }
 234 }
   1 /*
   2  * Copyright (c) 1997, 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


 198             xp.getSkin(slider, part).paintSkin(g, thumbRect.x, thumbRect.y, state);
 199         } else {
 200             super.paintThumb(g);
 201         }
 202     }
 203 
 204     protected Dimension getThumbSize() {
 205         XPStyle xp = XPStyle.getXP();
 206         if (xp != null) {
 207             Dimension size = new Dimension();
 208             Skin s = xp.getSkin(slider, getXPThumbPart());
 209             size.width = s.getWidth();
 210             size.height = s.getHeight();
 211             return size;
 212         } else {
 213             return super.getThumbSize();
 214         }
 215     }
 216 
 217     private Part getXPThumbPart() {

 218         Part part;
 219         boolean vertical = (slider.getOrientation() == JSlider.VERTICAL);
 220         boolean leftToRight = slider.getComponentOrientation().isLeftToRight();
 221         Boolean paintThumbArrowShape =
 222                 (Boolean)slider.getClientProperty("Slider.paintThumbArrowShape");
 223         if ((!slider.getPaintTicks() && paintThumbArrowShape == null) ||
 224             paintThumbArrowShape == Boolean.FALSE) {
 225                 part = vertical ? Part.TKP_THUMBVERT
 226                                 : Part.TKP_THUMB;
 227         } else {
 228                 part = vertical ? (leftToRight ? Part.TKP_THUMBRIGHT : Part.TKP_THUMBLEFT)
 229                                 : Part.TKP_THUMBBOTTOM;
 230         }
 231         return part;
 232     }
 233 }