/*
* NewMessageScreen.java
*
* Author: C. Enrique Ortiz, October 2003
*
* Companion source code to "Advanced Messaging Coding with JSR 120".
*
* Based on original work by C. Enrique Ortiz.
*
* COPYRIGHT All rights reserved Sony Ericsson Mobile Communications AB 2003.
* The software is the copyrighted work of Sony Ericsson Mobile Communications AB.
* The use of the software is subject to the terms of the end-user license
* agreement which accompanies or is included with the software. The software is
* provided "as is" and Sony Ericsson specifically disclaim any warranty or
* condition whatsoever regarding merchantability or fitness for a specific
* purpose, title or non-infringement. No warranty of any kind is made in
* relation to the condition, suitability, availability, accuracy, reliability,
* merchantability and/or non-infringement of the software provided herein.
*/
package wmafw;
import javax.microedition.lcdui.*;
/**
* NewMessageScreen displays the compose screen.
*/
class NewMessageScreen
{
/************/
/* Commands */
/************/
/** ViewCommand */
protected static Command SEND = new Command(UIConstants.TXT_SEND, Command.OK, 1);
/** Back Command */
protected static Command BACK = new Command(UIConstants.TXT_BACK, Command.BACK, 2);
/******/
/* UI */
/******/
/** Current display context */
private Display display;
/** The command listener responsible of application navigation */
private CommandListener commandListener;
/** The screen's ticker */
private Ticker ticker = new Ticker(" ");
/** The screen */
private Form screen;
/** To TextField */
private TextField toTF = new TextField(UIConstants.TXT_TO, "", 25, TextField.ANY);
/** Message TextField */
private TextField messageTF = new TextField(UIConstants.TXT_MESSAGE, "", 140, TextField.ANY);
/** Previous screen to return to */
private Displayable backScreen;
/**
* Constructor.
* @param d is the display context.
* @param cl is the command listener for this screen.
*/
protected NewMessageScreen(Display d, CommandListener cl) {
display = d;
commandListener = cl;
screen = new Form(UIConstants.TXT_NEW_MESSAGE);
screen.append(toTF);
screen.append(messageTF);
screen.addCommand(BACK);
screen.addCommand(SEND);
screen.setCommandListener(commandListener);
screen.setTicker(ticker);
}
/**
* Make the main menu visible.
* @param to is the message receipient.
* @param backScreen is the screen to return to.
*/
protected void showScreen(String to, Displayable backScreen) {
this.backScreen = backScreen;
toTF.setString(to);
if (display != null) display.setCurrent(screen);
}
/**
* Returns the main menu Displayable.
* @return the main menu screen.
*/
protected Displayable getScreen() {
return screen;
}
/**
* Returns the Displayable to return to.
* @return the screen to return to.
*/
protected Displayable getBackScreen() {
return backScreen;
}
/**
* Sets the content of the display's ticker
*/
protected void setTicker(String text) {
ticker.setString(text);
}
/**
* Returns the contents of the To TextField.
* @return the value of the To Textfield.
*/
protected String getFieldTo() {
return toTF.getString();
}
/**
* Returns the contents of the Message TextField.
* @return the value of the Message Textfield.
*/
protected String getFieldMessage() {
return messageTF.getString();
}
}
|