Exemplo n.º 1
0
 public void applyProperty(final CPlatformWindow c, final Object value) {
   boolean fullscrenable = Boolean.parseBoolean(value.toString());
   if (c.target instanceof RootPaneContainer
       && c.getPeer().getPeerType() == PeerType.FRAME) {
     if (c.isInFullScreen && !fullscrenable) {
       c.toggleFullScreen();
     }
   }
   c.setStyleBits(FULLSCREENABLE, fullscrenable);
 }
Exemplo n.º 2
0
  protected int getInitialStyleBits() {
    // defaults style bits
    int styleBits = DECORATED | HAS_SHADOW | CLOSEABLE | MINIMIZABLE | ZOOMABLE | RESIZABLE;

    if (isNativelyFocusableWindow()) {
      styleBits = SET(styleBits, SHOULD_BECOME_KEY, true);
      styleBits = SET(styleBits, SHOULD_BECOME_MAIN, true);
    }

    final boolean isFrame = (target instanceof Frame);
    final boolean isDialog = (target instanceof Dialog);
    final boolean isPopup = (target.getType() == Window.Type.POPUP);
    if (isDialog) {
      styleBits = SET(styleBits, MINIMIZABLE, false);
    }

    // Either java.awt.Frame or java.awt.Dialog can be undecorated, however java.awt.Window always
    // is undecorated.
    {
      this.undecorated =
          isFrame
              ? ((Frame) target).isUndecorated()
              : (isDialog ? ((Dialog) target).isUndecorated() : true);
      if (this.undecorated) styleBits = SET(styleBits, DECORATED, false);
    }

    // Either java.awt.Frame or java.awt.Dialog can be resizable, however java.awt.Window is never
    // resizable
    {
      final boolean resizable =
          isFrame
              ? ((Frame) target).isResizable()
              : (isDialog ? ((Dialog) target).isResizable() : false);
      styleBits = SET(styleBits, RESIZABLE, resizable);
      if (!resizable) {
        styleBits = SET(styleBits, ZOOMABLE, false);
      } else {
        setCanFullscreen(true);
      }
    }

    if (target.isAlwaysOnTop()) {
      styleBits = SET(styleBits, ALWAYS_ON_TOP, true);
    }

    if (target.getModalExclusionType() == Dialog.ModalExclusionType.APPLICATION_EXCLUDE) {
      styleBits = SET(styleBits, MODAL_EXCLUDED, true);
    }

    // If the target is a dialog, popup or tooltip we want it to ignore the brushed metal look.
    if (isPopup) {
      styleBits = SET(styleBits, TEXTURED, false);
      // Popups in applets don't activate applet's process
      styleBits = SET(styleBits, NONACTIVATING, true);
      styleBits = SET(styleBits, IS_POPUP, true);
    }

    if (Window.Type.UTILITY.equals(target.getType())) {
      styleBits = SET(styleBits, UTILITY, true);
    }

    if (target instanceof javax.swing.RootPaneContainer) {
      javax.swing.JRootPane rootpane = ((javax.swing.RootPaneContainer) target).getRootPane();
      Object prop = null;

      prop = rootpane.getClientProperty(WINDOW_BRUSH_METAL_LOOK);
      if (prop != null) {
        styleBits = SET(styleBits, TEXTURED, Boolean.parseBoolean(prop.toString()));
      }

      if (isDialog && ((Dialog) target).getModalityType() == ModalityType.DOCUMENT_MODAL) {
        prop = rootpane.getClientProperty(WINDOW_DOC_MODAL_SHEET);
        if (prop != null) {
          styleBits = SET(styleBits, SHEET, Boolean.parseBoolean(prop.toString()));
        }
      }

      prop = rootpane.getClientProperty(WINDOW_STYLE);
      if (prop != null) {
        if ("small".equals(prop)) {
          styleBits = SET(styleBits, UTILITY, true);
          if (target.isAlwaysOnTop()
              && rootpane.getClientProperty(WINDOW_HIDES_ON_DEACTIVATE) == null) {
            styleBits = SET(styleBits, HIDES_ON_DEACTIVATE, true);
          }
        }
        if ("textured".equals(prop)) styleBits = SET(styleBits, TEXTURED, true);
        if ("unified".equals(prop)) styleBits = SET(styleBits, UNIFIED, true);
        if ("hud".equals(prop)) styleBits = SET(styleBits, HUD, true);
      }

      prop = rootpane.getClientProperty(WINDOW_HIDES_ON_DEACTIVATE);
      if (prop != null) {
        styleBits = SET(styleBits, HIDES_ON_DEACTIVATE, Boolean.parseBoolean(prop.toString()));
      }

      prop = rootpane.getClientProperty(WINDOW_CLOSEABLE);
      if (prop != null) {
        styleBits = SET(styleBits, CLOSEABLE, Boolean.parseBoolean(prop.toString()));
      }

      prop = rootpane.getClientProperty(WINDOW_MINIMIZABLE);
      if (prop != null) {
        styleBits = SET(styleBits, MINIMIZABLE, Boolean.parseBoolean(prop.toString()));
      }

      prop = rootpane.getClientProperty(WINDOW_ZOOMABLE);
      if (prop != null) {
        styleBits = SET(styleBits, ZOOMABLE, Boolean.parseBoolean(prop.toString()));
      }

      prop = rootpane.getClientProperty(WINDOW_FULLSCREENABLE);
      if (prop != null) {
        styleBits = SET(styleBits, FULLSCREENABLE, Boolean.parseBoolean(prop.toString()));
      }

      prop = rootpane.getClientProperty(WINDOW_SHADOW);
      if (prop != null) {
        styleBits = SET(styleBits, HAS_SHADOW, Boolean.parseBoolean(prop.toString()));
      }

      prop = rootpane.getClientProperty(WINDOW_DRAGGABLE_BACKGROUND);
      if (prop != null) {
        styleBits = SET(styleBits, DRAGGABLE_BACKGROUND, Boolean.parseBoolean(prop.toString()));
      }
    }

    if (isDialog) {
      styleBits = SET(styleBits, IS_DIALOG, true);
      if (((Dialog) target).isModal()) {
        styleBits = SET(styleBits, IS_MODAL, true);
      }
    }

    peer.setTextured(IS(TEXTURED, styleBits));

    return styleBits;
  }
Exemplo n.º 3
0
 public void applyProperty(final CPlatformWindow c, final Object value) {
   c.setStyleBits(CLOSEABLE, Boolean.parseBoolean(value.toString()));
 }
Exemplo n.º 4
0
 public void applyProperty(final CPlatformWindow c, final Object value) {
   c.setStyleBits(
       HAS_SHADOW, value == null ? true : Boolean.parseBoolean(value.toString()));
 }
Exemplo n.º 5
0
 public void applyProperty(final CPlatformWindow c, final Object value) {
   c.setStyleBits(
       DOCUMENT_MODIFIED,
       value == null ? false : Boolean.parseBoolean(value.toString()));
 }
Exemplo n.º 6
0
  /**
   * Creates window with parameters specified by <code>params</code>
   *
   * @see #init
   */
  private final void create(XCreateWindowParams params) {
    XToolkit.awtLock();
    try {
      XSetWindowAttributes xattr = new XSetWindowAttributes();
      try {
        checkParams(params);

        long value_mask = ((Long) params.get(VALUE_MASK)).longValue();

        Long eventMask = (Long) params.get(EVENT_MASK);
        xattr.set_event_mask(eventMask.longValue());
        value_mask |= XlibWrapper.CWEventMask;

        Long border_pixel = (Long) params.get(BORDER_PIXEL);
        if (border_pixel != null) {
          xattr.set_border_pixel(border_pixel.longValue());
          value_mask |= XlibWrapper.CWBorderPixel;
        }

        Long colormap = (Long) params.get(COLORMAP);
        if (colormap != null) {
          xattr.set_colormap(colormap.longValue());
          value_mask |= XlibWrapper.CWColormap;
        }
        Long background_pixmap = (Long) params.get(BACKGROUND_PIXMAP);
        if (background_pixmap != null) {
          xattr.set_background_pixmap(background_pixmap.longValue());
          value_mask |= XlibWrapper.CWBackPixmap;
        }

        Long parentWindow = (Long) params.get(PARENT_WINDOW);
        Rectangle bounds = (Rectangle) params.get(BOUNDS);
        Integer depth = (Integer) params.get(DEPTH);
        Integer visual_class = (Integer) params.get(VISUAL_CLASS);
        Long visual = (Long) params.get(VISUAL);
        Boolean overrideRedirect = (Boolean) params.get(OVERRIDE_REDIRECT);
        if (overrideRedirect != null) {
          xattr.set_override_redirect(overrideRedirect.booleanValue());
          value_mask |= XlibWrapper.CWOverrideRedirect;
        }

        Boolean saveUnder = (Boolean) params.get(SAVE_UNDER);
        if (saveUnder != null) {
          xattr.set_save_under(saveUnder.booleanValue());
          value_mask |= XlibWrapper.CWSaveUnder;
        }

        Integer backingStore = (Integer) params.get(BACKING_STORE);
        if (backingStore != null) {
          xattr.set_backing_store(backingStore.intValue());
          value_mask |= XlibWrapper.CWBackingStore;
        }

        Integer bitGravity = (Integer) params.get(BIT_GRAVITY);
        if (bitGravity != null) {
          xattr.set_bit_gravity(bitGravity.intValue());
          value_mask |= XlibWrapper.CWBitGravity;
        }

        if (log.isLoggable(Level.FINE)) {
          log.fine("Creating window for " + this + " with the following attributes: \n" + params);
        }
        window =
            XlibWrapper.XCreateWindow(
                XToolkit.getDisplay(),
                parentWindow.longValue(),
                bounds.x,
                bounds.y, // location
                bounds.width,
                bounds.height, // size
                0, // border
                depth.intValue(), // depth
                visual_class.intValue(), // class
                visual.longValue(), // visual
                value_mask, // value mask
                xattr.pData); // attributes

        if (window == 0) {
          throw new IllegalStateException(
              "Couldn't create window because of wrong parameters. Run with NOISY_AWT to see details");
        }
        XToolkit.addToWinMap(window, this);
      } finally {
        xattr.dispose();
      }
    } finally {
      XToolkit.awtUnlock();
    }
  }