QtLayout.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef QTFLOWLAYOUT_H
00030 #define QTFLOWLAYOUT_H
00031
00032 #include <casa/aips.h>
00033
00034 #include <graphics/X11/X_enter.h>
00035 # include <QLayout>
00036 # include <QRect>
00037 # include <QWidgetItem>
00038 #include <graphics/X11/X_exit.h>
00039
00040
00041 namespace casa {
00042
00043
00044
00045 class QtFlowLayout : public QLayout {
00046 public:
00047 QtFlowLayout(QWidget *parent, int margin = 0, int spacing = -1);
00048 QtFlowLayout(int spacing = -1);
00049 ~QtFlowLayout();
00050
00051 void addItem(QLayoutItem *item);
00052 Qt::Orientations expandingDirections() const;
00053 bool hasHeightForWidth() const;
00054 int heightForWidth(int) const;
00055 int count() const;
00056 QLayoutItem *itemAt(int index) const;
00057 QSize minimumSize() const;
00058 void setGeometry(const QRect &rect);
00059 QSize sizeHint() const;
00060 QLayoutItem *takeAt(int index);
00061
00062 private:
00063 int doLayout(const QRect &rect, bool testOnly) const;
00064
00065 QList<QLayoutItem *> itemList;
00066 };
00067
00068
00069 class QtBorderLayout : public QLayout {
00070 public:
00071 enum Position { West, North, South, East, Center };
00072
00073 QtBorderLayout(QWidget *parent, int margin = 0, int spacing = -1);
00074 QtBorderLayout(int spacing = -1);
00075 ~QtBorderLayout();
00076
00077 void addItem(QLayoutItem *item);
00078 void addWidget(QWidget *widget, Position position);
00079 Qt::Orientations expandingDirections() const;
00080 bool hasHeightForWidth() const;
00081 int count() const;
00082 QLayoutItem *itemAt(int index) const;
00083 QSize minimumSize() const;
00084 void setGeometry(const QRect &rect);
00085 QSize sizeHint() const;
00086 QLayoutItem *takeAt(int index);
00087
00088 void add(QLayoutItem *item, Position position);
00089
00090 private:
00091 struct ItemWrapper {
00092 ItemWrapper(QLayoutItem *i, Position p) {
00093 item = i;
00094 position = p;
00095 }
00096
00097 QLayoutItem *item;
00098 Position position;
00099 };
00100
00101 enum SizeType { MinimumSize, SizeHint };
00102 QSize calculateSize(SizeType sizeType) const;
00103
00104 QList<ItemWrapper *> list;
00105 };
00106
00107 }
00108
00109 #endif