![]() |
Scribus
Open source desktop publishing at your fingertips
|
The FSize class defines the size of a two-dimensional object. More...
Public Types | |
enum | ScaleMode { ScaleFree, ScaleMin, ScaleMax } |
Public Member Functions | |
FSize () | |
FSize (qreal w, qreal h) | |
bool | isNull () const |
bool | isEmpty () const |
bool | isValid () const |
qreal | width () const |
qreal | height () const |
void | setWidth (qreal w) |
void | setHeight (qreal h) |
void | transpose () |
void | scale (qreal w, qreal h, Qt::AspectRatioMode mode) |
void | scale (const FSize &s, Qt::AspectRatioMode mode) |
FSize | expandedTo (const FSize &) const |
FSize | boundedTo (const FSize &) const |
qreal & | rwidth () |
qreal & | rheight () |
FSize & | operator+= (const FSize &) |
FSize & | operator-= (const FSize &) |
FSize & | operator*= (int c) |
FSize & | operator*= (qreal c) |
FSize & | operator/= (int c) |
FSize & | operator/= (qreal c) |
Friends | |
bool | operator== (const FSize &, const FSize &) |
bool | operator!= (const FSize &, const FSize &) |
const FSize | operator+ (const FSize &, const FSize &) |
const FSize | operator- (const FSize &, const FSize &) |
const FSize | operator* (const FSize &, int) |
const FSize | operator* (int, const FSize &) |
const FSize | operator* (const FSize &, qreal) |
const FSize | operator* (qreal, const FSize &) |
const FSize | operator/ (const FSize &, int) |
const FSize | operator/ (const FSize &, qreal) |
Related Functions | |
(Note that these are not member functions.) | |
const FSize | operator |
const FSize | operator |
const FSize | operator |
The FSize class defines the size of a two-dimensional object.
A size is specified by a width and a height.
The coordinate type is qreal (defined in <qwindowdefs.h>
as qreal
). The minimum value of qreal is qreal_MIN (-2147483648) and the maximum value is qreal_MAX (2147483647).
The size can be set in the constructor and changed with setWidth() and setHeight(), or using operator+=(), operator-=(), operator*=() and operator/=(), etc. You can swap the width and height with transpose(). You can get a size which holds the maximum height and width of two sizes using expandedTo(), and the minimum height and width of two sizes using boundedTo().
enum FSize::ScaleMode |
This enum type defines the different ways of scaling a size.
scaling.png
ScaleFree The size is scaled freely. The ratio is not preserved. ScaleMin The size is scaled to a rectangle as large as possible inside a given rectangle, preserving the aspect ratio. ScaleMax The size is scaled to a rectangle as small as possible outside a given rectangle, preserving the aspect ratio.
|
inline |
Constructs a size with invalid (negative) width and height.
|
inline |
Constructs a size with width w and height h.
Returns a size with the minimum width and height of this size and otherSize.
Returns a size with the maximum width and height of this size and otherSize.
|
inline |
Returns the height.
|
inline |
Returns TRUE if the width is less than or equal to 0, or the height is less than or equal to 0; otherwise returns FALSE.
|
inline |
Returns TRUE if the width is 0 and the height is 0; otherwise returns FALSE.
|
inline |
Returns TRUE if the width is equal to or greater than 0 and the height is equal to or greater than 0; otherwise returns FALSE.
|
inline |
Multiplies both the width and height by c and returns a reference to the size.
|
inline |
|
inline |
|
inline |
Divides both the width and height by c and returns a reference to the size.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Divides both the width and height by c and returns a reference to the size.
Note that the result is truncated.
|
inline |
|
inline |
void FSize::scale | ( | qreal | w, |
qreal | h, | ||
Qt::AspectRatioMode | mode | ||
) |
Scales the size to a rectangle of width w and height h according to the ScaleMode mode.
If mode is ScaleFree
, the size is set to (w, h). If mode is ScaleMin
, the current size is scaled to a rectangle as large as possible inside (w, h), preserving the aspect ratio. If mode is ScaleMax
, the current size is scaled to a rectangle as small as possible outside (w, h), preserving the aspect ratio.
Example:
void FSize::scale | ( | const FSize & | s, |
Qt::AspectRatioMode | mode | ||
) |
|
inline |
Sets the height to h.
|
inline |
Sets the width to w.
void FSize::transpose | ( | ) |
Swaps the values of width and height.
|
inline |
Returns the width.
|
related |
Multiplies s by c and returns the result.
|
related |
Multiplies s by c and returns the result.
|
related |
Multiplies s by c and returns the result.
Returns TRUE if s1 and s2 are different; otherwise returns FALSE.
Returns the sum of s1 and s2; each component is added separately.
Returns s2 subtracted from s1; each component is subtracted separately.
Divides s by c and returns the result.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Divides s by c and returns the result.
Note that the result is truncated.
Returns TRUE if s1 and s2 are equal; otherwise returns FALSE.