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)
void dispose ()
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_list_style_image ($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.
dispose (line 330)

"Destructor": forcibly free all references held by this object

void dispose ()
get_background_color (line 902)

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 915)

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 1103)

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 1010)

Returns the border colour as an array

See Style::get_color()

array get_border_bottom_color ()
get_border_bottom_width (line 1040)

Returns the border width, as it is currently stored

float|string get_border_bottom_width ()
get_border_left (line 1104)

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 1016)

Returns the border colour as an array

See Style::get_color()

array get_border_left_color ()
get_border_left_width (line 1045)

Returns the border width, as it is currently stored

float|string get_border_left_width ()
get_border_properties (line 1064)

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 1102)

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 1004)

Returns the border colour as an array

See Style::get_color()

array get_border_right_color ()
get_border_right_width (line 1035)

Returns the border width, as it is currently stored

float|string get_border_right_width ()
get_border_spacing (line 1116)

Returns border spacing as an array

The array has the format (h_space,v_space)

array get_border_spacing ()
get_border_top (line 1101)

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 998)

Returns the border colour as an array

See Style::get_color()

array get_border_top_color ()
get_border_top_width (line 1030)

Returns the border width, as it is currently stored

float|string get_border_top_width ()
get_color (line 890)

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 736)

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 791)

Returns the resolved font size, in points

float get_font_size ()
get_line_height (line 871)
float get_line_height ()
get_stylesheet (line 339)

returns the Stylesheet this Style is associated with.

Stylesheet get_stylesheet ()
get_word_spacing (line 860)
float get_word_spacing ()
inherit (line 458)

Set inherited properties in this style using values in $parent

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

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 482)

Override properties in this style with those in $style

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

Alias for Style::munge_colour()

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

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 1144)

Sets the background colour

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

Sets the border styles

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

Sets the border styles

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

Sets the border styles

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

Sets the border styles

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

Sets the border styles

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

Sets the border spacing

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

Sets the border styles

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

Sets the border styles

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

Sets the border styles

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

Sets colour

The colour parameter can be any valid CSS colour value

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

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 1545)

Sets the list style

This is not currently implemented

void set_list_style ($val $val)
  • $val $val
set_list_style_image (line 1525)

Sets the list style image

void set_list_style_image ($val $val)
  • $val $val
set_margin (line 1210)

Sets the margin size

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

Sets the margin size

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

Sets the margin size

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

Sets the margin size

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

Sets the margin size

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

Sets the padding size

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

Sets the padding size

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

Sets the padding size

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

Sets the padding size

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

Sets the padding size

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

Sets page break properties

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

Sets page break properties

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

Return a single border property

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

Sets a single border

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

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 675)

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 1578)

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 Sat, 19 Nov 2005 12:36:36 -0700 by phpDocumentor 1.3.0RC3