Name

style — specifies colors used by components

Synopsis

LZX: style
JavaScript: style
Type: Class
Access: public
Topic: Components.Base Components
Declared in: lps/components/base/style.lzx

Description

Styles may be defined to establish a consistent "look" for a group of components. There are a number of pre-defined styles. If you don't declare a default style, the OpenLaszlo components will use whitestyle. To specify a different default style, define a style with isdefault="true".

Example 35. Simple Style Example

        <canvas height="60" width="200" >
          <greenstyle name="mystyle" isdefault="true"/>
          <checkbox>Tell me more</checkbox>
          <button>Submit</button>
          <simplelayout spacing="10" inset="10"/>
        </canvas>
        

There are several styles defined as classes (whitestyle, silverstyle, bluestyle, greenstyle, goldstyle, and purplestyle). You may create an instance of one of these, create a new style, or create an instance with one or more modified attributes.

Different styles may be used in different parts of an application, to highlight a single component or to distinguish a group of components. The style of a component applies to itself and any component within it.

In the example below, section one and two of the tabslider and the checkboxes inside them appear gold. Section Three and the components inside it appear green.

Example 36. Using Multiple Styles

        <canvas height="250">
          <goldstyle name="defaultstyle" isdefault="true"/>
          <greenstyle name="specialstyle"/>
          <tabslider id="ts1" x="50" y="20"
                     width="300" height="180">
        
            <tabelement text="Section One" selected="true">
              <checkbox>option one</checkbox>
            </tabelement>
        
            <tabelement text="Section Two">
              <checkbox>option two</checkbox>
            </tabelement>
        
            <tabelement text="Section Three" style="$once{specialstyle}">
              <radiogroup>
                <radiobutton>Yes, I want to know more</radiobutton>
                <radiobutton>No, I prefer to remain blissfully unaware</radiobutton>
                <radiobutton>Please tell my neighbor, who may tell me</radiobutton>
              </radiogroup>
              <button align="right">Submit</button>
              <simplelayout axis="y" spacing="10"/>
            </tabelement>
          </tabslider>
        </canvas>
        

You may define your own style by declaring values for various style attributes described in the attribute reference below. For example, the following style uses the default values for most style attributes, but provides custom values for the basecolor (overall shade of the components) and the textcolor.

<pre> <style name="customstyle" basecolor="0xddddff" textcolor="blue"/> </pre>

Further reading

You can see the definitions of the pre-defined styles in: lps/components/base/defaultstyles.lzx

Named colors are defined in: lps/components/base/colors.lzx

contains style attributes which are applied to components to modify their look

Superclass Chain

node (LzNode) » style

Known Subclasses

Known Direct Subclasses: textstyle

Details

Properties (16)

basecolor
<attribute name="basecolor" type="color" value="offwhite" />
public var basecolor : color;
used for colorizing a component, components will typically use varying shades of this color. Default: offwhite
bgcolor
<attribute name="bgcolor" type="color" value="white" />
public var bgcolor : color;
used for colorizing the backgrounds of content areas, such as the background in tabslider's content, and window's content default: white
bordercolor
<attribute name="bordercolor" type="color" value="gray40" />
public var bordercolor : color;
used to color the frame of a component for those that have a visual border. Default: gray40 (a medium dark gray)
bordersize
<attribute name="bordersize" value="1" />
public var bordersize;
the line width used in those components that have a visual border, default: 1
canvascolor
<attribute name="canvascolor" type="color" value="null" />
public var canvascolor : color;
canvas color, default: null (will use whatever is specified as the canvas bgcolor, default: white)
disabledcolor
<attribute name="disabledcolor" type="color" value="gray30" />
public var disabledcolor : color;
used when an item is disabled default: gray30
hilitecolor
<attribute name="hilitecolor" type="color" value="iceblue4" />
public var hilitecolor : color;
used when the background color changes to highlight an item, such as when mouse is over a menu item default: iceblue3
isdefault
<attribute name="isdefault" value="false" />
public var isdefault;
if true, this style is the default style for components
isstyle
<attribute name="isstyle" value="true" />
public read-only var isstyle;
this is a style object
menuitembgcolor
<attribute name="menuitembgcolor" value="textfieldcolor" />
public var menuitembgcolor;
background color for menu items, defaults to the 'textfieldcolor'
selectedcolor
<attribute name="selectedcolor" type="color" value="iceblue3" />
public var selectedcolor : color;
used when an item is selected, such as in a list default: iceblue4
textcolor
<attribute name="textcolor" type="color" value="gray10" />
public var textcolor : color;
color for text, default: black
textdisabledcolor
<attribute name="textdisabledcolor" type="color" value="gray60" />
public var textdisabledcolor : color;
used as the text color when a component is disabled default: gray60
textfieldcolor
<attribute name="textfieldcolor" type="color" value="white" />
public var textfieldcolor : color;
background color for text areas, default: white
texthilitecolor
<attribute name="texthilitecolor" type="color" value="iceblue1" />
public var texthilitecolor : color;
used as the text color with 'hilitecolor' to highlight an item, such as when mouse is over a menu item default: iceblue1
textselectedcolor
<attribute name="textselectedcolor" type="color" value="black" />
public var textselectedcolor : color;
used as the text color with 'selectedcolor' to color the selected item default: iceblue1

Methods (1)

extend()
<method name="extend" args="args" />
public function extend(args);
returns a new style object which is based on this one with only specified attributes modified param dictionary args: the attributes for the new style

LZX Synopsis

<class name="style" extends=" LzNode ">
  <attribute name=" basecolor " type="color" value="offwhite" />
  <attribute name=" bgcolor " type="color" value="white" />
  <attribute name=" bordercolor " type="color" value="gray40" />
  <attribute name=" bordersize " value="1" />
  <attribute name=" canvascolor " type="color" value="null" />
  <attribute name=" disabledcolor " type="color" value="gray30" />
  <attribute name=" hilitecolor " type="color" value="iceblue4" />
  <attribute name=" isdefault " value="false" />
  <attribute name=" isstyle " value="true" />
  <attribute name=" menuitembgcolor " value="textfieldcolor" />
  <attribute name=" selectedcolor " type="color" value="iceblue3" />
  <attribute name=" textcolor " type="color" value="gray10" />
  <attribute name=" textdisabledcolor " type="color" value="gray60" />
  <attribute name=" textfieldcolor " type="color" value="white" />
  <attribute name=" texthilitecolor " type="color" value="iceblue1" />
  <attribute name=" textselectedcolor " type="color" value="black" />
  <method name=" extend " args="args" />
</class>

JavaScript Synopsis

public style extends  LzNode  {
  public var basecolor  : color;
  public var bgcolor  : color;
  public var bordercolor  : color;
  public var bordersize ;
  public var canvascolor  : color;
  public var disabledcolor  : color;
  public var hilitecolor  : color;
  public var isdefault ;
  public read-only var isstyle ;
  public var menuitembgcolor ;
  public var selectedcolor  : color;
  public var textcolor  : color;
  public var textdisabledcolor  : color;
  public var textfieldcolor  : color;
  public var texthilitecolor  : color;
  public var textselectedcolor  : color;
  prototype public function extend (args);
}