|
|
|
@ -25,9 +25,9 @@
|
|
|
|
|
|
|
|
|
|
class FlowLayoutIterator :public TQGLayoutIterator{
|
|
|
|
|
public:
|
|
|
|
|
FlowLayoutIterator( TQPtrList<TQLayoutItem>* tqlayoutItems ):
|
|
|
|
|
FlowLayoutIterator( TQPtrList<TQLayoutItem>* layoutItems ):
|
|
|
|
|
index(0),
|
|
|
|
|
mLayoutItems(tqlayoutItems){
|
|
|
|
|
mLayoutItems(layoutItems){
|
|
|
|
|
}
|
|
|
|
|
uint count() const;
|
|
|
|
|
TQLayoutItem* current();
|
|
|
|
@ -246,25 +246,25 @@ int FlowLayout::doLayoutHorizontal( const TQRect& rect, bool testOnly ){
|
|
|
|
|
int width = 0; // width of this column so far
|
|
|
|
|
int height = 0; // height of this column so far
|
|
|
|
|
TQPtrListIterator<TQLayoutItem> it(mLayoutItems);
|
|
|
|
|
TQLayoutItem* tqlayoutItem;
|
|
|
|
|
TQLayoutItem* layoutItem;
|
|
|
|
|
TQPtrList<TQLayoutItem> column; // stores the items of one column
|
|
|
|
|
while((tqlayoutItem = it.current()) != 0){
|
|
|
|
|
while((layoutItem = it.current()) != 0){
|
|
|
|
|
++it;
|
|
|
|
|
//int nextY = y + tqlayoutItem->tqsizeHint().height() + spacing(); // next y
|
|
|
|
|
int nextY = y + tqlayoutItem->tqsizeHint().height(); // next y
|
|
|
|
|
//int nextY = y + layoutItem->tqsizeHint().height() + spacing(); // next y
|
|
|
|
|
int nextY = y + layoutItem->tqsizeHint().height(); // next y
|
|
|
|
|
//if( nextY - spacing() > rect.bottom() && width > 0 ) {
|
|
|
|
|
if( nextY > rect.bottom() && width > 0 ) {
|
|
|
|
|
// next column
|
|
|
|
|
y = rect.y(); // reset y
|
|
|
|
|
x = x + width + spacing(); // new x
|
|
|
|
|
//nextY = y + tqlayoutItem->tqsizeHint().height() + spacing(); // next y with changed y
|
|
|
|
|
nextY = y + tqlayoutItem->tqsizeHint().height(); // next y with changed y
|
|
|
|
|
//nextY = y + layoutItem->tqsizeHint().height() + spacing(); // next y with changed y
|
|
|
|
|
nextY = y + layoutItem->tqsizeHint().height(); // next y with changed y
|
|
|
|
|
width = 0; // reset width for the next column
|
|
|
|
|
}
|
|
|
|
|
if(!testOnly){
|
|
|
|
|
tqlayoutItem->setGeometry( TQRect( TQPoint( x, y ), tqlayoutItem->tqsizeHint() ) );
|
|
|
|
|
column.append(tqlayoutItem);
|
|
|
|
|
height += tqlayoutItem->tqsizeHint().height(); // add the height of the current item to the column height
|
|
|
|
|
layoutItem->setGeometry( TQRect( TQPoint( x, y ), layoutItem->tqsizeHint() ) );
|
|
|
|
|
column.append(layoutItem);
|
|
|
|
|
height += layoutItem->tqsizeHint().height(); // add the height of the current item to the column height
|
|
|
|
|
if( it.current() == 0 || nextY + it.current()->tqsizeHint().height() > rect.bottom() ){ // test it it's the last item (of this column)
|
|
|
|
|
// calculate real needed width
|
|
|
|
|
int rWidth = 0;
|
|
|
|
@ -283,7 +283,7 @@ int FlowLayout::doLayoutHorizontal( const TQRect& rect, bool testOnly ){
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
y = nextY;
|
|
|
|
|
width = TQMAX( width, tqlayoutItem->tqsizeHint().width() );
|
|
|
|
|
width = TQMAX( width, layoutItem->tqsizeHint().width() );
|
|
|
|
|
}
|
|
|
|
|
return x + width - rect.x(); // width
|
|
|
|
|
}
|
|
|
|
@ -293,23 +293,23 @@ int FlowLayout::doLayoutVertical( const TQRect& rect, bool testOnly ){
|
|
|
|
|
int y = rect.y();
|
|
|
|
|
int height = 0; // height of this line so far
|
|
|
|
|
TQPtrListIterator<TQLayoutItem> it(mLayoutItems);
|
|
|
|
|
TQLayoutItem* tqlayoutItem;
|
|
|
|
|
while((tqlayoutItem = it.current() ) != 0){
|
|
|
|
|
TQLayoutItem* layoutItem;
|
|
|
|
|
while((layoutItem = it.current() ) != 0){
|
|
|
|
|
++it;
|
|
|
|
|
//int nextX = x + tqlayoutItem->tqsizeHint().width() + spacing();
|
|
|
|
|
int nextX = x + tqlayoutItem->tqsizeHint().width();
|
|
|
|
|
//int nextX = x + layoutItem->tqsizeHint().width() + spacing();
|
|
|
|
|
int nextX = x + layoutItem->tqsizeHint().width();
|
|
|
|
|
if(nextX - spacing() > rect.right() && height > 0) {
|
|
|
|
|
// next line
|
|
|
|
|
x = rect.x(); // reset x
|
|
|
|
|
//y = y + height + spacing(); // new y
|
|
|
|
|
y = y + height; // new y
|
|
|
|
|
//nextX = x + tqlayoutItem->tqsizeHint().width() + spacing(); // next x
|
|
|
|
|
nextX = x + tqlayoutItem->tqsizeHint().width(); // next x
|
|
|
|
|
//nextX = x + layoutItem->tqsizeHint().width() + spacing(); // next x
|
|
|
|
|
nextX = x + layoutItem->tqsizeHint().width(); // next x
|
|
|
|
|
height = 0; // reset height for the next line
|
|
|
|
|
}
|
|
|
|
|
const int itemHeight = tqlayoutItem->tqsizeHint().height();
|
|
|
|
|
const int itemHeight = layoutItem->tqsizeHint().height();
|
|
|
|
|
if(!testOnly)
|
|
|
|
|
tqlayoutItem->setGeometry(TQRect(x, y, rect.right(), itemHeight));
|
|
|
|
|
layoutItem->setGeometry(TQRect(x, y, rect.right(), itemHeight));
|
|
|
|
|
x = nextX;
|
|
|
|
|
height = TQMAX(height, itemHeight);
|
|
|
|
|
}
|
|
|
|
|