]> ruin.nu Git - moosique.git/blobdiff - MooGUI.java
Fixed some errors, updated the menu and toolbar.
[moosique.git] / MooGUI.java
index 22ccb53e4fddd29227ca023e604734408fc1ca47..f0c108ae7a800831ecc371584081433c34fc29d6 100644 (file)
@@ -1,25 +1,94 @@
+import javax.sound.midi.*;
 import javax.swing.*;
+import java.awt.*;
+import java.awt.event.*;
 
 /**
  * Moosique's graphical user interface.
  * 
- * @author  Andersson, Andreen, Lanneskog, Pehrson
- * @version 1
+ * @author  Mikael Andreen
  */
  
-public class MooGUI {
+public class MooGUI extends JFrame implements WindowListener {
 
+       private Sequence seq;
+
+       private JPanel trackPanel;
+       private MooTrackView[] trackViews;
+       private JLabel statusBar;
+
+       public static Font standardFont = new Font("Helvetica", Font.PLAIN, 10);
+       
        /** 
         * Creates the GUI.
         */
-       public MooGUI () {
+       public MooGUI(Sequence seq) {
+               super("Moosique");
+
+               this.seq = seq;
+               
+               Container pane = getContentPane();
+               pane.setLayout(new BorderLayout());
+               
+               // Adds menu bar.
+               setJMenuBar(new MooMenu());
+
+               // Adds toolbar.
+               pane.add(new MooToolbar(), BorderLayout.NORTH);
+               addWindowListener(this);
+
+               // Adds tracks.
+               trackPanel = new JPanel(true);
+               createTrackViews();
+               pane.add(trackPanel, BorderLayout.CENTER);
+
+               // Adds status bar.
+               statusBar = new JLabel("Welcome to Moosique!", JLabel.CENTER);
+               pane.add(statusBar, BorderLayout.SOUTH);
 
+               addWindowListener(this);
+               pack();
+               Dimension bounds = new Dimension(400,300);
+               setSize(bounds.width,bounds.height);
+               setLocation((Toolkit.getDefaultToolkit().getScreenSize().width / 2) - (bounds.width / 2), (Toolkit.getDefaultToolkit().getScreenSize().height / 2) - (bounds.height / 2));
+               // setResizable(false);
+               // setBackground(Color.white);
+               setVisible(true);
+               show();
+       }
+       
+       /** 
+        * Changes the sequence of the GUI.
+        * @param sequence      the MIDI sequence to visualize
+        */
+       public void setSequence(Sequence sequence) {
+               seq = sequence;
+               createTrackViews();
        }
 
        /** 
-        * 
+        * Shows the given message in the status bar.
+        * @param text  the message to show
         */
-       public void () {
+       public void setStatus(String text) {
+               statusBar.setText(text);
+       }
        
+       private void createTrackViews() {
+               trackPanel.removeAll();
+               Track[] tracks = seq.getTracks();
+               trackViews = new MooTrackView[tracks.length];
+               for (int i = 0; i < tracks.length; i++) {
+                       trackViews[i] = new MooTrackView(tracks[i]);
+                       trackPanel.add(new MooTrackView(tracks[i]));
+               }
        }
+
+       public void windowOpened(WindowEvent e) {}
+       public void windowClosing(WindowEvent e) {Moosique.quit();}
+       public void windowClosed(WindowEvent e) {}
+       public void windowIconified(WindowEvent e) {}
+       public void windowDeiconified(WindowEvent e) {}
+       public void windowActivated(WindowEvent e) {}
+       public void windowDeactivated(WindowEvent e) {}
 }