-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathStringWidget.java
More file actions
100 lines (89 loc) · 2.24 KB
/
StringWidget.java
File metadata and controls
100 lines (89 loc) · 2.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
package org.lcdproc.lcdjava;
/**
* String Widget.
* <p>Displays a String on the LCD display.
* <p>Copyright (c) 2004-2005 Darren Greaves.
* @author Darren Greaves
* @version $Id: StringWidget.java,v 1.2 2005-03-03 14:13:16 boncey Exp $
*/
public class StringWidget extends PositionalWidget
{
/**
* Version details.
*/
public static final String CVSID =
"$Id: StringWidget.java,v 1.2 2005-03-03 14:13:16 boncey Exp $";
/**
* The Widget text.
*/
private String _text;
/**
* Constructor.
* @param id the of the Widget.
* @param screen the Screen that knows about this Widget.
*/
protected StringWidget(int id, Screen screen)
{
super(id, screen);
}
/**
* Get the Widget type.
* @return the Widget type.
*/
public String getType()
{
return Widget.WIDGET_STRING;
}
/**
* Set the Widget text.
* @param text the Widget text.
*/
public void setText(String text)
{
_text = text;
update();
}
/**
* Get the Widget text.
* @return the Widget text.
*/
public String getText()
{
return _text;
}
/**
* Return the data this Widget needs to update itself.
* @return the data to update this Widget.
*/
public String getData()
{
return super.getData() + "\"" + stripQuotes(_text) + "\"";
}
/**
* Construct a new StringWidget.
* @param screen the Screen that owns the Widget.
* @param x the x position.
* @param y the y position.
* @param text the widget text.
* @return a new StringWidget.
*/
public static StringWidget construct(Screen screen,
int x,
int y,
String text)
{
StringWidget widget = null;
try
{
widget = (StringWidget)screen.constructWidget(Widget.WIDGET_STRING);
widget.setX(x);
widget.setY(y);
widget.setText(text);
}
catch (LCDException e)
{
// Supress, would only get one if we asked for an invalid Widget.
}
return widget;
}
}