206 "Now, congratulations if you can read this final line!"; |
206 "Now, congratulations if you can read this final line!"; |
207 si = new StringItem("The StringItem", longString); |
207 si = new StringItem("The StringItem", longString); |
208 stringItemForm.append(si); |
208 stringItemForm.append(si); |
209 Display.getDisplay(m).setCurrent(stringItemForm); |
209 Display.getDisplay(m).setCurrent(stringItemForm); |
210 } |
210 } |
211 else if (c == cmdNext) |
211 else if(c == cmdNext) |
212 { |
212 { |
213 change++; |
213 change++; |
214 changeForm(); |
214 changeForm(); |
215 } |
215 } |
216 else if (c == cmdRemoveCommand) |
216 else if(c == cmdRemoveCommand) |
217 { |
217 { |
218 Item item = null; |
218 Item item = null; |
219 item = stringItemForm.get(0); |
219 item = stringItemForm.get(0); |
220 item.removeCommand(cmdUnlock); |
220 item.removeCommand(cmdUnlock); |
221 item.removeCommand(cmdItem); |
221 item.removeCommand(cmdItem); |
222 } |
222 } |
223 else if (c == cmdRestoreCommand) |
223 else if(c == cmdRestoreCommand) |
224 { |
224 { |
225 Item item = null; |
225 Item item = null; |
226 item = stringItemForm.get(0); |
226 item = stringItemForm.get(0); |
227 item.addCommand(cmdUnlock); |
227 item.addCommand(cmdUnlock); |
228 item.setDefaultCommand(cmdItem); |
228 item.setDefaultCommand(cmdItem); |
229 } |
229 } |
230 else if (c == cmdRemoveItem) |
230 else if(c == cmdRemoveItem) |
231 { |
231 { |
232 stringItemForm.delete(0); |
232 stringItemForm.delete(0); |
233 } |
233 } |
234 else if (c == cmdLayout) |
234 else if(c == cmdLayout) |
235 { |
235 { |
236 layoutTest(Item.PLAIN); |
236 layoutTest(Item.PLAIN); |
237 } |
237 } |
238 else if (c == cmdLayoutHL) |
238 else if(c == cmdLayoutHL) |
239 { |
239 { |
240 layoutTest(Item.HYPERLINK); |
240 layoutTest(Item.HYPERLINK); |
241 } |
241 } |
242 else if (c == cmdLayoutButton) |
242 else if(c == cmdLayoutButton) |
243 { |
243 { |
244 layoutTest(Item.BUTTON); |
244 layoutTest(Item.BUTTON); |
245 } |
245 } |
246 else if (c == cmdVLayout) |
246 else if(c == cmdVLayout) |
247 { |
247 { |
248 verticalLayoutTest(Item.PLAIN); |
248 verticalLayoutTest(Item.PLAIN); |
249 } |
249 } |
250 else if (c == cmdVLayoutHL) |
250 else if(c == cmdVLayoutHL) |
251 { |
251 { |
252 verticalLayoutTest(Item.HYPERLINK); |
252 verticalLayoutTest(Item.HYPERLINK); |
253 } |
253 } |
254 else if (c == cmdVLayoutButton) |
254 else if(c == cmdVLayoutButton) |
255 { |
255 { |
256 verticalLayoutTest(Item.BUTTON); |
256 verticalLayoutTest(Item.BUTTON); |
257 } |
257 } |
258 else if (c == cmdAddListeners) |
258 else if(c == cmdAddListeners) |
259 { |
259 { |
260 int size = stringItemForm.size(); |
260 int size = stringItemForm.size(); |
261 for (int i = 0; i < size; i++) |
261 for(int i = 0; i < size; i++) |
262 { |
262 { |
263 Item item = null; |
263 Item item = null; |
264 item = stringItemForm.get(i); |
264 item = stringItemForm.get(i); |
265 item.setItemCommandListener(this); |
265 item.setItemCommandListener(this); |
266 } |
266 } |
267 } |
267 } |
268 else if (c == cmdExit) |
268 else if(c == cmdExit) |
269 { |
269 { |
270 m.destroyApp(false); |
270 m.destroyApp(false); |
271 m.notifyDestroyed(); |
271 m.notifyDestroyed(); |
272 } |
272 } |
273 else if (c == cmdScreenF) |
273 else if(c == cmdScreenF) |
274 { |
274 { |
275 stringItemForm.addCommand(cmdItemF); |
275 stringItemForm.addCommand(cmdItemF); |
276 stringItemForm.addCommand(cmdOkF); |
276 stringItemForm.addCommand(cmdOkF); |
277 } |
277 } |
278 else |
278 else |
281 String t = text.getString(); |
281 String t = text.getString(); |
282 int index = cg.getSelectedIndex(); |
282 int index = cg.getSelectedIndex(); |
283 String lo = cg.getString(index); |
283 String lo = cg.getString(index); |
284 int layout = 0; |
284 int layout = 0; |
285 |
285 |
286 if (c == cmdCreate) |
286 if(c == cmdCreate) |
287 si = new StringItem(l, t); |
287 si = new StringItem(l, t); |
288 else if (c == cmdCreateHL || c == cmdCreateHLM) |
288 else if(c == cmdCreateHL || c == cmdCreateHLM) |
289 { |
289 { |
290 si = new StringItem(l, t, Item.HYPERLINK); |
290 si = new StringItem(l, t, Item.HYPERLINK); |
291 si.setDefaultCommand(cmdItem); |
291 si.setDefaultCommand(cmdItem); |
292 } |
292 } |
293 else if (c == cmdCreateButton || c == cmdCreateButtonM) |
293 else if(c == cmdCreateButton || c == cmdCreateButtonM) |
294 { |
294 { |
295 si = new StringItem(l, t, Item.BUTTON); |
295 si = new StringItem(l, t, Item.BUTTON); |
296 si.setDefaultCommand(cmdItem); |
296 si.setDefaultCommand(cmdItem); |
297 } |
297 } |
298 |
298 |
299 if (lo.equals(cgTypes[0])) |
299 if(lo.equals(cgTypes[0])) |
300 { |
300 { |
301 layout = Item.LAYOUT_DEFAULT; |
301 layout = Item.LAYOUT_DEFAULT; |
302 } |
302 } |
303 else if (lo.equals(cgTypes[1])) |
303 else if(lo.equals(cgTypes[1])) |
304 { |
304 { |
305 layout = Item.LAYOUT_LEFT; |
305 layout = Item.LAYOUT_LEFT; |
306 } |
306 } |
307 else if (lo.equals(cgTypes[2])) |
307 else if(lo.equals(cgTypes[2])) |
308 { |
308 { |
309 layout = Item.LAYOUT_RIGHT; |
309 layout = Item.LAYOUT_RIGHT; |
310 } |
310 } |
311 else if (lo.equals(cgTypes[3])) |
311 else if(lo.equals(cgTypes[3])) |
312 { |
312 { |
313 layout = Item.LAYOUT_CENTER; |
313 layout = Item.LAYOUT_CENTER; |
314 } |
314 } |
315 else if (lo.equals(cgTypes[4])) |
315 else if(lo.equals(cgTypes[4])) |
316 { |
316 { |
317 layout = Item.LAYOUT_TOP; |
317 layout = Item.LAYOUT_TOP; |
318 } |
318 } |
319 else if (lo.equals(cgTypes[5])) |
319 else if(lo.equals(cgTypes[5])) |
320 { |
320 { |
321 layout = Item.LAYOUT_BOTTOM; |
321 layout = Item.LAYOUT_BOTTOM; |
322 } |
322 } |
323 else if (lo.equals(cgTypes[6])) |
323 else if(lo.equals(cgTypes[6])) |
324 { |
324 { |
325 layout = Item.LAYOUT_VCENTER; |
325 layout = Item.LAYOUT_VCENTER; |
326 } |
326 } |
327 else if (lo.equals(cgTypes[7])) |
327 else if(lo.equals(cgTypes[7])) |
328 { |
328 { |
329 layout = Item.LAYOUT_NEWLINE_BEFORE; |
329 layout = Item.LAYOUT_NEWLINE_BEFORE; |
330 } |
330 } |
331 else if (lo.equals(cgTypes[8])) |
331 else if(lo.equals(cgTypes[8])) |
332 { |
332 { |
333 layout = Item.LAYOUT_NEWLINE_AFTER; |
333 layout = Item.LAYOUT_NEWLINE_AFTER; |
334 } |
334 } |
335 else if (lo.equals(cgTypes[9])) |
335 else if(lo.equals(cgTypes[9])) |
336 { |
336 { |
337 layout = Item.LAYOUT_SHRINK; |
337 layout = Item.LAYOUT_SHRINK; |
338 } |
338 } |
339 else if (lo.equals(cgTypes[10])) |
339 else if(lo.equals(cgTypes[10])) |
340 { |
340 { |
341 layout = Item.LAYOUT_VSHRINK; |
341 layout = Item.LAYOUT_VSHRINK; |
342 } |
342 } |
343 else if (lo.equals(cgTypes[11])) |
343 else if(lo.equals(cgTypes[11])) |
344 { |
344 { |
345 layout = Item.LAYOUT_EXPAND; |
345 layout = Item.LAYOUT_EXPAND; |
346 } |
346 } |
347 else if (lo.equals(cgTypes[12])) |
347 else if(lo.equals(cgTypes[12])) |
348 { |
348 { |
349 layout = Item.LAYOUT_VEXPAND; |
349 layout = Item.LAYOUT_VEXPAND; |
350 } |
350 } |
351 si.setItemCommandListener(this); |
351 si.setItemCommandListener(this); |
352 si.setLayout(layout); |
352 si.setLayout(layout); |
353 setSize(width.getString(),height.getString()); |
353 setSize(width.getString(),height.getString()); |
354 stringItemForm.append(si); |
354 stringItemForm.append(si); |
355 stringItemForm.addCommand(cmdRemoveCommand); |
355 stringItemForm.addCommand(cmdRemoveCommand); |
356 stringItemForm.addCommand(cmdRestoreCommand); |
356 stringItemForm.addCommand(cmdRestoreCommand); |
357 stringItemForm.addCommand(cmdRemoveItem); |
357 stringItemForm.addCommand(cmdRemoveItem); |
358 if (c == cmdCreateButtonM || c == cmdCreateHLM) |
358 if(c == cmdCreateButtonM || c == cmdCreateHLM) |
359 { |
359 { |
360 si.addCommand(cmdBack); |
360 si.addCommand(cmdBack); |
361 } |
361 } |
362 Display.getDisplay(m).setCurrent(stringItemForm); |
362 Display.getDisplay(m).setCurrent(stringItemForm); |
363 } |
363 } |
364 } |
364 } |
365 public void commandAction(Command c, Item i) |
365 public void commandAction(Command c, Item i) |
366 { |
366 { |
367 if (c == cmdBack) |
367 if(c == cmdBack) |
368 { |
368 { |
369 label.setString(null); |
369 label.setString(null); |
370 text.setString(null); |
370 text.setString(null); |
371 Display.getDisplay(m).setCurrent(this); |
371 Display.getDisplay(m).setCurrent(this); |
372 } |
372 } |
373 else if (c == cmdUnlock) |
373 else if(c == cmdUnlock) |
374 { |
374 { |
375 i.setPreferredSize(-1,-1); |
375 i.setPreferredSize(-1,-1); |
376 } |
376 } |
377 else if (c == cmdItem) |
377 else if(c == cmdItem) |
378 { |
378 { |
379 i.setLabel(i.getLabel() + "."); |
379 i.setLabel(i.getLabel() + "."); |
380 } |
380 } |
381 } |
381 } |
382 private void setSize(String width, String height) |
382 private void setSize(String width, String height) |
383 { |
383 { |
384 if (width.equals("") && height.equals("")) |
384 if(width.equals("") && height.equals("")) |
385 { |
385 { |
386 si.setPreferredSize(-1,-1); |
386 si.setPreferredSize(-1,-1); |
387 } |
387 } |
388 else if (height.equals("")) |
388 else if(height.equals("")) |
389 { |
389 { |
390 si.setPreferredSize(Integer.parseInt(width),-1); |
390 si.setPreferredSize(Integer.parseInt(width),-1); |
391 } |
391 } |
392 else if (width.equals("")) |
392 else if(width.equals("")) |
393 { |
393 { |
394 si.setPreferredSize(-1,Integer.parseInt(height)); |
394 si.setPreferredSize(-1,Integer.parseInt(height)); |
395 } |
395 } |
396 else |
396 else |
397 { |
397 { |