Rocket::Core::Box Class Reference

#include <Box.h>

Collaboration diagram for Rocket::Core::Box:

Public Types

enum  Area {
  MARGIN = 0, BORDER = 1, PADDING = 2, CONTENT = 3,
  NUM_AREAS = 3
}
enum  Edge {
  TOP = 0, RIGHT = 1, BOTTOM = 2, LEFT = 3,
  NUM_EDGES = 4
}

Public Member Functions

 Box ()
 Initialises a zero-sized box.
 Box (const Vector2f &content)
 Initialises a box with a default content area and no padding, borders and margins.
const Vector2fGetOffset () const
Vector2f GetPosition (Area area=Box::CONTENT) const
Vector2f GetSize (Area area=Box::CONTENT) const
void SetOffset (const Vector2f &offset)
void SetContent (const Vector2f &content)
void SetEdge (Area area, Edge edge, float size)
float GetEdge (Area area, Edge edge) const
float GetCumulativeEdge (Area area, Edge edge) const
bool operator== (const Box &rhs) const
bool operator!= (const Box &rhs) const

Detailed Description

Stores a box with four sized areas; content, padding, a border and margin. See http://www.w3.org/TR/REC-CSS2/box.html#box-dimensions for a diagram.

Author:
Peter Curry

Member Function Documentation

const Vector2f & Rocket::Core::Box::GetOffset (  )  const

Returns the offset of this box. This will usually be (0, 0).

Returns:
The box's offset.

Vector2f Rocket::Core::Box::GetPosition ( Area  area = Box::CONTENT  )  const

Returns the top-left position of one of the box's areas, relative to the top-left of the border area. This means the position of the margin area is likely to be negative.

Parameters:
area[in] The desired area.
Returns:
The position of the area.

Vector2f Rocket::Core::Box::GetSize ( Area  area = Box::CONTENT  )  const

Returns the size of one of the box's areas. This will include all inner areas.

Parameters:
area[in] The desired area.
Returns:
The size of the requested area.

void Rocket::Core::Box::SetOffset ( const Vector2f offset  ) 

Sets the offset of the box, relative usually to the owning element. This should only be set for auxiliary boxes of an element.

Parameters:
offset[in] The offset of the box from the primary box.

void Rocket::Core::Box::SetContent ( const Vector2f content  ) 

Sets the size of the content area.

Parameters:
content[in] The size of the new content area.

void Rocket::Core::Box::SetEdge ( Area  area,
Edge  edge,
float  size 
)

Sets the size of one of the edges of one of the box's outer areas.

Parameters:
area[in] The area to change.
edge[in] The area edge to change.
size[in] The new size of the area segment.

float Rocket::Core::Box::GetEdge ( Area  area,
Edge  edge 
) const

Returns the size of one of the area edges.

Parameters:
area[in] The desired area.
edge[in] The desired edge.
Returns:
The size of the requested area edge.

float Rocket::Core::Box::GetCumulativeEdge ( Area  area,
Edge  edge 
) const

Returns the cumulative size of one edge up to one of the box's areas.

Parameters:
area[in] The area to measure up to (and including). So, MARGIN will return the width of the margin, and PADDING will be the sum of the margin, border and padding.
edge[in] The desired edge.
Returns:
The cumulative size of the edge.

bool Rocket::Core::Box::operator== ( const Box rhs  )  const

Compares the size of the content area and the other area edges.

Returns:
True if the boxes represent the same area.

bool Rocket::Core::Box::operator!= ( const Box rhs  )  const

Compares the size of the content area and the other area edges.

Returns:
True if the boxes do not represent the same area.


The documentation for this class was generated from the following files:
  • Include/Rocket/Core/Box.h
  • Source/Core/Box.cpp