pivot-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Bartlett <cbartlet...@gmail.com>
Subject Re: Applying a style to all elements of a control
Date Tue, 22 Mar 2011 06:38:07 GMT
On 22 March 2011 09:26, Bill van Melle <bill.van.melle@gmail.com> wrote:

> There's a note in the 2.0 change log about "named styles" (
> https://issues.apache.org/jira/browse/PIVOT-553).  I can't tell from the
> terse example in the ticket whether the capability I'm looking for exists,
> or just how to do it.  Certainly, the example there is not much less wordy
> (if at all) than simply repeating the style verbatim if it's a simple style.
>  And is there a way to do it without a separate json file, something like
>
I think this example goes with that JIRA ticket on named styles.
http://svn.apache.org/repos/asf/pivot/trunk/examples/src/org/apache/pivot/examples/styles/

I'm trying to understand if there's a way to set a common style for all like
> elements in a bxml file, e.g., make the text on all the Label controls have
> font size = 9, or for all PushButton's to have a grey background.  Or even
> cooler, setting the font size for *all* elements that render text (something
> WPF lets you do at the top level of a XAML file -- they have a notion of
> certain properties being inheritable thru a layout hierarchy).
>
Styles can be named or typed and are stored in static maps in Component, so
I don't think it is possible to scope them.  Of course you could use
different style names for your different BXML files, but that may not help
you much.
http://pivot.apache.org/2.0/docs/api/org/apache/pivot/wtk/Component.html#getNamedStyles()
http://pivot.apache.org/2.0/docs/api/org/apache/pivot/wtk/Component.html#getTypedStyles()
http://pivot.apache.org/2.0/docs/api/org/apache/pivot/wtk/
ApplicationContext.html#applyStylesheet(java.lang.String)
You can apply a stylesheet programmatically like this
ApplicationContext.applyStylesheet("/fully/qualified/path/to/my_styles_file.json");

You should be able to use named styles to apply font configuration, colors,
background colors etc.  I think it just tries to apply the styles contained
within the named style definition, but will only succeed when the style name
matches.  Therefore if would silently (gracefully?) fail if you tried to set
a style such as ListView's 'alternateItemBackgroundColor' for a Label (via a
named style).

Chris

Mime
View raw message