Source for gnu.gcj.xlib.WindowAttributes

   1: /* Copyright (C) 2000  Free Software Foundation
   2: 
   3:    This file is part of libgcj.
   4: 
   5: This software is copyrighted work licensed under the terms of the
   6: Libgcj License.  Please consult the file "LIBGCJ_LICENSE" for
   7: details.  */
   8: 
   9: package gnu.gcj.xlib;
  10: import gnu.gcj.RawData;
  11: 
  12: /**
  13:  * 
  14:  * Collection of attributes that can be applied to or read from an
  15:  * X11 window.
  16:  *
  17:  * <p>TODO: Split this class into two classes. One for the structure
  18:  * XSetWindowAttributes and one for the XWindowAttributes.  However
  19:  * they should still share this common base class.
  20:  *
  21:  * @author Rolf W. Rasmussen <rolfwr@ii.uib.no> */
  22: public class WindowAttributes
  23: {
  24:   // Must match definitions in X.h:
  25:   public final static long MASK_BUTTON_PRESS     = 1L<< 2,
  26:                            MASK_BUTTON_RELEASE   = 1L<< 3,
  27:                            MASK_EXPOSURE         = 1L<<15,
  28:                            MASK_STRUCTURE_NOTIFY = 1L<<17;
  29: 
  30:   public WindowAttributes()
  31:   {
  32:     init(null);
  33:   }
  34:   
  35:   public WindowAttributes(Window from)
  36:   {
  37:     initFromWindow(from);
  38:   }
  39: 
  40:   private native void initFromWindow(Window from);
  41:   private native void init(WindowAttributes copyFrom);
  42:   protected native void finalize();
  43:     
  44:   public Object clone()
  45:   {
  46:     try
  47:       {
  48:     WindowAttributes attributes = (WindowAttributes) super.clone();
  49:     // In case of an exception before the stucture is copied.
  50:     attributes.in  = null;
  51:     attributes.out = null;
  52:     
  53:     // FIXME: do anything else?
  54:     
  55:     attributes.init(this);
  56:     return attributes;
  57:       }
  58:     catch (CloneNotSupportedException ex)
  59:       {
  60:     // This should never happen.
  61:     throw new InternalError ();
  62:       }
  63:   }
  64: 
  65:   public native void setBackground(long pixel);
  66:   public native void setBackground(Pixmap pixmap);
  67:   public native void setEventMask(long eventMask);
  68: 
  69:   public void setVisual(Visual visual)
  70:   {
  71:     this.visual = visual;
  72:   }
  73: 
  74:   /**
  75:    * Retrieve the visual. 
  76:    *
  77:    * @return the visual that is or should be used by a window.  null
  78:    * means CopyFormParent. 
  79:    */
  80:   public native Visual getVisual();
  81: 
  82:   Display display;
  83: 
  84:   /**
  85:    * Reference to XWindowAttribute structure containing attributes
  86:    * read from a window.
  87:    */
  88:   RawData in = null;
  89: 
  90:   /**
  91:    * Reference to XSetWindowAttribute structure containing attributes
  92:    * to be applied to a window.
  93:    */
  94:   RawData out = null;
  95: 
  96:   long mask;
  97: 
  98:   /** null means CopyFromParent during window creation. */
  99:   Visual visual = null;
 100: 
 101:   public native void apply(Window window);
 102: 
 103:   final RawData getXSetWindowAttributesStructure()
 104:   {
 105:     if (out == null)
 106:       initOut();
 107:     return out;
 108:   }
 109:   
 110:   void initOut()
 111:   {
 112:     throw new UnsupportedOperationException("not implemented yet");
 113:   }
 114: }