Scribus Developer Documentation - API
logo-pen

Scribus Developer Documentation - API

FSize Class Reference

The FSize class defines the size of a two-dimensional object. More...

#include <fsize.h>

List of all members.

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 ()
FSizeoperator+= (const FSize &)
FSizeoperator-= (const FSize &)
FSizeoperator *= (int c)
FSizeoperator *= (double c)
FSizeoperator/= (int c)
FSizeoperator/= (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

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()
Enumerator:
ScaleFree 
ScaleMin 
ScaleMax 

Definition at line 50 of file fsize.h.


Constructor & Destructor Documentation

FSize::FSize (  )  [inline]

Constructs a size with invalid (negative) width and height.

Definition at line 116 of file fsize.h.

References ht, and wd.

Referenced by boundedTo(), expandedTo(), operator *(), operator+(), operator-(), and operator/().

FSize::FSize ( double  w,
double  h 
) [inline]

Constructs a size with width w and height h.

Definition at line 119 of file fsize.h.

References ht, and wd.


Member Function Documentation

bool FSize::isNull (  )  const [inline]

Returns TRUE if the width is 0 and the height is 0; otherwise returns FALSE.

Definition at line 122 of file fsize.h.

References ht, and wd.

bool FSize::isEmpty (  )  const [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.

Definition at line 125 of file fsize.h.

References ht, and wd.

bool FSize::isValid (  )  const [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.

Definition at line 128 of file fsize.h.

References ht, and wd.

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 (  ) 

Swaps the values of width and height.

Definition at line 127 of file fsize.cpp.

References ht, and wd.

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 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Equivalent to scale({s}.width(), {s}.height(), mode).

Definition at line 208 of file fsize.cpp.

References height(), scale(), and width().

FSize FSize::expandedTo ( const FSize otherSize  )  const [inline]

Returns a size with the maximum width and height of this size and otherSize.

Definition at line 223 of file fsize.h.

References FSize(), ht, and wd.

FSize FSize::boundedTo ( const FSize otherSize  )  const [inline]

Returns a size with the minimum width and height of this size and otherSize.

Definition at line 228 of file fsize.h.

References FSize(), ht, and wd.

double & FSize::rwidth (  )  [inline]

Returns a reference to the width.

Using a reference makes it possible to directly manipulate the width.

Example:

    FSize s( 100, 10 );
    s.rwidth() += 20;       // s becomes (120,10)

See also:
rheight()

Definition at line 143 of file fsize.h.

References wd.

double & FSize::rheight (  )  [inline]

Returns a reference to the height.

Using a reference makes it possible to directly manipulate the height.

Example:

    FSize s( 100, 10 );
    s.rheight() += 5;       // s becomes (100,15)

See also:
rwidth()

Definition at line 146 of file fsize.h.

References ht.

FSize & FSize::operator+= ( const FSize s  )  [inline]

Adds s to the size and returns a reference to this size.

Example:

    FSize s(  3, 7 );
    FSize r( -1, 4 );
    s += r;         // s becomes (2,11)

Definition at line 149 of file fsize.h.

References ht, and wd.

FSize & FSize::operator-= ( const FSize s  )  [inline]

Subtracts s from the size and returns a reference to this size.

Example:

    FSize s(  3, 7 );
    FSize r( -1, 4 );
    s -= r;         // s becomes (4,3)

Definition at line 152 of file fsize.h.

References ht, and wd.

FSize & FSize::operator *= ( int  c  )  [inline]

Definition at line 155 of file fsize.h.

References ht, and wd.

FSize & FSize::operator *= ( double  c  )  [inline]

Multiplies both the width and height by c and returns a reference to the size.

Definition at line 158 of file fsize.h.

References ht, and wd.

FSize & FSize::operator/= ( int  c  )  [inline]

Definition at line 185 of file fsize.h.

References ht, warningDivByZero(), and wd.

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]

Definition at line 378 of file fsize.cpp.

Referenced by operator/(), and operator/=().


Friends And Related Function Documentation

bool operator== ( const FSize s1,
const FSize s2 
) [friend]

Returns TRUE if s1 and s2 are equal; otherwise returns FALSE.

Definition at line 161 of file fsize.h.

bool operator!= ( const FSize s1,
const FSize s2 
) [friend]

Returns TRUE if s1 and s2 are different; otherwise returns FALSE.

Definition at line 164 of file fsize.h.

const FSize operator+ ( const FSize s1,
const FSize s2 
) [friend]

Returns the sum of s1 and s2; each component is added separately.

Definition at line 167 of file fsize.h.

const FSize operator- ( const FSize s1,
const FSize s2 
) [friend]

Returns s2 subtracted from s1; each component is subtracted separately.

Definition at line 170 of file fsize.h.

const FSize operator * ( const FSize s,
int  c 
) [friend]

Definition at line 173 of file fsize.h.

const FSize operator * ( int  c,
const FSize s 
) [friend]

Definition at line 176 of file fsize.h.

const FSize operator * ( const FSize s,
double  c 
) [friend]

Multiplies s by c and returns the result.

Definition at line 179 of file fsize.h.

const FSize operator * ( double  c,
const FSize s 
) [friend]

Definition at line 182 of file fsize.h.

const FSize operator/ ( const FSize s,
int  c 
) [friend]

Definition at line 205 of file fsize.h.

const FSize operator/ ( const FSize s,
double  c 
) [friend]

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.

Definition at line 214 of file fsize.h.

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]

double FSize::ht [private]


The documentation for this class was generated from the following files:
Created with personalized Doxygen. This is documentation for GPL software Scribus - Open Source Desktop Publishing.