01: /*
02: * CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF
03: * NETSCAPE COMMUNICATIONS CORPORATION
04: *
05: * Copyright (c) 1996 Netscape Communications Corporation.
06: * All Rights Reserved.
07: * Use of this Source Code is subject to the terms of the applicable
08: * license agreement from Netscape Communications Corporation.
09: */
10:
11: package graphical;
12:
13: import java.lang.Integer;
14: import java.util.Vector;
15:
16: import netscape.application.InternalWindow;
17: import netscape.application.Rect;
18:
19: public class WindowTiler extends java.util.Vector {
20: private Vector minimizedList;
21: private Object null_object = new Object();
22:
23: public WindowTiler() {
24: super (VECTOR_CAPACITY, VECTOR_INCR);
25: minimizedList = new Vector(VECTOR_CAPACITY, VECTOR_INCR);
26: }
27:
28: /**
29: * Add a new window to the WindowTiler.
30: */
31: public void addWindow(InternalWindow window) {
32: addElement(window);
33: Rect windowRect = window.bounds();
34: windowRect.x += (WINDOW_X_INCR * (elementCount - 1));
35: windowRect.y += (WINDOW_Y_INCR * (elementCount - 1));
36: window.setBounds(windowRect);
37: return;
38: }
39:
40: /**
41: * Add a new window to the WindowTiler minimize list.
42: */
43: public void minimizeWindow(Minimize minimize) {
44: int index = minimizedList.indexOf(null_object);
45:
46: if (index != -1) {
47: minimizedList.setElementAt(minimize, index);
48: } else {
49: index = minimizedList.size();
50: minimizedList.addElement(minimize);
51: }
52:
53: minimize.startX = ICON_X_INCR
54: + (ICON_X_INCR + minimize.size.width) * index;
55: minimize.startY = minimize.menuHeight + ICON_Y_INCR;
56: minimize.setBounds(minimize.startX, minimize.startY,
57: minimize.size.width, minimize.size.height);
58: return;
59: }
60:
61: /**
62: * Remove a window to the WindowTiler minimize list.
63: */
64: public void restoreWindow(Minimize minimize) {
65: int index = minimizedList.indexOf(minimize);
66:
67: if (index != -1) {
68: minimizedList.setElementAt(null_object, index);
69: }
70:
71: return;
72: }
73:
74: /**
75: * Vector capacity constants
76: */
77: private final static int VECTOR_CAPACITY = 20;
78: private final static int VECTOR_INCR = 10;
79:
80: /**
81: * Window increment constants
82: */
83: private final static int WINDOW_X_INCR = 20;
84: private final static int WINDOW_Y_INCR = 20;
85:
86: /**
87: * Icon increment constants
88: */
89: private final static int ICON_X_INCR = 5;
90: private final static int ICON_Y_INCR = 3;
91: }
|