ctkFlowLayout.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*=========================================================================
  2. Library: CTK
  3. Copyright (c) Kitware Inc.
  4. Licensed under the Apache License, Version 2.0 (the "License");
  5. you may not use this file except in compliance with the License.
  6. You may obtain a copy of the License at
  7. http://www.commontk.org/LICENSE
  8. Unless required by applicable law or agreed to in writing, software
  9. distributed under the License is distributed on an "AS IS" BASIS,
  10. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. See the License for the specific language governing permissions and
  12. limitations under the License.
  13. =========================================================================*/
  14. #ifndef __ctkFlowLayout_h
  15. #define __ctkFlowLayout_h
  16. // Qt includes
  17. #include <QLayout>
  18. // CTK includes
  19. #include "ctkWidgetsExport.h"
  20. class ctkFlowLayoutPrivate;
  21. /// Warning the Vertical orientation is NOT fully supported. You can obtain
  22. /// strange behavior
  23. class CTK_WIDGETS_EXPORT ctkFlowLayout : public QLayout
  24. {
  25. Q_OBJECT
  26. Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation)
  27. Q_PROPERTY(int horizontalSpacing READ horizontalSpacing WRITE setHorizontalSpacing)
  28. Q_PROPERTY(int verticalSpacing READ verticalSpacing WRITE setVerticalSpacing)
  29. Q_PROPERTY(bool alignItems READ alignItems WRITE setAlignItems)
  30. Q_PROPERTY(Qt::Orientations preferredExpandingDirections READ preferredExpandingDirections WRITE setPreferredExpandingDirections)
  31. public:
  32. typedef QLayout Superclass;
  33. explicit ctkFlowLayout(Qt::Orientation orientation, QWidget* parent = 0);
  34. explicit ctkFlowLayout(QWidget* parent);
  35. explicit ctkFlowLayout();
  36. virtual ~ctkFlowLayout();
  37. void setOrientation(Qt::Orientation orientation);
  38. Qt::Orientation orientation()const;
  39. void setPreferredExpandingDirections(Qt::Orientations directions);
  40. Qt::Orientations preferredExpandingDirections()const;
  41. int horizontalSpacing() const;
  42. void setHorizontalSpacing(int);
  43. int verticalSpacing() const;
  44. void setVerticalSpacing(int);
  45. bool alignItems()const;
  46. void setAlignItems(bool);
  47. virtual void addItem(QLayoutItem *item);
  48. virtual Qt::Orientations expandingDirections() const;
  49. virtual bool hasHeightForWidth() const;
  50. virtual int heightForWidth(int) const;
  51. virtual int count() const;
  52. virtual QLayoutItem *itemAt(int index) const;
  53. virtual QSize minimumSize() const;
  54. virtual void setGeometry(const QRect &rect);
  55. virtual QSize sizeHint() const;
  56. virtual QLayoutItem *takeAt(int index);
  57. protected:
  58. QScopedPointer<ctkFlowLayoutPrivate> d_ptr;
  59. private:
  60. Q_DECLARE_PRIVATE(ctkFlowLayout);
  61. Q_DISABLE_COPY(ctkFlowLayout);
  62. };
  63. #endif