This chapter gives an overview of layout components, starting with their
history, and then gives more specific description of the components
together with some examples.
Layouts are required to place components to specific places in the user interface. You
can use plain Java to accomplish sophisticated component layouting. Another
option is to use CustomLayout class and let the web page designers to take
responsibility of component layouting using their own set of tools.
Layouts are often strongly coupled with themes that specify various
layout attributes such as backgrounds, borders, alignment, and so
on. Themes are detailed in Chapter 6, Themes.
Ever since the ancient xeroxians invented graphical user interfaces,
programmers have wanted to make GUI programming ever easier for
themselves. Solutions started simple. When GUIs appeared on PC
desktops, practically all screens were of the VGA type and fixed into
640x480 size. Mac or X Window System on UNIX were not much
different. Everyone was so happy with such awesome graphics
resolutions that they never thought that an application would have to
work on a radically different screen size. At worst, screens could
only grow, they thought, giving more space for more windows. In the
80s, the idea of having a computer screen in your pocket was simply
not realistic. Hence, the GUI APIs allowed placing UI components
using screen coordinates. Visual Basic and other horribilities
provided an easy way for the designer to drag and drop components on
a fixed-sized window. One would have thought that at least
translators had complained about the awkwardness of such a solution,
but apparently they were not, as non-engineers, heard or at least
cared about. At best, engineers could throw at them a resource editor
that would allow them to resize the UI components by hand. Such was
the spirit back then.
After the web was born, layout design was doomed to change for ever.
At first, layout didn't matter much, as everyone was happy with plain
headings, paragraphs, and a few hyperlinks here and there. Designers
of HTML wanted the pages to run on any screen size. The screen size
was actually not pixels but rows and columns of characters, as the
baby web was really just hypertext, not
graphics. That was soon to be changed. The first GUI-based browser,
NCSA Mosaic, launched a revolution that culminated in Netscape
Navigator. Suddenly, people who had previously been doing
advertisement broshures started writing HTML. This meant that layout
design had to be easy not just for programmers, but also allow the
graphics designer do his or her job without having to know a thing
about programming. The W3C committee designing web standards came up
with the CSS (Cascading Style Sheet) specification, which allowed trivial separation of
appearance from content. Later versions of HTML followed, XHTML
appeared, as did countless other standards.
Page description and markup languages are a wonderful solution for static
presentations, such as books and most web pages. Real applications, however,
need to have more control. They need to be able to change the state of user
interface components and even their layout on the run. This creates a need to
separate the presentation from content from exactly the right level.
Thanks to the attack of graphics designers, desktop applications were, when it
comes to appearance, far behind web design. Sun Microsystems had come in 1995
with a new programming language, Java, for writing cross-platform desktop
applications. Java's original graphical user interface toolkit, AWT (Abstract
Windowing Toolkit), was designed to work on multiple operating systems as well
as embedded in web browsers. One of the special aspects of AWT was the layout
manager, which allowed user interface components to be flexible, growing and
shrinking as they needed. This made it possible for the user to resize the
windows of an application flexibly and also served the needs of localization,
as text strings were not limited to some fixed size in pixels. It became even
possible to resize the pixel size of fonts, and the rest of the layout
adapted to the new size.
Layout management of IT Mill Toolkit is a direct successor of the web-based
concept for separation of content and appearance and of the Java AWT solution
for binding the layout and user interface components into objects in
programs. IT Mill Toolkit layout components allow you to position your UI
components on the screen in a hierarchical fashion, much like in conventional
Java UI toolkits such as AWT, Swing, or SWT. In addition, you can approach the
layout from the direction of the web with the
CustomLayout component, which you can use to write your
layout as a template in XHTML that provides locations of any contained
components.
The moral of the story is that, because IT Mill Toolkit is intended
for web applications, appearance is of high importance. The solutions
have to be the best of both worlds and satisfy artist of the both
kind: code and graphics. On the API side, layout is controlled by UI
components, particularly the layout components. On the visual side, it is controlled by themes. Themes
can contain any HTML, CSS, and JavaScript that you or your web
artists create to make people feel good about your software.