]> ruin.nu Git - moosique.git/blobdiff - MooDialog.java
font settings..
[moosique.git] / MooDialog.java
index 4185d4c2d2f97317c32b31c19a77dc269118816a..54d6fdfb71308c4683c8a4fcdb77ba281d8d4a25 100644 (file)
@@ -2,9 +2,10 @@ import javax.swing.*;
 import java.awt.*;
 import java.awt.event.*;
 import javax.sound.midi.*;
+import java.io.*;
 import java.beans.*;
 
-/*
+/**
  * The GUI-class representing the popupdialogs in the Track menu.
  *
  * @author Björn Lanneskog
@@ -20,9 +21,12 @@ public class MooDialog extends JDialog {
                                DELETE_TRACK = 2,
                                COPY_TRACK = 3,
                                MOVE_TRACK = 4,
-                               JUMP = 5;
+                               JUMP = 5,
+                               CONTENTS = 6,
+                               INSERT_MEASURE = 7,
+                               DELETE_MEASURE = 8;
        
-       /*
+       /**
         * Constructor of the dialogs.
         */
         public MooDialog(int type) {
@@ -34,40 +38,21 @@ public class MooDialog extends JDialog {
                Track[] tracks = Moosique.getSequence().getTracks();
 
                switch (type) {
-                       case ADD_TRACK:
-                               
-                               makeAddDialog(pane, tracks);
-                               
-                               break;
-                               
-                       case DELETE_TRACK:
-                       
-                               makeDelDialog(pane, tracks);
-                               
-                               break;
-                               
-                       case COPY_TRACK:
-                               
-                               makeCopyDialog(pane, tracks);
-                       
-                               break;
-                       
-                       case MOVE_TRACK:
-                               
-                               makeMoveDialog(pane, tracks);
-                               
-                               break;
-                       
-                       case JUMP:
-                               
-                               makeJumpDialog(pane);
-                               
-                               break;
+                       case ADD_TRACK:         makeAddDialog(pane, tracks); break;
+                       case DELETE_TRACK:      makeDelDialog(pane, tracks); break;
+                       case COPY_TRACK:        makeCopyDialog(pane, tracks); break;
+                       case MOVE_TRACK:        makeMoveDialog(pane, tracks); break;
+                       case JUMP:              makeJumpDialog(pane); break;
+                       case CONTENTS:          makeTextDialog(pane, "Manual.txt"); break;
+                       case INSERT_MEASURE:    makeInsertMeasureDialog(pane); break;
+                       case DELETE_MEASURE:    makeDeleteMeasureDialog(pane); break;
                }
         }
        
-       /*
-        * Builds the add track popupdialog
+       /**
+        * Builds the add track popupdialog.
+        * @param pane          The container to put the dialog in.
+        * @param tracks        A array containing miditracks.
         */
        private void makeAddDialog(Container pane, Track[] tracks) {
        
@@ -101,8 +86,10 @@ public class MooDialog extends JDialog {
                setVisible(true);
        }
        
-       /*
-        * Builds the delete track popupdialog
+       /**
+        * Builds the delete track popupdialog.
+        * @param pane          The container to put the dialog in.
+        * @param tracks        A array containing miditracks.
         */
        private void makeDelDialog(Container pane, Track[] tracks) {
        
@@ -130,8 +117,10 @@ public class MooDialog extends JDialog {
                setVisible(true);
        }
        
-       /*
-        * Builds the copy track popupdialog
+       /**
+        * Builds the copy track popupdialog.
+        * @param pane          The container to put the dialog in.
+        * @param tracks        A array containing miditracks.
         */
        private void makeCopyDialog(Container pane, Track[] tracks) {
        
@@ -166,8 +155,10 @@ public class MooDialog extends JDialog {
                setVisible(true);
        }
        
-       /*
+       /**
         * Builds the move track popupdialog
+        * @param pane          The container to put the dialog in.
+        * @param tracks        A array containing miditracks.
         */
        private void makeMoveDialog(Container pane, Track[] tracks) {
        
@@ -202,8 +193,10 @@ public class MooDialog extends JDialog {
                setVisible(true);
        }
        
-       /*
-        * Builds the jump popupdialog
+       /**
+        * Builds the jump popupdialog.
+        * @param pane          The container to put the dialog in.
+        * @param tracks        A array containing miditracks.
         */
        private void makeJumpDialog(Container pane) {
                
@@ -238,10 +231,104 @@ public class MooDialog extends JDialog {
                (Toolkit.getDefaultToolkit().getScreenSize().height - this.getHeight()) / 2);
                setResizable(false);
                pack();
-               setSize(260,175);
+               setSize(260,165);
+               setVisible(true);
+       }
+       
+       /**
+        * Builds the insert measure popupdialog.
+        * @param pane          The container to put the dialog in.
+        */
+       private void makeInsertMeasureDialog(Container pane){
+       
+               setTitle("Insert Measure");
+               labelA = new JLabel("Insert at:", JLabel.RIGHT);
+               pane.add(labelA);
+               labelB = new JLabel("Measure count:", JLabel.RIGHT);
+               pane.add(labelB);
+               textFieldA = new JTextField();
+               pane.add(textFieldA);
+               textFieldB = new JTextField();
+               pane.add(textFieldB);
+               cancelButton = new JButton("Cancel");
+               pane.add(cancelButton);
+               okButton = new JButton("OK");
+               pane.add(okButton);
+               
+               labelA.setBounds(20, 20, 110 ,20);
+               labelB.setBounds(20, 50, 110, 20);
+               textFieldA.setBounds(140 ,20 , 40, 20);
+               textFieldB.setBounds(140,50, 40, 20);
+               cancelButton.setBounds(20 ,95 , 80, 30);
+               okButton.setBounds(120, 95, 60, 30);
+               
+               setLocation((Toolkit.getDefaultToolkit().getScreenSize().width - this.getWidth()) / 2,
+               (Toolkit.getDefaultToolkit().getScreenSize().height - this.getHeight()) / 2);
+               setResizable(false);
+               pack();
+               setSize(210,175);
+               setVisible(true);
+       }
+       
+       /**
+        * Builds the delete measure popupdialog.
+        * @param pane          The container to put the dialog in.
+        */
+       private void makeDeleteMeasureDialog(Container pane) {
+       
+               setTitle("Delete Measure");
+               labelA = new JLabel("Delete at:", JLabel.RIGHT);
+               pane.add(labelA);
+               labelB = new JLabel("Measure count:", JLabel.RIGHT);
+               pane.add(labelB);
+               textFieldA = new JTextField();
+               pane.add(textFieldA);
+               textFieldB = new JTextField();
+               pane.add(textFieldB);
+               cancelButton = new JButton("Cancel");
+               pane.add(cancelButton);
+               okButton = new JButton("OK");
+               pane.add(okButton);
+               
+               labelA.setBounds(20, 20, 110 ,20);
+               labelB.setBounds(20, 50, 110, 20);
+               textFieldA.setBounds(140 ,20 , 40, 20);
+               textFieldB.setBounds(140,50, 40, 20);
+               cancelButton.setBounds(20 ,95 , 80, 30);
+               okButton.setBounds(120, 95, 60, 30);
+               
+               setLocation((Toolkit.getDefaultToolkit().getScreenSize().width - this.getWidth()) / 2,
+               (Toolkit.getDefaultToolkit().getScreenSize().height - this.getHeight()) / 2);
+               setResizable(false);
+               pack();
+               setSize(210,175);
                setVisible(true);
        }
        
+       private void makeTextDialog(Container pane, String filename) {
+               setTitle("Contents");
+               File manual = new File(filename);
+               String s;
+               try {
+                       BufferedReader br = new BufferedReader(new FileReader(manual));
+                       char[] chars = new char[(int)manual.length()];
+                       br.read(chars, 0, (int)manual.length());
+                       s = new String(chars);
+               } catch (Exception ex) {
+                       s = "Manual not found";
+               }
+               JTextArea contents = new JTextArea(s, 30, 40);
+               contents.setAutoscrolls(true);
+               pane.add(contents);
+               contents.setBounds(10, 10, 500, 350);
+               setResizable(false);
+               pack();
+               setSize(600,400);
+               setLocation((Toolkit.getDefaultToolkit().getScreenSize().width - this.getWidth()) / 2,
+               (Toolkit.getDefaultToolkit().getScreenSize().height - this.getHeight()) / 2);
+               setVisible(true);
+       }
+
        private MooNote note;
        private JOptionPane optionPane;
        private JTextField pitch;