001: /*
002: * (C) Copyright IBM Corp. 1998-2004. All Rights Reserved.
003: *
004: * The program is provided "as is" without any warranty express or
005: * implied, including the warranty of non-infringement and the implied
006: * warranties of merchantibility and fitness for a particular purpose.
007: * IBM will not be liable for any damages suffered by you as a result
008: * of using the Program. In no event will IBM be liable for any
009: * special, indirect or consequential damages or lost profits even if
010: * IBM has been advised of the possibility of their occurrence. IBM
011: * will not be liable for any third party claims against you.
012: */
013: package com.ibm.richtext.awtui;
014:
015: import java.awt.Color;
016: import java.awt.Component;
017: import java.awt.Dimension;
018: import java.awt.Graphics;
019:
020: import com.ibm.richtext.textpanel.MTextPanel;
021: import com.ibm.richtext.uiimpl.TabRulerImpl;
022: import com.ibm.richtext.styledtext.MTabRuler;
023:
024: /**
025: * TabRuler is an implementation of MTabRulerComponent in an AWT component.
026: */
027: public final class TabRuler extends Component implements
028: MTabRulerComponent {
029:
030: static final String COPYRIGHT = "(C) Copyright IBM Corp. 1998-1999 - All Rights Reserved";
031: private TabRulerImpl fImpl;
032:
033: /**
034: * Create a new TabRuler.
035: * @param baseline the y-coordinate of the ruler's baseline
036: * @param origin the x-coordinate in this Component where
037: * the left margin appears
038: * @param textPanel the MTextPanel to listen to. This TabRuler
039: * will reflect the MTextPanel's paragraph styles, and update
040: * the paragraph styles when manipulated.
041: */
042: public TabRuler(int baseline, int origin, MTextPanel textPanel) {
043:
044: fImpl = new TabRulerImpl(baseline, origin, textPanel, this );
045: }
046:
047: /**
048: * Listen to the given MTextPanel and reflect its changes,
049: * and update its paragraph styles when TabRuler is
050: * manipulated.
051: * @param textPanel the MTextPanel to listen to
052: */
053: public void listenToTextPanel(MTextPanel textPanel) {
054:
055: fImpl.listenToTextPanel(textPanel);
056: }
057:
058: /**
059: * Return the background color of this TabRuler.
060: * @return the background color of this TabRuler
061: */
062: public Color getBackColor() {
063:
064: return fImpl.getBackColor();
065: }
066:
067: /**
068: * Set the background color of this TabRuler.
069: * @param backColor the new background color of this TabRuler
070: */
071: public void setBackColor(Color backColor) {
072:
073: fImpl.setBackColor(backColor);
074: }
075:
076: /**
077: * Return the MTabRuler represented by this TabRuler.
078: * @return the MTabRuler represented by this TabRuler
079: */
080: public MTabRuler getRuler() {
081:
082: return fImpl.getRuler();
083: }
084:
085: /**
086: * Return the leading margin of this TabRuler.
087: * @return the leading margin of this TabRuler
088: */
089: public int getLeadingMargin() {
090:
091: return fImpl.getLeadingMargin();
092: }
093:
094: /**
095: * Return the first line indent of this TabRuler.
096: * @return the first line indent of this TabRuler
097: */
098: public int getFirstLineIndent() {
099:
100: return fImpl.getFirstLineIndent();
101: }
102:
103: /**
104: * Return the trailing margin of this TabRuler.
105: * @return the trailing margin of this TabRuler
106: */
107: public final int getTrailingMargin() {
108:
109: return fImpl.getTrailingMargin();
110: }
111:
112: // The following are Component methods which need to be delegated to
113: // the implementation:
114:
115: public void paint(Graphics g) {
116:
117: fImpl.paint(g);
118: }
119:
120: public Dimension getPreferredSize() {
121:
122: return fImpl.getPreferredSize();
123: }
124:
125: public Dimension getMinimumSize() {
126:
127: return fImpl.getMinimumSize();
128: }
129: }
|