ctkBasePopupWidget_p.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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 __ctkBasePopupWidget_p_h
  15. #define __ctkBasePopupWidget_p_h
  16. // Qt includes
  17. #include <QPointer>
  18. class QLabel;
  19. class QPropertyAnimation;
  20. // CTK includes
  21. #include "ctkBasePopupWidget.h"
  22. #define PopupWindowType Qt::Tool
  23. // -------------------------------------------------------------------------
  24. /// \ingroup Widgets
  25. class CTK_WIDGETS_EXPORT ctkBasePopupWidgetPrivate
  26. : public QObject
  27. {
  28. Q_OBJECT
  29. Q_DECLARE_PUBLIC(ctkBasePopupWidget);
  30. protected:
  31. ctkBasePopupWidget* const q_ptr;
  32. public:
  33. ctkBasePopupWidgetPrivate(ctkBasePopupWidget& object);
  34. ~ctkBasePopupWidgetPrivate();
  35. virtual void init();
  36. bool isOpening()const;
  37. bool isClosing()const;
  38. /// Return true if the animation was closing (direction == backward).
  39. /// It doesn't indicate if the action is still running or finished.
  40. /// Can only be called in a slot as it uses sender().
  41. bool wasClosing()const;
  42. bool fitBaseWidgetSize()const;
  43. Qt::Alignment pixmapAlignment()const;
  44. void setupPopupPixmapWidget();
  45. QWidgetList focusWidgets(bool onlyVisible = false)const;
  46. // Return the widget if the mouse cursor is above any of the focus widgets or their
  47. // children.
  48. virtual QWidget* mouseOver();
  49. // Same as QWidget::isAncestorOf() but don't restrain to the same window
  50. // and apply it to all the focusWidgets
  51. bool isAncestorOf(const QWidget* ancestor, const QWidget* child)const;
  52. /// Return the closed geometry for the popup based on the current geometry
  53. QRect closedGeometry()const;
  54. /// Return the closed geometry for a given open geometry
  55. QRect closedGeometry(QRect openGeom)const;
  56. /// Return the desired geometry, maybe it won't happen if the size is too
  57. /// small for the popup.
  58. QRect desiredOpenGeometry()const;
  59. QRect desiredOpenGeometry(QRect baseGeometry)const;
  60. QRect baseGeometry()const;
  61. QPoint mapToGlobal(const QPoint& baseWidgetPoint)const;
  62. QPropertyAnimation* currentAnimation()const;
  63. //void temporarilyHiddenOn();
  64. //void temporarilyHiddenOff();
  65. void hideAll();
  66. protected:
  67. QPointer<QWidget> BaseWidget;
  68. double EffectAlpha;
  69. ctkBasePopupWidget::AnimationEffect Effect;
  70. int EffectDuration;
  71. QPropertyAnimation* AlphaAnimation;
  72. bool ForcedTranslucent;
  73. QPropertyAnimation* ScrollAnimation;
  74. QLabel* PopupPixmapWidget;
  75. // Geometry attributes
  76. Qt::Alignment Alignment;
  77. Qt::Orientations Orientations;
  78. ctkBasePopupWidget::VerticalDirection VerticalDirection;
  79. Qt::LayoutDirection HorizontalDirection;
  80. };
  81. #endif