1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.onemind.awtbridge.peer;
22
23 import java.awt.*;
24 import java.awt.peer.TextAreaPeer;
25 import org.onemind.awtbridge.BridgeContext;
26 /***
27 * A TextArea Peer
28 * @author TiongHiang Lee (thlee@onemindsoft.org)
29 * @version $Id: BridgeTextAreaPeer.java,v 1.3 2005/03/12 23:03:11 thlee Exp $ $Name: awtbridge-1_0_0 $
30 */
31 public class BridgeTextAreaPeer extends BridgeTextComponentPeer
32 implements
33 TextAreaPeer
34 {
35
36 /***
37 * {@inheritDoc}
38 */
39 public BridgeTextAreaPeer(Object componentObject, BridgeContext context)
40 {
41 super(componentObject, context);
42 }
43
44 /***
45 * {@inheritDoc}
46 */
47 public Dimension getMinimumSize(int rows, int columns)
48 {
49 return preferredSize(rows, columns);
50 }
51
52 /***
53 * {@inheritDoc}
54 */
55 public Dimension getPreferredSize(int rows, int columns)
56 {
57 return preferredSize(rows, columns);
58 }
59
60 /***
61 * {@inheritDoc}
62 */
63 public void insert(String text, int pos)
64 {
65 getTextBuffer().insert(pos, text);
66 }
67
68 /***
69 * TODO: TBI {@inheritDoc}
70 */
71 public void insertText(String txt, int pos)
72 {
73 getTextBuffer().insert(pos, txt);
74 }
75
76 /***
77 * {@inheritDoc}
78 */
79 public Dimension minimumSize(int rows, int cols)
80 {
81 return preferredSize(rows, cols);
82 }
83
84 /***
85 * {@inheritDoc}
86 */
87 public final Dimension preferredSize(int rows, int cols)
88 {
89 FontMetrics m = getCurrentFontMetrics();
90 return new Dimension(cols * m.charWidth('A'), rows * m.getHeight());
91 }
92
93 /***
94 * {@inheritDoc}
95 * TODO: TBI
96 */
97 public void replaceRange(String text, int start, int end)
98 {
99 getTextBuffer().replace(start, end, text);
100 }
101
102 /***
103 * {@inheritDoc}
104 * TODO: TBI
105 */
106 public void replaceText(String txt, int start, int end)
107 {
108 getTextBuffer().replace(start, end, txt);
109 }
110
111 /***
112 * {@inheritDoc}
113 * TODO: TBI
114 */
115 public Dimension preferredSize()
116 {
117 TextArea area = (TextArea) getComponent();
118 return preferredSize(area.getRows(), area.getColumns());
119 }
120 }