Package ketUI.panel

Source Code of ketUI.panel.KetFrame

/*
* Copyright (C) 2011  Alasdair C. Hamilton
*
* 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, either version 3 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
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program.  If not, see <http://www.gnu.org/licenses/>
*/

package ketUI.panel;


import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Desktop;
import java.awt.Dimension;
import java.awt.FileDialog;
import java.awt.Graphics;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.Window;
import java.awt.datatransfer.*;
import java.awt.dnd.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.*;
import java.net.URL;
import java.util.ArrayList;
import javax.swing.*;
import javax.swing.TransferHandler;


import ket.*;
import ket.display.ColourScheme;
import ket.display.ColourSchemeDecorator;
import ket.display.HTMLTools;
import ket.display.LatexTools;
import ket.display.box.Box;
import ket.math.*;
import ket.math.convert.ArgumentParser;
import ketUI.Clipboard;
import ketUI.Document;
import ketUI.FrameManager;
import ketUI.DocumentManager;
import ketUI.KetFrameListener;
import ketUI.KetTransfer;
import ketUI.KetTransfer;
import ketUI.MenuEventHandler;
import ketUI.ToolBarEventHandler;
import ketUI.chord.Chord;
import ketUI.chord.ChordEventHandler;
import ketUI.chord.KeyboardEventHandler;
import ketUI.modes.*;
import ketUI.panel.AnimatedDisplay;
import ketUI.panel.FocusRequestDaemon;
import ketUI.panel.FullScreenFocusListener;
import ketUI.panel.KetPanel;
import ketUI.panel.KetPanelFocusListener;
import ketUI.Ket;

public class KetFrame extends JFrame {
  static final String[] ICON_NAMES = new String[]{"data/icon.png", "data/iconMedium.png", "data/iconSmall.png"};
  final MenuEventHandler menuEventHandler;
  final ToolBarEventHandler toolBarEventHandler;
  final KetTransfer ketTransfer;
  public KetFrame(DocumentManager documentManager, Document document) {
    super("Ket");
    setLayout(new BorderLayout());
    iconSetup();
    setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    pack();
    setSize(FrameManager.SCREEN_WIDTH, FrameManager.SCREEN_HEIGHT);
    KnownArguments knownArguments = documentManager!=null ? documentManager.getKnownArguments() : null;
    Clipboard clipboard = documentManager!=null?documentManager.getClipboard() : null;
    KetPanel ketPanel = document.getKetPanel();
    ketTransfer = new KetTransfer(ketPanel, knownArguments, clipboard, document.getMathCollection());
    ketPanel.setTransferHandler(ketTransfer);
    toolBarEventHandler = new ToolBarEventHandler(document);
    String edge = ToolBarEventHandler.HORIZONAL_TOOLBAR_AXIS?BorderLayout.PAGE_START:BorderLayout.WEST;
    add(toolBarEventHandler.getToolBar(), edge);
    add(ketPanel, BorderLayout.CENTER);
    KetFrameListener ketFrameListener = new KetFrameListener(document);
    addWindowListener(ketFrameListener)// ZZ or ZQ
    menuEventHandler = new MenuEventHandler(document);
    refreshMenuBar();
  }

  private void iconSetup() {
    ArrayList<Image> imageList = new ArrayList<Image>();
    // Loop for each image.
    for (String name : ICON_NAMES) {
      URL url = getClass().getClassLoader().getResource(name);
      if (url!=null) {
        Image image = Toolkit.getDefaultToolkit().getImage(url);
        if (image!=null) {
          imageList.add(image);
        } else {
          Ket.out.println(" !!! Can't load icon image '"+name+"' !!! ");
        }
      }
    }
    if (imageList.size()>0) {
      setIconImages(imageList);
    }
  }

  public void refreshMenuBar() {
    setJMenuBar(menuEventHandler.getMenuBar());
  }

  public ToolBarEventHandler getToolBarEventHandler() {
    return toolBarEventHandler;
  }

  public MenuEventHandler getMenuEventHandler() {
    return menuEventHandler;
  }

}
TOP

Related Classes of ketUI.panel.KetFrame

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.