src/macosx/classes/com/apple/laf/AquaToolBarUI.java

Print this page


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


  38     private static RecyclableSingleton<ToolBarBorder> toolBarBorder = new RecyclableSingletonFromDefaultConstructor<ToolBarBorder>(ToolBarBorder.class);
  39     public static Border getToolBarBorder() {
  40         return toolBarBorder.get();
  41     }
  42 
  43     public static ComponentUI createUI(final JComponent c) {
  44         return new AquaToolBarUI();
  45     }
  46 
  47     protected void setBorderToNonRollover(final Component c) { }
  48     protected void setBorderToNormal(final Component c) { }
  49     protected void setBorderToRollover(final Component c) { }
  50 
  51     protected RootPaneContainer createFloatingWindow(final JToolBar toolbar) {
  52         final RootPaneContainer window = super.createFloatingWindow(toolbar);
  53         window.getRootPane().putClientProperty("Window.style", "small");
  54         return window;
  55     }
  56 
  57     /* ToolBarBorder and drag-off handle, based loosly on MetalBumps */

  58     static class ToolBarBorder extends AbstractBorder implements UIResource, javax.swing.SwingConstants {
  59         protected void fillHandle(final Graphics g, final int x1, final int y1, final int x2, final int y2, final boolean horizontal) {
  60             g.setColor(UIManager.getColor("ToolBar.borderHandleColor"));
  61             if (horizontal) {
  62                 final int h = y2 - y1 - 2;
  63                 g.fillRect(x1 + 2, y1 + 1, 1, h);
  64                 g.fillRect(x1 + 5, y1 + 1, 1, h);
  65             } else {
  66                 final int w = x2 - x1 - 2;
  67                 g.fillRect(x1 + 1, y1 + 2, w, 1);
  68                 g.fillRect(x1 + 1, y1 + 5, w, 1);
  69             }
  70         }
  71 
  72         public void paintBorder(final java.awt.Component c, final Graphics g, int x, int y, final int w, final int h) {
  73             g.translate(x, y);
  74 
  75             if (c.isOpaque()) {
  76                 AquaUtils.fillRect(g, c, c.getBackground(), 0, 0, w - 1, h - 1);
  77             }


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


  38     private static RecyclableSingleton<ToolBarBorder> toolBarBorder = new RecyclableSingletonFromDefaultConstructor<ToolBarBorder>(ToolBarBorder.class);
  39     public static Border getToolBarBorder() {
  40         return toolBarBorder.get();
  41     }
  42 
  43     public static ComponentUI createUI(final JComponent c) {
  44         return new AquaToolBarUI();
  45     }
  46 
  47     protected void setBorderToNonRollover(final Component c) { }
  48     protected void setBorderToNormal(final Component c) { }
  49     protected void setBorderToRollover(final Component c) { }
  50 
  51     protected RootPaneContainer createFloatingWindow(final JToolBar toolbar) {
  52         final RootPaneContainer window = super.createFloatingWindow(toolbar);
  53         window.getRootPane().putClientProperty("Window.style", "small");
  54         return window;
  55     }
  56 
  57     /* ToolBarBorder and drag-off handle, based loosly on MetalBumps */
  58     @SuppressWarnings("serial") // Superclass is not serializable across versions
  59     static class ToolBarBorder extends AbstractBorder implements UIResource, javax.swing.SwingConstants {
  60         protected void fillHandle(final Graphics g, final int x1, final int y1, final int x2, final int y2, final boolean horizontal) {
  61             g.setColor(UIManager.getColor("ToolBar.borderHandleColor"));
  62             if (horizontal) {
  63                 final int h = y2 - y1 - 2;
  64                 g.fillRect(x1 + 2, y1 + 1, 1, h);
  65                 g.fillRect(x1 + 5, y1 + 1, 1, h);
  66             } else {
  67                 final int w = x2 - x1 - 2;
  68                 g.fillRect(x1 + 1, y1 + 2, w, 1);
  69                 g.fillRect(x1 + 1, y1 + 5, w, 1);
  70             }
  71         }
  72 
  73         public void paintBorder(final java.awt.Component c, final Graphics g, int x, int y, final int w, final int h) {
  74             g.translate(x, y);
  75 
  76             if (c.isOpaque()) {
  77                 AquaUtils.fillRect(g, c, c.getBackground(), 0, 0, w - 1, h - 1);
  78             }