ctkSimpleLayoutManager.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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 QWidget* createWidget() = 0;
  25. };
  26. /// \ingroup Widgets
  27. template<class T>
  28. struct ctkTemplateInstanciator:public ctkWidgetInstanciator
  29. {
  30. virtual QWidget* createWidget() {return new T;}
  31. };
  32. /// \ingroup Widgets
  33. /// Utility class to access control on the DomDocument layout
  34. class CTK_WIDGETS_EXPORT ctkSimpleLayoutManager: public ctkLayoutManager
  35. {
  36. Q_OBJECT
  37. public:
  38. ctkSimpleLayoutManager(QObject* parent = 0);
  39. explicit ctkSimpleLayoutManager(QWidget* viewport, QObject* parent);
  40. virtual ~ctkSimpleLayoutManager();
  41. using ctkLayoutManager::setLayout;
  42. using ctkLayoutManager::layout;
  43. // Note the default constructor of the class must be declared with
  44. // Q_INVOKABLE.
  45. //void setViewMetaObject(const QMetaObject& viewMetaObject);
  46. //const QMetaObject viewMetaObject()const;
  47. void setViewInstanciator(ctkWidgetInstanciator* instanciator);
  48. ctkWidgetInstanciator* viewInstanciator()const;
  49. protected:
  50. virtual QWidget* viewFromXML(QDomElement viewElement);
  51. private:
  52. Q_DECLARE_PRIVATE(ctkSimpleLayoutManager);
  53. Q_DISABLE_COPY(ctkSimpleLayoutManager);
  54. };
  55. #endif