001: /*
002: * @(#)PPCDialogPeer.java 1.10 06/10/10
003: *
004: * Copyright 1990-2006 Sun Microsystems, Inc. All Rights Reserved.
005: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
006: *
007: * This program is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU General Public License version
009: * 2 only, as published by the Free Software Foundation.
010: *
011: * This program is distributed in the hope that it will be useful, but
012: * WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * General Public License version 2 for more details (a copy is
015: * included at /legal/license.txt).
016: *
017: * You should have received a copy of the GNU General Public License
018: * version 2 along with this work; if not, write to the Free Software
019: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA
021: *
022: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
023: * Clara, CA 95054 or visit www.sun.com if you need additional
024: * information or have any questions.
025: */
026: package sun.awt.pocketpc;
027:
028: import java.util.Vector;
029: import java.awt.*;
030: import sun.awt.peer.*;
031:
032: class PPCDialogPeer extends PPCWindowPeer implements DialogPeer {
033: static private native void initIDs();
034:
035: static {
036: initIDs();
037: }
038:
039: class ModalLock extends Object {
040: synchronized void waitModal() {
041: try {
042: wait();
043: } catch (InterruptedException ie) {
044: }
045: return;
046: }
047:
048: synchronized void endModal() {
049: notifyAll();
050: return;
051: }
052: }
053:
054: ModalLock modalLock = new ModalLock();
055:
056: // DialogPeer implementation
057:
058: // Toolkit & peer internals
059:
060: PPCDialogPeer(Dialog target) {
061: super (target);
062: }
063:
064: native void create(PPCComponentPeer parent);
065:
066: native void showModal();
067:
068: native void endModal();
069:
070: void initialize() {
071: super .initialize();
072:
073: Dialog target = (Dialog) this .target;
074:
075: if (target.getTitle() != null) {
076: setTitle(target.getTitle());
077: }
078: setResizable(target.isResizable());
079: return;
080: }
081:
082: public void show() {
083: if (((Dialog) target).isModal()) {
084: showModal();
085: // Short-term fix. Comment out to solve
086: // modality problems.
087: // modalLock.waitModal();
088: } else {
089: super .show();
090: }
091: return;
092: }
093:
094: public void hide() {
095: if (((Dialog) target).isModal()) {
096: endModal();
097: // Short-term fix. Comment out to solve
098: // modality problems.
099: // modalLock.endModal();
100: } else {
101: super .hide();
102: }
103: return;
104: }
105:
106: /* Set the appropriate default dialog color, depending on whether
107: * Win95/NT 4.0 is running or not. Since these values are class
108: * constants, it's easier (and safer) to do this in Java than C++.
109: */
110: private void setDefaultColor(boolean version4) {
111: Color c = version4 ? SystemColor.control : SystemColor.window;
112: ((Dialog) target).setBackground(c);
113: return;
114: }
115:
116: //not originally in Pjava version
117: //protected native void setTitleNative( byte[] title );
118:
119: //not originally in Pjava version
120: public void setTitle(String title) {
121: // if (title != null)
122: // setTitleNative(stringToNulMultiByte(title));
123: return;
124: }
125:
126: }
|