ctkCheckBox.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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 __ctkCheckBox_h
  15. #define __ctkCheckBox_h
  16. // QT includes
  17. #include <QCheckBox>
  18. // CTK includes
  19. #include "ctkWidgetsExport.h"
  20. class ctkCheckBoxPrivate;
  21. /// ctkCheckBox is an advanced QCheckBox that gives more control
  22. /// over its look and feel.
  23. /// We can change the indicator check box by a new QIcon, with two mode On/Off.
  24. /// The indicator icon size can be controled. see setIndicatorIconSize()
  25. class CTK_WIDGETS_EXPORT ctkCheckBox : public QCheckBox
  26. {
  27. Q_OBJECT
  28. Q_PROPERTY(QIcon indicatorIcon READ indicatorIcon WRITE setIndicatorIcon)
  29. Q_PROPERTY(QSize indicatorIconSize READ indicatorIconSize WRITE setIndicatorIconSize)
  30. public:
  31. typedef QCheckBox Superclass;
  32. ctkCheckBox(QWidget *_parent);
  33. virtual ~ctkCheckBox();
  34. void setIndicatorIcon(const QIcon& newIcon);
  35. QIcon indicatorIcon() const;
  36. /// Resize the indicator icon to Qsize.
  37. /// If newSize is bigger than the indicator icon's maximum size,
  38. /// The icon will get the icon's maximum size and not newSize.
  39. void setIndicatorIconSize(const QSize& newSize);
  40. QSize indicatorIconSize() const;
  41. protected:
  42. QScopedPointer<ctkCheckBoxPrivate> d_ptr;
  43. private:
  44. Q_DECLARE_PRIVATE(ctkCheckBox);
  45. Q_DISABLE_COPY(ctkCheckBox);
  46. };
  47. #endif