01: /*
02: * Copyright 2006 Pentaho Corporation. All rights reserved.
03: * This software was developed by Pentaho Corporation and is provided under the terms
04: * of the Mozilla Public License, Version 1.1, or any later version. You may not use
05: * this file except in compliance with the license. If you need a copy of the license,
06: * please go to http://www.mozilla.org/MPL/MPL-1.1.txt. The Original Code is the Pentaho
07: * BI Platform. The Initial Developer is Pentaho Corporation.
08: *
09: * Software distributed under the Mozilla Public License is distributed on an "AS IS"
10: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. Please refer to
11: * the license for the specific language governing your rights and limitations.
12: *
13: * @created Feb 01, 2006
14: * @author Michael D'Amour
15: */
16:
17: package org.pentaho.jfreereport.wizard.ui.swt;
18:
19: import org.eclipse.swt.events.PaintEvent;
20: import org.eclipse.swt.events.PaintListener;
21: import org.eclipse.swt.graphics.Color;
22: import org.eclipse.swt.graphics.GC;
23: import org.eclipse.swt.widgets.Composite;
24:
25: /**
26: * @author Michael D'Amour
27: *
28: */
29: public class SWTButton extends Composite {
30: Color color1 = null;
31: Color color2 = null;
32: Color color3 = null;
33:
34: /**
35: * @param parent
36: * @param style
37: */
38: public SWTButton(Composite parent, int style) {
39: super (parent, style);
40: color1 = new Color(getDisplay(), 0, 0, 0);
41: color2 = new Color(getDisplay(), 128, 128, 128);
42: color3 = new Color(getDisplay(), 255, 255, 255);
43: addPaintListener(new PaintListener() {
44: public void paintControl(PaintEvent e) {
45: GC gc = e.gc;
46: if (!isEnabled()) {
47: gc.setBackground(new Color(getDisplay(), 0xf2,
48: 0xf2, 0xf2));
49: gc.setForeground(new Color(getDisplay(), 0xf2,
50: 0xf2, 0xf2));
51: gc.fillRectangle(0, 0,
52: SWTButton.this .getBounds().width,
53: SWTButton.this .getBounds().height);
54: }
55:
56: // top
57: gc.setForeground(color3);
58: gc.drawLine(0, 0, SWTButton.this .getBounds().width, 0);
59: // left
60: gc.setForeground(color3);
61: gc.drawLine(0, 1, 0, SWTButton.this .getBounds().height);
62: // right
63: gc.setForeground(color1);
64: gc.drawLine(SWTButton.this .getBounds().width - 1, 0,
65: SWTButton.this .getBounds().width - 1,
66: SWTButton.this .getBounds().height);
67: gc.setForeground(color2);
68: gc.drawLine(SWTButton.this .getBounds().width - 2, 1,
69: SWTButton.this .getBounds().width - 2,
70: SWTButton.this .getBounds().height - 2);
71: // bottom
72: gc.setForeground(color1);
73: gc.drawLine(0, SWTButton.this .getBounds().height - 1,
74: SWTButton.this .getBounds().width - 1,
75: SWTButton.this .getBounds().height - 1);
76: gc.setForeground(color2);
77: gc.drawLine(1, SWTButton.this .getBounds().height - 2,
78: SWTButton.this .getBounds().width - 2,
79: SWTButton.this .getBounds().height - 2);
80:
81: if (!isEnabled()) {
82: gc
83: .setForeground(new Color(getDisplay(), 255,
84: 0, 0));
85: gc.drawLine(0,
86: SWTButton.this .getBounds().height - 1,
87: SWTButton.this .getBounds().width - 1, 0);
88: }
89:
90: }
91: });
92: }
93:
94: public void setEtchedColors(Color c1, Color c2, Color c3) {
95: color1 = c1;
96: color2 = c2;
97: color3 = c3;
98: }
99: }
|