2 * (C) Copyright IBM Corp. 1998-2007. All Rights Reserved.
\r
4 * The program is provided "as is" without any warranty express or
\r
5 * implied, including the warranty of non-infringement and the implied
\r
6 * warranties of merchantibility and fitness for a particular purpose.
\r
7 * IBM will not be liable for any damages suffered by you as a result
\r
8 * of using the Program. In no event will IBM be liable for any
\r
9 * special, indirect or consequential damages or lost profits even if
\r
10 * IBM has been advised of the possibility of their occurrence. IBM
\r
11 * will not be liable for any third party claims against you.
\r
13 package com.ibm.richtext.awtui;
\r
15 import java.awt.Color;
\r
16 import java.awt.Component;
\r
17 import java.awt.Dimension;
\r
18 import java.awt.Graphics;
\r
20 import com.ibm.richtext.textpanel.MTextPanel;
\r
21 import com.ibm.richtext.uiimpl.TabRulerImpl;
\r
22 import com.ibm.richtext.styledtext.MTabRuler;
\r
25 * TabRuler is an implementation of MTabRulerComponent in an AWT component.
\r
27 public final class TabRuler extends Component implements MTabRulerComponent {
\r
32 private static final long serialVersionUID = -8418099860214866635L;
\r
33 //static final String COPYRIGHT =
\r
34 // "(C) Copyright IBM Corp. 1998-1999 - All Rights Reserved";
\r
35 private TabRulerImpl fImpl;
\r
38 * Create a new TabRuler.
\r
39 * @param baseline the y-coordinate of the ruler's baseline
\r
40 * @param origin the x-coordinate in this Component where
\r
41 * the left margin appears
\r
42 * @param textPanel the MTextPanel to listen to. This TabRuler
\r
43 * will reflect the MTextPanel's paragraph styles, and update
\r
44 * the paragraph styles when manipulated.
\r
46 public TabRuler(int baseline, int origin, MTextPanel textPanel) {
\r
48 fImpl = new TabRulerImpl(baseline, origin, textPanel, this);
\r
52 * Listen to the given MTextPanel and reflect its changes,
\r
53 * and update its paragraph styles when TabRuler is
\r
55 * @param textPanel the MTextPanel to listen to
\r
57 public void listenToTextPanel(MTextPanel textPanel) {
\r
59 fImpl.listenToTextPanel(textPanel);
\r
63 * Return the background color of this TabRuler.
\r
64 * @return the background color of this TabRuler
\r
66 public Color getBackColor() {
\r
68 return fImpl.getBackColor();
\r
72 * Set the background color of this TabRuler.
\r
73 * @param backColor the new background color of this TabRuler
\r
75 public void setBackColor(Color backColor) {
\r
77 fImpl.setBackColor(backColor);
\r
81 * Return the MTabRuler represented by this TabRuler.
\r
82 * @return the MTabRuler represented by this TabRuler
\r
84 public MTabRuler getRuler() {
\r
86 return fImpl.getRuler();
\r
90 * Return the leading margin of this TabRuler.
\r
91 * @return the leading margin of this TabRuler
\r
93 public int getLeadingMargin() {
\r
95 return fImpl.getLeadingMargin();
\r
99 * Return the first line indent of this TabRuler.
\r
100 * @return the first line indent of this TabRuler
\r
102 public int getFirstLineIndent() {
\r
104 return fImpl.getFirstLineIndent();
\r
108 * Return the trailing margin of this TabRuler.
\r
109 * @return the trailing margin of this TabRuler
\r
111 public final int getTrailingMargin() {
\r
113 return fImpl.getTrailingMargin();
\r
116 // The following are Component methods which need to be delegated to
\r
117 // the implementation:
\r
119 public void paint(Graphics g) {
\r
124 public Dimension getPreferredSize() {
\r
126 return fImpl.getPreferredSize();
\r
129 public Dimension getMinimumSize() {
\r
131 return fImpl.getMinimumSize();
\r