Elaboration on ibex.widget templates

Charles Goodwin <[email protected]> Fri, 19 Mar 2004 02:13:13 +0000
Newsgroups gmane.comp.java.xwt.widgets
Organization XWT Foundation
Message-ID <[email protected]>
Having been playing with this a lot, I'm making a minor alteration
because we want theme consistency, the majority of themes will use the
same basic mdoel, and the uber complex themes can override[1] the
ibex.widget namespace to adjust it to their needs.

Best to start with an example.

Before for ibex.button.t we had:

<ibex xmlns="ibex.theme">
    <meta:doc>...</meta:doc>
    <clickable />
    <focusable />
    <button />
    <ui:box />
</ibex>

What I'm proposing:

<ibex xmlns="ibex.theme">
    <meta:doc>...</meta:doc>
    <margin redirect="$content">
        <button>
            ibex..org.ibex.theme.win2k.focusable(.clickable(thisbox));
            <pad id="content" />
        </button>
    </margin>
    //
    // glue js code
    //
</ibex>

Why this works:

 o  It forces consistency

    All buttons should have margin/padding available to them and it
    should always work in the same way; it reduces the potential for
    problems with an arbitrary theme

 o  It reduces theme code

    Every theme should be implementing margin/padding (for the above
    reason) and 99% of the time it will be done the same way

 o  It allows greater and more efficient reuse of in-theme code

    A good example is scrollbar; scrollbar uses two buttons which
    don't need margins or padding or focusing.  Rather than being
    limited to the bulked up version of a button, instead we could
    use the simple theme version:

    <theme:button fill=".image.arrow_up">
        theme.clickable(thisbox);
    </theme:button>

Another decent example is tabpane which becomes:

<ibex xmlns="org.ibex.theme.win2k">
    <meta:doc>...</meta:doc>
    <margin redirect="content">
        <tabpane>
            <pad>
                <cardpane id="content" />
            </pad>
        </tabpane>
    </margin>
    //
    // glue js code
    //
</ibex>

Pretty much all (apart from the mega-different) theme implementations of
tabpane will use cardpane, so it is easy to slot it into the ibex.widget
definition of tabpane rather than make each theme template use it.

[1] Some sort of theme initialisation process will be needed (for this
and for other unrelated reasons) so that themes can do required
operations such as cloning or static variable setting to prepare the
environment for their widgets to work as desired.
-- 
- Charlie

Charles Goodwin <[email protected]>
Online @ http://www.charlietech.com