src/gui/kernel/qgridlayout.cpp File Reference

#include "qgridlayout.h"
#include "qapplication.h"
#include "qwidget.h"
#include "qlist.h"
#include "qsizepolicy.h"
#include "qvector.h"
#include "qlayoutengine_p.h"
#include "qlayout_p.h"

Include dependency graph for qgridlayout.cpp:

Go to the source code of this file.

Classes

class  QGridBox
class  QGridLayoutPrivate

Functions

static void distributeMultiBox (QVector< QLayoutStruct > &chain, int spacing, int start, int end, int minSize, int sizeHint, QVector< int > &stretchArray, int stretch)
static bool checkWidget (QLayout *l, QWidget *w)


Function Documentation

static bool checkWidget ( QLayout l,
QWidget w 
) [static]

Definition at line 1167 of file qgridlayout.cpp.

References l, qWarning(), and w.

01168 {
01169     if (!w) {
01170         qWarning("QLayout: Cannot add null widget to %s/%s", l->metaObject()->className(),
01171                   l->objectName().toLocal8Bit().data());
01172         return false;
01173     }
01174     return true;
01175 }

Here is the call graph for this function:

static void distributeMultiBox ( QVector< QLayoutStruct > &  chain,
int  spacing,
int  start,
int  end,
int  minSize,
int  sizeHint,
QVector< int > &  stretchArray,
int  stretch 
) [static]

Definition at line 485 of file qgridlayout.cpp.

References QVector< T >::empty(), i, qGeomCalc(), qMax(), QWIDGETSIZE_MAX, size, and w.

Referenced by QGridLayoutPrivate::setupHfwLayoutData(), and QGridLayoutPrivate::setupLayoutData().

00487 {
00488     int i;
00489     int w = 0;
00490     int wh = 0;
00491     int max = 0;
00492     for (i = start; i <= end; i++) {
00493         w += chain[i].minimumSize;
00494         wh += chain[i].sizeHint;
00495         if (chain[i].empty)
00496             chain[i].maximumSize = QWIDGETSIZE_MAX;
00497         max += chain[i].maximumSize;
00498         chain[i].empty = false;
00499         if (stretchArray[i] == 0)
00500             chain[i].stretch = qMax(chain[i].stretch,stretch);
00501     }
00502     w += spacing * (end - start);
00503     wh += spacing * (end - start);
00504     max += spacing * (end - start);
00505 
00506     if (max < minSize) { // implies w < minSize
00507         /*
00508           We must increase the maximum size of at least one of the
00509           items. qGeomCalc() will put the extra space in between the
00510           items. We must recover that extra space and put it
00511           somewhere. It does not really matter where, since the user
00512           can always specify stretch factors and avoid this code.
00513         */
00514         qGeomCalc(chain, start, end - start + 1, 0, minSize, spacing);
00515         int pos = 0;
00516         for (i = start; i <= end; i++) {
00517             int nextPos = (i == end) ? minSize - 1 : chain[i + 1].pos;
00518             int realSize = nextPos - pos;
00519             if (i != end)
00520                 realSize -= spacing;
00521             if (chain[i].minimumSize < realSize)
00522                 chain[i].minimumSize = realSize;
00523             if (chain[i].maximumSize < chain[i].minimumSize)
00524                 chain[i].maximumSize = chain[i].minimumSize;
00525             pos = nextPos;
00526         }
00527     } else if (w < minSize) {
00528         qGeomCalc(chain, start, end - start + 1, 0, minSize, spacing);
00529         for (i = start; i <= end; i++) {
00530             if (chain[i].minimumSize < chain[i].size)
00531                 chain[i].minimumSize = chain[i].size;
00532         }
00533     }
00534 
00535     if (wh < sizeHint) {
00536         qGeomCalc(chain, start, end - start + 1, 0, sizeHint, spacing);
00537         for (i = start; i <= end; i++) {
00538             if (chain[i].sizeHint < chain[i].size)
00539                 chain[i].sizeHint = chain[i].size;
00540         }
00541     }
00542 }

Here is the call graph for this function:


Generated on Thu Mar 15 13:26:54 2007 for Qt 4.2 User's Guide by  doxygen 1.5.1