~l3on/ubuntu/oneiric/qwt/fix-921430

« back to all changes in this revision

Viewing changes to qwt-5.0.2/src/qwt_dyngrid_layout.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Fathi Boudra
  • Date: 2007-10-05 15:20:41 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20071005152041-qmybqh4fj9jejyo2
Tags: 5.0.2-2
* Handle nostrip build option. (Closes: #437877)
* Build libqwt5-doc package in binary-indep target. (Closes: #443110)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
 
2
 * Qwt Widget Library
 
3
 * Copyright (C) 1997   Josef Wilgen
 
4
 * Copyright (C) 2002   Uwe Rathmann
 
5
 *
 
6
 * This library is free software; you can redistribute it and/or
 
7
 * modify it under the terms of the Qwt License, Version 1.0
 
8
 *****************************************************************************/
 
9
 
 
10
#include <qwidget.h>
 
11
#include "qwt_dyngrid_layout.h"
 
12
#include "qwt_math.h"
 
13
 
 
14
#if QT_VERSION < 0x040000
 
15
#include <qvaluelist.h>
 
16
#else
 
17
#include <qlist.h>
 
18
#endif
 
19
 
 
20
class QwtDynGridLayout::PrivateData
 
21
{
 
22
public:
 
23
 
 
24
#if QT_VERSION < 0x040000
 
25
    class LayoutIterator: public QGLayoutIterator
 
26
    {
 
27
    public:
 
28
        LayoutIterator(PrivateData *data):
 
29
            d_data(data)  
 
30
        {
 
31
            d_iterator = d_data->itemList.begin();
 
32
        }
 
33
 
 
34
        virtual QLayoutItem *current()
 
35
        { 
 
36
            if (d_iterator == d_data->itemList.end())
 
37
               return NULL;
 
38
 
 
39
            return *d_iterator;
 
40
        }
 
41
 
 
42
        virtual QLayoutItem *next()
 
43
        { 
 
44
            if (d_iterator == d_data->itemList.end())
 
45
               return NULL;
 
46
 
 
47
            d_iterator++;
 
48
            if (d_iterator == d_data->itemList.end())
 
49
               return NULL;
 
50
 
 
51
            return *d_iterator;
 
52
        }
 
53
 
 
54
        virtual QLayoutItem *takeCurrent()
 
55
        { 
 
56
            if ( d_iterator == d_data->itemList.end() )
 
57
                return NULL;
 
58
 
 
59
            QLayoutItem *item = *d_iterator;
 
60
 
 
61
            d_data->isDirty = true;
 
62
            d_iterator = d_data->itemList.remove(d_iterator);
 
63
            return item;
 
64
        }
 
65
 
 
66
    private:
 
67
        
 
68
        QValueListIterator<QLayoutItem*> d_iterator;
 
69
        QwtDynGridLayout::PrivateData *d_data;
 
70
    };
 
71
#endif
 
72
 
 
73
    PrivateData():
 
74
        isDirty(true)
 
75
    {
 
76
    }
 
77
 
 
78
#if QT_VERSION < 0x040000
 
79
    typedef QValueList<QLayoutItem*> LayoutItemList;
 
80
#else
 
81
    typedef QList<QLayoutItem*> LayoutItemList;
 
82
#endif
 
83
 
 
84
    mutable LayoutItemList itemList;
 
85
 
 
86
    uint maxCols;
 
87
    uint numRows;
 
88
    uint numCols;
 
89
 
 
90
#if QT_VERSION < 0x040000
 
91
    QSizePolicy::ExpandData expanding;
 
92
#else
 
93
    Qt::Orientations expanding;
 
94
#endif
 
95
 
 
96
    bool isDirty;
 
97
    QwtArray<QSize> itemSizeHints;
 
98
};
 
99
 
 
100
 
 
101
/*!
 
102
  \param parent Parent widget
 
103
  \param margin Margin
 
104
  \param spacing Spacing
 
105
*/
 
106
 
 
107
QwtDynGridLayout::QwtDynGridLayout(QWidget *parent, 
 
108
        int margin, int spacing):
 
109
    QLayout(parent)
 
110
{
 
111
    init();
 
112
 
 
113
    setSpacing(spacing);
 
114
    setMargin(margin);
 
115
}
 
116
 
 
117
#if QT_VERSION < 0x040000
 
118
/*!
 
119
  \param parent Parent widget
 
120
  \param spacing Spacing
 
121
*/
 
122
QwtDynGridLayout::QwtDynGridLayout(QLayout *parent, int spacing):
 
123
    QLayout(parent, spacing)
 
124
{
 
125
    init();
 
126
}
 
127
#endif
 
128
 
 
129
/*!
 
130
  \param spacing Spacing
 
131
*/
 
132
 
 
133
QwtDynGridLayout::QwtDynGridLayout(int spacing)
 
134
{
 
135
    init();
 
136
    setSpacing(spacing);
 
137
}
 
138
 
 
139
/*!
 
140
  Initialize the layout with default values.
 
141
*/
 
142
void QwtDynGridLayout::init()
 
143
{
 
144
    d_data = new QwtDynGridLayout::PrivateData;
 
145
    d_data->maxCols = d_data->numRows 
 
146
        = d_data->numCols = 0;
 
147
 
 
148
#if QT_VERSION < 0x040000
 
149
    d_data->expanding = QSizePolicy::NoDirection;
 
150
    setSupportsMargin(true);
 
151
#else
 
152
    d_data->expanding = 0;
 
153
#endif
 
154
}
 
155
 
 
156
//! Destructor
 
157
 
 
158
QwtDynGridLayout::~QwtDynGridLayout()
 
159
{
 
160
#if QT_VERSION < 0x040000
 
161
    deleteAllItems(); 
 
162
#endif
 
163
 
 
164
    delete d_data;
 
165
}
 
166
 
 
167
void QwtDynGridLayout::invalidate()
 
168
{
 
169
    d_data->isDirty = true;
 
170
    QLayout::invalidate();
 
171
}
 
172
 
 
173
void QwtDynGridLayout::updateLayoutCache()
 
174
{
 
175
    d_data->itemSizeHints.resize(itemCount());
 
176
 
 
177
    int index = 0;
 
178
 
 
179
    for (PrivateData::LayoutItemList::iterator it = d_data->itemList.begin();
 
180
        it != d_data->itemList.end(); ++it, index++)
 
181
    {
 
182
        d_data->itemSizeHints[int(index)] = (*it)->sizeHint();
 
183
    }
 
184
 
 
185
    d_data->isDirty = false;
 
186
}
 
187
 
 
188
/*!
 
189
  Limit the number of columns.
 
190
  \param maxCols upper limit, 0 means unlimited
 
191
  \sa QwtDynGridLayout::maxCols()
 
192
*/
 
193
  
 
194
void QwtDynGridLayout::setMaxCols(uint maxCols)
 
195
{
 
196
    d_data->maxCols = maxCols;
 
197
}
 
198
 
 
199
/*!
 
200
  Return the upper limit for the number of columns.
 
201
  0 means unlimited, what is the default.
 
202
  \sa QwtDynGridLayout::setMaxCols()
 
203
*/
 
204
 
 
205
uint QwtDynGridLayout::maxCols() const 
 
206
 
207
    return d_data->maxCols; 
 
208
}
 
209
 
 
210
//! Adds item to the next free position.
 
211
 
 
212
void QwtDynGridLayout::addItem(QLayoutItem *item)
 
213
{
 
214
    d_data->itemList.append(item);
 
215
    invalidate();
 
216
}
 
217
 
 
218
/*! 
 
219
  \return true if this layout is empty. 
 
220
*/
 
221
 
 
222
bool QwtDynGridLayout::isEmpty() const
 
223
{
 
224
    return d_data->itemList.isEmpty();
 
225
}
 
226
 
 
227
/*! 
 
228
  \return number of layout items
 
229
*/
 
230
 
 
231
uint QwtDynGridLayout::itemCount() const
 
232
{
 
233
    return d_data->itemList.count();
 
234
}
 
235
 
 
236
#if  QT_VERSION < 0x040000
 
237
/*! 
 
238
  \return An iterator over the children of this layout.
 
239
*/
 
240
 
 
241
QLayoutIterator QwtDynGridLayout::iterator()
 
242
{       
 
243
    return QLayoutIterator( 
 
244
        new QwtDynGridLayout::PrivateData::LayoutIterator(d_data) );
 
245
}
 
246
 
 
247
/*!
 
248
  Set whether this layout can make use of more space than sizeHint(). 
 
249
  A value of Vertical or Horizontal means that it wants to grow in only 
 
250
  one dimension, while BothDirections means that it wants to grow in 
 
251
  both dimensions. The default value is NoDirection. 
 
252
  \sa QwtDynGridLayout::expanding()
 
253
*/
 
254
 
 
255
void QwtDynGridLayout::setExpanding(QSizePolicy::ExpandData expanding)
 
256
{
 
257
    d_data->expanding = expanding;
 
258
}
 
259
 
 
260
/*!
 
261
  Returns whether this layout can make use of more space than sizeHint(). 
 
262
  A value of Vertical or Horizontal means that it wants to grow in only 
 
263
  one dimension, while BothDirections means that it wants to grow in 
 
264
  both dimensions. 
 
265
  \sa QwtDynGridLayout::setExpanding()
 
266
*/
 
267
 
 
268
QSizePolicy::ExpandData QwtDynGridLayout::expanding() const
 
269
{
 
270
    return d_data->expanding;
 
271
}
 
272
 
 
273
#else // QT_VERSION >= 0x040000
 
274
 
 
275
QLayoutItem *QwtDynGridLayout::itemAt( int index ) const
 
276
{
 
277
    if ( index < 0 || index >= d_data->itemList.count() )
 
278
        return NULL;
 
279
 
 
280
    return d_data->itemList.at(index);
 
281
}
 
282
    
 
283
QLayoutItem *QwtDynGridLayout::takeAt( int index )
 
284
{
 
285
    if ( index < 0 || index >= d_data->itemList.count() )
 
286
        return NULL;
 
287
  
 
288
    d_data->isDirty = true;
 
289
    return d_data->itemList.takeAt(index);
 
290
}
 
291
 
 
292
int QwtDynGridLayout::count() const
 
293
{
 
294
    return d_data->itemList.count();
 
295
}
 
296
 
 
297
void QwtDynGridLayout::setExpandingDirections(Qt::Orientations expanding)
 
298
{
 
299
    d_data->expanding = expanding;
 
300
}
 
301
 
 
302
Qt::Orientations QwtDynGridLayout::expandingDirections() const
 
303
{
 
304
    return d_data->expanding;
 
305
}
 
306
 
 
307
#endif
 
308
 
 
309
/*!
 
310
  Reorganizes columns and rows and resizes managed widgets within 
 
311
  the rectangle rect. 
 
312
*/
 
313
 
 
314
void QwtDynGridLayout::setGeometry(const QRect &rect)
 
315
{
 
316
    QLayout::setGeometry(rect);
 
317
 
 
318
    if ( isEmpty() )
 
319
        return;
 
320
 
 
321
    d_data->numCols = columnsForWidth(rect.width());
 
322
    d_data->numRows = itemCount() / d_data->numCols;
 
323
    if ( itemCount() % d_data->numCols )
 
324
        d_data->numRows++;
 
325
 
 
326
#if QT_VERSION < 0x040000
 
327
    QValueList<QRect> itemGeometries = layoutItems(rect, d_data->numCols);
 
328
#else
 
329
    QList<QRect> itemGeometries = layoutItems(rect, d_data->numCols);
 
330
#endif
 
331
 
 
332
    int index = 0;
 
333
    for (PrivateData::LayoutItemList::iterator it = d_data->itemList.begin();
 
334
        it != d_data->itemList.end(); ++it)
 
335
    {
 
336
        QWidget *w = (*it)->widget();
 
337
        if ( w )
 
338
        {
 
339
            w->setGeometry(itemGeometries[index]);
 
340
            index++;
 
341
        }
 
342
    }
 
343
}
 
344
 
 
345
/*! 
 
346
  Calculate the number of columns for a given width. It tries to
 
347
  use as many columns as possible (limited by maxCols())
 
348
 
 
349
  \param width Available width for all columns
 
350
  \sa QwtDynGridLayout::maxCols(), QwtDynGridLayout::setMaxCols()
 
351
*/
 
352
 
 
353
uint QwtDynGridLayout::columnsForWidth(int width) const
 
354
{
 
355
    if ( isEmpty() )
 
356
        return 0;
 
357
 
 
358
    const int maxCols = (d_data->maxCols > 0) ? d_data->maxCols : itemCount();
 
359
    if ( maxRowWidth(maxCols) <= width )
 
360
        return maxCols;
 
361
 
 
362
    for (int numCols = 2; numCols <= maxCols; numCols++ )
 
363
    {
 
364
        const int rowWidth = maxRowWidth(numCols);
 
365
        if ( rowWidth > width )
 
366
            return numCols - 1;
 
367
    }
 
368
 
 
369
    return 1; // At least 1 column
 
370
}
 
371
 
 
372
/*! 
 
373
  Calculate the width of a layout for a given number of
 
374
  columns.
 
375
 
 
376
  \param numCols Given number of columns
 
377
  \param itemWidth Array of the width hints for all items
 
378
*/
 
379
int QwtDynGridLayout::maxRowWidth(int numCols) const
 
380
{
 
381
    int col;
 
382
 
 
383
    QwtArray<int> colWidth(numCols);
 
384
    for ( col = 0; col < (int)numCols; col++ )
 
385
        colWidth[col] = 0;
 
386
 
 
387
    if ( d_data->isDirty )
 
388
        ((QwtDynGridLayout*)this)->updateLayoutCache();
 
389
 
 
390
    for ( uint index = 0; 
 
391
        index < (uint)d_data->itemSizeHints.count(); index++ )
 
392
    {
 
393
        col = index % numCols;
 
394
        colWidth[col] = qwtMax(colWidth[col], 
 
395
            d_data->itemSizeHints[int(index)].width());
 
396
    }
 
397
 
 
398
    int rowWidth = 2 * margin() + (numCols - 1) * spacing();
 
399
    for ( col = 0; col < (int)numCols; col++ )
 
400
        rowWidth += colWidth[col];
 
401
 
 
402
    return rowWidth;
 
403
}
 
404
 
 
405
/*!
 
406
  \return the maximum width of all layout items
 
407
*/
 
408
 
 
409
int QwtDynGridLayout::maxItemWidth() const
 
410
{
 
411
    if ( isEmpty() )
 
412
        return 0;
 
413
 
 
414
    if ( d_data->isDirty )
 
415
        ((QwtDynGridLayout*)this)->updateLayoutCache();
 
416
 
 
417
    int w = 0;
 
418
    for ( uint i = 0; i < (uint)d_data->itemSizeHints.count(); i++ )
 
419
    {
 
420
        const int itemW = d_data->itemSizeHints[int(i)].width();
 
421
        if ( itemW > w )
 
422
            w = itemW;
 
423
    }
 
424
 
 
425
    return w;
 
426
}
 
427
 
 
428
/*!
 
429
  Calculate the geometries of the layout items for a layout
 
430
  with numCols columns and a given rect.
 
431
  \param rect Rect where to place the items
 
432
  \param numCols Number of columns
 
433
  \return item geometries
 
434
*/
 
435
 
 
436
#if QT_VERSION < 0x040000
 
437
QValueList<QRect> QwtDynGridLayout::layoutItems(const QRect &rect,
 
438
    uint numCols) const
 
439
#else
 
440
QList<QRect> QwtDynGridLayout::layoutItems(const QRect &rect,
 
441
    uint numCols) const
 
442
#endif
 
443
{
 
444
#if QT_VERSION < 0x040000
 
445
    QValueList<QRect> itemGeometries;
 
446
#else
 
447
    QList<QRect> itemGeometries;
 
448
#endif
 
449
    if ( numCols == 0 || isEmpty() )
 
450
        return itemGeometries;
 
451
 
 
452
    uint numRows = itemCount() / numCols;
 
453
    if ( numRows % itemCount() )
 
454
        numRows++;
 
455
 
 
456
    QwtArray<int> rowHeight(numRows);
 
457
    QwtArray<int> colWidth(numCols);
 
458
 
 
459
    layoutGrid(numCols, rowHeight, colWidth);
 
460
 
 
461
    bool expandH, expandV;
 
462
#if QT_VERSION >= 0x040000
 
463
    expandH = expandingDirections() & Qt::Horizontal;
 
464
    expandV = expandingDirections() & Qt::Vertical;
 
465
#else
 
466
    expandH = expanding() & QSizePolicy::Horizontally;
 
467
    expandV = expanding() & QSizePolicy::Vertically;
 
468
#endif
 
469
 
 
470
    if ( expandH || expandV )
 
471
        stretchGrid(rect, numCols, rowHeight, colWidth);
 
472
 
 
473
    QwtDynGridLayout *that = (QwtDynGridLayout *)this;
 
474
    const int maxCols = d_data->maxCols;
 
475
    that->d_data->maxCols = numCols;
 
476
    const QRect alignedRect = alignmentRect(rect);
 
477
    that->d_data->maxCols = maxCols;
 
478
 
 
479
    const int xOffset = expandH ? 0 : alignedRect.x();
 
480
    const int yOffset = expandV ? 0 : alignedRect.y();
 
481
 
 
482
    QwtArray<int> colX(numCols);
 
483
    QwtArray<int> rowY(numRows);
 
484
 
 
485
    const int xySpace = spacing();
 
486
 
 
487
    rowY[0] = yOffset + margin();
 
488
    for ( int r = 1; r < (int)numRows; r++ )
 
489
        rowY[r] = rowY[r-1] + rowHeight[r-1] + xySpace;
 
490
 
 
491
    colX[0] = xOffset + margin();
 
492
    for ( int c = 1; c < (int)numCols; c++ )
 
493
        colX[c] = colX[c-1] + colWidth[c-1] + xySpace;
 
494
    
 
495
    const int itemCount = d_data->itemList.size();
 
496
    for ( int i = 0; i < itemCount; i++ )
 
497
    {
 
498
        const int row = i / numCols;
 
499
        const int col = i % numCols;
 
500
 
 
501
        QRect itemGeometry(colX[col], rowY[row], 
 
502
            colWidth[col], rowHeight[row]);
 
503
        itemGeometries.append(itemGeometry);
 
504
    }
 
505
 
 
506
    return itemGeometries;
 
507
}
 
508
 
 
509
 
 
510
/*!
 
511
  Calculate the dimensions for the columns and rows for a grid
 
512
  of numCols columns.
 
513
  \param numCols Number of columns.
 
514
  \param rowHeight Array where to fill in the calculated row heights.
 
515
  \param colWidth Array where to fill in the calculated column widths.
 
516
*/
 
517
 
 
518
void QwtDynGridLayout::layoutGrid(uint numCols, 
 
519
    QwtArray<int>& rowHeight, QwtArray<int>& colWidth) const
 
520
{
 
521
    if ( numCols <= 0 )
 
522
        return;
 
523
 
 
524
    if ( d_data->isDirty )
 
525
        ((QwtDynGridLayout*)this)->updateLayoutCache();
 
526
 
 
527
    for ( uint index = 0; 
 
528
        index < (uint)d_data->itemSizeHints.count(); index++ )
 
529
    {
 
530
        const int row = index / numCols;
 
531
        const int col = index % numCols;
 
532
 
 
533
        const QSize &size = d_data->itemSizeHints[int(index)];
 
534
 
 
535
        rowHeight[row] = (col == 0) 
 
536
            ? size.height() : qwtMax(rowHeight[row], size.height());
 
537
        colWidth[col] = (row == 0) 
 
538
            ? size.width() : qwtMax(colWidth[col], size.width());
 
539
    }
 
540
}
 
541
 
 
542
/*!
 
543
  \return true: QwtDynGridLayout implements heightForWidth.
 
544
  \sa QwtDynGridLayout::heightForWidth()
 
545
*/
 
546
 
 
547
bool QwtDynGridLayout::hasHeightForWidth() const
 
548
{
 
549
    return true;
 
550
}
 
551
 
 
552
/*!
 
553
  \return The preferred height for this layout, given the width w. 
 
554
  \sa QwtDynGridLayout::hasHeightForWidth()
 
555
*/
 
556
 
 
557
int QwtDynGridLayout::heightForWidth(int width) const
 
558
{
 
559
    if ( isEmpty() )
 
560
        return 0;
 
561
 
 
562
    const uint numCols = columnsForWidth(width);
 
563
    uint numRows = itemCount() / numCols;
 
564
    if ( itemCount() % numCols )
 
565
        numRows++;
 
566
 
 
567
    QwtArray<int> rowHeight(numRows);
 
568
    QwtArray<int> colWidth(numCols);
 
569
 
 
570
    layoutGrid(numCols, rowHeight, colWidth);
 
571
 
 
572
    int h = 2 * margin() + (numRows - 1) * spacing();
 
573
    for ( int row = 0; row < (int)numRows; row++ )
 
574
        h += rowHeight[row];
 
575
 
 
576
    return h;
 
577
}
 
578
 
 
579
/*!
 
580
  Stretch columns in case of expanding() & QSizePolicy::Horizontal and
 
581
  rows in case of expanding() & QSizePolicy::Vertical to fill the entire
 
582
  rect. Rows and columns are stretched with the same factor.
 
583
  \sa QwtDynGridLayout::setExpanding(), QwtDynGridLayout::expanding()
 
584
*/
 
585
 
 
586
void QwtDynGridLayout::stretchGrid(const QRect &rect, 
 
587
    uint numCols, QwtArray<int>& rowHeight, QwtArray<int>& colWidth) const
 
588
{
 
589
    if ( numCols == 0 || isEmpty() )
 
590
        return;
 
591
 
 
592
    bool expandH, expandV;
 
593
#if QT_VERSION >= 0x040000
 
594
    expandH = expandingDirections() & Qt::Horizontal;
 
595
    expandV = expandingDirections() & Qt::Vertical;
 
596
#else
 
597
    expandH = expanding() & QSizePolicy::Horizontally;
 
598
    expandV = expanding() & QSizePolicy::Vertically;
 
599
#endif
 
600
 
 
601
    if ( expandH )
 
602
    {
 
603
        int xDelta = rect.width() - 2 * margin() - (numCols - 1) * spacing();
 
604
        for ( int col = 0; col < (int)numCols; col++ )
 
605
            xDelta -= colWidth[col];
 
606
 
 
607
        if ( xDelta > 0 )
 
608
        {
 
609
            for ( int col = 0; col < (int)numCols; col++ )
 
610
            {
 
611
                const int space = xDelta / (numCols - col);
 
612
                colWidth[col] += space;
 
613
                xDelta -= space;
 
614
            }
 
615
        }
 
616
    }
 
617
 
 
618
    if ( expandV )
 
619
    {
 
620
        uint numRows = itemCount() / numCols;
 
621
        if ( itemCount() % numCols )
 
622
            numRows++;
 
623
 
 
624
        int yDelta = rect.height() - 2 * margin() - (numRows - 1) * spacing();
 
625
        for ( int row = 0; row < (int)numRows; row++ )
 
626
            yDelta -= rowHeight[row];
 
627
 
 
628
        if ( yDelta > 0 )
 
629
        {
 
630
            for ( int row = 0; row < (int)numRows; row++ )
 
631
            {
 
632
                const int space = yDelta / (numRows - row);
 
633
                rowHeight[row] += space;
 
634
                yDelta -= space;
 
635
            }
 
636
        }
 
637
    }
 
638
}
 
639
 
 
640
/*!
 
641
   Return the size hint. If maxCols() > 0 it is the size for
 
642
   a grid with maxCols() columns, otherwise it is the size for
 
643
   a grid with only one row.
 
644
   \sa QwtDynGridLayout::maxCols(), QwtDynGridLayout::setMaxCols()
 
645
*/
 
646
 
 
647
QSize QwtDynGridLayout::sizeHint() const
 
648
{
 
649
    if ( isEmpty() )
 
650
        return QSize();
 
651
 
 
652
    const uint numCols = (d_data->maxCols > 0 ) ? d_data->maxCols : itemCount();
 
653
    uint numRows = itemCount() / numCols;
 
654
    if ( itemCount() % numCols )
 
655
        numRows++;
 
656
 
 
657
    QwtArray<int> rowHeight(numRows);
 
658
    QwtArray<int> colWidth(numCols);
 
659
 
 
660
    layoutGrid(numCols, rowHeight, colWidth);
 
661
 
 
662
    int h = 2 * margin() + (numRows - 1) * spacing();
 
663
    for ( int row = 0; row < (int)numRows; row++ )
 
664
        h += rowHeight[row];
 
665
 
 
666
    int w = 2 * margin() + (numCols - 1) * spacing(); 
 
667
    for ( int col = 0; col < (int)numCols; col++ )
 
668
        w += colWidth[col];
 
669
 
 
670
    return QSize(w, h);
 
671
}
 
672
 
 
673
/*!
 
674
  \return Number of rows of the current layout.
 
675
  \sa QwtDynGridLayout::numCols
 
676
  \warning The number of rows might change whenever the geometry changes
 
677
*/
 
678
uint QwtDynGridLayout::numRows() const 
 
679
 
680
    return d_data->numRows; 
 
681
}
 
682
 
 
683
/*!
 
684
  \return Number of columns of the current layout.
 
685
  \sa QwtDynGridLayout::numRows
 
686
  \warning The number of columns might change whenever the geometry changes
 
687
*/
 
688
uint QwtDynGridLayout::numCols() const 
 
689
 
690
    return d_data->numCols; 
 
691
}