Redesigned the interface of the handheld version.

This commit is contained in:
amontano 2003-08-03 06:29:08 +00:00
parent 2b5a5fe67a
commit ef0df405d9

View file

@ -30,74 +30,70 @@ import java.awt.event.*;
@see WindowScannerFilter @see WindowScannerFilter
*/ */
public class SimpleScannerPanel extends ScannerPanel public class SimpleScannerPanel extends ScannerPanel implements ItemListener
{ {
private TextArea txtInput, txtOutput; private TextArea txtInput, txtOutput;
private Panel inputPanel; private Panel cardPanel;
private List listDefs;
private Word wordArray[];
private int lenPreview;
private static int WIDTH_PORTRAIT = 34;
private static int WIDTH_LANDSCAPE = 46;
public SimpleScannerPanel(String file, boolean landscape) public SimpleScannerPanel(String file, boolean landscape)
{ {
super(file); super(file);
Panel panel1, panel2; Panel panel1, panel2;
inputPanel = new Panel(new CardLayout()); cardPanel = new Panel(new CardLayout());
txtInput = new TextArea("",1,1,TextArea.SCROLLBARS_VERTICAL_ONLY);
inputPanel.add(txtInput, "1");
if (landscape) panel2 = getDictPanel(5); // FIXME values shouldn't be hardwired
else panel2 = getDictPanel(4); if (landscape) lenPreview = WIDTH_LANDSCAPE;
if (panel2!=null) else lenPreview = WIDTH_PORTRAIT;
{ wordArray=null;
inputPanel.add(panel2, "2");
}
txtOutput = new TextArea("",0,0,TextArea.SCROLLBARS_VERTICAL_ONLY); // panel1 = new Panel(new GridLayout(3, 1));
txtOutput.setEditable(false);
panel1 = new Panel(new BorderLayout()); panel1 = new Panel(new BorderLayout());
panel1.add(inputPanel, BorderLayout.NORTH); // txtInput = new TextArea("",1,1,TextArea.SCROLLBARS_VERTICAL_ONLY);
panel1.add(txtOutput, BorderLayout.CENTER); if (landscape) txtInput = new TextArea("", 2, WIDTH_LANDSCAPE, TextArea.SCROLLBARS_VERTICAL_ONLY);
else txtInput = new TextArea("", 3, WIDTH_PORTRAIT, TextArea.SCROLLBARS_VERTICAL_ONLY);
//panel1.add(txtInput);
panel1.add(txtInput, BorderLayout.NORTH);
listDefs = new List();
listDefs.setMultipleMode(false);
listDefs.addItemListener(this);
/*panel1 = new Panel (new GridLayout(2,1)); panel2 = new Panel(new GridLayout(2,1));
panel1.add(inputPanel); panel2.add(listDefs);
panel1.add(txtOutput);*/ txtOutput = new TextArea("",0,0,TextArea.SCROLLBARS_VERTICAL_ONLY);
txtOutput.setEditable(false);
panel2.add(txtOutput);
panel1.add(panel2, BorderLayout.CENTER);
cardPanel.add(panel1, "1");
/*GridBagLayout gridbag = new GridBagLayout(); // FIXME: values shouldn't be hardwired
GridBagConstraints c = new GridBagConstraints(); if (landscape) panel2 = getDictPanel(2);
panel1 = new Panel(gridbag); else panel2 = getDictPanel(1);
c.weightx=1; if (panel2!=null)
c.gridheight=1; {
c.fill = GridBagConstraints.BOTH; cardPanel.add(panel2, "2");
c.gridwidth = GridBagConstraints.REMAINDER;
gridbag.setConstraints(inputPanel, c);
panel1.add(inputPanel);
c.gridheight=2;
c.weighty=1;
c.gridheight = GridBagConstraints.REMAINDER;
gridbag.setConstraints(txtOutput, c);
panel1.add(txtOutput);*/
/* GridBagLayout gridbag = new GridBagLayout();
GridBagConstraints c = new GridBagConstraints();
panel1 = new Panel(gridbag);
c.weightx=1;
c.weighty=1;
c.gridheight=1;
c.fill = GridBagConstraints.BOTH;
c.gridwidth = GridBagConstraints.REMAINDER;
gridbag.setConstraints(txtInput, c);
panel1.add(txtInput);
c.gridheight = GridBagConstraints.REMAINDER;
c.ipady = 70;
gridbag.setConstraints(txtOutput, c);*/
add(panel1, BorderLayout.CENTER);
} }
add(cardPanel, BorderLayout.CENTER);
}
public void itemStateChanged(ItemEvent e)
{
int n = listDefs.getSelectedIndex();
if (n>-1) txtOutput.setText(wordArray[n].toString());
}
public void setWylieInput(boolean enabled) public void setWylieInput(boolean enabled)
{ {
CardLayout cl = (CardLayout) inputPanel.getLayout(); CardLayout cl = (CardLayout) cardPanel.getLayout();
if (enabled) cl.first(inputPanel); if (enabled) cl.first(cardPanel);
else cl.last(inputPanel); else cl.last(cardPanel);
} }
@ -110,17 +106,25 @@ public class SimpleScannerPanel extends ScannerPanel
public void printAllDefs() public void printAllDefs()
{ {
int i; int i;
Object array[] = scanner.getTokenArray(); wordArray = scanner.getWordArray();
String preview;
for(i=0; i<array.length; i++) listDefs.removeAll();
if (array[i] instanceof Word)
txtOutput.append("* " + array[i].toString() + "\n\n"); for(i=0; i<wordArray.length; i++)
{
preview = wordArray[i].toString();
if (preview.length()>lenPreview) preview = preview.substring(0,lenPreview);
listDefs.add(preview);
}
} }
public void clear() public void clear()
{ {
txtInput.setText(""); txtInput.setText("");
txtOutput.setText(""); txtOutput.setText("");
listDefs.removeAll();
} }
public void translate() public void translate()