ctkPopupWidget_p.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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 __ctkPopupWidget_p_h
  15. #define __ctkPopupWidget_p_h
  16. // Qt includes
  17. class QPropertyAnimation;
  18. class QLabel;
  19. // CTK includes
  20. #include "ctkPopupWidget.h"
  21. // -------------------------------------------------------------------------
  22. class CTK_WIDGETS_EXPORT ctkPopupWidgetPrivate: public QObject
  23. {
  24. Q_OBJECT
  25. Q_DECLARE_PUBLIC(ctkPopupWidget);
  26. protected:
  27. ctkPopupWidget* const q_ptr;
  28. public:
  29. ctkPopupWidgetPrivate(ctkPopupWidget& object);
  30. ~ctkPopupWidgetPrivate();
  31. void init();
  32. bool isOpening()const;
  33. bool isClosing()const;
  34. bool fitBaseWidgetSize()const;
  35. Qt::Alignment pixmapAlignment()const;
  36. void setupPopupPixmapWidget();
  37. QList<const QWidget*> focusWidgets(bool onlyVisible = false)const;
  38. // Return true if the mouse cursor is above any of the focus widgets or their
  39. // children.
  40. // If the cursor is above a child widget, install the event filter to listen
  41. // when the cursor leaves the widget.
  42. bool mouseOver();
  43. // Same as QWidget::isAncestorOf() but don't restrain to the same window
  44. // and apply it to all the focusWidgets
  45. bool isAncestorOf(const QWidget* ancestor, const QWidget* child)const;
  46. /// Return the closed geometry for the popup based on the current geometry
  47. QRect closedGeometry()const;
  48. /// Return the closed geometry for a given open geometry
  49. QRect closedGeometry(QRect openGeom)const;
  50. /// Return the desired geometry, maybe it won't happen if the size is too
  51. /// small for the popup.
  52. QRect desiredOpenGeometry()const;
  53. QPropertyAnimation* currentAnimation()const;
  54. virtual bool eventFilter(QObject* obj, QEvent* event);
  55. void temporarilyHiddenOn();
  56. void temporarilyHiddenOff();
  57. public slots:
  58. void updateVisibility();
  59. void onBaseWidgetDestroyed();
  60. void onApplicationDeactivate();
  61. protected:
  62. QWidget* BaseWidget;
  63. bool AutoShow;
  64. bool AutoHide;
  65. double EffectAlpha;
  66. ctkPopupWidget::AnimationEffect Effect;
  67. QPropertyAnimation* AlphaAnimation;
  68. bool ForcedTranslucent;
  69. QPropertyAnimation* ScrollAnimation;
  70. QLabel* PopupPixmapWidget;
  71. // Geometry attributes
  72. Qt::Alignment Alignment;
  73. Qt::Orientations Orientations;
  74. ctkPopupWidget::VerticalDirection VerticalDirection;
  75. Qt::LayoutDirection HorizontalDirection;
  76. };
  77. #endif