1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
15 * The Original Code is mozilla.org code.
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
24 * Alternatively, the contents of this file may be used under the terms of
25 * either of the GNU General Public License Version 2 or later (the "GPL"),
26 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
36 * ***** END LICENSE BLOCK ***** */
38 #ifndef nsScrollPortView_h___
39 #define nsScrollPortView_h___
42 #include "nsIScrollableView.h"
46 class nsISupportsArray
;
49 //this is a class that acts as a container for other views and provides
50 //automatic management of scrolling of the views it contains.
52 class nsScrollPortView
: public nsView
, public nsIScrollableView
55 nsScrollPortView(nsViewManager
* aViewManager
= nsnull
);
57 virtual nsIScrollableView
* ToScrollableView() { return this; }
59 NS_IMETHOD
QueryInterface(REFNSIID aIID
,
62 //nsIScrollableView interface
63 NS_IMETHOD
CreateScrollControls(nsNativeWidget aNative
= nsnull
);
64 NS_IMETHOD
GetContainerSize(nscoord
*aWidth
, nscoord
*aHeight
) const;
65 NS_IMETHOD
SetScrolledView(nsIView
*aScrolledView
);
66 NS_IMETHOD
GetScrolledView(nsIView
*&aScrolledView
) const;
68 NS_IMETHOD
GetScrollPosition(nscoord
&aX
, nscoord
&aY
) const;
69 NS_IMETHOD
ScrollTo(nscoord aX
, nscoord aY
, PRUint32 aUpdateFlags
);
70 NS_IMETHOD
SetScrollProperties(PRUint32 aProperties
);
71 NS_IMETHOD
GetScrollProperties(PRUint32
*aProperties
);
72 NS_IMETHOD
SetLineHeight(nscoord aHeight
);
73 NS_IMETHOD
GetLineHeight(nscoord
*aHeight
);
74 NS_IMETHOD
ScrollByLines(PRInt32 aNumLinesX
, PRInt32 aNumLinesY
,
75 PRUint32 aUpdateFlags
= 0);
76 NS_IMETHOD
GetPageScrollDistances(nsSize
*aDistances
);
77 NS_IMETHOD
ScrollByPages(PRInt32 aNumPagesX
, PRInt32 aNumPagesY
,
78 PRUint32 aUpdateFlags
= 0);
79 NS_IMETHOD
ScrollByWhole(PRBool aTop
, PRUint32 aUpdateFlags
= 0);
80 NS_IMETHOD
ScrollByPixels(PRInt32 aNumPixelsX
, PRInt32 aNumPixelsY
,
81 PRUint32 aUpdateFlags
= 0);
82 NS_IMETHOD
CanScroll(PRBool aHorizontal
, PRBool aForward
, PRBool
&aResult
);
84 NS_IMETHOD_(nsIView
*) View();
86 NS_IMETHOD
AddScrollPositionListener(nsIScrollPositionListener
* aListener
);
87 NS_IMETHOD
RemoveScrollPositionListener(nsIScrollPositionListener
* aListener
);
89 // local to the view module
91 nsView
* GetScrolledView() const { return GetFirstChild(); }
94 NS_IMETHOD
ScrollToImpl(nscoord aX
, nscoord aY
);
97 AsyncScroll
* mAsyncScroll
;
100 void IncrementalScroll();
101 PRBool
IsSmoothScrollingEnabled();
102 static void AsyncScrollCallback(nsITimer
*aTimer
, void* aSPV
);
105 virtual ~nsScrollPortView();
108 void Scroll(nsView
*aScrolledView
, nsPoint aTwipsDelta
, nsPoint aPixDelta
, PRInt32 p2a
);
109 PRBool
CannotBitBlt(nsView
* aScrolledView
);
111 nscoord mOffsetX
, mOffsetY
;
112 nscoord mDestinationX
, mDestinationY
;
113 PRUint32 mScrollProperties
;
115 nsISupportsArray
*mListeners
;