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 /**
7 
8   Eric D Vaughan
9   This class lays out its children either vertically or horizontally
10 
11 **/
12 
13 #ifndef nsScrollbarButtonFrame_h___
14 #define nsScrollbarButtonFrame_h___
15 
16 #include "mozilla/Attributes.h"
17 #include "nsButtonBoxFrame.h"
18 #include "nsITimer.h"
19 #include "nsRepeatService.h"
20 
21 class nsScrollbarButtonFrame : public nsButtonBoxFrame
22 {
23 public:
24   NS_DECL_FRAMEARENA_HELPERS
25 
nsScrollbarButtonFrame(nsStyleContext * aContext)26   explicit nsScrollbarButtonFrame(nsStyleContext* aContext):
27     nsButtonBoxFrame(aContext), mCursorOnThis(false) {}
28 
29   // Overrides
30   virtual void DestroyFrom(nsIFrame* aDestructRoot) override;
31 
32   friend nsIFrame* NS_NewScrollbarButtonFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
33 
34   virtual nsresult HandleEvent(nsPresContext* aPresContext,
35                                mozilla::WidgetGUIEvent* aEvent,
36                                nsEventStatus* aEventStatus) override;
37 
38   static nsresult GetChildWithTag(nsIAtom* atom, nsIFrame* start, nsIFrame*& result);
39   static nsresult GetParentWithTag(nsIAtom* atom, nsIFrame* start, nsIFrame*& result);
40 
41   bool HandleButtonPress(nsPresContext* aPresContext,
42                          mozilla::WidgetGUIEvent* aEvent,
43                          nsEventStatus* aEventStatus);
44 
HandleMultiplePress(nsPresContext * aPresContext,mozilla::WidgetGUIEvent * aEvent,nsEventStatus * aEventStatus,bool aControlHeld)45   NS_IMETHOD HandleMultiplePress(nsPresContext* aPresContext,
46                                  mozilla::WidgetGUIEvent* aEvent,
47                                  nsEventStatus* aEventStatus,
48                                  bool aControlHeld) override
49  {
50    return NS_OK;
51  }
52 
HandleDrag(nsPresContext * aPresContext,mozilla::WidgetGUIEvent * aEvent,nsEventStatus * aEventStatus)53   NS_IMETHOD HandleDrag(nsPresContext* aPresContext,
54                         mozilla::WidgetGUIEvent* aEvent,
55                         nsEventStatus* aEventStatus) override
56   {
57     return NS_OK;
58   }
59 
60   NS_IMETHOD HandleRelease(nsPresContext* aPresContext,
61                            mozilla::WidgetGUIEvent* aEvent,
62                            nsEventStatus* aEventStatus) override;
63 
64 protected:
65   virtual void MouseClicked(mozilla::WidgetGUIEvent* aEvent) override;
66 
StartRepeat()67   void StartRepeat() {
68     nsRepeatService::GetInstance()->Start(Notify, this);
69   }
StopRepeat()70   void StopRepeat() {
71     nsRepeatService::GetInstance()->Stop(Notify, this);
72   }
73   void Notify();
Notify(void * aData)74   static void Notify(void* aData) {
75     static_cast<nsScrollbarButtonFrame*>(aData)->Notify();
76   }
77 
78   bool mCursorOnThis;
79 };
80 
81 #endif
82