Now the handheld version supports both portrait and landscape.
This commit is contained in:
parent
f9670233ba
commit
8565855dd1
5 changed files with 122 additions and 82 deletions
|
@ -263,7 +263,7 @@ public class AppletScannerFilter extends JApplet implements ActionListener, Focu
|
|||
}
|
||||
public void itemStateChanged(ItemEvent e)
|
||||
{
|
||||
sp.setEnableTibetanScript(e.getStateChange()==ItemEvent.SELECTED);
|
||||
sp.setWylieInput(e.getStateChange()!=ItemEvent.SELECTED);
|
||||
}
|
||||
|
||||
class SymComponent extends java.awt.event.ComponentAdapter
|
||||
|
|
|
@ -50,7 +50,10 @@ public class DuffScannerPanel extends ScannerPanel
|
|||
public DuffScannerPanel(String file)
|
||||
{
|
||||
super(file);
|
||||
Panel panel1;
|
||||
Panel panel1, panel2;
|
||||
panel2 = new Panel(new BorderLayout());
|
||||
panel1 = getDictPanel();
|
||||
if (panel1!=null) panel2.add (panel1, BorderLayout.NORTH);
|
||||
panel1 = new Panel(new GridLayout(3,1));
|
||||
/* Looks up tibcodes in directory of applet. In order
|
||||
to work through a proxy store all the applet classes toghether
|
||||
|
@ -77,7 +80,8 @@ public class DuffScannerPanel extends ScannerPanel
|
|||
|
||||
panel1.add(listDef);
|
||||
panel1.add(fullDef);
|
||||
add(panel1, BorderLayout.CENTER);
|
||||
panel2.add(panel1, BorderLayout.CENTER);
|
||||
add(panel2, BorderLayout.CENTER);
|
||||
showingTibetan = true;
|
||||
|
||||
// tibetanFont = new Font("TibetanMachine",Font.PLAIN,36);
|
||||
|
@ -175,10 +179,10 @@ public class DuffScannerPanel extends ScannerPanel
|
|||
table.repaint();
|
||||
}
|
||||
|
||||
public void setEnableTibetanScript(boolean enabled)
|
||||
public void setWylieInput(boolean enabled)
|
||||
{
|
||||
CardLayout cl = (CardLayout) inputPanel.getLayout();
|
||||
if (enabled && !showingTibetan)
|
||||
if (!enabled && !showingTibetan)
|
||||
{
|
||||
String s = txtInput.getText();
|
||||
/* int posEnter = s.indexOf('\n');
|
||||
|
@ -191,7 +195,7 @@ public class DuffScannerPanel extends ScannerPanel
|
|||
cl.first(inputPanel);
|
||||
showingTibetan = true;
|
||||
}
|
||||
if (!enabled && showingTibetan)
|
||||
if (enabled && showingTibetan)
|
||||
{
|
||||
txtInput.setText(duffInput.getWylie());
|
||||
table.activateTibetan(false);
|
||||
|
|
|
@ -31,6 +31,7 @@ import java.io.*;
|
|||
*/
|
||||
public abstract class ScannerPanel extends Panel implements ActionListener
|
||||
{
|
||||
private static int dictCols=4;
|
||||
private Label status;
|
||||
protected Checkbox chkDicts[];
|
||||
Button cmdTranslate;
|
||||
|
@ -40,26 +41,9 @@ public abstract class ScannerPanel extends Panel implements ActionListener
|
|||
hidden through the menu.
|
||||
*/
|
||||
|
||||
public ScannerPanel(String file, boolean ipaq)
|
||||
{
|
||||
this(file, ipaq, 4);
|
||||
}
|
||||
|
||||
public ScannerPanel(String file)
|
||||
{
|
||||
this(file, false, 4);
|
||||
}
|
||||
|
||||
public ScannerPanel(String file, int cols)
|
||||
{
|
||||
this(file, false, 4);
|
||||
}
|
||||
|
||||
public ScannerPanel(String file, boolean ipaq, int cols)
|
||||
|
||||
{
|
||||
boolean exito=true;
|
||||
int rows, n;
|
||||
|
||||
setLayout(new BorderLayout());
|
||||
status = new Label();
|
||||
|
@ -83,57 +67,58 @@ public abstract class ScannerPanel extends Panel implements ActionListener
|
|||
else
|
||||
scanner = new LocalTibetanScanner(file);
|
||||
|
||||
String dictionaries[] = scanner.getDictionaryDescriptions();
|
||||
if (dictionaries!=null)
|
||||
{
|
||||
n = dictionaries.length;
|
||||
chkDicts = new Checkbox[n];
|
||||
if (n>cols)
|
||||
{
|
||||
rows = n/cols;
|
||||
if (n%cols>0) rows++;
|
||||
}
|
||||
else
|
||||
{
|
||||
cols = n;
|
||||
rows = 1;
|
||||
}
|
||||
Panel panel2 = new Panel(new GridLayout(rows,cols));
|
||||
// panel2 = new Panel();
|
||||
int i;
|
||||
|
||||
for (i=0; i<dictionaries.length; i++)
|
||||
{
|
||||
if (dictionaries[i]!=null)
|
||||
chkDicts[i] = new Checkbox(dictionaries[i] + " (" + Definitions.defTags[i] + ")", true);
|
||||
else
|
||||
chkDicts[i] = new Checkbox(Definitions.defTags[i], true);
|
||||
panel2.add(chkDicts[i]);
|
||||
}
|
||||
panel1.add(panel2, BorderLayout.SOUTH);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
status.setText("Dictionary could no be loaded!");
|
||||
exito=false;
|
||||
}
|
||||
if (ipaq)
|
||||
{
|
||||
/* panel2 = new Panel(new BorderLayout());
|
||||
panel2.add(panel1, BorderLayout.CENTER);
|
||||
panel2.add(copyright, BorderLayout.SOUTH);
|
||||
add(panel2, BorderLayout.SOUTH);*/
|
||||
add(panel1, BorderLayout.SOUTH);
|
||||
}
|
||||
else
|
||||
{
|
||||
add(panel1, BorderLayout.NORTH);
|
||||
// add(copyright, BorderLayout.SOUTH);
|
||||
}
|
||||
add(panel1, BorderLayout.NORTH);
|
||||
|
||||
if (exito)
|
||||
returnStatusToNorm();
|
||||
}
|
||||
|
||||
protected Panel getDictPanel()
|
||||
{
|
||||
return getDictPanel(dictCols);
|
||||
}
|
||||
|
||||
protected Panel getDictPanel(int dictCols)
|
||||
{
|
||||
int rows, n;
|
||||
|
||||
String dictionaries[] = scanner.getDictionaryDescriptions();
|
||||
if (dictionaries!=null)
|
||||
{
|
||||
n = dictionaries.length;
|
||||
chkDicts = new Checkbox[n];
|
||||
if (n>dictCols)
|
||||
{
|
||||
rows = n/dictCols;
|
||||
if (n%dictCols>0) rows++;
|
||||
}
|
||||
else
|
||||
{
|
||||
dictCols = n;
|
||||
rows = 1;
|
||||
}
|
||||
Panel panel2 = new Panel(new GridLayout(rows,dictCols));
|
||||
// panel2 = new Panel();
|
||||
int i;
|
||||
|
||||
for (i=0; i<dictionaries.length; i++)
|
||||
{
|
||||
if (dictionaries[i]!=null)
|
||||
chkDicts[i] = new Checkbox(dictionaries[i] + " (" + Definitions.defTags[i] + ")", true);
|
||||
else
|
||||
chkDicts[i] = new Checkbox(Definitions.defTags[i], true);
|
||||
panel2.add(chkDicts[i]);
|
||||
}
|
||||
return panel2;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void doingStatus(String s)
|
||||
{
|
||||
|
@ -177,6 +162,6 @@ public abstract class ScannerPanel extends Panel implements ActionListener
|
|||
|
||||
public abstract void translate();
|
||||
public abstract void clear();
|
||||
public void setEnableTibetanScript(boolean enabled) {}
|
||||
public abstract void setWylieInput(boolean enabled);
|
||||
public void addFocusListener(FocusListener fl) {}
|
||||
}
|
||||
|
|
|
@ -33,12 +33,50 @@ import java.awt.event.*;
|
|||
public class SimpleScannerPanel extends ScannerPanel
|
||||
{
|
||||
private TextArea txtInput, txtOutput;
|
||||
private Panel inputPanel;
|
||||
|
||||
public SimpleScannerPanel(String file)
|
||||
public SimpleScannerPanel(String file, boolean landscape)
|
||||
{
|
||||
super(file, true);
|
||||
Panel panel1;
|
||||
GridBagLayout gridbag = new GridBagLayout();
|
||||
super(file);
|
||||
Panel panel1, panel2;
|
||||
inputPanel = new Panel(new CardLayout());
|
||||
txtInput = new TextArea("",1,1,TextArea.SCROLLBARS_VERTICAL_ONLY);
|
||||
inputPanel.add(txtInput, "1");
|
||||
|
||||
if (landscape) panel2 = getDictPanel(5);
|
||||
else panel2 = getDictPanel(4);
|
||||
if (panel2!=null)
|
||||
{
|
||||
inputPanel.add(panel2, "2");
|
||||
}
|
||||
|
||||
txtOutput = new TextArea("",0,0,TextArea.SCROLLBARS_VERTICAL_ONLY);
|
||||
txtOutput.setEditable(false);
|
||||
|
||||
panel1 = new Panel(new BorderLayout());
|
||||
panel1.add(inputPanel, BorderLayout.NORTH);
|
||||
panel1.add(txtOutput, BorderLayout.CENTER);
|
||||
|
||||
/*panel1 = new Panel (new GridLayout(2,1));
|
||||
panel1.add(inputPanel);
|
||||
panel1.add(txtOutput);*/
|
||||
|
||||
/*GridBagLayout gridbag = new GridBagLayout();
|
||||
GridBagConstraints c = new GridBagConstraints();
|
||||
panel1 = new Panel(gridbag);
|
||||
c.weightx=1;
|
||||
c.gridheight=1;
|
||||
c.fill = GridBagConstraints.BOTH;
|
||||
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;
|
||||
|
@ -46,17 +84,22 @@ public class SimpleScannerPanel extends ScannerPanel
|
|||
c.gridheight=1;
|
||||
c.fill = GridBagConstraints.BOTH;
|
||||
c.gridwidth = GridBagConstraints.REMAINDER;
|
||||
txtInput = new TextArea("",0,0,TextArea.SCROLLBARS_VERTICAL_ONLY);
|
||||
txtOutput = new TextArea("",0,0,TextArea.SCROLLBARS_VERTICAL_ONLY);
|
||||
txtOutput.setEditable(false);
|
||||
gridbag.setConstraints(txtInput, c);
|
||||
panel1.add(txtInput);
|
||||
c.gridheight = GridBagConstraints.REMAINDER;
|
||||
c.ipady = 70;
|
||||
gridbag.setConstraints(txtOutput, c);
|
||||
panel1.add(txtOutput);
|
||||
gridbag.setConstraints(txtOutput, c);*/
|
||||
|
||||
add(panel1, BorderLayout.CENTER);
|
||||
}
|
||||
|
||||
public void setWylieInput(boolean enabled)
|
||||
{
|
||||
CardLayout cl = (CardLayout) inputPanel.getLayout();
|
||||
if (enabled) cl.first(inputPanel);
|
||||
else cl.last(inputPanel);
|
||||
}
|
||||
|
||||
|
||||
public void addFocusListener(FocusListener fl)
|
||||
{
|
||||
|
|
|
@ -46,7 +46,7 @@ public class WindowScannerFilter implements WindowListener, FocusListener, Actio
|
|||
{
|
||||
private ScannerPanel sp;
|
||||
private MenuItem mnuExit, mnuCut, mnuCopy, mnuPaste, mnuDelete, mnuSelectAll, mnuAbout, mnuClear;
|
||||
private CheckboxMenuItem tibScript;
|
||||
private CheckboxMenuItem tibScript, mnuDicts;
|
||||
private Object objModified;
|
||||
private Frame frame;
|
||||
private Dialog diagAbout;
|
||||
|
@ -64,11 +64,12 @@ public class WindowScannerFilter implements WindowListener, FocusListener, Actio
|
|||
frame.setBackground(Color.white);
|
||||
diagAbout = null;
|
||||
usingSwing=!ipaq;
|
||||
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
|
||||
|
||||
if (usingSwing)
|
||||
sp = new DuffScannerPanel(file);
|
||||
else
|
||||
sp = new SimpleScannerPanel(file);
|
||||
sp = new SimpleScannerPanel(file, d.width >d.height);
|
||||
|
||||
MenuBar mb = new MenuBar();
|
||||
Menu m = new Menu ("File");
|
||||
|
@ -102,15 +103,22 @@ public class WindowScannerFilter implements WindowListener, FocusListener, Actio
|
|||
m.add(mnuClear);
|
||||
mnuClear.addActionListener(this);
|
||||
mb.add(m);
|
||||
m = new Menu("View");
|
||||
if (usingSwing)
|
||||
{
|
||||
m = new Menu("View");
|
||||
tibScript = new CheckboxMenuItem("Tibetan Script", true);
|
||||
m.add(tibScript);
|
||||
tibScript.addItemListener(this);
|
||||
mb.add(m);
|
||||
mnuDicts=null;
|
||||
}
|
||||
else tibScript=null;
|
||||
else
|
||||
{
|
||||
mnuDicts = new CheckboxMenuItem("Dictionaries", false);
|
||||
m.add(mnuDicts);
|
||||
mnuDicts.addItemListener(this);
|
||||
tibScript=null;
|
||||
}
|
||||
mb.add(m);
|
||||
|
||||
m = new Menu("Help");
|
||||
mnuAbout = new MenuItem("About...");
|
||||
|
@ -125,7 +133,7 @@ public class WindowScannerFilter implements WindowListener, FocusListener, Actio
|
|||
frame.setMenuBar(mb);
|
||||
frame.add(sp);
|
||||
frame.addWindowListener(this);
|
||||
frame.setSize(Toolkit.getDefaultToolkit().getScreenSize());
|
||||
frame.setSize(d);
|
||||
// frame.setSize(240,320);
|
||||
//else frame.setSize(500,600);
|
||||
frame.show();
|
||||
|
@ -374,6 +382,6 @@ public class WindowScannerFilter implements WindowListener, FocusListener, Actio
|
|||
|
||||
public void itemStateChanged(ItemEvent e)
|
||||
{
|
||||
sp.setEnableTibetanScript(e.getStateChange()==ItemEvent.SELECTED);
|
||||
sp.setWylieInput(e.getStateChange()!=ItemEvent.SELECTED);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue