/jEdit/tags/jedit-4-5-pre1/org/gjt/sp/jedit/bsh/commands/thinBorder.bsh
Unknown | 80 lines | 67 code | 13 blank | 0 comment | 0 complexity | e5f8248b0f5ee283fd8081f3a560cfde MD5 | raw file
Possible License(s): BSD-3-Clause, AGPL-1.0, Apache-2.0, LGPL-2.0, LGPL-3.0, GPL-2.0, CC-BY-SA-3.0, LGPL-2.1, GPL-3.0, MPL-2.0-no-copyleft-exception, IPL-1.0
- /**
- * A one pixel wide bevel border. This border works for buttons (with optional
- * rollover) and other components
- *
- * @author Daniel Leuck
- */
- import javax.swing.border.*;
- Insets INSETS = new Insets(1,1,1,1);
- public thinBorder() { return thinBorder(null, null, false); }
- public thinBorder(Color lightColor, Color darkColor) {
- return thinBorder(lightColor, darkColor, false);
- }
- public thinBorder(Color lightColor, Color darkColor, boolean rollOver)
- {
- /**
- * Draw a 1 pixel border given a color for topLeft and bottomRight.
- */
- drawBorder(g, x, y, width, height, topLeft, bottomRight) {
- //Color oldColor = g.color;
- Color oldColor = g.getColor();
-
- //g.color=topLeft;
- g.setColor(topLeft);
- g.drawLine(x, y, x+width-1, y);
- g.drawLine(x, y, x, y+height-1);
-
- //g.color=bottomRight;
- g.setColor(bottomRight);
- g.drawLine(x+width-1, y, x+width-1, y+height-1);
- g.drawLine(x, y+height-1, x+width-1, y+height-1);
-
- //g.color=oldColor;
- g.setColor(oldColor);
- }
-
- public void paintBorder(c, g, x, y, width, height)
- {
- // Access to the background color is protected on the Mac for
- // some reason... workaround
- try {
- Color bgColor = c.background;
- Color dark = (darkColor==null) ? bgColor.darker().darker() :
- darkColor;
- Color light = (lightColor==null) ? bgColor.brighter() :
- lightColor;
- if(c instanceof AbstractButton) {
- if(c.rolloverEnabled && !c.model.rollover && c.opaque) {
- drawBorder(g, x, y, width, height, bgColor, bgColor);
- } else {
- if(c.model.isPressed())
- drawBorder(g, x, y, width, height, dark, light);
- else
- drawBorder(g, x, y, width, height, light, dark);
- }
- } else {
- drawBorder(g, x, y, width, height, light, dark);
- }
- } catch ( SecurityException e ) { }
- }
- /**
- * Returns the insets of the border.
- *
- * @param c the component for which this border insets value applies
- */
- public Insets getBorderInsets(Component c) { return INSETS; }
-
- /**
- * Always returns false
- */
- public boolean isBorderOpaque() { return false; }
-
- return this;
- }