FSize Class Reference
The FSize class defines the size of a two-dimensional object. More...
#include <fsize.h>
Public Types | |
| enum | ScaleMode { ScaleFree, ScaleMin, ScaleMax } |
Public Member Functions | |
| FSize () | |
| FSize (double w, double h) | |
| bool | isNull () const |
| bool | isEmpty () const |
| bool | isValid () const |
| double | width () const |
| double | height () const |
| void | setWidth (double w) |
| void | setHeight (double h) |
| void | transpose () |
| void | scale (double w, double h, Qt::AspectRatioMode mode) |
| void | scale (const FSize &s, Qt::AspectRatioMode mode) |
| FSize | expandedTo (const FSize &) const |
| FSize | boundedTo (const FSize &) const |
| double & | rwidth () |
| double & | rheight () |
| FSize & | operator+= (const FSize &) |
| FSize & | operator-= (const FSize &) |
| FSize & | operator *= (int c) |
| FSize & | operator *= (double c) |
| FSize & | operator/= (int c) |
| FSize & | operator/= (double c) |
Static Private Member Functions | |
| static void | warningDivByZero () |
Private Attributes | |
| double | wd |
| double | ht |
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 &, double) |
| const FSize | operator * (double, const FSize &) |
| const FSize | operator/ (const FSize &, int) |
| const FSize | operator/ (const FSize &, double) |
Related Functions | |
| (Note that these are not member functions.) | |
| const FSize | operator |
| const FSize | operator |
| const FSize | operator |
Detailed Description
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 double (defined in <qwindowdefs.h> as double). The minimum value of double is double_MIN (-2147483648) and the maximum value is double_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().
- See also:
- QPoint, QRect
Definition at line 45 of file fsize.h.
Member Enumeration Documentation
| 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.
- See also:
- FSize::scale(), QImage::scale(), QImage::smoothScale()
Constructor & Destructor Documentation
| FSize::FSize | ( | ) | [inline] |
Constructs a size with invalid (negative) width and height.
Definition at line 116 of file fsize.h.
Referenced by boundedTo(), expandedTo(), operator *(), operator+(), operator-(), and operator/().
| FSize::FSize | ( | double | w, | |
| double | h | |||
| ) | [inline] |
Member Function Documentation
| bool FSize::isNull | ( | ) | const [inline] |
| bool FSize::isEmpty | ( | ) | const [inline] |
| bool FSize::isValid | ( | ) | const [inline] |
| double FSize::width | ( | ) | const [inline] |
Returns the width.
- See also:
- height()
Definition at line 131 of file fsize.h.
References wd.
Referenced by FRect::FRect(), scale(), and FRect::setSize().
| double FSize::height | ( | ) | const [inline] |
Returns the height.
- See also:
- width()
Definition at line 134 of file fsize.h.
References ht.
Referenced by FRect::FRect(), scale(), and FRect::setSize().
| void FSize::setWidth | ( | double | w | ) | [inline] |
Sets the width to w.
- See also:
- width(), setHeight()
Definition at line 137 of file fsize.h.
References wd.
| void FSize::setHeight | ( | double | h | ) | [inline] |
Sets the height to h.
- See also:
- height(), setWidth()
Definition at line 140 of file fsize.h.
References ht.
| void FSize::transpose | ( | ) |
| void FSize::scale | ( | double | w, | |
| double | 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:
FSize t1( 10, 12 ); t1.scale( 60, 60, FSize::ScaleFree ); // t1 is (60, 60) FSize t2( 10, 12 ); t2.scale( 60, 60, FSize::ScaleMin ); // t2 is (50, 60) FSize t3( 10, 12 ); t3.scale( 60, 60, FSize::ScaleMax ); // t3 is (60, 72)
Definition at line 176 of file fsize.cpp.
References height(), ht, wd, and width().
Referenced by scale().
| void FSize::scale | ( | const FSize & | s, | |
| Qt::AspectRatioMode | mode | |||
| ) |
| double & FSize::rwidth | ( | ) | [inline] |
| double & FSize::rheight | ( | ) | [inline] |
| FSize & FSize::operator *= | ( | int | c | ) | [inline] |
| FSize & FSize::operator *= | ( | double | c | ) | [inline] |
| FSize & FSize::operator/= | ( | int | c | ) | [inline] |
| FSize & FSize::operator/= | ( | double | c | ) | [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.
Definition at line 195 of file fsize.h.
References ht, warningDivByZero(), and wd.
| void FSize::warningDivByZero | ( | ) | [static, private] |
Friends And Related Function Documentation
const FSize operator [related] |
Multiplies s by c and returns the result.
const FSize operator [related] |
Multiplies s by c and returns the result.
const FSize operator [related] |
Multiplies s by c and returns the result.
Member Data Documentation
double FSize::wd [private] |
Definition at line 99 of file fsize.h.
Referenced by boundedTo(), expandedTo(), FSize(), isEmpty(), isNull(), isValid(), operator *(), operator *=(), operator!=(), operator+(), operator+=(), operator-(), operator-=(), operator/(), operator/=(), operator==(), rwidth(), scale(), setWidth(), transpose(), and width().
double FSize::ht [private] |
Definition at line 100 of file fsize.h.
Referenced by boundedTo(), expandedTo(), FSize(), height(), isEmpty(), isNull(), isValid(), operator *(), operator *=(), operator!=(), operator+(), operator+=(), operator-(), operator-=(), operator/(), operator/=(), operator==(), rheight(), scale(), setHeight(), and transpose().
The documentation for this class was generated from the following files:
