Include TeleMega v3.0 firmware with releases
[fw/altos] / altosui / AltosConfigureUI.java
index 0e411b03e4dfc7f87fc4641f40f9a86c1bfb18d2..acafc65996f3e22b6c5359ffd809d63789b7e9e2 100644 (file)
@@ -3,7 +3,8 @@
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -22,7 +23,7 @@ import java.awt.event.*;
 import java.beans.*;
 import javax.swing.*;
 import javax.swing.event.*;
-import org.altusmetrum.altosuilib.*;
+import org.altusmetrum.altosuilib_12.*;
 
 public class AltosConfigureUI
        extends AltosUIConfigure
@@ -31,6 +32,7 @@ public class AltosConfigureUI
        AltosVoice      voice;
 
        public JTextField       callsign_value;
+       public JComboBox<String>        position_value;
 
        /* DocumentListener interface methods */
        public void insertUpdate(DocumentEvent e) {
@@ -42,7 +44,7 @@ public class AltosConfigureUI
        }
 
        public void changedUpdate(DocumentEvent e) {
-               if (callsign_value != null) 
+               if (callsign_value != null)
                        AltosUIPreferences.set_callsign(callsign_value.getText());
        }
 
@@ -81,13 +83,15 @@ public class AltosConfigureUI
                /* Callsign setting */
                pane.add(new JLabel("Callsign"), constraints(0, 1));
 
-               JTextField callsign_value = new JTextField(AltosUIPreferences.callsign());
+               callsign_value = new JTextField(AltosUIPreferences.callsign());
                callsign_value.getDocument().addDocumentListener(this);
                callsign_value.setToolTipText("Callsign sent in packet mode");
                pane.add(callsign_value, constraints(1, 2, GridBagConstraints.BOTH));
                row++;
        }
 
+       boolean has_bluetooth;
+
        public void add_bluetooth() {
                JButton manage_bluetooth = new JButton("Manage Bluetooth");
                manage_bluetooth.addActionListener(new ActionListener() {
@@ -97,6 +101,7 @@ public class AltosConfigureUI
                        });
                pane.add(manage_bluetooth, constraints(0, 2));
                /* in the same row as add_frequencies, so don't bump row */
+               has_bluetooth = true;
        }
 
        public void add_frequencies() {
@@ -107,7 +112,40 @@ public class AltosConfigureUI
                                }
                        });
                manage_frequencies.setToolTipText("Configure which values are shown in frequency menus");
-               pane.add(manage_frequencies, constraints(2, 1));
+               if (has_bluetooth)
+                       pane.add(manage_frequencies, constraints(2, 1));
+               else
+                       pane.add(manage_frequencies, constraints(0, 3));
+               row++;
+       }
+
+       final static String[] position_names = {
+               "Top left",
+               "Top",
+               "Top right",
+               "Left",
+               "Center",
+               "Right",
+               "Bottom left",
+               "Bottom",
+               "Bottom right",
+       };
+
+       public void add_position() {
+               pane.add(new JLabel ("Menu position"), constraints(0, 1));
+
+               position_value = new JComboBox<String>(position_names);
+               position_value.setMaximumRowCount(position_names.length);
+               int position = AltosUIPreferences.position();
+               position_value.setSelectedIndex(position);
+               position_value.addActionListener(new ActionListener() {
+                               public void actionPerformed(ActionEvent e) {
+                                       int     position = position_value.getSelectedIndex();
+                                       AltosUIPreferences.set_position(position);
+                               }
+                       });
+               pane.add(position_value, constraints(1, 2, GridBagConstraints.BOTH));
+               position_value.setToolTipText("Position of main AltosUI window");
                row++;
        }