예제 #1
0
 public Insets getBorderInsets(Component c, Insets insets) {
   insets.set(1, 1, 1, 1);
   if (!(c instanceof JToolBar)) {
     return insets;
   }
   if (((JToolBar) c).isFloatable()) {
     int gripInset = (XPStyle.getXP() != null) ? 12 : 9;
     if (((JToolBar) c).getOrientation() == HORIZONTAL) {
       if (c.getComponentOrientation().isLeftToRight()) {
         insets.left = gripInset;
       } else {
         insets.right = gripInset;
       }
     } else {
       insets.top = gripInset;
     }
   }
   return insets;
 }
예제 #2
0
    public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
      if (!(c instanceof JToolBar)) {
        return;
      }
      g.translate(x, y);

      XPStyle xp = XPStyle.getXP();
      if (xp != null) {
        Border xpBorder = xp.getBorder(c, Part.TP_TOOLBAR);
        if (xpBorder != null) {
          xpBorder.paintBorder(c, g, 0, 0, width, height);
        }
      }
      if (((JToolBar) c).isFloatable()) {
        boolean vertical = ((JToolBar) c).getOrientation() == VERTICAL;

        if (xp != null) {
          Part part = vertical ? Part.RP_GRIPPERVERT : Part.RP_GRIPPER;
          Skin skin = xp.getSkin(c, part);
          int dx, dy, dw, dh;
          if (vertical) {
            dx = 0;
            dy = 2;
            dw = width - 1;
            dh = skin.getHeight();
          } else {
            dw = skin.getWidth();
            dh = height - 1;
            dx = c.getComponentOrientation().isLeftToRight() ? 2 : (width - dw - 2);
            dy = 0;
          }
          skin.paintSkin(g, dx, dy, dw, dh, State.NORMAL);

        } else {

          if (!vertical) {
            if (c.getComponentOrientation().isLeftToRight()) {
              g.setColor(shadow);
              g.drawLine(4, 3, 4, height - 4);
              g.drawLine(4, height - 4, 2, height - 4);

              g.setColor(highlight);
              g.drawLine(2, 3, 3, 3);
              g.drawLine(2, 3, 2, height - 5);
            } else {
              g.setColor(shadow);
              g.drawLine(width - 3, 3, width - 3, height - 4);
              g.drawLine(width - 4, height - 4, width - 4, height - 4);

              g.setColor(highlight);
              g.drawLine(width - 5, 3, width - 4, 3);
              g.drawLine(width - 5, 3, width - 5, height - 5);
            }
          } else { // Vertical
            g.setColor(shadow);
            g.drawLine(3, 4, width - 4, 4);
            g.drawLine(width - 4, 2, width - 4, 4);

            g.setColor(highlight);
            g.drawLine(3, 2, width - 4, 2);
            g.drawLine(3, 2, 3, 3);
          }
        }
      }

      g.translate(-x, -y);
    }
예제 #3
0
 /*
  * Convenience function for determining ComponentOrientation.  Helps us
  * avoid having Munge directives throughout the code.
  */
 static boolean isLeftToRight(Component c) {
   return c.getComponentOrientation().isLeftToRight();
 }