ctkPushButton.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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 __ctkPushButton_h
  15. #define __ctkPushButton_h
  16. // Qt includes
  17. #include <QPushButton>
  18. // CTK includes
  19. #include <ctkPimpl.h>
  20. #include "ctkWidgetsExport.h"
  21. class ctkPushButtonPrivate;
  22. /// \ingroup Widgets
  23. /// Description
  24. /// ctkPushButton is an advanced QPushButton. It can control the alignment of text and icons.
  25. class CTK_WIDGETS_EXPORT ctkPushButton : public QPushButton
  26. {
  27. Q_OBJECT
  28. /// Set the alignment of the text on the button,
  29. /// Qt::AlignHCenter|Qt::AlignVCenter by default.
  30. /// \sa textAlignment(), setTextAlignment(), iconAlignment
  31. Q_PROPERTY(Qt::Alignment buttonTextAlignment READ buttonTextAlignment WRITE setButtonTextAlignment)
  32. /// Set the alignment of the icon with regard to the text.
  33. /// Qt::AlignLeft|Qt::AlignVCenter by default.
  34. /// \sa iconAlignment(), setIconAlignment(), textAlignment
  35. Q_PROPERTY(Qt::Alignment iconAlignment READ iconAlignment WRITE setIconAlignment)
  36. public:
  37. ctkPushButton(QWidget *parent = 0);
  38. ctkPushButton(const QString& text, QWidget *parent = 0);
  39. ctkPushButton(const QIcon& icon, const QString& text, QWidget *parent = 0);
  40. virtual ~ctkPushButton();
  41. /// Set the buttonTextAlignment property value.
  42. /// \sa buttonTextAlignment
  43. void setButtonTextAlignment(Qt::Alignment buttonTextAlignment);
  44. /// Return the buttonTextAlignment property value.
  45. /// \sa buttonTextAlignment
  46. Qt::Alignment buttonTextAlignment()const;
  47. /// Set the iconAlignment property value.
  48. /// \sa iconAlignment
  49. void setIconAlignment(Qt::Alignment iconAlignment);
  50. /// Return the iconAlignment property value.
  51. /// \sa iconAlignment
  52. Qt::Alignment iconAlignment()const;
  53. virtual QSize minimumSizeHint()const;
  54. virtual QSize sizeHint()const;
  55. protected:
  56. /// Reimplemented for internal reasons
  57. virtual void paintEvent(QPaintEvent*);
  58. protected:
  59. QScopedPointer<ctkPushButtonPrivate> d_ptr;
  60. ctkPushButton(ctkPushButtonPrivate*, QWidget* parent = 0);
  61. private:
  62. Q_DECLARE_PRIVATE(ctkPushButton);
  63. Q_DISABLE_COPY(ctkPushButton);
  64. };
  65. #endif