From 7794b9b80ea2effceefaca9d52e3f11d7db0ad44 Mon Sep 17 00:00:00 2001 From: "hyatt%netscape.com" Date: Wed, 23 Jun 1999 17:00:17 +0000 Subject: [PATCH] Tweaks to the scrollbar. --- layout/xul/base/src/nsIScrollbarListener.h | 3 +-- layout/xul/base/src/nsSliderFrame.cpp | 23 +++++++++++++++++++++- layout/xul/base/src/nsSliderFrame.h | 6 ++++++ 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/layout/xul/base/src/nsIScrollbarListener.h b/layout/xul/base/src/nsIScrollbarListener.h index b5999b69386..200b7541153 100644 --- a/layout/xul/base/src/nsIScrollbarListener.h +++ b/layout/xul/base/src/nsIScrollbarListener.h @@ -34,8 +34,7 @@ public: NS_IMETHOD PositionChanged(PRInt32 aOldIndex, PRInt32 aNewIndex) = 0; - NS_IMETHOD PagedUp() = 0; - NS_IMETHOD PagedDown() = 0; + NS_IMETHOD PagedUpDown() = 0; }; #endif diff --git a/layout/xul/base/src/nsSliderFrame.cpp b/layout/xul/base/src/nsSliderFrame.cpp index 0c891e18f80..99db3902cd4 100644 --- a/layout/xul/base/src/nsSliderFrame.cpp +++ b/layout/xul/base/src/nsSliderFrame.cpp @@ -48,7 +48,7 @@ #include "nsDocument.h" #include "nsTitledButtonFrame.h" #include "nsScrollbarButtonFrame.h" - +#include "nsIScrollbarListener.h" nsresult NS_NewSliderFrame ( nsIFrame** aNewFrame ) @@ -68,6 +68,7 @@ NS_NewSliderFrame ( nsIFrame** aNewFrame ) nsSliderFrame::nsSliderFrame() +:mScrollbarListener(nsnull), mCurPos(0) { } @@ -455,6 +456,10 @@ nsSliderFrame::PageUpDown(nsIPresContext& aPresContext, nsIFrame* aThumbFrame, n // asking it for the current position and the page increment. If we are not in a scrollbar we will // get the values from our own node. nsIContent* scrollbar = GetScrollBar(); + + if (mScrollbarListener) + mScrollbarListener->PagedUpDown(); // Let the listener decide our increment. + nscoord pageIncrement = GetPageIncrement(scrollbar); PRInt32 curpos = GetCurrentPosition(scrollbar); SetCurrentPosition(aPresContext, scrollbar, aThumbFrame, curpos + change*pageIncrement); @@ -516,6 +521,12 @@ nsSliderFrame::CurrentPositionChanged(nsIPresContext* aPresContext) // redraw just the change Invalidate(changeRect, PR_TRUE); + + if (mScrollbarListener) + mScrollbarListener->PositionChanged(mCurPos, curpos); + + mCurPos = curpos; + } void @@ -527,6 +538,7 @@ nsSliderFrame::SetCurrentPosition(nsIPresContext& aPresContext, nsIContent* scro nscoord onePixel = NSIntPixelsToTwips(1, p2t); // get our current position and max position from our content node + PRInt32 curpos = GetCurrentPosition(scrollbar); PRInt32 maxpos = GetMaxPosition(scrollbar); // get the new position and make sure it is in bounds @@ -541,6 +553,8 @@ nsSliderFrame::SetCurrentPosition(nsIPresContext& aPresContext, nsIContent* scro // set the new position scrollbar->SetAttribute(kNameSpaceID_None, nsXULAtoms::curpos, nsString(ch), PR_TRUE); + CurrentPositionChanged(&aPresContext); + printf("Current Pos=%d\n",newpos); } @@ -759,3 +773,10 @@ nsSliderFrame::Release(void) { return NS_OK; } + +void +nsSliderFrame::SetScrollbarListener(nsIScrollbarListener* aListener) +{ + // Don't addref/release this, since it's actually a frame. + mScrollbarListener = aListener; +} diff --git a/layout/xul/base/src/nsSliderFrame.h b/layout/xul/base/src/nsSliderFrame.h index f9f933d8100..01ffef5528a 100644 --- a/layout/xul/base/src/nsSliderFrame.h +++ b/layout/xul/base/src/nsSliderFrame.h @@ -31,6 +31,7 @@ #include "nsIDOMMouseListener.h" class nsString; +class nsIScrollbarListener; nsresult NS_NewSliderFrame(nsIFrame** aResult) ; @@ -156,6 +157,7 @@ public: static PRInt32 GetIntegerAttribute(nsIContent* content, nsIAtom* atom, PRInt32 defaultValue); static PRInt32 IsHorizontal(nsIContent* content); + void SetScrollbarListener(nsIScrollbarListener* aListener); protected: @@ -184,6 +186,10 @@ private: nscoord mDragStartPx; nscoord mThumbStart; + PRInt32 mCurPos; + + nsIScrollbarListener* mScrollbarListener; + }; // class nsSliderFrame #endif