1
/**********************************************************************
2
** Copyright (C) 2000 Trolltech AS. All rights reserved.
4
** This file is part of Qt Designer.
6
** This file may be distributed and/or modified under the terms of the
7
** GNU General Public License version 2 as published by the Free Software
8
** Foundation and appearing in the file LICENSE.GPL included in the
9
** packaging of this file.
11
** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
12
** licenses may use this file in accordance with the Qt Commercial License
13
** Agreement provided with the Software.
15
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
18
** See http://www.trolltech.com/gpl/ for GPL licensing information.
19
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
20
** information about Qt Commercial License Agreements.
22
** Contact info@trolltech.com if any conditions of this licensing are
25
**********************************************************************/
27
#include "formwindow.h"
29
#include <widgetdatabase.h>
30
#include "widgetfactory.h"
37
#include <qsplitter.h>
38
#include <qvaluevector.h>
39
#include <qmainwindow.h>
41
bool operator<( const QGuardedPtr<QWidget> &p1, const QGuardedPtr<QWidget> &p2 )
43
return p1.operator->() < p2.operator->();
47
\class Layout layout.h
48
\brief Baseclass for layouting widgets in the Designer
50
Classes derived from this abstract base class are used for layouting
51
operations in the Designer.
55
/*! \a p specifies the parent of the layoutBase \a lb. The parent
56
might be changed in setup(). If the layoutBase is a
57
container, the parent and the layoutBase are the same. Also they
58
always have to be a widget known to the designer (e.g. in the case
59
of the tabwidget parent and layoutBase are the tabwidget and not the
60
page which actually gets laid out. For actual usage the correct
61
widget is found later by Layout.)
64
Layout::Layout( const QWidgetList &wl, QWidget *p, FormWindow *fw, QWidget *lb, bool doSetup, bool splitter )
65
: widgets( wl ), parent( p ), formWindow( fw ), isBreak( !doSetup ), useSplitter( splitter )
67
widgets.setAutoDelete( FALSE );
69
if ( !doSetup && layoutBase )
70
oldGeometry = layoutBase->geometry();
73
/*! The widget list we got in the constructor might contain too much
74
widgets (like widgets with different parents, already laid out
75
widgets, etc.). Here we set up the list and so the only the "best"
81
startPoint = QPoint( 32767, 32767 );
82
QValueList<QWidgetList> lists;
83
QWidget *lastParent = 0;
84
QWidgetList *lastList = 0;
87
// Go through all widgets of the list we got. As we can only
88
// layout widgets which have the same parent, we first do some
89
// sorting which means create a list for each parent containing
90
// its child here. After that we keep working on the list of
91
// childs which has the most entries.
92
// Widgets which are already laid out are thrown away here too
93
for ( w = widgets.first(); w; w = widgets.next() ) {
94
if ( w->parentWidget() && WidgetFactory::layoutType( w->parentWidget() ) != WidgetFactory::NoLayout )
96
if ( lastParent != w->parentWidget() ) {
98
lastParent = w->parentWidget();
99
QValueList<QWidgetList>::Iterator it = lists.begin();
100
for ( ; it != lists.end(); ++it ) {
101
if ( ( *it ).first()->parentWidget() == w->parentWidget() )
106
l.setAutoDelete( FALSE );
108
lastList = &lists.last();
111
lastList->append( w );
114
// So, now find the list with the most entries
116
QValueList<QWidgetList>::Iterator it = lists.begin();
117
for ( ; it != lists.end(); ++it ) {
118
if ( !lastList || ( *it ).count() > lastList->count() )
122
// If we found no list (because no widget did fit at all) or the
123
// best list has only one entry and we do not layout a container,
125
if ( !lastList || ( lastList->count() < 2 &&
127
( !WidgetDatabase::isContainer( WidgetDatabase::idFromClassName( WidgetFactory::classNameOf( layoutBase ) ) ) &&
128
layoutBase != formWindow->mainContainer() ) )
131
startPoint = QPoint( 0, 0 );
135
// Now we have a new and clean widget list, which makes sense
138
// Also use the only correct parent later, so store it
139
parent = WidgetFactory::widgetOfContainer( widgets.first()->parentWidget() );
140
// Now calculate the position where the layout-meta-widget should
141
// be placed and connect to widgetDestroyed() signals of the
142
// widgets to get informed if one gets deleted to be able to
143
// handle that and do not crash in this case
144
for ( w = widgets.first(); w; w = widgets.next() ) {
145
connect( w, SIGNAL( destroyed() ),
146
this, SLOT( widgetDestroyed() ) );
147
startPoint = QPoint( QMIN( startPoint.x(), w->x() ),
148
QMIN( startPoint.y(), w->y() ) );
149
geometries.insert( w, QRect( w->pos(), w->size() ) );
150
// Change the Z-order, as saving/loading uses the Z-order for
151
// writing/creating widgets and this has to be the same as in
152
// the layout. Else saving + loading will give different results
157
void Layout::widgetDestroyed()
159
if ( sender() && sender()->isWidgetType() )
160
widgets.removeRef( (QWidget*)sender() );
163
bool Layout::prepareLayout( bool &needMove, bool &needReparent )
165
if ( !widgets.count() )
167
for ( QWidget *w = widgets.first(); w; w = widgets.next() )
169
needMove = !layoutBase;
170
needReparent = needMove || ::qt_cast<QLayoutWidget*>(layoutBase) || ::qt_cast<QSplitter*>(layoutBase);
173
layoutBase = WidgetFactory::create( WidgetDatabase::idFromClassName( "QLayoutWidget" ),
174
WidgetFactory::containerOfWidget( parent ) );
176
layoutBase = WidgetFactory::create( WidgetDatabase::idFromClassName( "QSplitter" ),
177
WidgetFactory::containerOfWidget( parent ) );
179
WidgetFactory::deleteLayout( layoutBase );
185
void Layout::finishLayout( bool needMove, QLayout *layout )
188
layoutBase->move( startPoint );
189
QRect g( QRect( layoutBase->pos(), layoutBase->size() ) );
190
if ( WidgetFactory::layoutType( layoutBase->parentWidget() ) == WidgetFactory::NoLayout && !isBreak )
191
layoutBase->adjustSize();
193
layoutBase->setGeometry( oldGeometry );
197
formWindow->insertWidget( layoutBase );
198
formWindow->selectWidget( layoutBase );
199
QString n = layoutBase->name();
200
if ( n.find( "qt_dead_widget_" ) != -1 ) {
201
n.remove( 0, QString( "qt_dead_widget_" ).length() );
202
layoutBase->setName( n );
206
void Layout::undoLayout()
208
if ( !widgets.count() )
210
QMap<QGuardedPtr<QWidget>, QRect>::Iterator it = geometries.begin();
211
for ( ; it != geometries.end(); ++it ) {
214
it.key()->reparent( WidgetFactory::containerOfWidget( parent ), 0, ( *it ).topLeft(), it.key()->isVisibleTo( formWindow ) );
215
it.key()->resize( ( *it ).size() );
217
formWindow->selectWidget( layoutBase, FALSE );
218
WidgetFactory::deleteLayout( layoutBase );
219
if ( parent != layoutBase && !::qt_cast<QMainWindow*>(layoutBase) ) {
221
QString n = layoutBase->name();
222
n.prepend( "qt_dead_widget_" );
223
layoutBase->setName( n );
225
layoutBase->setGeometry( oldGeometry );
227
if ( widgets.first() )
228
formWindow->selectWidget( widgets.first() );
230
formWindow->selectWidget( formWindow );
233
void Layout::breakLayout()
235
QMap<QWidget*, QRect> rects;
236
if ( !widgets.isEmpty() ) {
238
for ( w = widgets.first(); w; w = widgets.next() )
239
rects.insert( w, w->geometry() );
241
WidgetFactory::deleteLayout( layoutBase );
242
bool needReparent = qstrcmp( layoutBase->className(), "QLayoutWidget" ) == 0 ||
243
qstrcmp( layoutBase->className(), "QSplitter" ) == 0 ||
244
( !WidgetDatabase::isContainer( WidgetDatabase::idFromClassName( WidgetFactory::classNameOf( layoutBase ) ) ) &&
245
layoutBase != formWindow->mainContainer() );
246
bool needResize = qstrcmp( layoutBase->className(), "QSplitter" ) == 0;
247
bool add = geometries.isEmpty();
248
for ( QWidget *w = widgets.first(); w; w = widgets.next() ) {
250
w->reparent( layoutBase->parentWidget(), 0,
251
layoutBase->pos() + w->pos(), TRUE );
253
QMap<QWidget*, QRect>::Iterator it = rects.find( w );
254
if ( it != rects.end() )
255
w->setGeometry( QRect( layoutBase->pos() + (*it).topLeft(), (*it).size() ) );
258
geometries.insert( w, QRect( w->pos(), w->size() ) );
260
if ( needReparent ) {
262
parent = layoutBase->parentWidget();
263
QString n = layoutBase->name();
264
n.prepend( "qt_dead_widget_" );
265
layoutBase->setName( n );
269
if ( widgets.first() && widgets.first()->isVisibleTo( formWindow ) )
270
formWindow->selectWidget( widgets.first() );
272
formWindow->selectWidget( formWindow );
275
class HorizontalLayoutList : public QWidgetList
278
HorizontalLayoutList( const QWidgetList &l )
279
: QWidgetList( l ) {}
281
int compareItems( QPtrCollection::Item item1, QPtrCollection::Item item2 ) {
282
QWidget *w1 = (QWidget*)item1;
283
QWidget *w2 = (QWidget*)item2;
284
if ( w1->x() == w2->x() )
286
if ( w1->x() > w2->x() )
293
HorizontalLayout::HorizontalLayout( const QWidgetList &wl, QWidget *p, FormWindow *fw, QWidget *lb, bool doSetup, bool splitter )
294
: Layout( wl, p, fw, lb, doSetup, splitter )
300
void HorizontalLayout::setup()
302
HorizontalLayoutList l( widgets );
308
void HorizontalLayout::doLayout()
310
bool needMove, needReparent;
311
if ( !prepareLayout( needMove, needReparent ) )
314
QHBoxLayout *layout = (QHBoxLayout*)WidgetFactory::createLayout( layoutBase, 0, WidgetFactory::HBox );
316
for ( QWidget *w = widgets.first(); w; w = widgets.next() ) {
317
if ( needReparent && w->parent() != layoutBase )
318
w->reparent( layoutBase, 0, QPoint( 0, 0 ), FALSE );
319
if ( !useSplitter ) {
320
if ( qstrcmp( w->className(), "Spacer" ) == 0 )
321
layout->addWidget( w, 0, ( (Spacer*)w )->alignment() );
323
layout->addWidget( w );
324
if ( ::qt_cast<QLayoutWidget*>(w) )
325
( (QLayoutWidget*)w )->updateSizePolicy();
330
if ( ::qt_cast<QSplitter*>(layoutBase) )
331
( (QSplitter*)layoutBase )->setOrientation( Qt::Horizontal );
333
finishLayout( needMove, layout );
339
class VerticalLayoutList : public QWidgetList
342
VerticalLayoutList( const QWidgetList &l )
343
: QWidgetList( l ) {}
345
int compareItems( QPtrCollection::Item item1, QPtrCollection::Item item2 ) {
346
QWidget *w1 = (QWidget*)item1;
347
QWidget *w2 = (QWidget*)item2;
348
if ( w1->y() == w2->y() )
350
if ( w1->y() > w2->y() )
357
VerticalLayout::VerticalLayout( const QWidgetList &wl, QWidget *p, FormWindow *fw, QWidget *lb, bool doSetup, bool splitter )
358
: Layout( wl, p, fw, lb, doSetup, splitter )
364
void VerticalLayout::setup()
366
VerticalLayoutList l( widgets );
372
void VerticalLayout::doLayout()
374
bool needMove, needReparent;
375
if ( !prepareLayout( needMove, needReparent ) )
378
QVBoxLayout *layout = (QVBoxLayout*)WidgetFactory::createLayout( layoutBase, 0, WidgetFactory::VBox );
380
for ( QWidget *w = widgets.first(); w; w = widgets.next() ) {
381
if ( needReparent && w->parent() != layoutBase )
382
w->reparent( layoutBase, 0, QPoint( 0, 0 ), FALSE );
383
if ( !useSplitter ) {
384
if ( qstrcmp( w->className(), "Spacer" ) == 0 )
385
layout->addWidget( w, 0, ( (Spacer*)w )->alignment() );
387
layout->addWidget( w );
388
if ( ::qt_cast<QLayoutWidget*>(w) )
389
( (QLayoutWidget*)w )->updateSizePolicy();
394
if ( ::qt_cast<QSplitter*>(layoutBase) )
395
( (QSplitter*)layoutBase )->setOrientation( Qt::Vertical );
397
finishLayout( needMove, layout );
407
Grid( int rows, int cols );
410
QWidget* cell( int row, int col ) const { return cells[ row * ncols + col]; }
411
void setCell( int row, int col, QWidget* w ) { cells[ row*ncols + col] = w; }
412
void setCells( QRect c, QWidget* w ) {
413
for ( int rows = c.bottom()-c.top(); rows >= 0; rows--)
414
for ( int cols = c.right()-c.left(); cols >= 0; cols--) {
415
setCell(c.top()+rows, c.left()+cols, w);
418
int numRows() const { return nrows; }
419
int numCols() const { return ncols; }
422
bool locateWidget( QWidget* w, int& row, int& col, int& rowspan, int& colspan );
426
int countRow( int r, int c ) const;
427
int countCol( int r, int c ) const;
428
void setRow( int r, int c, QWidget* w, int count );
429
void setCol( int r, int c, QWidget* w, int count );
430
bool isWidgetStartCol( int c ) const;
431
bool isWidgetEndCol( int c ) const;
432
bool isWidgetStartRow( int r ) const;
433
bool isWidgetEndRow( int r ) const;
434
bool isWidgetTopLeft( int r, int c ) const;
446
Grid::Grid( int r, int c )
447
: nrows( r ), ncols( c )
449
cells = new QWidget*[ r * c ];
450
memset( cells, 0, sizeof( cells ) * r * c );
451
rows = new bool[ r ];
452
cols = new bool[ c ];
463
int Grid::countRow( int r, int c ) const
465
QWidget* w = cell( r, c );
467
while ( i < ncols && cell( r, i ) == w )
472
int Grid::countCol( int r, int c ) const
474
QWidget* w = cell( r, c );
476
while ( i < nrows && cell( i, c ) == w )
481
void Grid::setCol( int r, int c, QWidget* w, int count )
483
for (int i = 0; i < count; i++ )
484
setCell( r + i, c, w );
487
void Grid::setRow( int r, int c, QWidget* w, int count )
489
for (int i = 0; i < count; i++ )
490
setCell( r, c + i, w );
493
bool Grid::isWidgetStartCol( int c ) const
496
for ( r = 0; r < nrows; r++ ) {
497
if ( cell( r, c ) && ( (c==0) || (cell( r, c) != cell( r, c-1) )) ) {
504
bool Grid::isWidgetEndCol( int c ) const
507
for ( r = 0; r < nrows; r++ ) {
508
if ( cell( r, c ) && ((c == ncols-1) || (cell( r, c) != cell( r, c+1) )) )
514
bool Grid::isWidgetStartRow( int r ) const
517
for ( c = 0; c < ncols; c++ ) {
518
if ( cell( r, c ) && ( (r==0) || (cell( r, c) != cell( r-1, c) )) )
524
bool Grid::isWidgetEndRow( int r ) const
527
for ( c = 0; c < ncols; c++ ) {
528
if ( cell( r, c ) && ((r == nrows-1) || (cell( r, c) != cell( r+1, c) )) )
535
bool Grid::isWidgetTopLeft( int r, int c ) const
537
QWidget* w = cell( r, c );
540
return ( !r || cell( r-1, c) != w ) && (!c || cell( r, c-1) != w);
543
void Grid::extendLeft()
546
for ( c = 1; c < ncols; c++ ) {
547
for ( r = 0; r < nrows; r++ ) {
548
QWidget* w = cell( r, c );
551
int cc = countCol( r, c);
553
for ( i = c-1; i >= 0; i-- ) {
556
if ( countCol( r, i ) < cc )
558
if ( isWidgetEndCol( i ) )
560
if ( isWidgetStartCol( i ) ) {
566
for ( i = 0; i < stretch; i++ )
567
setCol( r, c-i-1, w, cc );
574
void Grid::extendRight()
577
for ( c = ncols - 2; c >= 0; c-- ) {
578
for ( r = 0; r < nrows; r++ ) {
579
QWidget* w = cell( r, c );
582
int cc = countCol( r, c);
584
for ( i = c+1; i < ncols; i++ ) {
587
if ( countCol( r, i ) < cc )
589
if ( isWidgetStartCol( i ) )
591
if ( isWidgetEndCol( i ) ) {
597
for ( i = 0; i < stretch; i++ )
598
setCol( r, c+i+1, w, cc );
605
void Grid::extendUp()
608
for ( r = 1; r < nrows; r++ ) {
609
for ( c = 0; c < ncols; c++ ) {
610
QWidget* w = cell( r, c );
613
int cr = countRow( r, c);
615
for ( i = r-1; i >= 0; i-- ) {
618
if ( countRow( i, c ) < cr )
620
if ( isWidgetEndRow( i ) )
622
if ( isWidgetStartRow( i ) ) {
628
for ( i = 0; i < stretch; i++ )
629
setRow( r-i-1, c, w, cr );
635
void Grid::extendDown()
638
for ( r = nrows - 2; r >= 0; r-- ) {
639
for ( c = 0; c < ncols; c++ ) {
640
QWidget* w = cell( r, c );
643
int cr = countRow( r, c);
645
for ( i = r+1; i < nrows; i++ ) {
648
if ( countRow( i, c ) < cr )
650
if ( isWidgetStartRow( i ) )
652
if ( isWidgetEndRow( i ) ) {
658
for ( i = 0; i < stretch; i++ )
659
setRow( r+i+1, c, w, cr );
666
void Grid::simplify()
679
for ( c = 0; c < ncols; c++ )
682
for ( r = 0; r < nrows; r++ )
685
for ( c = 0; c < ncols; c++ ) {
686
for ( r = 0; r < nrows; r++ ) {
687
if ( isWidgetTopLeft( r, c ) ) {
695
bool Grid::locateWidget( QWidget* w, int& row, int& col, int& rowspan, int & colspan )
698
for ( c = 0; c < ncols; c++ ) {
699
for ( r = 0; r < nrows; r++ ) {
700
if ( cell( r, c ) == w ) {
702
for ( r2 = 1; r2 <= r; r2++ ) {
707
for ( c2 = 1; c2 <= c; c2++ ) {
712
for ( r2 = r ; r2 < nrows && cell( r2, c) == w; r2++ ) {
717
for ( c2 = c; c2 < ncols && cell( r, c2) == w; c2++ ) {
731
GridLayout::GridLayout( const QWidgetList &wl, QWidget *p, FormWindow *fw, QWidget *lb, const QSize &res, bool doSetup )
732
: Layout( wl, p, fw, lb, doSetup ), resolution( res )
739
GridLayout::~GridLayout()
744
void GridLayout::doLayout()
746
bool needMove, needReparent;
747
if ( !prepareLayout( needMove, needReparent ) )
750
QDesignerGridLayout *layout = (QDesignerGridLayout*)WidgetFactory::createLayout( layoutBase, 0, WidgetFactory::Grid );
757
for ( w = widgets.first(); w; w = widgets.next() ) {
758
if ( grid->locateWidget( w, r, c, rs, cs) ) {
759
if ( needReparent && w->parent() != layoutBase )
760
w->reparent( layoutBase, 0, QPoint( 0, 0 ), FALSE );
761
if ( rs * cs == 1 ) {
762
layout->addWidget( w, r, c, ::qt_cast<Spacer*>(w) ? ( (Spacer*)w )->alignment() : 0 );
764
layout->addMultiCellWidget( w, r, r+rs-1, c, c+cs-1, ::qt_cast<Spacer*>(w) ? ( (Spacer*)w )->alignment() : 0 );
766
if ( ::qt_cast<QLayoutWidget*>(w) )
767
( (QLayoutWidget*)w )->updateSizePolicy();
770
qWarning("ooops, widget '%s' does not fit in layout", w->name() );
773
finishLayout( needMove, layout );
776
void GridLayout::setup()
782
void GridLayout::buildGrid()
784
if ( !widgets.count() )
787
// Pixel to cell conversion:
788
// By keeping a list of start'n'stop values (x & y) for each widget,
789
// it is possible to create a very small grid of cells to represent
790
// the widget layout.
791
// -----------------------------------------------------------------
793
// We need a list of both start and stop values for x- & y-axis
794
QValueVector<int> x( widgets.count()*2 );
795
QValueVector<int> y( widgets.count()*2 );
797
// Using push_back would look nicer, but operator[] is much faster
800
for ( w = widgets.first(); w; w = widgets.next() ) {
801
QRect widgetPos = w->geometry();
802
x[index] = widgetPos.left();
803
x[index+1] = widgetPos.right();
804
y[index] = widgetPos.top();
805
y[index+1] = widgetPos.bottom();
812
// Remove duplicate x enteries (Remove next, if equal to current)
814
for (QValueVector<int>::iterator current = x.begin() ;
815
(current != x.end()) && ((current+1) != x.end()) ; )
816
if ( (*current == *(current+1)) )
822
// Remove duplicate y enteries (Remove next, if equal to current)
824
for (QValueVector<int>::iterator current = y.begin() ;
825
(current != y.end()) && ((current+1) != y.end()) ; )
826
if ( (*current == *(current+1)) )
832
// Create the smallest grid possible to represent the current layout
833
// Since no widget will be placed in the last row and column, we'll
834
// skip them to increase speed even further
836
grid = new Grid( y.size()-1, x.size()-1 );
838
// Mark the cells in the grid that contains a widget
839
for ( w = widgets.first(); w; w = widgets.next() ) {
840
QRect c(0,0,0,0), widgetPos = w->geometry();
841
// From left til right (not including)
842
for (uint cw=0; cw<x.size(); cw++) {
843
if ( x[cw] == widgetPos.left() )
845
if ( x[cw] < widgetPos.right())
848
// From top til bottom (not including)
849
for (uint ch=0; ch<y.size(); ch++) {
850
if ( y[ch] == widgetPos.top() )
852
if ( y[ch] < widgetPos.bottom() )
855
grid->setCells(c, w); // Mark cellblock
866
Spacer::Spacer( QWidget *parent, const char *name )
867
: QWidget( parent, name, WMouseNoMask ),
868
orient( Vertical ), interactive(TRUE), sh( QSize(20,20) )
870
setSizeType( Expanding );
874
void Spacer::paintEvent( QPaintEvent * )
877
p.setPen( Qt::blue );
879
if ( orient == Horizontal ) {
881
const int amplitude = QMIN( 3, height() / 3 );
882
const int base = height() / 2;
885
for ( i = 0; i < width() / 3 +2; ++i )
886
p.drawLine( i * dist, base - amplitude, i * dist + dist / 2, base + amplitude );
888
for ( i = 0; i < width() / 3 +2; ++i )
889
p.drawLine( i * dist + dist / 2, base + amplitude, i * dist + dist, base - amplitude );
890
p.drawLine( 0, 0, 0, height() );
891
p.drawLine( width() - 1, 0, width() - 1, height());
894
const int amplitude = QMIN( 3, width() / 3 );
895
const int base = width() / 2;
898
for ( i = 0; i < height() / 3 +2; ++i )
899
p.drawLine( base - amplitude, i * dist, base + amplitude,i * dist + dist / 2 );
901
for ( i = 0; i < height() / 3 +2; ++i )
902
p.drawLine( base + amplitude, i * dist + dist / 2, base - amplitude, i * dist + dist );
903
p.drawLine( 0, 0, width(), 0 );
904
p.drawLine( 0, height() - 1, width(), height() - 1 );
908
void Spacer::resizeEvent( QResizeEvent* e)
910
QWidget::resizeEvent( e );
911
if ( !parentWidget() || WidgetFactory::layoutType( parentWidget() ) == WidgetFactory::NoLayout )
915
void Spacer::updateMask()
918
if ( orient == Horizontal ) {
919
const int amplitude = QMIN( 3, height() / 3 );
920
const int base = height() / 2;
921
r = r.subtract( QRect(1, 0, width() - 2, base - amplitude ) );
922
r = r.subtract( QRect(1, base + amplitude, width() - 2, height() - base - amplitude ) );
924
const int amplitude = QMIN( 3, width() / 3 );
925
const int base = width() / 2;
926
r = r.subtract( QRect(0, 1, base - amplitude, height() - 2 ) );
927
r = r.subtract( QRect( base + amplitude, 1, width() - base - amplitude, height() - 2 ) );
932
void Spacer::setSizeType( SizeType t )
935
if ( orient == Vertical )
936
sizeP = QSizePolicy( QSizePolicy::Minimum, (QSizePolicy::SizeType)t );
938
sizeP = QSizePolicy( (QSizePolicy::SizeType)t, QSizePolicy::Minimum );
939
setSizePolicy( sizeP );
943
Spacer::SizeType Spacer::sizeType() const
945
if ( orient == Vertical )
946
return (SizeType)sizePolicy().verData();
947
return (SizeType)sizePolicy().horData();
950
int Spacer::alignment() const
952
if ( orient == Vertical )
957
QSize Spacer::minimumSize() const
959
QSize s = QSize( 20,20 );
960
if ( sizeType() == Expanding )
961
if ( orient == Vertical )
968
QSize Spacer::sizeHint() const
974
void Spacer::setSizeHint( const QSize &s )
977
if ( !parentWidget() || WidgetFactory::layoutType( parentWidget() ) == WidgetFactory::NoLayout )
978
resize( sizeHint() );
982
Qt::Orientation Spacer::orientation() const
987
void Spacer::setOrientation( Qt::Orientation o )
992
SizeType st = sizeType();
996
sh = QSize( sh.height(), sh.width() );
997
if (!parentWidget() || WidgetFactory::layoutType( parentWidget() ) == WidgetFactory::NoLayout )
998
resize( height(), width() );
1006
void QDesignerGridLayout::addWidget( QWidget *w, int row, int col, int align_ )
1008
items.insert( w, Item(row, col, 1, 1) );
1009
QGridLayout::addWidget( w, row, col, align_ );
1012
void QDesignerGridLayout::addMultiCellWidget( QWidget *w, int fromRow, int toRow,
1013
int fromCol, int toCol, int align_ )
1015
items.insert( w, Item(fromRow, fromCol, toRow - fromRow + 1, toCol - fromCol +1) );
1016
QGridLayout::addMultiCellWidget( w, fromRow, toRow, fromCol, toCol, align_ );