layout/xul/nsSliderFrame.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/layout/xul/nsSliderFrame.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,185 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef nsSliderFrame_h__
    1.10 +#define nsSliderFrame_h__
    1.11 +
    1.12 +#include "mozilla/Attributes.h"
    1.13 +#include "nsRepeatService.h"
    1.14 +#include "nsBoxFrame.h"
    1.15 +#include "nsIAtom.h"
    1.16 +#include "nsCOMPtr.h"
    1.17 +#include "nsITimer.h"
    1.18 +#include "nsIDOMEventListener.h"
    1.19 +
    1.20 +class nsString;
    1.21 +class nsITimer;
    1.22 +class nsSliderFrame;
    1.23 +
    1.24 +nsIFrame* NS_NewSliderFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
    1.25 +
    1.26 +class nsSliderMediator : public nsIDOMEventListener
    1.27 +{
    1.28 +public:
    1.29 +
    1.30 +  NS_DECL_ISUPPORTS
    1.31 +
    1.32 +  nsSliderFrame* mSlider;
    1.33 +
    1.34 +  nsSliderMediator(nsSliderFrame* aSlider) {  mSlider = aSlider; }
    1.35 +  virtual ~nsSliderMediator() {}
    1.36 +
    1.37 +  virtual void SetSlider(nsSliderFrame* aSlider) { mSlider = aSlider; }
    1.38 +
    1.39 +  NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent) MOZ_OVERRIDE;
    1.40 +};
    1.41 +
    1.42 +class nsSliderFrame : public nsBoxFrame
    1.43 +{
    1.44 +public:
    1.45 +  NS_DECL_FRAMEARENA_HELPERS
    1.46 +
    1.47 +  friend class nsSliderMediator;
    1.48 +
    1.49 +  nsSliderFrame(nsIPresShell* aShell, nsStyleContext* aContext);
    1.50 +  virtual ~nsSliderFrame();
    1.51 +
    1.52 +#ifdef DEBUG_FRAME_DUMP
    1.53 +  virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE {
    1.54 +    return MakeFrameName(NS_LITERAL_STRING("SliderFrame"), aResult);
    1.55 +  }
    1.56 +#endif
    1.57 +
    1.58 +  virtual nsSize GetPrefSize(nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE;
    1.59 +  virtual nsSize GetMinSize(nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE;
    1.60 +  virtual nsSize GetMaxSize(nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE;
    1.61 +  NS_IMETHOD DoLayout(nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE;
    1.62 +
    1.63 +  // nsIFrame overrides
    1.64 +  virtual nsresult  AppendFrames(ChildListID     aListID,
    1.65 +                                 nsFrameList&    aFrameList) MOZ_OVERRIDE;
    1.66 +
    1.67 +  virtual nsresult  InsertFrames(ChildListID     aListID,
    1.68 +                                 nsIFrame*       aPrevFrame,
    1.69 +                                 nsFrameList&    aFrameList) MOZ_OVERRIDE;
    1.70 +
    1.71 +  virtual nsresult  RemoveFrame(ChildListID     aListID,
    1.72 +                                nsIFrame*       aOldFrame) MOZ_OVERRIDE;
    1.73 +
    1.74 +  virtual void DestroyFrom(nsIFrame* aDestructRoot) MOZ_OVERRIDE;
    1.75 +
    1.76 +  virtual void BuildDisplayListForChildren(nsDisplayListBuilder*   aBuilder,
    1.77 +                                           const nsRect&           aDirtyRect,
    1.78 +                                           const nsDisplayListSet& aLists) MOZ_OVERRIDE;
    1.79 +
    1.80 +  virtual void BuildDisplayList(nsDisplayListBuilder*   aBuilder,
    1.81 +                                const nsRect&           aDirtyRect,
    1.82 +                                const nsDisplayListSet& aLists) MOZ_OVERRIDE;
    1.83 + 
    1.84 +  virtual nsresult AttributeChanged(int32_t aNameSpaceID,
    1.85 +                                    nsIAtom* aAttribute,
    1.86 +                                    int32_t aModType) MOZ_OVERRIDE;
    1.87 +
    1.88 +  virtual void Init(nsIContent*      aContent,
    1.89 +                    nsIFrame*        aParent,
    1.90 +                    nsIFrame*        asPrevInFlow) MOZ_OVERRIDE;
    1.91 +
    1.92 +
    1.93 +  virtual nsresult HandleEvent(nsPresContext* aPresContext,
    1.94 +                               mozilla::WidgetGUIEvent* aEvent,
    1.95 +                               nsEventStatus* aEventStatus) MOZ_OVERRIDE;
    1.96 +
    1.97 +  virtual nsresult SetInitialChildList(ChildListID     aListID,
    1.98 +                                       nsFrameList&    aChildList) MOZ_OVERRIDE;
    1.99 +
   1.100 +  virtual nsIAtom* GetType() const MOZ_OVERRIDE;
   1.101 +
   1.102 +  nsresult StartDrag(nsIDOMEvent* aEvent);
   1.103 +
   1.104 +  static int32_t GetCurrentPosition(nsIContent* content);
   1.105 +  static int32_t GetMinPosition(nsIContent* content);
   1.106 +  static int32_t GetMaxPosition(nsIContent* content);
   1.107 +  static int32_t GetIncrement(nsIContent* content);
   1.108 +  static int32_t GetPageIncrement(nsIContent* content);
   1.109 +  static int32_t GetIntegerAttribute(nsIContent* content, nsIAtom* atom, int32_t defaultValue);
   1.110 +  void EnsureOrient();
   1.111 +
   1.112 +  NS_IMETHOD HandlePress(nsPresContext* aPresContext,
   1.113 +                         mozilla::WidgetGUIEvent* aEvent,
   1.114 +                         nsEventStatus* aEventStatus) MOZ_OVERRIDE;
   1.115 +
   1.116 +  NS_IMETHOD HandleMultiplePress(nsPresContext* aPresContext,
   1.117 +                                 mozilla::WidgetGUIEvent* aEvent,
   1.118 +                                 nsEventStatus* aEventStatus,
   1.119 +                                 bool aControlHeld) MOZ_OVERRIDE
   1.120 +  {
   1.121 +    return NS_OK;
   1.122 +  }
   1.123 +
   1.124 +  NS_IMETHOD HandleDrag(nsPresContext* aPresContext,
   1.125 +                        mozilla::WidgetGUIEvent* aEvent,
   1.126 +                        nsEventStatus* aEventStatus) MOZ_OVERRIDE
   1.127 +  {
   1.128 +    return NS_OK;
   1.129 +  }
   1.130 +
   1.131 +  NS_IMETHOD HandleRelease(nsPresContext* aPresContext,
   1.132 +                           mozilla::WidgetGUIEvent* aEvent,
   1.133 +                           nsEventStatus* aEventStatus) MOZ_OVERRIDE;
   1.134 +
   1.135 +private:
   1.136 +
   1.137 +  bool GetScrollToClick();
   1.138 +  nsIFrame* GetScrollbar();
   1.139 +  bool ShouldScrollForEvent(mozilla::WidgetGUIEvent* aEvent);
   1.140 +  bool ShouldScrollToClickForEvent(mozilla::WidgetGUIEvent* aEvent);
   1.141 +  bool IsEventOverThumb(mozilla::WidgetGUIEvent* aEvent);
   1.142 +
   1.143 +  void PageUpDown(nscoord change);
   1.144 +  void SetCurrentThumbPosition(nsIContent* aScrollbar, nscoord aNewPos, bool aIsSmooth,
   1.145 +                               bool aMaySnap);
   1.146 +  void SetCurrentPosition(nsIContent* aScrollbar, int32_t aNewPos, bool aIsSmooth);
   1.147 +  void SetCurrentPositionInternal(nsIContent* aScrollbar, int32_t pos,
   1.148 +                                  bool aIsSmooth);
   1.149 +  void CurrentPositionChanged();
   1.150 +
   1.151 +  void DragThumb(bool aGrabMouseEvents);
   1.152 +  void AddListener();
   1.153 +  void RemoveListener();
   1.154 +  bool isDraggingThumb();
   1.155 +
   1.156 +  void StartRepeat() {
   1.157 +    nsRepeatService::GetInstance()->Start(Notify, this);
   1.158 +  }
   1.159 +  void StopRepeat() {
   1.160 +    nsRepeatService::GetInstance()->Stop(Notify, this);
   1.161 +  }
   1.162 +  void Notify();
   1.163 +  static void Notify(void* aData) {
   1.164 +    (static_cast<nsSliderFrame*>(aData))->Notify();
   1.165 +  }
   1.166 + 
   1.167 +  nsPoint mDestinationPoint;
   1.168 +  nsRefPtr<nsSliderMediator> mMediator;
   1.169 +
   1.170 +  float mRatio;
   1.171 +
   1.172 +  nscoord mDragStart;
   1.173 +  nscoord mThumbStart;
   1.174 +
   1.175 +  int32_t mCurPos;
   1.176 +
   1.177 +  nscoord mChange;
   1.178 +
   1.179 +  // true if an attribute change has been caused by the user manipulating the
   1.180 +  // slider. This allows notifications to tell how a slider's current position
   1.181 +  // was changed.
   1.182 +  bool mUserChanged;
   1.183 +
   1.184 +  static bool gMiddlePref;
   1.185 +  static int32_t gSnapMultiplier;
   1.186 +}; // class nsSliderFrame
   1.187 +
   1.188 +#endif

mercurial