ctkLayoutManager.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 __ctkLayoutManager_h
  15. #define __ctkLayoutManager_h
  16. // Qt includes
  17. #include <QObject>
  18. #include <QDomDocument>
  19. class QLayoutItem;
  20. // CTK includes
  21. #include "ctkWidgetsExport.h"
  22. class ctkLayoutManagerPrivate;
  23. /// ctkLayoutManager is
  24. class CTK_WIDGETS_EXPORT ctkLayoutManager: public QObject
  25. {
  26. Q_OBJECT
  27. public:
  28. /// Constructor
  29. ctkLayoutManager(QObject* parent = 0);
  30. explicit ctkLayoutManager(QWidget* viewport, QObject* parent);
  31. /// Destructor
  32. virtual ~ctkLayoutManager();
  33. void setViewport(QWidget* widget);
  34. QWidget* viewport()const;
  35. void refresh();
  36. public slots:
  37. signals:
  38. void layoutChanged();
  39. protected:
  40. QScopedPointer<ctkLayoutManagerPrivate> d_ptr;
  41. ctkLayoutManager(ctkLayoutManagerPrivate* ptr, QWidget* viewport, QObject* parent);
  42. virtual void onViewportChanged();
  43. void clearLayout();
  44. void setupLayout();
  45. virtual void setLayout(const QDomDocument& newLayout);
  46. const QDomDocument layout()const;
  47. virtual QLayoutItem* processElement(QDomElement element);
  48. virtual QLayoutItem* processLayoutElement(QDomElement layoutElement);
  49. virtual QLayoutItem* layoutFromXML(QDomElement layoutElement);
  50. virtual void processItemElement(QDomElement layoutElement, QLayoutItem* layoutItem);
  51. virtual QWidget* processViewElement(QDomElement layoutElement);
  52. virtual QWidget* viewFromXML(QDomElement layoutElement);
  53. private:
  54. Q_DECLARE_PRIVATE(ctkLayoutManager);
  55. Q_DISABLE_COPY(ctkLayoutManager);
  56. };
  57. #endif