How to create a grid

"Charles Goodwin" <[email protected]> Wed, 30 Jul 2003 10:38:51 -0000 (GMT)
Newsgroups gmane.comp.java.xwt.widgets
Message-ID <[email protected]>
One of the reasons we are missing widgets like table is that they are very
dependent on a grid.

My initial attempts to create a grid failed, miserably.  And, once I was
under the impression gridbag was a priority addition to the core, I
dropped my efforts.  But it no longer appears that gridbag is a priority
(no progress in 2 months) and since then I have come across a very
effective technique: shadowing.

In tabpane, because the tabs resize and move according to their being
selected, it was difficult to create a literal header[tab, tab, tab] as
moving and resizing tabs obviously had a knock on effect.  A temporary
holding tab was not ideal either, as it's size was based upon the
now-moved selected tab - which was no longer sensitive to any size changes
in the header.  You can't have two objects dynamically size yet size off
of each other.

So I came up with the concept of shadow boxen:

shadow[tab1.shadow, tab2.shadow, tab3.shadow]
header[tab1, tab3]
selected[tab2]

$header and $selected get their size from $shadow, then the tabs get their
positioning from their respective shadows (which are free to dynamically
resize as shadow resizes) and be as big or small as they like.  This makes
having the selected tab overlap other tabs relatively easy as well.

So, I realised, why not apply the same concept to grid?

shadow[row1.s[cola1.s, colb1.s]], row2.s[cola2.s, colb2.s]]
grid[row1[cola1, colb1], row2[cola2, colb2]]

Using the shadows and absolute positioning tricks, it's easy to do things
such as colspan and rowspan.

It will use a nice, xwt box structure, being defined:

<grid>
  <row>
    <col />
    <col />
  </row>
  <row>
    <col />
    <col />
  </row>
</grid>

My reservations come into play with large tables.  'Boxes are cheap' so
the shadows in not a problem, however the box <> box.shadow relationship
is heavily _SizeChange and _PosChange dependent.  In a tabpane, this is
not an issue because you'll never have more than a few 10s of tabs in a
tabpane.

However, a table with 5,000 rows and 10 columns?  That's 50,000
_SizeChange and _PosChange traps.  Is this a viable method?  I'm going to
persevere because we need grids, I need grids.  Expect it to be part of
the 0.6 release.

- Charlie

The future of webapps - www.xwt.org