]> ruin.nu Git - moosique.git/blobdiff - MooGUI.java
some changes
[moosique.git] / MooGUI.java
index dcb52da9469934f4a310840128f5a99f25fa0361..ce67d69e7cb65db5daccde7fbb97fc6bce7bb101 100644 (file)
+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  Einar Pehrson
  */
  
-public class MooGUI {
+public class MooGUI extends JFrame {
 
-       /* 
+       private Sequence seq;
+       private MooMenu menu;
+       private MooToolbar toolbar;
+       private MooView view;
+       private JLabel statusBar;
+       public static final Font FONT = new Font("Helvetica", Font.PLAIN, 10);
+       public static final Color bgColor = new Color(192, 224, 255);
+       
+       /** 
         * Creates the GUI.
         */
-       public MooGUI () {
+       public MooGUI(Sequence seq) {
+               super("Moosique");
+
+               this.seq = seq;
+               
+               Container pane = getContentPane();
+               pane.setLayout(new BoxLayout(pane, BoxLayout.Y_AXIS));
+
+               // Adds menu bar.
+               menu = new MooMenu();
+               setJMenuBar(menu);
+
+               // Adds toolbar.
+               toolbar = new MooToolbar();
+               pane.add(toolbar, BorderLayout.NORTH);
+
+               // Adds main view.
+               view = new MooView(seq.getTracks());
+               pane.add(view, BorderLayout.CENTER);
+
+               // Adds status bar.
+               statusBar = new JLabel("Welcome to Moosique!", JLabel.CENTER);
+               statusBar.setFont(FONT);
+               pane.add(statusBar, BorderLayout.SOUTH);
+
+               // Brings on the colors!
+               setBackground(pane);
+               setBackground(menu);
+               setBackground(toolbar);
+               setBackground(view);
+               statusBar.setBackground(bgColor);
+               view.setBackground(bgColor);
 
+               // Configures window.
+               addWindowListener(new MooGUICloser());
+               pack();
+               Dimension bounds = Toolkit.getDefaultToolkit().getScreenSize();
+               setSize(bounds.width,bounds.height - 40);
+               setLocation(0, 0);
+               // setResizable(false);
+               setBackground(Color.white);
+               setVisible(true);
+               show();
        }
 
-       /* 
-        * 
+       private void setBackground(Container c) {
+               c.setBackground(bgColor);
+               Component[] comps = c.getComponents();
+               for (int i = 0; i < comps.length; i++) {
+                       comps[i].setBackground(bgColor);
+               }
+       }
+       
+       /** 
+        * Changes the sequence of the GUI.
+        * @param sequence      the MIDI sequence to visualize
+        */
+       public void setSequence(Sequence sequence) {
+               seq = sequence;
+               view.update(seq.getTracks());
+       }
+
+       /** 
+        * Shows the given message in the status bar.
+        * @param text  the message to show
         */
-       public void () {
+       public void setStatus(String text) {
+               statusBar.setText(text);
+       }
        
+       class MooGUICloser extends WindowAdapter {
+               public void windowClosing(WindowEvent e) {
+                       Moosique.quit();
+               }
        }
-}
+}
\ No newline at end of file