Introduction to Standard Widget Toolkit (III)

28 December 2007

I assume that you have gone through part I and II of “Introduction to Standard Widget Toolkit”. In this post, I will write about display, shell, parent and children, and style.

Display

The Display represents the connection between SWT and the underlying platform’s GUI system. Displays are primarily used to manage the platform event loop and control communication between the UI thread and other threads.

You must create a display before creating any windows, and you must dispose of the display when your shell is closed. You don’t need to think about the display much more unless you are designing a multi-threaded application.

Shell

A Shell is a “window” managed by the OS platform window manager. Top level shells are those that are created as a child of the display. These windows are the windows that users move, resize, minimize, and maximize while using the application. Secondary shells are those that are created as a child of another shell. These windows are typically used as dialog windows or other transient windows that only exist in the context of another window.

Parents and children

All widgets that are not top level shells must have a parent. Top level shells do not have a parent, but they are created in association with a particular Display. You can access this display using getDisplay(). All other widgets are created as descendants (direct or indirect) of top level shells.

Composite widgets are widgets that can have children.

When you see an application window, you can think of it as a widget tree, or hierarchy, whose root is the shell. Depending on the complexity of the application, there may be a single child of the shell, several children, or nested layers of composites with children.

Style bits

Some widget properties must be set at the time a widget is created and cannot be subsequently changed. For example, a list may be single or multi-selection, and may or may not have scroll bars.

These properties, called styles, are set in the constructor. All widget constructors take an int argument that specifies the bitwise OR of all desired styles. In some cases, a particular style is considered a hint, which means that it may not be available on all platforms, but will be gracefully ignored on platforms that do not support it.

The style constants are located in the SWT class as public static fields. A list of applicable constants for each widget class is contained in the API Reference for SWT.

del.icio.us:Introduction to Standard Widget Toolkit (III)  digg:Introduction to Standard Widget Toolkit (III)  spurl:Introduction to Standard Widget Toolkit (III)  wists:Introduction to Standard Widget Toolkit (III)  simpy:Introduction to Standard Widget Toolkit (III)  newsvine:Introduction to Standard Widget Toolkit (III)  blinklist:Introduction to Standard Widget Toolkit (III)  furl:Introduction to Standard Widget Toolkit (III)  reddit:Introduction to Standard Widget Toolkit (III)  fark:Introduction to Standard Widget Toolkit (III)  blogmarks:Introduction to Standard Widget Toolkit (III)  Y!:Introduction to Standard Widget Toolkit (III)  smarking:Introduction to Standard Widget Toolkit (III)  magnolia:Introduction to Standard Widget Toolkit (III)  segnalo:Introduction to Standard Widget Toolkit (III)  gifttagging:Introduction to Standard Widget Toolkit (III)

Top Of Page | Trackback

If you found this page useful, consider linking to it. Simply copy and paste the code below into your web site.

It will look like this: Introduction to Standard Widget Toolkit (III)

Leave a Reply