Add (and install) svg for the new krunner interface.
[kdebase/uwolfer.git] / workspace / ksplash / ksplashx / qsize.h
blobea38bfc4537f8780abfecd88a9eb7233ef0e152d
1 /****************************************************************************
2 **
3 ** This file is based on sources of the Qt GUI Toolkit, used under the terms
4 ** of the GNU General Public License version 2 (see the original copyright
5 ** notice below).
6 ** All further contributions to this file are (and are required to be)
7 ** licensed under the terms of the GNU General Public License as published by
8 ** the Free Software Foundation; either version 2 of the License, or
9 ** (at your option) any later version.
11 ** The original Qt license header follows:
12 **
14 ** Definition of QSize class
16 ** Created : 931028
18 ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
20 ** This file is part of the kernel module of the Qt GUI Toolkit.
22 ** This file may be distributed under the terms of the Q Public License
23 ** as defined by Trolltech AS of Norway and appearing in the file
24 ** LICENSE.QPL included in the packaging of this file.
26 ** This file may be distributed and/or modified under the terms of the
27 ** GNU General Public License version 2 as published by the Free Software
28 ** Foundation and appearing in the file LICENSE.GPL included in the
29 ** packaging of this file.
31 ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
32 ** licenses may use this file in accordance with the Qt Commercial License
33 ** Agreement provided with the Software.
35 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
36 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
38 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
39 ** information about Qt Commercial License Agreements.
40 ** See http://www.trolltech.com/qpl/ for QPL licensing information.
41 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
43 ** Contact info@trolltech.com if any conditions of this licensing are
44 ** not clear to you.
46 **********************************************************************/
48 #ifndef QSIZE_H
49 #define QSIZE_H
51 #ifndef QT_H
52 #include "qpoint.h" // ### change to qwindowdefs.h?
53 #endif // QT_H
55 class Q_EXPORT QSize
56 // ### Make QSize inherit Qt in Qt 4.0
58 public:
59 // ### Move this enum to qnamespace.h in Qt 4.0
60 enum ScaleMode {
61 ScaleFree,
62 ScaleMin,
63 ScaleMax
66 QSize();
67 QSize( int w, int h );
69 bool isNull() const;
70 bool isEmpty() const;
71 bool isValid() const;
73 int width() const;
74 int height() const;
75 void setWidth( int w );
76 void setHeight( int h );
77 void transpose();
79 void scale( int w, int h, ScaleMode mode );
80 void scale( const QSize &s, ScaleMode mode );
82 QSize expandedTo( const QSize & ) const;
83 QSize boundedTo( const QSize & ) const;
85 QCOORD &rwidth();
86 QCOORD &rheight();
88 QSize &operator+=( const QSize & );
89 QSize &operator-=( const QSize & );
90 QSize &operator*=( int c );
91 QSize &operator*=( double c );
92 QSize &operator/=( int c );
93 QSize &operator/=( double c );
95 friend inline bool operator==( const QSize &, const QSize & );
96 friend inline bool operator!=( const QSize &, const QSize & );
97 friend inline const QSize operator+( const QSize &, const QSize & );
98 friend inline const QSize operator-( const QSize &, const QSize & );
99 friend inline const QSize operator*( const QSize &, int );
100 friend inline const QSize operator*( int, const QSize & );
101 friend inline const QSize operator*( const QSize &, double );
102 friend inline const QSize operator*( double, const QSize & );
103 friend inline const QSize operator/( const QSize &, int );
104 friend inline const QSize operator/( const QSize &, double );
106 private:
107 static void warningDivByZero();
109 QCOORD wd;
110 QCOORD ht;
114 /*****************************************************************************
115 QSize stream functions
116 *****************************************************************************/
118 #ifndef QT_NO_DATASTREAM
119 Q_EXPORT QDataStream &operator<<( QDataStream &, const QSize & );
120 Q_EXPORT QDataStream &operator>>( QDataStream &, QSize & );
121 #endif
123 /*****************************************************************************
124 QSize inline functions
125 *****************************************************************************/
127 inline QSize::QSize()
128 { wd = ht = -1; }
130 inline QSize::QSize( int w, int h )
131 { wd=(QCOORD)w; ht=(QCOORD)h; }
133 inline bool QSize::isNull() const
134 { return wd==0 && ht==0; }
136 inline bool QSize::isEmpty() const
137 { return wd<1 || ht<1; }
139 inline bool QSize::isValid() const
140 { return wd>=0 && ht>=0; }
142 inline int QSize::width() const
143 { return wd; }
145 inline int QSize::height() const
146 { return ht; }
148 inline void QSize::setWidth( int w )
149 { wd=(QCOORD)w; }
151 inline void QSize::setHeight( int h )
152 { ht=(QCOORD)h; }
154 inline QCOORD &QSize::rwidth()
155 { return wd; }
157 inline QCOORD &QSize::rheight()
158 { return ht; }
160 inline QSize &QSize::operator+=( const QSize &s )
161 { wd+=s.wd; ht+=s.ht; return *this; }
163 inline QSize &QSize::operator-=( const QSize &s )
164 { wd-=s.wd; ht-=s.ht; return *this; }
166 inline QSize &QSize::operator*=( int c )
167 { wd*=(QCOORD)c; ht*=(QCOORD)c; return *this; }
169 inline QSize &QSize::operator*=( double c )
170 { wd=(QCOORD)(wd*c); ht=(QCOORD)(ht*c); return *this; }
172 inline bool operator==( const QSize &s1, const QSize &s2 )
173 { return s1.wd == s2.wd && s1.ht == s2.ht; }
175 inline bool operator!=( const QSize &s1, const QSize &s2 )
176 { return s1.wd != s2.wd || s1.ht != s2.ht; }
178 inline const QSize operator+( const QSize & s1, const QSize & s2 )
179 { return QSize(s1.wd+s2.wd, s1.ht+s2.ht); }
181 inline const QSize operator-( const QSize &s1, const QSize &s2 )
182 { return QSize(s1.wd-s2.wd, s1.ht-s2.ht); }
184 inline const QSize operator*( const QSize &s, int c )
185 { return QSize(s.wd*c, s.ht*c); }
187 inline const QSize operator*( int c, const QSize &s )
188 { return QSize(s.wd*c, s.ht*c); }
190 inline const QSize operator*( const QSize &s, double c )
191 { return QSize((QCOORD)(s.wd*c), (QCOORD)(s.ht*c)); }
193 inline const QSize operator*( double c, const QSize &s )
194 { return QSize((QCOORD)(s.wd*c), (QCOORD)(s.ht*c)); }
196 inline QSize &QSize::operator/=( int c )
198 #if defined(QT_CHECK_MATH)
199 if ( c == 0 )
200 warningDivByZero();
201 #endif
202 wd/=(QCOORD)c; ht/=(QCOORD)c;
203 return *this;
206 inline QSize &QSize::operator/=( double c )
208 #if defined(QT_CHECK_MATH)
209 if ( c == 0.0 )
210 warningDivByZero();
211 #endif
212 wd=(QCOORD)(wd/c); ht=(QCOORD)(ht/c);
213 return *this;
216 inline const QSize operator/( const QSize &s, int c )
218 #if defined(QT_CHECK_MATH)
219 if ( c == 0 )
220 QSize::warningDivByZero();
221 #endif
222 return QSize(s.wd/c, s.ht/c);
225 inline const QSize operator/( const QSize &s, double c )
227 #if defined(QT_CHECK_MATH)
228 if ( c == 0.0 )
229 QSize::warningDivByZero();
230 #endif
231 return QSize((QCOORD)(s.wd/c), (QCOORD)(s.ht/c));
234 inline QSize QSize::expandedTo( const QSize & otherSize ) const
236 return QSize( qMax(wd,otherSize.wd), qMax(ht,otherSize.ht) );
239 inline QSize QSize::boundedTo( const QSize & otherSize ) const
241 return QSize( qMin(wd,otherSize.wd), qMin(ht,otherSize.ht) );
245 #endif // QSIZE_H