ctkDynamicSpacer.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*=========================================================================
  2. Library: CTK
  3. Copyright (c) Kitware Inc.
  4. All rights reserved.
  5. Distributed under a BSD License. See LICENSE.txt file.
  6. This software is distributed "AS IS" WITHOUT ANY WARRANTY; without even
  7. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the above copyright notice for more information.
  9. =========================================================================*/
  10. #ifndef __ctkDynamicSpacer_h
  11. #define __ctkDynamicSpacer_h
  12. // Qt includes
  13. #include <QWidget>
  14. // CTK includes
  15. #include <ctkPimpl.h>
  16. #include "CTKWidgetsExport.h"
  17. class ctkDynamicSpacerPrivate;
  18. /// Description
  19. /// A Menu widget that show/hide its children depending on its checked/collapsed properties
  20. class CTK_WIDGETS_EXPORT ctkDynamicSpacer : public QWidget
  21. {
  22. Q_OBJECT
  23. Q_PROPERTY(QSizePolicy activeSizePolicy READ activeSizePolicy WRITE setActiveSizePolicy);
  24. Q_PROPERTY(QSizePolicy inactiveSizePolicy READ inactiveSizePolicy WRITE setInactiveSizePolicy);
  25. public:
  26. ctkDynamicSpacer(QWidget *parent = 0);
  27. virtual ~ctkDynamicSpacer();
  28. QSizePolicy activeSizePolicy() const;
  29. void setActiveSizePolicy(QSizePolicy sizePolicy);
  30. inline void setActiveSizePolicy(QSizePolicy::Policy horizontal, QSizePolicy::Policy vertical);
  31. QSizePolicy inactiveSizePolicy() const;
  32. void setInactiveSizePolicy(QSizePolicy sizePolicy);
  33. inline void setInactiveSizePolicy(QSizePolicy::Policy horizontal, QSizePolicy::Policy vertical);
  34. public slots:
  35. void activate(bool enable);
  36. private:
  37. CTK_DECLARE_PRIVATE(ctkDynamicSpacer);
  38. };
  39. void ctkDynamicSpacer::setActiveSizePolicy(QSizePolicy::Policy horizontal, QSizePolicy::Policy vertical)
  40. {
  41. this->setActiveSizePolicy(QSizePolicy(horizontal, vertical));
  42. }
  43. #endif