# dlangui.widgets.styles

DLANGUI library.
This module contains declaration of themes and styles implementation.
Style - style container Theme - parent for all styles
Synopsis:

    import dlangui.widgets.styles;

License:
Boost License 1.0
Authors:
Vadim Lopatin, coolreader.org@gmail.com

immutable uint COLOR_TRANSPARENT;
  transparent color constant
immutable ushort FONT_SIZE_UNSPECIFIED;
  unspecified font size constant - to take parent style property value
immutable ushort FONT_WEIGHT_UNSPECIFIED;
  unspecified font weight constant - to take parent style property value
immutable ubyte FONT_STYLE_UNSPECIFIED;
  unspecified font style constant - to take parent style property value
immutable ubyte FONT_STYLE_NORMAL;
  normal font style constant
immutable ubyte FONT_STYLE_ITALIC;
  italic font style constant
immutable int SIZE_UNSPECIFIED;
  use as widget.layout() param to avoid applying of parent size
immutable uint TEXT_FLAGS_UNSPECIFIED;
  use text flags from parent style
immutable uint TEXT_FLAGS_USE_PARENT;
  use text flags from parent widget
immutable int FILL_PARENT;
  layout option, to occupy all available place
immutable int WRAP_CONTENT;
  layout option, for size based on content
immutable int WEIGHT_UNSPECIFIED;
  to take layout weight from parent
enum Align: ubyte;
  Align option bit constants
  Unspecified
    alignment is not specified
  Left
    horizontally align to the left of box
  Right
    horizontally align to the right of box
  HCenter
    horizontally align to the center of box
  Top
    vertically align to the top of box
  Bottom
    vertically align to the bottom of box
  VCenter
    vertically align to the center of box
  Center
    align to the center of box (VCenter | HCenter)
  TopLeft
    align to the top left corner of box (Left | Top)
enum TextFlag: uint;
  text drawing flag bits
  HotKeys
    text contains hot key prefixed with & char (e.g. "&File")
  UnderlineHotKeys
    underline hot key when drawing
  UnderlineHotKeysWhenAltPressed
    underline hot key when drawing
  Underline
    underline text when drawing
class DrawableAttribute;
  custom drawable attribute container for styles
class Style;
  style properties
  const @property const(Style) parentStyle();
    access to parent style for this style
  @property Style parentStyle();
    access to parent style for this style
  @property ref DrawableRef customDrawable(string id);
    get custom drawable attribute
  const @property string customDrawableId(string id);
    get custom drawable attribute
  Style setCustomDrawable(string id, string resourceId);
    sets custom drawable attribute for style
  const @property FontFamily fontFamily();
    font size
  const @property string fontFace();
    font size
  const @property bool fontItalic();
    font style - italic
  const @property ushort fontWeight();
    font weight
  const @property ushort fontSize();
    font size
  const @property ref const(Rect) padding();
    padding
  const @property ref const(Rect) margins();
    margins
  const @property uint alpha();
    alpha (0=opaque .. 255=transparent)
  const @property uint textColor();
    text color
  const @property uint textFlags();
    text flags
  const @property uint backgroundColor();
    background color
  const @property string backgroundImageId();
    font size
  const @property uint minWidth();
    minimal width constraint, 0 if limit is not set
  const @property uint maxWidth();
    max width constraint, returns SIZE_UNSPECIFIED if limit is not set
  const @property uint minHeight();
    minimal height constraint, 0 if limit is not set
  const @property uint maxHeight();
    max height constraint, SIZE_UNSPECIFIED if limit is not set
  @property Style minWidth(int value);
    set min width constraint
  @property Style maxWidth(int value);
    set max width constraint
  @property Style minHeight(int value);
    set min height constraint
  @property Style maxHeight(int value);
    set max height constraint
  const @property uint layoutWidth();
    layout width parameter
  const @property uint layoutHeight();
    layout height parameter
  const @property uint layoutWeight();
    layout weight parameter
  @property Style layoutHeight(int value);
    set layout height
  @property Style layoutWidth(int value);
    set layout width
  @property Style layoutWeight(int value);
    set layout weight
  const @property ubyte alignment();
    get full alignment (both vertical and horizontal)
  const @property ubyte valign();
    vertical alignment: Top / VCenter / Bottom
  const @property ubyte halign();
    horizontal alignment: Left / HCenter / Right
  @property Style alignment(ubyte value);
    set alignment
  Style createSubstyle(string id);
    create named substyle of this style
  Style createState(uint stateMask = 0, uint stateValue = 0);
    create state substyle for this style
  const const(Style) forState(uint state);
    find substyle based on widget state (e.g. focused, pressed, ...)
class Theme: dlangui.widgets.styles.Style;
  Theme - root for style hierarhy.
  Style modifyStyle(string id);
    create wrapper style which will have currentTheme.get(id) as parent instead of fixed parent - to modify some base style properties in widget
  const @property string backgroundImageId();
    font size
  const @property uint minWidth();
    minimal width constraint, 0 if limit is not set
  const @property uint maxWidth();
    max width constraint, returns SIZE_UNSPECIFIED if limit is not set
  const @property uint minHeight();
    minimal height constraint, 0 if limit is not set
  const @property uint maxHeight();
    max height constraint, SIZE_UNSPECIFIED if limit is not set
  Style createSubstyle(string id);
    create new named style or get existing
  @property Style get(string id);
    find style by id, returns theme if not style with specified ID is not found
  const const(Style) forState(uint state);
    find substyle based on widget state (e.g. focused, pressed, ...)
@property Theme currentTheme();
  current theme accessor
@property void currentTheme(Theme theme);
  set new current theme
Rect decodeRect(string s);
  decode comma delimited dimension list or single value - and put to Rect
ubyte decodeAlignment(string s);
  parses string like "Left|VCenter" to bit set of Align flags
uint decodeTextFlags(string s);
  parses string like "HotKeys|UnderlineHotKeysWhenAltPressed" to bit set of TextFlag flags
FontFamily decodeFontFamily(string s);
  decode FontFamily item name to value
int decodeLayoutDimension(string s);
  decode layout dimension (FILL_PARENT, WRAP_CONTENT, or just size)
bool loadStyleAttributes(Style style, Element elem, bool allowStates);
  load style attributes from XML element
bool loadTheme(Theme theme, Element doc, int level = 0);
  load theme from XML document
  Sample:

      <?xml version="1.0" encoding="utf-8"?>
      <theme id="theme_custom" parent="theme_default">
        	<style id="BUTTON"
      			backgroundImageId="btn_default_small"
      	 	>
        	</style>
      </theme>

bool loadTheme(Theme theme, string resourceId, int level = 0);
  load theme from file
Theme loadTheme(string resourceId);
  load theme from XML file (null if failed)

Page generated by Ddoc. Vadim Lopatin, 2014