diff options
author | Timothy Pearson <[email protected]> | 2011-07-10 15:24:15 -0500 |
---|---|---|
committer | Timothy Pearson <[email protected]> | 2011-07-10 15:24:15 -0500 |
commit | bd0f3345a938b35ce6a12f6150373b0955b8dd12 (patch) | |
tree | 7a520322212d48ebcb9fbe1087e7fca28b76185c /examples/customlayout/border.h | |
download | qt3-bd0f3345a938b35ce6a12f6150373b0955b8dd12.tar.gz qt3-bd0f3345a938b35ce6a12f6150373b0955b8dd12.zip |
Add Qt3 development HEAD version
Diffstat (limited to 'examples/customlayout/border.h')
-rw-r--r-- | examples/customlayout/border.h | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/examples/customlayout/border.h b/examples/customlayout/border.h new file mode 100644 index 0000000..bb4d3a7 --- /dev/null +++ b/examples/customlayout/border.h @@ -0,0 +1,104 @@ +/**************************************************************************** +** +** Definition of simple flow layout for custom layout example +** +** Created : 979899 +** +** Copyright (C) 1997-2008 Trolltech ASA. 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 <qptrlist.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 ); + + QPtrList<BorderLayoutStruct> list; + QSize cached, mcached; + bool sizeDirty, msizeDirty; + +}; + +#endif |