001: /*
002: * Copyright 1995-2007 Sun Microsystems, Inc. All Rights Reserved.
003: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004: *
005: * This code is free software; you can redistribute it and/or modify it
006: * under the terms of the GNU General Public License version 2 only, as
007: * published by the Free Software Foundation. Sun designates this
008: * particular file as subject to the "Classpath" exception as provided
009: * by Sun in the LICENSE file that accompanied this code.
010: *
011: * This code is distributed in the hope that it will be useful, but WITHOUT
012: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014: * version 2 for more details (a copy is included in the LICENSE file that
015: * accompanied this code).
016: *
017: * You should have received a copy of the GNU General Public License version
018: * 2 along with this work; if not, write to the Free Software Foundation,
019: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020: *
021: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022: * CA 95054 USA or visit www.sun.com if you need additional information or
023: * have any questions.
024: */
025: package sun.awt.motif;
026:
027: import java.util.Vector;
028: import java.awt.*;
029: import java.awt.peer.*;
030: import java.awt.event.*;
031: import sun.awt.motif.MInputMethodControl;
032: import sun.awt.im.*;
033:
034: class MDialogPeer extends MWindowPeer implements DialogPeer,
035: MInputMethodControl {
036:
037: static Vector allDialogs = new Vector();
038:
039: MDialogPeer(Dialog target) {
040:
041: /* create MWindowPeer object */
042: super ();
043:
044: winAttr.nativeDecor = !target.isUndecorated();
045: winAttr.initialFocus = true;
046: winAttr.isResizable = target.isResizable();
047: winAttr.initialState = MWindowAttributes.NORMAL;
048: winAttr.title = target.getTitle();
049: winAttr.icon = null;
050: if (winAttr.nativeDecor) {
051: winAttr.decorations = winAttr.AWT_DECOR_ALL
052: | winAttr.AWT_DECOR_MINIMIZE
053: | winAttr.AWT_DECOR_MAXIMIZE;
054: } else {
055: winAttr.decorations = winAttr.AWT_DECOR_NONE;
056: }
057: /* create and init native component */
058: init(target);
059: allDialogs.addElement(this );
060: }
061:
062: public void setTitle(String title) {
063: pSetTitle(title);
064: }
065:
066: protected void disposeImpl() {
067: allDialogs.removeElement(this );
068: super .disposeImpl();
069: }
070:
071: // NOTE: This method is called by privileged threads.
072: // DO NOT INVOKE CLIENT CODE ON THIS THREAD!
073: public void handleMoved(int x, int y) {
074: postEvent(new ComponentEvent(target,
075: ComponentEvent.COMPONENT_MOVED));
076: }
077:
078: public void show() {
079: pShowModal(((Dialog) target).isModal());
080: updateAlwaysOnTop(alwaysOnTop);
081: }
082:
083: // NOTE: This method may be called by privileged threads.
084: // DO NOT INVOKE CLIENT CODE ON THIS THREAD!
085: public void handleIconify() {
086: // Note: These routines are necessary for Coaleseing of native implementations
087: // As Dialogs do not currently send Iconify/DeIconify messages but
088: // Windows/Frames do. If this should be made consistent...to do so
089: // uncomment the postEvent.
090: // postEvent(new WindowEvent((Window)target, WindowEvent.WINDOW_ICONIFIED));
091: }
092:
093: // NOTE: This method may be called by privileged threads.
094: // DO NOT INVOKE CLIENT CODE ON THIS THREAD!
095: public void handleDeiconify() {
096: // Note: These routines are necessary for Coaleseing of native implementations
097: // As Dialogs do not currently send Iconify/DeIconify messages but
098: // Windows/Frames do. If this should be made consistent...to do so
099: // uncomment the postEvent.
100: // postEvent(new WindowEvent((Window)target, WindowEvent.WINDOW_DEICONIFIED));
101: }
102:
103: public void blockWindows(java.util.List<Window> toBlock) {
104: // do nothing
105: }
106: }
|