From fb3d21dd264151dce808d7698ee0d8a28d6f227e Mon Sep 17 00:00:00 2001
From: Jacek Kowalski <Jacek@jacekk.info>
Date: Wed, 08 Aug 2012 09:50:50 +0000
Subject: [PATCH] Przeniesienie menu z osobnej formatki pod przycisk.
---
src/brydz/BrydzForm.java | 56 +++++++++++++++++++++++++++++++++++++++-----------------
1 files changed, 39 insertions(+), 17 deletions(-)
diff --git a/src/brydz/BrydzForm.java b/src/brydz/BrydzForm.java
index 9c8f78d..bf56192 100644
--- a/src/brydz/BrydzForm.java
+++ b/src/brydz/BrydzForm.java
@@ -4,6 +4,8 @@
public class BrydzForm extends Form implements CommandListener, ItemStateListener {
protected BrydzMIDlet midlet;
+ protected BrydzPomocForm help = null;
+ protected BrydzPomocForm about = null;
protected TextField kontraktField;
protected ChoiceGroup kontraktChoice;
@@ -51,26 +53,46 @@
this.append(this.lewyField);
this.append(this.resultText);
- setItemStateListener(this);
- setCommandListener(this);
- addCommand(new Command("Wyczyść", Command.OK, 1));
- addCommand(new Command("Wyjście", Command.EXIT, 1));
+ this.addCommand(new Command("Wyczyść", Command.BACK, 1));
+ this.addCommand(new Command("Pomoc", Command.HELP, 2));
+ this.addCommand(new Command("O programie", Command.HELP, 3));
+ this.addCommand(new Command("Wyjście", Command.EXIT, 4));
+
+ this.setItemStateListener(this);
+ this.setCommandListener(this);
}
public void commandAction(Command command, Displayable displayable) {
- if (command.getCommandType() == Command.OK) {
- this.kontraktField.setString(null);
- this.kontraktChoice.setSelectedIndex(0, true);
- this.kontraChoice.setSelectedIndex(0, true);
- this.partiaChoice.setSelectedIndex(0, true);
- this.punktyField.setString(null);
- this.lewyField.setString(null);
- this.resultText.setText("Podaj wszystkie dane.");
-
- Display.getDisplay(this.midlet).setCurrentItem(this.kontraktField);
- }
- else if (command.getCommandType() == Command.EXIT) {
- this.midlet.destroyApp(true);
+ switch(command.getCommandType()) {
+ case Command.EXIT:
+ this.midlet.destroyApp(true);
+ break;
+ case Command.CANCEL:
+ case Command.BACK:
+ this.kontraktField.setString(null);
+ this.kontraktChoice.setSelectedIndex(0, true);
+ this.kontraChoice.setSelectedIndex(0, true);
+ this.partiaChoice.setSelectedIndex(0, true);
+ this.punktyField.setString(null);
+ this.lewyField.setString(null);
+ this.resultText.setText("Podaj wszystkie dane.");
+
+ this.midlet.display.setCurrentItem(this.kontraktField);
+ break;
+ case Command.HELP:
+ if(command.getPriority() == 2) {
+ if(this.help == null) {
+ this.help = new BrydzPomocForm(this.midlet, this, false);
+ }
+ this.midlet.display.setCurrent(this.help);
+ }
+ else if(command.getPriority() == 3) {
+ if(this.about == null) {
+ this.about = new BrydzPomocForm(this.midlet, this, true);
+ }
+ this.midlet.display.setCurrent(this.about);
+ }
+ break;
}
}
--
Gitblit v1.10.0