ctkSimpleLayoutManager.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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.apache.org/licenses/LICENSE-2.0.txt
  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 __ctkSimpleLayoutManager_h
  15. #define __ctkSimpleLayoutManager_h
  16. // Qt includes
  17. #include <QMetaObject>
  18. // CTK includes
  19. #include "ctkLayoutManager.h"
  20. class ctkSimpleLayoutManagerPrivate;
  21. /// \ingroup Widgets
  22. struct ctkWidgetInstanciator
  23. {
  24. virtual void beginSetupLayout(){}
  25. virtual void endSetupLayout(){}
  26. virtual QWidget* createWidget() = 0;
  27. };
  28. /// \ingroup Widgets
  29. template<class T>
  30. struct ctkTemplateInstanciator:public ctkWidgetInstanciator
  31. {
  32. virtual QWidget* createWidget() {return new T;}
  33. };
  34. /// \ingroup Widgets
  35. /// Utility class to access control on the DomDocument layout
  36. class CTK_WIDGETS_EXPORT ctkSimpleLayoutManager: public ctkLayoutManager
  37. {
  38. Q_OBJECT
  39. public:
  40. ctkSimpleLayoutManager(QObject* parent = 0);
  41. explicit ctkSimpleLayoutManager(QWidget* viewport, QObject* parent);
  42. virtual ~ctkSimpleLayoutManager();
  43. using ctkLayoutManager::setLayout;
  44. using ctkLayoutManager::layout;
  45. // Note the default constructor of the class must be declared with
  46. // Q_INVOKABLE.
  47. //void setViewMetaObject(const QMetaObject& viewMetaObject);
  48. //const QMetaObject viewMetaObject()const;
  49. void setViewInstanciator(ctkWidgetInstanciator* instanciator);
  50. ctkWidgetInstanciator* viewInstanciator()const;
  51. protected:
  52. virtual QWidget* viewFromXML(QDomElement viewElement);
  53. virtual void setupLayout();
  54. private:
  55. Q_DECLARE_PRIVATE(ctkSimpleLayoutManager);
  56. Q_DISABLE_COPY(ctkSimpleLayoutManager);
  57. };
  58. #endif