casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
QtLayout.h
Go to the documentation of this file.
00001 //# QtLayout.h: Qt definition of the flow-layout and borderlayout.
00002 //# Copyright (C) 2005
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //#
00005 //# This library is free software; you can redistribute it and/or modify it
00006 //# under the terms of the GNU Library General Public License as published by
00007 //# the Free Software Foundation; either version 2 of the License, or (at your
00008 //# option) any later version.
00009 //#
00010 //# This library is distributed in the hope that it will be useful, but WITHOUT
00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00013 //# License for more details.
00014 //#
00015 //# You should have received a copy of the GNU Library General Public License
00016 //# along with this library; if not, write to the Free Software Foundation,
00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00018 //#
00019 //# Correspondence concerning AIPS++ should be addressed as follows:
00020 //#        Internet email: aips2-request@nrao.edu.
00021 //#        Postal address: AIPS++ Project Office
00022 //#                        National Radio Astronomy Observatory
00023 //#                        520 Edgemont Road
00024 //#                        Charlottesville, VA 22903-2475 USA
00025 //#
00026 //# $Id$
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 { //# NAMESPACE CASA - BEGIN
00042 
00043 
00044 
00045 class QtFlowLayout : public QLayout
00046     {
00047     public:
00048         QtFlowLayout(QWidget *parent, int margin = 0, int spacing = -1);
00049         QtFlowLayout(int spacing = -1);
00050         ~QtFlowLayout();
00051 
00052         void addItem(QLayoutItem *item);
00053         Qt::Orientations expandingDirections() const;
00054         bool hasHeightForWidth() const;
00055         int heightForWidth(int) const;
00056         int count() const;
00057         QLayoutItem *itemAt(int index) const;
00058         QSize minimumSize() const;
00059         void setGeometry(const QRect &rect);
00060         QSize sizeHint() const;
00061         QLayoutItem *takeAt(int index);
00062 
00063     private:
00064         int doLayout(const QRect &rect, bool testOnly) const;
00065 
00066         QList<QLayoutItem *> itemList;
00067 };
00068 
00069 
00070 class QtBorderLayout : public QLayout
00071 {
00072 public:
00073     enum Position { West, North, South, East, Center };
00074 
00075     QtBorderLayout(QWidget *parent, int margin = 0, int spacing = -1);
00076     QtBorderLayout(int spacing = -1);
00077     ~QtBorderLayout();
00078 
00079     void addItem(QLayoutItem *item);
00080     void addWidget(QWidget *widget, Position position);
00081     Qt::Orientations expandingDirections() const;
00082     bool hasHeightForWidth() const;
00083     int count() const;
00084     QLayoutItem *itemAt(int index) const;
00085     QSize minimumSize() const;
00086     void setGeometry(const QRect &rect);
00087     QSize sizeHint() const;
00088     QLayoutItem *takeAt(int index);
00089 
00090     void add(QLayoutItem *item, Position position);
00091 
00092 private:
00093     struct ItemWrapper
00094     {
00095         ItemWrapper(QLayoutItem *i, Position p) {
00096             item = i;
00097             position = p;
00098         }
00099 
00100         QLayoutItem *item;
00101         Position position;
00102     };
00103 
00104     enum SizeType { MinimumSize, SizeHint };
00105     QSize calculateSize(SizeType sizeType) const;
00106 
00107     QList<ItemWrapper *> list;
00108 };
00109 
00110 } //# NAMESPACE CASA - END
00111 
00112 #endif