* You are viewing Posts Tagged ‘Chromium’

Vista glass in SWT application

Desktop Java applications by definition are/should be portable to multiple operating systems. Writing with SWT refines set of available operating systems, but it also gives you some opportunities to make application aware of operating system and blends it visually. With Windows Vista’s new Desktop Window Manager we are able to create visually more stunning and eye catching applications. Look at the Chrome screenshot below, notice the decoration of window, it’s transparent and blurred:

Chrome

You can actually do similar thing in SWT (under Windows Vista only) and here’s a small example screenshot:

Vista glass in SWT

So, what do we need to do to accomplish that? It’s quite easy, as a matter of fact, but requires nasty access to internal OS class which makes it SWT windows only!

/**
 * Applies vista glass frame - works only on Vista with Areo.
 */

private void applyVistaGlassFrame()
{
    int glassHeight = 100;

    MARGINS margins = new MARGINS();
    margins.cyTopHeight = glassHeight;

    OS.DwmExtendFrameIntoClientArea(shell.handle, margins);
}

Example above will add 100 pixels of glass area at top of the dialog.

But that’s not enough, we need also to cover glass area with black color, for this we can add Composite widget that will have background color set to SWT.COLOR_BLACK.

Unfortunately this functionality is not 100% covered by SWT. Additional checks against Vista needs to be done. We also need to know if Desktop Window Manager’s Compositions are enabled. Unfortunately we don’t have access to DwmIsCompositionEnabled (it’s not declared in OS class).

While writing this article, I’ve came up with idea how this can be used in Eclipse - about dialog. Recent changes to about dialog are great, but what if go a little bit further and make top of the dialog similar to this, but under Windows Vista with composition instead of white background use glass?