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 nsIScrollableView_h___
39 #define nsIScrollableView_h___
44 class nsIScrollPositionListener
;
47 // IID for the nsIScrollableView interface
48 #define NS_ISCROLLABLEVIEW_IID \
49 { 0x1fcd151c, 0x5e26, 0x4c9d, \
50 { 0xa5, 0x2c, 0x87, 0x43, 0x7d, 0x7b, 0x1c, 0xe8 } }
53 * A scrolling view allows an arbitrary view that you supply to be scrolled
54 * vertically or horizontally (or both). The scrolling view creates and
55 * manages the scrollbars.
57 * You must use SetScrolledView() to specify the view that is to be scrolled,
58 * because the scrolled view is made a child of the clip view (an internal
59 * child view created by the scrolling view).
62 class nsIScrollableView
{
64 NS_DECLARE_STATIC_IID_ACCESSOR(NS_ISCROLLABLEVIEW_IID
)
67 * Create the controls used to allow scrolling. Call this method
68 * before anything else is done with the scrollable view.
69 * @param aNative native widget to use as parent for control widgets
70 * @return error status
72 NS_IMETHOD
CreateScrollControls(nsNativeWidget aNative
= nsnull
) = 0;
75 * Get the dimensions of the container
76 * @param aWidth return value for width of container
77 * @param aHeight return value for height of container
79 NS_IMETHOD
GetContainerSize(nscoord
*aWidth
, nscoord
*aHeight
) const = 0;
82 * Set the view that we are scrolling within the scrolling view.
84 NS_IMETHOD
SetScrolledView(nsIView
*aScrolledView
) = 0;
87 * Get the view that we are scrolling within the scrolling view.
90 NS_IMETHOD
GetScrolledView(nsIView
*&aScrolledView
) const = 0;
93 * Get the position of the scrolled view.
95 NS_IMETHOD
GetScrollPosition(nscoord
&aX
, nscoord
& aY
) const = 0;
98 * Scroll the view to the given x,y, update's the scrollbar's thumb
99 * positions and the view's offset. Clamps the values to be
100 * legal. Updates the display based on aUpdateFlags.
101 * @param aX left edge to scroll to
102 * @param aY top edge to scroll to
103 * @param aUpdateFlags passed onto nsIViewManager->UpdateView()
104 * @return error status
106 NS_IMETHOD
ScrollTo(nscoord aX
, nscoord aY
, PRUint32 aUpdateFlags
) = 0;
109 * Set the properties describing how scrolling can be performed
110 * in this scrollable.
111 * @param aProperties new properties
112 * @return error status
114 NS_IMETHOD
SetScrollProperties(PRUint32 aProperties
) = 0;
117 * Get the properties describing how scrolling can be performed
118 * in this scrollable.
119 * @param aProperties out parameter for current properties
120 * @return error status
122 NS_IMETHOD
GetScrollProperties(PRUint32
*aProperties
) = 0;
125 * Set the height of a line used for line scrolling.
126 * @param aHeight new line height in app units. the default
127 * height is 12 points.
128 * @return error status
130 NS_IMETHOD
SetLineHeight(nscoord aHeight
) = 0;
133 * Get the height of a line used for line scrolling.
134 * @param aHeight out parameter for line height
135 * @return error status
137 NS_IMETHOD
GetLineHeight(nscoord
*aHeight
) = 0;
140 * Scroll the view left or right by aNumLinesX columns. Positive values move right.
141 * Scroll the view up or down by aNumLinesY lines. Positive values move down.
142 * Prevents scrolling off the end of the view.
143 * @param aNumLinesX number of lines to scroll the view horizontally
144 * @param aNumLinesY number of lines to scroll the view vertically
145 * @return error status
147 NS_IMETHOD
ScrollByLines(PRInt32 aNumLinesX
, PRInt32 aNumLinexY
) = 0;
150 * Get the desired size of a page scroll in each dimension.
151 * ScrollByPages will scroll by independent multiples of these amounts
152 * unless it hits the edge of the view.
154 NS_IMETHOD
GetPageScrollDistances(nsSize
*aDistances
) = 0;
157 * Scroll the view left or right by aNumPagesX pages. Positive values move right.
158 * Scroll the view up or down by aNumPagesY pages. Positive values move down.
159 * A page is considered to be the amount displayed by the clip view.
160 * Prevents scrolling off the end of the view.
161 * @param aNumPagesX number of pages to scroll the view horizontally
162 * @param aNumPagesY number of pages to scroll the view vertically
163 * @return error status
165 NS_IMETHOD
ScrollByPages(PRInt32 aNumPagesX
, PRInt32 aNumPagesY
) = 0;
168 * Scroll the view to the top or bottom of the document depending
169 * on the value of aTop.
170 * @param aForward indicates whether to scroll to top or bottom
171 * @return error status
173 NS_IMETHOD
ScrollByWhole(PRBool aTop
) = 0;
176 * Scroll the view left or right by aNumLinesX pixels. Positive values move
177 * right. Scroll the view up or down by aNumLinesY pixels. Positive values
178 * move down. Prevents scrolling off the end of the view.
179 * @param aNumLinesX number of lines to scroll the view horizontally
180 * @param aNumLinesY number of lines to scroll the view vertically
181 * @return error status
183 NS_IMETHOD
ScrollByPixels(PRInt32 aNumPixelsX
, PRInt32 aNumPixelsY
) = 0;
186 * Check the view can scroll from current offset.
187 * @param aHorizontal If checking to Left or to Right, true. Otherwise, false.
188 * @param aForward If checking to Right or Bottom, true. Otherwise, false.
189 * @param aResult If the view can scroll, true. Otherwise, false.
190 * @return error status
192 NS_IMETHOD
CanScroll(PRBool aHorizontal
, PRBool aForward
, PRBool
&aResult
) = 0;
195 * Returns the view as an nsIView*
197 NS_IMETHOD_(nsIView
*) View() = 0;
200 * Adds a scroll position listener.
202 NS_IMETHOD
AddScrollPositionListener(nsIScrollPositionListener
* aListener
) = 0;
205 * Removes a scroll position listener.
207 NS_IMETHOD
RemoveScrollPositionListener(nsIScrollPositionListener
* aListener
) = 0;
210 NS_DEFINE_STATIC_IID_ACCESSOR(nsIScrollableView
, NS_ISCROLLABLEVIEW_IID
)
212 //regardless of the transparency or opacity settings
213 //for this view, it can always be scrolled via a blit
214 #define NS_SCROLL_PROPERTY_ALWAYS_BLIT 0x0001