60 //the command to create the StringItem with the entered label and text |
60 //the command to create the StringItem with the entered label and text |
61 private Command cmdCreate = new Command("Create", Command.SCREEN, 1); |
61 private Command cmdCreate = new Command("Create", Command.SCREEN, 1); |
62 |
62 |
63 //the command to create the StringItem with the entered label and text and with focus |
63 //the command to create the StringItem with the entered label and text and with focus |
64 private Command cmdCreateHL = new Command("Create as Hyperlink", Command.SCREEN, 1); |
64 private Command cmdCreateHL = new Command("Create as Hyperlink", Command.SCREEN, 1); |
|
65 private Command cmdCreateHLM = new Command("Create as Hyperlink 2 cmds", Command.SCREEN, 1); |
65 |
66 |
66 //the command to create the StringItem with the entered label and text and with focus |
67 //the command to create the StringItem with the entered label and text and with focus |
67 private Command cmdCreateButton = new Command("Create as Button", Command.SCREEN, 1); |
68 private Command cmdCreateButton = new Command("Create as Button", Command.SCREEN, 1); |
|
69 private Command cmdCreateButtonM = new Command("Create as Button 2 cmds", Command.SCREEN, 1); |
68 |
70 |
69 //the command to unlock the Item |
71 //the command to unlock the Item |
70 private Command cmdUnlock = new Command("Unlock", Command.SCREEN, 1); |
72 private Command cmdUnlock = new Command("Unlock", Command.SCREEN, 1); |
71 //the command for the item |
73 //the command for the item |
72 private Command cmdItem = new Command("Item cmd", Command.ITEM, 1); |
74 private Command cmdItem = new Command("Item cmd", Command.ITEM, 1); |
95 private Command cmdLongText = new Command("Long text layout test", Command.SCREEN, 1); |
97 private Command cmdLongText = new Command("Long text layout test", Command.SCREEN, 1); |
96 |
98 |
97 private Command cmdNext = new Command("Next", Command.SCREEN, 1); |
99 private Command cmdNext = new Command("Next", Command.SCREEN, 1); |
98 private Command cmdExit = new Command("Exit", Command.EXIT, 1); |
100 private Command cmdExit = new Command("Exit", Command.EXIT, 1); |
99 |
101 |
|
102 // commands for the form |
|
103 private Command cmdItemF = new Command("ItemF", Command.ITEM, 1); |
|
104 private Command cmdOkF = new Command("OkF", Command.OK, 1); |
|
105 private Command cmdScreenF = new Command("Add form commands", Command.SCREEN, 1); |
|
106 |
100 static int change = -1; |
107 static int change = -1; |
101 |
108 |
102 public FormStringItemTests(Midp_StringItem_01 m) |
109 public FormStringItemTests(Midp_StringItem_01 m) |
103 { |
110 { |
104 //set the name of the form to be the name of MIDlet |
111 //set the name of the form to be the name of MIDlet |
116 append(width); |
123 append(width); |
117 append(height); |
124 append(height); |
118 append(cg); |
125 append(cg); |
119 addCommand(cmdCreate); |
126 addCommand(cmdCreate); |
120 addCommand(cmdCreateHL); |
127 addCommand(cmdCreateHL); |
|
128 addCommand(cmdCreateHLM); |
121 addCommand(cmdCreateButton); |
129 addCommand(cmdCreateButton); |
|
130 addCommand(cmdCreateButtonM); |
122 addCommand(cmdLayout); |
131 addCommand(cmdLayout); |
123 addCommand(cmdLayoutHL); |
132 addCommand(cmdLayoutHL); |
124 addCommand(cmdLayoutButton); |
133 addCommand(cmdLayoutButton); |
125 addCommand(cmdVLayout); |
134 addCommand(cmdVLayout); |
126 addCommand(cmdVLayoutHL); |
135 addCommand(cmdVLayoutHL); |
132 Display.getDisplay(m).setCurrent(this); |
141 Display.getDisplay(m).setCurrent(this); |
133 |
142 |
134 //create StringItemForm |
143 //create StringItemForm |
135 stringItemForm = new Form("StringItem"); |
144 stringItemForm = new Form("StringItem"); |
136 stringItemForm.addCommand(cmdBack); |
145 stringItemForm.addCommand(cmdBack); |
|
146 stringItemForm.addCommand(cmdScreenF); |
137 stringItemForm.setCommandListener(this); |
147 stringItemForm.setCommandListener(this); |
138 } |
148 } |
139 |
149 |
140 /** |
150 /** |
141 * This method handles command invocations. |
151 * This method handles command invocations. |
221 { |
231 { |
222 stringItemForm.delete(0); |
232 stringItemForm.delete(0); |
223 } |
233 } |
224 else if (c == cmdLayout) |
234 else if (c == cmdLayout) |
225 { |
235 { |
226 |
|
227 layoutTest(Item.PLAIN); |
236 layoutTest(Item.PLAIN); |
228 |
|
229 } |
237 } |
230 else if (c == cmdLayoutHL) |
238 else if (c == cmdLayoutHL) |
231 { |
239 { |
232 |
|
233 layoutTest(Item.HYPERLINK); |
240 layoutTest(Item.HYPERLINK); |
234 |
|
235 } |
241 } |
236 else if (c == cmdLayoutButton) |
242 else if (c == cmdLayoutButton) |
237 { |
243 { |
238 |
|
239 layoutTest(Item.BUTTON); |
244 layoutTest(Item.BUTTON); |
240 |
|
241 } |
245 } |
242 else if (c == cmdVLayout) |
246 else if (c == cmdVLayout) |
243 { |
247 { |
244 |
|
245 verticalLayoutTest(Item.PLAIN); |
248 verticalLayoutTest(Item.PLAIN); |
246 |
|
247 } |
249 } |
248 else if (c == cmdVLayoutHL) |
250 else if (c == cmdVLayoutHL) |
249 { |
251 { |
250 |
|
251 verticalLayoutTest(Item.HYPERLINK); |
252 verticalLayoutTest(Item.HYPERLINK); |
252 |
|
253 } |
253 } |
254 else if (c == cmdVLayoutButton) |
254 else if (c == cmdVLayoutButton) |
255 { |
255 { |
256 |
|
257 verticalLayoutTest(Item.BUTTON); |
256 verticalLayoutTest(Item.BUTTON); |
258 |
|
259 } |
257 } |
260 else if (c == cmdAddListeners) |
258 else if (c == cmdAddListeners) |
261 { |
259 { |
262 int size = stringItemForm.size(); |
260 int size = stringItemForm.size(); |
263 for (int i = 0; i < size; i++) |
261 for (int i = 0; i < size; i++) |
280 String lo = cg.getString(index); |
283 String lo = cg.getString(index); |
281 int layout = 0; |
284 int layout = 0; |
282 |
285 |
283 if (c == cmdCreate) |
286 if (c == cmdCreate) |
284 si = new StringItem(l, t); |
287 si = new StringItem(l, t); |
285 else if (c == cmdCreateHL) |
288 else if (c == cmdCreateHL || c == cmdCreateHLM) |
286 { |
289 { |
287 si = new StringItem(l, t, Item.HYPERLINK); |
290 si = new StringItem(l, t, Item.HYPERLINK); |
288 si.setDefaultCommand(cmdItem); |
291 si.setDefaultCommand(cmdItem); |
289 } |
292 } |
290 else if (c == cmdCreateButton) |
293 else if (c == cmdCreateButton || c == cmdCreateButtonM) |
291 { |
294 { |
292 si = new StringItem(l, t, Item.BUTTON); |
295 si = new StringItem(l, t, Item.BUTTON); |
293 si.setDefaultCommand(cmdItem); |
296 si.setDefaultCommand(cmdItem); |
294 } |
297 } |
295 |
298 |
350 setSize(width.getString(),height.getString()); |
353 setSize(width.getString(),height.getString()); |
351 stringItemForm.append(si); |
354 stringItemForm.append(si); |
352 stringItemForm.addCommand(cmdRemoveCommand); |
355 stringItemForm.addCommand(cmdRemoveCommand); |
353 stringItemForm.addCommand(cmdRestoreCommand); |
356 stringItemForm.addCommand(cmdRestoreCommand); |
354 stringItemForm.addCommand(cmdRemoveItem); |
357 stringItemForm.addCommand(cmdRemoveItem); |
|
358 if (c == cmdCreateButtonM || c == cmdCreateHLM) |
|
359 { |
|
360 si.addCommand(cmdBack); |
|
361 } |
355 Display.getDisplay(m).setCurrent(stringItemForm); |
362 Display.getDisplay(m).setCurrent(stringItemForm); |
356 } |
363 } |
357 } |
364 } |
358 public void commandAction(Command c, Item i) |
365 public void commandAction(Command c, Item i) |
359 { |
366 { |