jdk/src/solaris/classes/sun/awt/motif/MFramePeer.java
author xdono
Wed, 02 Jul 2008 12:55:45 -0700
changeset 715 f16baef3a20e
parent 129 f995b9c9c5fa
permissions -rw-r--r--
6719955: Update copyright year Summary: Update copyright year for files that have been modified in 2008 Reviewed-by: ohair, tbell
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
715
f16baef3a20e 6719955: Update copyright year
xdono
parents: 129
diff changeset
     2
 * Copyright 1995-2008 Sun Microsystems, Inc.  All Rights Reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
package sun.awt.motif;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
import java.util.Vector;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.awt.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.awt.peer.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.awt.event.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import sun.awt.motif.MInputMethodControl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import sun.awt.im.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.awt.image.ColorModel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.awt.image.BufferedImage;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.awt.image.DataBuffer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import java.awt.image.DataBufferInt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import java.awt.image.DataBufferByte;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import java.awt.image.DataBufferUShort;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import java.awt.image.ImageObserver;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
import java.awt.image.WritableRaster;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
import sun.awt.image.ImageRepresentation;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
import sun.awt.image.ToolkitImage;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
class MFramePeer extends MWindowPeer implements FramePeer, MInputMethodControl {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    static Vector allFrames = new Vector();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    // XXX: Stub out for now.  Need to propagate to normal size hints.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    public void setMaximizedBounds(Rectangle b) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    public void create(MComponentPeer parent, Object arg) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
        super.create( parent );
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    MFramePeer(Frame target) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
        super();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
        // set the window attributes for this Frame
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
        winAttr.nativeDecor = !target.isUndecorated();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
        winAttr.initialFocus = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
        winAttr.isResizable =  target.isResizable();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
        winAttr.initialState = target.getState();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
        winAttr.title = target.getTitle();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
        winAttr.icon = target.getIconImage();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
        if (winAttr.nativeDecor) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
            winAttr.decorations = winAttr.AWT_DECOR_ALL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
            winAttr.decorations = winAttr.AWT_DECOR_NONE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
        // for input method windows, use minimal decorations
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
        if (target instanceof InputMethodWindow) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
            winAttr.initialFocus = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
            winAttr.decorations = (winAttr.AWT_DECOR_TITLE | winAttr.AWT_DECOR_BORDER);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        // create and init native component
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
        init( target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    if (winAttr.icon != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
        setIconImage(winAttr.icon);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
        allFrames.addElement(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    public void setTitle(String title) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
        pSetTitle(title);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    protected void disposeImpl() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
        allFrames.removeElement(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
        super.disposeImpl();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    public void setMenuBar(MenuBar mb) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        MMenuBarPeer mbpeer = (MMenuBarPeer) MToolkit.targetToPeer(mb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        pSetMenuBar(mbpeer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        Rectangle r = target.bounds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        pReshape(r.x, r.y, r.width, r.height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        if (target.isVisible()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
            target.validate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    public void setIconImage(Image im) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        int width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
        int height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
        GraphicsConfiguration defaultGC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        if (im != null) {  // 4633887  Avoid Null pointer exception.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
        if (im instanceof ToolkitImage) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
            ImageRepresentation ir = ((ToolkitImage)im).getImageRep();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
            ir.reconstruct(ImageObserver.ALLBITS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
            width = ir.getWidth();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
            height = ir.getHeight();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
            width = im.getWidth(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
            height = im.getHeight(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        if (pGetIconSize(width, height)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
            //Icons are displayed using the default visual, so create image
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
            //using default GraphicsConfiguration
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
            defaultGC = getGraphicsConfiguration().getDevice().
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
                getDefaultConfiguration();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
            ColorModel model = defaultGC.getColorModel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
            WritableRaster raster =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
                model.createCompatibleWritableRaster(iconWidth, iconHeight);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
            Image image = new BufferedImage(model, raster,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
                                            model.isAlphaPremultiplied(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
                                            null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
            // ARGB BufferedImage to hunt for transparent pixels
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
            BufferedImage bimage =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
                new BufferedImage(iconWidth, iconHeight,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
                                  BufferedImage.TYPE_INT_ARGB);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
            ColorModel alphaCheck = bimage.getColorModel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
            Graphics g = image.getGraphics();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
            Graphics big = bimage.getGraphics();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
                g.drawImage(im, 0, 0, iconWidth, iconHeight, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
                big.drawImage(im, 0, 0, iconWidth, iconHeight, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
            } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
                g.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
                big.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
            DataBuffer db = ((BufferedImage)image).getRaster().getDataBuffer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
            DataBuffer bidb = bimage.getRaster().getDataBuffer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
            byte[] bytedata = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
            int[] intdata = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
            int bidbLen = bidb.getSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
            int imgDataIdx;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
            //Get native RGB value for window background color
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
            //Should work for byte as well as int
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
            int bgRGB = getNativeColor(SystemColor.window, defaultGC);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
            /* My first attempt at a solution to bug 4175560 was to use
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
             * the iconMask and iconPixmap attributes of Windows.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
             * This worked fine on CDE/dtwm, however olwm displayed only
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
             * single color icons (white on background).  Instead, the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
             * fix gets the default background window color and replaces
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
             * transparent pixels in the icon image with this color.  This
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
             * solutions works well with dtwm as well as olwm.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
            for (imgDataIdx = 0; imgDataIdx < bidbLen; imgDataIdx++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
                if (alphaCheck.getAlpha(bidb.getElem(imgDataIdx)) == 0 ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
                    //Assuming single data bank
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
                    db.setElem(imgDataIdx, bgRGB);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
            short[] ushortdata = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
            if (db instanceof DataBufferByte) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
                // Pseudocolor data
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
                bytedata = ((DataBufferByte)db).getData();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
            else if (db instanceof DataBufferInt) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
                // Truecolor data
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
                intdata = ((DataBufferInt) db).getData();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
            else if (db instanceof DataBufferUShort) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
                // Truecolor data
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
                ushortdata = ((DataBufferUShort) db).getData();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
               pSetIconImage(bytedata, intdata, ushortdata,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
                          iconWidth, iconHeight);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    native boolean pGetIconSize(int widthHint, int heightHint);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
    // [jk] added ushortData for 16-bpp displays
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
    native void pSetIconImage(byte[] byteData,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
                              int[] intData,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
                              short[] ushortData,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
                              int iconWidth, int iconHeight);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
    // NOTE: This method may be called by privileged threads.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
    //       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
    public void handleIconify() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        postEvent(new WindowEvent((Window)target, WindowEvent.WINDOW_ICONIFIED));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
    // NOTE: This method may be called by privileged threads.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
    //       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
    public void handleDeiconify() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
        postEvent(new WindowEvent((Window)target, WindowEvent.WINDOW_DEICONIFIED));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     * Called to inform the Frame that it has moved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
    // NOTE: This method may be called by privileged threads.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
    //       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
    public void handleMoved(int x, int y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
        postEvent(new ComponentEvent(target, ComponentEvent.COMPONENT_MOVED));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
    static final int CROSSHAIR_INSET = 5;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
    static final int BUTTON_Y = CROSSHAIR_INSET + 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
    static final int BUTTON_W = 17;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
    static final int BUTTON_H = 17;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
    static final int SYS_MENU_X = CROSSHAIR_INSET + 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
    static final int SYS_MENU_CONTAINED_X = SYS_MENU_X + 5;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
    static final int SYS_MENU_CONTAINED_Y = BUTTON_Y + 7;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
    static final int SYS_MENU_CONTAINED_W = 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
    static final int SYS_MENU_CONTAINED_H = 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
    static final int MAXIMIZE_X_DIFF = CROSSHAIR_INSET + BUTTON_W;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
    static final int MAXIMIZE_CONTAINED_X_DIFF = MAXIMIZE_X_DIFF - 5;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    static final int MAXIMIZE_CONTAINED_Y = BUTTON_Y + 5;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
    static final int MAXIMIZE_CONTAINED_W = 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    static final int MAXIMIZE_CONTAINED_H = 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    static final int MINIMIZE_X_DIFF = MAXIMIZE_X_DIFF + BUTTON_W;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
    static final int MINIMIZE_CONTAINED_X_DIFF = MINIMIZE_X_DIFF - 7;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
    static final int MINIMIZE_CONTAINED_Y = BUTTON_Y + 7;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
    static final int MINIMIZE_CONTAINED_W = 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
    static final int MINIMIZE_CONTAINED_H = 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
    static final int TITLE_X = SYS_MENU_X + BUTTON_W;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
    static final int TITLE_W_DIFF = BUTTON_W * 3 + CROSSHAIR_INSET * 2 - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
    static final int TITLE_MID_Y = BUTTON_Y + (BUTTON_H / 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
    static final int MENUBAR_X = CROSSHAIR_INSET + 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
    static final int MENUBAR_Y = BUTTON_Y + BUTTON_H;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
    static final int HORIZ_RESIZE_INSET = CROSSHAIR_INSET + BUTTON_H;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
    static final int VERT_RESIZE_INSET = CROSSHAIR_INSET + BUTTON_W;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
     * Print the native component by rendering the Motif look ourselves.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
     * We also explicitly print the MenuBar since a MenuBar isn't a subclass
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
     * of Component (and thus it has no "print" method which gets called by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
     * default).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
    public void print(Graphics g) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
        super.print(g);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
        Frame f = (Frame)target;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
        Insets finsets = f.getInsets();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
        Dimension fsize = f.getSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
        Color bg = f.getBackground();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
        Color fg = f.getForeground();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
        Color highlight = bg.brighter();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
        Color shadow = bg.darker();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
        // Well, we could query for the currently running window manager
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
        // and base the look on that, or we could just always do dtwm.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
        // aim, tball, and levenson all agree we'll just do dtwm.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
        if (hasDecorations(MWindowAttributes.AWT_DECOR_BORDER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
            // top outer -- because we'll most likely be drawing on white paper,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
            // for aesthetic reasons, don't make any part of the outer border
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
            // pure white
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
            if (highlight.equals(Color.white)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
                g.setColor(new Color(230, 230, 230));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
            else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
                g.setColor(highlight);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
            g.drawLine(0, 0, fsize.width, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
            g.drawLine(0, 1, fsize.width - 1, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
            // left outer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
            // if (highlight.equals(Color.white)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
            //     g.setColor(new Color(230, 230, 230));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
            // }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
            // else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
            //     g.setColor(highlight);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
            // }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
            g.drawLine(0, 0, 0, fsize.height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
            g.drawLine(1, 0, 1, fsize.height - 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
            // bottom cross-hair
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
            g.setColor(highlight);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
            g.drawLine(CROSSHAIR_INSET + 1, fsize.height - CROSSHAIR_INSET,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
                       fsize.width - CROSSHAIR_INSET,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
                       fsize.height - CROSSHAIR_INSET);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
            // right cross-hair
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
            // g.setColor(highlight);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
            g.drawLine(fsize.width - CROSSHAIR_INSET, CROSSHAIR_INSET + 1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
                       fsize.width - CROSSHAIR_INSET,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
                       fsize.height - CROSSHAIR_INSET);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
            // bottom outer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
            g.setColor(shadow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
            g.drawLine(1, fsize.height, fsize.width, fsize.height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
            g.drawLine(2, fsize.height - 1, fsize.width, fsize.height - 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
            // right outer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
            // g.setColor(shadow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
            g.drawLine(fsize.width, 1, fsize.width, fsize.height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
            g.drawLine(fsize.width - 1, 2, fsize.width - 1, fsize.height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
            // top cross-hair
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
            // g.setColor(shadow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
            g.drawLine(CROSSHAIR_INSET, CROSSHAIR_INSET,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
                       fsize.width - CROSSHAIR_INSET, CROSSHAIR_INSET);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
            // left cross-hair
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
            // g.setColor(shadow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
            g.drawLine(CROSSHAIR_INSET, CROSSHAIR_INSET, CROSSHAIR_INSET,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
                   fsize.height - CROSSHAIR_INSET);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
        if (hasDecorations(MWindowAttributes.AWT_DECOR_TITLE)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
            if (hasDecorations(MWindowAttributes.AWT_DECOR_MENU)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
                // system menu
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
                g.setColor(bg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
                g.fill3DRect(SYS_MENU_X, BUTTON_Y, BUTTON_W, BUTTON_H, true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
                g.fill3DRect(SYS_MENU_CONTAINED_X, SYS_MENU_CONTAINED_Y,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
                             SYS_MENU_CONTAINED_W, SYS_MENU_CONTAINED_H, true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
            // title bar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
            // g.setColor(bg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
            g.fill3DRect(TITLE_X, BUTTON_Y, fsize.width - TITLE_W_DIFF, BUTTON_H,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
                         true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
            if (hasDecorations(MWindowAttributes.AWT_DECOR_MINIMIZE)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
                // minimize button
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
                // g.setColor(bg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
                g.fill3DRect(fsize.width - MINIMIZE_X_DIFF, BUTTON_Y, BUTTON_W,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
                             BUTTON_H, true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
                g.fill3DRect(fsize.width - MINIMIZE_CONTAINED_X_DIFF,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
                             MINIMIZE_CONTAINED_Y, MINIMIZE_CONTAINED_W,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
                             MINIMIZE_CONTAINED_H, true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
            if (hasDecorations(MWindowAttributes.AWT_DECOR_MAXIMIZE)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
                // maximize button
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
                // g.setColor(bg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
                g.fill3DRect(fsize.width - MAXIMIZE_X_DIFF, BUTTON_Y, BUTTON_W,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
                             BUTTON_H, true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
                g.fill3DRect(fsize.width - MAXIMIZE_CONTAINED_X_DIFF,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
                             MAXIMIZE_CONTAINED_Y, MAXIMIZE_CONTAINED_W,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
                             MAXIMIZE_CONTAINED_H, true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
            // title bar text
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
            g.setColor(fg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
            Font sysfont = new Font(Font.SANS_SERIF, Font.PLAIN, 10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
            g.setFont(sysfont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
            FontMetrics sysfm = g.getFontMetrics();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
            String ftitle = f.getTitle();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
            g.drawString(ftitle,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
                         ((TITLE_X + TITLE_X + fsize.width - TITLE_W_DIFF) / 2) -
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
                         (sysfm.stringWidth(ftitle) / 2),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
                         TITLE_MID_Y + sysfm.getMaxDescent());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
        if (f.isResizable() &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
            hasDecorations(MWindowAttributes.AWT_DECOR_RESIZEH)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
            // add resize cross hairs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
            // upper-left horiz (shadow)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
            g.setColor(shadow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
            g.drawLine(1, HORIZ_RESIZE_INSET, CROSSHAIR_INSET,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
                       HORIZ_RESIZE_INSET);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
            // upper-left vert (shadow)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
            // g.setColor(shadow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
            g.drawLine(VERT_RESIZE_INSET, 1, VERT_RESIZE_INSET, CROSSHAIR_INSET);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
            // upper-right horiz (shadow)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
            // g.setColor(shadow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
            g.drawLine(fsize.width - CROSSHAIR_INSET + 1, HORIZ_RESIZE_INSET,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
                       fsize.width, HORIZ_RESIZE_INSET);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
            // upper-right vert (shadow)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
            // g.setColor(shadow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
            g.drawLine(fsize.width - VERT_RESIZE_INSET - 1, 2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
                       fsize.width - VERT_RESIZE_INSET - 1, CROSSHAIR_INSET + 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
            // lower-left horiz (shadow)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
            // g.setColor(shadow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
            g.drawLine(1, fsize.height - HORIZ_RESIZE_INSET - 1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
                       CROSSHAIR_INSET, fsize.height - HORIZ_RESIZE_INSET - 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
            // lower-left vert (shadow)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
            // g.setColor(shadow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
            g.drawLine(VERT_RESIZE_INSET, fsize.height - CROSSHAIR_INSET + 1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
                       VERT_RESIZE_INSET, fsize.height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
            // lower-right horiz (shadow)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
            // g.setColor(shadow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
            g.drawLine(fsize.width - CROSSHAIR_INSET + 1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
                       fsize.height - HORIZ_RESIZE_INSET - 1, fsize.width,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
                       fsize.height - HORIZ_RESIZE_INSET - 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
            // lower-right vert (shadow)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
            // g.setColor(shadow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
            g.drawLine(fsize.width - VERT_RESIZE_INSET - 1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
                       fsize.height - CROSSHAIR_INSET + 1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
                       fsize.width - VERT_RESIZE_INSET - 1, fsize.height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
            // upper-left horiz (highlight)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
            g.setColor(highlight);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
            g.drawLine(2, HORIZ_RESIZE_INSET + 1, CROSSHAIR_INSET,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
                       HORIZ_RESIZE_INSET + 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
            // upper-left vert (highlight)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
            // g.setColor(highlight);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
            g.drawLine(VERT_RESIZE_INSET + 1, 2, VERT_RESIZE_INSET + 1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
                       CROSSHAIR_INSET);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
            // upper-right horiz (highlight)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
            // g.setColor(highlight);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
            g.drawLine(fsize.width - CROSSHAIR_INSET + 1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
                       HORIZ_RESIZE_INSET + 1, fsize.width - 1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
                       HORIZ_RESIZE_INSET + 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
            // upper-right vert (highlight)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
            // g.setColor(highlight);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
            g.drawLine(fsize.width - VERT_RESIZE_INSET, 2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
                       fsize.width - VERT_RESIZE_INSET, CROSSHAIR_INSET);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
            // lower-left horiz (highlight)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
            // g.setColor(highlight);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
            g.drawLine(2, fsize.height - HORIZ_RESIZE_INSET, CROSSHAIR_INSET,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
                       fsize.height - HORIZ_RESIZE_INSET);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
            // lower-left vert (highlight)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
            // g.setColor(highlight);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
            g.drawLine(VERT_RESIZE_INSET + 1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
                       fsize.height - CROSSHAIR_INSET + 1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
                       VERT_RESIZE_INSET + 1, fsize.height - 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
            // lower-right horiz (highlight)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
            // g.setColor(highlight);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
            g.drawLine(fsize.width - CROSSHAIR_INSET + 1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
                       fsize.height - HORIZ_RESIZE_INSET, fsize.width - 1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
                       fsize.height - HORIZ_RESIZE_INSET);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
            // lower-right vert (highlight)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
            // g.setColor(highlight);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
            g.drawLine(fsize.width - VERT_RESIZE_INSET,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
                       fsize.height - CROSSHAIR_INSET + 1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
                       fsize.width - VERT_RESIZE_INSET, fsize.height - 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
        MenuBar mb = f.getMenuBar();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
        if (mb != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
            MMenuBarPeer peer = (MMenuBarPeer) MToolkit.targetToPeer(mb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
            if (peer != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
                Insets insets = getInsets();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
                Graphics ng = g.create();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
                int menubarX = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
                int menubarY = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
                if (hasDecorations(MWindowAttributes.AWT_DECOR_BORDER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
                    menubarX += CROSSHAIR_INSET + 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
                    menubarY += CROSSHAIR_INSET + 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
                if (hasDecorations(MWindowAttributes.AWT_DECOR_TITLE)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
                    menubarY += BUTTON_H;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
                try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
                    ng.translate(menubarX, menubarY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
                    peer.print(ng);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
                } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
                    ng.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
    // Saveunders are not done by Frame.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
    void setSaveUnder(boolean state) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
    /* Returns the native paint should be posted after setting new size
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
    public boolean checkNativePaintOnSetBounds(int width, int height) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
        // Fix for 4418155. Undecorated Frame does not repaint
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
        // automticaly if shrinking. Should not wait for Expose
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
        return ((Frame)target).isUndecorated() ?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
            ((width > oldWidth) || (height > oldHeight)):
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
            ((width != oldWidth) || (height != oldHeight));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
    public void setBoundsPrivate(int x, int y, int width, int height) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
        setBounds(x, y, width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
    public Rectangle getBoundsPrivate() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
        return getBounds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
    }
129
f995b9c9c5fa 6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents: 2
diff changeset
   506
f995b9c9c5fa 6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents: 2
diff changeset
   507
    @Override
f995b9c9c5fa 6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents: 2
diff changeset
   508
    final boolean isTargetUndecorated() {
f995b9c9c5fa 6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents: 2
diff changeset
   509
        return ((Frame)target).isUndecorated();
f995b9c9c5fa 6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents: 2
diff changeset
   510
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
}