package bmsi.fsp; import java.awt.*; import java.awt.peer.*; import java.awt.event.WindowEvent; /** TUI Frames and Dialogs provide their own frames. @author Stuart D. Gathman Copyright (C) 2000 Business Management Systems, Inc. */ class FSFramedWindow extends FSWindow { private Insets insets; private String title; private boolean resizable = false; public void paint(Graphics g) { Dimension d = target.getSize(); g.drawRect(0,0,d.width,d.height); int clientWidth = d.width - insets.right - insets.left; int clientHeight = d.height - insets.top - insets.bottom; if (title != null) { FontMetrics fm = g.getFontMetrics(); int w = fm.stringWidth(title); int h = fm.getHeight(); g.clipRect(insets.left,0,clientWidth,h); g.drawString(title,(clientWidth-w)/2,h); } g.setClip(insets.left,insets.top,clientWidth,clientHeight); super.paint(g); } FSFramedWindow(Window w,FSToolkit toolkit) { super(w,toolkit); insets = toolkit.getInsets(); // compute scaled insets } public void setTitle(String s) { title = s; } public void setResizable(boolean flg) { resizable = flg; } /** Our TUI system uses a 1 char frame on all sides (no shadowing). */ public Insets getInsets() { return insets; } void activate() { toolkit.theQueue.postEvent( new WindowEvent((Window)target,WindowEvent.WINDOW_ACTIVATED)); super.activate(); } void deactiveate() { super.deactivate(); toolkit.theQueue.postEvent( new WindowEvent((Window)target,WindowEvent.WINDOW_DEACTIVATED)); } public void postKey(int k) { switch (k - 256) { case TI.KEY_CLOSE: toolkit.theQueue.postEvent( new WindowEvent((Window)target,WindowEvent.WINDOW_CLOSING)); return; } super.postKey(k); } }