• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2010 Google Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are
6  * met:
7  *
8  *     * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *     * Redistributions in binary form must reproduce the above
11  * copyright notice, this list of conditions and the following disclaimer
12  * in the documentation and/or other materials provided with the
13  * distribution.
14  *     * Neither the name of Google Inc. nor the names of its
15  * contributors may be used to endorse or promote products derived from
16  * this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30 
31 #ifndef WebScrollbar_h
32 #define WebScrollbar_h
33 
34 #include "WebCanvas.h"
35 #include "WebCommon.h"
36 
37 namespace WebKit {
38 
39 class WebInputEvent;
40 class WebScrollbarClient;
41 struct WebRect;
42 
43 class WebScrollbar {
44 public:
45     enum Orientation {
46         Horizontal,
47         Vertical
48     };
49 
50     enum ScrollDirection {
51         ScrollBackward,
52         ScrollForward
53     };
54 
55     enum ScrollGranularity {
56         ScrollByLine,
57         ScrollByPage,
58         ScrollByDocument,
59         ScrollByPixel
60     };
61 
62     // Creates a WebScrollbar.
63     WEBKIT_API static WebScrollbar* create(WebScrollbarClient*, Orientation);
64 
~WebScrollbar()65     virtual ~WebScrollbar() {}
66 
67     // Gets the thickness of the scrollbar in pixels.
68     WEBKIT_API static int defaultThickness();
69 
70     // Sets the rectangle of the scrollbar.
71     virtual void setLocation(const WebRect&) = 0;
72 
73     // Gets the current value (i.e. position inside the region).
74     virtual int value() const = 0;
75 
76     // Sets the current value.
77     virtual void setValue(int position) = 0;
78 
79     // Sets the size of the scrollable region in pixels.  i.e. if a document is
80     // 800x10000 pixels and the viewport is 1000x1000 pixels, then setLocation
81     // for the vertical scrollbar would have passed in a rectangle like:
82     //            (800 - defaultThickness(), 0) (defaultThickness() x 10000)
83     // and setDocumentSize(10000)
84     virtual void setDocumentSize(int size) = 0;
85 
86     // Scroll back or forward with the given granularity.
87     virtual void scroll(ScrollDirection, ScrollGranularity, float multiplier) = 0;
88 
89     // Paint the given rectangle.
90     virtual void paint(WebCanvas*, const WebRect&) = 0;
91 
92     // Returns true iff the given event was used.
93     virtual bool handleInputEvent(const WebInputEvent&) = 0;
94 };
95 
96 } // namespace WebKit
97 
98 #endif
99