Class Style

Description

Represents CSS properties.

The Style class is responsible for handling and storing CSS properties. It includes methods to resolve colours and lengths, as well as getters & setters for many CSS properites.

Actual CSS parsing is performed in the Stylesheet class.

Located in /include/style.cls.php (line 53)


	
			
Variable Summary
Method Summary
Style __construct (Stylesheet $stylesheet)
string get_border_bottom ()
float|string get_border_bottom_width ()
string get_border_left ()
float|string get_border_left_width ()
string get_border_right ()
float|string get_border_right_width ()
string get_border_top ()
float|string get_border_top_width ()
array get_color ()
string get_font_family ()
float get_font_size ()
float get_line_height ()
float get_word_spacing ()
void inherit (Style $parent)
float length_in_pt (float|array $length, [float $ref_size = null])
void merge (Style $style)
array munge_color (string $color)
array munge_colour (string $colour)
void set_background_color (string $colour)
void set_border (string $val)
void set_border_bottom (string $val)
void set_border_color (string $val)
void set_border_left (string $val)
void set_border_right (string $val)
void set_border_spacing (float $val)
void set_border_style (string $val)
void set_border_top (string $val)
void set_border_width (string $val)
void set_color (string $colour)
void set_font_size (string|float $size)
void set_list_style ($val $val)
void set_margin ($val $val)
void set_margin_bottom ($val $val)
void set_margin_left ($val $val)
void set_margin_right ($val $val)
void set_margin_top ($val $val)
void set_padding ($val $val)
void set_padding_bottom ($val $val)
void set_padding_left ($val $val)
void set_padding_right ($val $val)
void set_padding_top ($val $val)
void set_page_break_after (string $break)
void set_page_break_before (string $break)
mixed _get_border (mixed $side)
void _set_border (string $side, string $border_spec)
mixed __get (string $prop)
void __set (string $prop, mixed $val)
string __toString ()
Variables
array $BLOCK_TYPES = array("block","inline-block", "table-cell", "list-item") (line 81)

List of all block types. Should really be a constant.

  • static:
array $BORDER_STYLES = array("none", "hidden", "dotted", "dashed", "solid",
"double", "groove", "ridge", "inset", "outset")
(line 95)

List of valid border styles. Should also really be a constant.

  • static:
float $default_font_size = 12 (line 60)

Default font size, in points.

  • static:
float $default_line_height = 1.2 (line 67)

Default line height, as a fraction of the font size.

  • static:
array $INLINE_TYPES = array("inline") (line 74)

List of all inline types. Should really be a constant.

  • static:
array; $TABLE_TYPES = array("table", "inline-table") (line 88)

List of all table types. Should really be a constant.

  • static:
array $_defaults = null (line 105)

Default style values.

array $_inherited = null (line 114)

List of inherited properties

float $_parent_font_size (line 137)

Font size of parent element in document tree. Used for relative font size resolution.

  • access: protected
array $_props (line 129)

Main array of all CSS properties & values

  • access: protected
Stylesheet $_stylesheet (line 122)

The stylesheet this style belongs to

Methods
Constructor __construct (line 152)

Class constructor

Style __construct (Stylesheet $stylesheet)
  • Stylesheet $stylesheet: the stylesheet this Style is associated with.
get_background_color (line 895)

Returns the background colour as an array

The returned array has the same format as Style::get_color()

array get_background_color ()
get_background_position (line 908)

Returns the background position as an array

The returned array has the following format:

  1. array(x,y, "x" => x, "y" => y)

array get_background_position ()
get_border_bottom (line 1096)

Return full border properties as a string

Border properties are returned just as specified in CSS:

[width] [style] [color]
e.g. "1px solid blue"

string get_border_bottom ()
get_border_bottom_color (line 1003)

Returns the border colour as an array

array get_border_bottom_color ()
get_border_bottom_width (line 1033)

Returns the border width, as it is currently stored

float|string get_border_bottom_width ()
get_border_left (line 1097)

Return full border properties as a string

Border properties are returned just as specified in CSS:

[width] [style] [color]
e.g. "1px solid blue"

string get_border_left ()
get_border_left_color (line 1009)

Returns the border colour as an array

array get_border_left_color ()
get_border_left_width (line 1038)

Returns the border width, as it is currently stored

float|string get_border_left_width ()
get_border_properties (line 1057)

Return an array of all border properties.

The returned array has the following structure:

  1. array("top" => array("width" => [border-width],
  2. "style" => [border-style],
  3. "color" => [border-color (array)]),
  4. "bottom" ... )

array get_border_properties ()
get_border_right (line 1095)

Return full border properties as a string

Border properties are returned just as specified in CSS:

[width] [style] [color]
e.g. "1px solid blue"

string get_border_right ()
get_border_right_color (line 997)

Returns the border colour as an array

array get_border_right_color ()
get_border_right_width (line 1028)

Returns the border width, as it is currently stored

float|string get_border_right_width ()
get_border_spacing (line 1109)

Returns border spacing as an array

The array has the format (h_space,v_space)

array get_border_spacing ()
get_border_top (line 1094)

Return full border properties as a string

Border properties are returned just as specified in CSS:

[width] [style] [color]
e.g. "1px solid blue"

string get_border_top ()
get_border_top_color (line 991)

Returns the border colour as an array

array get_border_top_color ()
get_border_top_width (line 1023)

Returns the border width, as it is currently stored

float|string get_border_top_width ()
get_color (line 883)

Returns the colour as an array

The array has the following format:

  1. array(r,g,b, "r" => r, "g" => g, "b" => b, "hex" => "#rrggbb")

array get_color ()
get_font_family (line 729)

Getter for the 'font-family' CSS property.

Uses the Font_Metrics class to resolve the font family into an actual font file.

string get_font_family ()
get_font_size (line 784)

Returns the resolved font size, in points

float get_font_size ()
get_line_height (line 864)
float get_line_height ()
get_stylesheet (line 332)

returns the Stylesheet this Style is associated with.

Stylesheet get_stylesheet ()
get_word_spacing (line 853)
float get_word_spacing ()
inherit (line 451)

Set inherited properties in this style using values in $parent

void inherit (Style $parent)
length_in_pt (line 348)

Converts any CSS length value into an absolute length in points.

length_in_pt() takes a single length (e.g. '1em') or an array of lengths and returns an absolute length. If an array is passed, then the return value is the sum of all elements.

If a reference size is not provided, the default font size is used (Style::$default_font_size).

float length_in_pt (float|array $length, [float $ref_size = null])
  • float|array $length: the length or array of lengths to resolve
  • float $ref_size: an absolute reference size to resolve percentage lengths
merge (line 475)

Override properties in this style with those in $style

void merge (Style $style)
munge_color (line 647)

Alias for Style::munge_colour()

array munge_color (string $color)
  • string $color
munge_colour (line 490)

Returns an array(r, g, b, "r"=> r, "g"=>g, "b"=>b, "hex"=>"#rrggbb") based on the provided CSS colour value.

array munge_colour (string $colour)
  • string $colour
set_background_color (line 1137)

Sets the background colour

void set_background_color (string $colour)
  • string $colour
set_border (line 1361)

Sets the border styles

void set_border (string $val)
  • string $val
set_border_bottom (line 1358)

Sets the border styles

void set_border_bottom (string $val)
  • string $val
set_border_color (line 1410)

Sets the border styles

void set_border_color (string $val)
  • string $val
set_border_left (line 1359)

Sets the border styles

void set_border_left (string $val)
  • string $val
set_border_right (line 1357)

Sets the border styles

void set_border_right (string $val)
  • string $val
set_border_spacing (line 1502)

Sets the border spacing

void set_border_spacing (float $val)
  • float $val
set_border_style (line 1453)

Sets the border styles

void set_border_style (string $val)
  • string $val
set_border_top (line 1356)

Sets the border styles

void set_border_top (string $val)
  • string $val
set_border_width (line 1369)

Sets the border styles

void set_border_width (string $val)
  • string $val
set_color (line 1122)

Sets colour

The colour parameter can be any valid CSS colour value

void set_color (string $colour)
  • string $colour
set_font_size (line 1153)

Sets the font size

$size can be any acceptable CSS size

void set_font_size (string|float $size)
  • string|float $size
set_list_style (line 1520)

Sets the list style

This is not currently implemented

void set_list_style ($val $val)
  • $val $val
set_margin (line 1203)

Sets the margin size

void set_margin ($val $val)
  • $val $val
set_margin_bottom (line 1195)

Sets the margin size

void set_margin_bottom ($val $val)
  • $val $val
set_margin_left (line 1199)

Sets the margin size

void set_margin_left ($val $val)
  • $val $val
set_margin_right (line 1191)

Sets the margin size

void set_margin_right ($val $val)
  • $val $val
set_margin_top (line 1187)

Sets the margin size

void set_margin_top ($val $val)
  • $val $val
set_padding (line 1270)

Sets the padding size

void set_padding ($val $val)
  • $val $val
set_padding_bottom (line 1262)

Sets the padding size

void set_padding_bottom ($val $val)
  • $val $val
set_padding_left (line 1266)

Sets the padding size

void set_padding_left ($val $val)
  • $val $val
set_padding_right (line 1258)

Sets the padding size

void set_padding_right ($val $val)
  • $val $val
set_padding_top (line 1254)

Sets the padding size

void set_padding_top ($val $val)
  • $val $val
set_page_break_after (line 1171)

Sets page break properties

void set_page_break_after (string $break)
  • string $break
set_page_break_before (line 1164)

Sets page break properties

void set_page_break_before (string $break)
  • string $break
_get_border (line 1077)

Return a single border property

  • access: protected
mixed _get_border (mixed $side)
_set_border (line 1319)

Sets a single border

  • access: protected
void _set_border (string $side, string $border_spec)
  • string $side
  • string $border_spec: ([width] [style] [color])
__get (line 702)

PHP5 overloaded getter

Along with Style::__set() __get() provides access to all CSS properties directly. Typically __get() is not called directly outside of this class.

mixed __get (string $prop)
  • string $prop
__set (line 668)

PHP5 overloaded setter

This function along with Style::__get() permit a user of the Style class to access any (CSS) property using the following syntax:

  1. Style->margin_top = "1em";
  2. echo (Style->margin_top);

__set() automatically calls the provided set function, if one exists, otherwise it sets the property directly. Typically, __set() is not called directly from outside of this class.

void __set (string $prop, mixed $val)
  • string $prop: the property to set
  • mixed $val: the value of the property
__toString (line 1535)

Generate a string representation of the Style

This dumps the entire property array into a string via print_r. Useful for debugging.

string __toString ()

Documentation generated on Fri, 04 Mar 2005 13:31:19 -0700 by phpDocumentor 1.3.0RC3