ctkMenuButton.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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 __ctkMenuButton_h
  15. #define __ctkMenuButton_h
  16. // Qt includes
  17. #include <QPushButton>
  18. // CTK includes
  19. #include <ctkPimpl.h>
  20. #include "ctkWidgetsExport.h"
  21. class ctkMenuButtonPrivate;
  22. /// Description
  23. /// ctkMenuButton is a QPushButton that separates the clickable area for
  24. /// poping up the optional QMenu from the traditional area of the QPushButton.
  25. /// The menu indicator in the button has its own button and clicking it pops
  26. /// up the menu.
  27. /// ctkMenuButton makes sense only if a QMenu is set.
  28. class CTK_WIDGETS_EXPORT ctkMenuButton : public QPushButton
  29. {
  30. Q_OBJECT
  31. public:
  32. ctkMenuButton(QWidget *parent = 0);
  33. ctkMenuButton(const QString& text, QWidget *parent = 0);
  34. virtual ~ctkMenuButton();
  35. /// Reimplemented for internal reasons
  36. virtual QSize minimumSizeHint()const;
  37. /// Reimplemented for internal reasons
  38. virtual QSize sizeHint()const;
  39. protected:
  40. /// Reimplemented for internal reasons
  41. virtual void paintEvent(QPaintEvent*);
  42. /// Reimplemented for internal reasons
  43. virtual void mousePressEvent(QMouseEvent* event);
  44. /// Reimplemented for internal reasons
  45. virtual bool hitButton(const QPoint & pos) const;
  46. /// Reimplemented for internal reasons
  47. virtual void initStyleOption ( QStyleOptionButton * option ) const;
  48. protected:
  49. QScopedPointer<ctkMenuButtonPrivate> d_ptr;
  50. private:
  51. Q_DECLARE_PRIVATE(ctkMenuButton);
  52. Q_DISABLE_COPY(ctkMenuButton);
  53. };
  54. #endif