001: /*
002: * @(#)PPCFramePeer.java 1.16 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: import java.awt.image.ImageObserver;
032: import sun.awt.image.ImageRepresentation;
033:
034: class PPCFramePeer extends PPCWindowPeer implements FramePeer {
035:
036: // FramePeer implementation
037:
038: // System property to indicate whether we can set Frame state
039: private static boolean setStateRestricted;
040:
041: private static native void initIDs();
042:
043: static {
044: initIDs();
045: setStateRestricted = Boolean
046: .getBoolean("java.awt.Frame.setState.isRestricted");
047: }
048:
049: public Dimension minimumSize() {
050: int height = (((Frame) target).getMenuBar() != null) ? 45 : 30;
051: return (new Dimension(30, height));
052: }
053:
054: public void setIconImage(Image im) {
055: ImageRepresentation ir = ((PPCImage) im).getImageRep();
056: ir.reconstruct(ImageObserver.ALLBITS);
057: _setIconImage(ir);
058: return;
059: }
060:
061: // Fix for 1251439: like PPCComponentPeer.reshape, but checks SM_C[XY]MIN
062: public synchronized native void reshape(int x, int y, int width,
063: int height);
064:
065: public void setMenuBar(MenuBar mb) {
066: PPCMenuBarPeer mbPeer = (PPCMenuBarPeer) PPCObjectPeer
067: .getPeerForTarget(mb);
068: //PPCMenuBarPeer mbPeer = null;
069: setMenuBarNative(mbPeer);
070: updateInsets(insets_);
071: return;
072: }
073:
074: private native void setMenuBarNative(PPCMenuBarPeer mbPeer);
075:
076: // Toolkit & peer internals
077:
078: PPCFramePeer(Frame target) {
079: super (target);
080: }
081:
082: native void create(PPCComponentPeer parent);
083:
084: public void setState(int state) {
085: if (!setStateRestricted) {
086: this .state = state;
087: }
088: return;
089: }
090:
091: public int getState() {
092: return this .state;
093: }
094:
095: void initialize() {
096: super .initialize();
097:
098: Frame target = (Frame) this .target;
099:
100: if (target.getTitle() != null) {
101: setTitle(target.getTitle());
102: }
103:
104: setResizable(target.isResizable());
105:
106: Image icon = target.getIconImage();
107: if (icon != null) {
108: setIconImage(icon);
109: }
110:
111: if (!target.getCursor().equals(Cursor.getDefaultCursor())) {
112: setCursor(target.getCursor());
113: }
114:
115: return;
116: }
117:
118: native void _setIconImage(ImageRepresentation ir);
119:
120: // setState( int ) and getState() were added to the
121: // FramePeer interface after the pjava port. Put the
122: // state variable here for the time being.
123: int state = 0;
124: }
|