Eneboo - Documentación para desarrolladores
src/qt/include/qsize.h
Ir a la documentación de este archivo.
00001 /****************************************************************************
00002 ** $Id: qt/qsize.h   3.3.8   edited Jan 11 14:38 $
00003 **
00004 ** Definition of QSize class
00005 **
00006 ** Created : 931028
00007 **
00008 ** Copyright (C) 1992-2007 Trolltech ASA.  All rights reserved.
00009 **
00010 ** This file is part of the kernel module of the Qt GUI Toolkit.
00011 **
00012 ** This file may be distributed under the terms of the Q Public License
00013 ** as defined by Trolltech ASA of Norway and appearing in the file
00014 ** LICENSE.QPL included in the packaging of this file.
00015 **
00016 ** This file may be distributed and/or modified under the terms of the
00017 ** GNU General Public License version 2 as published by the Free Software
00018 ** Foundation and appearing in the file LICENSE.GPL included in the
00019 ** packaging of this file.
00020 **
00021 ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
00022 ** licenses may use this file in accordance with the Qt Commercial License
00023 ** Agreement provided with the Software.
00024 **
00025 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00026 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00027 **
00028 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
00029 **   information about Qt Commercial License Agreements.
00030 ** See http://www.trolltech.com/qpl/ for QPL licensing information.
00031 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
00032 **
00033 ** Contact info@trolltech.com if any conditions of this licensing are
00034 ** not clear to you.
00035 **
00036 **********************************************************************/
00037 
00038 #ifndef QSIZE_H
00039 #define QSIZE_H
00040 
00041 #ifndef QT_H
00042 #include "qpoint.h" // ### change to qwindowdefs.h?
00043 #endif // QT_H
00044 
00045 class Q_EXPORT QSize
00046 // ### Make QSize inherit Qt in Qt 4.0
00047 {
00048 public:
00049     // ### Move this enum to qnamespace.h in Qt 4.0
00050     enum ScaleMode {
00051         ScaleFree,
00052         ScaleMin,
00053         ScaleMax
00054     };
00055 
00056     QSize();
00057     QSize( int w, int h );
00058 
00059     bool isNull() const;
00060     bool isEmpty() const;
00061     bool isValid() const;
00062 
00063     int width() const;
00064     int height() const;
00065     void setWidth( int w );
00066     void setHeight( int h );
00067     void transpose();
00068 
00069     void scale( int w, int h, ScaleMode mode );
00070     void scale( const QSize &s, ScaleMode mode );
00071 
00072     QSize expandedTo( const QSize & ) const;
00073     QSize boundedTo( const QSize & ) const;
00074 
00075     QCOORD &rwidth();
00076     QCOORD &rheight();
00077 
00078     QSize &operator+=( const QSize & );
00079     QSize &operator-=( const QSize & );
00080     QSize &operator*=( int c );
00081     QSize &operator*=( double c );
00082     QSize &operator/=( int c );
00083     QSize &operator/=( double c );
00084 
00085     friend inline bool operator==( const QSize &, const QSize & );
00086     friend inline bool operator!=( const QSize &, const QSize & );
00087     friend inline const QSize operator+( const QSize &, const QSize & );
00088     friend inline const QSize operator-( const QSize &, const QSize & );
00089     friend inline const QSize operator*( const QSize &, int );
00090     friend inline const QSize operator*( int, const QSize & );
00091     friend inline const QSize operator*( const QSize &, double );
00092     friend inline const QSize operator*( double, const QSize & );
00093     friend inline const QSize operator/( const QSize &, int );
00094     friend inline const QSize operator/( const QSize &, double );
00095 
00096 private:
00097     static void warningDivByZero();
00098 
00099     QCOORD wd;
00100     QCOORD ht;
00101 };
00102 
00103 
00104 /*****************************************************************************
00105   QSize stream functions
00106  *****************************************************************************/
00107 
00108 Q_EXPORT QDataStream &operator<<( QDataStream &, const QSize & );
00109 Q_EXPORT QDataStream &operator>>( QDataStream &, QSize & );
00110 
00111 
00112 /*****************************************************************************
00113   QSize inline functions
00114  *****************************************************************************/
00115 
00116 inline QSize::QSize()
00117 { wd = ht = -1; }
00118 
00119 inline QSize::QSize( int w, int h )
00120 { wd=(QCOORD)w; ht=(QCOORD)h; }
00121 
00122 inline bool QSize::isNull() const
00123 { return wd==0 && ht==0; }
00124 
00125 inline bool QSize::isEmpty() const
00126 { return wd<1 || ht<1; }
00127 
00128 inline bool QSize::isValid() const
00129 { return wd>=0 && ht>=0; }
00130 
00131 inline int QSize::width() const
00132 { return wd; }
00133 
00134 inline int QSize::height() const
00135 { return ht; }
00136 
00137 inline void QSize::setWidth( int w )
00138 { wd=(QCOORD)w; }
00139 
00140 inline void QSize::setHeight( int h )
00141 { ht=(QCOORD)h; }
00142 
00143 inline QCOORD &QSize::rwidth()
00144 { return wd; }
00145 
00146 inline QCOORD &QSize::rheight()
00147 { return ht; }
00148 
00149 inline QSize &QSize::operator+=( const QSize &s )
00150 { wd+=s.wd; ht+=s.ht; return *this; }
00151 
00152 inline QSize &QSize::operator-=( const QSize &s )
00153 { wd-=s.wd; ht-=s.ht; return *this; }
00154 
00155 inline QSize &QSize::operator*=( int c )
00156 { wd*=(QCOORD)c; ht*=(QCOORD)c; return *this; }
00157 
00158 inline QSize &QSize::operator*=( double c )
00159 { wd=(QCOORD)(wd*c); ht=(QCOORD)(ht*c); return *this; }
00160 
00161 inline bool operator==( const QSize &s1, const QSize &s2 )
00162 { return s1.wd == s2.wd && s1.ht == s2.ht; }
00163 
00164 inline bool operator!=( const QSize &s1, const QSize &s2 )
00165 { return s1.wd != s2.wd || s1.ht != s2.ht; }
00166 
00167 inline const QSize operator+( const QSize & s1, const QSize & s2 )
00168 { return QSize(s1.wd+s2.wd, s1.ht+s2.ht); }
00169 
00170 inline const QSize operator-( const QSize &s1, const QSize &s2 )
00171 { return QSize(s1.wd-s2.wd, s1.ht-s2.ht); }
00172 
00173 inline const QSize operator*( const QSize &s, int c )
00174 { return QSize(s.wd*c, s.ht*c); }
00175 
00176 inline const QSize operator*( int c, const QSize &s )
00177 {  return QSize(s.wd*c, s.ht*c); }
00178 
00179 inline const QSize operator*( const QSize &s, double c )
00180 { return QSize((QCOORD)(s.wd*c), (QCOORD)(s.ht*c)); }
00181 
00182 inline const QSize operator*( double c, const QSize &s )
00183 { return QSize((QCOORD)(s.wd*c), (QCOORD)(s.ht*c)); }
00184 
00185 inline QSize &QSize::operator/=( int c )
00186 {
00187 #if defined(QT_CHECK_MATH)
00188     if ( c == 0 )
00189         warningDivByZero();
00190 #endif
00191     wd/=(QCOORD)c; ht/=(QCOORD)c;
00192     return *this;
00193 }
00194 
00195 inline QSize &QSize::operator/=( double c )
00196 {
00197 #if defined(QT_CHECK_MATH)
00198     if ( c == 0.0 )
00199         warningDivByZero();
00200 #endif
00201     wd=(QCOORD)(wd/c); ht=(QCOORD)(ht/c);
00202     return *this;
00203 }
00204 
00205 inline const QSize operator/( const QSize &s, int c )
00206 {
00207 #if defined(QT_CHECK_MATH)
00208     if ( c == 0 )
00209         QSize::warningDivByZero();
00210 #endif
00211     return QSize(s.wd/c, s.ht/c);
00212 }
00213 
00214 inline const QSize operator/( const QSize &s, double c )
00215 {
00216 #if defined(QT_CHECK_MATH)
00217     if ( c == 0.0 )
00218         QSize::warningDivByZero();
00219 #endif
00220     return QSize((QCOORD)(s.wd/c), (QCOORD)(s.ht/c));
00221 }
00222 
00223 inline QSize QSize::expandedTo( const QSize & otherSize ) const
00224 {
00225     return QSize( QMAX(wd,otherSize.wd), QMAX(ht,otherSize.ht) );
00226 }
00227 
00228 inline QSize QSize::boundedTo( const QSize & otherSize ) const
00229 {
00230     return QSize( QMIN(wd,otherSize.wd), QMIN(ht,otherSize.ht) );
00231 }
00232 
00233 
00234 #endif // QSIZE_H
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'