#include <libsswf.h>
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 |
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().
sswf::SRectangle::Set(long xmin, long xmax, long ymin, long ymax)
sswf::SRectangle::SetReorder(long xmin, long xmax, long ymin, long ymax)
SRectangle::SRectangle | ( | void | ) |
By default a rectangle is an empty rectangle with all of its coordinates set to zero.
References Reset().
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.
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.
[in] | data | The data buffer where the rectangle is read. |
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.
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.
[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.
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.
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.
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.
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.
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.
References f_ymin.
Referenced by sswf::TagShape::Save(), sswf::TagShape::SaveAlignZone(), and sswf::TagHeader::SetFrame().
long sswf::SRectangle::f_xmax [private] |
long sswf::SRectangle::f_xmin [private] |
long sswf::SRectangle::f_ymax [private] |
long sswf::SRectangle::f_ymin [private] |