2001-09-28 20:14:13 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
1999-04-20 21:39:52 +00:00
|
|
|
|
1999-04-20 21:43:09 +00:00
|
|
|
#ifndef nsSliderFrame_h__
|
|
|
|
#define nsSliderFrame_h__
|
1999-04-20 21:39:52 +00:00
|
|
|
|
2008-02-15 02:04:34 +00:00
|
|
|
#include "nsRepeatService.h"
|
2000-03-31 07:02:06 +00:00
|
|
|
#include "nsBoxFrame.h"
|
1999-04-20 21:39:52 +00:00
|
|
|
#include "prtypes.h"
|
|
|
|
#include "nsIAtom.h"
|
|
|
|
#include "nsCOMPtr.h"
|
2002-09-07 05:38:16 +00:00
|
|
|
#include "nsITimer.h"
|
2011-06-28 17:59:14 +00:00
|
|
|
#include "nsIDOMEventListener.h"
|
1999-04-20 21:39:52 +00:00
|
|
|
|
|
|
|
class nsString;
|
1999-08-19 22:16:23 +00:00
|
|
|
class nsITimer;
|
2000-04-26 04:00:29 +00:00
|
|
|
class nsSliderFrame;
|
1999-08-19 22:16:23 +00:00
|
|
|
|
2006-03-26 21:30:36 +00:00
|
|
|
nsIFrame* NS_NewSliderFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
|
1999-04-20 21:39:52 +00:00
|
|
|
|
2011-06-28 17:59:14 +00:00
|
|
|
class nsSliderMediator : public nsIDOMEventListener
|
2000-04-26 04:00:29 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
|
|
|
nsSliderFrame* mSlider;
|
|
|
|
|
2003-01-08 21:19:10 +00:00
|
|
|
nsSliderMediator(nsSliderFrame* aSlider) { mSlider = aSlider; }
|
2000-04-26 04:00:29 +00:00
|
|
|
virtual ~nsSliderMediator() {}
|
|
|
|
|
|
|
|
virtual void SetSlider(nsSliderFrame* aSlider) { mSlider = aSlider; }
|
|
|
|
|
2011-06-28 17:59:14 +00:00
|
|
|
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent);
|
2008-02-15 02:04:34 +00:00
|
|
|
};
|
2000-04-26 04:00:29 +00:00
|
|
|
|
|
|
|
class nsSliderFrame : public nsBoxFrame
|
1999-04-20 21:39:52 +00:00
|
|
|
{
|
|
|
|
public:
|
2009-09-12 16:49:24 +00:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS
|
|
|
|
|
2003-09-14 01:25:04 +00:00
|
|
|
friend class nsSliderMediator;
|
|
|
|
|
2006-03-26 21:30:36 +00:00
|
|
|
nsSliderFrame(nsIPresShell* aShell, nsStyleContext* aContext);
|
1999-08-19 22:16:23 +00:00
|
|
|
virtual ~nsSliderFrame();
|
1999-04-20 21:39:52 +00:00
|
|
|
|
1999-11-01 22:12:45 +00:00
|
|
|
#ifdef DEBUG
|
2001-11-14 01:33:42 +00:00
|
|
|
NS_IMETHOD GetFrameName(nsAString& aResult) const {
|
|
|
|
return MakeFrameName(NS_LITERAL_STRING("SliderFrame"), aResult);
|
1999-04-20 21:39:52 +00:00
|
|
|
}
|
1999-11-01 22:12:45 +00:00
|
|
|
#endif
|
1999-06-15 04:02:43 +00:00
|
|
|
|
2007-01-08 02:57:59 +00:00
|
|
|
virtual nsSize GetPrefSize(nsBoxLayoutState& aBoxLayoutState);
|
|
|
|
virtual nsSize GetMinSize(nsBoxLayoutState& aBoxLayoutState);
|
|
|
|
virtual nsSize GetMaxSize(nsBoxLayoutState& aBoxLayoutState);
|
2000-07-07 22:24:06 +00:00
|
|
|
NS_IMETHOD DoLayout(nsBoxLayoutState& aBoxLayoutState);
|
2000-03-31 07:02:06 +00:00
|
|
|
|
1999-11-01 22:12:45 +00:00
|
|
|
// nsIFrame overrides
|
2011-08-24 20:54:30 +00:00
|
|
|
NS_IMETHOD AppendFrames(ChildListID aListID,
|
2009-07-30 17:23:32 +00:00
|
|
|
nsFrameList& aFrameList);
|
2001-01-11 01:56:27 +00:00
|
|
|
|
2011-08-24 20:54:30 +00:00
|
|
|
NS_IMETHOD InsertFrames(ChildListID aListID,
|
2001-01-11 01:56:27 +00:00
|
|
|
nsIFrame* aPrevFrame,
|
2009-07-30 17:23:32 +00:00
|
|
|
nsFrameList& aFrameList);
|
2001-01-11 01:56:27 +00:00
|
|
|
|
2011-08-24 20:54:30 +00:00
|
|
|
NS_IMETHOD RemoveFrame(ChildListID aListID,
|
2001-01-11 01:56:27 +00:00
|
|
|
nsIFrame* aOldFrame);
|
|
|
|
|
2009-12-24 05:21:15 +00:00
|
|
|
virtual void DestroyFrom(nsIFrame* aDestructRoot);
|
1999-08-29 10:51:15 +00:00
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
NS_IMETHOD BuildDisplayListForChildren(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists);
|
|
|
|
|
|
|
|
NS_IMETHOD BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists);
|
1999-06-15 04:02:43 +00:00
|
|
|
|
2005-09-07 16:49:21 +00:00
|
|
|
NS_IMETHOD AttributeChanged(PRInt32 aNameSpaceID,
|
1999-06-15 04:02:43 +00:00
|
|
|
nsIAtom* aAttribute,
|
2003-07-11 21:16:12 +00:00
|
|
|
PRInt32 aModType);
|
1999-06-15 04:02:43 +00:00
|
|
|
|
2006-03-09 18:55:21 +00:00
|
|
|
NS_IMETHOD Init(nsIContent* aContent,
|
1999-06-15 04:02:43 +00:00
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIFrame* asPrevInFlow);
|
|
|
|
|
|
|
|
|
2004-07-31 23:15:21 +00:00
|
|
|
NS_IMETHOD HandleEvent(nsPresContext* aPresContext,
|
1999-06-15 04:02:43 +00:00
|
|
|
nsGUIEvent* aEvent,
|
1999-11-24 06:03:41 +00:00
|
|
|
nsEventStatus* aEventStatus);
|
1999-06-15 04:02:43 +00:00
|
|
|
|
2011-08-24 20:54:30 +00:00
|
|
|
NS_IMETHOD SetInitialChildList(ChildListID aListID,
|
2009-07-28 12:53:20 +00:00
|
|
|
nsFrameList& aChildList);
|
1999-06-15 04:02:43 +00:00
|
|
|
|
2007-05-25 10:09:29 +00:00
|
|
|
virtual nsIAtom* GetType() const;
|
|
|
|
|
2012-07-09 16:55:35 +00:00
|
|
|
nsresult StartDrag(nsIDOMEvent* aEvent);
|
1999-06-15 04:02:43 +00:00
|
|
|
|
|
|
|
static PRInt32 GetCurrentPosition(nsIContent* content);
|
2006-05-30 13:50:48 +00:00
|
|
|
static PRInt32 GetMinPosition(nsIContent* content);
|
1999-06-15 04:02:43 +00:00
|
|
|
static PRInt32 GetMaxPosition(nsIContent* content);
|
|
|
|
static PRInt32 GetIncrement(nsIContent* content);
|
|
|
|
static PRInt32 GetPageIncrement(nsIContent* content);
|
|
|
|
static PRInt32 GetIntegerAttribute(nsIContent* content, nsIAtom* atom, PRInt32 defaultValue);
|
2000-03-31 07:02:06 +00:00
|
|
|
void EnsureOrient();
|
1999-06-15 04:02:43 +00:00
|
|
|
|
2004-07-31 23:15:21 +00:00
|
|
|
NS_IMETHOD HandlePress(nsPresContext* aPresContext,
|
1999-08-19 22:16:23 +00:00
|
|
|
nsGUIEvent * aEvent,
|
1999-11-24 06:03:41 +00:00
|
|
|
nsEventStatus* aEventStatus);
|
1999-08-19 22:16:23 +00:00
|
|
|
|
2004-07-31 23:15:21 +00:00
|
|
|
NS_IMETHOD HandleMultiplePress(nsPresContext* aPresContext,
|
2009-07-28 12:53:20 +00:00
|
|
|
nsGUIEvent * aEvent,
|
|
|
|
nsEventStatus* aEventStatus,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aControlHeld) { return NS_OK; }
|
1999-08-19 22:16:23 +00:00
|
|
|
|
2011-08-03 03:39:02 +00:00
|
|
|
NS_IMETHOD HandleDrag(nsPresContext* aPresContext,
|
|
|
|
nsGUIEvent * aEvent,
|
|
|
|
nsEventStatus* aEventStatus) { return NS_OK; }
|
|
|
|
|
2004-07-31 23:15:21 +00:00
|
|
|
NS_IMETHOD HandleRelease(nsPresContext* aPresContext,
|
1999-08-19 22:16:23 +00:00
|
|
|
nsGUIEvent * aEvent,
|
1999-11-24 06:03:41 +00:00
|
|
|
nsEventStatus* aEventStatus);
|
1999-08-19 22:16:23 +00:00
|
|
|
|
1999-06-15 04:02:43 +00:00
|
|
|
private:
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool GetScrollToClick();
|
2012-08-06 03:00:57 +00:00
|
|
|
nsIFrame* GetScrollbar();
|
2000-03-31 07:02:06 +00:00
|
|
|
|
2007-04-09 22:39:57 +00:00
|
|
|
void PageUpDown(nscoord change);
|
2011-09-29 06:19:26 +00:00
|
|
|
void SetCurrentThumbPosition(nsIContent* aScrollbar, nscoord aNewPos, bool aIsSmooth,
|
|
|
|
bool aImmediateRedraw, bool aMaySnap);
|
|
|
|
void SetCurrentPosition(nsIContent* aScrollbar, PRInt32 aNewPos, bool aIsSmooth,
|
|
|
|
bool aImmediateRedraw);
|
2008-02-07 05:28:15 +00:00
|
|
|
void SetCurrentPositionInternal(nsIContent* aScrollbar, PRInt32 pos,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aIsSmooth, bool aImmediateRedraw);
|
2007-05-25 10:09:29 +00:00
|
|
|
nsresult CurrentPositionChanged(nsPresContext* aPresContext,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aImmediateRedraw);
|
2012-07-09 16:55:35 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
void DragThumb(bool aGrabMouseEvents);
|
1999-06-15 04:02:43 +00:00
|
|
|
void AddListener();
|
|
|
|
void RemoveListener();
|
2011-09-29 06:19:26 +00:00
|
|
|
bool isDraggingThumb();
|
1999-06-15 04:02:43 +00:00
|
|
|
|
2008-02-15 02:04:34 +00:00
|
|
|
void StartRepeat() {
|
|
|
|
nsRepeatService::GetInstance()->Start(Notify, this);
|
|
|
|
}
|
|
|
|
void StopRepeat() {
|
|
|
|
nsRepeatService::GetInstance()->Stop(Notify, this);
|
|
|
|
}
|
|
|
|
void Notify();
|
|
|
|
static void Notify(void* aData) {
|
|
|
|
(static_cast<nsSliderFrame*>(aData))->Notify();
|
|
|
|
}
|
|
|
|
|
2009-05-12 10:13:09 +00:00
|
|
|
nsPoint mDestinationPoint;
|
|
|
|
nsRefPtr<nsSliderMediator> mMediator;
|
|
|
|
|
1999-06-15 04:02:43 +00:00
|
|
|
float mRatio;
|
|
|
|
|
2004-08-28 11:41:02 +00:00
|
|
|
nscoord mDragStart;
|
1999-06-15 04:02:43 +00:00
|
|
|
nscoord mThumbStart;
|
1999-04-20 21:39:52 +00:00
|
|
|
|
1999-06-23 17:00:17 +00:00
|
|
|
PRInt32 mCurPos;
|
|
|
|
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-09 22:02:40 +00:00
|
|
|
nscoord mChange;
|
|
|
|
|
2009-01-14 18:21:58 +00:00
|
|
|
// true if an attribute change has been caused by the user manipulating the
|
|
|
|
// slider. This allows notifications to tell how a slider's current position
|
|
|
|
// was changed.
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mUserChanged;
|
2009-01-14 18:21:58 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
static bool gMiddlePref;
|
2004-01-27 05:19:57 +00:00
|
|
|
static PRInt32 gSnapMultiplier;
|
1999-04-20 21:43:09 +00:00
|
|
|
}; // class nsSliderFrame
|
1999-04-20 21:39:52 +00:00
|
|
|
|
|
|
|
#endif
|