Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions

TQSize Class Reference

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

#include <tqsize.h>

List of all member functions.

Public Members

Related Functions


Detailed Description

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

A size is specified by a width and a height.

The coordinate type is TQCOORD (defined in <ntqwindowdefs.h> as int). The minimum value of TQCOORD is TQCOORD_MIN (-2147483648) and the maximum value is TQCOORD_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 TQPoint, TQRect, Graphics Classes, and Image Processing Classes.


Member Type Documentation

TQSize::ScaleMode

This enum type defines the different ways of scaling a size.

See also TQSize::scale(), TQImage::scale(), and TQImage::smoothScale().


Member Function Documentation

TQSize::TQSize ()

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

TQSize::TQSize ( int w, int h )

Constructs a size with width w and height h.

TQSize TQSize::boundedTo ( const TQSize & otherSize ) const

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

TQSize TQSize::expandedTo ( const TQSize & otherSize ) const

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

Examples: customlayout/card.cpp and customlayout/flow.cpp.

int TQSize::height () const

Returns the height.

See also width().

Examples: movies/main.cpp, qfd/fontdisplayer.cpp, and qfd/qfd.cpp.

bool TQSize::isEmpty () const

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.

bool TQSize::isNull () const

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

bool TQSize::isValid () const

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.

TQSize & TQSize::operator*= ( int c )

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

TQSize & TQSize::operator*= ( double c )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

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

Note that the result is truncated.

TQSize & TQSize::operator+= ( const TQSize & s )

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

Example:

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

TQSize & TQSize::operator-= ( const TQSize & s )

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

Example:

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

TQSize & TQSize::operator/= ( int c )

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

TQSize & TQSize::operator/= ( double c )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

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

Note that the result is truncated.

TQCOORD & TQSize::rheight ()

Returns a reference to the height.

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

Example:

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

See also rwidth().

TQCOORD & TQSize::rwidth ()

Returns a reference to the width.

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

Example:

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

See also rheight().

void TQSize::scale ( int w, int h, ScaleMode mode )

Scales the size to a rectangle of width w and height h according to the ScaleMode mode.

Example:

    TQSize t1( 10, 12 );
    t1.scale( 60, 60, TQSize::ScaleFree );
    // t1 is (60, 60)

    TQSize t2( 10, 12 );
    t2.scale( 60, 60, TQSize::ScaleMin );
    // t2 is (50, 60)

    TQSize t3( 10, 12 );
    t3.scale( 60, 60, TQSize::ScaleMax );
    // t3 is (60, 72)
    

void TQSize::scale ( const TQSize & s, ScaleMode mode )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Equivalent to scale(s.width(), s.height(), mode).

void TQSize::setHeight ( int h )

Sets the height to h.

See also height() and setWidth().

void TQSize::setWidth ( int w )

Sets the width to w.

See also width() and setHeight().

void TQSize::transpose ()

Swaps the values of width and height.

int TQSize::width () const

Returns the width.

See also height().

Examples: movies/main.cpp, qfd/fontdisplayer.cpp, and qfd/qfd.cpp.


Related Functions

bool operator!= ( const TQSize & s1, const TQSize & s2 )

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

const TQSize operator* ( const TQSize & s, int c )

Multiplies s by c and returns the result.

const TQSize operator* ( int c, const TQSize & s )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Multiplies s by c and returns the result.

const TQSize operator* ( const TQSize & s, double c )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Multiplies s by c and returns the result.

const TQSize operator* ( double c, const TQSize & s )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Multiplies s by c and returns the result.

const TQSize operator+ ( const TQSize & s1, const TQSize & s2 )

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

const TQSize operator- ( const TQSize & s1, const TQSize & s2 )

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

const TQSize operator/ ( const TQSize & s, int c )

Divides s by c and returns the result.

const TQSize operator/ ( const TQSize & s, double c )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Divides s by c and returns the result.

Note that the result is truncated.

TQDataStream & operator<< ( TQDataStream & s, const TQSize & sz )

Writes the size sz to the stream s and returns a reference to the stream.

See also Format of the TQDataStream operators.

bool operator== ( const TQSize & s1, const TQSize & s2 )

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

TQDataStream & operator>> ( TQDataStream & s, TQSize & sz )

Reads the size from the stream s into size sz and returns a reference to the stream.

See also Format of the TQDataStream operators.


This file is part of the TQt toolkit. Copyright © 1995-2007 Trolltech. All Rights Reserved.


Copyright © 2007 TrolltechTrademarks
TQt 3.3.8