Eneboo - Documentación para desarrolladores
src/qt/include/qsizepolicy.h
Ir a la documentación de este archivo.
00001 /****************************************************************************
00002 ** $Id: qt/qsizepolicy.h   3.3.8   edited Jan 11 14:46 $
00003 **
00004 ** Definition of the QSizePolicy class
00005 **
00006 ** Created : 980929
00007 **
00008 ** Copyright (C) 1998-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 QSIZEPOLICY_H
00039 #define QSIZEPOLICY_H
00040 
00041 #ifndef QT_H
00042 #include "qglobal.h"
00043 #endif // QT_H
00044 
00045 // Documentation is in qabstractlayout.cpp.
00046 
00047 class Q_EXPORT QSizePolicy
00048 {
00049 private:
00050     enum SizePolicy_Internal { HSize = 6, HMask = 0x3f, VMask = HMask << HSize,
00051                                MayGrow = 1, ExpMask = 2, MayShrink = 4 };
00052 public:
00053     enum SizeType { Fixed = 0,
00054                     Minimum = MayGrow,
00055                     Maximum = MayShrink,
00056                     Preferred = MayGrow | MayShrink,
00057                     MinimumExpanding = MayGrow | ExpMask,
00058                     Expanding = MayGrow | MayShrink | ExpMask,
00059                     Ignored = ExpMask /* magic value */ };
00060 
00061     enum ExpandData { NoDirection = 0,
00062                       Horizontally = 1,
00063                       Vertically = 2,
00064 #ifndef QT_NO_COMPAT
00065                       Horizontal = Horizontally,
00066                       Vertical = Vertically,
00067 #endif
00068                       BothDirections = Horizontally | Vertically };
00069 
00070     QSizePolicy() : data( 0 ) { }
00071 
00072     QSizePolicy( SizeType hor, SizeType ver, bool hfw = FALSE )
00073         : data( hor | (ver<<HSize) | (hfw ? (Q_UINT32)(1<<2*HSize) : 0) ) { }
00074     QSizePolicy( SizeType hor, SizeType ver, uchar hors, uchar vers, bool hfw = FALSE );
00075 
00076     SizeType horData() const { return (SizeType)( data & HMask ); }
00077     SizeType verData() const { return (SizeType)( (data & VMask) >> HSize ); }
00078 
00079     bool mayShrinkHorizontally() const { return horData() & MayShrink || horData() == Ignored; }
00080     bool mayShrinkVertically() const { return verData() & MayShrink || verData() == Ignored; }
00081     bool mayGrowHorizontally() const { return horData() & MayGrow || horData() == Ignored; }
00082     bool mayGrowVertically() const { return verData() & MayGrow || verData() == Ignored; }
00083 
00084     ExpandData expanding() const
00085     {
00086         return (ExpandData)( (int)(verData() & ExpMask ? Vertically : 0) |
00087                              (int)(horData() & ExpMask ? Horizontally : 0) );
00088     }
00089 
00090     void setHorData( SizeType d ) { data = (Q_UINT32)(data & ~HMask) | d; }
00091     void setVerData( SizeType d ) { data = (Q_UINT32)(data & ~(HMask << HSize)) |
00092                                            (d << HSize); }
00093 
00094     void setHeightForWidth( bool b ) { data = b ? (Q_UINT32)( data | ( 1 << 2*HSize ) )
00095                                               : (Q_UINT32)( data & ~( 1 << 2*HSize ) );  }
00096     bool hasHeightForWidth() const { return data & ( 1 << 2*HSize ); }
00097 
00098     bool operator==( const QSizePolicy& s ) const { return data == s.data; }
00099     bool operator!=( const QSizePolicy& s ) const { return data != s.data; }
00100 
00101 
00102     uint horStretch() const { return data >> 24; }
00103     uint verStretch() const { return (data >> 16) & 0xff; }
00104     void setHorStretch( uchar sf ) { data = (data&0x00ffffff) | (uint(sf)<<24); }
00105     void setVerStretch( uchar sf ) { data = (data&0xff00ffff) | (uint(sf)<<16); }
00106     inline void transpose();
00107 
00108 private:
00109     QSizePolicy( int i ) : data( (Q_UINT32)i ) { }
00110 
00111     Q_UINT32 data;
00112 };
00113 
00114 inline QSizePolicy::QSizePolicy( SizeType hor, SizeType ver, uchar hors, uchar vers, bool hfw )
00115     : data( hor | (ver<<HSize) | (hfw ? (Q_UINT32)(1<<2*HSize) : 0) ) {
00116     setHorStretch( hors );
00117     setVerStretch( vers );
00118 }
00119 
00120 inline void QSizePolicy::transpose() {
00121     *this = QSizePolicy( verData(), horData(), verStretch(), horStretch(),
00122                          hasHeightForWidth() );
00123 }
00124 
00125 #endif // QSIZEPOLICY_H
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'