Source code: javax/microedition/lcdui/Item.java
1 /*
2 * MicroEmulator
3 * Copyright (C) 2001 Bartek Teodorczyk <barteo@it.pl>
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 * Contributor(s):
20 * 3GLab
21 */
22
23 package javax.microedition.lcdui;
24
25
26 public abstract class Item
27 {
28
29 static final int OUTOFITEM = Integer.MAX_VALUE;
30
31 StringComponent labelComponent;
32 Screen owner = null;
33 private boolean focus = false;
34
35
36 Item(String label)
37 {
38 labelComponent = new StringComponent(label);
39 }
40
41
42 public String getLabel()
43 {
44 return labelComponent.getText();
45 }
46
47
48 public void setLabel(String label)
49 {
50 labelComponent.setText(label);
51 }
52
53
54 int getHeight()
55 {
56 return labelComponent.getHeight();
57 }
58
59
60 boolean isFocusable()
61 {
62 return false;
63 }
64
65
66 void keyPressed(int keyCode)
67 {
68 }
69
70
71 abstract int paint(Graphics g);
72
73
74 void paintContent(Graphics g)
75 {
76 labelComponent.paint(g);
77 }
78
79
80 void repaint()
81 {
82 if (owner != null) {
83 owner.repaint();
84 }
85 }
86
87
88 boolean hasFocus()
89 {
90 return focus;
91 }
92
93
94 void setFocus(boolean state)
95 {
96 focus = state;
97 }
98
99
100 Screen getOwner()
101 {
102 return owner;
103 }
104
105
106 void setOwner(Screen owner)
107 {
108 this.owner = owner;
109 }
110
111
112 boolean select()
113 {
114 return false;
115 }
116
117
118 int traverse(int gameKeyCode, int top, int bottom, boolean action)
119 {
120 return 0;
121 }
122
123 }