-
Notifications
You must be signed in to change notification settings - Fork 0
/
DocumentWindow.java
191 lines (163 loc) · 4.24 KB
/
DocumentWindow.java
1
import java.awt.*;import java.awt.image.*;import java.applet.*;import java.util.*;public class DocumentWindow extends NewWindow{ protected Image titlePort; protected Graphics titlePortGC; public DocumentWindow() { super(); highlighted = true; drag = true; zoombox = true; growbox = true; modal = false; } protected void CreatePorts(int theWidth,int theHeight) { graphicsPort = theApplet.createImage(theWidth-2,theHeight-20); graphicsPortGC = graphicsPort.getGraphics(); graphicsPortGC.setFont(helvFont); titlePort = theApplet.createImage(theWidth-1,19); titlePortGC = titlePort.getGraphics(); titlePortGC.setFont(helvFont); } protected void DrawFrame() { DrawTitle(); } protected void Redraw() { if (visible) { theDesktop.offScreenImageGC.drawImage(titlePort,xPos,yPos,null); theDesktop.offScreenImageGC.drawImage(graphicsPort,xPos+1,yPos+19,null); if (highlighted) graphicsPortGC.setColor(Color.black); else graphicsPortGC.setColor(borderGray); theDesktop.offScreenImageGC.drawRect(xPos,yPos,width-1,height-1); // Add shadow theDesktop.offScreenImageGC.setColor(Color.black); theDesktop.offScreenImageGC.drawLine(xPos+1,yPos+height,xPos+width,yPos+height); theDesktop.offScreenImageGC.drawLine(xPos+width,yPos+1,xPos+width,yPos+height); } } protected void DrawGraphicsPort() { theDesktop.offScreenImageGC.drawImage(graphicsPort,xPos+1,yPos+19,null); } protected void DrawTitle() { if (highlighted) { titlePortGC.setColor(lighterGray); titlePortGC.fillRect(0,0,width-1,18); titlePortGC.setColor(lightBlue); titlePortGC.drawLine(1,1,width-3,1); titlePortGC.drawLine(1,2,1,16); titlePortGC.setColor(midBlue); titlePortGC.drawLine(1,17,width-2,17); titlePortGC.drawLine(width-2,1,width-2,16); titlePortGC.setColor(midGray); for (int i=0; i<6; i++)titlePortGC.drawLine(2,4+(2*i),width-3,4+(2*i)); titlePortGC.setColor(Color.black); titlePortGC.drawLine(1,18,width-1,18); if (!title.equals("")) { titlePortGC.setColor(lighterGray); titlePortGC.fillRect((width/2)-(titleWidth/2),4,titleWidth,13); titlePortGC.setColor(Color.black); titlePortGC.drawString(title,(width/2)-(titleWidth/2)+5,14); } if (closebox) { titlePortGC.setColor(lighterGray); titlePortGC.fillRect(closeRect.x-1,4,13,11); titlePortGC.drawImage(AFC.closeImage,closeRect.x,closeRect.y,null); } if (zoombox) { zoomRect.x = width - 20; titlePortGC.setColor(lighterGray); titlePortGC.fillRect(zoomRect.x-1,4,13,11); titlePortGC.drawImage(AFC.zoomImage,zoomRect.x,zoomRect.y,null); } } else { titlePortGC.setColor(Color.white); titlePortGC.fillRect(0,0,width-1,18); titlePortGC.setColor(borderGray); titlePortGC.drawLine(1,18,width-1,18); if (!title.equals("")) { titlePortGC.setColor(textGray); titlePortGC.drawString(title,(width/2)-(titleWidth/2)+5,14); } } } public void Init() { } public void DrawGrowIcon() { growRect.x = width - 15; growRect.y = height- 15; graphicsPortGC.setColor(Color.black); graphicsPortGC.drawLine(0,growRect.y-20,width-2,growRect.y-20); graphicsPortGC.drawLine(width-17,0,width-17,height-20); if (highlighted) graphicsPortGC.drawImage(theApplet.ApplicationThread.AFC.growImage,growRect.x-1,growRect.y-19,null); else { graphicsPortGC.setColor(Color.white); graphicsPortGC.fillRect(growRect.x-1,growRect.y-19,14,14); } } public void Draw() { } public void Activate() { theApplet.theMenuBar.EnableMenuBar(); userActivate(); } public void userActivate() { } public void Deactivate() { Enumeration e; Control TempControl; e = theControls.elements(); while (e.hasMoreElements()) { TempControl = (Control)e.nextElement(); TempControl.hiliteState = 0; TempControl.Draw(); } userDeactivate(); } public void userDeactivate() { } public void Close() { } public Point GlobalToLocal(Point thePoint) { return new Point(thePoint.x - xPos - 1, thePoint.y - yPos - 19); } protected void DisposePorts() { graphicsPort.flush(); graphicsPort = null; graphicsPortGC.dispose(); graphicsPortGC = null; titlePort.flush(); titlePort = null; titlePortGC.dispose(); titlePortGC = null; }}