ctkExpandButton.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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 __ctkExpandButton_h
  15. #define __ctkExpandButton_h
  16. // QT includes
  17. #include <QToolButton>
  18. // CTK includes
  19. #include <ctkPimpl.h>
  20. #include "ctkWidgetsExport.h"
  21. class ctkExpandButtonPrivate;
  22. /// \ingroup Widgets
  23. /// QToolButton with a standard icon
  24. /// This button has the same behavior as the extension
  25. /// button which appear as the last item in the toolbar
  26. /// ctkButton's purpose is to show, if the button is checked
  27. /// or hide, some others widgets.
  28. /// we can set the orientation of the icon with setOrientation()
  29. /// the widget can also mirror the icon on click if mirrorOnExpand is true.
  30. class CTK_WIDGETS_EXPORT ctkExpandButton
  31. : public QToolButton
  32. {
  33. Q_OBJECT
  34. Q_PROPERTY(bool mirrorOnExpand READ mirrorOnExpand WRITE setMirrorOnExpand)
  35. public:
  36. /// Superclass typedef
  37. typedef QToolButton Superclass;
  38. explicit ctkExpandButton(QWidget *_parent = 0);
  39. virtual ~ctkExpandButton();
  40. void setMirrorOnExpand(bool newBehavior);
  41. bool mirrorOnExpand() const;
  42. void setOrientation(Qt::Orientation newOrientation);
  43. Qt::Orientation orientation() const;
  44. virtual QSize sizeHint() const;
  45. private Q_SLOTS:
  46. void updateIcon(Qt::LayoutDirection newDirection);
  47. protected:
  48. virtual void nextCheckState();
  49. protected:
  50. QScopedPointer<ctkExpandButtonPrivate> d_ptr;
  51. private:
  52. Q_DECLARE_PRIVATE(ctkExpandButton);
  53. Q_DISABLE_COPY(ctkExpandButton);
  54. };
  55. #endif