home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 25 / CDROM25.iso / Share / prog / VJ11 / VJTRIAL.EXE / IE30Java.exe / classd.exe / sun / awt / win32 / MFramePeer.java < prev    next >
Encoding:
Java Source  |  1997-01-27  |  4.1 KB  |  141 lines

  1. /*
  2.  * @(#)MFramePeer.java    1.22 96/04/10 Sami Shaio
  3.  *
  4.  * Copyright (c) 1995 Sun Microsystems, Inc. All Rights Reserved.
  5.  *
  6.  * Permission to use, copy, modify, and distribute this software
  7.  * and its documentation for NON-COMMERCIAL purposes and without
  8.  * fee is hereby granted provided that this copyright notice
  9.  * appears in all copies. Please refer to the file "copyright.html"
  10.  * for further important copyright and licensing information.
  11.  *
  12.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
  13.  * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
  14.  * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
  15.  * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR
  16.  * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
  17.  * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
  18.  */
  19. package sun.awt.win32;
  20.  
  21. import java.util.Vector;
  22. import java.awt.*;
  23. import java.awt.peer.*;
  24. import java.awt.image.ImageObserver;
  25. import sun.awt.image.ImageRepresentation;
  26.  
  27. class MFramePeer extends MPanelPeer implements FramePeer {
  28.     Insets    insets = new Insets(0, 0, 0, 0);
  29.  
  30.     static Vector allFrames = new Vector();
  31.  
  32.     native void create(MComponentPeer parent);
  33.     native void pSetTitle(String title);
  34.     native void pShow();
  35.     native void pHide();
  36.     native void pReshape(int x, int y, int width, int height);
  37.     native void pDispose();
  38.     native void pSetIconImage(ImageRepresentation ir);
  39.     // XXX: need separate call to set insets because the insets data member
  40.     // isn't set until after the super constructor is called. This was solved
  41.     // differently on the Motif side but this solution seems cleaner.
  42.     native void setInsets(Insets i);
  43.     public native void setResizable(boolean resizable);
  44.  
  45.     MFramePeer(Frame target) {
  46.     super(target);
  47.     // see comment above for setInsets
  48.     setInsets(insets);
  49.     allFrames.addElement(this);
  50.     if (target.getTitle() != null) {
  51.         pSetTitle(target.getTitle());
  52.     }
  53.     Font f = target.getFont();
  54.     if (f == null) {
  55.         f = new Font("Dialog", Font.PLAIN, 12);
  56.         target.setFont(f);
  57.         setFont(f);
  58.     }
  59.     Color c = target.getBackground();
  60.     if (c == null) {
  61.             c = new Color(getWindowBackgroundColor());
  62.         target.setBackground(c);
  63.         setBackground(c);
  64.     }
  65.     c = target.getForeground();
  66.     if (c == null) {
  67.         target.setForeground(Color.black);
  68.         setForeground(Color.black);
  69.     }
  70.     Image icon = target.getIconImage();
  71.     if (icon != null) {
  72.         setIconImage(icon);
  73.     }
  74.     if (target.getCursorType() != Frame.DEFAULT_CURSOR) {
  75.         setCursor(target.getCursorType());
  76.     }
  77.     setResizable(target.isResizable());
  78.     }
  79.  
  80.     public void setTitle(String title) {
  81.     pSetTitle(title);
  82.     }
  83.  
  84.     public void dispose() {
  85.     allFrames.removeElement(this);
  86.     super.dispose();
  87.     }
  88.  
  89.     public void setIconImage(Image im) {
  90.     ImageRepresentation ir = ((Win32Image)im).getImageRep(-1, -1);
  91.     ir.reconstruct(ImageObserver.ALLBITS);
  92.     pSetIconImage(ir);
  93.     }
  94.  
  95.     public native void setMenuBar(MenuBar mb);
  96.  
  97.     public void handleQuit() {
  98.     target.postEvent(new Event(target, Event.WINDOW_DESTROY, null));
  99.     }
  100.  
  101.     public void handleIconify() {
  102.     target.postEvent(new Event(target, Event.WINDOW_ICONIFY, null));
  103.     }
  104.  
  105.     public void handleDeiconify() {
  106.     target.postEvent(new Event(target, Event.WINDOW_DEICONIFY, null));
  107.     }
  108.  
  109.     public void toFront() {
  110.     show();
  111.     }
  112.     public void toBack() {
  113.     }
  114.  
  115.     /**
  116.      * Called to inform the Frame that it has moved.
  117.      */
  118.     public synchronized void handleMoved(int x, int y) {
  119.     target.postEvent(new Event(target, 0, Event.WINDOW_MOVED, x, y, 0, 0));
  120.     }
  121.  
  122.     /**
  123.      * Called to inform the Frame that its size has changed and it
  124.      * should layout its children.
  125.      */
  126.     public synchronized void handleResize(int width, int height) {
  127.     //target.resize(width, height);
  128.     target.invalidate();
  129.     target.validate();
  130.     target.repaint();
  131.     }
  132.  
  133.     public Insets insets() {
  134.     return insets;
  135.     }
  136.  
  137.     public native void setCursor(int cursorType);
  138.  
  139.     public native int getWindowBackgroundColor();
  140. }
  141.