Made to Order Software Corporation Logo

libsswf: sswf::SRectangle Class Reference

The SWF rectangle. More...

#include <libsswf.h>

List of all members.


Public Member Functions

bool IsEmpty (void) const
 Check whether a rectangle is empty.
ErrorManager::error_code_t Parse (const Data &data)
 Parses a rectangle from a data buffer.
void Reset (void)
 Resets the rectangle to all zeroes.
void Save (Data &data) const
 Save a rectangle in a data buffer.
void Set (long xmin, long xmax, long ymin, long ymax)
 Sets the coordinates of the rectangle.
void SetReorder (long xmin, long xmax, long ymin, long ymax)
 Set the coordinates of the rectangle ordering them as required.
 SRectangle (void)
 Initialize the rectangle to all zeroes.
long XMax (void) const
 Read the right side X coordinate.
long XMin (void) const
 Read the left side X coordinate.
long YMax (void) const
 Read the bottom side Y coordinate.
long YMin (void) const
 Read the top side Y coordinate.

Private Attributes

long f_xmax
long f_xmin
long f_ymax
long f_ymin

Detailed Description

The SWF format allows for compressed rectangles. These are saved with 5 bits representing the number of bits used for each coordinate followed by the coordinates.

The coordinates represent points. In other words, the rectangle is defined with two points (xmin, ymin) and (xmax, ymax).

If the rectangle is considered empty, the width and height are considered to be 0.

To compute the width, do XMax() - XMin().

To compute the height, do YMax() - YMin().

See also:
sswf::SRectangle::Reset(void)

sswf::SRectangle::Set(long xmin, long xmax, long ymin, long ymax)

sswf::SRectangle::SetReorder(long xmin, long xmax, long ymin, long ymax)

SWF Alexis' Reference—swf_rect


Constructor & Destructor Documentation

SRectangle::SRectangle ( void   ) 

By default a rectangle is an empty rectangle with all of its coordinates set to zero.

See also:
sswf::SRectangle::Reset(void)

References Reset().


Member Function Documentation

bool SRectangle::IsEmpty ( void   )  const

This function returns true if the rectangle is considered empty.

Some rectangles in SWF cannot be empty (especially the display screen!)

A rectangle is considered empty when xmin >= xmax or ymin >= ymax.

Returns:
true if the rectangle is empty
See also:
sswf::SRectangle::Reset(void)

References f_xmax, f_xmin, f_ymax, and f_ymin.

Referenced by sswf::TagScalingGrid::GridPreSave(), sswf::TagScalingGrid::GridSave(), sswf::TagShape::HasAlignZone(), and sswf::TagShape::HasBounds().

ErrorManager::error_code_t SRectangle::Parse ( const Data data  ) 

This function parses a rectangle from a data buffer.

Parameters:
[in] data The data buffer where the rectangle is read.
Returns:
An error number or ERROR_CODE_NONE.

References sswf::ErrorManager::ERROR_CODE_NONE, f_xmax, f_xmin, f_ymax, f_ymin, sswf::Data::GetBits(), and sswf::Data::ReadAlign().

Referenced by sswf::TagScalingGrid::ParseGridTag(), and sswf::TagEditText::ParseTag().

void SRectangle::Reset ( void   ) 

This function resets the rectangle to all zeroes. In effect, the rectangle becomes the empty rectangle.

See also:
sswf::SRectangle::SRectangle(void)

References f_xmax, f_xmin, f_ymax, and f_ymin.

Referenced by SRectangle().

void SRectangle::Save ( Data data  )  const

This function saves a rectangle in a data buffer as compressed as possible.

The function first determines the necessary number of bits to save all the coordinates, and then it saves them in the specified data buffer.

An empty rectangle is saved on 2 bytes.

Parameters:
[in] data The data buffer where the rectangle is saved.

References f_xmax, f_xmin, f_ymax, f_ymin, sswf::TagBase::SIBitSize(), and sswf::Data::WriteBits().

Referenced by sswf::TagScalingGrid::GridSave(), sswf::TagText::Save(), sswf::TagShape::Save(), sswf::TagHeader::Save(), sswf::TagFont::Save(), and sswf::TagEditText::Save().

void SRectangle::Set ( long  xmin,
long  xmax,
long  ymin,
long  ymax 
)

Sets the coordinates of the rectangle to the specified coordinates. If xmin >= xmax or ymin >= ymax then the rectangle is considered empty. You can also call the sswf::SRectangle::Reset() function to make the rectangle empty.

See also:
sswf::SRectangle::Reset(void)

sswf::SRectangle::SetReorder(long xmin, long xmax, long ymin, long ymax)

References f_xmax, f_xmin, f_ymax, and f_ymin.

Referenced by sswf::TagShape::ParseAlignZone(), sswf::TagShape::Save(), and sswf::TagHeader::TagHeader().

void SRectangle::SetReorder ( long  xmin,
long  xmax,
long  ymin,
long  ymax 
)

This function sets the coordinates of the rectangle. It will reorder the min/max is the right order. So if xmin > xmax, the horizontal coordinates are swapped. And if ymin > ymax, the vertical coodinates are swapped.

To create an empty rectangle, you need to set xmin equal to xmax or ymin equal to ymax or call the sswf::SRectangle::Reset() function.

See also:
sswf::SRectangle::Reset(void)

sswf::SRectangle::Set(long xmin, long xmax, long ymin, long ymax)

References f_xmax, f_xmin, f_ymax, and f_ymin.

Referenced by sswf::TagShape::Save(), and sswf::TagHeader::SetFrame().

long SRectangle::XMax ( void   )  const

This function returns the maximum X coordinate.

Returns:
The xmax coordinate
See also:
sswf::SRectangle::XMin(void) const

References f_xmax.

Referenced by sswf::TagShape::Save(), sswf::TagShape::SaveAlignZone(), and sswf::TagHeader::SetFrame().

long SRectangle::XMin ( void   )  const

This function returns the minimum X coordinate.

Returns:
The xmin coordinate
See also:
sswf::SRectangle::XMax(void) const

References f_xmin.

Referenced by sswf::TagShape::Save(), sswf::TagShape::SaveAlignZone(), and sswf::TagHeader::SetFrame().

long SRectangle::YMax ( void   )  const

This function returns the maximum Y coordinate.

Returns:
The ymax coordinate
See also:
sswf::SRectangle::YMin(void) const

References f_ymax.

Referenced by sswf::TagShape::Save(), sswf::TagShape::SaveAlignZone(), and sswf::TagHeader::SetFrame().

long SRectangle::YMin ( void   )  const

This function returns the minimum Y coordinate.

Returns:
The ymin coordinate
See also:
sswf::SRectangle::YMax(void) const

References f_ymin.

Referenced by sswf::TagShape::Save(), sswf::TagShape::SaveAlignZone(), and sswf::TagHeader::SetFrame().


Member Data Documentation


The documentation for this class was generated from the following files:


Generated on Wed Mar 18 15:13:58 2009 for libsswf by  doxygen 1.5.5