Hydra 0.20
hydra.src/desktop/FlowLayout.h
00001 
00002 /*
00003  * Copyright (c) 2009 Aleksander B. Demko
00004  * This source code is distributed under the MIT license.
00005  * See the accompanying file LICENSE.MIT.txt for details.
00006  */
00007 
00008 #ifndef __INCLUDED_HYDRADESKTOP_FLOWLAYOUT_H__
00009 #define __INCLUDED_HYDRADESKTOP_FLOWLAYOUT_H__
00010 
00011 #include <vector>
00012 
00013 #include <QLayout>
00014 
00015 namespace desktop
00016 {
00017   class FlowLayout;
00018 }
00019 
00020 class desktop::FlowLayout : public QLayout
00021 {
00022   public:
00023     FlowLayout(bool horizorder);
00024     virtual ~FlowLayout();
00025 
00026     virtual bool hasHeightForWidth(void) const;
00027     virtual int heightForWidth(int w) const;
00028 
00029     virtual int count(void) const { return static_cast<int>(dm_items.size()); }
00030     virtual void addItem(QLayoutItem *item);
00031     virtual QSize sizeHint() const;
00032     virtual QSize minimumSize() const;
00033     virtual QLayoutItem *itemAt(int index) const;
00034     virtual QLayoutItem *takeAt(int index);
00035     virtual void setGeometry(const QRect &rect);
00036 
00037     void insertWidget(int indexAt, QWidget *widget);
00038 
00039     QRect boundingBox(void) const { return dm_boundingBox; }
00040 
00041   private:
00042     int & fastPoint(QPoint &p) const;
00043     int fastPoint(const QPoint &p) const;
00044     int & slowPoint(QPoint &p) const;
00045     int slowPoint(const QPoint &p) const;
00046     int fastSize(const QSize &s) const;
00047     int slowSize(const QSize &s) const;
00048 
00049     QRect computeLayout(const QRect &rect, bool performSetGeometry) const;
00050 
00051   private:
00052     bool dm_horizorder;
00053 
00054     std::vector<QLayoutItem*> dm_items;
00055 
00056     QRect dm_boundingBox;
00057 };
00058 
00059 #endif
00060 
 All Classes Namespaces Functions Variables