1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
|
/****************************************************************************
** $Id: qt/examples/customlayout/border.h 2.3.1 edited 2001-01-26 $
**
** Definition of simple flow layout for custom layout example
**
** Created : 979899
**
** Copyright (C) 1997 by Trolltech AS. All rights reserved.
**
** This file is part of an example program for Qt. This example
** program may be used, distributed and modified without limitation.
**
*****************************************************************************/
#ifndef BORDER_H
#define BORDER_H
#include <qlayout.h>
#include <qlist.h>
class BorderWidgetItem : public QWidgetItem
{
public:
BorderWidgetItem( QWidget *w )
: QWidgetItem( w )
{}
void setGeometry( const QRect &r )
{ widget()->setGeometry( r ); }
};
class BorderLayout : public QLayout
{
public:
enum Position {
West = 0,
North,
South,
East,
Center
};
struct BorderLayoutStruct
{
BorderLayoutStruct( QLayoutItem *i, Position p ) {
item = i;
pos = p;
}
QLayoutItem *item;
Position pos;
};
enum SizeType {
Minimum = 0,
SizeHint
};
BorderLayout( QWidget *parent, int border = 0, int autoBorder = -1,
const char *name = 0 )
: QLayout( parent, border, autoBorder, name ), cached( 0, 0 ), mcached( 0, 0 ),
sizeDirty( TRUE ), msizeDirty( TRUE )
{}
BorderLayout( QLayout* parent, int autoBorder = -1, const char *name = 0 )
: QLayout( parent, autoBorder, name ), cached( 0, 0 ), mcached( 0, 0 ),
sizeDirty( TRUE ), msizeDirty( TRUE )
{}
BorderLayout( int autoBorder = -1, const char *name = 0 )
: QLayout( autoBorder, name ), cached( 0, 0 ), mcached( 0, 0 ),
sizeDirty( TRUE ), msizeDirty( TRUE )
{}
~BorderLayout();
void addItem( QLayoutItem *item );
void addWidget( QWidget *widget, Position pos );
void add( QLayoutItem *item, Position pos );
bool hasHeightForWidth() const;
QSize sizeHint() const;
QSize minimumSize() const;
QLayoutIterator iterator();
QSizePolicy::ExpandData expanding() const;
protected:
void setGeometry( const QRect &rect );
private:
void doLayout( const QRect &rect, bool testonly = FALSE );
void calcSize( SizeType st );
QList<BorderLayoutStruct> list;
QSize cached, mcached;
bool sizeDirty, msizeDirty;
};
#endif
|