From 8565855dd1a108b6f7cddc860b210bb74dc13329 Mon Sep 17 00:00:00 2001 From: amontano Date: Sun, 30 Mar 2003 17:09:09 +0000 Subject: [PATCH] Now the handheld version supports both portrait and landscape. --- .../thdl/tib/scanner/AppletScannerFilter.java | 2 +- .../thdl/tib/scanner/DuffScannerPanel.java | 14 ++- source/org/thdl/tib/scanner/ScannerPanel.java | 105 ++++++++---------- .../thdl/tib/scanner/SimpleScannerPanel.java | 61 ++++++++-- .../thdl/tib/scanner/WindowScannerFilter.java | 22 ++-- 5 files changed, 122 insertions(+), 82 deletions(-) diff --git a/source/org/thdl/tib/scanner/AppletScannerFilter.java b/source/org/thdl/tib/scanner/AppletScannerFilter.java index 1923eab..63aa5aa 100644 --- a/source/org/thdl/tib/scanner/AppletScannerFilter.java +++ b/source/org/thdl/tib/scanner/AppletScannerFilter.java @@ -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 diff --git a/source/org/thdl/tib/scanner/DuffScannerPanel.java b/source/org/thdl/tib/scanner/DuffScannerPanel.java index 1490619..b4a182e 100644 --- a/source/org/thdl/tib/scanner/DuffScannerPanel.java +++ b/source/org/thdl/tib/scanner/DuffScannerPanel.java @@ -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); diff --git a/source/org/thdl/tib/scanner/ScannerPanel.java b/source/org/thdl/tib/scanner/ScannerPanel.java index 7717c04..1b46355 100644 --- a/source/org/thdl/tib/scanner/ScannerPanel.java +++ b/source/org/thdl/tib/scanner/ScannerPanel.java @@ -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; idictCols) + { + 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; id.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); } }