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: public class SWTLine extends Composite {
26: Color color1 = new Color(getDisplay(), 0, 0, 0);
27: Color color2 = new Color(getDisplay(), 0, 0, 0);
28: boolean horizontal = true;
29:
30: /**
31: * @param parent
32: * @param style
33: */
34: public SWTLine(Composite parent, int style) {
35: super (parent, style);
36: addPaintListener(new PaintListener() {
37: public void paintControl(PaintEvent e) {
38: GC gc = e.gc;
39: gc.setForeground(color1);
40: // gc.drawLine(0, (int)(e.height-2), e.width, (int)(e.height-2));
41: // gc.drawLine(0, (int)(e.height/2), e.width, (int)(e.height/2));
42: int middleX = getBounds().width / 2;
43: int middleY = getBounds().height / 2;
44: if (horizontal) {
45: gc.drawLine(0, middleY, getBounds().width, middleY);
46: } else {
47: gc
48: .drawLine(middleX, 0, middleX,
49: getBounds().height);
50: }
51: gc.setForeground(color2);
52: // gc.drawLine(0, (int)(e.height-1), e.width, (int)(e.height-1));
53: // gc.drawLine(0, (int)(e.height/2)+1, e.width, (int)(e.height/2)+1);
54: if (horizontal) {
55: gc.drawLine(0, middleY + 1, getBounds().width,
56: middleY + 1);
57: } else {
58: gc.drawLine(middleX + 1, 0, middleX + 1,
59: getBounds().height);
60: }
61: }
62: });
63: }
64:
65: public void setHorizontal(boolean horizontal) {
66: this .horizontal = horizontal;
67: }
68:
69: public void setEtchedColors(Color primary, Color secondary) {
70: color1 = primary;
71: color2 = secondary;
72: }
73: }
|