package Graphics;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import borland.jbcl.layout.*;

public class MainFrame extends JFrame
{

  //Construct the frame
  JMenuBar menuBar1 = new JMenuBar();
  JMenu menuFile = new JMenu();
  JMenuItem menuFileExit = new JMenuItem();
  JMenu menuHelp = new JMenu();
  JMenuItem menuHelpAbout = new JMenuItem();
  JToolBar toolBar = new JToolBar();
  ImageIcon image1;
  ImageIcon image2;
  ImageIcon image3;
  JLabel statusBar = new JLabel();
  Image image;
  canvas screen=new canvas();
  JScrollPane jScrollPane1 = new JScrollPane();
  BorderLayout borderLayout1 = new BorderLayout();
  Panel panel1 = new Panel();

  toolbox controls=new toolbox(new Frame(),"Perspective View controls");
  Button btnToolBar = new Button();
  FlowLayout flowLayout1 = new FlowLayout();


  public MainFrame()
  {
    enableEvents(AWTEvent.WINDOW_EVENT_MASK);
    try
    {
      jbInit();
     /* jButton1.setIcon(image1);
      jButton2.setIcon(image2);
      jButton3.setIcon(image3);*/
    }
    catch (Exception e)
    {
      e.printStackTrace();
    }
  }
//Component initialization

  private void jbInit() throws Exception
  {
    image1 = new ImageIcon(getClass().getResource("openFile.gif"));
    image2 = new ImageIcon(getClass().getResource("closeFile.gif"));
    image3 = new ImageIcon(getClass().getResource("help.gif"));
    this.getContentPane().setLayout(borderLayout1);
    this.setSize(new Dimension(700, 500));
    this.setTitle("Graphics Algorithms");
    statusBar.setText(" ");
    menuFile.setText("File");
    menuFileExit.setText("Exit");
    menuFileExit.addActionListener(new ActionListener()
    {
      public void actionPerformed(ActionEvent e)
      {
        fileExit_actionPerformed(e);
      }
    });
    menuHelp.setText("Help");
    menuHelpAbout.setText("About");
    toolBar.setPreferredSize(new Dimension(103, 30));
    toolBar.setLayout(flowLayout1);
    menuHelpAbout.addActionListener(new ActionListener()
    {
      public void actionPerformed(ActionEvent e)
      {
        helpAbout_actionPerformed(e);
      }
    });
    screen.setPreferredSize(new Dimension(400, 400));
    screen.setBackground(Color.black);

    jScrollPane1.setPreferredSize(new Dimension(689, 410));
    btnToolBar.setLabel("Toolbar");
    btnToolBar.addActionListener(new java.awt.event.ActionListener()
    {
      public void actionPerformed(ActionEvent e)
      {
        btnToolBar_actionPerformed(e);
      }
    });
    menuFile.add(menuFileExit);
    menuHelp.add(menuHelpAbout);
    menuBar1.add(menuFile);
    menuBar1.add(menuHelp);
    this.setJMenuBar(menuBar1);
    this.getContentPane().add(toolBar, BorderLayout.NORTH);
    toolBar.add(btnToolBar, null);
    this.getContentPane().add(statusBar, BorderLayout.WEST);
    this.getContentPane().add(jScrollPane1, BorderLayout.CENTER);
   jScrollPane1.getViewport().add(screen, null);
    this.getContentPane().add(panel1, BorderLayout.SOUTH);

    jScrollPane1.setAutoscrolls(true);
    jScrollPane1.setDoubleBuffered(true);


    controls.screen=screen;
    controls.show();





  }


//File | Exit action performed

  public void fileExit_actionPerformed(ActionEvent e)
  {
    System.exit(0);
  }
//Help | About action performed

  public void helpAbout_actionPerformed(ActionEvent e)
  {
    MainFrame_AboutBox dlg = new MainFrame_AboutBox(this);
    Dimension dlgSize = dlg.getPreferredSize();
    Dimension frmSize = getSize();
    Point loc = getLocation();
    dlg.setLocation((frmSize.width - dlgSize.width) / 2 + loc.x, (frmSize.height - dlgSize.height) / 2 + loc.y);
    dlg.setModal(true);
    dlg.show();
  }
//Overriden so we can exit on System Close

  protected void processWindowEvent(WindowEvent e)
  {
    super.processWindowEvent(e);
    if (e.getID() == WindowEvent.WINDOW_CLOSING)
    {
      fileExit_actionPerformed(null);
    }
  }

  void btnDraw_actionPerformed(ActionEvent e)
  {
  


  }

  void btnToolBar_actionPerformed(ActionEvent e)
  {
    controls.screen=screen;
    controls.show();
  }

}


