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