001: /*
002: * CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF
003: * NETSCAPE COMMUNICATIONS CORPORATION
004: *
005: * Copyright (c) 1996 Netscape Communications Corporation.
006: * All Rights Reserved.
007: * Use of this Source Code is subject to the terms of the applicable
008: * license agreement from Netscape Communications Corporation.
009: */
010:
011: package graphical;
012:
013: import java.awt.Dimension;
014:
015: import netscape.application.Bitmap;
016: import netscape.application.ContainerView;
017: import netscape.application.Graphics;
018: import netscape.application.Image;
019: import netscape.application.InternalWindow;
020: import netscape.application.MouseEvent;
021: import netscape.application.Size;
022: import netscape.application.TextField;
023: import netscape.application.Window;
024:
025: class MinimizeContainer extends ContainerView {
026: Minimize mi;
027: int x;
028: int y;
029:
030: MinimizeContainer(Minimize mi, int x, int y, int width, int height) {
031: super (x, y, width, height);
032: setMinimize(mi);
033: }
034:
035: void setMinimize(Minimize mi) {
036: this .mi = mi;
037: }
038:
039: public void mouseUp(MouseEvent event) {
040: mi.mouseUp(event);
041: }
042:
043: public void mouseDragged(MouseEvent event) {
044: event.x = event.x - x - mi.startX;
045: event.y = event.y - y - mi.startY;
046: mi.mouseDragged(event);
047: }
048:
049: public boolean mouseDown(MouseEvent event) {
050: x = event.x;
051: y = event.y;
052:
053: if (event.clickCount() == 2) {
054: mi.internalWindow.show();
055: mi.hide();
056: mi.internalWindow.windowTiler.restoreWindow(mi);
057: } else {
058: mi.mouseDown(event);
059: }
060:
061: return true;
062: }
063: }
064:
065: /**
066: Minimize.
067: <p>
068: <b>Open Issues</b>
069: <ul>
070: <li>Label handling not right.
071: <li>Sizing not right.
072: <li>Not excited about MinimizeContainer.
073: <li>Event co-ordinate fiddling works, but is creepy.
074: </ul>
075: *
076: * @version 2.B01, 6 Nov 1996
077: */
078: public class Minimize extends InternalWindow {
079: private ContainerView containerView;
080: private MinimizeContainer minimizeContainer;
081: protected IconInternalWindow internalWindow;
082: private TextField label;
083: private Bitmap bitmap;
084:
085: public Size size;
086: public int startX;
087: public int startY;
088: public int menuHeight = 0;
089:
090: /**
091: * @param bitmap bitmap to be displayed
092: * @param internalWindow is the corresponding Internalwindow
093: * @param s is the label for the icon
094: */
095: public Minimize(Bitmap bitmap, IconInternalWindow internalWindow,
096: String s) {
097: super (0, 0, bitmap.width(), bitmap.height());
098: setType(Window.BLANK_TYPE);
099: setWindow(internalWindow);
100: setLabel(s);
101: minimizeContainer = new MinimizeContainer(this , 0, 0, bitmap
102: .width(), bitmap.height());
103: setImage(bitmap);
104: containerView = new ContainerView(0, 0, minimizeContainer
105: .width(), minimizeContainer.height() + label.height());
106:
107: label.setBounds(Header.LABELCONTAINERGAP, bitmap.height(),
108: label.width(), label.height());
109:
110: label.setJustification(Graphics.CENTERED);
111:
112: containerView.addSubview(minimizeContainer);
113: containerView.addSubview(label);
114: addSubview(containerView);
115: size = windowSizeForContentSize(containerView.width(),
116: containerView.height());
117: sizeTo(size.width, size.height);
118: hide();
119: }
120:
121: /**
122: * Set the Minimize label.
123: */
124: public void setLabel(String label) {
125: // SGP: should have widget resize power
126: this .label = TextField.createLabel(label);
127: }
128:
129: /**
130: * Set the Minimize bitmap.
131: */
132: public void setImage(Bitmap bitmap) {
133: // SGP: should have widget resize power
134: minimizeContainer.setImage(bitmap);
135: }
136:
137: /**
138: * Get the Minimize bitmap.
139: */
140: public Image image() {
141: return minimizeContainer.image();
142: }
143:
144: /**
145: * Set the corresponding InternalWindow.
146: * @param internalWindow internal window
147: */
148: public void setWindow(IconInternalWindow internalWindow) {
149: this .internalWindow = internalWindow;
150: }
151:
152: public void moveTo(int x, int y) {
153: startX = x;
154: startY = y;
155: super .moveTo(x, y);
156: }
157:
158: public boolean mouseDown(MouseEvent event) {
159: if (event.clickCount() == 2) {
160: internalWindow.show();
161: hide();
162: internalWindow.windowTiler.restoreWindow(this );
163: setDirty(true);
164: }
165:
166: return true;
167: }
168: }
|