nsScrollbarButtonFrame.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. /**
  6. Eric D Vaughan
  7. This class lays out its children either vertically or horizontally
  8. **/
  9. #ifndef nsScrollbarButtonFrame_h___
  10. #define nsScrollbarButtonFrame_h___
  11. #include "mozilla/Attributes.h"
  12. #include "nsButtonBoxFrame.h"
  13. #include "nsITimer.h"
  14. #include "nsRepeatService.h"
  15. class nsScrollbarButtonFrame : public nsButtonBoxFrame
  16. {
  17. public:
  18. NS_DECL_FRAMEARENA_HELPERS
  19. explicit nsScrollbarButtonFrame(nsStyleContext* aContext):
  20. nsButtonBoxFrame(aContext), mCursorOnThis(false) {}
  21. // Overrides
  22. virtual void DestroyFrom(nsIFrame* aDestructRoot) override;
  23. friend nsIFrame* NS_NewScrollbarButtonFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
  24. virtual nsresult HandleEvent(nsPresContext* aPresContext,
  25. mozilla::WidgetGUIEvent* aEvent,
  26. nsEventStatus* aEventStatus) override;
  27. static nsresult GetChildWithTag(nsIAtom* atom, nsIFrame* start, nsIFrame*& result);
  28. static nsresult GetParentWithTag(nsIAtom* atom, nsIFrame* start, nsIFrame*& result);
  29. bool HandleButtonPress(nsPresContext* aPresContext,
  30. mozilla::WidgetGUIEvent* aEvent,
  31. nsEventStatus* aEventStatus);
  32. NS_IMETHOD HandleMultiplePress(nsPresContext* aPresContext,
  33. mozilla::WidgetGUIEvent* aEvent,
  34. nsEventStatus* aEventStatus,
  35. bool aControlHeld) override
  36. {
  37. return NS_OK;
  38. }
  39. NS_IMETHOD HandleDrag(nsPresContext* aPresContext,
  40. mozilla::WidgetGUIEvent* aEvent,
  41. nsEventStatus* aEventStatus) override
  42. {
  43. return NS_OK;
  44. }
  45. NS_IMETHOD HandleRelease(nsPresContext* aPresContext,
  46. mozilla::WidgetGUIEvent* aEvent,
  47. nsEventStatus* aEventStatus) override;
  48. protected:
  49. virtual void MouseClicked(mozilla::WidgetGUIEvent* aEvent) override;
  50. void StartRepeat() {
  51. nsRepeatService::GetInstance()->Start(Notify, this);
  52. }
  53. void StopRepeat() {
  54. nsRepeatService::GetInstance()->Stop(Notify, this);
  55. }
  56. void Notify();
  57. static void Notify(void* aData) {
  58. static_cast<nsScrollbarButtonFrame*>(aData)->Notify();
  59. }
  60. bool mCursorOnThis;
  61. };
  62. #endif